Skip to contentSkip to conversation

PCI: add MSI INTX_DISABLE quirks for AR8161/AR8162/AR8171/AR8172

PATCH In review xiong 2 participants 5 messages Mar 6, 2013 – Mar 9, 2013 2 messages not in the archive PCI

lore
Share & tools
lore

xiong

author
#0 lore raw

PATCH 1/1 PCI: add MSI INTX_DISABLE quirks for AR8161/AR8162/AR8171/AR8172

From: "Huang,Xiong" <[email protected]>

PCI devices of AR8161/AR8162/AR8171/AR8172 which revision lower than 0x18 have this bug.

---
 drivers/pci/quirks.c    | 35 +++++++++++++++++++++++++++++++++++
 include/linux/pci_ids.h |  4 ++++
 2 files changed, 39 insertions(+)
drivers/pci/quirks.c +35 -0
index 0369fb6..bf31d72 100644
@@ -2594,6 +2594,29 @@ static void quirk_msi_intx_disable_ati_bug(struct pci_dev *dev)
 		dev->dev_flags |= PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG;
 	pci_dev_put(p);
 }
+static void quirk_msi_intx_disable_qca_bug(struct pci_dev *dev)
+{
+	static u16 qca_eth_devid[] = {
+			PCI_DEVICE_ID_AR8161,
+			PCI_DEVICE_ID_AR8162,
+			PCI_DEVICE_ID_AR8171,
+			PCI_DEVICE_ID_AR8172};
+	struct pci_dev *p;
+	int i;
+
+	/* AR816X/AR817X MSI is fixed at HW level from revision 0x18 */
+	for (i = 0; i < ARRAY_SIZE(qca_eth_devid); i++) {
+		p = pci_get_device(PCI_VENDOR_ID_ATTANSIC,
+				   qca_eth_devid[i],
+				   NULL);
+		if (!p)
+			return;
+
+		if (p->revision < 0x18)
+			dev->dev_flags |= PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG;
+		pci_dev_put(p);
+	}
+}
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM,
 			PCI_DEVICE_ID_TIGON3_5780,
 			quirk_msi_intx_disable_bug);
@@ -2643,6 +2666,18 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, 0x1073,
 			quirk_msi_intx_disable_bug);
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, 0x1083,
 			quirk_msi_intx_disable_bug);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC,
+			PCI_DEVICE_ID_AR8161,
+			quirk_msi_intx_disable_qca_bug);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC,
+			PCI_DEVICE_ID_AR8162,
+			quirk_msi_intx_disable_qca_bug);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC,
+			PCI_DEVICE_ID_AR8171,
+			quirk_msi_intx_disable_qca_bug);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC,
+			PCI_DEVICE_ID_AR8172,
+			quirk_msi_intx_disable_qca_bug);
 #endif /* CONFIG_PCI_MSI */
 
 /* Allow manual resource allocation for PCI hotplug bridges
include/linux/pci_ids.h +4 -0
index f11c1c2..7e171fb 100644
@@ -2438,6 +2438,10 @@
 #define PCI_VENDOR_ID_ATTANSIC		0x1969
 #define PCI_DEVICE_ID_ATTANSIC_L1	0x1048
 #define PCI_DEVICE_ID_ATTANSIC_L2	0x2048
+#define PCI_DEVICE_ID_AR8161		0x1091
+#define PCI_DEVICE_ID_AR8162		0x1090
+#define PCI_DEVICE_ID_AR8171		0x10A1
+#define PCI_DEVICE_ID_AR8172		0x10A0
 
 #define PCI_VENDOR_ID_JMICRON		0x197B
 #define PCI_DEVICE_ID_JMICRON_JMB360	0x2360
Signature · 1 line
1.7.11.7

A message that is not in the archive (sent off-list or not yet received): 20130307094214.GA2317@richard.(null)

#2 lore raw
Quoted 35 lines

drivers/pci/quirks.c static void quirk_msi_intx_disable_ati_bug(struct pci_dev *dev) · line 2610

Quoted 13 lines
drivers/pci/quirks.c +13 -0
+static void quirk_msi_intx_disable_qca_bug(struct pci_dev *dev) {
+	static u16 qca_eth_devid[] = {
+			PCI_DEVICE_ID_AR8161,
+			PCI_DEVICE_ID_AR8162,
+			PCI_DEVICE_ID_AR8171,
+			PCI_DEVICE_ID_AR8172};
+	struct pci_dev *p;
+	int i;
+
+	/* AR816X/AR817X MSI is fixed at HW level from revision 0x18 */
+	for (i = 0; i < ARRAY_SIZE(qca_eth_devid); i++) {
+		p = pci_get_device(PCI_VENDOR_ID_ATTANSIC,
+				   qca_eth_devid[i],

xiong,

The "FINAL" fixup is called just in pci_apply_final_quirks(), if I am correct.

In this function, it will go through all the pci devices which are registered in the system. And try to invoke the fixup hook.

Also, before invode the hook, in function pci_do_fixups() it will make sure the hook just apply to the devices whose VendorID and DeviceID match what you defined in DECLARE_PCI_FIXUP_FINAL.

So I think there is no need to iterate on all those pci device, before you want to change the pci_dev->dev_flags.

drivers/pci/quirks.c static void quirk_msi_intx_disable_ati_bug(struct pci_dev *dev)

Quoted 6 lines
drivers/pci/quirks.c +6 -0
+				   NULL);
+		if (!p)
+			return;
+
+		if (p->revision < 0x18)
+			dev->dev_flags |=

PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG;

Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+		pci_dev_put(p);
+	}

