Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1567807 > unrolled thread

[PATCH 01/13] mmc: bcm2835: add bcm2835_read_wait_sdcmd

Started byGerd Hoffmann <kraxel@redhat.com>
First post2017-01-27 00:40 +0100
Last post2017-01-27 11:50 +0100
Articles 6 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 01/13] mmc: bcm2835: add bcm2835_read_wait_sdcmd Gerd Hoffmann <kraxel@redhat.com> - 2017-01-27 00:40 +0100
    Re: [PATCH 01/13] mmc: bcm2835: add bcm2835_read_wait_sdcmd Florian Fainelli <f.fainelli@gmail.com> - 2017-01-27 01:00 +0100
      Re: [PATCH 01/13] mmc: bcm2835: add bcm2835_read_wait_sdcmd Gerd Hoffmann <kraxel@redhat.com> - 2017-01-27 09:10 +0100
        Re: [PATCH 01/13] mmc: bcm2835: add bcm2835_read_wait_sdcmd Florian Fainelli <f.fainelli@gmail.com> - 2017-01-27 19:30 +0100
    Re: [PATCH 01/13] mmc: bcm2835: add bcm2835_read_wait_sdcmd Shawn Lin <shawn.lin@rock-chips.com> - 2017-01-27 03:10 +0100
      Re: [PATCH 01/13] mmc: bcm2835: add bcm2835_read_wait_sdcmd Gerd Hoffmann <kraxel@redhat.com> - 2017-01-27 11:50 +0100

#1567807 — [PATCH 01/13] mmc: bcm2835: add bcm2835_read_wait_sdcmd

FromGerd Hoffmann <kraxel@redhat.com>
Date2017-01-27 00:40 +0100
Subject[PATCH 01/13] mmc: bcm2835: add bcm2835_read_wait_sdcmd
Message-ID<t41O2-5cG-15@gated-at.bofh.it>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/mmc/host/bcm2835.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c
index 9744517..ceee4cf 100644
--- a/drivers/mmc/host/bcm2835.c
+++ b/drivers/mmc/host/bcm2835.c
@@ -609,6 +609,36 @@ static void bcm2835_prepare_data(struct bcm2835_host *host,
 	writel(data->blocks, host->ioaddr + SDHBLC);
 }
 
