Messages in this thread | | | Subject | Re: [PATCH v10 2/8] PCI: Add new array for keeping track of ordering of reset methods | From | Shanker R Donthineni <> | Date | Wed, 28 Jul 2021 13:08:36 -0500 |
| |
Hi Amey,
On 7/28/21 12:45 PM, Amey Narkhede wrote: >>> + BUILD_BUG_ON(ARRAY_SIZE(pci_reset_fn_methods) != PCI_NUM_RESET_METHODS); >>> >>> might_sleep(); >>> >>> - rc = pci_dev_specific_reset(dev, 1); >>> - if (rc != -ENOTTY) >>> - return rc; >>> - rc = pcie_reset_flr(dev, 1); >>> - if (rc != -ENOTTY) >>> - return rc; >>> - rc = pci_af_flr(dev, 1); >>> - if (rc != -ENOTTY) >>> - return rc; >>> - rc = pci_pm_reset(dev, 1); >>> - if (rc != -ENOTTY) >>> - return rc; >>> + for (i = 1; i < PCI_NUM_RESET_METHODS; i++) { >>> + rc = pci_reset_fn_methods[i].reset_fn(dev, 1); >>> + if (!rc) >>> + reset_methods[n++] = i; >> Why do we need this local reset_methods[] array? Can we just fill >> in dev->reset_methods[] directly and skip the memcpy() below? >> > This is for avoiding caching of previously supported reset methods. > Is it okay if I use memset(dev->reset_methods, 0, > sizeof(dev->reset_methods)) instead to clear the values in > dev->reset_methods?
Clearing the array before the loop might a better option, we can get rid of a local variable.
void pci_init_reset_methods(struct pci_dev *dev) { int i, n, rc;
BUILD_BUG_ON(ARRAY_SIZE(pci_reset_fn_methods) != PCI_NUM_RESET_METHODS);
might_sleep();
memset(dev->reset_methods, 0x0, sizeof(reset_methods));
n = 0; for (i = 1; i < PCI_NUM_RESET_METHODS; i++) { rc = pci_reset_fn_methods[i].reset_fn(dev, 1); if (!rc) dev->reset_methods[n++] = i; else if (rc != -ENOTTY) break; } }
| |