Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1858060pxb; Fri, 5 Mar 2021 01:05:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJwWs2Is0HTkrk4+OxnHocqOf6A8Z9vJ1b+a21mZCYdiTbs+uQiQSFFtMxSXxgZCKyYUIKy0 X-Received: by 2002:a5e:c00a:: with SMTP id u10mr7248460iol.165.1614935133943; Fri, 05 Mar 2021 01:05:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614935133; cv=none; d=google.com; s=arc-20160816; b=gtTQlDuu6nS1frzZUf/9T31cXFJFAXeetSxcnl099ymooV5T7amUOl4QcD1EGxRJ35 490G9rhPU3T0sy+/CjYJUt2SImdyXNlFJzL4e4eHq2evRxtZOQCPZcZsq541u80x+Z85 /8hPnD+PZL1QKmIoSZV1EsO22Vr5AG0Hau7lNSfu8VlIDGaz9rKhXt8/u0DVX87+yyEC 0m/yFDECBcwsKmX1iSTL4TAoLujRiiVULxvCeTiVkIKG4BpoY/80qwvZNJF3p+q6Vk1K ZrXbJOCUrLfQWtyU5IefeOzIet9lz2+fhr8uzHMU6s9wJa6+jpAoVY/w9Ta4CooUxD1a uKDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=atjP8f2LIBFIQmzpIATQWnkiklvX3yT/K4KDUa3wf4Q=; b=iIN0e6hXAtus2eX2FWQOhkVXBpx/QQtUsUuP3gnzkVXDAP6g2QYTftSX1w3IwZdpip GiOUOpxIiHeD9rtNDzy9IEpciFOezIPvWzoUsC0YE4p7OYsxByFinqu1HBHOvHHI0NrA f7pB6PtD3xLUzwcWS0KzJ6Pl6YDwbq1mlozv3IqorgqkRa+ip4bPQkdBvZPsJaErNBWk fTt+91j+8yUgbdmM6GFm4jrR5g2mDhNcOlI3bOR9+bqeO4dzNF7u3itr1tJYjMayGVaB 0A+vwV4ziXnzjXlqUR8OVeqr8VVzP4Q9Ph9tOD/TrvPuVXaFVkFbcbcEYyMiW2XPbBT0 W8vQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i4si2222454iov.52.2021.03.05.01.05.20; Fri, 05 Mar 2021 01:05:33 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229997AbhCEJDo (ORCPT + 99 others); Fri, 5 Mar 2021 04:03:44 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:44144 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229723AbhCEJD0 (ORCPT ); Fri, 5 Mar 2021 04:03:26 -0500 X-UUID: 6957a129b0464d079f75c935ee46d9b8-20210305 X-UUID: 6957a129b0464d079f75c935ee46d9b8-20210305 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1428301465; Fri, 05 Mar 2021 17:03:20 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs06n1.mediatek.inc (172.21.101.129) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 5 Mar 2021 17:03:18 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 5 Mar 2021 17:03:17 +0800 From: Chunfeng Yun To: Mathias Nyman , Greg Kroah-Hartman , Ikjoon Jang CC: Chunfeng Yun , Matthias Brugger , , , , , Nicolas Boichat , Eddie Hung Subject: [PATCH 06/17] usb: xhci-mtk: add a function to (un)load bandwidth info Date: Fri, 5 Mar 2021 17:02:44 +0800 Message-ID: <1614934975-15188-6-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1614934975-15188-1-git-send-email-chunfeng.yun@mediatek.com> References: <1614934975-15188-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Extract a function to load/unload bandwidth info, and remove a dummy check of TT offset. Signed-off-by: Chunfeng Yun --- 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 9016188eee97..bef82c1f909d 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.18.0