From c4a2c4870adefca175a4ece214b070904c7c5c2e Mon Sep 17 00:00:00 2001 From: Leonid Lobachev Date: Mon, 25 Mar 2019 17:57:15 -0700 Subject: [PATCH] staging: gasket: Fix pci remove/rescan for kernel module build. For driver build as module pci_fixup_header approach doesn't work. This causes apex pci class to remain 0xff and BARs remain unclaimed. Adding a retry with explicit fixup function call workarounds the problem. Bug: 129287752 Change-Id: Id5ff85ef427d3740706a214d3beb1c9bbf42ab5a Signed-off-by: Leonid Lobachev --- apex_driver.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apex_driver.c b/apex_driver.c index e227017..1eff202 100644 --- a/apex_driver.c +++ b/apex_driver.c @@ -652,7 +652,7 @@ static void apex_pci_fixup_class(struct pci_dev *pdev) pdev->class = (PCI_CLASS_SYSTEM_OTHER << 8) | pdev->class; } DECLARE_PCI_FIXUP_CLASS_HEADER(APEX_PCI_VENDOR_ID, APEX_PCI_DEVICE_ID, - PCI_CLASS_NOT_DEFINED, 8, apex_pci_fixup_class); + PCI_ANY_ID, 8, apex_pci_fixup_class); static int apex_pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) @@ -663,6 +663,13 @@ static int apex_pci_probe(struct pci_dev *pci_dev, struct gasket_dev *gasket_dev; ret = pci_enable_device(pci_dev); +#ifdef MODULE + if (ret) { + apex_pci_fixup_class(pci_dev); + pci_bus_assign_resources(pci_dev->bus); + ret = pci_enable_device(pci_dev); + } +#endif if (ret) { dev_err(&pci_dev->dev, "error enabling PCI device\n"); return ret;