Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp446299pxb; Thu, 9 Sep 2021 04:47:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzX6KEGYw5QvuNEU2aOdGMuzTPh8WhkesGlVnhTggoaqLkF5xtKXNv0Q3mlg3YC3a+FuCdc X-Received: by 2002:a17:906:f243:: with SMTP id gy3mr2953044ejb.327.1631188048170; Thu, 09 Sep 2021 04:47:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631188048; cv=none; d=google.com; s=arc-20160816; b=pZGOssL+5JWacVvfTbztY6IMVCN5Yty9GsXfB4cOvqGpIYYGLkwZsfN3FW8e9fP1aE rEivByeLTytvvkKKO3QX2mVsZfxHzStVsOUIppuCfa7/0m71uNf90QQ0iwv45aqjcTv2 aRMVJ+BhNvzIDc0eQQbOKYI6ULUDfdaSNtzQuzLZp8Fp+EkdVDIaco6v4e0JYbb4vin5 R0n3uZ37rZmxzKC+v/u3oFbOyKqgMtn686eGdR6T0QsDTfCSAz5F8FoWx9wkVsZ9kBVD hRm86QHsU+kzqEtYtvy2up6sYG6SQ+Sv6K2IFX0t4t1KzHss+kmEiQQkWv0TrTelgwQX bw6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ij/3ytqopztmKDA82JJJs2kz0DVatXDXx44nelcoUPs=; b=gKdykKOASvOFKrQ6d52yp9WODTYnVXsXyWr+CJOVqyJ+Ic+Yr63NFNT/7AplnpQ4gY m6bvgmRtSthn8xXDYpxkVcUOqMh+tiHIyI7+SAOJbPuuyH5kZ8KveWWOL+PiR2eRuj6s Bw1Slv8vwh1S+ekKeWvxS/sHEytp+NLISAW70AxCYlIouuDcgfL9ykQpg2rWdThxD4tQ Ko2pY7trlmVmYO1O+qGJmUYjCcqug9Li835pDNwScbfHd/8G1PZJsOuTZZSKbhBcJZHT kRErJwvdQJFYs+2G3lSLDBy1vM8UEaeZylgrhjgsSYy5Ih6sQex4ALo0GW1QOq4RPvw2 YjHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vFVOP45y; 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 b20si1660710edw.120.2021.09.09.04.47.03; Thu, 09 Sep 2021 04:47:28 -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=k20201202 header.b=vFVOP45y; 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 S237638AbhIILqy (ORCPT + 99 others); Thu, 9 Sep 2021 07:46:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:45714 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237644AbhIILnQ (ORCPT ); Thu, 9 Sep 2021 07:43:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6C0C3611C1; Thu, 9 Sep 2021 11:41:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187717; bh=/7KPsCX9pQezb/7uiZQSpE7yV0x6xQss320gO62+wss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vFVOP45y7OjYP8gEYNwboF4HiJ3yEaWvCTors/nXyTzuZBk8bkVlO7d9naenqHZ2L /ohu2EWtLVGCXMfi18+r7FD6rXqe1reGDiTiBK//78h009XPBMsr3Q5+w4tANjfxOu 1VgEH9ne1lu5mEu9xGlNALECp0H1gUuVpUYSyb57hRqgbpXFR0sLtTWb3oXqB58P3T C//bLJPAMZpQsk051ivLpWtVM73A/URkCqZFHa+cE/zhafhus8DKyTg2w9q7efNEva klOivJGq9oct8m/sIT1lJV7t2B2yLaCBShIvIRxyFOu7GwSJt5u3MiBLB4AnHnokuy 0lvHi2rGqjFRw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kelly Devilliv , Greg Kroah-Hartman , Sasha Levin , linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 5.14 039/252] usb: host: fotg210: fix the endpoint's transactional opportunities calculation Date: Thu, 9 Sep 2021 07:37:33 -0400 Message-Id: <20210909114106.141462-39-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kelly Devilliv [ Upstream commit c2e898764245c852bc8ee4857613ba4f3a6d761d ] Now that usb_endpoint_maxp() only returns the lowest 11 bits from wMaxPacketSize, we should make use of the usb_endpoint_* helpers instead and remove the unnecessary max_packet()/hb_mult() macro. Signed-off-by: Kelly Devilliv Link: https://lore.kernel.org/r/20210627125747.127646-3-kelly.devilliv@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/host/fotg210-hcd.c | 36 ++++++++++++++++------------------ 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c index 05fb8d97cf02..dd29f7b68d6f 100644 --- a/drivers/usb/host/fotg210-hcd.c +++ b/drivers/usb/host/fotg210-hcd.c @@ -2510,11 +2510,6 @@ static unsigned qh_completions(struct fotg210_hcd *fotg210, return count; } -/* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */ -#define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03)) -/* ... and packet size, for any kind of endpoint descriptor */ -#define max_packet(wMaxPacketSize) ((wMaxPacketSize) & 0x07ff) - /* reverse of qh_urb_transaction: free a list of TDs. * used for cleanup after errors, before HC sees an URB's TDs. */ @@ -2600,7 +2595,7 @@ static struct list_head *qh_urb_transaction(struct fotg210_hcd *fotg210, token |= (1 /* "in" */ << 8); /* else it's already initted to "out" pid (0 << 8) */ - maxpacket = max_packet(usb_maxpacket(urb->dev, urb->pipe, !is_input)); + maxpacket = usb_maxpacket(urb->dev, urb->pipe, !is_input); /* * buffer gets wrapped in one or more qtds; @@ -2714,9 +2709,11 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb, gfp_t flags) { struct fotg210_qh *qh = fotg210_qh_alloc(fotg210, flags); + struct usb_host_endpoint *ep; u32 info1 = 0, info2 = 0; int is_input, type; int maxp = 0; + int mult; struct usb_tt *tt = urb->dev->tt; struct fotg210_qh_hw *hw; @@ -2731,14 +2728,15 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb, is_input = usb_pipein(urb->pipe); type = usb_pipetype(urb->pipe); - maxp = usb_maxpacket(urb->dev, urb->pipe, !is_input); + ep = usb_pipe_endpoint(urb->dev, urb->pipe); + maxp = usb_endpoint_maxp(&ep->desc); + mult = usb_endpoint_maxp_mult(&ep->desc); /* 1024 byte maxpacket is a hardware ceiling. High bandwidth * acts like up to 3KB, but is built from smaller packets. */ - if (max_packet(maxp) > 1024) { - fotg210_dbg(fotg210, "bogus qh maxpacket %d\n", - max_packet(maxp)); + if (maxp > 1024) { + fotg210_dbg(fotg210, "bogus qh maxpacket %d\n", maxp); goto done; } @@ -2752,8 +2750,7 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb, */ if (type == PIPE_INTERRUPT) { qh->usecs = NS_TO_US(usb_calc_bus_time(USB_SPEED_HIGH, - is_input, 0, - hb_mult(maxp) * max_packet(maxp))); + is_input, 0, mult * maxp)); qh->start = NO_FRAME; if (urb->dev->speed == USB_SPEED_HIGH) { @@ -2790,7 +2787,7 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb, think_time = tt ? tt->think_time : 0; qh->tt_usecs = NS_TO_US(think_time + usb_calc_bus_time(urb->dev->speed, - is_input, 0, max_packet(maxp))); + is_input, 0, maxp)); qh->period = urb->interval; if (qh->period > fotg210->periodic_size) { qh->period = fotg210->periodic_size; @@ -2853,11 +2850,11 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb, * to help them do so. So now people expect to use * such nonconformant devices with Linux too; sigh. */ - info1 |= max_packet(maxp) << 16; + info1 |= maxp << 16; info2 |= (FOTG210_TUNE_MULT_HS << 30); } else { /* PIPE_INTERRUPT */ - info1 |= max_packet(maxp) << 16; - info2 |= hb_mult(maxp) << 30; + info1 |= maxp << 16; + info2 |= mult << 30; } break; default: @@ -3927,6 +3924,7 @@ static void iso_stream_init(struct fotg210_hcd *fotg210, int is_input; long bandwidth; unsigned multi; + struct usb_host_endpoint *ep; /* * this might be a "high bandwidth" highspeed endpoint, @@ -3934,14 +3932,14 @@ static void iso_stream_init(struct fotg210_hcd *fotg210, */ epnum = usb_pipeendpoint(pipe); is_input = usb_pipein(pipe) ? USB_DIR_IN : 0; - maxp = usb_maxpacket(dev, pipe, !is_input); + ep = usb_pipe_endpoint(dev, pipe); + maxp = usb_endpoint_maxp(&ep->desc); if (is_input) buf1 = (1 << 11); else buf1 = 0; - maxp = max_packet(maxp); - multi = hb_mult(maxp); + multi = usb_endpoint_maxp_mult(&ep->desc); buf1 |= maxp; maxp *= multi; -- 2.30.2