Skip to contentSkip to conversation

mmc: sdhci-brcmstb: Add SDHCI_QUIRK2_BROKEN_64_BIT_DMA

PATCH Jaedon Shin 5 participants 10 messages Aug 19, 2016 – Aug 30, 2016 5 messages not in the archive MMC, SD and SDIO

lore
Share & tools
lore
#5 lore raw
In reply to a message not in the archive

Hi Ulf,

Quoted 27 lines · Ulf Hansson
Quoted 11 lines · Jaedon Shin

Hi Alan,

Quoted 8 lines · Alan Cooper

It would be better to make this a MIPS only setting because this issue only exists for MIPS chips and some newer ARM chips will support 64 bit DMA.
Also, since there's been a general effort to reduce the use QUIRKs, you could clear the SDHCI_CAN_64BIT in CAPS1 instead of using the QUIRK.

Quoted 12 lines

Review static int sdhci_brcmstb_probe(struct platform_device *pdev) · line 108

Quoted 9 lines
(quoted diff) +3 -0
@@ -101,6 +101,9 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
      host->caps1 = sdhci_readl(host, SDHCI_CAPABILITIES_1);
      host->caps1 &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_SDR104 |
                      SDHCI_SUPPORT_DDR50);
+#if defined(CONFIG_MIPS)
+       host->caps1 &= ~SDHCI_CAN_64BIT;
+#endif
      host->quirks |= SDHCI_QUIRK_MISSING_CAPS |
              SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;

It's better to me, but we should use host->cap instead of host->cap1. I will update patch with your comment.

Quoted 5 lines

Please, then also send this to the public linux-mmc list.

Kind regards
Uffe

I'm sorry I could not add the public linux-mmc list this mail thread, but I have already sent the updated patch with linux-mmc.

https://patchwork.kernel.org/patch/9289189/

Thanks,
Jaedon

Quoted 35 lines
Quoted 35 lines

Thanks,
Jaedon

Quoted 31 lines

Al

Quoted 26 lines · Adrian Hunter
Quoted 6 lines · Jaedon Shin

Add SDHCI_QUIRK2_BROKEN_64_BIT_DMA quirk for Broadcom BRCMSTB SoCs. The Broadcom ARM and MIPS based BRCMSTB SDHCI host controllers are using ADMA, but the several chipsets have a incorrect capability about ADMA 64-bit.

Quoted 16 lines

---
drivers/mmc/host/sdhci-brcmstb.c | 1 +

1 file changed, 1 insertion(+)
drivers/mmc/host/sdhci-brcmstb.c +1 -0
index cce10fe3e19e..704267000ef0 100644
@@ -103,6 +103,7 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
                    SDHCI_SUPPORT_DDR50);
    host->quirks |= SDHCI_QUIRK_MISSING_CAPS |
            SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
+     host->quirks2 |= SDHCI_QUIRK2_BROKEN_64_BIT_DMA;
 
    res = sdhci_add_host(host);
    if (res)
#6 lore raw
Quoted 31 lines · Jaedon Shin

Hi Ulf,

Quoted 29 lines · Ulf Hansson
Quoted 11 lines · Jaedon Shin

Hi Alan,

Quoted 8 lines · Alan Cooper

It would be better to make this a MIPS only setting because this issue only exists for MIPS chips and some newer ARM chips will support 64 bit DMA.
Also, since there's been a general effort to reduce the use QUIRKs, you could clear the SDHCI_CAN_64BIT in CAPS1 instead of using the QUIRK.

Quoted 12 lines

Review static int sdhci_brcmstb_probe(struct platform_device *pdev) · line 108

Quoted 9 lines
(quoted diff) +3 -0
@@ -101,6 +101,9 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
      host->caps1 = sdhci_readl(host, SDHCI_CAPABILITIES_1);
      host->caps1 &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_SDR104 |
                      SDHCI_SUPPORT_DDR50);
+#if defined(CONFIG_MIPS)
+       host->caps1 &= ~SDHCI_CAN_64BIT;
+#endif
      host->quirks |= SDHCI_QUIRK_MISSING_CAPS |
              SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;

It's better to me, but we should use host->cap instead of host->cap1. I will update patch with your comment.

Please, then also send this to the public linux-mmc list.

Quoted 8 lines
Quoted 3 lines

Kind regards
Uffe

I'm sorry I could not add the public linux-mmc list this mail thread, but I have already sent the updated patch with linux-mmc.

https://patchwork.kernel.org/patch/9289189/

