Skip to content

Commit 78e5ad7

Browse files
committed
Merge branch 'pci/enumeration'
- Convert pci-host-common.c platform .remove() callback to .remove_new() returning 'void' since it's not useful to return error codes here (Uwe Kleine-König) - Log a message about updating AMD USB controller class code (so dwc3, not xhci, claims it) only when we actually change it (Guilherme G. Piccoli) - Use PCI_HEADER_TYPE_* instead of literals in x86, powerpc, SCSI lpfc (Ilpo Järvinen) - Clean up open-coded PCIBIOS return code mangling (Ilpo Järvinen) - Fix 64GT/s effective data rate calculation to use 1b/1b encoding rather than the 8b/10b or 128b/130b used by lower rates (Ilpo Järvinen) * pci/enumeration: PCI: Fix 64GT/s effective data rate calculation x86/pci: Clean up open-coded PCIBIOS return code mangling scsi: lpfc: Use PCI_HEADER_TYPE_MFD instead of literal powerpc/fsl-pci: Use PCI_HEADER_TYPE_MASK instead of literal x86/pci: Use PCI_HEADER_TYPE_* instead of literals PCI: Only override AMD USB controller if required PCI: host-generic: Convert to platform remove callback returning void
2 parents 996e337 + ac4f189 commit 78e5ad7

File tree

10 files changed

+38
-24
lines changed

10 files changed

+38
-24
lines changed

arch/powerpc/sysdev/fsl_pci.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static void quirk_fsl_pcie_early(struct pci_dev *dev)
5454

5555
/* if we aren't in host mode don't bother */
5656
pci_read_config_byte(dev, PCI_HEADER_TYPE, &hdr_type);
57-
if ((hdr_type & 0x7f) != PCI_HEADER_TYPE_BRIDGE)
57+
if ((hdr_type & PCI_HEADER_TYPE_MASK) != PCI_HEADER_TYPE_BRIDGE)
5858
return;
5959

6060
dev->class = PCI_CLASS_BRIDGE_PCI_NORMAL;
@@ -581,7 +581,7 @@ static int fsl_add_bridge(struct platform_device *pdev, int is_primary)
581581
hose->ops = &fsl_indirect_pcie_ops;
582582
/* For PCIE read HEADER_TYPE to identify controller mode */
583583
early_read_config_byte(hose, 0, 0, PCI_HEADER_TYPE, &hdr_type);
584-
if ((hdr_type & 0x7f) != PCI_HEADER_TYPE_BRIDGE)
584+
if ((hdr_type & PCI_HEADER_TYPE_MASK) != PCI_HEADER_TYPE_BRIDGE)
585585
goto no_bridge;
586586

587587
} else {

arch/x86/kernel/aperture_64.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,9 @@ static u32 __init search_agp_bridge(u32 *order, int *valid_agp)
259259
order);
260260
}
261261

262-
/* No multi-function device? */
263262
type = read_pci_config_byte(bus, slot, func,
264263
PCI_HEADER_TYPE);
265-
if (!(type & 0x80))
264+
if (!(type & PCI_HEADER_TYPE_MFD))
266265
break;
267266
}
268267
}

arch/x86/kernel/early-quirks.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,13 +779,13 @@ static int __init check_dev_quirk(int num, int slot, int func)
779779
type = read_pci_config_byte(num, slot, func,
780780
PCI_HEADER_TYPE);
781781

