From patchwork Thu Dec 10 10:47:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ikjoon Jang X-Patchwork-Id: 11964139 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=-16.8 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 5CAAAC433FE for ; Thu, 10 Dec 2020 10:49:22 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 0989823D50 for ; Thu, 10 Dec 2020 10:49:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0989823D50 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=JLuZz+4bNDmRnGnxomxgg6y7/Hu2a33GqxH7T6ql/oM=; b=KUD0aNMSJhzsEBps018FjfHfF ALgbrDrqlN7L11LHSf7wDKxKVprrd50x7H3VUBpkwcBUqpCi1ZtOEodjVePC9axTUuiHTDVoNqUAE YWBjYwI/Tjhiz/h9p0X9Zc1oVgxTaWFj7VeIDOh8wFGRVOQyzFOqc5L9Jq9B+8e6A9JEaIfs8LZ1S VcetOE6IxfKjlc8t8MKHsVGuwO+ugyX/57wn1F2dPTqv7TeV53hskpAUkYzFLelEal8F3Ida4IVCz gRr7VQ9KtrB5vFyvlXKhYuSki5z886DKFUdkDoCXSfLiszV/ibahiasMhG9tXNFsFXBRDcq25l1ho NiHWg4qRQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1knJUa-0002p2-NJ; Thu, 10 Dec 2020 10:48:12 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1knJUQ-0002l2-3I for linux-arm-kernel@lists.infradead.org; Thu, 10 Dec 2020 10:48:04 +0000 Received: by mail-pl1-x642.google.com with SMTP id x12so2095437plr.10 for ; Thu, 10 Dec 2020 02:48:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bVxoTM9ZIDuLtAtEZCaE86d03rCpF39qAUQSwcojzBQ=; b=mCzBo3T7pjVoucpOnWfWM+ywq7wwbqcufmD7e+j4SDVNHPVXEgjxmw0PgQPIZlYvoN FaCLmRNc/fmz9xEqpT/1D8VlDCq9wKCZ/Q1gsvL/uBjrlm2tTLp0BB7l03y0mcOezM80 kMb0qYWr/YBfzgUq2L+AGo8Hng4rKToF0xWs0= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=bVxoTM9ZIDuLtAtEZCaE86d03rCpF39qAUQSwcojzBQ=; b=cBK4Qnm1bp1V16vCxNR2OBg8XjPScl8v8Jy9IL4wbQHTSgypibssG7LR2DnuA3DpQn 1NVrm6Jza1pgbbh1xXc4whFG5Fsgdu0IRFuDPnGM0zAEWoSFzswd2SS6WzqeBRhqp80C f1kAk4TmxnVP3JUJR/ltRsef60isQ9dDEgXiDeb7aIVfkqiaMXIPkh50jEm718WU0tKv ssWRounaE3QT9eOXbyDHZOfSrGKcE/Rf0AjKHJl6c83rppId7Fw6eYOge/laJMp++cKw hONnzGpZulpFcK2Xp6QenFK5OAWN00RpHaiWE8L3Y1+bIj3HdmHMS/MmySS6J0j0cmaU zujg== X-Gm-Message-State: AOAM531m6hgy+YISrkoWYW1bhMZNqbyDe+OiUcYpAA9uP0Hhq3qhDMxI 14zz3N/EFHlQfLO9x/nfwf0gAQ== X-Google-Smtp-Source: ABdhPJxr7DuO4PC45I9h6/PmEATHMWDZamF91OytRBLHd3oflEYtNyuiMontSXkEgPoJ7p6PKKDnnw== X-Received: by 2002:a17:902:82c7:b029:da:cb88:38f8 with SMTP id u7-20020a17090282c7b02900dacb8838f8mr967622plz.49.1607597280180; Thu, 10 Dec 2020 02:48:00 -0800 (PST) Received: from ikjn-p920.tpe.corp.google.com ([2401:fa00:1:b:f693:9fff:fef4:a8fc]) by smtp.gmail.com with ESMTPSA id y1sm6386658pff.17.2020.12.10.02.47.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Dec 2020 02:47:59 -0800 (PST) From: Ikjoon Jang To: linux-mediatek@lists.infradead.org, linux-usb@vger.kernel.org Subject: [PATCH v2 2/3] usb: xhci-mtk: delay association of tt and ep Date: Thu, 10 Dec 2020 18:47:46 +0800 Message-Id: <20201210184700.v2.2.I236cbd6fe27db5a9c776b6d14fe146748373bbce@changeid> X-Mailer: git-send-email 2.29.2.576.ga3fc446d84-goog In-Reply-To: <20201210104747.3416781-1-ikjn@chromium.org> References: <20201210104747.3416781-1-ikjn@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201210_054802_304208_E74AA1CA X-CRM114-Status: GOOD ( 16.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhanyong Wang , Mathias Nyman , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Tianping Fang , Matthias Brugger , Chunfeng Yun , Ikjoon Jang , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org xhci-mtk creates internal data structures for representing the relationship between endpoint and TT. This patch simply delays its association between endpoint and TT when it's really loaded onto internal bandwidth table. This is a preparation step for fixing unreleased periodic TT bandwidth data, no functional changes. Signed-off-by: Ikjoon Jang --- drivers/usb/host/xhci-mtk-sch.c | 40 ++++++++++++++++----------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c index c334b6d76479..439391f1dc78 100644 --- a/drivers/usb/host/xhci-mtk-sch.c +++ b/drivers/usb/host/xhci-mtk-sch.c @@ -174,7 +174,6 @@ static struct mu3h_sch_ep_info *create_sch_ep(struct usb_device *udev, struct usb_host_endpoint *ep, struct xhci_ep_ctx *ep_ctx) { struct mu3h_sch_ep_info *sch_ep; - struct mu3h_sch_tt *tt = NULL; u32 len_bw_budget_table; size_t mem_size; @@ -192,15 +191,6 @@ static struct mu3h_sch_ep_info *create_sch_ep(struct usb_device *udev, if (!sch_ep) return ERR_PTR(-ENOMEM); - if (is_fs_or_ls(udev->speed)) { - tt = find_tt(udev); - if (IS_ERR(tt)) { - kfree(sch_ep); - return ERR_PTR(-ENOMEM); - } - } - - sch_ep->sch_tt = tt; sch_ep->ep = ep; return sch_ep; @@ -377,10 +367,10 @@ static void update_bus_bw(struct mu3h_sch_bw_info *sch_bw, } } -static int check_sch_tt(struct usb_device *udev, - struct mu3h_sch_ep_info *sch_ep, u32 offset) +static int check_sch_tt(struct mu3h_sch_tt *tt, + struct mu3h_sch_ep_info *sch_ep, + u32 offset) { - struct mu3h_sch_tt *tt = sch_ep->sch_tt; u32 extra_cs_count; u32 fs_budget_start; u32 start_ss, last_ss; @@ -450,10 +440,9 @@ static int check_sch_tt(struct usb_device *udev, return 0; } -static void update_sch_tt(struct usb_device *udev, - struct mu3h_sch_ep_info *sch_ep) +static void update_sch_tt(struct mu3h_sch_tt *tt, + struct mu3h_sch_ep_info *sch_ep) { - struct mu3h_sch_tt *tt = sch_ep->sch_tt; u32 base, num_esit; int i, j; @@ -465,10 +454,12 @@ static void update_sch_tt(struct usb_device *udev, } list_add_tail(&sch_ep->tt_endpoint, &tt->ep_list); + sch_ep->sch_tt = tt; } static int check_sch_bw(struct usb_device *udev, - struct mu3h_sch_bw_info *sch_bw, struct mu3h_sch_ep_info *sch_ep) + struct mu3h_sch_bw_info *sch_bw, + struct mu3h_sch_ep_info *sch_ep) { u32 offset; u32 esit; @@ -480,8 +471,14 @@ static int check_sch_bw(struct usb_device *udev, u32 min_cs_count; bool tt_offset_ok = false; int ret; + struct mu3h_sch_tt *tt = NULL; esit = sch_ep->esit; + if (is_fs_or_ls(udev->speed)) { + tt = find_tt(udev); + if (IS_ERR(tt)) + return -ENOMEM; + } /* * Search through all possible schedule microframes. @@ -493,7 +490,7 @@ static int check_sch_bw(struct usb_device *udev, min_num_budget = sch_ep->num_budget_microframes; for (offset = 0; offset < esit; offset++) { if (is_fs_or_ls(udev->speed)) { - ret = check_sch_tt(udev, sch_ep, offset); + ret = check_sch_tt(tt, sch_ep, offset); if (ret) continue; else @@ -531,10 +528,11 @@ static int check_sch_bw(struct usb_device *udev, if (is_fs_or_ls(udev->speed)) { /* all offset for tt is not ok*/ - if (!tt_offset_ok) + if (!tt_offset_ok) { + drop_tt(udev); return -ERANGE; - - update_sch_tt(udev, sch_ep); + } + update_sch_tt(tt, sch_ep); } /* update bus bandwidth info */