History

Merge branch 'pci/misc'

- Constify struct bin_attribute for sysfs, VPD, P2PDMA, and the IBM ACPI hotplug driver (Thomas Weißschuh) - Update PCI_EXP_LNKCAP_SLS comment (Lukas Wunner) - Drop superfluous pm_wakeup.h include (Wolfram Sang) - Remove redundant PCI_VSEC_HDR and PCI_VSEC_HDR_LEN_SHIFT (Dongdong Zhang) - Correct documentation of the 'config_acs=' kernel parameter (Akihiko Odaki) * pci/misc: Documentation: Fix pci=config_acs= example PCI: Remove redundant PCI_VSEC_HDR and PCI_VSEC_HDR_LEN_SHIFT PCI: Don't include 'pm_wakeup.h' directly PCI: Update code comment on PCI_EXP_LNKCAP_SLS for PCIe r3.0 PCI/ACPI: Constify 'struct bin_attribute' PCI/P2PDMA: Constify 'struct bin_attribute' PCI/VPD: Constify 'struct bin_attribute' PCI/sysfs: Constify 'struct bin_attribute'

Bjorn Helgaas committed 1 year ago

Commit 10ff5bb2 parents 4d3bf4e b388fac8 files · +39 −42Browse files

Unified · Split

8 files
  1. Documentation/admin-guide/kernel-parameters.txt +1 −1
  2. drivers/pci/hotplug/acpiphp_ibm.c +3 −3
  3. drivers/pci/p2pdma.c +3 −3
  4. drivers/pci/pci-sysfs.c +21 −21
  5. drivers/pci/pci.c +0 −1
  6. drivers/pci/vpd.c +7 −7
  7. drivers/vfio/pci/vfio_pci_config.c +3 −2
  8. include/uapi/linux/pci_regs.h +1 −4