Humm, is not this one of these cases where we would expect the compatible string to dictacte whether enabling 64_BIT_DMA makes sense or not?

The patch is technically correct though.

Signature · 1 line
Florian
#7 lore raw
Quoted 36 lines · Florian Fainelli
Quoted 35 lines · Jaedon Shin

Hi Ulf,

Quoted 32 lines · Ulf Hansson
Quoted 11 lines · Jaedon Shin

Hi Alan,

Quoted 8 lines · Alan Cooper

It would be better to make this a MIPS only setting because this issue only exists for MIPS chips and some newer ARM chips will support 64 bit DMA.
Also, since there's been a general effort to reduce the use QUIRKs, you could clear the SDHCI_CAN_64BIT in CAPS1 instead of using the QUIRK.

Quoted 12 lines

Review static int sdhci_brcmstb_probe(struct platform_device *pdev) · line 108

Quoted 9 lines
(quoted diff) +3 -0
@@ -101,6 +101,9 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
      host->caps1 = sdhci_readl(host, SDHCI_CAPABILITIES_1);
      host->caps1 &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_SDR104 |
                      SDHCI_SUPPORT_DDR50);
+#if defined(CONFIG_MIPS)
+       host->caps1 &= ~SDHCI_CAN_64BIT;
+#endif
      host->quirks |= SDHCI_QUIRK_MISSING_CAPS |
              SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;

It's better to me, but we should use host->cap instead of host->cap1. I will update patch with your comment.

Please, then also send this to the public linux-mmc list.

Kind regards
Uffe

Quoted 8 lines
Quoted 4 lines

I'm sorry I could not add the public linux-mmc list this mail thread, but I have already sent the updated patch with linux-mmc.

https://patchwork.kernel.org/patch/9289189/

Humm, is not this one of these cases where we would expect the compatible string to dictacte whether enabling 64_BIT_DMA makes sense or not?

Yes!

Jaedon, can you please send an updated patch. Please also bump the version number of the patch!

Kind regards
Uffe

Quoted 4 lines

The patch is technically correct though.
--
Florian

#8 lore raw
Quoted 42 lines · Ulf Hansson
Quoted 41 lines · Florian Fainelli
Quoted 39 lines · Jaedon Shin

Hi Ulf,

Quoted 27 lines · Ulf Hansson
Quoted 11 lines · Jaedon Shin

Hi Alan,

Quoted 8 lines · Alan Cooper

It would be better to make this a MIPS only setting because this issue only exists for MIPS chips and some newer ARM chips will support 64 bit DMA.
Also, since there's been a general effort to reduce the use QUIRKs, you could clear the SDHCI_CAN_64BIT in CAPS1 instead of using the QUIRK.

Quoted 12 lines

Review static int sdhci_brcmstb_probe(struct platform_device *pdev) · line 108

Quoted 9 lines
(quoted diff) +3 -0
@@ -101,6 +101,9 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
      host->caps1 = sdhci_readl(host, SDHCI_CAPABILITIES_1);
      host->caps1 &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_SDR104 |
                      SDHCI_SUPPORT_DDR50);
+#if defined(CONFIG_MIPS)
+       host->caps1 &= ~SDHCI_CAN_64BIT;
+#endif
      host->quirks |= SDHCI_QUIRK_MISSING_CAPS |
              SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;

It's better to me, but we should use host->cap instead of host->cap1. I will update patch with your comment.

Quoted 5 lines

Please, then also send this to the public linux-mmc list.

Kind regards
Uffe

I'm sorry I could not add the public linux-mmc list this mail thread, but I have already sent the updated patch with linux-mmc.

https://patchwork.kernel.org/patch/9289189/

Quoted 9 lines
Quoted 3 lines

Humm, is not this one of these cases where we would expect the compatible string to dictacte whether enabling 64_BIT_DMA makes sense or not?

Yes!

Jaedon, can you please send an updated patch. Please also bump the version number of the patch!

Sorry for jumping in late in the thread, but if I understand it right that the problem is an SDHCI controller claiming to support 64-bit DMA that is connected to a bus that only supports 32-bit addressing, this should be handled by interpreting the dma-ranges property of the parent bus instead.

Arnd

#9 lore raw
In reply to Florian Fainelli

Hi Florian,

Quoted 40 lines · Florian Fainelli
Quoted 38 lines · Jaedon Shin

Hi Ulf,

Quoted 27 lines · Ulf Hansson
Quoted 11 lines · Jaedon Shin

