Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp797249rwb; Mon, 26 Sep 2022 06:05:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7TbhsPUNaSkj94kWlZEdgjcjJ7CJyhFZ6Ou2dPnZgLeEJ7c83GMOnQITVhh+VGYiVK14fu X-Received: by 2002:a17:906:5a45:b0:77a:406c:6867 with SMTP id my5-20020a1709065a4500b0077a406c6867mr17742302ejc.437.1664197541199; Mon, 26 Sep 2022 06:05:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664197541; cv=none; d=google.com; s=arc-20160816; b=oAyUKr3F5yhzm0tUnGE0K8IBIAhgea5gL0oKyKsRonLQxoPRHMRzwzQGwqt2CQrkh3 qQT5r1RgCGAFyVb7+O93H4ho2ARW6kZmhTOfBD0yGlMhfkiy7fLPCeOqk/J7Ax8WBkjh 95STIjIK6BWTZq3wqHutRDvv/kjavY55WdINxFfCFkDsAxtytaSg5WRWebVpWY+ANs84 Axkwr8lLMqjxVJWRh+66i9y+A64Impp1gbISskax6FeFICqpjjs699/R/scOtfvJkPgb 5bHoZK8MSgNmnrfXlAvBqrI2kUmn+5VBghcGEjdx9iyWyiX9d1k0uf2isZ7ybwW2IKhz JPmw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WK6uxasLXQ+BhiNhlunVF4EcDg+k6EQdN8FVvyIwyv4=; b=jTfq/PLTzxoFZHtRjzW1cLsR/fP4QcSyh3QvJJJ7kb2flD2ibRr2JFbGWgQ0UeDDEX 9SXRoO2DRFtZS0VGjOID88iPKVQmI0CCsZ9+xvHYZQlehcgl29B1nwsko0Bn4RemOljA fN4Wwom0aMEcKPUaCxxmQp4ixG+QQZI9c8IW/G9ck+Miw7F1+wDs36hLU/Bx1afHmxNk VXXIG33eSb9n0wfaRmd5ivnQiVs0qFXXFPoqczbPEnEKS8q/xSG5Gc5pt/1dRoi5/hFz 0Th3NtGYgMdMLlRBOXn1ZDJThL/o3ufw1jJ7IIVnw2GZVKxOp8NZsP/FltEdqMflJGJI 2X8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zNr4jX+L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt20-20020a170907729400b00780837381d8si17449156ejc.591.2022.09.26.06.05.13; Mon, 26 Sep 2022 06:05:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zNr4jX+L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236369AbiIZKmE (ORCPT + 99 others); Mon, 26 Sep 2022 06:42:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236027AbiIZKj6 (ORCPT ); Mon, 26 Sep 2022 06:39:58 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42FE53E77B; Mon, 26 Sep 2022 03:23:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0578FB80924; Mon, 26 Sep 2022 10:23:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39FCCC433C1; Mon, 26 Sep 2022 10:23:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664187820; bh=/KzNBC/1o7m8B9RSy27+tliksvw2eqi39Mn6M3WBaDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zNr4jX+L5UVJf9zNzuXTdlHyTUUGBIoZ7RHb3Acba3IhtAIf7UsjCK727A/sacNSk X8/Dk4ptiq/E+1bs2cGoqsQc3/KNmzC8zIqC6beVrbZBaxqRy6FAeeos1agyTE3Uua +HaDEEzYEuxotOLHN4YMjPQuLKu7Pv+dY58DBjzQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chunfeng Yun , Sasha Levin Subject: [PATCH 5.4 038/120] usb: xhci-mtk: add a function to (un)load bandwidth info Date: Mon, 26 Sep 2022 12:11:11 +0200 Message-Id: <20220926100752.083339049@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100750.519221159@linuxfoundation.org> References: <20220926100750.519221159@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chunfeng Yun [ Upstream commit 338af695fffb12a9407c376ce0cebce896c15050 ] Extract a function to load/unload bandwidth info, and remove a dummy check of TT offset. Signed-off-by: Chunfeng Yun Link: https://lore.kernel.org/r/6fbc000756a4a4a7efbce651b785fee7561becb6.1615170625.git.chunfeng.yun@mediatek.com Signed-off-by: Greg Kroah-Hartman Stable-dep-of: 548011957d1d ("usb: xhci-mtk: relax TT periodic bandwidth allocation") Signed-off-by: Sasha Levin --- drivers/usb/host/xhci-mtk-sch.c | 37 ++++++++++++++------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c index b1da3cb077c9..9a9685f74940 100644 --- a/drivers/usb/host/xhci-mtk-sch.c +++ b/drivers/usb/host/xhci-mtk-sch.c @@ -375,7 +375,6 @@ static void update_bus_bw(struct mu3h_sch_bw_info *sch_bw, sch_ep->bw_budget_table[j]; } } - sch_ep->allocated = used; } static int check_fs_bus_bw(struct mu3h_sch_ep_info *sch_ep, int offset) @@ -509,6 +508,19 @@ static void update_sch_tt(struct usb_device *udev, list_del(&sch_ep->tt_endpoint); } +static int load_ep_bw(struct usb_device *udev, struct mu3h_sch_bw_info *sch_bw, + struct mu3h_sch_ep_info *sch_ep, bool loaded) +{ + if (sch_ep->sch_tt) + update_sch_tt(udev, sch_ep, loaded); + + /* update bus bandwidth info */ + update_bus_bw(sch_bw, sch_ep, loaded); + sch_ep->allocated = loaded; + + return 0; +} + static u32 get_esit_boundary(struct mu3h_sch_ep_info *sch_ep) { u32 boundary = sch_ep->esit; @@ -535,7 +547,6 @@ static int check_sch_bw(struct usb_device *udev, u32 esit_boundary; u32 min_num_budget; u32 min_cs_count; - bool tt_offset_ok = false; int ret; /* @@ -552,8 +563,6 @@ static int check_sch_bw(struct usb_device *udev, ret = check_sch_tt(udev, sch_ep, offset); if (ret) continue; - else - tt_offset_ok = true; } if ((offset + sch_ep->num_budget_microframes) > esit_boundary) @@ -585,29 +594,15 @@ static int check_sch_bw(struct usb_device *udev, sch_ep->cs_count = min_cs_count; sch_ep->num_budget_microframes = min_num_budget; - if (sch_ep->sch_tt) { - /* all offset for tt is not ok*/ - if (!tt_offset_ok) - return -ERANGE; - - update_sch_tt(udev, sch_ep, 1); - } - - /* update bus bandwidth info */ - update_bus_bw(sch_bw, sch_ep, 1); - - return 0; + return load_ep_bw(udev, sch_bw, sch_ep, true); } static void destroy_sch_ep(struct usb_device *udev, struct mu3h_sch_bw_info *sch_bw, struct mu3h_sch_ep_info *sch_ep) { /* only release ep bw check passed by check_sch_bw() */ - if (sch_ep->allocated) { - update_bus_bw(sch_bw, sch_ep, 0); - if (sch_ep->sch_tt) - update_sch_tt(udev, sch_ep, 0); - } + if (sch_ep->allocated) + load_ep_bw(udev, sch_bw, sch_ep, false); if (sch_ep->sch_tt) drop_tt(udev); -- 2.35.1