Skip to content

Commit b29f83a

Browse files
committed
Merge tag 'pci-v3.17-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
Pull PCI fixes from Bjorn Helgaas: "These fix: - Boot video device detection on dual-GPU Apple systems - Hotplug fiascos on VGA switcheroo with radeon & nouveau drivers - Boot hang on Freescale i.MX6 systems - Excessive "no hotplug settings from platform" warnings In particular: Enumeration - Don't default exclusively to first video device (Bruno Prémont) PCI device hotplug - Remove "no hotplug settings from platform" warning (Bjorn Helgaas) - Add pci_ignore_hotplug() for VGA switcheroo (Bjorn Helgaas) Freescale i.MX6 - Put LTSSM in "Detect" state before disabling (Lucas Stach)" * tag 'pci-v3.17-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: vgaarb: Drop obsolete #ifndef vgaarb: Don't default exclusively to first video device with mem+io ACPIPHP / radeon / nouveau: Remove acpi_bus_no_hotplug() PCI: Remove "no hotplug settings from platform" warning PCI: Add pci_ignore_hotplug() to ignore hotplug events for a device PCI: imx6: Put LTSSM in "Detect" state before disabling it MAINTAINERS: Add Lucas Stach as co-maintainer for i.MX6 PCI driver
2 parents 73030ef + 649ae75 commit b29f83a

File tree

16 files changed

+110
-114
lines changed

16 files changed

+110
-114
lines changed

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6876,7 +6876,7 @@ F: arch/x86/kernel/quirks.c
68766876

68776877
PCI DRIVER FOR IMX6
68786878
M: Richard Zhu <[email protected]>
6879-
M: Shawn Guo <[email protected]>
6879+
M: Lucas Stach <[email protected]>
68806880
68816881
L: [email protected] (moderated for non-subscribers)
68826882
S: Maintained

arch/ia64/pci/fixup.c

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,6 @@ static void pci_fixup_video(struct pci_dev *pdev)
3838
return;
3939
/* Maybe, this machine supports legacy memory map. */
4040

41-
if (!vga_default_device()) {
42-
resource_size_t start, end;
43-
int i;
44-
45-
/* Does firmware framebuffer belong to us? */
46-
for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
47-
if (!(pci_resource_flags(pdev, i) & IORESOURCE_MEM))
48-
continue;
49-
50-
start = pci_resource_start(pdev, i);
51-
end = pci_resource_end(pdev, i);
52-
53-
if (!start || !end)
54-
continue;
55-
56-
if (screen_info.lfb_base >= start &&
57-
(screen_info.lfb_base + screen_info.lfb_size) < end)
58-
vga_set_default_device(pdev);
59-
}
60-
}
61-
6241
/* Is VGA routed to us? */
6342
bus = pdev->bus;
6443
while (bus) {
@@ -83,8 +62,7 @@ static void pci_fixup_video(struct pci_dev *pdev)
8362
pci_read_config_word(pdev, PCI_COMMAND, &config);
8463
if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) {
8564
pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW;
86-
dev_printk(KERN_DEBUG, &pdev->dev, "Boot video device\n");
87-
vga_set_default_device(pdev);
65+
dev_printk(KERN_DEBUG, &pdev->dev, "Video device with shadowed ROM\n");
8866
}
8967
}
9068
}

arch/x86/pci/fixup.c

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -326,27 +326,6 @@ static void pci_fixup_video(struct pci_dev *pdev)
326326
struct pci_bus *bus;
327327
u16 config;
328328

329-
if (!vga_default_device()) {
330-
resource_size_t start, end;
331-
int i;
332-
333-
/* Does firmware framebuffer belong to us? */
334-
for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
335-
if (!(pci_resource_flags(pdev, i) & IORESOURCE_MEM))
336-
continue;
337-
338-
start = pci_resource_start(pdev, i);
339-
end = pci_resource_end(pdev, i);
340-
341-
if (!start || !end)
342-
continue;
343-
344-
if (screen_info.lfb_base >= start &&
345-
(screen_info.lfb_base + screen_info.lfb_size) < end)
346-
vga_set_default_device(pdev);
347-
}
348-
}
349-
350329
/* Is VGA routed to us? */
351330
bus = pdev->bus;
352331
while (bus) {
@@ -371,8 +350,7 @@ static void pci_fixup_video(struct pci_dev *pdev)
371350
pci_read_config_word(pdev, PCI_COMMAND, &config);
372351
if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) {
373352
pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW;
374-
dev_printk(KERN_DEBUG, &pdev->dev, "Boot video device\n");
375-
vga_set_default_device(pdev);
353+
dev_printk(KERN_DEBUG, &pdev->dev, "Video device with shadowed ROM\n");
376354
}
377355
}
378356
}

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/gpu/vga/vgaarb.c

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <linux/poll.h>
4242
#include <linux/miscdevice.h>
4343
#include <linux/slab.h>
44+
#include <linux/screen_info.h>
4445

