[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fd2cdc06-5d88-306a-3ee1-7aef3e3b8921@huawei.com>
Date: Mon, 9 May 2022 15:50:33 +0100
From: John Garry <john.garry@...wei.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
Christoph Hellwig <hch@...radead.org>
CC: "Ewan D. Milne" <emilne@...hat.com>,
"James E.J. Bottomley" <jejb@...ux.ibm.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
"Alim Akhtar" <alim.akhtar@...sung.com>,
Avri Altman <avri.altman@....com>,
"Doug Gilbert" <dgilbert@...erlog.com>,
<linux-scsi@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<james.smart@...adcom.com>
Subject: Re: [PATCH 1/4] scsi: core: constify pointer to scsi_host_template
On 09/05/2022 14:20, Krzysztof Kozlowski wrote:
> On 09/05/2022 13:28, John Garry wrote:
>>
>> For some reason I cannot fetch your git due to "error: RPC failed ..."
>> which I think is a timeout. I seem to have this problem recently
>> whenever a linux.git clone has branches based on linux-next.git . Maybe
>> a git config issue for me...
>
> Just to be sure - the link was not a git remote, but direct link for a
> web browser. The repo is:
> https://github.com/krzk/linux.git
> branch: n/qcom-ufs-opp-cleanups-v2
>
OK, I'll double check. Regardless I'll sort my own IT issues :)
>>> However this does not solve the problem. The SHT has "module" which gets
>>> incremented/decremented. Exactly like in case of other drivers
>>> (driver->owner).
>>
>> Ah, I missed that this could be a problem. So we have this member to
>> stop the SCSI host driver being removed when we have disks mounted, etc.
>>
>> But isn't scsi_host_template.module just a pointer to the local driver
>> module data (and that data gets incremented/decremented)? I am looking
>> at the THIS_MODULE definition in export.h:
>
> Yes, it is just a pointer, just like 'struct device_driver.owner' is.
>
>>
>> extern stuct module __this_module;
>> #define THIS_MODULE(&__this_module)
>>
>> However I do see scsi_device_dev_release(), which does:
>>
>> sdp->host->hostt->module = NULL
>>
>> I am not sure how necessary that really is. I would need to check further.
>
>>
>> Did you see if there other places which set hostt->module dynamically?
>
> I think all SHT set it statically.
Incidentally I did notice that the ata ahci driver does not set sht->module.
> Then it is being dynamically
> incremented when needed and in scsi_device_dev_release() is being
> nullified (as you mentioned above).
>
> I guess this SHT->module is actually duplicating what most of drivers
> (e.g. PCI, platform, USB) are doing. If I understand correctly, the
> Scsi_Host is instantiated by the probe of a driver (pci_driver,
> virtio_driver etc), therefore the SHT->module could be simply stored in
> Scsi_Host.
If you check scsi_device_dev_release(), we try to do a 'get' - if it
fails, then we nullify hostt->module. I think that is important as then
we call execute_in_process_context(), whose worker does the 'put'.
However, the 'put' will get upset if the refcnt was 0, which it would be
if the earlier 'get' fails - hence the nullify is to avoid that
possibility. So whatever you do needs to handle that. Details are in
f2b85040
Thanks,
john
Powered by blists - more mailing lists