782-
if ((type & 0x7f) == PCI_HEADER_TYPE_BRIDGE) {
782+
if ((type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
783783
sec = read_pci_config_byte(num, slot, func, PCI_SECONDARY_BUS);
784784
if (sec > num)
785785
early_pci_scan_bus(sec);
786786
}
787787

788-
if (!(type & 0x80))
788+
if (!(type & PCI_HEADER_TYPE_MFD))
789789
return -1;
790790

791791
return 0;

arch/x86/pci/pcbios.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* BIOS32 and PCI BIOS handling.
44
*/
55

6+
#include <linux/bits.h>
7+
#include <linux/bitfield.h>
68
#include <linux/pci.h>
79
#include <linux/init.h>
810
#include <linux/slab.h>
@@ -29,8 +31,19 @@
2931
#define PCIBIOS_HW_TYPE1_SPEC 0x10
3032
#define PCIBIOS_HW_TYPE2_SPEC 0x20
3133

34+
/*
35+
* Returned in EAX:
36+
* - AH: return code
37+
*/
38+
#define PCIBIOS_RETURN_CODE GENMASK(15, 8)
39+
3240
int pcibios_enabled;
3341

42+
static u8 pcibios_get_return_code(u32 eax)
43+
{
44+
return FIELD_GET(PCIBIOS_RETURN_CODE, eax);
45+
}
46+
3447
/* According to the BIOS specification at:
3548
* http://members.datafast.net.au/dft0802/specs/bios21.pdf, we could
3649
* restrict the x zone to some pages and make it ro. But this may be
@@ -154,7 +167,7 @@ static int __init check_pcibios(void)
154167
: "memory");
155168
local_irq_restore(flags);
156169

157-
status = (eax >> 8) & 0xff;
170+
status = pcibios_get_return_code(eax);
158171
hw_mech = eax & 0xff;
159172
major_ver = (ebx >> 8) & 0xff;
160173
minor_ver = ebx & 0xff;
@@ -227,7 +240,7 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
227240

228241
raw_spin_unlock_irqrestore(&pci_config_lock, flags);
229242

230-
return (int)((result & 0xff00) >> 8);
243+
return pcibios_get_return_code(result);
231244
}
232245

233246
static int pci_bios_write(unsigned int seg, unsigned int bus,
@@ -269,7 +282,7 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
269282

270283
raw_spin_unlock_irqrestore(&pci_config_lock, flags);
271284

272-
return (int)((result & 0xff00) >> 8);
285+
return pcibios_get_return_code(result);
273286
}
274287

275288

@@ -385,9 +398,10 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
385398
"m" (opt)
386399
: "memory");
387400
DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
388-
if (ret & 0xff00)
389-
printk(KERN_ERR "PCI: Error %02x when fetching IRQ routing table.\n", (ret >> 8) & 0xff);
390-
else if (opt.size) {
401+
ret = pcibios_get_return_code(ret);
402+
if (ret) {
403+
printk(KERN_ERR "PCI: Error %02x when fetching IRQ routing table.\n", ret);
404+
} else if (opt.size) {
391405
rt = kmalloc(sizeof(struct irq_routing_table) + opt.size, GFP_KERNEL);
392406
if (rt) {
393407
memset(rt, 0, sizeof(struct irq_routing_table));
@@ -415,7 +429,7 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
415429
"b" ((dev->bus->number << 8) | dev->devfn),
416430
"c" ((irq << 8) | (pin + 10)),
417431
"S" (&pci_indirect));
418-
return !(ret & 0xff00);
432+
return pcibios_get_return_code(ret) == PCIBIOS_SUCCESSFUL;
419433
}
420434
EXPORT_SYMBOL(pcibios_set_irq_routing);
421435

drivers/pci/controller/pci-host-common.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,14 @@ int pci_host_common_probe(struct platform_device *pdev)
8585
}
8686
EXPORT_SYMBOL_GPL(pci_host_common_probe);
8787

88-
int pci_host_common_remove(struct platform_device *pdev)
88+
void pci_host_common_remove(struct platform_device *pdev)
8989
{
9090
struct pci_host_bridge *bridge = platform_get_drvdata(pdev);
9191

9292
pci_lock_rescan_remove();
9393
pci_stop_root_bus(bridge->bus);
9494
pci_remove_root_bus(bridge->bus);
9595
pci_unlock_rescan_remove();
96-
97-
return 0;
9896
}
9997
EXPORT_SYMBOL_GPL(pci_host_common_remove);
10098

drivers/pci/controller/pci-host-generic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static struct platform_driver gen_pci_driver = {
8282
.of_match_table = gen_pci_of_match,
8383
},
8484
.probe = pci_host_common_probe,
85-
.remove = pci_host_common_remove,
85+
.remove_new = pci_host_common_remove,
8686
};
8787
module_platform_driver(gen_pci_driver);
8888

drivers/pci/pci.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ void pci_bus_put(struct pci_bus *bus);
272272

273273
/* PCIe speed to Mb/s reduced by encoding overhead */
274274
#define PCIE_SPEED2MBS_ENC(speed) \
275-
((speed) == PCIE_SPEED_64_0GT ? 64000*128/130 : \
275+
((speed) == PCIE_SPEED_64_0GT ? 64000*1/1 : \
276276
(speed) == PCIE_SPEED_32_0GT ? 32000*128/130 : \
277277
(speed) == PCIE_SPEED_16_0GT ? 16000*128/130 : \
278278
(speed) == PCIE_SPEED_8_0GT ? 8000*128/130 : \

drivers/pci/quirks.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -702,10 +702,13 @@ static void quirk_amd_dwc_class(struct pci_dev *pdev)
702702
{
703703
u32 class = pdev->class;
704704

705-
/* Use "USB Device (not host controller)" class */
706-
pdev->class = PCI_CLASS_SERIAL_USB_DEVICE;
707-
pci_info(pdev, "PCI class overridden (%#08x -> %#08x) so dwc3 driver can claim this instead of xhci\n",
708-
class, pdev->class);
705+
if (class != PCI_CLASS_SERIAL_USB_DEVICE) {
706+
/* Use "USB Device (not host controller)" class */
707+
pdev->class = PCI_CLASS_SERIAL_USB_DEVICE;
708+
pci_info(pdev,
709+
"PCI class overridden (%#08x -> %#08x) so dwc3 driver can claim this instead of xhci\n",
710+
class, pdev->class);
711+
}
709712
}
710713
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB,
711714
quirk_amd_dwc_class);

drivers/scsi/lpfc/lpfc_sli.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4875,7 +4875,7 @@ void lpfc_reset_barrier(struct lpfc_hba *phba)
48754875
lockdep_assert_held(&phba->hbalock);
48764876

48774877
pci_read_config_byte(phba->pcidev, PCI_HEADER_TYPE, &hdrtype);
4878-
if (hdrtype != 0x80 ||
4878+
if (hdrtype != PCI_HEADER_TYPE_MFD ||
48794879
(FC_JEDEC_ID(phba->vpd.rev.biuRev) != HELIOS_JEDEC_ID &&
48804880
FC_JEDEC_ID(phba->vpd.rev.biuRev) != THOR_JEDEC_ID))
48814881
return;

include/linux/pci-ecam.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,6 @@ extern const struct pci_ecam_ops loongson_pci_ecam_ops; /* Loongson PCIe */
9393
#if IS_ENABLED(CONFIG_PCI_HOST_COMMON)
9494
/* for DT-based PCI controllers that support ECAM */
9595
int pci_host_common_probe(struct platform_device *pdev);
96-
int pci_host_common_remove(struct platform_device *pdev);
96+
void pci_host_common_remove(struct platform_device *pdev);
9797
#endif
9898
#endif

0 commit comments

Comments
 (0)