Hi Alan,

Quoted 8 lines · Alan Cooper

It would be better to make this a MIPS only setting because this issue only exists for MIPS chips and some newer ARM chips will support 64 bit DMA.
Also, since there's been a general effort to reduce the use QUIRKs, you could clear the SDHCI_CAN_64BIT in CAPS1 instead of using the QUIRK.

Quoted 12 lines

Review static int sdhci_brcmstb_probe(struct platform_device *pdev) · line 108

Quoted 9 lines
(quoted diff) +3 -0
@@ -101,6 +101,9 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
     host->caps1 = sdhci_readl(host, SDHCI_CAPABILITIES_1);
     host->caps1 &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_SDR104 |
                     SDHCI_SUPPORT_DDR50);
+#if defined(CONFIG_MIPS)
+       host->caps1 &= ~SDHCI_CAN_64BIT;
+#endif
     host->quirks |= SDHCI_QUIRK_MISSING_CAPS |
             SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;

It's better to me, but we should use host->cap instead of host->cap1. I will update patch with your comment.

Quoted 5 lines

Please, then also send this to the public linux-mmc list.

Kind regards
Uffe

I'm sorry I could not add the public linux-mmc list this mail thread, but I have already sent the updated patch with linux-mmc.

Quoted 7 lines
Quoted 1 line

https://patchwork.kernel.org/patch/9289189/

Humm, is not this one of these cases where we would expect the compatible string to dictacte whether enabling 64_BIT_DMA makes sense or not?

The patch is technically correct though.

Yes, It's right way that uses host->cap according to the previous discussion for this driver and commit 5eaa7476f937 ("mmc: sdhci: Allow CAPS check for SDHCI_CAN_64BIT to use overridden caps").

If the 64bit ARM chipsets have own compatible string, the patch like as below

	if (of_device_is_compatible(pdev->dev.of_node, "brcm,bcm7425-sdhci"))
		host->caps &= ~SDHCI_CAN_64BIT;

Could you tell me the some newer 64bit ARM chipsets have possible own compatible string?

Thanks,
Jaedon

Quoted 2 lines
Signature · 1 line
Florian
#10 lore raw
Quoted 50 lines · Jaedon Shin

Hi Florian,

Quoted 47 lines · Florian Fainelli
Quoted 31 lines · Jaedon Shin

Hi Ulf,

Quoted 29 lines · Ulf Hansson
Quoted 11 lines · Jaedon Shin

Hi Alan,

Quoted 8 lines · Alan Cooper

It would be better to make this a MIPS only setting because this issue only exists for MIPS chips and some newer ARM chips will support 64 bit DMA.
Also, since there's been a general effort to reduce the use QUIRKs, you could clear the SDHCI_CAN_64BIT in CAPS1 instead of using the QUIRK.

Quoted 12 lines

Review static int sdhci_brcmstb_probe(struct platform_device *pdev) · line 108

Quoted 9 lines
(quoted diff) +3 -0
@@ -101,6 +101,9 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
     host->caps1 = sdhci_readl(host, SDHCI_CAPABILITIES_1);
     host->caps1 &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_SDR104 |
                     SDHCI_SUPPORT_DDR50);
+#if defined(CONFIG_MIPS)
+       host->caps1 &= ~SDHCI_CAN_64BIT;
+#endif
     host->quirks |= SDHCI_QUIRK_MISSING_CAPS |
             SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;

It's better to me, but we should use host->cap instead of host->cap1. I will update patch with your comment.

Please, then also send this to the public linux-mmc list.

Quoted 8 lines
Quoted 3 lines

Kind regards
Uffe

I'm sorry I could not add the public linux-mmc list this mail thread, but I have already sent the updated patch with linux-mmc.

https://patchwork.kernel.org/patch/9289189/

Humm, is not this one of these cases where we would expect the compatible string to dictacte whether enabling 64_BIT_DMA makes sense or not?

The patch is technically correct though.

Hi Jaedon,

Quoted 5 lines

Yes, It's right way that uses host->cap according to the previous discussion for this driver and commit 5eaa7476f937 ("mmc: sdhci: Allow CAPS check for SDHCI_CAN_64BIT to use overridden caps").

Quoted 7 lines

If the 64bit ARM chipsets have own compatible string, the patch like as below

	if (of_device_is_compatible(pdev->dev.of_node, "brcm,bcm7425-sdhci"))
		host->caps &= ~SDHCI_CAN_64BIT;

