Skip to content

Commit 20730e9

Browse files
Lennert Buytenhekfloatious
authored andcommitted
ahci: add 43-bit DMA address quirk for ASMedia ASM1061 controllers
With one of the on-board ASM1061 AHCI controllers (1b21:0612) on an ASUSTeK Pro WS WRX80E-SAGE SE WIFI mainboard, a controller hang was observed that was immediately preceded by the following kernel messages: ahci 0000:28:00.0: Using 64-bit DMA addresses ahci 0000:28:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0035 address=0x7fffff00000 flags=0x0000] ahci 0000:28:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0035 address=0x7fffff00300 flags=0x0000] ahci 0000:28:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0035 address=0x7fffff00380 flags=0x0000] ahci 0000:28:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0035 address=0x7fffff00400 flags=0x0000] ahci 0000:28:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0035 address=0x7fffff00680 flags=0x0000] ahci 0000:28:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0035 address=0x7fffff00700 flags=0x0000] The first message is produced by code in drivers/iommu/dma-iommu.c which is accompanied by the following comment that seems to apply: /* * Try to use all the 32-bit PCI addresses first. The original SAC vs. * DAC reasoning loses relevance with PCIe, but enough hardware and * firmware bugs are still lurking out there that it's safest not to * venture into the 64-bit space until necessary. * * If your device goes wrong after seeing the notice then likely either * its driver is not setting DMA masks accurately, the hardware has * some inherent bug in handling >32-bit addresses, or not all the * expected address bits are wired up between the device and the IOMMU. */ Asking the ASM1061 on a discrete PCIe card to DMA from I/O virtual address 0xffffffff00000000 produces the following I/O page faults: vfio-pci 0000:07:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0021 address=0x7ff00000000 flags=0x0010] vfio-pci 0000:07:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0021 address=0x7ff00000500 flags=0x0010] Note that the upper 21 bits of the logged DMA address are zero. (When asking a different PCIe device in the same PCIe slot to DMA to the same I/O virtual address, we do see all the upper 32 bits of the DMA address as 1, so this is not an issue with the chipset or IOMMU configuration on the test system.) Also, hacking libahci to always set the upper 21 bits of all DMA addresses to 1 produces no discernible effect on the behavior of the ASM1061, and mkfs/mount/scrub/etc work as without this hack. This all strongly suggests that the ASM1061 has a 43 bit DMA address limit, and this commit therefore adds a quirk to deal with this limit. This issue probably applies to (some of) the other supported ASMedia parts as well, but we limit it to the PCI IDs known to refer to ASM1061 parts, as that's the only part we know for sure to be affected by this issue at this point. Link: https://lore.kernel.org/linux-ide/ZaZ2PIpEId-rl6jv@wantstofly.org/ Signed-off-by: Lennert Buytenhek <kernel@wantstofly.org> [cassel: drop date from error messages in commit log] Signed-off-by: Niklas Cassel <cassel@kernel.org>
1 parent 0077a50 commit 20730e9

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

drivers/ata/ahci.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ enum {
4848
enum board_ids {
4949
/* board IDs by feature in alphabetical order */
5050
board_ahci,
51+
board_ahci_43bit_dma,
5152
board_ahci_ign_iferr,
5253
board_ahci_low_power,
5354
board_ahci_no_debounce_delay,
@@ -128,6 +129,13 @@ static const struct ata_port_info ahci_port_info[] = {
128129
.udma_mask = ATA_UDMA6,
129130
.port_ops = &ahci_ops,
130131
},
132+
[board_ahci_43bit_dma] = {
133+
AHCI_HFLAGS (AHCI_HFLAG_43BIT_ONLY),
134+
.flags = AHCI_FLAG_COMMON,
135+
.pio_mask = ATA_PIO4,
136+
.udma_mask = ATA_UDMA6,
137+
.port_ops = &ahci_ops,
138+
},
131139
[board_ahci_ign_iferr] = {
132140
AHCI_HFLAGS (AHCI_HFLAG_IGN_IRQ_IF_ERR),
133141
.flags = AHCI_FLAG_COMMON,
@@ -597,11 +605,11 @@ static const struct pci_device_id ahci_pci_tbl[] = {
597605
{ PCI_VDEVICE(PROMISE, 0x3f20), board_ahci }, /* PDC42819 */
598606
{ PCI_VDEVICE(PROMISE, 0x3781), board_ahci }, /* FastTrak TX8660 ahci-mode */
599607

600-
/* Asmedia */
608+
/* ASMedia */
601609
{ PCI_VDEVICE(ASMEDIA, 0x0601), board_ahci }, /* ASM1060 */
602610
{ PCI_VDEVICE(ASMEDIA, 0x0602), board_ahci }, /* ASM1060 */
603-
{ PCI_VDEVICE(ASMEDIA, 0x0611), board_ahci }, /* ASM1061 */
604-
{ PCI_VDEVICE(ASMEDIA, 0x0612), board_ahci }, /* ASM1062 */
611+
{ PCI_VDEVICE(ASMEDIA, 0x0611), board_ahci_43bit_dma }, /* ASM1061 */
612+
{ PCI_VDEVICE(ASMEDIA, 0x0612), board_ahci_43bit_dma }, /* ASM1061/1062 */
605613
{ PCI_VDEVICE(ASMEDIA, 0x0621), board_ahci }, /* ASM1061R */
606614
{ PCI_VDEVICE(ASMEDIA, 0x0622), board_ahci }, /* ASM1062R */
607615
{ PCI_VDEVICE(ASMEDIA, 0x0624), board_ahci }, /* ASM1062+JMB575 */
@@ -954,11 +962,20 @@ static int ahci_pci_device_resume(struct device *dev)
954962

955963
#endif /* CONFIG_PM */
956964

957-
static int ahci_configure_dma_masks(struct pci_dev *pdev, int using_dac)
965+
static int ahci_configure_dma_masks(struct pci_dev *pdev,
966+
struct ahci_host_priv *hpriv)
958967
{
959-
const int dma_bits = using_dac ? 64 : 32;
968+
int dma_bits;
960969
int rc;
961970

971+
if (hpriv->cap & HOST_CAP_64) {
972+
dma_bits = 64;
973+
if (hpriv->flags & AHCI_HFLAG_43BIT_ONLY)
974+
dma_bits = 43;
975+
} else {
976+
dma_bits = 32;
977+
}
978+
962979
/*
963980
* If the device fixup already set the dma_mask to some non-standard
964981
* value, don't extend it here. This happens on STA2X11, for example.
@@ -1931,7 +1948,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
19311948
ahci_gtf_filter_workaround(host);
19321949

19331950
/* initialize adapter */
1934-
rc = ahci_configure_dma_masks(pdev, hpriv->cap & HOST_CAP_64);
1951+
rc = ahci_configure_dma_masks(pdev, hpriv);
19351952
if (rc)
19361953
return rc;
19371954

drivers/ata/ahci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ enum {
247247
AHCI_HFLAG_SUSPEND_PHYS = BIT(26), /* handle PHYs during
248248
suspend/resume */
249249
AHCI_HFLAG_NO_SXS = BIT(28), /* SXS not supported */
250+
AHCI_HFLAG_43BIT_ONLY = BIT(29), /* 43bit DMA addr limit */
250251

251252
/* ap->flags bits */
252253

0 commit comments

Comments
 (0)