Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp654780pxt; Thu, 12 Aug 2021 06:52:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyajv909/BhqvU1vpm4llEPWVQWdSJBS7BtLUmF3Hqeyiw8oy+Eq7psq5hl7c9aBSo9az2E X-Received: by 2002:a17:906:b0c8:: with SMTP id bk8mr3764504ejb.412.1628776330246; Thu, 12 Aug 2021 06:52:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628776330; cv=none; d=google.com; s=arc-20160816; b=ECCt7fqlhssL4XdaKc+C/noT/JwGEAZBzEjeOcNU8aJHREzE5/RK4ycNbAM3HfQWgA VJxD0IfJ/q+gtqVNJHaioYQ7ogMn7+venur4dwTOkJn9EHWgny5nWT6Fkj7W1inlacfo LqiXZYxcwlt6S9oQfRkaWIOqogmmEPDEFpqHhtTclMA1224HlzOeDaHwwWh5Sxv7UkYC gAU12qZU6/IXtLSlPD0uHk3VxeZx4SCFtCXOMalatpdL1qUl+UYqL2e2HpPeP5z2SdLd F64BdNPX1ojkz8353ngWqF329mz1RN8KPeyvAnMtgAUnEHabySNqcaEF2MQk60qWk9Bb +UdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=hyhelxpd7QUVPAkk5IYGM9KEnUOWxWDMxwO8ECoYdnU=; b=eNE4+FICNFuePD7BQTCQgK2x9Sreqx7S8LQNBbswUEYhyF9+shrrltZU7ds2gXg0dL 3g5SyBzlfOrW6zSH3oyLhFJ4FBWROFGCuBAdIPlJ5T0RncHKXiIWyK53NgTx01VSR7qn l6kcS2BfxbaTAVLlWaRo50k4O2QcdR1OzRk7cYfWk+YbhBmMndDvBPzOfF/CkcnbWV4N ZWmwHETLnnyx4s3GTnQUKH0OdYDQeYd51fJV4w0Gfebqe0D7iDS2/53lxrSqv0fAfIWj zO5m/KxgJSZtZJ5/1f6OtwsljfExaZqe/438nHzuK0VE7LdxaG9K9u9irppHMO4kjU3p C04A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Rs4dAv5o; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r11si2582896edd.67.2021.08.12.06.51.46; Thu, 12 Aug 2021 06:52:10 -0700 (PDT) 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; dkim=pass header.i=@chromium.org header.s=google header.b=Rs4dAv5o; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237612AbhHLNsE (ORCPT + 99 others); Thu, 12 Aug 2021 09:48:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232859AbhHLNsC (ORCPT ); Thu, 12 Aug 2021 09:48:02 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1845CC0613D9 for ; Thu, 12 Aug 2021 06:47:34 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id b7so7343690plh.7 for ; Thu, 12 Aug 2021 06:47:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=hyhelxpd7QUVPAkk5IYGM9KEnUOWxWDMxwO8ECoYdnU=; b=Rs4dAv5o9o6YzH/Kos2vl/SACHZatk/nOkTogbL/1EBFQ9n8+ZFw91oSx+CeUKBQ3H 2m6mLxziThndH+V4UTq3JF0Qt/JuqFap8S5hupa6Ec5y4PXtz7ajadJH4M8D5rAQblUM 2su3i/xOb5hBn41lp62bfbt0FSGbf+Admw2lA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=hyhelxpd7QUVPAkk5IYGM9KEnUOWxWDMxwO8ECoYdnU=; b=bZSFnYawDH3iiRR1zMmBswNB7brDBb2cIXPpCphNNUDqzduOeiPiAZhhKhkrP84vO2 GggQLGrvD/lkbH0FfKyyGWuagx8Eeb+jEQvTpuQGpvnFUjr/UGfWxskkNU6NToRaGGiQ 0OeWfFnhp7Y6ILEwzZSaHNGdhIsgJLJtu/Mf3dZLh2BCPDIPDy8GzuLhhsRN+WVVZoBU Dg7W9uHheWQJHPAQWncRlieM2iZvF4bXi742xgNL5wfwI4RSUH/MiS0mkBwPcbnhpuXZ /oTk2TZaHSSIJrLFfCfAyIEOw3IGXKVuxIbiGh8KDC2BhAEoWUKhX7LmTJDLZmn73T+9 dOVg== X-Gm-Message-State: AOAM530nkJSCIDqsICO87FaArXq9hnC6vxJGUbXMQB4wvE/TyMi4DLS8 2DMxkqQIPnTWOH9in9DadbRWUitM3zl/cORTYx4VkA== X-Received: by 2002:aa7:8387:0:b029:395:a683:a0e6 with SMTP id u7-20020aa783870000b0290395a683a0e6mr4295749pfm.12.1628776053473; Thu, 12 Aug 2021 06:47:33 -0700 (PDT) MIME-Version: 1.0 References: <20210809165904.RFC.1.I5165a4a8da5cac23c9928b1ec3c3a1a7383b7c23@changeid> <7b48f4c132a8b4b3819282e961fbe8b3ed753069.camel@mediatek.com> In-Reply-To: From: Ikjoon Jang Date: Thu, 12 Aug 2021 21:47:22 +0800 Message-ID: Subject: Re: [RFC PATCH] usb: xhci-mtk: handle bandwidth table rollover To: =?UTF-8?B?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= Cc: "linux-arm-kernel@lists.infradead.org" , "matthias.bgg@gmail.com" , "linux-mediatek@lists.infradead.org" , "gregkh@linuxfoundation.org" , "mathias.nyman@intel.com" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org oops sorry I sent a prior mail in HTML. Resend this mail in plain text. On Thu, Aug 12, 2021 at 7:49 PM Chunfeng Yun (=E4=BA=91=E6=98=A5=E5=B3=B0) wrote: > > On Thu, 2021-08-12 at 17:31 +0800, Ikjoon Jang wrote: > > HI, > > > > On Wed, Aug 11, 2021 at 5:02 PM Chunfeng Yun (=E4=BA=91=E6=98=A5=E5=B3= =B0) > > wrote: > > > > > > On Mon, 2021-08-09 at 17:42 +0800, Ikjoon Jang wrote: > > > > On Mon, Aug 9, 2021 at 5:11 PM Greg Kroah-Hartman > > > > wrote: > > > > > > > > > > On Mon, Aug 09, 2021 at 04:59:29PM +0800, Ikjoon Jang wrote: > > > > > > xhci-mtk has 64 slots for periodic bandwidth calculations and > > > > > > each > > > > > > slot represents byte budgets on a microframe. When an > > > > > > endpoint's > > > > > > allocation sits on the boundary of the table, byte budgets' > > > > > > slot > > > > > > should be rolled over but the current implementation doesn't. > > > > > > > > > > > > This patch applies a 6 bits mask to the microframe index to > > > > > > handle > > > > > > its rollover 64 slots and prevent out-of-bounds array access. > > > > > > > > > > > > Signed-off-by: Ikjoon Jang > > > > > > --- > > > > > > > > > > > > drivers/usb/host/xhci-mtk-sch.c | 79 +++++++++------------ > > > > > > ---- > > > > > > -------- > > > > > > drivers/usb/host/xhci-mtk.h | 1 + > > > > > > 2 files changed, 23 insertions(+), 57 deletions(-) > > > > > > > > > > Why is this "RFC"? What needs to be addressed in this change > > > > > before it > > > > > can be accepted? > > > > > > > > sorry, I had to mention why this is RFC: > > > > > > > > I simply don't know about the details of the xhci-mtk internals. > > > > It was okay from my tests with mt8173 and I think this will be > > > > harmless > > > > as this is "better than before". > > > > > > > > But when I removed get_esit_boundary(), I really have no idea why > > > > it was there. I'm wondering if there was another reason of that > > > > function > > > > other than just preventing out-of-bounds. Maybe chunfeng can > > > > answer > > > > this? > > > > > > We use @esit to prevent out-of-bounds array access. it's not a > > > ring, > > > can't insert out-of-bounds value into head slot. > > > > Thanks, so that function was only for out-of-bounds array access. > > then I think we just can remove that function and use it as a ring. > > Can you tell me _why_ it can't be used as a ring? > Treat it as a period, roll over slot equals to put it into the next > period. > > > > > I think a transaction (e.g. esit_boundary =3D 7) can start its first > > SSPLIT > > from Y_7 (offset =3D 7). But will that allocation be matched with this? > > > > - if ((offset + sch_ep->num_budget_microframes) > > > esit_boundary) > > - break; > > > > I mean I'm not sure why this is needed. > Prevent out-of-bounds. > > > > > Until now, I couldn't find a way to accept the USB audio headset > > with a configuration of { INT-IN 64 + ISOC-OUT 384 + ISOC-IN 192 } > > without this patch. > what is the interval value of each endpoint? interrupt ep is 2ms and others are 1ms Thanks. > > > > > > > > > > > > > > Thanks! > > > > > > > > > > > > > > thanks, > > > > > > > > > > greg k-h