Could you tell me the some newer 64bit ARM chipsets have possible own compatible string?

All ARM 32-bit brcmstb chips are LPAE capable, which means that the SDHCI controller may have to deal with bus addresses larger than 32-bits, so we always need SDHCI_CAN_64BIT to be set for that to happen and work correctly.

On ARM 64-bit brcmstb chips, we may not have enough memory such that the SDHCI controller needs to deal with > 32-bits bus addresses, but same thing, this may happen and the controller is fully capable of, so we also need SDHCI_CAN_64BIT.

In both cases, the controller should be fully operational with > 32-bits physical addresses.

On BMIPS chips, we should probably clear SDHCI_CAN_64BIT because AFAIR, it really is broken (Al, can you confirm?), but at the same time, the DMA-API should never hand us buffers which exceed the 32-bits bus address boundary because of the processor and chip memory map limitations anyway, is that what you encountered though?

At the moment, brcm,bcm7425-sdhci is used across all 3 types of SoCs (BMIPS, ARM and ARM64) while we should probably allocate a new one for ARM and newer and then we could reliably base the clearing of SDHCI_CAN_64BIT based on brcm,bcm7425-sdhci.

Finally, Arnd's suggestions of using "dma-ranges" is fine, but I do not think we quite need this here because we really need to advertise the right set of capabilities based on the generation/version of the controller deployed in specific chips.

I would like to have Al's feedback on this, since he wrote the driver ;)

Thanks!

Signature · 1 line
Florian
#11 lore raw
Quoted 92 lines · Florian Fainelli
Quoted 50 lines · Jaedon Shin

Hi Florian,

Quoted 47 lines · Florian Fainelli
Quoted 31 lines · Jaedon Shin

Hi Ulf,

Quoted 29 lines · Ulf Hansson
Quoted 11 lines · Jaedon Shin

Hi Alan,

Quoted 8 lines · Alan Cooper

It would be better to make this a MIPS only setting because this issue only exists for MIPS chips and some newer ARM chips will support 64 bit DMA.
Also, since there's been a general effort to reduce the use QUIRKs, you could clear the SDHCI_CAN_64BIT in CAPS1 instead of using the QUIRK.

Quoted 12 lines

Review static int sdhci_brcmstb_probe(struct platform_device *pdev) · line 108

Quoted 9 lines
(quoted diff) +3 -0
@@ -101,6 +101,9 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
    host->caps1 = sdhci_readl(host, SDHCI_CAPABILITIES_1);
    host->caps1 &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_SDR104 |
                    SDHCI_SUPPORT_DDR50);
+#if defined(CONFIG_MIPS)
+       host->caps1 &= ~SDHCI_CAN_64BIT;
+#endif
    host->quirks |= SDHCI_QUIRK_MISSING_CAPS |
            SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;

It's better to me, but we should use host->cap instead of host->cap1. I will update patch with your comment.

Please, then also send this to the public linux-mmc list.

Quoted 8 lines
Quoted 3 lines

Kind regards
Uffe

I'm sorry I could not add the public linux-mmc list this mail thread, but I have already sent the updated patch with linux-mmc.

https://patchwork.kernel.org/patch/9289189/

Humm, is not this one of these cases where we would expect the compatible string to dictacte whether enabling 64_BIT_DMA makes sense or not?

The patch is technically correct though.

Hi Jaedon,

Quoted 5 lines

Yes, It's right way that uses host->cap according to the previous discussion for this driver and commit 5eaa7476f937 ("mmc: sdhci: Allow CAPS check for SDHCI_CAN_64BIT to use overridden caps").

Quoted 7 lines

If the 64bit ARM chipsets have own compatible string, the patch like as below

	if (of_device_is_compatible(pdev->dev.of_node, "brcm,bcm7425-sdhci"))
		host->caps &= ~SDHCI_CAN_64BIT;

Could you tell me the some newer 64bit ARM chipsets have possible own compatible string?

All ARM 32-bit brcmstb chips are LPAE capable, which means that the SDHCI controller may have to deal with bus addresses larger than 32-bits, so we always need SDHCI_CAN_64BIT to be set for that to happen and work correctly.

On ARM 64-bit brcmstb chips, we may not have enough memory such that the SDHCI controller needs to deal with > 32-bits bus addresses, but same thing, this may happen and the controller is fully capable of, so we also need SDHCI_CAN_64BIT.

In both cases, the controller should be fully operational with > 32-bits physical addresses.

