Skip to content

Commit 90cc0c3

Browse files
westeribjorn-helgaas
authored andcommitted
PCI: shpchp: Add shpchp_is_native()
In the same way we do for pciehp, add shpchp_is_native(), which returns true if the bridge should be handled by the native SHPC driver. Then convert the driver to use this function. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
1 parent bed4e9c commit 90cc0c3

File tree

6 files changed

+35
-16
lines changed

6 files changed

+35
-16
lines changed

drivers/pci/hotplug/acpi_pcihp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ int acpi_get_hp_hw_control_from_firmware(struct pci_dev *pdev)
8383
* OSHP within the scope of the hotplug controller and its parents,
8484
* up to the host bridge under which this controller exists.
8585
*/
86-
host = pci_find_host_bridge(pdev->bus);
87-
if (host->native_shpc_hotplug)
86+
if (shpchp_is_native(pdev))
8887
return 0;
8988

9089
/* If _OSC exists, we should not evaluate OSHP */
90+
host = pci_find_host_bridge(pdev->bus);
9191
root = acpi_pci_find_root(ACPI_HANDLE(&host->dev));
9292
if (root->osc_support_set)
9393
goto no_control;

drivers/pci/hotplug/shpchp.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ struct controller {
105105
};
106106

107107
/* Define AMD SHPC ID */
108-
#define PCI_DEVICE_ID_AMD_GOLAM_7450 0x7450
109108
#define PCI_DEVICE_ID_AMD_POGO_7458 0x7458
110109

111110
/* AMD PCI-X bridge registers */

drivers/pci/hotplug/shpchp_core.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -270,24 +270,12 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
270270
return 0;
271271
}
272272

273-
static int is_shpc_capable(struct pci_dev *dev)
274-
{
275-
if (dev->vendor == PCI_VENDOR_ID_AMD &&
276-
dev->device == PCI_DEVICE_ID_AMD_GOLAM_7450)
277-
return 1;
278-
if (!pci_find_capability(dev, PCI_CAP_ID_SHPC))
279-
return 0;
280-
if (acpi_get_hp_hw_control_from_firmware(dev))
281-
return 0;
282-
return 1;
283-
}
284-
285273
static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
286274
{
287275
int rc;
288276
struct controller *ctrl;
289277

290-
if (!is_shpc_capable(pdev))
278+
if (acpi_get_hp_hw_control_from_firmware(pdev))
291279
return -ENODEV;
292280

293281
ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);

drivers/pci/pci-acpi.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,35 @@ bool pciehp_is_native(struct pci_dev *bridge)
394394
return host->native_pcie_hotplug;
395395
}
396396

397+
/**
398+
* shpchp_is_native - Check whether a hotplug port is handled by the OS
399+
* @bridge: Hotplug port to check
400+
*
401+
* Returns true if the given @bridge is handled by the native SHPC hotplug
402+
* driver.
403+
*/
404+
bool shpchp_is_native(struct pci_dev *bridge)
405+
{
406+
const struct pci_host_bridge *host;
407+
408+
if (!IS_ENABLED(CONFIG_HOTPLUG_PCI_SHPC))
409+
return false;
410+
411+
/*
412+
* It is assumed that AMD GOLAM chips support SHPC but they do not
413+
* have SHPC capability.
414+
*/
415+
if (bridge->vendor == PCI_VENDOR_ID_AMD &&
416+
bridge->device == PCI_DEVICE_ID_AMD_GOLAM_7450)
417+
return true;
418+
419+
if (!pci_find_capability(bridge, PCI_CAP_ID_SHPC))
420+
return false;
421+
422+
host = pci_find_host_bridge(bridge->bus);
423+
return host->native_shpc_hotplug;
424+
}
425+
397426
/**
398427
* pci_acpi_wake_bus - Root bus wakeup notification fork function.
399428
* @context: Device wakeup context.

include/linux/pci_hotplug.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ struct hotplug_params {
164164
int pci_get_hp_params(struct pci_dev *dev, struct hotplug_params *hpp);
165165
bool pciehp_is_native(struct pci_dev *bridge);
166166
int acpi_get_hp_hw_control_from_firmware(struct pci_dev *bridge);
167+
bool shpchp_is_native(struct pci_dev *bridge);
167168
int acpi_pci_check_ejectable(struct pci_bus *pbus, acpi_handle handle);
168169
int acpi_pci_detect_ejectable(acpi_handle handle);
169170
#else
@@ -178,5 +179,6 @@ static inline int acpi_get_hp_hw_control_from_firmware(struct pci_dev *bridge)
178179
return 0;
179180
}
180181
static inline bool pciehp_is_native(struct pci_dev *bridge) { return true; }
182+
static inline bool shpchp_is_native(struct pci_dev *bridge) { return true; }
181183
#endif
182184
#endif

include/linux/pci_ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@
561561
#define PCI_DEVICE_ID_AMD_OPUS_7443 0x7443
562562
#define PCI_DEVICE_ID_AMD_VIPER_7443 0x7443
563563
#define PCI_DEVICE_ID_AMD_OPUS_7445 0x7445
564+
#define PCI_DEVICE_ID_AMD_GOLAM_7450 0x7450
564565
#define PCI_DEVICE_ID_AMD_8111_PCI 0x7460
565566
#define PCI_DEVICE_ID_AMD_8111_LPC 0x7468
566567
#define PCI_DEVICE_ID_AMD_8111_IDE 0x7469

0 commit comments

Comments
 (0)