From: cang@codeaurora.org
To: Bart Van Assche <bvanassche@acm.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>,
asutoshd@codeaurora.org, nguyenb@codeaurora.org,
rnayak@codeaurora.org, linux-scsi@vger.kernel.org,
kernel-team@android.com, saravanak@google.com,
salyzyn@google.com, Alim Akhtar <alim.akhtar@samsung.com>,
Avri Altman <avri.altman@wdc.com>,
Pedro Sousa <pedrom.sousa@synopsys.com>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Evan Green <evgreen@chromium.org>,
Kishon Vijay Abraham I <kishon@ti.com>,
Stephen Boyd <swboyd@chromium.org>,
Stanley Chu <stanley.chu@mediatek.com>,
Vignesh Raghavendra <vigneshr@ti.com>,
Bean Huo <beanhuo@micron.com>,
Venkat Gopalakrishnan <venkatg@codeaurora.org>,
Tomas Winkler <tomas.winkler@intel.com>,
Arnd Bergmann <arnd@arndb.de>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] scsi: ufs: Modulize ufs-bsg
Date: Tue, 17 Dec 2019 16:56:23 +0800 [thread overview]
Message-ID: <b3fee6ea02c4c3c46eeba81b0bdcf7c4@codeaurora.org> (raw)
In-Reply-To: <62933901-fcdf-b5ae-431d-e1fbfc897128@acm.org>
On 2019-12-17 01:22, Bart Van Assche wrote:
> On 12/15/19 8:36 PM, cang@codeaurora.org wrote:
>> On 2019-12-16 05:49, Bart Van Assche wrote:
>>> On 2019-12-11 22:37, Bjorn Andersson wrote:
>>>> It's the asymmetry that I don't like.
>>>>
>>>> Perhaps if you instead make ufshcd platform_device_register_data()
>>>> the
>>>> bsg device you would solve the probe ordering, the remove will be
>>>> symmetric and module autoloading will work as well (although then
>>>> you
>>>> need a MODULE_ALIAS of platform:device-name).
>>>
>>> Hi Bjorn,
>>>
>>> From Documentation/driver-api/driver-model/platform.rst:
>>> "Platform devices are devices that typically appear as autonomous
>>> entities in the system. This includes legacy port-based devices and
>>> host bridges to peripheral buses, and most controllers integrated
>>> into system-on-chip platforms. What they usually have in common
>>> is direct addressing from a CPU bus. Rarely, a platform_device will
>>> be connected through a segment of some other kind of bus; but its
>>> registers will still be directly addressable."
>>>
>>> Do you agree that the above description is not a good match for the
>>> ufs-bsg kernel module?
>>
>> I missed this one.
>> How about making it a plain device and add it from ufs driver?
>
> Hi Can,
>
> Since the ufs_bsg kernel module already creates one device node under
> /dev/bsg for each UFS host I don't think that we need to create any
> additional device nodes for ufs-bsg devices. My proposal is to modify
> the original patch 2/3 from this series as follows:
> * Use module_init() instead of late_initcall_sync().
> * Remove the ufshcd_get_hba_list_lock() and
> ufshcd_put_hba_list_unlock() functions.
> * Implement a notification mechanism in the UFS core that invokes a
> callback function after an UFS host has been created and also after
> an
> UFS host has been removed.
> * Register for these notifications from inside the ufs-bsg driver.
> * During registration for notifications, invoke the UFS host creation
> callback function for all known UFS hosts.
> * If the UFS core is unloaded, invoke the UFS host removal callback
> function for all known UFS hosts.
>
> I think there are several examples of similar notification mechanisms
> in the Linux kernel, e.g. the probe and remove callback functions in
> struct pci_driver.
>
> Bart.
Hi Bart,
Even in the current ufs_bsg.c, it creates two devices, one is ufs-bsg,
one is the char dev node under /dev/bsg. Why this becomes a problem
after make it a module?
I took a look into the pci_driver, it is no different than making
ufs-bsg
a plain device. The only special place about pci_driver is that it has
its
own probe() and remove(), and the probe() in its bus_type calls the
probe() in pci_driver. Meaning the bus->probe() is an intermediate call
used to pass whatever needed by pci_driver->probe().
Of course we can also do this, but isn't it too much for ufs-bsg?
For our case, calling set_dev_drvdata(bsg_dev, hba) to pass hba to
ufs_bsg.c would be enough.
If you take a look at the V3 patch, the change makes the ufs_bsg.c
much conciser. platform_device_register_data() does everything for us,
initialize the device, set device name, provide the match func,
bus type and release func.
Since ufs-bsg is somewhat not a platform device, we can still add it
as a plain device, just need a few more lines to get it initialized.
This allows us leverage kernel's device driver model. Just like Greg
commented, we don't need to re-implement the mechanism again.
Thanks,
Can Guo.
next prev parent reply other threads:[~2019-12-17 8:56 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1576054123-16417-1-git-send-email-cang@codeaurora.org>
2019-12-11 8:48 ` [PATCH v2 1/3] scsi: ufs: Put SCSI host after remove it Can Guo
2019-12-11 10:37 ` Avri Altman
2019-12-11 11:06 ` cang
[not found] ` <0101016ef4a3e5f5-915372c8-5e1e-4db5-b3da-f97f7ca963e4-000000@us-west-2.amazonses.com>
2019-12-11 11:22 ` Avri Altman
2019-12-11 11:44 ` cang
[not found] ` <0101016ef4c6065b-3e4428fc-71f8-40cf-a7fa-bc633a2b9fda-000000@us-west-2.amazonses.com>
2019-12-11 13:44 ` Avri Altman
2019-12-11 8:49 ` [PATCH v2 2/3] scsi: ufs: Modulize ufs-bsg Can Guo
2019-12-12 4:53 ` Bjorn Andersson
2019-12-12 6:01 ` cang
[not found] ` <0101016ef8b2e2f8-72260b08-e6ad-42fc-bd4b-4a0a72c5c9b3-000000@us-west-2.amazonses.com>
2019-12-12 6:37 ` Bjorn Andersson
2019-12-12 7:00 ` Avri Altman
2019-12-12 16:53 ` cang
[not found] ` <0101016efb07efac-32cf270a-68dd-455a-b037-9fac2f3834cd-000000@us-west-2.amazonses.com>
2019-12-12 18:24 ` Bjorn Andersson
2019-12-14 12:30 ` cang
2019-12-15 7:38 ` Avri Altman
2019-12-12 16:45 ` cang
2019-12-15 21:49 ` Bart Van Assche
2019-12-16 4:36 ` cang
2019-12-16 17:22 ` Bart Van Assche
2019-12-16 18:06 ` Greg KH
2019-12-17 8:56 ` cang [this message]
2019-12-17 18:19 ` Bart Van Assche
2019-12-17 18:47 ` cang
[not found] ` <0101016ef425ed74-071c2ec2-5aeb-44fa-8889-d9ec60192d44-000000@us-west-2.amazonses.com>
2019-12-12 5:40 ` Vignesh Raghavendra
[not found] ` <0101016ef425e749-1808e138-740e-4036-922f-7a49ec02c2b8-000000@us-west-2.amazonses.com>
2019-12-13 20:59 ` Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b3fee6ea02c4c3c46eeba81b0bdcf7c4@codeaurora.org \
--to=cang@codeaurora.org \
--cc=alim.akhtar@samsung.com \
--cc=arnd@arndb.de \
--cc=asutoshd@codeaurora.org \
--cc=avri.altman@wdc.com \
--cc=beanhuo@micron.com \
--cc=bjorn.andersson@linaro.org \
--cc=bvanassche@acm.org \
--cc=evgreen@chromium.org \
--cc=jejb@linux.ibm.com \
--cc=kernel-team@android.com \
--cc=kishon@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=nguyenb@codeaurora.org \
--cc=pedrom.sousa@synopsys.com \
--cc=rnayak@codeaurora.org \
--cc=salyzyn@google.com \
--cc=saravanak@google.com \
--cc=stanley.chu@mediatek.com \
--cc=swboyd@chromium.org \
--cc=tomas.winkler@intel.com \
--cc=venkatg@codeaurora.org \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.