Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5430395pxu; Thu, 22 Oct 2020 01:59:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxti4wC2VXWaJbmtSAmgJSvqssVtYg2KWfq8/eBOYDM+xA4hNap3sWZTeuJri0fVCzPhvc X-Received: by 2002:a17:907:70cb:: with SMTP id yk11mr942563ejb.122.1603357165420; Thu, 22 Oct 2020 01:59:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603357165; cv=none; d=google.com; s=arc-20160816; b=YdRRc3biCkRwUQmuv5RXhGm5ZLTdJa7NCO5UBYmtpI10ZAb+juhzQxsItYfKjWxP0v pFlmC6559rM1HxTy5KH8h7861pjXem047222TGsCSSCc8Au4D1BZbzAeTfvL9SI+2RM+ IQH0sxAVMI2jhwBkGHONe5atHCIRnPeEbTtqYnGFyMQEO3P0rYWsub6baTJL4GJkTL27 4cHMr09z1pWxzuCsv+5/Fq9g1ndEt5qT0IBsnjnAA2AL9R6vwB+ZHRXtu109+nKxgQ/c F4IHX/UV5SWltkkFMfMQlbIEymAIXhqOiKX2dga28og4NxASL8TjEl/UEZ7NZ7bKpZo7 ordA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=lIP+iGYVs26Ziy/Zw0+mDM8p96XSNhNo8oDPzMUB4/w=; b=zI9ozru1cDPoWZamYR5vz/uDmX5kcCfDFOlbZuvoWEASb2T8ATgYsjqFr0ALU2V/QE YK/LKH6tKfeNeufMRA6zuTzIm0G9l7uvYoAKBD6ODnfP4Mrvsd0Y0UvdlrTZuUqblFmv 7dgLSStkCLq80o9DFH+0gtmw10i6afQvaiTkiuNq2WJqh+YtPZKKnIpQaLSZLcvpM+5H ah4p9m7ymkTkzZAUFjAo+SKbwj2qpHW9Ppl1HwpXaF92Cwbk/049rGn8lG1epPVuPjT0 GONRvd4dQWS639lUfofqxA4mMQCrfkwRr+7U7Bn8r0JmvUf9J4ZpwJFoDPVIlVOuIZft wXmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iEi6a+RS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si732309edy.27.2020.10.22.01.59.03; Thu, 22 Oct 2020 01:59:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iEi6a+RS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2509092AbgJVH6b (ORCPT + 99 others); Thu, 22 Oct 2020 03:58:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:41540 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2509085AbgJVH6b (ORCPT ); Thu, 22 Oct 2020 03:58:31 -0400 Received: from saruman (88-113-213-94.elisa-laajakaista.fi [88.113.213.94]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F2FA8222E9; Thu, 22 Oct 2020 07:58:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603353510; bh=R3GjlbgsAx9M4Z5V/xVVQ17WGhcRX8d0qQvUOfWTD9k=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=iEi6a+RS0cISCZe+Xnl4ygnW2xdMiVzjk8atFZZKQSVEatUz1QcDdo5ioJPNnClSE ZJyjipNN8U/7OFMmjpHhpfjfd/hStq/C25IJ4YajF3dc9mrv882rcrtMJ8OUyqIa+z 8CKxK3a2P/lW/9HqDD/QF6DtwiISHT4MSx4f2UAo= From: Felipe Balbi To: Thinh Nguyen , John Stultz , lkml Cc: Yu Chen , Tejas Joglekar , Yang Fei , YongQin Liu , Andrzej Pietrasiewicz , Jun Li , Mauro Carvalho Chehab , Greg Kroah-Hartman , "linux-usb@vger.kernel.org" Subject: Re: [PATCH v2] usb: dwc3: Trigger a GCTL soft reset when switching modes in DRD In-Reply-To: References: <20201021224619.20796-1-john.stultz@linaro.org> Date: Thu, 22 Oct 2020 10:58:20 +0300 Message-ID: <87tuumelpf.fsf@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, Thinh Nguyen writes: > John Stultz wrote: >> static void __dwc3_set_mode(struct work_struct *work) >> { >> struct dwc3 *dwc =3D work_to_dwc(work); >> unsigned long flags; >> + int hw_mode; >> int ret; >> u32 reg; >>=20=20 >> @@ -154,6 +168,11 @@ static void __dwc3_set_mode(struct work_struct *wor= k) >> break; >> } >>=20=20 >> + /* Execute a GCTL Core Soft Reset when switch mode in DRD*/ >> + hw_mode =3D DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0); >> + if (hw_mode =3D=3D DWC3_GHWPARAMS0_MODE_DRD) >> + dwc3_gctl_core_soft_reset(dwc); >> + > > I think this should be done inside the spin_lock. > >> spin_lock_irqsave(&dwc->lock, flags); >>=20=20 >> dwc3_set_prtcap(dwc, dwc->desired_dr_role); > > The DRD mode change sequence should be like this if we want to switch > from host -> device according to the programming guide (for all DRD IPs): > 1. Reset controller with GCTL.CoreSoftReset > 2. Set GCTL.PrtCapDir(device) > 3. Soft reset with DCTL.CSftRst > 4. Then follow up with the initializing registers sequence > > However, from code review, with this patch, it follows this sequence: > a. Soft reset with DCTL.CSftRst on driver probe > b. Reset controller with GCTL.CoreSoftReset > c. Set GCTL.PrtCapDir(device) > d. < missing DCTL.CSftRst > > e. Then follow up with initializing registers sequence > > It may work, but it doesn't follow the programming guide. > > For device -> host, it should be fine because the xHCI driver will do > USBCMD.HCRST during initialization. The only reason why this is needed is because SNPS saves some die area by mapping some host and peripheral register to the same physical area in the die. I still think a full soft reset is unnecessary as we have been running this driver without that soft reset for several years now. =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJFBAEBCAAvFiEElLzh7wn96CXwjh2IzL64meEamQYFAl+RO50RHGJhbGJpQGtl cm5lbC5vcmcACgkQzL64meEamQYWERAArJPvRoN0gRVmDv0KjAcTbj3ERGO751DQ wSCHutD9ZLsxLDywoWOy5dZksoYkGp6rtnvTlO78h2Ve1ks/b3Etwo2QbpuDbgrU EnuzhecNaGREVdpK5lQ2UBwQAs/l+4jWeNGTs/JWnTstNJJH1r3iRHJCXzGr0o/N tL+HTBg49qHNdqdmIxpxjDIzIdz7vhQ8GDZTI8rW5xwimdHnIUBWrgLMaouM7M8/ iRIw8f+cC2GmuJ0bpiTTYgAaY+qltzTJms6IJ/f4QQil8WkkSgIHfC2U7zyyYzsp 9KsK2W5yNtii9JVfbZLY0x+Ut/QrjbgPffqR1I0B9PVMm9HO7sKyqhfYSIheAipa xXifm69+74EEnLdhGQV2LPrjcBe59gLmpGVnsTOH274JzrnLLREeXo87nNfhluio aWW7BYYenm0xAcU3gSmwdzHEAgFDCYLaHc8yWcsGJKvDt2Y6lO2JB4E7TEgtx6jK zh8zWU4F9LP7xQJHLKTC3aduwz1k8CVCtca5aLmfczNhNyd7rxFlsqu8bBOdy1ro 5+BSQIu9ok7Etdb/Ynh+eDM+Vqzp46fWSHfI93MeHqo2qFFzQPRsp3uLpyq7Du3T s1B0egzEdDYUpTsS7iLbGdLNhGLWNSpqnRHUG6Dti+VBWDotUL57KZD4LADkhAax oU3nbqiLCxA= =1ekg -----END PGP SIGNATURE----- --=-=-=--