4546
#include <linux/uaccess.h>
4647

@@ -112,10 +113,8 @@ static int vga_str_to_iostate(char *buf, int str_size, int *io_state)
112113
return 1;
113114
}
114115

115-
#ifndef __ARCH_HAS_VGA_DEFAULT_DEVICE
116116
/* this is only used a cookie - it should not be dereferenced */
117117
static struct pci_dev *vga_default;
118-
#endif
119118

120119
static void vga_arb_device_card_gone(struct pci_dev *pdev);
121120

@@ -131,7 +130,6 @@ static struct vga_device *vgadev_find(struct pci_dev *pdev)
131130
}
132131

133132
/* Returns the default VGA device (vgacon's babe) */
134-
#ifndef __ARCH_HAS_VGA_DEFAULT_DEVICE
135133
struct pci_dev *vga_default_device(void)
136134
{
137135
return vga_default;
@@ -147,7 +145,6 @@ void vga_set_default_device(struct pci_dev *pdev)
147145
pci_dev_put(vga_default);
148146
vga_default = pci_dev_get(pdev);
149147
}
150-
#endif
151148

152149
static inline void vga_irq_set_state(struct vga_device *vgadev, bool state)
153150
{
@@ -583,11 +580,12 @@ static bool vga_arbiter_add_pci_device(struct pci_dev *pdev)
583580
/* Deal with VGA default device. Use first enabled one
584581
* by default if arch doesn't have it's own hook
585582
*/
586-
#ifndef __ARCH_HAS_VGA_DEFAULT_DEVICE
587583
if (vga_default == NULL &&
588-
((vgadev->owns & VGA_RSRC_LEGACY_MASK) == VGA_RSRC_LEGACY_MASK))
584+
((vgadev->owns & VGA_RSRC_LEGACY_MASK) == VGA_RSRC_LEGACY_MASK)) {
585+
pr_info("vgaarb: setting as boot device: PCI:%s\n",
586+
pci_name(pdev));
589587
vga_set_default_device(pdev);
590-
#endif
588+
}
591589

592590
vga_arbiter_check_bridge_sharing(vgadev);
593591

@@ -621,10 +619,8 @@ static bool vga_arbiter_del_pci_device(struct pci_dev *pdev)
621619
goto bail;
622620
}
623621

624-
#ifndef __ARCH_HAS_VGA_DEFAULT_DEVICE
625622
if (vga_default == pdev)
626623
vga_set_default_device(NULL);
627-
#endif
628624

629625
if (vgadev->decodes & (VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM))
630626
vga_decode_count--;
@@ -1320,6 +1316,38 @@ static int __init vga_arb_device_init(void)
13201316
pr_info("vgaarb: loaded\n");
13211317

13221318
list_for_each_entry(vgadev, &vga_list, list) {
1319+
#if defined(CONFIG_X86) || defined(CONFIG_IA64)
1320+
/* Override I/O based detection done by vga_arbiter_add_pci_device()
1321+
* as it may take the wrong device (e.g. on Apple system under EFI).
1322+
*
1323+
* Select the device owning the boot framebuffer if there is one.
1324+
*/
1325+
resource_size_t start, end;
1326+
int i;
1327+
1328+
/* Does firmware framebuffer belong to us? */
1329+
for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
1330+
if (!(pci_resource_flags(vgadev->pdev, i) & IORESOURCE_MEM))
1331+
continue;
1332+
1333+
start = pci_resource_start(vgadev->pdev, i);
1334+
end = pci_resource_end(vgadev->pdev, i);
1335+
1336+
if (!start || !end)
1337+
continue;
1338+
1339+
if (screen_info.lfb_base < start ||
1340+
(screen_info.lfb_base + screen_info.lfb_size) >= end)
1341+
continue;
1342+
if (!vga_default_device())
1343+
pr_info("vgaarb: setting as boot device: PCI:%s\n",
1344+
pci_name(vgadev->pdev));
1345+
else if (vgadev->pdev != vga_default_device())
1346+
pr_info("vgaarb: overriding boot device: PCI:%s\n",
1347+
pci_name(vgadev->pdev));
1348+
vga_set_default_device(vgadev->pdev);
1349+
}
1350+
#endif
13231351
if (vgadev->bridge_has_one_vga)
13241352
pr_info("vgaarb: bridge control possible %s\n", pci_name(vgadev->pdev));
13251353
else

