Subject: Re: [PATCH v5 net-next 3/5] net: wwan: t7xx: PCIe reset rescan

From: "Kumar, M Chetan" <[email-masked]>
Date: Fri, 27 Jan 2023 15:57:16 +0530

On 1/26/2023 8:55 PM, Bjorn Helgaas wrote:
> On Tue, Jan 24, 2023 at 08:45:43PM -0800, Jakub Kicinski wrote:
>> Hi Bjorn,
>>
>> any objections to the kind of shenanigans this is playing?
> 
> Yes, thanks for asking.  Drivers definitely should not have to do this
> sort of thing.
> 
>> On Sat, 21 Jan 2023 19:03:23 +0530 [email-masked] wrote:
>>> From: M Chetan Kumar <[email-masked]>
>>>
>>> PCI rescan module implements "rescan work queue".
>>> In firmware flashing or coredump collection procedure
>>> WWAN device is programmed to boot in fastboot mode and
>>> a work item is scheduled for removal & detection.
>>>
>>> The WWAN device is reset using APCI call as part driver
>>> removal flow. Work queue rescans pci bus at fixed interval
>>> for device detection, later when device is detect work queue
>>> exits.
> 
> I'm not sure what's going on here.  Do we need to reset the device
> when the t7xx driver is loaded so the device will load new firmware
> when it comes out of reset?

Flow is, Reset the device to get into firmware download mode then update
the firmware and later reset it to go back to normal mode.

> 
> There are a few drivers that do that, e.g., with pci_reset_function().
> 

Thanks for the suggestion.
I will explore a bit and also try to use pci_reset_function() interface 
and see if it serves the purpose.

>>> +static struct remove_rescan_context t7xx_rescan_ctx;
> 
> Apparently this only supports a single t7xx instance in a system?  Not
> good.
> 
>>> +void t7xx_pci_dev_rescan(void)
>>> +{
>>> +	struct pci_bus *b = NULL;
>>> +
>>> +	pci_lock_rescan_remove();
>>> +	while ((b = pci_find_next_bus(b)))
>>> +		pci_rescan_bus(b);
> 
> No, this driver absolutely cannot rescan and assign unassigned
> resources for all the PCI buses in the system.

T7xx device falls off the bus due to ACPI reset.
Would you please suggest how we can bring device back on the bus without 
such changes inside driver ?  Will pci_reset_function() help in this 
regard ?

If there is no alternate option, then we shall try using remove and 
rescan from user space and drop this patch.

> Bjorn

-- 
Chetan