From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Peter Chen <peter.chen@nxp.com>
Cc: Felipe Balbi <balbi@kernel.org>,
Chunfeng Yun <chunfeng.yun@mediatek.com>, Bin Liu <b-liu@ti.com>,
Benson Leung <bleung@chromium.org>,
Prashant Malani <pmalani@chromium.org>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: Re: [PATCH 5/9] usb: roles: Provide the switch drivers handle to the switch in the API
Date: Wed, 19 Feb 2020 15:38:15 +0200 [thread overview]
Message-ID: <20200219133815.GH28776@kuha.fi.intel.com> (raw)
In-Reply-To: <20200219015840.GC8602@b29397-desktop>
On Wed, Feb 19, 2020 at 01:58:38AM +0000, Peter Chen wrote:
> On 20-02-18 14:25:45, Heikki Krogerus wrote:
> > Hi,
> >
> > On Tue, Feb 18, 2020 at 07:23:41AM +0000, Peter Chen wrote:
> > > > > @@ -1118,6 +1119,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
> > > > > }
> > > > >
> > > > > if (ci_role_switch.fwnode) {
> > > > > + ci_role_switch.driver_data = ci;
> > > > > ci->role_switch = usb_role_switch_register(dev,
> > > > > &ci_role_switch);
> > >
> > > Why the struct usb_role_switch_desc needs drvdata, the struct
> > > usb_role_switch has already one?
> >
> > I'm assuming that you are asking why not just register the switch,
> > and then call usb_role_switch_set_drvdata(), right?
>
> Yes.
>
> >
> > That may create a race condition where the switch is accessed before
> > the driver data is available. That can happen for example if the
> > switch is exposed to the user space.
> >
> > To play it safe, supplying the driver data as part of the descriptor.
> > That way we can be sure that the driver data is always available
> > the moment the switch is registered.
> >
>
> Then, you may use the uniform way for the driver. Some may have
> race condition like you said.
Uniform way for the driver?
--
heikki
next prev parent reply other threads:[~2020-02-19 13:38 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-13 13:24 [PATCH 0/9] usb: typec: Driver for Intel PMC Mux-Agent Heikki Krogerus
2020-02-13 13:24 ` [PATCH 1/9] usb: typec: mux: Allow the muxes to be named Heikki Krogerus
2020-02-13 13:24 ` [PATCH 2/9] usb: typec: mux: Add helpers for setting the mux state Heikki Krogerus
2020-02-13 13:24 ` [PATCH 3/9] usb: typec: mux: Allow the mux handles to be requested with fwnode Heikki Krogerus
2020-02-13 13:24 ` [PATCH 4/9] usb: roles: Leave the private driver data pointer to the drivers Heikki Krogerus
2020-02-15 9:19 ` Chunfeng Yun
2020-02-17 9:16 ` Heikki Krogerus
2020-02-13 13:24 ` [PATCH 5/9] usb: roles: Provide the switch drivers handle to the switch in the API Heikki Krogerus
2020-02-13 13:32 ` Heikki Krogerus
2020-02-18 7:23 ` Peter Chen
2020-02-18 12:25 ` Heikki Krogerus
2020-02-19 1:58 ` Peter Chen
2020-02-19 13:38 ` Heikki Krogerus [this message]
2020-02-19 14:09 ` Peter Chen
2020-02-19 14:14 ` Heikki Krogerus
2020-02-15 9:33 ` Chunfeng Yun
2020-02-13 13:24 ` [PATCH 6/9] usb: roles: Allow the role switches to be named Heikki Krogerus
2020-02-13 13:24 ` [PATCH 7/9] device property: Export fwnode_get_name() Heikki Krogerus
2020-02-13 13:24 ` [PATCH 8/9] usb: typec: Add definitions for Thunderbolt 3 Alternate Mode Heikki Krogerus
2020-02-13 13:24 ` [PATCH 9/9] usb: typec: driver for Intel PMC mux control Heikki Krogerus
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=20200219133815.GH28776@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=b-liu@ti.com \
--cc=balbi@kernel.org \
--cc=bleung@chromium.org \
--cc=chunfeng.yun@mediatek.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=peter.chen@nxp.com \
--cc=pmalani@chromium.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).