Documentation/admin-guide/kernel-parameters.txt+1−1
@@ -4673,7 +4673,7 @@ · 4672 unmodified lines
4673 '1' – force enabled4673 '1' – force enabled
4674 'x' – unchanged4674 'x' – unchanged
4675 For example,4675 For example,
4676 pci=config_acs=10x4676 pci=config_acs=10x@pci:0:0
4677 would configure all devices that support4677 would configure all devices that support
4678 ACS to enable P2P Request Redirect, disable4678 ACS to enable P2P Request Redirect, disable
4679 Translation Blocking, and leave Source4679 Translation Blocking, and leave Source
drivers/pci/hotplug/acpiphp_ibm.c+3−3
@@ -84,7 +84,7 @@ static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status); · 83 unmodified lines
84static void ibm_handle_events(acpi_handle handle, u32 event, void *context);84static void ibm_handle_events(acpi_handle handle, u32 event, void *context);
85static int ibm_get_table_from_acpi(char **bufp);85static int ibm_get_table_from_acpi(char **bufp);
86static ssize_t ibm_read_apci_table(struct file *filp, struct kobject *kobj,86static ssize_t ibm_read_apci_table(struct file *filp, struct kobject *kobj,
87 struct bin_attribute *bin_attr,87 const struct bin_attribute *bin_attr,
88 char *buffer, loff_t pos, size_t size);88 char *buffer, loff_t pos, size_t size);
89static acpi_status __init ibm_find_acpi_device(acpi_handle handle,89static acpi_status __init ibm_find_acpi_device(acpi_handle handle,
90 u32 lvl, void *context, void **rv);90 u32 lvl, void *context, void **rv);
@@ -98,7 +98,7 @@ static struct bin_attribute ibm_apci_table_attr __ro_after_init = { · 7 unmodified lines
98 .name = "apci_table",98 .name = "apci_table",
99 .mode = S_IRUGO,99 .mode = S_IRUGO,
100 },100 },
101 .read = ibm_read_apci_table,101 .read_new = ibm_read_apci_table,
102 .write = NULL,102 .write = NULL,
103};103};
104static struct acpiphp_attention_info ibm_attention_info =104static struct acpiphp_attention_info ibm_attention_info =
@@ -353,7 +353,7 @@ read_table_done: · 248 unmodified lines
353 * our solution is to only allow reading the table in all at once.353 * our solution is to only allow reading the table in all at once.
354 */354 */
355static ssize_t ibm_read_apci_table(struct file *filp, struct kobject *kobj,355static ssize_t ibm_read_apci_table(struct file *filp, struct kobject *kobj,
356 struct bin_attribute *bin_attr,356 const struct bin_attribute *bin_attr,
357 char *buffer, loff_t pos, size_t size)357 char *buffer, loff_t pos, size_t size)
358{358{
359 int bytes_read = -EINVAL;359 int bytes_read = -EINVAL;
drivers/pci/p2pdma.c+3−3
@@ -161,7 +161,7 @@ out: · 160 unmodified lines
161 return ret;161 return ret;
162}162}
163 163
164static struct bin_attribute p2pmem_alloc_attr = {164static const struct bin_attribute p2pmem_alloc_attr = {
165 .attr = { .name = "allocate", .mode = 0660 },165 .attr = { .name = "allocate", .mode = 0660 },
166 .mmap = p2pmem_alloc_mmap,166 .mmap = p2pmem_alloc_mmap,
167 /*167 /*
@@ -180,14 +180,14 @@ static struct attribute *p2pmem_attrs[] = { · 12 unmodified lines
180 NULL,180 NULL,
181};181};
182 182
183static struct bin_attribute *p2pmem_bin_attrs[] = {183static const struct bin_attribute *const p2pmem_bin_attrs[] = {
184 &p2pmem_alloc_attr,184 &p2pmem_alloc_attr,
185 NULL,185 NULL,
186};186};
187 187
188static const struct attribute_group p2pmem_group = {188static const struct attribute_group p2pmem_group = {
189 .attrs = p2pmem_attrs,189 .attrs = p2pmem_attrs,
190 .bin_attrs = p2pmem_bin_attrs,190 .bin_attrs_new = p2pmem_bin_attrs,
191 .name = "p2pmem",191 .name = "p2pmem",
192};192};
193 193
drivers/pci/pci-sysfs.c+21−21
@@ -695,7 +695,7 @@ static ssize_t boot_vga_show(struct device *dev, struct device_attribute *attr, · 694 unmodified lines
695static DEVICE_ATTR_RO(boot_vga);695static DEVICE_ATTR_RO(boot_vga);
696 696
697static ssize_t pci_read_config(struct file *filp, struct kobject *kobj,697static ssize_t pci_read_config(struct file *filp, struct kobject *kobj,
698 struct bin_attribute *bin_attr, char *buf,698 const struct bin_attribute *bin_attr, char *buf,
699 loff_t off, size_t count)699 loff_t off, size_t count)
700{700{
701 struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));701 struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));
@@ -770,7 +770,7 @@ static ssize_t pci_read_config(struct file *filp, struct kobject *kobj, · 68 unmodified lines
770}770}
771 771
772static ssize_t pci_write_config(struct file *filp, struct kobject *kobj,772static ssize_t pci_write_config(struct file *filp, struct kobject *kobj,
773 struct bin_attribute *bin_attr, char *buf,773 const struct bin_attribute *bin_attr, char *buf,
774 loff_t off, size_t count)774 loff_t off, size_t count)
775{775{
776 struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));776 struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));
@@ -838,9 +838,9 @@ static ssize_t pci_write_config(struct file *filp, struct kobject *kobj, · 61 unmodified lines
838 838
839 return count;839 return count;
840}840}
841static BIN_ATTR(config, 0644, pci_read_config, pci_write_config, 0);841static const BIN_ATTR(config, 0644, pci_read_config, pci_write_config, 0);
842 842
843static struct bin_attribute *pci_dev_config_attrs[] = {843static const struct bin_attribute *const pci_dev_config_attrs[] = {
844 &bin_attr_config,844 &bin_attr_config,
845 NULL,845 NULL,
846};846};
@@ -857,7 +857,7 @@ static size_t pci_dev_config_attr_bin_size(struct kobject *kobj, · 10 unmodified lines
857}857}
858 858
859static const struct attribute_group pci_dev_config_attr_group = {859static const struct attribute_group pci_dev_config_attr_group = {
860 .bin_attrs = pci_dev_config_attrs,860 .bin_attrs_new = pci_dev_config_attrs,
861 .bin_size = pci_dev_config_attr_bin_size,861 .bin_size = pci_dev_config_attr_bin_size,
862};862};
863 863
@@ -888,8 +888,8 @@ pci_llseek_resource(struct file *filep, · 24 unmodified lines
888 * callback routine (pci_legacy_read).888 * callback routine (pci_legacy_read).
889 */889 */
890static ssize_t pci_read_legacy_io(struct file *filp, struct kobject *kobj,890static ssize_t pci_read_legacy_io(struct file *filp, struct kobject *kobj,
891 struct bin_attribute *bin_attr, char *buf,891 const struct bin_attribute *bin_attr,
892 loff_t off, size_t count)892 char *buf, loff_t off, size_t count)
893{893{
894 struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj));894 struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj));
895 895
@@ -913,8 +913,8 @@ static ssize_t pci_read_legacy_io(struct file *filp, struct kobject *kobj, · 17 unmodified lines
913 * callback routine (pci_legacy_write).913 * callback routine (pci_legacy_write).
914 */914 */
915static ssize_t pci_write_legacy_io(struct file *filp, struct kobject *kobj,915static ssize_t pci_write_legacy_io(struct file *filp, struct kobject *kobj,
916 struct bin_attribute *bin_attr, char *buf,916 const struct bin_attribute *bin_attr,
917 loff_t off, size_t count)917 char *buf, loff_t off, size_t count)
918{918{
919 struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj));919 struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj));
920 920
@@ -1004,8 +1004,8 @@ void pci_create_legacy_files(struct pci_bus *b) · 83 unmodified lines
1004 b->legacy_io->attr.name = "legacy_io";1004 b->legacy_io->attr.name = "legacy_io";
1005 b->legacy_io->size = 0xffff;1005 b->legacy_io->size = 0xffff;
1006 b->legacy_io->attr.mode = 0600;1006 b->legacy_io->attr.mode = 0600;
1007 b->legacy_io->read = pci_read_legacy_io;1007 b->legacy_io->read_new = pci_read_legacy_io;
1008 b->legacy_io->write = pci_write_legacy_io;1008 b->legacy_io->write_new = pci_write_legacy_io;
1009 /* See pci_create_attr() for motivation */1009 /* See pci_create_attr() for motivation */
1010 b->legacy_io->llseek = pci_llseek_resource;1010 b->legacy_io->llseek = pci_llseek_resource;
1011 b->legacy_io->mmap = pci_mmap_legacy_io;1011 b->legacy_io->mmap = pci_mmap_legacy_io;
@@ -1100,7 +1100,7 @@ static int pci_mmap_resource_wc(struct file *filp, struct kobject *kobj, · 88 unmodified lines
1100}1100}
1101 1101
1102static ssize_t pci_resource_io(struct file *filp, struct kobject *kobj,1102static ssize_t pci_resource_io(struct file *filp, struct kobject *kobj,
1103 struct bin_attribute *attr, char *buf,1103 const struct bin_attribute *attr, char *buf,
1104 loff_t off, size_t count, bool write)1104 loff_t off, size_t count, bool write)
1105{1105{
1106#ifdef CONFIG_HAS_IOPORT1106#ifdef CONFIG_HAS_IOPORT
@@ -1143,14 +1143,14 @@ static ssize_t pci_resource_io(struct file *filp, struct kobject *kobj, · 36 unmodified lines
1143}1143}
1144 1144
1145static ssize_t pci_read_resource_io(struct file *filp, struct kobject *kobj,1145static ssize_t pci_read_resource_io(struct file *filp, struct kobject *kobj,
1146 struct bin_attribute *attr, char *buf,1146 const struct bin_attribute *attr, char *buf,
1147 loff_t off, size_t count)1147 loff_t off, size_t count)
1148{1148{
1149 return pci_resource_io(filp, kobj, attr, buf, off, count, false);1149 return pci_resource_io(filp, kobj, attr, buf, off, count, false);
1150}1150}
1151 1151
1152static ssize_t pci_write_resource_io(struct file *filp, struct kobject *kobj,1152static ssize_t pci_write_resource_io(struct file *filp, struct kobject *kobj,
1153 struct bin_attribute *attr, char *buf,1153 const struct bin_attribute *attr, char *buf,
1154 loff_t off, size_t count)1154 loff_t off, size_t count)
1155{1155{
1156 int ret;1156 int ret;
@@ -1211,8 +1211,8 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine) · 54 unmodified lines
1211 } else {1211 } else {
1212 sprintf(res_attr_name, "resource%d", num);1212 sprintf(res_attr_name, "resource%d", num);
1213 if (pci_resource_flags(pdev, num) & IORESOURCE_IO) {1213 if (pci_resource_flags(pdev, num) & IORESOURCE_IO) {
1214 res_attr->read = pci_read_resource_io;1214 res_attr->read_new = pci_read_resource_io;
1215 res_attr->write = pci_write_resource_io;1215 res_attr->write_new = pci_write_resource_io;
1216 if (arch_can_pci_mmap_io())1216 if (arch_can_pci_mmap_io())
1217 res_attr->mmap = pci_mmap_resource_uc;1217 res_attr->mmap = pci_mmap_resource_uc;
1218 } else {1218 } else {
@@ -1293,7 +1293,7 @@ void __weak pci_remove_resource_files(struct pci_dev *dev) { return; } · 74 unmodified lines
1293 * writing anything except 0 enables it1293 * writing anything except 0 enables it
1294 */1294 */
1295static ssize_t pci_write_rom(struct file *filp, struct kobject *kobj,1295static ssize_t pci_write_rom(struct file *filp, struct kobject *kobj,
1296 struct bin_attribute *bin_attr, char *buf,1296 const struct bin_attribute *bin_attr, char *buf,
1297 loff_t off, size_t count)1297 loff_t off, size_t count)
1298{1298{
1299 struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));1299 struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
@@ -1319,7 +1319,7 @@ static ssize_t pci_write_rom(struct file *filp, struct kobject *kobj, · 19 unmodified lines
1319 * device corresponding to @kobj.1319 * device corresponding to @kobj.
1320 */1320 */
1321static ssize_t pci_read_rom(struct file *filp, struct kobject *kobj,1321static ssize_t pci_read_rom(struct file *filp, struct kobject *kobj,
1322 struct bin_attribute *bin_attr, char *buf,1322 const struct bin_attribute *bin_attr, char *buf,
1323 loff_t off, size_t count)1323 loff_t off, size_t count)
1324{1324{
1325 struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));1325 struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
@@ -1345,9 +1345,9 @@ static ssize_t pci_read_rom(struct file *filp, struct kobject *kobj, · 19 unmodified lines
1345 1345
1346 return count;1346 return count;
1347}1347}
1348static BIN_ATTR(rom, 0600, pci_read_rom, pci_write_rom, 0);1348static const BIN_ATTR(rom, 0600, pci_read_rom, pci_write_rom, 0);
1349 1349
1350static struct bin_attribute *pci_dev_rom_attrs[] = {1350static const struct bin_attribute *const pci_dev_rom_attrs[] = {
1351 &bin_attr_rom,1351 &bin_attr_rom,
1352 NULL,1352 NULL,
1353};1353};
@@ -1373,7 +1373,7 @@ static size_t pci_dev_rom_attr_bin_size(struct kobject *kobj, · 19 unmodified lines
1373}1373}
1374 1374
1375static const struct attribute_group pci_dev_rom_attr_group = {1375static const struct attribute_group pci_dev_rom_attr_group = {
1376 .bin_attrs = pci_dev_rom_attrs,1376 .bin_attrs_new = pci_dev_rom_attrs,
1377 .is_bin_visible = pci_dev_rom_attr_is_visible,1377 .is_bin_visible = pci_dev_rom_attr_is_visible,
1378 .bin_size = pci_dev_rom_attr_bin_size,1378 .bin_size = pci_dev_rom_attr_bin_size,
1379};1379};
drivers/pci/pci.c+0−1
@@ -23,7 +23,6 @@ · 22 unmodified lines
23#include <linux/string.h>23#include <linux/string.h>
24#include <linux/log2.h>24#include <linux/log2.h>
25#include <linux/logic_pio.h>25#include <linux/logic_pio.h>
26#include <linux/pm_wakeup.h>
27#include <linux/device.h>26#include <linux/device.h>
28#include <linux/pm_runtime.h>27#include <linux/pm_runtime.h>
29#include <linux/pci_hotplug.h>28#include <linux/pci_hotplug.h>
drivers/pci/vpd.c+7−7
@@ -271,8 +271,8 @@ void pci_vpd_init(struct pci_dev *dev) · 270 unmodified lines
271}271}
272 272
273static ssize_t vpd_read(struct file *filp, struct kobject *kobj,273static ssize_t vpd_read(struct file *filp, struct kobject *kobj,
274 struct bin_attribute *bin_attr, char *buf, loff_t off,274 const struct bin_attribute *bin_attr, char *buf,
275 size_t count)275 loff_t off, size_t count)
276{276{
277 struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));277 struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));
278 struct pci_dev *vpd_dev = dev;278 struct pci_dev *vpd_dev = dev;
@@ -295,8 +295,8 @@ static ssize_t vpd_read(struct file *filp, struct kobject *kobj, · 16 unmodified lines
295}295}
296 296
297static ssize_t vpd_write(struct file *filp, struct kobject *kobj,297static ssize_t vpd_write(struct file *filp, struct kobject *kobj,
298 struct bin_attribute *bin_attr, char *buf, loff_t off,298 const struct bin_attribute *bin_attr, char *buf,
299 size_t count)299 loff_t off, size_t count)
300{300{
301 struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));301 struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));
302 struct pci_dev *vpd_dev = dev;302 struct pci_dev *vpd_dev = dev;
@@ -317,9 +317,9 @@ static ssize_t vpd_write(struct file *filp, struct kobject *kobj, · 14 unmodified lines
317 317
318 return ret;318 return ret;
319}319}
320static BIN_ATTR(vpd, 0600, vpd_read, vpd_write, 0);320static const BIN_ATTR(vpd, 0600, vpd_read, vpd_write, 0);
321 321
322static struct bin_attribute *vpd_attrs[] = {322static const struct bin_attribute *const vpd_attrs[] = {
323 &bin_attr_vpd,323 &bin_attr_vpd,
324 NULL,324 NULL,
325};325};
@@ -336,7 +336,7 @@ static umode_t vpd_attr_is_visible(struct kobject *kobj, · 10 unmodified lines
336}336}
337 337
338const struct attribute_group pci_dev_vpd_attr_group = {338const struct attribute_group pci_dev_vpd_attr_group = {
339 .bin_attrs = vpd_attrs,339 .bin_attrs_new = vpd_attrs,
340 .is_bin_visible = vpd_attr_is_visible,340 .is_bin_visible = vpd_attr_is_visible,
341};341};
342 342
drivers/vfio/pci/vfio_pci_config.c+3−2
@@ -1389,11 +1389,12 @@ static int vfio_ext_cap_len(struct vfio_pci_core_device *vdev, u16 ecap, u16 epo · 1388 unmodified lines
1389 1389
1390 switch (ecap) {1390 switch (ecap) {
1391 case PCI_EXT_CAP_ID_VNDR:1391 case PCI_EXT_CAP_ID_VNDR:
1392 ret = pci_read_config_dword(pdev, epos + PCI_VSEC_HDR, &dword);1392 ret = pci_read_config_dword(pdev, epos + PCI_VNDR_HEADER,
1393 &dword);
1393 if (ret)1394 if (ret)
1394 return pcibios_err_to_errno(ret);1395 return pcibios_err_to_errno(ret);
1395 1396
1396 return dword >> PCI_VSEC_HDR_LEN_SHIFT;1397 return PCI_VNDR_HEADER_LEN(dword);
1397 case PCI_EXT_CAP_ID_VC:1398 case PCI_EXT_CAP_ID_VC:
1398 case PCI_EXT_CAP_ID_VC9:1399 case PCI_EXT_CAP_ID_VC9:
1399 case PCI_EXT_CAP_ID_MFVC:1400 case PCI_EXT_CAP_ID_MFVC:
include/uapi/linux/pci_regs.h+1−4
@@ -533,7 +533,7 @@ · 532 unmodified lines
533#define PCI_EXP_DEVSTA_TRPND 0x0020 /* Transactions Pending */533#define PCI_EXP_DEVSTA_TRPND 0x0020 /* Transactions Pending */
534#define PCI_CAP_EXP_RC_ENDPOINT_SIZEOF_V1 12 /* v1 endpoints without link end here */534#define PCI_CAP_EXP_RC_ENDPOINT_SIZEOF_V1 12 /* v1 endpoints without link end here */
535#define PCI_EXP_LNKCAP 0x0c /* Link Capabilities */535#define PCI_EXP_LNKCAP 0x0c /* Link Capabilities */
536#define PCI_EXP_LNKCAP_SLS 0x0000000f /* Supported Link Speeds */536#define PCI_EXP_LNKCAP_SLS 0x0000000f /* Max Link Speed (prior to PCIe r3.0: Supported Link Speeds) */
537#define PCI_EXP_LNKCAP_SLS_2_5GB 0x00000001 /* LNKCAP2 SLS Vector bit 0 */537#define PCI_EXP_LNKCAP_SLS_2_5GB 0x00000001 /* LNKCAP2 SLS Vector bit 0 */
538#define PCI_EXP_LNKCAP_SLS_5_0GB 0x00000002 /* LNKCAP2 SLS Vector bit 1 */538#define PCI_EXP_LNKCAP_SLS_5_0GB 0x00000002 /* LNKCAP2 SLS Vector bit 1 */
539#define PCI_EXP_LNKCAP_SLS_8_0GB 0x00000003 /* LNKCAP2 SLS Vector bit 2 */539#define PCI_EXP_LNKCAP_SLS_8_0GB 0x00000003 /* LNKCAP2 SLS Vector bit 2 */
@@ -1004,9 +1004,6 @@ · 464 unmodified lines
1004#define PCI_ACS_CTRL 0x06 /* ACS Control Register */1004#define PCI_ACS_CTRL 0x06 /* ACS Control Register */
1005#define PCI_ACS_EGRESS_CTL_V 0x08 /* ACS Egress Control Vector */1005#define PCI_ACS_EGRESS_CTL_V 0x08 /* ACS Egress Control Vector */
1006 1006
1007#define PCI_VSEC_HDR 4 /* extended cap - vendor-specific */
1008#define PCI_VSEC_HDR_LEN_SHIFT 20 /* shift for length field */
1009
1010/* SATA capability */1007/* SATA capability */
1011#define PCI_SATA_REGS 4 /* SATA REGs specifier */1008#define PCI_SATA_REGS 4 /* SATA REGs specifier */
1012#define PCI_SATA_REGS_MASK 0xF /* location - BAR#/inline */1009#define PCI_SATA_REGS_MASK 0xF /* location - BAR#/inline */