Skip to content

Commit 6de8eee

Browse files
committed
Merge branch 'pci/hotplug-vga' into for-linus
* pci/hotplug-vga: ACPIPHP / radeon / nouveau: Remove acpi_bus_no_hotplug() PCI: Add pci_ignore_hotplug() to ignore hotplug events for a device
2 parents fd7155f + f91ce35 commit 6de8eee

File tree

9 files changed

+31
-51
lines changed

9 files changed

+31
-51
lines changed

drivers/acpi/bus.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,6 @@ void acpi_bus_detach_private_data(acpi_handle handle)
177177
}
178178
EXPORT_SYMBOL_GPL(acpi_bus_detach_private_data);
179179

180-
void acpi_bus_no_hotplug(acpi_handle handle)
181-
{
182-
struct acpi_device *adev = NULL;
183-
184-
acpi_bus_get_device(handle, &adev);
185-
if (adev)
186-
adev->flags.no_hotplug = true;
187-
}
188-
EXPORT_SYMBOL_GPL(acpi_bus_no_hotplug);
189-
190180
static void acpi_print_osc_error(acpi_handle handle,
191181
struct acpi_osc_context *context, char *error)
192182
{

drivers/gpu/drm/nouveau/nouveau_acpi.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ static struct nouveau_dsm_priv {
4646
bool dsm_detected;
4747
bool optimus_detected;
4848
acpi_handle dhandle;
49-
acpi_handle other_handle;
5049
acpi_handle rom_handle;
5150
} nouveau_dsm_priv;
5251

@@ -222,10 +221,9 @@ static int nouveau_dsm_pci_probe(struct pci_dev *pdev)
222221
if (!dhandle)
223222
return false;
224223

225-
if (!acpi_has_method(dhandle, "_DSM")) {
226-
nouveau_dsm_priv.other_handle = dhandle;
224+
if (!acpi_has_method(dhandle, "_DSM"))
227225
return false;
228-
}
226+
229227
if (acpi_check_dsm(dhandle, nouveau_dsm_muid, 0x00000102,
230228
1 << NOUVEAU_DSM_POWER))
231229
retval |= NOUVEAU_DSM_HAS_MUX;
@@ -301,16 +299,6 @@ static bool nouveau_dsm_detect(void)
301299
printk(KERN_INFO "VGA switcheroo: detected DSM switching method %s handle\n",
302300
acpi_method_name);
303301
nouveau_dsm_priv.dsm_detected = true;
304-
/*
305-
* On some systems hotplug events are generated for the device
306-
* being switched off when _DSM is executed. They cause ACPI
307-
* hotplug to trigger and attempt to remove the device from
308-
* the system, which causes it to break down. Prevent that from
309-
* happening by setting the no_hotplug flag for the involved
310-
* ACPI device objects.
311-
*/
312-
acpi_bus_no_hotplug(nouveau_dsm_priv.dhandle);
313-
acpi_bus_no_hotplug(nouveau_dsm_priv.other_handle);
314302
ret = true;
315303
}
316304

drivers/gpu/drm/nouveau/nouveau_drm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ int nouveau_pmops_suspend(struct device *dev)
627627

628628
pci_save_state(pdev);
629629
pci_disable_device(pdev);
630+
pci_ignore_hotplug(pdev);
630631
pci_set_power_state(pdev, PCI_D3hot);
631632
return 0;
632633
}

drivers/gpu/drm/radeon/radeon_atpx_handler.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ static struct radeon_atpx_priv {
3333
bool atpx_detected;
3434
/* handle for device - and atpx */
3535
acpi_handle dhandle;
36-
acpi_handle other_handle;
3736
struct radeon_atpx atpx;
3837
} radeon_atpx_priv;
3938

@@ -453,10 +452,9 @@ static bool radeon_atpx_pci_probe_handle(struct pci_dev *pdev)
453452
return false;
454453

455454
status = acpi_get_handle(dhandle, "ATPX", &atpx_handle);
456-
if (ACPI_FAILURE(status)) {
457-
radeon_atpx_priv.other_handle = dhandle;
455+
if (ACPI_FAILURE(status))
458456
return false;
459-
}
457+
460458
radeon_atpx_priv.dhandle = dhandle;
461459
radeon_atpx_priv.atpx.handle = atpx_handle;
462460
return true;
@@ -540,16 +538,6 @@ static bool radeon_atpx_detect(void)
540538
printk(KERN_INFO "VGA switcheroo: detected switching method %s handle\n",
541539
acpi_method_name);
542540
radeon_atpx_priv.atpx_detected = true;
543-
/*
544-
* On some systems hotplug events are generated for the device
545-
* being switched off when ATPX is executed. They cause ACPI
546-
* hotplug to trigger and attempt to remove the device from
547-
* the system, which causes it to break down. Prevent that from
548-
* happening by setting the no_hotplug flag for the involved
549-
* ACPI device objects.
550-
*/
551-
acpi_bus_no_hotplug(radeon_atpx_priv.dhandle);
552-
acpi_bus_no_hotplug(radeon_atpx_priv.other_handle);
553541
return true;
554542
}
555543
return false;

