From patchwork Thu Aug 5 05:39:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ikjoon Jang X-Patchwork-Id: 12420343 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE22EC432BE for ; Thu, 5 Aug 2021 05:41:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9A35160EBB for ; Thu, 5 Aug 2021 05:41:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9A35160EBB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=639DJMPAPECnDWNTKg1DC4JGDQVnmsWz9GSpEA6QvIE=; b=gp95G/sWyhP/r6 ywQ74k/GndbU+325no4fY7CQfXUwcrit0fjjFs3IB7eAMYlCrchoUFMu9CUV2g3SxO0bSWgJcN6M0 StteQs50MTY1jZto1p2DM0eoaAjP3Gz4DDXZ74q1qnBh6kYrnjqC0zUziBcZJkuZGjvB+h2gz5+aB hpgzBqA2WUKUxjv9mE+8myEU7FuUIfC31X1rpwu+1onUc/ExkKZvMs+SIz/CaYGMFkQteD2jZvleE xo0sT8aAnhf4nJir72gktcapsm9gu60JkvYP9qYhfBVKqZq0J3kyIc8yrp7DwarIfnW5w14Qui7lf dpkh25zZ3yW+BueyLVxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mBW75-0089cu-Ps; Thu, 05 Aug 2021 05:40:15 +0000 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mBW6t-0089aV-0D for linux-arm-kernel@lists.infradead.org; Thu, 05 Aug 2021 05:40:04 +0000 Received: by mail-pj1-x102b.google.com with SMTP id l19so6470051pjz.0 for ; Wed, 04 Aug 2021 22:40:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=51DhxgLLj3oVTgO+Yt93dkTR66UP+XGV38AcifiutDo=; b=aZ9gfJt7tWoRAh1e4EZ2vxtE8tdrM3/OkMxB6G+f/d+SsaXKfIKeC+lZJJ4KdaNqXv YvRKy7WABqV9WttO1WUR0viz2JPHE/UNqxRlpRKKC6j2SZ381VLtRQ6XvWO/ucbFkAqV P1Ghs69qgg4RNDU7X0SJHs/XaDPJe57Wkcecw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=51DhxgLLj3oVTgO+Yt93dkTR66UP+XGV38AcifiutDo=; b=jp03+b5gFbEurxsAL1DN/r5de6bHlmlrDZ5hm7nl2uf0X+GXfYKuf91j8kkEV7y+6b XvuwVrSh22x9rpEla0K+2HmRLWo1qSN30/ow/cnDc7X9CCS7DAgNPjHAEbRomlXnv3+b U624KCZE4jhZIrs0Hyo0WOL7be1UUqIqjhqZEWIOZwaGKlfi7ECaLb2ttY5N4LTK40nL sWE2wzmH1tNujl7wsjUJZMZR55i8XGkhLZMsbvslmuXvOfg9DxyyQUbwWnHmsbdDQafR spbne+oHekvH4Q2aQVvOK9/qIDfaBrlHMK3h7m3SIUe+u6iTWhjy+LWZsEnGOYkLpecW ZX2g== X-Gm-Message-State: AOAM532bVOrYXshDQnmJlLCtpV6K8XWMr47wGkHVbPu7XvvtAKNRdFhb 7fM1gRTl9shwGO1nELnqL0I5SA== X-Google-Smtp-Source: ABdhPJyHCuhOyC1Oy4T+eWgglbQq9jy/tHFCTFzoK9gzeT7ihh+02C9vYfXvv+9/aVeXVOSdzr30AA== X-Received: by 2002:a17:902:7804:b029:12c:de88:7d50 with SMTP id p4-20020a1709027804b029012cde887d50mr2329868pll.27.1628142001763; Wed, 04 Aug 2021 22:40:01 -0700 (PDT) Received: from ikjn-p920.tpe.corp.google.com ([2401:fa00:1:10:7a1c:b216:fca0:2cc2]) by smtp.gmail.com with ESMTPSA id d22sm5448699pgi.73.2021.08.04.22.40.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Aug 2021 22:40:01 -0700 (PDT) From: Ikjoon Jang To: Chunfeng Yun , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Mathias Nyman , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , linux-usb@vger.kernel.org, Matthias Brugger , Ikjoon Jang Subject: [PATCH] usb: xhci-mtk: relax TT periodic bandwidth allocation Date: Thu, 5 Aug 2021 13:39:57 +0800 Message-Id: <20210805133937.1.Ia8174b875bc926c12ce427a5a1415dea31cc35ae@changeid> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210804_224003_118498_F67727F3 X-CRM114-Status: GOOD ( 16.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently xhci-mtk needs software-managed bandwidth allocation for periodic endpoints, it allocates the microframe index for the first start-split packet for each endpoint. As this index allocation logic should avoid the conflicts with other full/low-speed periodic endpoints, it uses the worst case byte budgets on high-speed bus bandwidth For example, for an isochronos IN endpoint with 192 bytes budget, it will consume the whole 4 u-frames(188 * 4) while the actual full-speed bus budget should be just 192bytes. This patch changes the low/full-speed bandwidth allocation logic to use "approximate" best case budget for lower speed bandwidth management. For the same endpoint from the above example, the approximate best case budget is now reduced to (188 * 2) bytes. Without this patch, many usb audio headsets with 3 interfaces (audio input, audio output, and HID) cannot be configured on xhci-mtk. Signed-off-by: Ikjoon Jang --- drivers/usb/host/xhci-mtk-sch.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c index f9b4d27ce449..46cbf5d54f4f 100644 --- a/drivers/usb/host/xhci-mtk-sch.c +++ b/drivers/usb/host/xhci-mtk-sch.c @@ -459,16 +459,17 @@ static int check_fs_bus_bw(struct mu3h_sch_ep_info *sch_ep, int offset) u32 num_esit, tmp; int base; int i, j; + u8 uframes = DIV_ROUND_UP(sch_ep->maxpkt, FS_PAYLOAD_MAX); num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit; + + if (sch_ep->ep_type == INT_IN_EP || sch_ep->ep_type == ISOC_IN_EP) + offset++; + for (i = 0; i < num_esit; i++) { base = offset + i * sch_ep->esit; - /* - * Compared with hs bus, no matter what ep type, - * the hub will always delay one uframe to send data - */ - for (j = 0; j < sch_ep->cs_count; j++) { + for (j = 0; j < uframes; j++) { tmp = tt->fs_bus_bw[base + j] + sch_ep->bw_cost_per_microframe; if (tmp > FS_PAYLOAD_MAX) return -ESCH_BW_OVERFLOW; @@ -546,6 +547,8 @@ static void update_sch_tt(struct mu3h_sch_ep_info *sch_ep, bool used) u32 base, num_esit; int bw_updated; int i, j; + int offset = sch_ep->offset; + u8 uframes = DIV_ROUND_UP(sch_ep->maxpkt, FS_PAYLOAD_MAX); num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit; @@ -554,10 +557,13 @@ static void update_sch_tt(struct mu3h_sch_ep_info *sch_ep, bool used) else bw_updated = -sch_ep->bw_cost_per_microframe; + if (sch_ep->ep_type == INT_IN_EP || sch_ep->ep_type == ISOC_IN_EP) + offset++; + for (i = 0; i < num_esit; i++) { - base = sch_ep->offset + i * sch_ep->esit; + base = offset + i * sch_ep->esit; - for (j = 0; j < sch_ep->cs_count; j++) + for (j = 0; j < uframes; j++) tt->fs_bus_bw[base + j] += bw_updated; }