Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5993122rdb; Sun, 17 Sep 2023 23:56:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGd9qgnABtwCT4/wGf+qb1XxXTB3KQjWIqPS1EU0ykwlovK3WuHpBrVZOmoJJG2FX6pNdOM X-Received: by 2002:a17:902:9b83:b0:1bf:73ec:b980 with SMTP id y3-20020a1709029b8300b001bf73ecb980mr6048657plp.66.1695020206998; Sun, 17 Sep 2023 23:56:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695020206; cv=none; d=google.com; s=arc-20160816; b=yRDct5WUsgARwbnP46K209c2zwYZ6W6Bg8r493zU1HFNd/Pq6bXQpo/prsL0Wjik6O LaQfQHp0rT5s+7kcUkwtBt6JD6KyBKlsF8R+2AEkXzYkiweKhd8c7GBQWcr+NaoXC/0s gyBfmZgkildbQPOkeYXaWALAzPIRQW/pXRvSBVuMaj52O8i7/0mSwdyz8cjO5ZRJ189G jWt7vMWB3kon9NWxMTPdE0yDjutRvemvaCsFUN4XtFTXdR6FuMJGeg7V2qPsq1pXKBAA NimbmAvLa8BLULvxFMJ14Pgrk6NvCQ/Oc+oYgd6Phe76YcyZsWtV+PKfHJvoAhTohyk6 Iu6Q== 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=kg83dkCIcOfafRCLkMeI+KwToQlkTDJezwxVxKbajGo=; fh=CIUPAtsZsS2PZ4vys4GqJENPvNfZ4XConaz1xxgrC3k=; b=mUbmpVXLXJYL1KiEuLirUK8OW/SMxPcHvhB3OxFiEij1EYZIoZGGvo0aHB4ekHLDwF 9UPD5CYHa5MEO75jrfeV3YduwBel6CAf5olahbL9pz/cDs00QfBChTRrYPl7J1ZLskW8 VCfnq5NseHZy3oriZ/CmkJXkgoGXBKJjVa6zZz3llrRl7soJqrlapdAB/hlprNtlArIv Mtj7GFQkicSLZpS+2UBhEB8m9l7CyuUHA8OkngS6RIyUJK937aCc36ugB6alvcUSrybD j09QLoTgThGptaXqVzEEmbg9f+/qKYdbXpuQMZQJ8WkhZI+rW7YadRx6FpRYzPE7Npo9 tOQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MYNkTO4W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id i17-20020a170902e49100b001c3a2e70278si7587249ple.437.2023.09.17.23.56.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 23:56:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MYNkTO4W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 3BDA58069F03; Sun, 17 Sep 2023 22:51:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237259AbjIRFvG (ORCPT + 99 others); Mon, 18 Sep 2023 01:51:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239862AbjIRFud (ORCPT ); Mon, 18 Sep 2023 01:50:33 -0400 Received: from mail-oo1-xc2a.google.com (mail-oo1-xc2a.google.com [IPv6:2607:f8b0:4864:20::c2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6EE713E; Sun, 17 Sep 2023 22:50:23 -0700 (PDT) Received: by mail-oo1-xc2a.google.com with SMTP id 006d021491bc7-57656330b80so2741812eaf.3; Sun, 17 Sep 2023 22:50:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695016223; x=1695621023; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=kg83dkCIcOfafRCLkMeI+KwToQlkTDJezwxVxKbajGo=; b=MYNkTO4WyCd/g0JRXQtpGPcCDtRPxXU+Au/ADDQO5pVjG1SUT+rge4isnAaYzVauSM h01j7+s28hiYZKFa+14KQ6sJwKiumX/iyJUhzh0FkuJhjlziDwO0b8gWJ7qyNHm7BCJ5 I08UVme7L7t2+AYMXFi+PfYytmeMz4jC94gCfqRMq7qAUr0QSLsLUvP5TE2htNun9lX6 +UxqqXXJrvAWK+sD2LZj3mwIhVsZWq+YF5+8zxnqVl7GRG4CHnnofmNQOVm+TpO6XpcT NjfK/rUD66HORMukdqizhBWDVNFw+puxpt7lUtyh2tLuVjyNEAWXi/uonB2gI6of9w0Z bbXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695016223; x=1695621023; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kg83dkCIcOfafRCLkMeI+KwToQlkTDJezwxVxKbajGo=; b=Mk9SWpq3dvb3XHcYxBo004dMe0dclv3Bnnrsc9rOh/Lq8uJwx3P5+cnuxVVL1H0yiX whv6b1xQE1+VhF5FKhKFHkyx308x5gYQoPiU+Uke9Tat7JT8ZZgcAxGnrR3JX8HJYqU3 upddOy4644JZj/4tRjPZkoSEyooSRz/lZvfDGrPq53RwrwAB0k3UbD1fPfK/y3JtrDIy AzusimkbkZsCKltsoz53X1ljZiL9sO6L3xBTObjVYxP58a7yblAZr0N/MvBEz43JC0RH XsIRgDRdtToRIHw5iJO3NLOoT79yGxaIKBBp74d61UlnCqinGRPw4Sa8U0RoSLONhaR8 Kq1g== X-Gm-Message-State: AOJu0Yx3vAQLTGFjw3e/kGJfF+HcaonNGHdQNdp3Ol/j3Rf5hZ6RTRlS D03ntEvmvR3GDMM1+eJ4nHHH7WyfP9hpXbPXTgw= X-Received: by 2002:a4a:6c12:0:b0:56e:4ddd:e333 with SMTP id q18-20020a4a6c12000000b0056e4ddde333mr7419649ooc.9.1695016223045; Sun, 17 Sep 2023 22:50:23 -0700 (PDT) MIME-Version: 1.0 References: <20230914015656.20856-1-xingxing.luo@unisoc.com> <8365ba2a-8ecd-d055-e962-3a7f2bfdbfb0@omp.ru> In-Reply-To: From: xingxing luo Date: Mon, 18 Sep 2023 13:50:11 +0800 Message-ID: Subject: Re: [PATCH] usb: musb: Get the musb_qh poniter after musb_giveback To: Sergey Shtylyov , b-liu@ti.com Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, xingxing luo , Zhiyong.Liu@unisoc.com, Cixi.Geng1@unisoc.com, Orson.Zhai@unisoc.com, Chunyan Zhang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 17 Sep 2023 22:51:34 -0700 (PDT) Add more. On Mon, Sep 18, 2023 at 1:22=E2=80=AFPM xingxing luo wrote: > > On Fri, Sep 15, 2023 at 4:48=E2=80=AFPM Sergey Shtylyov wrote: > > > > On 9/15/23 5:59 AM, xingxing luo wrote: > > [...] > > > > >>> When multiple threads are performing USB transmission, musb->lock w= ill be > > >>> unlocked when musb_giveback is executed. At this time, qh may be re= leased > > >>> in the dequeue process in other threads, resulting in a wild pointe= r, so > > >>> it needs to be here get qh again, and judge whether qh is NULL, and= when > > >>> dequeue, you need to set qh to NULL. > > >>> > > >>> Fixes: dbac5d07d13e ("usb: musb: host: don't start next rx urb if c= urrent one failed") > > >>> Signed-off-by: Xingxing Luo > > >>> --- > > >>> drivers/usb/musb/musb_host.c | 9 ++++++++- > > >>> 1 file changed, 8 insertions(+), 1 deletion(-) > > >>> > > >>> diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_h= ost.c > > >>> index a02c29216955..9df27db5847a 100644 > > >>> --- a/drivers/usb/musb/musb_host.c > > >>> +++ b/drivers/usb/musb/musb_host.c > > >>> @@ -321,10 +321,16 @@ static void musb_advance_schedule(struct musb= *musb, struct urb *urb, > > >>> musb_giveback(musb, urb, status); > > >>> qh->is_ready =3D ready; > > >>> > > >>> + /* > > >>> + * musb->lock had been unlocked in musb_giveback, so somtimes= qh > > >> > > >> Sometimes? > > > > You have a typo... > > > > >> > > >>> + * may freed, need get it again > > >>> + */ > > >>> + qh =3D musb_ep_get_qh(hw_ep, is_in); > > >>> + > > >>> /* reclaim resources (and bandwidth) ASAP; deschedule it, and > > >>> * invalidate qh as soon as list_empty(&hep->urb_list) > > >>> */ > > >>> - if (list_empty(&qh->hep->urb_list)) { > > >>> + if (qh !=3D NULL && list_empty(&qh->hep->urb_list)) { > > >> > > >> Just qh, perhaps? > > > > > > Could you elaborate a little more? > > > Thanks. > > > > Just 'qh' gives you the same as 'qh !=3D NULL'. > > Ok, I will address this in the next version. > > > > > [...] > > > > MBR, Sergey B.R Xingxing.Luo