drivers/pci/host/pci-imx6.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ struct imx6_pcie {
4949

5050
/* PCIe Port Logic registers (memory-mapped) */
5151
#define PL_OFFSET 0x700
52+
#define PCIE_PL_PFLR (PL_OFFSET + 0x08)
53+
#define PCIE_PL_PFLR_LINK_STATE_MASK (0x3f << 16)
54+
#define PCIE_PL_PFLR_FORCE_LINK (1 << 15)
5255
#define PCIE_PHY_DEBUG_R0 (PL_OFFSET + 0x28)
5356
#define PCIE_PHY_DEBUG_R1 (PL_OFFSET + 0x2c)
5457
#define PCIE_PHY_DEBUG_R1_XMLH_LINK_IN_TRAINING (1 << 29)
@@ -214,6 +217,32 @@ static int imx6q_pcie_abort_handler(unsigned long addr,
214217
static int imx6_pcie_assert_core_reset(struct pcie_port *pp)
215218
{
216219
struct imx6_pcie *imx6_pcie = to_imx6_pcie(pp);
220+
u32 val, gpr1, gpr12;
221+
222+
/*
223+
* If the bootloader already enabled the link we need some special
224+
* handling to get the core back into a state where it is safe to
225+
* touch it for configuration. As there is no dedicated reset signal
226+
* wired up for MX6QDL, we need to manually force LTSSM into "detect"
227+
* state before completely disabling LTSSM, which is a prerequisite
228+
* for core configuration.
229+
*
230+
* If both LTSSM_ENABLE and REF_SSP_ENABLE are active we have a strong
231+
* indication that the bootloader activated the link.
232+
*/
233+
regmap_read(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, &gpr1);
234+
regmap_read(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, &gpr12);
235+
236+
if ((gpr1 & IMX6Q_GPR1_PCIE_REF_CLK_EN) &&
237+
(gpr12 & IMX6Q_GPR12_PCIE_CTL_2)) {
238+
val = readl(pp->dbi_base + PCIE_PL_PFLR);
239+
val &= ~PCIE_PL_PFLR_LINK_STATE_MASK;
240+
val |= PCIE_PL_PFLR_FORCE_LINK;
241+
writel(val, pp->dbi_base + PCIE_PL_PFLR);
242+
243+
regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12,
244+
IMX6Q_GPR12_PCIE_CTL_2, 0 << 10);
245+
}
217246

218247
regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,
219248
IMX6Q_GPR1_PCIE_TEST_PD, 1 << 18);
@@ -589,6 +618,14 @@ static int __init imx6_pcie_probe(struct platform_device *pdev)
589618
return 0;
590619
}
591620

621+
static void imx6_pcie_shutdown(struct platform_device *pdev)
622+
{
623+
struct imx6_pcie *imx6_pcie = platform_get_drvdata(pdev);
624+
625+
/* bring down link, so bootloader gets clean state in case of reboot */
626+
imx6_pcie_assert_core_reset(&imx6_pcie->pp);
627+
}
628+
592629
static const struct of_device_id imx6_pcie_of_match[] = {
593630
{ .compatible = "fsl,imx6q-pcie", },
594631
{},
@@ -601,6 +638,7 @@ static struct platform_driver imx6_pcie_driver = {
601638
.owner = THIS_MODULE,
602639
.of_match_table = imx6_pcie_of_match,
603640
},
641+
.shutdown = imx6_pcie_shutdown,
604642
};
605643

606644
/* Freescale PCIe driver does not allow module unload */

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);

0 commit comments

Comments
 (0)