Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6555425ybi; Wed, 5 Jun 2019 02:49:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqx8Ogkt4Fpa7Q7r70UPbOCiIO9UUkfvMOhwM8h7ZTrCBfuNhifne3G9u84ojFcKZxkJ1Bqv X-Received: by 2002:aa7:8d10:: with SMTP id j16mr30815077pfe.204.1559728178293; Wed, 05 Jun 2019 02:49:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559728178; cv=none; d=google.com; s=arc-20160816; b=itV19ywrMvCfpUzNdwzAl+3WhJyFE5QMzmeLut3zoQpMkBYWJqiOCBOMVk8GvQE4qT iavNi5rYjU6T1MslUzLdZkzRRPh3xNe+YN/RxQttuRn8ZThro7kNm+T6t2OGff0yjvGS BLotKmQw/qVEVRRokp6sxjIms76gdo18m+8OTnnoaYtSrH7gTkS2qo/oYWJqaSbu0yeN +lMuBEyMhUa1Zd6+YR9FSbqZg94GkFWs+n1FY08dfgK4xYiZNMAAKjMN5rbyIYLmuBD2 YWMqLHDRwiuMtsVJs5hxxqLakLS2VdAayXYRQ5xww61Fqhu7lPMaZZnuNkcpg836RkMy DwKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:cc :references:to:subject; bh=grjBNnzx9l51zL5S3keIIjDGVi0z/QiNjnVmI0UGVtc=; b=Gn9qLebsjSe3bCIC6fRBTYo4fy/owHdgYRYpf/qzF0vmDBtA/RBJlcQc2rADPhguJp H8zx0Negfv4WhfkgJ10ZFRq5bVcCGyn9shRWS5nbbN/immLj7PUflBl0cYDnzKCeRHGK K/NJKRRk+i5Ryn1edN+kJlhqi22G73Rz8aW1bM7UjDWnU6Ntx79GH02fvezAiAr8iHOM rHjGlZwBuvGaMufAyrLqCW3sAn4ZbqwJpNWJbVjbGmvtOa0bwFKQGbPMlPn+5TDF13At bMrT/LDemOKTY3KM+2zVq0gYNzFvtUOmvi3Mh+qM7Nl93m7RfGdUTU//ZzQxtn904iPH y7ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=T0CwpM0U; 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=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si24949981plr.74.2019.06.05.02.49.21; Wed, 05 Jun 2019 02:49:38 -0700 (PDT) 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=@nvidia.com header.s=n1 header.b=T0CwpM0U; 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=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727079AbfFEJsJ (ORCPT + 99 others); Wed, 5 Jun 2019 05:48:09 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:12855 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727045AbfFEJsJ (ORCPT ); Wed, 5 Jun 2019 05:48:09 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 05 Jun 2019 02:48:05 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 05 Jun 2019 02:48:06 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 05 Jun 2019 02:48:06 -0700 Received: from [10.19.120.158] (172.20.13.39) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 5 Jun 2019 09:48:04 +0000 Subject: Re: [PATCH v11 1/2] usb: Add devaddr in struct usb_device To: , , , , , , , , References: <1559559224-9845-1-git-send-email-jilin@nvidia.com> <1559559224-9845-2-git-send-email-jilin@nvidia.com> CC: , From: Jim Lin Message-ID: Date: Wed, 5 Jun 2019 17:48:02 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <1559559224-9845-2-git-send-email-jilin@nvidia.com> X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL103.nvidia.com (172.20.187.11) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1559728085; bh=grjBNnzx9l51zL5S3keIIjDGVi0z/QiNjnVmI0UGVtc=; h=X-PGP-Universal:Subject:To:References:CC:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Transfer-Encoding; b=T0CwpM0U1bZ8cYs38JVl/NcOvHXHtjp1u9DpcUpioOoJCgRM13yw2a/ca79gLHgpm J+MyJ6f413Xswb0SN5ypua4/y927A7Dizy+nVpZEmFnTvTZnf6UulTJANNz61D8s/7 7UX3P5iPWNelw2vMVKKj2CAxkygOi7EZJ5yR8HAUKP2ZBtXs8GjlcelndF2JXrdbKl lzf+yV5f83SX+QtmkodPMGiiY4H/okuow71RuXx9KVFyqDSKrmr3wO8vY1V8UfhIzA YulD6hqh/CdSZkrEXN8bRx/LnE9OidNpX1MczWePk92TsuifmIsXz+OpkAtwK+9xmo 1sJNXo43zCssg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019=E5=B9=B406=E6=9C=8803=E6=97=A5 18:53, Jim Lin wrote: > The Clear_TT_Buffer request sent to the hub includes the address of > the LS/FS child device in wValue field. usb_hub_clear_tt_buffer() > uses udev->devnum to set the address wValue. This won't work for > devices connected to xHC. > > For other host controllers udev->devnum is the same as the address of > the usb device, chosen and set by usb core. With xHC the controller > hardware assigns the address, and won't be the same as devnum. > > Here we add devaddr in "struct usb_device" for > usb_hub_clear_tt_buffer() to use. > > Signed-off-by: Jim Lin > --- > v2: xhci_clear_tt_buffer_complete: add static, shorter indentation > , remove its claiming in xhci.h > v3: Add description for clearing_tt (xhci.h) > v4: Remove clearing_tt flag because hub_tt_work has hub->tt.lock > to protect for Clear_TT_Buffer to be run serially. > Remove xhci_clear_tt_buffer_complete as it's not necessary. > Same reason as the above. > Extend usb_hub_clear_tt_buffer parameter > v5: Not extending usb_hub_clear_tt_buffer parameter > Add description. > v6: Remove unused parameter slot_id from xhci_clear_hub_tt_buffer > v7: Add devaddr field in "struct usb_device" > v8: split as two patches, change type from int to u8 for devaddr. > v9: Use pahole to find place to put devaddr in struct usb_device. > Remove space between type cast and variable. > hub.c changed from v8 > clear->devinfo |=3D (u16) (udev->devaddr << 4); > to > clear->devinfo |=3D ((u16)udev->devaddr) << 4; > to solve a problem if devaddr is larger than 16. > v10 Initialize devaddr in xhci_setup_device() > Move devaddr to be below "u8 level" > v11 Add xhci.c "slot_ctx =3D ..." > > drivers/usb/core/hub.c | 4 +++- > drivers/usb/host/xhci.c | 2 ++ > include/linux/usb.h | 2 ++ > 3 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c > index 572e8c26a129..82cc3766cb23 100644 > --- a/drivers/usb/core/hub.c > +++ b/drivers/usb/core/hub.c > @@ -873,7 +873,7 @@ int usb_hub_clear_tt_buffer(struct urb *urb) > /* info that CLEAR_TT_BUFFER needs */ > clear->tt =3D tt->multi ? udev->ttport : 1; > clear->devinfo =3D usb_pipeendpoint (pipe); > - clear->devinfo |=3D udev->devnum << 4; > + clear->devinfo |=3D ((u16)udev->devaddr) << 4; > clear->devinfo |=3D usb_pipecontrol(pipe) > ? (USB_ENDPOINT_XFER_CONTROL << 11) > : (USB_ENDPOINT_XFER_BULK << 11); > @@ -2125,6 +2125,8 @@ static void update_devnum(struct usb_device *udev, = int devnum) > /* The address for a WUSB device is managed by wusbcore. */ > if (!udev->wusb) > udev->devnum =3D devnum; > + if (!udev->devaddr) > + udev->devaddr =3D (u8)devnum; > } > =20 > static void hub_free_dev(struct usb_device *udev) > diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c > index 20db378a6012..4f92643e3a4c 100644 > --- a/drivers/usb/host/xhci.c > +++ b/drivers/usb/host/xhci.c > @@ -4125,6 +4125,8 @@ static int xhci_setup_device(struct usb_hcd *hcd, s= truct usb_device *udev, > /* Zero the input context control for later use */ > ctrl_ctx->add_flags =3D 0; > ctrl_ctx->drop_flags =3D 0; > + slot_ctx =3D xhci_get_slot_ctx(xhci, virt_dev->out_ctx); > + udev->devaddr =3D (u8)(le32_to_cpu(slot_ctx->dev_state) & DEV_ADDR_MASK= ); > =20 > xhci_dbg_trace(xhci, trace_xhci_dbg_address, > "Internal device address =3D %d", > diff --git a/include/linux/usb.h b/include/linux/usb.h > index ae82d9d1112b..83d35d993e8c 100644 > --- a/include/linux/usb.h > +++ b/include/linux/usb.h > @@ -578,6 +578,7 @@ struct usb3_lpm_parameters { > * @bus_mA: Current available from the bus > * @portnum: parent port number (origin 1) > * @level: number of USB hub ancestors > + * @devaddr: device address, XHCI: assigned by HW, others: same as devnu= m > * @can_submit: URBs may be submitted > * @persist_enabled: USB_PERSIST enabled for this device > * @have_langid: whether string_langid is valid > @@ -661,6 +662,7 @@ struct usb_device { > unsigned short bus_mA; > u8 portnum; > u8 level; > + u8 devaddr; > =20 > unsigned can_submit:1; > unsigned persist_enabled:1; - May I get patch v11 1/2 acked or reviewed by Alan? Did I not do this already? Oh well, in any case: Acked-by: Alan Stern Alan Stern --nvpublic