Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp185753imm; Tue, 28 Aug 2018 19:57:57 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZlpsvBz2SQljzHsIkylLh3mqU3MGNayB39DG3ITMezBgeRVpTsz+9mfCC/oFRNyYO6e3s4 X-Received: by 2002:a62:3a08:: with SMTP id h8-v6mr3937801pfa.61.1535511477472; Tue, 28 Aug 2018 19:57:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535511477; cv=none; d=google.com; s=arc-20160816; b=FTwxtI44RHT3dscJSd12aj7FUmmMspg1Kbz9SrqNfQNiEKBygrhQgaHGCa49UEfWSe RLeko8udnXeexdC5sm5EVMm4wz7SwksXcbkx4Se4erSnUEb0ZAeWmpvjtunUh05pFuaS 9wEVYolEThBSHLKS/NnERgbwg27WfyIrU/BYEGyxKY605O04ZkACUphXL1jBx7J3gJ99 RrLkI4fHFZ++sHsjxgqU9WyIgGCnUXDOTKVph3XkDfG2M7COxuV4YvDbzz9QorYHDhP9 cYzLSqN2j7ABxgm3m9TfKpNudTKXSkKikC06/PpIWsjuiRu0hodUrQwsEgqGBHS0P3zZ 5kQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=am9WaxycubF2hd3zO7EHU7apj8PzQL1O4JZST4X69T8=; b=M4EtQNDFEyF2S88K988XYNgJ4Xk+a66yvnSCLk04NMBahMmVrGSgXpKW8BDFO754eP YrODU+kVD3W15te24KPlf2u38KevDJyF4rk9i0xn8iTc12K8UIZ/vUFGX9wZ/c+fUrmf kymHH7vslx/C02efKlOKxI62wPAcPhXU7Qr9Vj7zR+o/V6Lhv9TK/uMWDaPAMwKtdymP sXRWvA4fByNogSEMYJFVHH3YJ+eFVga2MgM8w/DfxbkIn/tBsROLAkXNO3U5yewYchzC LccQ7t8kR5FZ6scjNE2EVfZq61KY1VVS9M4ShlYNPV3iVX/OCklCDzP6ofzNkTjXqjZg xkoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 71-v6si2618048pfv.139.2018.08.28.19.57.30; Tue, 28 Aug 2018 19:57:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727581AbeH2GuJ (ORCPT + 99 others); Wed, 29 Aug 2018 02:50:09 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:40039 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727067AbeH2GuJ (ORCPT ); Wed, 29 Aug 2018 02:50:09 -0400 X-UUID: 3264ebb230f14bafa9934d6a3c8d4f3f-20180829 Received: from mtkcas35.mediatek.inc [(172.27.4.250)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 178765800; Wed, 29 Aug 2018 10:55:23 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by MTKMBS31N1.mediatek.inc (172.27.4.69) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Wed, 29 Aug 2018 10:55:21 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Wed, 29 Aug 2018 10:55:20 +0800 From: Chunfeng Yun To: Mathias Nyman CC: Greg Kroah-Hartman , Felipe Balbi , Matthias Brugger , Alan Stern , Chunfeng Yun , , , , , Subject: [PATCH 2/6] usb: xhci-mtk: use maximum ESIT payload of endpiont context Date: Wed, 29 Aug 2018 10:55:14 +0800 Message-ID: <19a0f3e20ba5314112c08307ee39cca603ddf819.1535510898.git.chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <3bcc220aa54bfebc39cea54cd736388ad37ee0c5.1535510898.git.chunfeng.yun@mediatek.com> References: <3bcc220aa54bfebc39cea54cd736388ad37ee0c5.1535510898.git.chunfeng.yun@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make use of maximum ESIT payload of endpoint context to calculate the number of packets to send in each ESIT Signed-off-by: Chunfeng Yun --- drivers/usb/host/xhci-mtk-sch.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c index fa33d6e..46fe0a2 100644 --- a/drivers/usb/host/xhci-mtk-sch.c +++ b/drivers/usb/host/xhci-mtk-sch.c @@ -73,12 +73,17 @@ static void setup_sch_info(struct usb_device *udev, u32 max_burst; u32 mult; u32 esit_pkts; + u32 max_esit_payload; ep_type = CTX_TO_EP_TYPE(le32_to_cpu(ep_ctx->ep_info2)); ep_interval = CTX_TO_EP_INTERVAL(le32_to_cpu(ep_ctx->ep_info)); max_packet_size = MAX_PACKET_DECODED(le32_to_cpu(ep_ctx->ep_info2)); max_burst = CTX_TO_MAX_BURST(le32_to_cpu(ep_ctx->ep_info2)); mult = CTX_TO_EP_MULT(le32_to_cpu(ep_ctx->ep_info)); + max_esit_payload = + (CTX_TO_MAX_ESIT_PAYLOAD_HI( + le32_to_cpu(ep_ctx->ep_info)) << 16) | + CTX_TO_MAX_ESIT_PAYLOAD(le32_to_cpu(ep_ctx->tx_info)); sch_ep->esit = 1 << ep_interval; sch_ep->offset = 0; @@ -105,7 +110,15 @@ static void setup_sch_info(struct usb_device *udev, } else if (udev->speed == USB_SPEED_SUPER) { /* usb3_r1 spec section4.4.7 & 4.4.8 */ sch_ep->cs_count = 0; - esit_pkts = (mult + 1) * (max_burst + 1); + /* + * some device's (d)wBytesPerInterval is set as 0, + * then max_esit_payload is 0, so evaluate esit_pkts from + * mult and burst + */ + esit_pkts = DIV_ROUND_UP(max_esit_payload, max_packet_size); + if (esit_pkts == 0) + esit_pkts = (mult + 1) * (max_burst + 1); + if (ep_type == INT_IN_EP || ep_type == INT_OUT_EP) { sch_ep->pkts = esit_pkts; sch_ep->num_budget_microframes = 1; -- 1.9.1