mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master] mci: bcm2835: reset host controller on barebox shutdown
@ 2022-09-30 11:19 Ahmad Fatoum
  2022-09-30 12:24 ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Ahmad Fatoum @ 2022-09-30 11:19 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

We don't usually disable MMC controllers on barebox shutdown, because
they don't DMA on their own, unlike e.g. network controllers.

Booting Linux v5.17.0 on a Raspberry Pi 4 in 32-bit mode still has the
MMC host controller driver complain:

  [   22.464887] mmc1: Got data interrupt 0x00000002 even though no
  			data operation was in progress.

Fix this by resetting the SDHCI once barebox is done with it.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/mci/mci-bcm2835.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/mci/mci-bcm2835.c b/drivers/mci/mci-bcm2835.c
index f092156f9a83..c5b226ba033c 100644
--- a/drivers/mci/mci-bcm2835.c
+++ b/drivers/mci/mci-bcm2835.c
@@ -385,6 +385,8 @@ static int bcm2835_mci_probe(struct device_d *hw_dev)
 	host->sdhci.read32 = bcm2835_sdhci_read32;
 	host->sdhci.write32 = bcm2835_sdhci_write32;
 
+	hw_dev->priv = host;
+
 	mci_of_parse(&host->mci);
 
 	iores = dev_request_mem_resource(hw_dev, 0);
@@ -420,6 +422,15 @@ static int bcm2835_mci_probe(struct device_d *hw_dev)
 	return mci_register(&host->mci);
 }
 