On BMIPS chips, we should probably clear SDHCI_CAN_64BIT because AFAIR, it really is broken (Al, can you confirm?), but at the same time, the DMA-API should never hand us buffers which exceed the 32-bits bus address boundary because of the processor and chip memory map limitations anyway, is that what you encountered though?

At the moment, brcm,bcm7425-sdhci is used across all 3 types of SoCs (BMIPS, ARM and ARM64) while we should probably allocate a new one for ARM and newer and then we could reliably base the clearing of SDHCI_CAN_64BIT based on brcm,bcm7425-sdhci.

Quoted 10 lines

Finally, Arnd's suggestions of using "dma-ranges" is fine, but I do not think we quite need this here because we really need to advertise the right set of capabilities based on the generation/version of the controller deployed in specific chips.

I would like to have Al's feedback on this, since he wrote the driver ;)

Thanks!

Signature · 1 line
Florian

Thanks for your detailed replay, and I understand why it must use a compatible string for all brcmstb chips. I'm sending the bumped patch for BMIPS quickly.

Thanks,
Jaedon

#12 lore raw
In reply to Florian Fainelli
Quoted 5 lines · CEST Florian Fainelli

Finally, Arnd's suggestions of using "dma-ranges" is fine, but I do not think we quite need this here because we really need to advertise the right set of capabilities based on the generation/version of the controller deployed in specific chips.

To be more specific here, I think that without the dma-ranges property you should never be able to set a dma-mask larger than the 32-bit mask, so if you have machines that are capable of high DMA, you should definitely add the property in the bus, even if that is currently ignored.

I've suggested a patch before, but I believe both ARM and MIPS ignore this at the moment, and just allow drivers to set arbitrary masks even when the bus does not have a dma-ranges property, and that is a bug.

Arnd

#13 lore raw
Quoted 13 lines · Arnd Bergmann
Quoted 5 lines · CEST Florian Fainelli

Finally, Arnd's suggestions of using "dma-ranges" is fine, but I do not think we quite need this here because we really need to advertise the right set of capabilities based on the generation/version of the controller deployed in specific chips.

To be more specific here, I think that without the dma-ranges property you should never be able to set a dma-mask larger than the 32-bit mask, so if you have machines that are capable of high DMA, you should definitely add the property in the bus, even if that is currently ignored.

Quoted 4 lines

I've suggested a patch before, but I believe both ARM and MIPS ignore this at the moment, and just allow drivers to set arbitrary masks even when the bus does not have a dma-ranges property, and that is a bug.

I think there's some confusion over the core issue so let be summarize. The SDHCI host controller CAPABILITIES register bit 28 indicates if the host controller hardware can support 64 bit addresses using the larger 96 bit DMA descriptors. We currently don't have any SoCs that have this support, even our current 64bit ARM SoCs don't support this, though there are future ARM SoCs that will have this support. The bug is that a few MIPS based SoCs had this bit incorrectly set even though the hardware did not support it and this caused the driver to use the larger DMA descriptors which crashed the driver. All we're trying to fix here is a simple SDHCI host controller hardware bug where a CAPs bit is a 1 where it should be a 0. Our future 64 ARM chips that do support 64bit addressing should be the only chips with this bit set.

Al

#14 lore raw
Quoted 4 lines · Alan Cooper

I think there's some confusion over the core issue so let be summarize. The SDHCI host controller CAPABILITIES register bit 28 indicates if the host controller hardware can support 64 bit addresses using the larger 96 bit DMA descriptors. We currently don't have any SoCs that

Quoted 8 lines

have this support, even our current 64bit ARM SoCs don't support this, though there are future ARM SoCs that will have this support. The bug is that a few MIPS based SoCs had this bit incorrectly set even though the hardware did not support it and this caused the driver to use the larger DMA descriptors which crashed the driver. All we're trying to fix here is a simple SDHCI host controller hardware bug where a CAPs bit is a 1 where it should be a 0. Our future 64 ARM chips that do support 64bit addressing should be the only chips with this bit set.

Ok, got it. Thanks for the clarification.

So the SDHCI device claims to have a capability that doesn't work, rather than correctly listing a property that works in principle but is prevented from working by something outside of the device as we discussed another time [1]

If this happens in other chips as well, I guess we could also solve this by changing the code to only enable the 64-bit ADMA feature when dma_get_required_mask() returns something larger than a 32-bit mask. This would also be (very slightly) more efficient because we have to access fewer registers per transfer.

Arnd

[1] http://marc.info/?l=linux-mmc&m=141457290627820&w=2