Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753519AbdHKQTG (ORCPT ); Fri, 11 Aug 2017 12:19:06 -0400 Received: from mail-he1eur01on0064.outbound.protection.outlook.com ([104.47.0.64]:27184 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753242AbdHKQTD (ORCPT ); Fri, 11 Aug 2017 12:19:03 -0400 From: Leo Li To: Yinbo Zhu , Yinbo Zhu , Rob Herring , Mark Rutland , Russell King , Felipe Balbi CC: open list , Laurent Pinchart , Catalin Marinas , open list , open list , Doug Ledford , "Stefano Stabellini" , Greg Kroah-Hartman , Bart Van Assche , moderated list Subject: RE: [linux-devel] [PATCH 2/3] usb: dwc3 : Add support for USB snooping Thread-Topic: [linux-devel] [PATCH 2/3] usb: dwc3 : Add support for USB snooping Thread-Index: AQHTEor352R7SSCs+0uFBslQclADZ6J/U9+A Date: Fri, 11 Aug 2017 16:18:58 +0000 Message-ID: References: <1502445596-33716-1-git-send-email-yinbo.zhu@nxp.com> In-Reply-To: <1502445596-33716-1-git-send-email-yinbo.zhu@nxp.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=leoyang.li@nxp.com; x-originating-ip: [192.88.168.1] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;HE1PR04MB1259;6:871Lr/uJ7CqbU2mtArLQ6+Ev2zNtKs+RBgwXZ4nl5g6pxfttiAFkncfsxMq/07dJnnWZTyElmwD3D9sYQmJqyVzTSnMq28X/Kd3EjNpAWwYi7SVJkAMzw6/q6c5eZP7YWVKX6CAOdpPg+wOAhplu7xNGpSUBui71mf3UwMn3h3V8MROUAt3bMbmI6cdd5ctxur3v2FNQ22eUxxzvj5a1nh5NEOHdXVmZ1lWnWwPSVF7GcqJH/ujp6hyFPfqlCrDaiK0a/8sXAb5TMcrxMRlE4t662xMgBXeqAE27XS4Kpxn22uJoxlFwDADxp8GXpeRiu1Cd4nJ2+P14MTc128HOUA==;5:dPt5Xi6Glyt2+sR3b6rf8ix34SR28WNaIRmQT+YXHyJPZZev5YJw4gJjz/WGavWgmX9ZTk25Me/dI1ULTuSTQ8lDs7yXFs+muoLYclwTHuGuXrmn7dGhOZJzi0MXsu5EUqI5JjpEsK6tydVfUiMlIA==;24:RSD22W5NwWMK465wTj6Ckl38CXZrD8X5weSFx0Y8weveuaKJf5zdO5Q+fBwHHF2QHBB5CR9SCGCclFnGO5dnh/1qSfV7JkXq5mUSU1TiZDM=;7:PXZcxDd6BQP653P9WIQnxiWuz++AV9T8fxrOHDEHm0fk0/DjdzYVjN6oTzfAl/8BQDhTLlK4MSeEsSe1jHJnJW6NxfRExXFvrhlKJXK0CFdGX6Jh7iGTecgrvX5GNvzYbhVFtc/mlQHKa2VAp8JF5RVxvZaV3Gv5LsTcVprK+tZDb24a0SDvcgKJ8DdzQuUYZu9iV+mAf3qw573hNO8iQ173zO/7oFvygX7txo/djwA= x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-forefront-antispam-report: SFV:SKI;SCL:-1;SFV:NSPM;SFS:(10009020)(6009001)(39860400002)(13464003)(189002)(377454003)(199003)(4326008)(66066001)(81156014)(81166006)(25786009)(53546010)(6506006)(68736007)(97736004)(8676002)(7416002)(189998001)(2900100001)(55016002)(5660300001)(7696004)(8936002)(99286003)(6306002)(74316002)(54906002)(9686003)(3660700001)(101416001)(2950100002)(53936002)(229853002)(478600001)(76176999)(50986999)(14454004)(33656002)(6436002)(8656003)(54356999)(86362001)(575784001)(2906002)(305945005)(3280700002)(966005)(105586002)(7736002)(106356001)(5250100002)(6116002)(3846002)(102836003)(45080400002)(6246003);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR04MB1259;H:AM4PR0401MB1699.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; x-ms-office365-filtering-correlation-id: a0c5b635-d404-4cac-bf66-08d4e0d4ab98 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:HE1PR04MB1259; x-ms-traffictypediagnostic: HE1PR04MB1259: x-exchange-antispam-report-test: UriScan:(180628864354917)(9452136761055)(189930954265078)(185117386973197)(101931422205132)(258649278758335)(259967162476793)(45079756050767)(42932892334569); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(10201501046)(6055026)(6041248)(20161123562025)(20161123564025)(20161123558100)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:HE1PR04MB1259;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:HE1PR04MB1259; x-forefront-prvs: 03965EFC76 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Aug 2017 16:18:58.1435 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR04MB1259 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v7BGJCtO019629 Content-Length: 7422 Lines: 219 > -----Original Message----- > From: linux-devel-bounces@gforge.freescale.net [mailto:linux-devel- > bounces@gforge.freescale.net] On Behalf Of yinbo.zhu@nxp.com > Sent: Friday, August 11, 2017 5:00 AM > To: linux-devel@gforge.freescale.net; Yinbo Zhu ; Rob > Herring ; Mark Rutland ; > Russell King ; Felipe Balbi > Cc: open list ; Laurent Pinchart > ; Catalin Marinas > ; open list ; open list > ; Doug Ledford ; > Stefano Stabellini ; Greg Kroah-Hartman > ; Bart Van Assche > ; moderated list kernel@lists.infradead.org> > Subject: [linux-devel] [PATCH 2/3] usb: dwc3 : Add support for USB snooping > > From: Rajesh Bhagat > > Add support for USB3 snooping by asserting bits in register DWC3_GSBUSCFG0 > for data and descriptor The description doesn't fully cover the change you made below, for example allocating multiple event buffers. Please explain why you made such change. > > Signed-off-by: Nikhil Badola > Signed-off-by: Rajesh Bhagat > Signed-off-by: yinbo.zhu > --- > drivers/usb/dwc3/core.c | 71 ++++++++++++++++++++++++++++++++++++------- > ------ > drivers/usb/dwc3/core.h | 3 +++ > drivers/usb/dwc3/host.c | 8 +++++- > 3 files changed, 63 insertions(+), 19 deletions(-) > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index > 02a534a..b51b0d8 100644 > --- a/drivers/usb/dwc3/core.c > +++ b/drivers/usb/dwc3/core.c > @@ -90,6 +90,7 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc) > > if (IS_ENABLED(CONFIG_USB_DWC3_HOST)) > mode = USB_DR_MODE_HOST; > + Why are you adding a new line here? > else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET)) > mode = USB_DR_MODE_PERIPHERAL; > } > @@ -305,14 +306,27 @@ static void dwc3_free_event_buffers(struct dwc3 > *dwc) > */ > static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) { > - struct dwc3_event_buffer *evt; > + int num; > + int i; > + > + num = DWC3_NUM_INT(dwc->hwparams.hwparams1); > + dwc->num_event_buffers = num; > + > + dwc->ev_buffs = devm_kzalloc(dwc->dev, sizeof(*dwc->ev_buffs) * num, > + GFP_KERNEL); > + if (!dwc->ev_buffs) > + return -ENOMEM; > > - evt = dwc3_alloc_one_event_buffer(dwc, length); > - if (IS_ERR(evt)) { > - dev_err(dwc->dev, "can't allocate event buffer\n"); > - return PTR_ERR(evt); > + for (i = 0; i < num; i++) { > + struct dwc3_event_buffer *evt; > + > + evt = dwc3_alloc_one_event_buffer(dwc, length); > + if (IS_ERR(evt)) { > + dev_err(dwc->dev, "can't allocate event buffer\n"); > + return PTR_ERR(evt); > + } > + dwc->ev_buffs[i] = evt; > } > - dwc->ev_buf = evt; > > return 0; > } > @@ -325,17 +339,25 @@ static int dwc3_alloc_event_buffers(struct dwc3 > *dwc, unsigned length) > */ > static int dwc3_event_buffers_setup(struct dwc3 *dwc) { > - struct dwc3_event_buffer *evt; > - > - evt = dwc->ev_buf; > - evt->lpos = 0; > - dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(0), > - lower_32_bits(evt->dma)); > - dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0), > - upper_32_bits(evt->dma)); > - dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), > - DWC3_GEVNTSIZ_SIZE(evt->length)); > - dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0); > + struct dwc3_event_buffer *evt; > + int n; > + > + for (n = 0; n < dwc->num_event_buffers; n++) { > + evt = dwc->ev_buffs[n]; > + dev_dbg(dwc->dev, "Event buf %p dma %08llx length %d\n", > + evt->buf, (unsigned long long) evt->dma, > + evt->length); > + > + evt->lpos = 0; > + > + dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n), > + lower_32_bits(evt->dma)); > + dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), > + upper_32_bits(evt->dma)); > + dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n), > + DWC3_GEVNTSIZ_SIZE(evt->length)); > + dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0); > + } > > return 0; > } > @@ -1181,6 +1203,7 @@ static void dwc3_check_params(struct dwc3 *dwc) > static int dwc3_probe(struct platform_device *pdev) { > struct device *dev = &pdev->dev; > + struct device_node *node = dev->of_node; > struct resource *res; > struct dwc3 *dwc; > > @@ -1188,7 +1211,6 @@ static int dwc3_probe(struct platform_device *pdev) > > void __iomem *regs; > > - struct device_node *node = dev->of_node; > dwc = devm_kzalloc(dev, sizeof(*dwc), GFP_KERNEL); > if (!dwc) > return -ENOMEM; > @@ -1260,6 +1282,19 @@ static int dwc3_probe(struct platform_device *pdev) > goto err2; > } > > + /* Change burst beat and outstanding pipelined transfers requests */ > + dwc3_writel(dwc->regs, DWC3_GSBUSCFG0, > + (dwc3_readl(dwc->regs, DWC3_GSBUSCFG0) & ~0xff) | 0xf); > + dwc3_writel(dwc->regs, DWC3_GSBUSCFG1, > + dwc3_readl(dwc->regs, DWC3_GSBUSCFG1) | 0xf00); > + > + /* Enable Snooping */ > + if (node && of_dma_is_coherent(node)) { > + dwc3_writel(dwc->regs, DWC3_GSBUSCFG0, > + dwc3_readl(dwc->regs, DWC3_GSBUSCFG0) | 0x22220000); > + dev_dbg(dev, "enabled snooping for usb\n"); > + } > + > ret = dwc3_get_dr_mode(dwc); > if (ret) > goto err3; > diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index > b83388f..e075665 100644 > --- a/drivers/usb/dwc3/core.h > +++ b/drivers/usb/dwc3/core.h > @@ -29,6 +29,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -913,6 +914,7 @@ struct dwc3 { > struct platform_device *xhci; > struct resource > xhci_resources[DWC3_XHCI_RESOURCES_NUM]; > > + struct dwc3_event_buffer **ev_buffs; > struct dwc3_event_buffer *ev_buf; > struct dwc3_ep *eps[DWC3_ENDPOINTS_NUM]; > > @@ -946,6 +948,7 @@ struct dwc3 { > u32 incrx_type[2]; > u32 irq_gadget; > u32 nr_scratch; > + u32 num_event_buffers; > u32 u1u2; > u32 maximum_speed; > > diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index > 3e85616..0f2b86c 100644 > --- a/drivers/usb/dwc3/host.c > +++ b/drivers/usb/dwc3/host.c > @@ -93,8 +93,14 @@ int dwc3_host_init(struct dwc3 *dwc) > dma_set_coherent_mask(&xhci->dev, dwc->dev- > >coherent_dma_mask); > > xhci->dev.parent = dwc->dev; > - > xhci->dev.dma_mask = dwc->dev->dma_mask; > + xhci->dev.dma_parms = dwc->dev->dma_parms; > + > + /* set DMA operations */ > + if (dwc->dev->of_node && of_dma_is_coherent(dwc->dev->of_node)) { > + xhci->dev.archdata.dma_ops = dwc->dev->archdata.dma_ops; > + dev_dbg(dwc->dev, "set dma_ops for usb\n"); > + } > > dwc->xhci = xhci; > > -- > 2.1.0.27.g96db324 > > _______________________________________________ > linux-devel mailing list > linux-devel@gforge.freescale.net > https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgforge. > freescale.net%2Fmailman%2Flistinfo%2Flinux- > devel&data=01%7C01%7Cleoyang.li%40nxp.com%7Cdcd03fd92ce54edfdbd508 > d4e0a2177f%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0&sdata=s87LyGGpn > LwaLJxTm20tGTj9yC7noIMvoonqiZv7mVM%3D&reserved=0