[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e8ad2686-22e8-7d75-f0f4-82c0c57fc65e@nvidia.com>
Date: Wed, 28 Jul 2021 13:08:36 -0500
From: Shanker R Donthineni <sdonthineni@...dia.com>
To: Amey Narkhede <ameynarkhede03@...il.com>,
Bjorn Helgaas <helgaas@...nel.org>
CC: <alex.williamson@...hat.com>,
Raphael Norwitz <raphael.norwitz@...anix.com>,
<linux-pci@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<kw@...ux.com>, Sinan Kaya <okaya@...nel.org>,
Len Brown <lenb@...nel.org>,
"Rafael J. Wysocki" <rjw@...ysocki.net>
Subject: Re: [PATCH v10 2/8] PCI: Add new array for keeping track of ordering
of reset methods
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;
}
}
Powered by blists - more mailing lists