+static u32 bcm2835_read_wait_sdcmd(struct bcm2835_host *host, u32 timeout,
+				   bool check_fail)
+{
+	struct device *dev = &host->pdev->dev;
+	unsigned long start = jiffies;
+	unsigned long fastpoll = start + usecs_to_jiffies(10);
+	unsigned long end = start + msecs_to_jiffies(timeout);
+	u32 value;
+
+	for (;;) {
+		value = readl(host->ioaddr + SDCMD);
+		if (!(value & SDCMD_NEW_FLAG))
+			break;
+		if (check_fail && (value & SDCMD_FAIL_FLAG))
+			break;
+		if (time_after(jiffies, end)) {
+			dev_err(dev, "%s: timeout (%d us)\n",
+				__func__, timeout);
+			break;
+		}
+
+		/* if it takes longer reduce poll interval */
+		if (time_after(jiffies, fastpoll))
+			udelay(10);
+		else
+			cpu_relax();
+	}
+	return value;
+}
+
 bool bcm2835_send_command(struct bcm2835_host *host,
 			  struct mmc_command *cmd)
 {
-- 
1.8.3.1

[toc] | [next] | [standalone]


#1567823

FromFlorian Fainelli <f.fainelli@gmail.com>
Date2017-01-27 01:00 +0100
Message-ID<t427n-5jj-1@gated-at.bofh.it>
In reply to#1567807
On 01/26/2017 03:37 PM, Gerd Hoffmann wrote:
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Few things with your submission:

- if you send more than one patch, a cover letter is a welcome to
explain your changes

- try to provide commit messages for things that are not obvious (in
fact, most maintainers actually request commit messages even for trivial
things)

- have not we switched to the iproc SDHCI driver, or is this for the
other SDIO connected peripherals here?

Thanks
-- 
Florian

[toc] | [prev] | [next] | [standalone]


#1567930

FromGerd Hoffmann <kraxel@redhat.com>
Date2017-01-27 09:10 +0100
Message-ID<t49Lz-1FK-3@gated-at.bofh.it>
In reply to#1567823
On Do, 2017-01-26 at 15:51 -0800, Florian Fainelli wrote:
> On 01/26/2017 03:37 PM, Gerd Hoffmann wrote:
> > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> 
> Few things with your submission:
> 
> - if you send more than one patch, a cover letter is a welcome to
> explain your changes

There actually is a cover letter.  The git-send-email "cccmd =
scripts/get_maintainer.pl" hook doesn't work for the cover letter though
because it isn't a patch.  I've hand-picked some people who
touched/reviewed the driver before to the git-send-email command line,
but everybody else got the patches only.

Anyone has a good solution for this btw?

> - try to provide commit messages for things that are not obvious (in
> fact, most maintainers actually request commit messages even for trivial
> things)

The driver is out of tree still, these are cleanups Ulf Hansson asked
for last time the driver was submitted.

Full set of patches:
  https://www.kraxel.org/cgit/linux/log/?h=bcm2837-sdhost-cleanup

Plan for upstream merge is to actually squash all the incremental
cleanups, but for now I kept them as separate changes.  I think this
makes it easier to spot mistakes and it'll also help in case there are
regressions b/c you can bisect things.

> - have not we switched to the iproc SDHCI driver, or is this for the
> other SDIO connected peripherals here?

The 2835 has two SD controllers: The Arasan SDHCI controller that we
currently use (iproc drives that one), and a custom SD controller.

This is a driver for the custom one.  Has better performance than the
sdhci controller (according to Eric Anholt).  For the rpi3 switching to
this driver has the additional advantage that we can use the iproc
driver driver to handle the wifi.

cheers,
  Gerd

[toc] | [prev] | [next] | [standalone]


#1568598

FromFlorian Fainelli <f.fainelli@gmail.com>
Date2017-01-27 19:30 +0100
Message-ID<t4jrz-7BT-5@gated-at.bofh.it>
In reply to#1567930
On 01/27/2017 12:04 AM, Gerd Hoffmann wrote:
> On Do, 2017-01-26 at 15:51 -0800, Florian Fainelli wrote:
>> On 01/26/2017 03:37 PM, Gerd Hoffmann wrote:
>>> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
>>
>> Few things with your submission:
>>
>> - if you send more than one patch, a cover letter is a welcome to
>> explain your changes
> 
> There actually is a cover letter.  The git-send-email "cccmd =
> scripts/get_maintainer.pl" hook doesn't work for the cover letter though
> because it isn't a patch.  I've hand-picked some people who
> touched/reviewed the driver before to the git-send-email command line,
> but everybody else got the patches only.
> 
> Anyone has a good solution for this btw?

Do a dry run against all patches, collect the cclist in a file, and have
a script that outputs one line, something like this:

./scripts/get_maintainer.pl patches/*.patch > cclist

cclist.sh:

#!/bin/sh
cat $(dirname $0)/cclist

git send-email --cc-cmd=cclist.sh patches/*.patch

> 
>> - try to provide commit messages for things that are not obvious (in
>> fact, most maintainers actually request commit messages even for trivial
>> things)
> 
> The driver is out of tree still, these are cleanups Ulf Hansson asked
> for last time the driver was submitted.
> 
> Full set of patches:
>   https://www.kraxel.org/cgit/linux/log/?h=bcm2837-sdhost-cleanup
> 
> Plan for upstream merge is to actually squash all the incremental
> cleanups, but for now I kept them as separate changes.  I think this
> makes it easier to spot mistakes and it'll also help in case there are
> regressions b/c you can bisect things.
> 
>> - have not we switched to the iproc SDHCI driver, or is this for the
>> other SDIO connected peripherals here?
> 
> The 2835 has two SD controllers: The Arasan SDHCI controller that we
> currently use (iproc drives that one), and a custom SD controller.
> 
> This is a driver for the custom one.  Has better performance than the
> sdhci controller (according to Eric Anholt).  For the rpi3 switching to
> this driver has the additional advantage that we can use the iproc
> driver driver to handle the wifi.

OK
-- 
Florian

[toc] | [prev] | [next] | [standalone]


#1567865

FromShawn Lin <shawn.lin@rock-chips.com>
Date2017-01-27 03:10 +0100
Message-ID<t449b-6GZ-3@gated-at.bofh.it>
In reply to#1567807
On 2017/1/27 7:37, Gerd Hoffmann wrote:
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  drivers/mmc/host/bcm2835.c | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
>
> diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c
> index 9744517..ceee4cf 100644
> --- a/drivers/mmc/host/bcm2835.c
> +++ b/drivers/mmc/host/bcm2835.c
> @@ -609,6 +609,36 @@ static void bcm2835_prepare_data(struct bcm2835_host *host,
>  	writel(data->blocks, host->ioaddr + SDHBLC);
>  }
>
> +static u32 bcm2835_read_wait_sdcmd(struct bcm2835_host *host, u32 timeout,
> +				   bool check_fail)
> +{
> +	struct device *dev = &host->pdev->dev;
> +	unsigned long start = jiffies;
> +	unsigned long fastpoll = start + usecs_to_jiffies(10);
> +	unsigned long end = start + msecs_to_jiffies(timeout);
> +	u32 value;
> +
> +	for (;;) {
> +		value = readl(host->ioaddr + SDCMD);
> +		if (!(value & SDCMD_NEW_FLAG))
> +			break;
> +		if (check_fail && (value & SDCMD_FAIL_FLAG))
> +			break;
> +		if (time_after(jiffies, end)) {
> +			dev_err(dev, "%s: timeout (%d us)\n",
> +				__func__, timeout);
> +			break;
> +		}
> +
> +		/* if it takes longer reduce poll interval */
> +		if (time_after(jiffies, fastpoll))
> +			udelay(10);
> +		else
> +			cpu_relax();
> +	}

Use readl_poll_timeout intead of open-coding them..

> +	return value;
> +}
> +
>  bool bcm2835_send_command(struct bcm2835_host *host,
>  			  struct mmc_command *cmd)
>  {
>


-- 
Best Regards
Shawn Lin

[toc] | [prev] | [next] | [standalone]


#1568036

FromGerd Hoffmann <kraxel@redhat.com>
Date2017-01-27 11:50 +0100
Message-ID<t4cgq-2YU-5@gated-at.bofh.it>
In reply to#1567865

[Multipart message — attachments visible in raw view] — view raw

  Hi,

> > +	for (;;) {
> > +		value = readl(host->ioaddr + SDCMD);
> > +		if (!(value & SDCMD_NEW_FLAG))
> > +			break;
> > +		if (check_fail && (value & SDCMD_FAIL_FLAG))
> > +			break;
> > +		if (time_after(jiffies, end)) {
> > +			dev_err(dev, "%s: timeout (%d us)\n",
> > +				__func__, timeout);
> > +			break;
> > +		}
> > +
> > +		/* if it takes longer reduce poll interval */
> > +		if (time_after(jiffies, fastpoll))
> > +			udelay(10);
> > +		else
> > +			cpu_relax();
> > +	}
> 
> Use readl_poll_timeout intead of open-coding them..

Cool.  Didn't know this exists.  Incremental fixup attached.

thanks,
  Gerd

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web