+static void bcm2835_mci_remove(struct device_d *dev)
+{
+	struct bcm2835_mci_host *host = dev->priv;
+
+	sdhci_write32(&host->sdhci,
+		      SDHCI_CLOCK_CONTROL__TIMEOUT_CONTROL__SOFTWARE_RESET,
+		      0x00);
+}
+
 static __maybe_unused struct of_device_id bcm2835_mci_compatible[] = {
 	{
 		.compatible = "brcm,bcm2835-sdhci",
@@ -433,6 +444,7 @@ static __maybe_unused struct of_device_id bcm2835_mci_compatible[] = {
 static struct driver_d bcm2835_mci_driver = {
 	.name = "bcm2835_mci",
 	.probe = bcm2835_mci_probe,
+	.remove = bcm2835_mci_remove,
 	.of_compatible = DRV_OF_COMPAT(bcm2835_mci_compatible),
 };
 
-- 
2.30.2




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH master] mci: bcm2835: reset host controller on barebox shutdown
  2022-09-30 11:19 [PATCH master] mci: bcm2835: reset host controller on barebox shutdown Ahmad Fatoum
@ 2022-09-30 12:24 ` Sascha Hauer
  2022-09-30 14:18   ` Ahmad Fatoum
  0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2022-09-30 12:24 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Fri, Sep 30, 2022 at 01:19:40PM +0200, Ahmad Fatoum wrote:
> We don't usually disable MMC controllers on barebox shutdown, because
> they don't DMA on their own, unlike e.g. network controllers.
> 
> Booting Linux v5.17.0 on a Raspberry Pi 4 in 32-bit mode still has the
> MMC host controller driver complain:
> 
>   [   22.464887] mmc1: Got data interrupt 0x00000002 even though no
>   			data operation was in progress.
> 
> Fix this by resetting the SDHCI once barebox is done with it.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/mci/mci-bcm2835.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)

Applied, thanks

Sascha

> 
> diff --git a/drivers/mci/mci-bcm2835.c b/drivers/mci/mci-bcm2835.c
> index f092156f9a83..c5b226ba033c 100644
> --- a/drivers/mci/mci-bcm2835.c
> +++ b/drivers/mci/mci-bcm2835.c
> @@ -385,6 +385,8 @@ static int bcm2835_mci_probe(struct device_d *hw_dev)
>  	host->sdhci.read32 = bcm2835_sdhci_read32;
>  	host->sdhci.write32 = bcm2835_sdhci_write32;
>  
> +	hw_dev->priv = host;
> +
>  	mci_of_parse(&host->mci);
>  
>  	iores = dev_request_mem_resource(hw_dev, 0);
> @@ -420,6 +422,15 @@ static int bcm2835_mci_probe(struct device_d *hw_dev)
>  	return mci_register(&host->mci);
>  }
>  
> +static void bcm2835_mci_remove(struct device_d *dev)
> +{
> +	struct bcm2835_mci_host *host = dev->priv;
> +
> +	sdhci_write32(&host->sdhci,
> +		      SDHCI_CLOCK_CONTROL__TIMEOUT_CONTROL__SOFTWARE_RESET,
> +		      0x00);
> +}
> +
>  static __maybe_unused struct of_device_id bcm2835_mci_compatible[] = {
>  	{
>  		.compatible = "brcm,bcm2835-sdhci",
> @@ -433,6 +444,7 @@ static __maybe_unused struct of_device_id bcm2835_mci_compatible[] = {
>  static struct driver_d bcm2835_mci_driver = {
>  	.name = "bcm2835_mci",
>  	.probe = bcm2835_mci_probe,
> +	.remove = bcm2835_mci_remove,
>  	.of_compatible = DRV_OF_COMPAT(bcm2835_mci_compatible),
>  };
>  
> -- 
> 2.30.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH master] mci: bcm2835: reset host controller on barebox shutdown
  2022-09-30 12:24 ` Sascha Hauer
@ 2022-09-30 14:18   ` Ahmad Fatoum
  2022-10-04  7:55     ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Ahmad Fatoum @ 2022-09-30 14:18 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 30.09.22 13:24, Sascha Hauer wrote:
> On Fri, Sep 30, 2022 at 01:19:40PM +0200, Ahmad Fatoum wrote:
>> We don't usually disable MMC controllers on barebox shutdown, because
>> they don't DMA on their own, unlike e.g. network controllers.
>>
>> Booting Linux v5.17.0 on a Raspberry Pi 4 in 32-bit mode still has the
>> MMC host controller driver complain:
>>
>>   [   22.464887] mmc1: Got data interrupt 0x00000002 even though no
>>   			data operation was in progress.
>>
>> Fix this by resetting the SDHCI once barebox is done with it.
>>
>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>> ---
>>  drivers/mci/mci-bcm2835.c | 12 ++++++++++++
>>  1 file changed, 12 insertions(+)
> 
> Applied, thanks

Please drop again. The warning is spurious and it just happened to not
show up in my testing runs afterwards. I am looking into a proper fix
and will let it do more reboot cycles to make sure issue is indeed
resolved.

> 
> Sascha
> 
>>
>> diff --git a/drivers/mci/mci-bcm2835.c b/drivers/mci/mci-bcm2835.c
>> index f092156f9a83..c5b226ba033c 100644
>> --- a/drivers/mci/mci-bcm2835.c
>> +++ b/drivers/mci/mci-bcm2835.c
>> @@ -385,6 +385,8 @@ static int bcm2835_mci_probe(struct device_d *hw_dev)
>>  	host->sdhci.read32 = bcm2835_sdhci_read32;
>>  	host->sdhci.write32 = bcm2835_sdhci_write32;
>>  
>> +	hw_dev->priv = host;
>> +
>>  	mci_of_parse(&host->mci);
>>  
>>  	iores = dev_request_mem_resource(hw_dev, 0);
>> @@ -420,6 +422,15 @@ static int bcm2835_mci_probe(struct device_d *hw_dev)
>>  	return mci_register(&host->mci);
>>  }
>>  
>> +static void bcm2835_mci_remove(struct device_d *dev)
>> +{
>> +	struct bcm2835_mci_host *host = dev->priv;
>> +
>> +	sdhci_write32(&host->sdhci,
>> +		      SDHCI_CLOCK_CONTROL__TIMEOUT_CONTROL__SOFTWARE_RESET,
>> +		      0x00);
>> +}
>> +
>>  static __maybe_unused struct of_device_id bcm2835_mci_compatible[] = {
>>  	{
>>  		.compatible = "brcm,bcm2835-sdhci",
>> @@ -433,6 +444,7 @@ static __maybe_unused struct of_device_id bcm2835_mci_compatible[] = {
>>  static struct driver_d bcm2835_mci_driver = {
>>  	.name = "bcm2835_mci",
>>  	.probe = bcm2835_mci_probe,
>> +	.remove = bcm2835_mci_remove,
>>  	.of_compatible = DRV_OF_COMPAT(bcm2835_mci_compatible),
>>  };
>>  
>> -- 
>> 2.30.2
>>
>>
>>
> 


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH master] mci: bcm2835: reset host controller on barebox shutdown
  2022-09-30 14:18   ` Ahmad Fatoum
@ 2022-10-04  7:55     ` Sascha Hauer
  0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2022-10-04  7:55 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Fri, Sep 30, 2022 at 03:18:29PM +0100, Ahmad Fatoum wrote:
> On 30.09.22 13:24, Sascha Hauer wrote:
> > On Fri, Sep 30, 2022 at 01:19:40PM +0200, Ahmad Fatoum wrote:
> >> We don't usually disable MMC controllers on barebox shutdown, because
> >> they don't DMA on their own, unlike e.g. network controllers.
> >>
> >> Booting Linux v5.17.0 on a Raspberry Pi 4 in 32-bit mode still has the
> >> MMC host controller driver complain:
> >>
> >>   [   22.464887] mmc1: Got data interrupt 0x00000002 even though no
> >>   			data operation was in progress.
> >>
> >> Fix this by resetting the SDHCI once barebox is done with it.
> >>
> >> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> >> ---
> >>  drivers/mci/mci-bcm2835.c | 12 ++++++++++++
> >>  1 file changed, 12 insertions(+)
> > 
> > Applied, thanks
> 
> Please drop again. The warning is spurious and it just happened to not
> show up in my testing runs afterwards. I am looking into a proper fix
> and will let it do more reboot cycles to make sure issue is indeed
> resolved.

It's already pushed to master, I can't drop it. I could revert it.
Should I do that?

Sascha

> 
> > 
> > Sascha
> > 
> >>
> >> diff --git a/drivers/mci/mci-bcm2835.c b/drivers/mci/mci-bcm2835.c
> >> index f092156f9a83..c5b226ba033c 100644
> >> --- a/drivers/mci/mci-bcm2835.c
> >> +++ b/drivers/mci/mci-bcm2835.c
> >> @@ -385,6 +385,8 @@ static int bcm2835_mci_probe(struct device_d *hw_dev)
> >>  	host->sdhci.read32 = bcm2835_sdhci_read32;
> >>  	host->sdhci.write32 = bcm2835_sdhci_write32;
> >>  
> >> +	hw_dev->priv = host;
> >> +
> >>  	mci_of_parse(&host->mci);
> >>  
> >>  	iores = dev_request_mem_resource(hw_dev, 0);
> >> @@ -420,6 +422,15 @@ static int bcm2835_mci_probe(struct device_d *hw_dev)
> >>  	return mci_register(&host->mci);
> >>  }
> >>  
> >> +static void bcm2835_mci_remove(struct device_d *dev)
> >> +{
> >> +	struct bcm2835_mci_host *host = dev->priv;
> >> +
> >> +	sdhci_write32(&host->sdhci,
> >> +		      SDHCI_CLOCK_CONTROL__TIMEOUT_CONTROL__SOFTWARE_RESET,
> >> +		      0x00);
> >> +}
> >> +
> >>  static __maybe_unused struct of_device_id bcm2835_mci_compatible[] = {
> >>  	{
> >>  		.compatible = "brcm,bcm2835-sdhci",
> >> @@ -433,6 +444,7 @@ static __maybe_unused struct of_device_id bcm2835_mci_compatible[] = {
> >>  static struct driver_d bcm2835_mci_driver = {
> >>  	.name = "bcm2835_mci",
> >>  	.probe = bcm2835_mci_probe,
> >> +	.remove = bcm2835_mci_remove,
> >>  	.of_compatible = DRV_OF_COMPAT(bcm2835_mci_compatible),
> >>  };
> >>  
> >> -- 
> >> 2.30.2
> >>
> >>
> >>
> > 
> 
> 
> -- 
> Pengutronix e.K.                           |                             |
> Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
> 31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-04  7:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-30 11:19 [PATCH master] mci: bcm2835: reset host controller on barebox shutdown Ahmad Fatoum
2022-09-30 12:24 ` Sascha Hauer
2022-09-30 14:18   ` Ahmad Fatoum
2022-10-04  7:55     ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox