Re: [PATCH v2 0/3] scsi: ufs ums-*: fix module reference counting
2015-01-08 0:09 GMT+09:00 Alan Stern st...@rowland.harvard.edu: On Wed, 7 Jan 2015, Christoph Hellwig wrote: On Wed, Jan 07, 2015 at 11:02:59PM +0900, Akinobu Mita wrote: While accessing a scsi_device, the use count of the underlying LLDD module is incremented. The module reference is retrieved through .module field of struct scsi_host_template. This mapping between scsi_device and underlying LLDD module works well except some scsi drivers (ufs and unusual usb storage drivers). These drivers consist with core driver and actual LLDDs, and scsi_host_template is defined in the core driver. So the actual LLDDs can be unloaded even if the scsi_device is being accessed. Why don't ufs and usb-storage define the host templates in the sub drivers? That's what libata or the mpt fusion driver do. Originally the subdrivers were all part of usb-storage. When they were split out into separate modules, there didn't seem to be any need to copy the host template into each one. (Especially since some of the method pointers in the host template refer to routines in usb-storage itself, not in the subdrivers.) The fact that the .module member was no longer adequate escaped our notice at the time. For ufs, the reason why a host template is shared by sub drivers is similar to usb-storage. Originally there was only a single pci driver for ufs. When platform driver for ufs was introduced, it was split into core driver (ufshcd) and sub drivers (ufshcd-pci and ufshcd-pltfrm). They require exactly the same host template. Is there any other preferable way to fix this problem? The first time I found this in ufs driver, I was trying to fix it by merging core and sub drivers into a single compound module. But I realized that usm-* drivers have the same problem, then I decided to propose what this patch series do instead. -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 0/3] scsi: ufs ums-*: fix module reference counting
On Thu, 8 Jan 2015, Akinobu Mita wrote: Why don't ufs and usb-storage define the host templates in the sub drivers? That's what libata or the mpt fusion driver do. Originally the subdrivers were all part of usb-storage. When they were split out into separate modules, there didn't seem to be any need to copy the host template into each one. (Especially since some of the method pointers in the host template refer to routines in usb-storage itself, not in the subdrivers.) The fact that the .module member was no longer adequate escaped our notice at the time. For ufs, the reason why a host template is shared by sub drivers is similar to usb-storage. Originally there was only a single pci driver for ufs. When platform driver for ufs was introduced, it was split into core driver (ufshcd) and sub drivers (ufshcd-pci and ufshcd-pltfrm). They require exactly the same host template. Is there any other preferable way to fix this problem? The first time I found this in ufs driver, I was trying to fix it by merging core and sub drivers into a single compound module. But I realized that usm-* drivers have the same problem, then I decided to propose what this patch series do instead. I can't think of any other ways to fix it. The only options seem to be to duplicate the host template in each subdriver or to add the .module field to the host structure. I prefer the second option because it doesn't involve so much code duplication. Alan Stern -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 0/3] scsi: ufs ums-*: fix module reference counting
While accessing a scsi_device, the use count of the underlying LLDD module is incremented. The module reference is retrieved through .module field of struct scsi_host_template. This mapping between scsi_device and underlying LLDD module works well except some scsi drivers (ufs and unusual usb storage drivers). These drivers consist with core driver and actual LLDDs, and scsi_host_template is defined in the core driver. So the actual LLDDs can be unloaded even if the scsi_device is being accessed. This patch series first adds ability to adjust module reference for scsi host by LLDDs and then fixes ufs and unusual usb storage drivers by adjusting module reference after scsi host allocation. * v2: - Pass correct module reference to usb_stor_probe1() instead of touching all ums-* drivers, suggested by Alan Stern Akinobu Mita (3): scsi: add ability to adjust module reference for scsi host scsi: ufs: adjust module reference for scsi host usb: storage: adjust module reference for scsi host drivers/scsi/hosts.c | 1 + drivers/scsi/scsi.c | 4 ++-- drivers/scsi/ufs/ufshcd-pci.c| 1 + drivers/scsi/ufs/ufshcd-pltfrm.c | 1 + drivers/scsi/ufs/ufshcd.c| 1 - drivers/usb/storage/usb.c| 8 +--- drivers/usb/storage/usb.h| 7 +-- include/scsi/scsi_host.h | 1 + 8 files changed, 16 insertions(+), 8 deletions(-) Cc: Vinayak Holikatti vinholika...@gmail.com Cc: Dolev Raviv dra...@codeaurora.org Cc: Sujit Reddy Thumma sthu...@codeaurora.org Cc: Subhash Jadavani subha...@codeaurora.org Cc: Christoph Hellwig h...@lst.de Cc: James E.J. Bottomley jbottom...@parallels.com Cc: Matthew Dharm mdharm-...@one-eyed-alien.net Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Cc: Alan Stern st...@rowland.harvard.edu Cc: linux-...@vger.kernel.org Cc: usb-stor...@lists.one-eyed-alien.net Cc: linux-scsi@vger.kernel.org -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 0/3] scsi: ufs ums-*: fix module reference counting
On Wed, 7 Jan 2015, Christoph Hellwig wrote: On Wed, Jan 07, 2015 at 11:02:59PM +0900, Akinobu Mita wrote: While accessing a scsi_device, the use count of the underlying LLDD module is incremented. The module reference is retrieved through .module field of struct scsi_host_template. This mapping between scsi_device and underlying LLDD module works well except some scsi drivers (ufs and unusual usb storage drivers). These drivers consist with core driver and actual LLDDs, and scsi_host_template is defined in the core driver. So the actual LLDDs can be unloaded even if the scsi_device is being accessed. Why don't ufs and usb-storage define the host templates in the sub drivers? That's what libata or the mpt fusion driver do. Originally the subdrivers were all part of usb-storage. When they were split out into separate modules, there didn't seem to be any need to copy the host template into each one. (Especially since some of the method pointers in the host template refer to routines in usb-storage itself, not in the subdrivers.) The fact that the .module member was no longer adequate escaped our notice at the time. Alan Stern -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html