drivers/gpu/drm/radeon/radeon_drv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ static int radeon_pmops_runtime_suspend(struct device *dev)
440440
ret = radeon_suspend_kms(drm_dev, false, false);
441441
pci_save_state(pdev);
442442
pci_disable_device(pdev);
443+
pci_ignore_hotplug(pdev);
443444
pci_set_power_state(pdev, PCI_D3cold);
444445
drm_dev->switch_power_state = DRM_SWITCH_POWER_DYNAMIC_OFF;
445446

drivers/pci/hotplug/acpiphp_glue.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -560,19 +560,15 @@ static void disable_slot(struct acpiphp_slot *slot)
560560
slot->flags &= (~SLOT_ENABLED);
561561
}
562562

563-
static bool acpiphp_no_hotplug(struct acpi_device *adev)
564-
{
565-
return adev && adev->flags.no_hotplug;
566-
}
567-
568563
static bool slot_no_hotplug(struct acpiphp_slot *slot)
569564
{
570-
struct acpiphp_func *func;
565+
struct pci_bus *bus = slot->bus;
566+
struct pci_dev *dev;
571567

572-
list_for_each_entry(func, &slot->funcs, sibling)
573-
if (acpiphp_no_hotplug(func_to_acpi_device(func)))
568+
list_for_each_entry(dev, &bus->devices, bus_list) {
569+
if (PCI_SLOT(dev->devfn) == slot->device && dev->ignore_hotplug)
574570
return true;
575-
571+
}
576572
return false;
577573
}
578574

@@ -645,7 +641,7 @@ static void trim_stale_devices(struct pci_dev *dev)
645641

646642
status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta);
647643
alive = (ACPI_SUCCESS(status) && device_status_valid(sta))
648-
|| acpiphp_no_hotplug(adev);
644+
|| dev->ignore_hotplug;
649645
}
650646
if (!alive)
651647
alive = pci_device_is_present(dev);

drivers/pci/hotplug/pciehp_hpc.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,8 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
506506
{
507507
struct controller *ctrl = (struct controller *)dev_id;
508508
struct pci_dev *pdev = ctrl_dev(ctrl);
509+
struct pci_bus *subordinate = pdev->subordinate;
510+
struct pci_dev *dev;
509511
struct slot *slot = ctrl->slot;
510512
u16 detected, intr_loc;
511513

@@ -539,6 +541,16 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
539541
wake_up(&ctrl->queue);
540542
}
541543

544+
if (subordinate) {
545+
list_for_each_entry(dev, &subordinate->devices, bus_list) {
546+
if (dev->ignore_hotplug) {
547+
ctrl_dbg(ctrl, "ignoring hotplug event %#06x (%s requested no hotplug)\n",
548+
intr_loc, pci_name(dev));
549+
return IRQ_HANDLED;
550+
}
551+
}
552+
}
553+
542554
if (!(intr_loc & ~PCI_EXP_SLTSTA_CC))
543555
return IRQ_HANDLED;
544556

include/acpi/acpi_bus.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,9 @@ struct acpi_device_flags {
204204
u32 match_driver:1;
205205
u32 initialized:1;
206206
u32 visited:1;
207-
u32 no_hotplug:1;
208207
u32 hotplug_notify:1;
209208
u32 is_dock_station:1;
210-
u32 reserved:22;
209+
u32 reserved:23;
211210
};
212211

213212
/* File System */
@@ -412,7 +411,6 @@ void acpi_bus_private_data_handler(acpi_handle, void *);
412411
int acpi_bus_get_private_data(acpi_handle, void **);
413412
int acpi_bus_attach_private_data(acpi_handle, void *);
414413
void acpi_bus_detach_private_data(acpi_handle);
415-
void acpi_bus_no_hotplug(acpi_handle handle);
416414
extern int acpi_notifier_call_chain(struct acpi_device *, u32, u32);
417415
extern int register_acpi_notifier(struct notifier_block *);
418416
extern int unregister_acpi_notifier(struct notifier_block *);

include/linux/pci.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ struct pci_dev {
303303
D3cold, not set for devices
304304
powered on/off by the
305305
corresponding bridge */
306+
unsigned int ignore_hotplug:1; /* Ignore hotplug events */
306307
unsigned int d3_delay; /* D3->D0 transition time in ms */
307308
unsigned int d3cold_delay; /* D3cold->D0 transition time in ms */
308309

@@ -1021,6 +1022,11 @@ bool pci_dev_run_wake(struct pci_dev *dev);
10211022
bool pci_check_pme_status(struct pci_dev *dev);
10221023
void pci_pme_wakeup_bus(struct pci_bus *bus);
10231024

1025+
static inline void pci_ignore_hotplug(struct pci_dev *dev)
1026+
{
1027+
dev->ignore_hotplug = 1;
1028+
}
1029+
10241030
static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state,
10251031
bool enable)
10261032
{

0 commit comments

Comments
 (0)