Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp613067ybl; Fri, 13 Dec 2019 01:42:00 -0800 (PST) X-Google-Smtp-Source: APXvYqx0d3YS6Y08oBsMC3TbbQcJzAHK2TG+myGrcWWgV1J53sh4rEgwHVia4sNwznlYAOSTO/8N X-Received: by 2002:a9d:6a4c:: with SMTP id h12mr14005273otn.81.1576230120118; Fri, 13 Dec 2019 01:42:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576230120; cv=none; d=google.com; s=arc-20160816; b=i8NA/xYEL34lx8TAZoVZAv9X36s+O5lJxDQ8oTcel+gcM49KjT/RDODm0UJC1QE6wj +lyROEdZjmaknyHtoCzpIFiJWOvPLSw4Mr7Bo6+nDhikiAeVT3skea2ItRU3mznaMKPY Ux3gjkBqHqjXFzPZ6hu8vjmYT6WNONK0qKTeTerAXBn5ZYo605K/9AdrmQY/bTdKMwjH gmbDuu1YiujaXTStgs/ePOSXz0Q7cLKLlzQkdkFscgLfnHVgmb1NbsavV+u0WWfTvMEO KfztS0WHNHa039kjBmvd3W/BkZsLHGh5fcbHHp4Y+MkHKhuIl1oA5ixlh4bfCuLTKE81 hlvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=rLS9j9/v+WdGMqb4v9MHAWLQ8gZQVgXD7hX48cX4b0I=; b=GEa7C6rFwEVVvnmFCUKWiUejBn/TdC/NpK9lm9aiTdcldBg5BW3go2/ipUKfYjNqg+ nM+A4qNdRa45mS+bCL0SnAbMYEWHfKmO1fSnyiac5KO7PW029k5frqbBATIl/EqRaA1s 5Pgut4zQf5VAYARNW7XHnzUP82+yzmhCDXuQ/6KXRhrulMZ7kW/vctuwDUyWYKS59b7/ k/iTSRo+T4Xe4uD1/AOqRzf9sGZbPJOdjeOsHEEpaUJ3JSJ6zXwivNe3Rwk7DfQlgCF0 UAYgDdYmVbIBj3flazwbdN9qWvVM9soG1IyZ+PaJV9eQ7/T0RY5m4WMjtwt+HhLDK1Kh EIOw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x126si4660566oix.53.2019.12.13.01.41.49; Fri, 13 Dec 2019 01:42:00 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726524AbfLMJk7 (ORCPT + 99 others); Fri, 13 Dec 2019 04:40:59 -0500 Received: from jabberwock.ucw.cz ([46.255.230.98]:57996 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbfLMJk6 (ORCPT ); Fri, 13 Dec 2019 04:40:58 -0500 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 64EFE1C24A9; Fri, 13 Dec 2019 10:40:56 +0100 (CET) Date: Fri, 13 Dec 2019 10:40:55 +0100 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Thinh Nguyen , Felipe Balbi , Sasha Levin Subject: Re: [PATCH 4.19 099/243] usb: dwc3: debugfs: Properly print/set link state for HS Message-ID: <20191213094055.GB27976@amd> References: <20191211150339.185439726@linuxfoundation.org> <20191211150345.799359877@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="BwCQnh7xodEAoBMC" Content-Disposition: inline In-Reply-To: <20191211150345.799359877@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --BwCQnh7xodEAoBMC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > From: Thinh Nguyen >=20 > [ Upstream commit 0d36dede457873404becd7c9cb9d0f2bcfd0dcd9 ] >=20 > Highspeed device and below has different state names than superspeed and > higher. Add proper checks and printouts of link states for highspeed and > below. Just noticed some more oddity: >=20 > + case DWC3_LINK_STATE_RESUME: > + return "Resume"; > + default: > + return "UNKNOWN link state\n"; > + } "UNKNOWN" would be consistent with the rest of the file. > +++ b/drivers/usb/dwc3/debugfs.c > @@ -433,13 +433,17 @@ static int dwc3_link_state_show(struct seq_file *s,= void *unused) > unsigned long flags; > enum dwc3_link_state state; > u32 reg; > + u8 speed; > =20 > spin_lock_irqsave(&dwc->lock, flags); > reg =3D dwc3_readl(dwc->regs, DWC3_DSTS); > state =3D DWC3_DSTS_USBLNKST(reg); > - spin_unlock_irqrestore(&dwc->lock, flags); > + speed =3D reg & DWC3_DSTS_CONNECTSPD; > =20 > - seq_printf(s, "%s\n", dwc3_gadget_link_string(state)); > + seq_printf(s, "%s\n", (speed >=3D DWC3_DSTS_SUPERSPEED) ? > + dwc3_gadget_link_string(state) : > + dwc3_gadget_hs_link_string(state)); > + spin_unlock_irqrestore(&dwc->lock, flags); > =20 > return 0; > } The locking change is really wrong, right? There's no reason to do seq_printfs under spinlock.. > @@ -477,6 +483,15 @@ static ssize_t dwc3_link_state_write(struct file *file, > return -EINVAL; > =20 > spin_lock_irqsave(&dwc->lock, flags); > + reg =3D dwc3_readl(dwc->regs, DWC3_DSTS); > + speed =3D reg & DWC3_DSTS_CONNECTSPD; > + > + if (speed < DWC3_DSTS_SUPERSPEED && > + state !=3D DWC3_LINK_STATE_RECOV) { > + spin_unlock_irqrestore(&dwc->lock, flags); > + return -EINVAL; > + } > + > dwc3_gadget_set_link_state(dwc, state); > spin_unlock_irqrestore(&dwc->lock, flags); > =20 This might be ok but is not mentioned in the changelog. --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --BwCQnh7xodEAoBMC Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl3zXKcACgkQMOfwapXb+vLikgCdHTHZdhRWzTvFTOhg7AE29rDJ U8MAn1UIEgISShvU3BWSVEyBiz6Mq470 =qKFy -----END PGP SIGNATURE----- --BwCQnh7xodEAoBMC--