aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pci/iov.c42
-rw-r--r--drivers/pci/pci-sysfs.c3
-rw-r--r--drivers/pci/pci.c85
-rw-r--r--drivers/pci/pci.h4
-rw-r--r--drivers/pci/probe.c61
-rw-r--r--drivers/pci/quirks.c12
-rw-r--r--include/linux/pci.h11
-rw-r--r--include/linux/pci_ids.h1
8 files changed, 168 insertions, 51 deletions
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 538de9057c23..8adf4a64f291 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -112,6 +112,29 @@ resource_size_t pci_iov_resource_size(struct pci_dev *dev, int resno)
112 return dev->sriov->barsz[resno - PCI_IOV_RESOURCES]; 112 return dev->sriov->barsz[resno - PCI_IOV_RESOURCES];
113} 113}
114 114
115static void pci_read_vf_config_common(struct pci_dev *virtfn)
116{
117 struct pci_dev *physfn = virtfn->physfn;
118
119 /*
120 * Some config registers are the same across all associated VFs.
121 * Read them once from VF0 so we can skip reading them from the
122 * other VFs.
123 *
124 * PCIe r4.0, sec 9.3.4.1, technically doesn't require all VFs to
125 * have the same Revision ID and Subsystem ID, but we assume they
126 * do.
127 */
128 pci_read_config_dword(virtfn, PCI_CLASS_REVISION,
129 &physfn->sriov->class);
130 pci_read_config_byte(virtfn, PCI_HEADER_TYPE,
131 &physfn->sriov->hdr_type);
132 pci_read_config_word(virtfn, PCI_SUBSYSTEM_VENDOR_ID,
133 &physfn->sriov->subsystem_vendor);
134 pci_read_config_word(virtfn, PCI_SUBSYSTEM_ID,
135 &physfn->sriov->subsystem_device);
136}
137
115int pci_iov_add_virtfn(struct pci_dev *dev, int id) 138int pci_iov_add_virtfn(struct pci_dev *dev, int id)
116{ 139{
117 int i; 140 int i;
@@ -134,13 +157,17 @@ int pci_iov_add_virtfn(struct pci_dev *dev, int id)
134 virtfn->devfn = pci_iov_virtfn_devfn(dev, id); 157 virtfn->devfn = pci_iov_virtfn_devfn(dev, id);
135 virtfn->vendor = dev->vendor; 158 virtfn->vendor = dev->vendor;
136 virtfn->device = iov->vf_device; 159 virtfn->device = iov->vf_device;
160 virtfn->is_virtfn = 1;
161 virtfn->physfn = pci_dev_get(dev);
162
163 if (id == 0)
164 pci_read_vf_config_common(virtfn);
165
137 rc = pci_setup_device(virtfn); 166 rc = pci_setup_device(virtfn);
138 if (rc) 167 if (rc)
139 goto failed0; 168 goto failed1;
140 169
141 virtfn->dev.parent = dev->dev.parent; 170 virtfn->dev.parent = dev->dev.parent;
142 virtfn->physfn = pci_dev_get(dev);
143 virtfn->is_virtfn = 1;
144 virtfn->multifunction = 0; 171 virtfn->multifunction = 0;
145 172
146 for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) { 173 for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) {
@@ -161,10 +188,10 @@ int pci_iov_add_virtfn(struct pci_dev *dev, int id)
161 sprintf(buf, "virtfn%u", id); 188 sprintf(buf, "virtfn%u", id);
162 rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf); 189 rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf);
163 if (rc) 190 if (rc)
164 goto failed1; 191 goto failed2;
165 rc = sysfs_create_link(&virtfn->dev.kobj, &dev->dev.kobj, "physfn"); 192 rc = sysfs_create_link(&virtfn->dev.kobj, &dev->dev.kobj, "physfn");
166 if (rc) 193 if (rc)
167 goto failed2; 194 goto failed3;
168 195
169 kobject_uevent(&virtfn->dev.kobj, KOBJ_CHANGE); 196 kobject_uevent(&virtfn->dev.kobj, KOBJ_CHANGE);
170 197
@@ -172,11 +199,12 @@ int pci_iov_add_virtfn(struct pci_dev *dev, int id)
172 199
173 return 0; 200 return 0;
174 201
175failed2: 202failed3:
176 sysfs_remove_link(&dev->dev.kobj, buf); 203 sysfs_remove_link(&dev->dev.kobj, buf);
204failed2:
205 pci_stop_and_remove_bus_device(virtfn);
177failed1: 206failed1:
178 pci_dev_put(dev); 207 pci_dev_put(dev);
179 pci_stop_and_remove_bus_device(virtfn);
180failed0: 208failed0:
181 virtfn_remove_bus(dev->bus, bus); 209 virtfn_remove_bus(dev->bus, bus);
182failed: 210failed:
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 478dde8330c3..116e97dafda0 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1515,11 +1515,10 @@ static int pci_create_capabilities_sysfs(struct pci_dev *dev)
1515 /* Active State Power Management */ 1515 /* Active State Power Management */
1516 pcie_aspm_create_sysfs_dev_files(dev); 1516 pcie_aspm_create_sysfs_dev_files(dev);
1517 1517
1518 if (!pci_probe_reset_function(dev)) { 1518 if (dev->reset_fn) {
1519 retval = device_create_file(&dev->dev, &reset_attr); 1519 retval = device_create_file(&dev->dev, &reset_attr);
1520 if (retval) 1520 if (retval)
1521 goto error; 1521 goto error;
1522 dev->reset_fn = 1;
1523 } 1522 }
1524 return 0; 1523 return 0;
1525 1524
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index bfac1d5ae842..43aeecc4b675 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -127,6 +127,9 @@ static int __init pcie_port_pm_setup(char *str)
127} 127}
128__setup("pcie_port_pm=", pcie_port_pm_setup); 128__setup("pcie_port_pm=", pcie_port_pm_setup);
129 129
130/* Time to wait after a reset for device to become responsive */
131#define PCIE_RESET_READY_POLL_MS 60000
132
130/** 133/**
131 * pci_bus_max_busnr - returns maximum PCI bus number of given bus' children 134 * pci_bus_max_busnr - returns maximum PCI bus number of given bus' children
132 * @bus: pointer to PCI bus structure to search 135 * @bus: pointer to PCI bus structure to search
@@ -3969,20 +3972,13 @@ int pci_wait_for_pending_transaction(struct pci_dev *dev)
3969} 3972}
3970EXPORT_SYMBOL(pci_wait_for_pending_transaction); 3973EXPORT_SYMBOL(pci_wait_for_pending_transaction);
3971 3974
3972static void pci_flr_wait(struct pci_dev *dev) 3975static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout)
3973{ 3976{
3974 int delay = 1, timeout = 60000; 3977 int delay = 1;
3975 u32 id; 3978 u32 id;
3976 3979
3977 /* 3980 /*
3978 * Per PCIe r3.1, sec 6.6.2, a device must complete an FLR within 3981 * After reset, the device should not silently discard config
3979 * 100ms, but may silently discard requests while the FLR is in
3980 * progress. Wait 100ms before trying to access the device.
3981 */
3982 msleep(100);
3983
3984 /*
3985 * After 100ms, the device should not silently discard config
3986 * requests, but it may still indicate that it needs more time by 3982 * requests, but it may still indicate that it needs more time by
3987 * responding to them with CRS completions. The Root Port will 3983 * responding to them with CRS completions. The Root Port will
3988 * generally synthesize ~0 data to complete the read (except when 3984 * generally synthesize ~0 data to complete the read (except when
@@ -3996,14 +3992,14 @@ static void pci_flr_wait(struct pci_dev *dev)
3996 pci_read_config_dword(dev, PCI_COMMAND, &id); 3992 pci_read_config_dword(dev, PCI_COMMAND, &id);
3997 while (id == ~0) { 3993 while (id == ~0) {
3998 if (delay > timeout) { 3994 if (delay > timeout) {
3999 pci_warn(dev, "not ready %dms after FLR; giving up\n", 3995 pci_warn(dev, "not ready %dms after %s; giving up\n",
4000 100 + delay - 1); 3996 delay - 1, reset_type);
4001 return; 3997 return -ENOTTY;
4002 } 3998 }
4003 3999
4004 if (delay > 1000) 4000 if (delay > 1000)
4005 pci_info(dev, "not ready %dms after FLR; waiting\n", 4001 pci_info(dev, "not ready %dms after %s; waiting\n",
4006 100 + delay - 1); 4002 delay - 1, reset_type);
4007 4003
4008 msleep(delay); 4004 msleep(delay);
4009 delay *= 2; 4005 delay *= 2;
@@ -4011,7 +4007,10 @@ static void pci_flr_wait(struct pci_dev *dev)
4011 } 4007 }
4012 4008
4013 if (delay > 1000) 4009 if (delay > 1000)
4014 pci_info(dev, "ready %dms after FLR\n", 100 + delay - 1); 4010 pci_info(dev, "ready %dms after %s\n", delay - 1,
4011 reset_type);
4012
4013 return 0;
4015} 4014}
4016 4015
4017/** 4016/**
@@ -4040,13 +4039,21 @@ static bool pcie_has_flr(struct pci_dev *dev)
4040 * device supports FLR before calling this function, e.g. by using the 4039 * device supports FLR before calling this function, e.g. by using the
4041 * pcie_has_flr() helper. 4040 * pcie_has_flr() helper.
4042 */ 4041 */
4043void pcie_flr(struct pci_dev *dev) 4042int pcie_flr(struct pci_dev *dev)
4044{ 4043{
4045 if (!pci_wait_for_pending_transaction(dev)) 4044 if (!pci_wait_for_pending_transaction(dev))
4046 pci_err(dev, "timed out waiting for pending transaction; performing function level reset anyway\n"); 4045 pci_err(dev, "timed out waiting for pending transaction; performing function level reset anyway\n");
4047 4046
4048 pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR); 4047 pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR);
4049 pci_flr_wait(dev); 4048
4049 /*
4050 * Per PCIe r4.0, sec 6.6.2, a device must complete an FLR within
4051 * 100ms, but may silently discard requests while the FLR is in
4052 * progress. Wait 100ms before trying to access the device.
4053 */
4054 msleep(100);
4055
4056 return pci_dev_wait(dev, "FLR", PCIE_RESET_READY_POLL_MS);
4050} 4057}
4051EXPORT_SYMBOL_GPL(pcie_flr); 4058EXPORT_SYMBOL_GPL(pcie_flr);
4052 4059
@@ -4079,8 +4086,16 @@ static int pci_af_flr(struct pci_dev *dev, int probe)
4079 pci_err(dev, "timed out waiting for pending transaction; performing AF function level reset anyway\n"); 4086 pci_err(dev, "timed out waiting for pending transaction; performing AF function level reset anyway\n");
4080 4087
4081 pci_write_config_byte(dev, pos + PCI_AF_CTRL, PCI_AF_CTRL_FLR); 4088 pci_write_config_byte(dev, pos + PCI_AF_CTRL, PCI_AF_CTRL_FLR);
4082 pci_flr_wait(dev); 4089
4083 return 0; 4090 /*
4091 * Per Advanced Capabilities for Conventional PCI ECN, 13 April 2006,
4092 * updated 27 July 2006; a device must complete an FLR within
4093 * 100ms, but may silently discard requests while the FLR is in
4094 * progress. Wait 100ms before trying to access the device.
4095 */
4096 msleep(100);
4097
4098 return pci_dev_wait(dev, "AF_FLR", PCIE_RESET_READY_POLL_MS);
4084} 4099}
4085 4100
4086/** 4101/**
@@ -4125,7 +4140,7 @@ static int pci_pm_reset(struct pci_dev *dev, int probe)
4125 pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, csr); 4140 pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, csr);
4126 pci_dev_d3_sleep(dev); 4141 pci_dev_d3_sleep(dev);
4127 4142
4128 return 0; 4143 return pci_dev_wait(dev, "PM D3->D0", PCIE_RESET_READY_POLL_MS);
4129} 4144}
4130 4145
4131void pci_reset_secondary_bus(struct pci_dev *dev) 4146void pci_reset_secondary_bus(struct pci_dev *dev)
@@ -4167,9 +4182,11 @@ void __weak pcibios_reset_secondary_bus(struct pci_dev *dev)
4167 * Use the bridge control register to assert reset on the secondary bus. 4182 * Use the bridge control register to assert reset on the secondary bus.
4168 * Devices on the secondary bus are left in power-on state. 4183 * Devices on the secondary bus are left in power-on state.
4169 */ 4184 */
4170void pci_reset_bridge_secondary_bus(struct pci_dev *dev) 4185int pci_reset_bridge_secondary_bus(struct pci_dev *dev)
4171{ 4186{
4172 pcibios_reset_secondary_bus(dev); 4187 pcibios_reset_secondary_bus(dev);
4188
4189 return pci_dev_wait(dev, "bus reset", PCIE_RESET_READY_POLL_MS);
4173} 4190}
4174EXPORT_SYMBOL_GPL(pci_reset_bridge_secondary_bus); 4191EXPORT_SYMBOL_GPL(pci_reset_bridge_secondary_bus);
4175 4192
@@ -4332,8 +4349,9 @@ int __pci_reset_function_locked(struct pci_dev *dev)
4332 if (rc != -ENOTTY) 4349 if (rc != -ENOTTY)
4333 return rc; 4350 return rc;
4334 if (pcie_has_flr(dev)) { 4351 if (pcie_has_flr(dev)) {
4335 pcie_flr(dev); 4352 rc = pcie_flr(dev);
4336 return 0; 4353 if (rc != -ENOTTY)
4354 return rc;
4337 } 4355 }
4338 rc = pci_af_flr(dev, 0); 4356 rc = pci_af_flr(dev, 0);
4339 if (rc != -ENOTTY) 4357 if (rc != -ENOTTY)
@@ -4403,9 +4421,8 @@ int pci_reset_function(struct pci_dev *dev)
4403{ 4421{
4404 int rc; 4422 int rc;
4405 4423
4406 rc = pci_probe_reset_function(dev); 4424 if (!dev->reset_fn)
4407 if (rc) 4425 return -ENOTTY;
4408 return rc;
4409 4426
4410 pci_dev_lock(dev); 4427 pci_dev_lock(dev);
4411 pci_dev_save_and_disable(dev); 4428 pci_dev_save_and_disable(dev);
@@ -4440,9 +4457,8 @@ int pci_reset_function_locked(struct pci_dev *dev)
4440{ 4457{
4441 int rc; 4458 int rc;
4442 4459
4443 rc = pci_probe_reset_function(dev); 4460 if (!dev->reset_fn)
4444 if (rc) 4461 return -ENOTTY;
4445 return rc;
4446 4462
4447 pci_dev_save_and_disable(dev); 4463 pci_dev_save_and_disable(dev);
4448 4464
@@ -4464,18 +4480,17 @@ int pci_try_reset_function(struct pci_dev *dev)
4464{ 4480{
4465 int rc; 4481 int rc;
4466 4482
4467 rc = pci_probe_reset_function(dev); 4483 if (!dev->reset_fn)
4468 if (rc) 4484 return -ENOTTY;
4469 return rc;
4470 4485
4471 if (!pci_dev_trylock(dev)) 4486 if (!pci_dev_trylock(dev))
4472 return -EAGAIN; 4487 return -EAGAIN;
4473 4488
4474 pci_dev_save_and_disable(dev); 4489 pci_dev_save_and_disable(dev);
4475 rc = __pci_reset_function_locked(dev); 4490 rc = __pci_reset_function_locked(dev);
4491 pci_dev_restore(dev);
4476 pci_dev_unlock(dev); 4492 pci_dev_unlock(dev);
4477 4493
4478 pci_dev_restore(dev);
4479 return rc; 4494 return rc;
4480} 4495}
4481EXPORT_SYMBOL_GPL(pci_try_reset_function); 4496EXPORT_SYMBOL_GPL(pci_try_reset_function);
@@ -4683,7 +4698,9 @@ static void pci_slot_restore(struct pci_slot *slot)
4683 list_for_each_entry(dev, &slot->bus->devices, bus_list) { 4698 list_for_each_entry(dev, &slot->bus->devices, bus_list) {
4684 if (!dev->slot || dev->slot != slot) 4699 if (!dev->slot || dev->slot != slot)
4685 continue; 4700 continue;
4701 pci_dev_lock(dev);
4686 pci_dev_restore(dev); 4702 pci_dev_restore(dev);
4703 pci_dev_unlock(dev);
4687 if (dev->subordinate) 4704 if (dev->subordinate)
4688 pci_bus_restore(dev->subordinate); 4705 pci_bus_restore(dev->subordinate);
4689 } 4706 }
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 38b2596df38a..6722302db194 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -293,6 +293,10 @@ struct pci_sriov {
293 u16 driver_max_VFs; /* Max num VFs driver supports */ 293 u16 driver_max_VFs; /* Max num VFs driver supports */
294 struct pci_dev *dev; /* Lowest numbered PF */ 294 struct pci_dev *dev; /* Lowest numbered PF */
295 struct pci_dev *self; /* This PF */ 295 struct pci_dev *self; /* This PF */
296 u32 class; /* VF device */
297 u8 hdr_type; /* VF header type */
298 u16 subsystem_vendor; /* VF subsystem vendor */
299 u16 subsystem_device; /* VF subsystem device */
296 resource_size_t barsz[PCI_SRIOV_NUM_BARS]; /* VF BAR size */ 300 resource_size_t barsz[PCI_SRIOV_NUM_BARS]; /* VF BAR size */
297 bool drivers_autoprobe; /* Auto probing of VFs by driver */ 301 bool drivers_autoprobe; /* Auto probing of VFs by driver */
298}; 302};
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index f26fcbf6942e..caa07109e5f5 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -329,6 +329,10 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
329 if (dev->non_compliant_bars) 329 if (dev->non_compliant_bars)
330 return; 330 return;
331 331
332 /* Per PCIe r4.0, sec 9.3.4.1.11, the VF BARs are all RO Zero */
333 if (dev->is_virtfn)
334 return;
335
332 for (pos = 0; pos < howmany; pos++) { 336 for (pos = 0; pos < howmany; pos++) {
333 struct resource *res = &dev->resource[pos]; 337 struct resource *res = &dev->resource[pos];
334 reg = PCI_BASE_ADDRESS_0 + (pos << 2); 338 reg = PCI_BASE_ADDRESS_0 + (pos << 2);
@@ -1240,6 +1244,13 @@ static void pci_read_irq(struct pci_dev *dev)
1240{ 1244{
1241 unsigned char irq; 1245 unsigned char irq;
1242 1246
1247 /* VFs are not allowed to use INTx, so skip the config reads */
1248 if (dev->is_virtfn) {
1249 dev->pin = 0;
1250 dev->irq = 0;
1251 return;
1252 }
1253
1243 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irq); 1254 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irq);
1244 dev->pin = irq; 1255 dev->pin = irq;
1245 if (irq) 1256 if (irq)
@@ -1399,6 +1410,43 @@ int pci_cfg_space_size(struct pci_dev *dev)
1399 return PCI_CFG_SPACE_SIZE; 1410 return PCI_CFG_SPACE_SIZE;
1400} 1411}
1401 1412
1413static u32 pci_class(struct pci_dev *dev)
1414{
1415 u32 class;
1416
1417#ifdef CONFIG_PCI_IOV
1418 if (dev->is_virtfn)
1419 return dev->physfn->sriov->class;
1420#endif
1421 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class);
1422 return class;
1423}
1424
1425static void pci_subsystem_ids(struct pci_dev *dev, u16 *vendor, u16 *device)
1426{
1427#ifdef CONFIG_PCI_IOV
1428 if (dev->is_virtfn) {
1429 *vendor = dev->physfn->sriov->subsystem_vendor;
1430 *device = dev->physfn->sriov->subsystem_device;
1431 return;
1432 }
1433#endif
1434 pci_read_config_word(dev, PCI_SUBSYSTEM_VENDOR_ID, vendor);
1435 pci_read_config_word(dev, PCI_SUBSYSTEM_ID, device);
1436}
1437
1438static u8 pci_hdr_type(struct pci_dev *dev)
1439{
1440 u8 hdr_type;
1441
1442#ifdef CONFIG_PCI_IOV
1443 if (dev->is_virtfn)
1444 return dev->physfn->sriov->hdr_type;
1445#endif
1446 pci_read_config_byte(dev, PCI_HEADER_TYPE, &hdr_type);
1447 return hdr_type;
1448}
1449
1402#define LEGACY_IO_RESOURCE (IORESOURCE_IO | IORESOURCE_PCI_FIXED) 1450#define LEGACY_IO_RESOURCE (IORESOURCE_IO | IORESOURCE_PCI_FIXED)
1403 1451
1404static void pci_msi_setup_pci_dev(struct pci_dev *dev) 1452static void pci_msi_setup_pci_dev(struct pci_dev *dev)
@@ -1464,8 +1512,7 @@ int pci_setup_device(struct pci_dev *dev)
1464 struct pci_bus_region region; 1512 struct pci_bus_region region;
1465 struct resource *res; 1513 struct resource *res;
1466 1514
1467 if (pci_read_config_byte(dev, PCI_HEADER_TYPE, &hdr_type)) 1515 hdr_type = pci_hdr_type(dev);
1468 return -EIO;
1469 1516
1470 dev->sysdata = dev->bus->sysdata; 1517 dev->sysdata = dev->bus->sysdata;
1471 dev->dev.parent = dev->bus->bridge; 1518 dev->dev.parent = dev->bus->bridge;
@@ -1487,7 +1534,8 @@ int pci_setup_device(struct pci_dev *dev)
1487 dev->bus->number, PCI_SLOT(dev->devfn), 1534 dev->bus->number, PCI_SLOT(dev->devfn),
1488 PCI_FUNC(dev->devfn)); 1535 PCI_FUNC(dev->devfn));
1489 1536
1490 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class); 1537 class = pci_class(dev);
1538
1491 dev->revision = class & 0xff; 1539 dev->revision = class & 0xff;
1492 dev->class = class >> 8; /* upper 3 bytes */ 1540 dev->class = class >> 8; /* upper 3 bytes */
1493 1541
@@ -1527,8 +1575,8 @@ int pci_setup_device(struct pci_dev *dev)
1527 goto bad; 1575 goto bad;
1528 pci_read_irq(dev); 1576 pci_read_irq(dev);
1529 pci_read_bases(dev, 6, PCI_ROM_ADDRESS); 1577 pci_read_bases(dev, 6, PCI_ROM_ADDRESS);
1530 pci_read_config_word(dev, PCI_SUBSYSTEM_VENDOR_ID, &dev->subsystem_vendor); 1578
1531 pci_read_config_word(dev, PCI_SUBSYSTEM_ID, &dev->subsystem_device); 1579 pci_subsystem_ids(dev, &dev->subsystem_vendor, &dev->subsystem_device);
1532 1580
1533 /* 1581 /*
1534 * Do the ugly legacy mode stuff here rather than broken chip 1582 * Do the ugly legacy mode stuff here rather than broken chip
@@ -2131,6 +2179,9 @@ static void pci_init_capabilities(struct pci_dev *dev)
2131 2179
2132 /* Advanced Error Reporting */ 2180 /* Advanced Error Reporting */
2133 pci_aer_init(dev); 2181 pci_aer_init(dev);
2182
2183 if (pci_probe_reset_function(dev) == 0)
2184 dev->reset_fn = 1;
2134} 2185}
2135 2186
2136/* 2187/*
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 8bf0ad91432a..df75bc8ed40d 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3888,6 +3888,9 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9182,
3888/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c46 */ 3888/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c46 */
3889DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x91a0, 3889DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x91a0,
3890 quirk_dma_func1_alias); 3890 quirk_dma_func1_alias);
3891/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c127 */
3892DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9220,
3893 quirk_dma_func1_alias);
3891/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c49 */ 3894/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c49 */
3892DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9230, 3895DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9230,
3893 quirk_dma_func1_alias); 3896 quirk_dma_func1_alias);
@@ -4506,6 +4509,15 @@ static const struct pci_dev_acs_enabled {
4506 { PCI_VENDOR_ID_CAVIUM, PCI_ANY_ID, pci_quirk_cavium_acs }, 4509 { PCI_VENDOR_ID_CAVIUM, PCI_ANY_ID, pci_quirk_cavium_acs },
4507 /* APM X-Gene */ 4510 /* APM X-Gene */
4508 { PCI_VENDOR_ID_AMCC, 0xE004, pci_quirk_xgene_acs }, 4511 { PCI_VENDOR_ID_AMCC, 0xE004, pci_quirk_xgene_acs },
4512 /* Ampere Computing */
4513 { PCI_VENDOR_ID_AMPERE, 0xE005, pci_quirk_xgene_acs },
4514 { PCI_VENDOR_ID_AMPERE, 0xE006, pci_quirk_xgene_acs },
4515 { PCI_VENDOR_ID_AMPERE, 0xE007, pci_quirk_xgene_acs },
4516 { PCI_VENDOR_ID_AMPERE, 0xE008, pci_quirk_xgene_acs },
4517 { PCI_VENDOR_ID_AMPERE, 0xE009, pci_quirk_xgene_acs },
4518 { PCI_VENDOR_ID_AMPERE, 0xE00A, pci_quirk_xgene_acs },
4519 { PCI_VENDOR_ID_AMPERE, 0xE00B, pci_quirk_xgene_acs },
4520 { PCI_VENDOR_ID_AMPERE, 0xE00C, pci_quirk_xgene_acs },
4509 { 0 } 4521 { 0 }
4510}; 4522};
4511 4523
diff --git a/include/linux/pci.h b/include/linux/pci.h
index ee0bfc1a0274..283953c90b52 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1085,7 +1085,7 @@ u32 pcie_bandwidth_available(struct pci_dev *dev, struct pci_dev **limiting_dev,
1085 enum pci_bus_speed *speed, 1085 enum pci_bus_speed *speed,
1086 enum pcie_link_width *width); 1086 enum pcie_link_width *width);
1087void pcie_print_link_status(struct pci_dev *dev); 1087void pcie_print_link_status(struct pci_dev *dev);
1088void pcie_flr(struct pci_dev *dev); 1088int pcie_flr(struct pci_dev *dev);
1089int __pci_reset_function_locked(struct pci_dev *dev); 1089int __pci_reset_function_locked(struct pci_dev *dev);
1090int pci_reset_function(struct pci_dev *dev); 1090int pci_reset_function(struct pci_dev *dev);
1091int pci_reset_function_locked(struct pci_dev *dev); 1091int pci_reset_function_locked(struct pci_dev *dev);
@@ -1098,7 +1098,7 @@ int pci_reset_bus(struct pci_bus *bus);
1098int pci_try_reset_bus(struct pci_bus *bus); 1098int pci_try_reset_bus(struct pci_bus *bus);
1099void pci_reset_secondary_bus(struct pci_dev *dev); 1099void pci_reset_secondary_bus(struct pci_dev *dev);
1100void pcibios_reset_secondary_bus(struct pci_dev *dev); 1100void pcibios_reset_secondary_bus(struct pci_dev *dev);
1101void pci_reset_bridge_secondary_bus(struct pci_dev *dev); 1101int pci_reset_bridge_secondary_bus(struct pci_dev *dev);
1102void pci_update_resource(struct pci_dev *dev, int resno); 1102void pci_update_resource(struct pci_dev *dev, int resno);
1103int __must_check pci_assign_resource(struct pci_dev *dev, int i); 1103int __must_check pci_assign_resource(struct pci_dev *dev, int i);
1104int __must_check pci_reassign_resource(struct pci_dev *dev, int i, resource_size_t add_size, resource_size_t align); 1104int __must_check pci_reassign_resource(struct pci_dev *dev, int i, resource_size_t add_size, resource_size_t align);
@@ -1299,7 +1299,6 @@ unsigned char pci_bus_max_busnr(struct pci_bus *bus);
1299void pci_setup_bridge(struct pci_bus *bus); 1299void pci_setup_bridge(struct pci_bus *bus);
1300resource_size_t pcibios_window_alignment(struct pci_bus *bus, 1300resource_size_t pcibios_window_alignment(struct pci_bus *bus,
1301 unsigned long type); 1301 unsigned long type);
1302resource_size_t pcibios_iov_resource_alignment(struct pci_dev *dev, int resno);
1303 1302
1304#define PCI_VGA_STATE_CHANGE_BRIDGE (1 << 0) 1303#define PCI_VGA_STATE_CHANGE_BRIDGE (1 << 0)
1305#define PCI_VGA_STATE_CHANGE_DECODES (1 << 1) 1304#define PCI_VGA_STATE_CHANGE_DECODES (1 << 1)
@@ -1922,6 +1921,7 @@ void pcibios_release_device(struct pci_dev *dev);
1922void pcibios_penalize_isa_irq(int irq, int active); 1921void pcibios_penalize_isa_irq(int irq, int active);
1923int pcibios_alloc_irq(struct pci_dev *dev); 1922int pcibios_alloc_irq(struct pci_dev *dev);
1924void pcibios_free_irq(struct pci_dev *dev); 1923void pcibios_free_irq(struct pci_dev *dev);
1924resource_size_t pcibios_default_alignment(void);
1925 1925
1926#ifdef CONFIG_HIBERNATE_CALLBACKS 1926#ifdef CONFIG_HIBERNATE_CALLBACKS
1927extern struct dev_pm_ops pcibios_pm_ops; 1927extern struct dev_pm_ops pcibios_pm_ops;
@@ -1954,6 +1954,11 @@ int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs);
1954int pci_sriov_get_totalvfs(struct pci_dev *dev); 1954int pci_sriov_get_totalvfs(struct pci_dev *dev);
1955resource_size_t pci_iov_resource_size(struct pci_dev *dev, int resno); 1955resource_size_t pci_iov_resource_size(struct pci_dev *dev, int resno);
1956void pci_vf_drivers_autoprobe(struct pci_dev *dev, bool probe); 1956void pci_vf_drivers_autoprobe(struct pci_dev *dev, bool probe);
1957
1958/* Arch may override these (weak) */
1959int pcibios_sriov_enable(struct pci_dev *pdev, u16 num_vfs);
1960int pcibios_sriov_disable(struct pci_dev *pdev);
1961resource_size_t pcibios_iov_resource_alignment(struct pci_dev *dev, int resno);
1957#else 1962#else
1958static inline int pci_iov_virtfn_bus(struct pci_dev *dev, int id) 1963static inline int pci_iov_virtfn_bus(struct pci_dev *dev, int id)
1959{ 1964{
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 6a96a70fb462..f22124e9887d 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1333,6 +1333,7 @@
1333#define PCI_DEVICE_ID_IMS_TT3D 0x9135 1333#define PCI_DEVICE_ID_IMS_TT3D 0x9135
1334 1334
1335#define PCI_VENDOR_ID_AMCC 0x10e8 1335#define PCI_VENDOR_ID_AMCC 0x10e8
1336#define PCI_VENDOR_ID_AMPERE 0x1def
1336 1337
1337#define PCI_VENDOR_ID_INTERG 0x10ea 1338#define PCI_VENDOR_ID_INTERG 0x10ea
1338#define PCI_DEVICE_ID_INTERG_1682 0x1682 1339#define PCI_DEVICE_ID_INTERG_1682 0x1682