Wei, thanks for you feedback, this patch is just follow the function 'quirk_msi_intx_disable_ati_bug' in quirks.c Is it ok if I revise code as:

	static void quirk_msi_intx_disable_qca_bug(struct pci_dev *dev)
	{
		If (dev->revision < 0x18)
			dev->dev_flags |=  PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG;
	}

Please advise, thanks !

-Xiong

maintainer
#3 lore raw
Quoted 38 lines · Xiong
Quoted 28 lines

drivers/pci/quirks.c static void quirk_msi_intx_disable_ati_bug(struct pci_dev *dev) · line 2610

Quoted 13 lines
drivers/pci/quirks.c +13 -0
+static void quirk_msi_intx_disable_qca_bug(struct pci_dev *dev) {
+    static u16 qca_eth_devid[] = {
+                    PCI_DEVICE_ID_AR8161,
+                    PCI_DEVICE_ID_AR8162,
+                    PCI_DEVICE_ID_AR8171,
+                    PCI_DEVICE_ID_AR8172};
+    struct pci_dev *p;
+    int i;
+
+    /* AR816X/AR817X MSI is fixed at HW level from revision 0x18 */
+    for (i = 0; i < ARRAY_SIZE(qca_eth_devid); i++) {
+            p = pci_get_device(PCI_VENDOR_ID_ATTANSIC,
+                               qca_eth_devid[i],

xiong,

The "FINAL" fixup is called just in pci_apply_final_quirks(), if I am correct.

In this function, it will go through all the pci devices which are registered in the system. And try to invoke the fixup hook.

Also, before invode the hook, in function pci_do_fixups() it will make sure the hook just apply to the devices whose VendorID and DeviceID match what you defined in DECLARE_PCI_FIXUP_FINAL.

So I think there is no need to iterate on all those pci device, before you want to change the pci_dev->dev_flags.

Quoted 9 lines

drivers/pci/quirks.c static void quirk_msi_intx_disable_ati_bug(struct pci_dev *dev)

Quoted 6 lines
drivers/pci/quirks.c +6 -0
+                               NULL);
+            if (!p)
+                    return;
+
+            if (p->revision < 0x18)
+                    dev->dev_flags |=

PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG;

Quoted 2 lines
(quoted diff) +2 -0
+            pci_dev_put(p);
+    }
Quoted 7 lines

Wei, thanks for you feedback, this patch is just follow the function 'quirk_msi_intx_disable_ati_bug' in quirks.c Is it ok if I revise code as:

        static void quirk_msi_intx_disable_qca_bug(struct pci_dev *dev)
        {
                If (dev->revision < 0x18)
                        dev->dev_flags |=  PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG;
        }

Per the comment in pci_ids.h, you should not add #defines there unless they are used in more than one place. So in this case, you would just use the hex constants directly in quirks.c, as we already do for the existing ATTANSIC quirks.

As far as the loop with pci_get_device(), the revised patch is probably what you want, but it is not functionally equivalent to the original. Let's say you have two devices:

1) 8161 rev 0x18
2) 8171 rev 0x17

The original patch will disable MSI for the 8161 because there is *another* device (the 8171) with rev < 0x18. I doubt that's what you want.

I'd like to see a dev_info() saying that you're disabling MSI for this device so that when somebody complains "my device should be using MSI but isn't," it's easy to figure out why not.

Bjorn

#4 lore raw
Quoted 20 lines
Quoted 7 lines

Wei, thanks for you feedback, this patch is just follow the function 'quirk_msi_intx_disable_ati_bug' in quirks.c Is it ok if I revise code as:

        static void quirk_msi_intx_disable_qca_bug(struct pci_dev *dev)
        {
                If (dev->revision < 0x18)
                        dev->dev_flags |=  PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG;
        }

Per the comment in pci_ids.h, you should not add #defines there unless they are used in more than one place. So in this case, you would just use the hex constants directly in quirks.c, as we already do for the existing ATTANSIC quirks.

As far as the loop with pci_get_device(), the revised patch is probably what you want, but it is not functionally equivalent to the original. Let's say you have two devices:

1) 8161 rev 0x18
2) 8171 rev 0x17

Quoted 7 lines

The original patch will disable MSI for the 8161 because there is *another* device (the 8171) with rev < 0x18. I doubt that's what you want.

I'd like to see a dev_info() saying that you're disabling MSI for this device so that when somebody complains "my device should be using MSI but isn't," it's easy to figure out why not.

Bjorn, your example is very clear for me. I made a bug for the original patch :)

BTW. The flag of PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG isn't disable MSI on such devices,
But not enable PCI INT_DISABLE bit for PCI_COMMAND register when enable MSI function.
Some devices like AR8161 with revision lower than 0x18 will not issue MSI interrupt if INT_DISABLE bit is set.

Thanks
Xiong

A message that is not in the archive (sent off-list or not yet received): 20130308012236.GA5213@richard.(null)

#6 lore raw
Quoted 6 lines
Quoted 6 lines

Wei, thanks for you feedback, this patch is just follow the function 'quirk_msi_intx_disable_ati_bug' in quirks.c Is it ok if I revise code as:

	static void quirk_msi_intx_disable_qca_bug(struct pci_dev *dev)
	{
		If (dev->revision < 0x18)
			dev->dev_flags |=
Quoted 7 lines

PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG;

Quoted 1 line
	}

I think it is ok. Have you tested it?

If your test passed, I think you can send out another version.

Wei,
I have tested it. It's ok. thanks for your help. I sent out another version patch yesterday.

-Xiong