diff mbox

[01/13] mmc: bcm2835: add bcm2835_read_wait_sdcmd

Message ID 1485473846-24537-2-git-send-email-kraxel@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gerd Hoffmann Jan. 26, 2017, 11:37 p.m. UTC
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/mmc/host/bcm2835.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

Comments

Florian Fainelli Jan. 26, 2017, 11:51 p.m. UTC | #1
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
Shawn Lin Jan. 27, 2017, 2:03 a.m. UTC | #2
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)
>  {
>
Gerd Hoffmann Jan. 27, 2017, 8:04 a.m. UTC | #3
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


--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Florian Fainelli Jan. 27, 2017, 6:23 p.m. UTC | #4
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
Jeremy McNicoll Feb. 15, 2017, 10:59 a.m. UTC | #5
> On Jan 27, 2017, at 10:23 AM, Florian Fainelli <f.fainelli@gmail.com> wrote:
> 
> 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


How is the cover letter being created?  

$ git send-email -10 —-compose  

drops you into your editor to write the cover letter / lead in. 

What about this?

$ git format-patch -o /tmp/blah/ --cover-letter --subject-prefix="[V2]" HEAD~10

Your first patch 0000.patch will be your cover letter to fill in. 

Add this to your ~/.gitconfig
   [sendmail] 
       ….
       confirm = always

$ git config --global sendemail.confirm always


As well there is a ‘—-dry-run’ option to git send-email. 

HTH

Its always good to cut twice and measure once ;-)

-jeremy



> 
>> 
>>> - 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
> 
> _______________________________________________
> linux-rpi-kernel mailing list
> linux-rpi-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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)
 {