Received: by 10.223.164.202 with SMTP id h10csp405744wrb; Wed, 15 Nov 2017 01:35:02 -0800 (PST) X-Google-Smtp-Source: AGs4zMYqbmEV4DOV1BoOxaY6OAxZEUEk/wwnCMlKXNNgI7T7W3nviCqMDB/JUEPFrV89sizIuMpS X-Received: by 10.101.78.210 with SMTP id w18mr14758112pgq.337.1510738502183; Wed, 15 Nov 2017 01:35:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510738502; cv=none; d=google.com; s=arc-20160816; b=tgMi/0xEVn+cT2FFobzGq2mrk9yB74vxaQkE9Kpe6J+nt3XcTj94F/ihAPm253K7EB KZQmNk9BifyumXuYeSeSeC2LzL/sOgzluE0znBYYOYSacFbSg9wvBr6oQMS5pAgEIXTU dJx/0Ggczz6PxLp4NF2lIlQMWIRkrxRecU/2ChsZenBYdi1Z3vjV66LbuiadmeswbBeE MtO2y1PtHvfE2FzWSPeWA6jkdOAT+iOoeSll0BBfMYBbVylR935SWLfo2EmcLwCXnAFf aQqOdZbBiS+60VAy885H6TQEGR2KNZmKzHGOAmBIZaLw459m0BZJhJJY+Y5L+RjuS6bY YAWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=M/d+AOe5F/IPG4RyNEF8JdbV3OSAawsz4HSidHN0ME4=; b=HgDW34934de23zdAtcmm6UjNRI5jXHD9X/hdb9xbJm/e4rekdGWNyjbOhKbmACl8QF SQNJV5yw5zmap0AGGjeYJeZk8gbJ+C1Ryjoh+Tp7cNZ3MsmaINdhxPxpDxe0bg+r07tw GWn8OwvFtzirf17Y0CqpZTMLJTqKdJ8RhopuS4O+mUzZ4FpMZ+RXG28Q2vLJs2dun4OU fUYMzWKppnSa3OxyhjfMYAqgm0GVxmMy2mAjgCUqGLDydQrrd601lJQarJXxG2VEGUiA GbDc7QI23Bs7WiNOYmFABHfBRUAzJk0vLtD5AAzk2s/TVXdoBPvSVoU/Kpf2w2Ovmw3v zIAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=rpoa43SS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d8si6279414pgu.56.2017.11.15.01.34.49; Wed, 15 Nov 2017 01:35:02 -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; dkim=pass header.i=@nxp.com header.s=selector1 header.b=rpoa43SS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932173AbdKOJd0 (ORCPT + 88 others); Wed, 15 Nov 2017 04:33:26 -0500 Received: from mail-eopbgr00088.outbound.protection.outlook.com ([40.107.0.88]:44761 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757301AbdKOJdS (ORCPT ); Wed, 15 Nov 2017 04:33:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=M/d+AOe5F/IPG4RyNEF8JdbV3OSAawsz4HSidHN0ME4=; b=rpoa43SSMSU71GSLHcQi9/JAlBaTdhhgc/KdmRFfVjKAnerPk1xduTvJ0+k7d+LBfuLw3IlGkl4ILq3AHdOERDBHShhw+II1/UB6Y5Oioq1AC4hB0rdLfDYbn2VRFCDWwq879iB5rXkH7XwoSvuTsFdyHWrUWPzcd1+u8BBhWzY= Received: from VI1PR04MB1504.eurprd04.prod.outlook.com (10.163.167.12) by HE1PR0401MB1820.eurprd04.prod.outlook.com (10.169.119.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.218.12; Wed, 15 Nov 2017 09:33:14 +0000 Received: from VI1PR04MB1504.eurprd04.prod.outlook.com ([fe80::b5:c3d7:853a:9ae]) by VI1PR04MB1504.eurprd04.prod.outlook.com ([fe80::b5:c3d7:853a:9ae%14]) with mapi id 15.20.0218.015; Wed, 15 Nov 2017 09:33:12 +0000 From: Ran Wang To: Felipe Balbi CC: Greg Kroah-Hartman , "open list:DESIGNWARE USB3 DRD IP DRIVER" , open list , Jerry Huang , "Rajesh Bhagat" , Leo Li , Rob Herring , "devicetree@vger.kernel.org" Subject: RE: [PATCH] usb: dwc3: Enable the USB snooping Thread-Topic: [PATCH] usb: dwc3: Enable the USB snooping Thread-Index: AQHTXdpMV/QBUrO8J0eNmcCmR0ATg6MVIlkAgAAD6zA= Date: Wed, 15 Nov 2017 09:33:12 +0000 Message-ID: References: <20171115060459.45375-1-ran.wang_1@nxp.com> <87ineb9b5v.fsf@linux.intel.com> In-Reply-To: <87ineb9b5v.fsf@linux.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=ran.wang_1@nxp.com; x-originating-ip: [192.158.241.86] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;HE1PR0401MB1820;6:RZ3sinkTPABkWUvQ1GwRAPlqeUBKflPnDcm7A5svpSiBtKuSF6sMwrDfP6Pkq+jJd7tklnfXk/giqfq1mkuyZG/8ehMrvhVRzBq2VbXtADbyjGsW6Bl+EdZAJ/d09H4mtiB/x3rBQZU7hRkpP7dhIvhqWzRoQeOLYOOdNJCFhS3Bys/13mT+9IPhHu46E3bdeyP6F4VMzxCxv0ttpfQLNIzGpJpENqrO310Sv/JPCbQ+GAhQzc+ClP2kdBGvfXsMZdZWHAFuJ9ocI9ceDpL1h96HyzL0DAY7dfntsREV3aZ0DE6WklcqiEGzZEwevmXA5Wis2V0peYi12tjIvWku7FyhqADXjAg2cHLUypiKyX0=;5:LH5TKpgt9flnQzKpAp3PMcIFDIS+abqBjVkv7fRN+oetllLKKdgqCPhaRzsPLClU9NZSc3AJdqmVRSrzXVYruT5lDoq1rs6PSBkpngkwgubiRi8Hgcw74N9ky4ExHvPDO5qBbQ/PbVRtWNQGGVF46DyCyhnulMTm0PQJHe+OP6U=;24:j18danUxF3Hmd8IyBMvKC6O67jiV5/R7fiHjpvQtZFMsH6s1efbDy1lYZexPNqveqgj+A+KLzjSmK9OQYYdtNm5ThDbsgDLXTVHp8xwT6O0=;7:NAqqAn0b0RjkBsOWeRPY+QpF+n4wbrjS1899HbcsagDcEH7AZFj/Dzw0BA0sIPz88DwHhn0Ep8WKARC18HpPRYtaJ4exFCenQdnx7zfsu7Y+KdV4xuFMlbjkQSZGcLwxC1AcI0yHKRDfIsJo/dx+fxRlrUzPCGDkBr4l8pDLi8/M6iqYIYqYNKx4rQotjU3aFOTDOdXxoRoEWe5wmqKLwdX3nlc6YptpURB/nrA1+QQgFCx//M6O2xI9M/ffv6W6 x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-forefront-antispam-report: SFV:SKI;SCL:-1;SFV:NSPM;SFS:(10009020)(6009001)(39860400002)(376002)(346002)(57704003)(189002)(199003)(13464003)(8936002)(66066001)(575784001)(6506006)(101416001)(6436002)(4326008)(33656002)(5660300001)(105586002)(55016002)(5250100002)(3280700002)(53936002)(68736007)(7696004)(9686003)(53546010)(6246003)(106356001)(86362001)(2906002)(6916009)(3660700001)(2950100002)(6116002)(14454004)(229853002)(8676002)(81156014)(305945005)(2900100001)(3846002)(478600001)(102836003)(189998001)(74316002)(7736002)(97736004)(54356999)(25786009)(316002)(99286004)(50986999)(54906003)(76176999)(81166006);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR0401MB1820;H:VI1PR04MB1504.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; x-ms-office365-filtering-correlation-id: f67d9371-be80-488f-e129-08d52c0be408 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603199);SRVR:HE1PR0401MB1820; x-ms-traffictypediagnostic: HE1PR0401MB1820: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(185117386973197); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3231022)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123560025)(20161123564025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:HE1PR0401MB1820;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:HE1PR0401MB1820; x-forefront-prvs: 0492FD61DD received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f67d9371-be80-488f-e129-08d52c0be408 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Nov 2017 09:33:12.3280 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0401MB1820 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Balbi, > -----Original Message----- > From: Felipe Balbi [mailto:balbi@kernel.org] > Sent: Wednesday, November 15, 2017 4:52 PM > To: Ran Wang > Cc: Greg Kroah-Hartman ; open > list:DESIGNWARE USB3 DRD IP DRIVER ; open > list ; Jerry Huang ; > Rajesh Bhagat ; Leo Li ; Ran > Wang ; Rob Herring ; > devicetree@vger.kernel.org > Subject: Re: [PATCH] usb: dwc3: Enable the USB snooping >=20 >=20 > Hi, >=20 > Ran Wang writes: > > Add support for USB3 snooping by asserting bits in register > > DWC3_GSBUSCFG0 for data and descriptor. >=20 > we know *how* to enable a feature :-) It's always the same, you fiddle wi= th > some registers and it works. What you failed to tell us is: >=20 > a) WHY do you need this? > b) WHY do we need another DT property for this? > c) WHAT does this mean for PCI devices? So far I cannot have the answer for you, will get you back after some discu= ssion with my colleagues. > > Signed-off-by: Changming Huang > > Signed-off-by: Rajesh Bhagat > > Signed-off-by: Ran Wang > > --- > > drivers/usb/dwc3/core.c | 24 ++++++++++++++++++++++++ > > drivers/usb/dwc3/core.h | 10 ++++++++++ > > 2 files changed, 34 insertions(+) > > > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index > > 07832509584f..ffc078ab4a1c 100644 > > --- a/drivers/usb/dwc3/core.c > > +++ b/drivers/usb/dwc3/core.c > > @@ -236,6 +236,26 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc) > > return -ETIMEDOUT; > > } > > > > +/* > > + * dwc3_enable_snooping - Enable snooping feature > > + * @dwc3: Pointer to our controller context structure */ static void > > +dwc3_enable_snooping(struct dwc3 *dwc) { > > + u32 cfg; > > + > > + cfg =3D dwc3_readl(dwc->regs, DWC3_GSBUSCFG0); > > + if (dwc->dma_coherent) { > > + cfg &=3D ~DWC3_GSBUSCFG0_SNP_MASK; > > + cfg |=3D (AXI3_CACHE_TYPE_SNP << > DWC3_GSBUSCFG0_DATARD_SHIFT) | > > + (AXI3_CACHE_TYPE_SNP << > DWC3_GSBUSCFG0_DESCRD_SHIFT) | > > + (AXI3_CACHE_TYPE_SNP << > DWC3_GSBUSCFG0_DATAWR_SHIFT) | > > + (AXI3_CACHE_TYPE_SNP << > DWC3_GSBUSCFG0_DESCWR_SHIFT); >=20 > This "value << shift" looks super clumsy. I would rather have something a= kin > to: >=20 > cfg |=3D DWC3_GSBUSCFG0_DATARD_CACHEABLE | > DWC3_GSBUSCFG0_DESCRD_CACHEABLE ... >=20 > and so on. Got it.=20 > > + } > > + > > + dwc3_writel(dwc->regs, DWC3_GSBUSCFG0, cfg); >=20 > this will *always* read and write GSBUSCFG0 even for those platforms whic= h > don't need to change anything on this register. You should just bail out = early > if !dwc->dma_coherent >=20 > Also, I think dma_coherent is likely not the best name for this property. >=20 > Another question is: Why wasn't this setup properly during coreConsultant > instantiation of the RTL? Do you have devices on the market already that > need this or is this some early FPGA model or test-only ASIC? Yes, you are right. Actually I thought that all dwc3 IP will have this reg= ister, and it can be controlled by DTS property.=20 > > @@ -776,6 +796,8 @@ static int dwc3_core_init(struct dwc3 *dwc) > > /* Adjust Frame Length */ > > dwc3_frame_length_adjustment(dwc); > > > > + dwc3_enable_snooping(dwc); > > + > > usb_phy_set_suspend(dwc->usb2_phy, 0); > > usb_phy_set_suspend(dwc->usb3_phy, 0); > > ret =3D phy_power_on(dwc->usb2_generic_phy); > > @@ -1021,6 +1043,8 @@ static void dwc3_get_properties(struct dwc3 > *dwc) > > &hird_threshold); > > dwc->usb3_lpm_capable =3D device_property_read_bool(dev, > > "snps,usb3_lpm_capable"); > > + dwc->dma_coherent =3D device_property_read_bool(dev, > > + "dma-coherent"); > > > > dwc->disable_scramble_quirk =3D device_property_read_bool(dev, > > "snps,disable_scramble_quirk"); > > diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index > > 4a4a4c98508c..6e6a66650e53 100644 > > --- a/drivers/usb/dwc3/core.h > > +++ b/drivers/usb/dwc3/core.h > > @@ -153,6 +153,14 @@ > > > > /* Bit fields */ > > > > +/* Global SoC Bus Configuration Register 0 */ > > +#define AXI3_CACHE_TYPE_SNP 0x2 /* cacheable */ > > +#define DWC3_GSBUSCFG0_DATARD_SHIFT 28 > > +#define DWC3_GSBUSCFG0_DESCRD_SHIFT 24 > > +#define DWC3_GSBUSCFG0_DATAWR_SHIFT 20 > > +#define DWC3_GSBUSCFG0_DESCWR_SHIFT 16 > > +#define DWC3_GSBUSCFG0_SNP_MASK 0xffff0000 >=20 >=20 >=20 > > + > > /* Global Debug Queue/FIFO Space Available Register */ > > #define DWC3_GDBGFIFOSPACE_NUM(n) ((n) & 0x1f) > > #define DWC3_GDBGFIFOSPACE_TYPE(n) (((n) << 5) & 0x1e0) > > @@ -859,6 +867,7 @@ struct dwc3_scratchpad_array { > > * 3 - Reserved > > * @imod_interval: set the interrupt moderation interval in 250ns > > * increments or 0 to disable. > > + * @dma_coherent: set if enable dma-coherent. >=20 > you're not enabling dma coherency, you're enabling cache snooping. And > this property should describe that. Also, keep in mind that different dev= ices > may want different cache types for each of those fields, so your property > would have to be a lot more complex. Something like: >=20 > snps,cache-type =3D , , ... >=20 > Then driver would have to parse this properly to setup GSBUSCFG0. Got it, learn a lot, need more time to digest and test, thanks for your pat= iently explanation. > In any > case, I still want to know why do you really need this? What's the reason= ? > What happens if you don't fix GSBUSCFG0? What's the value you have there > by default? Why isn't that default good enough? So far the Layerscape SoC (such as LS1088A) has enabled this feature and I have tested it. Once we add dma-coherent on DTS without this Patch, dwc3 will fail on device enumeration as below: [ 15.124031] xhci-hcd xhci-hcd.0.auto: Error while assigning device slot = ID [ 15.130912] xhci-hcd xhci-hcd.0.auto: Max number of devices this xHCI ho= st supports is 127. [ 15.139268] usb usb1-port1: couldn't allocate usb_device >=20 > ps: since you're fiddling with DT, you should also include devicetree@vge= r OK Best Regards Ran From 1584121587250259608@xxx Wed Nov 15 08:54:31 +0000 2017 X-GM-THRID: 1584112908314612929 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread