Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp596764ybv; Wed, 19 Feb 2020 05:38:44 -0800 (PST) X-Google-Smtp-Source: APXvYqxsPNfJxUA7Hhk9ki8S3Xsv54mJ77DB7IUwt7qjcyKQVDqDJVNIcOv91ALTErXLojUJUACl X-Received: by 2002:aca:dd05:: with SMTP id u5mr4628514oig.91.1582119524069; Wed, 19 Feb 2020 05:38:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582119524; cv=none; d=google.com; s=arc-20160816; b=ABz/xkELP5XKQJZ6rtd61mJcroCbThRbY9DwuUlGlkNjgwWTJCcISEDWiJvfYp23Pw 6X1KBMBqw1R9FGMyV+gu+hpmCAoFN4D7S40jtHR8SGS2RD/VyjC8b5F4zW15wFjg+Om5 kcWubZc4/xZJWlQVSyNcY8zF1v/hk3EQzUL2cq7l9o1GzPkxPZj2sVQau+/Xts5YgLId cCfLrPCisIM4gimw8oZihMdxj+iCyGV8EsCFkiFhGN7EszhrFggr3kdxZ2JMif9MGasu jRoWtDUxz6LRwYqCkTiN/WlrapVKPKgbh0EGTSAZ/LqUB9cXQFJp7s+2r0vJqDeix3hm I47g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=ZO3Y7qYLqMQXWZfT4IIdJ+9XW51gW7Uil26jcRpSnQ4=; b=OM28jk8pH8PD7jGKZb8Y4MjyemubIQTzXzvv2zA140L7n5cudq2T842CIACgMNfwvT DBqYOwJOEH/QXx8RvFGp320y1UQBpn//AusofQky6yoyArZbsi1PUoV1LZ3sGsIcsEHl H4rhZ37FRyonKgQBDgGLI9SbqVmksHXtRkcggvLRFSPNFrXhTRj0BLU6hebL4SCDntHi fMRwwvIHem43il4nN2dGoE5Wm5uUbTVUrZE+qGcxt+uCaVyQR2VJPY1kP2VOZM86YCx3 JMzDZ5qXZGi732XTvnRUXVWGa10xhcB/K6u/v9nQmrvzFUGAyqKQ54TiV5i7vD2J2zJH 1WkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h22si1805745oie.189.2020.02.19.05.38.32; Wed, 19 Feb 2020 05:38:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727858AbgBSNiV (ORCPT + 99 others); Wed, 19 Feb 2020 08:38:21 -0500 Received: from mga01.intel.com ([192.55.52.88]:10095 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727263AbgBSNiV (ORCPT ); Wed, 19 Feb 2020 08:38:21 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Feb 2020 05:38:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,459,1574150400"; d="scan'208";a="348943003" Received: from kuha.fi.intel.com ([10.237.72.53]) by fmsmga001.fm.intel.com with SMTP; 19 Feb 2020 05:38:16 -0800 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Wed, 19 Feb 2020 15:38:15 +0200 Date: Wed, 19 Feb 2020 15:38:15 +0200 From: Heikki Krogerus To: Peter Chen Cc: Felipe Balbi , Chunfeng Yun , Bin Liu , Benson Leung , Prashant Malani , Mika Westerberg , Greg Kroah-Hartman , "linux-kernel@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 Message-ID: <20200219133815.GH28776@kuha.fi.intel.com> References: <20200213132428.53374-1-heikki.krogerus@linux.intel.com> <20200213132428.53374-6-heikki.krogerus@linux.intel.com> <20200213133239.GN1498@kuha.fi.intel.com> <20200218072341.GA30350@b29397-desktop> <20200218122545.GF28776@kuha.fi.intel.com> <20200219015840.GC8602@b29397-desktop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200219015840.GC8602@b29397-desktop> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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