Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4961482pxv; Tue, 27 Jul 2021 22:56:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+HypMVEkwzyGoHewCaz9hT3lLhQFsOKqY+k5C9ArhPnV7Nh2AZp3l35zmefWYzSFKwUqZ X-Received: by 2002:a02:774a:: with SMTP id g71mr24470412jac.137.1627451809256; Tue, 27 Jul 2021 22:56:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627451809; cv=none; d=google.com; s=arc-20160816; b=pIdNBVhk+FEujZpBsYWpayCv1/nA/ZNy7APzuxK6lcJLpgTL5MpDo9EUh6Cy4d3QR2 k0N1HKmgyuKkTQ3Hkw/On27+2F9K5SqdLXZz4rk6zEGFF66Be1R/vrYGXxqlQtFnU+HB UlmE1RTBOc4QxKn4VUd35dakHcVdDYwbSI2ByZ1J2l+wO1l/aLJlqgvSsddk9PaeAGSd Gkf7wU3nn+e65ReGE94ad2minG+rq2Y5nKJF7aFDNetUVLwjwgdM89QjnlRDHCLQlEvA 91TLsmyR5R7+kwJtRnGx48Q8Q9WDS+OdUMlFyaqBmnI1e+jfleg1ODK9/Uv0AphzXaez Xrcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:in-reply-to:subject :cc:to:from:user-agent:references:dkim-signature; bh=rYUXhS9nmk3eTNe8wLnZ+WQcYvQdegO6qz5s7o7uukc=; b=EFgczVE/T6ZijEKeOcle2+GMpVj7cHi79asBfleskxYJiEJWNGWnNLXZe6j3mnYJLs CwV6cM8kLa0HDQ0r8B4jzBELJmqKRB2JMHVw6EhVW55ulnvCYBJHncYG4RciyPhtvExy 3P7Ks2rM8Am0ZCIBoi0SXQA6igLnoMh3TD22al+efdM5q9Vj9guPg9b1xf/FBU6brF8g K+cacDPP3nxaNIZFRKKsIbhXmQUfk2xIPjhYSK+xFBnFvPsTuqoFlMIALfIerEkfG6Zb kvG1ZrRb/22tRU35XjGQ2PdfS5AzKW9kjW4chZ1604MYGlBsNTjV+S6K6i2T48wiRfK/ luIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sSZ3Q+zo; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y7si5302283ila.59.2021.07.27.22.56.38; Tue, 27 Jul 2021 22:56:49 -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=@kernel.org header.s=k20201202 header.b=sSZ3Q+zo; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233574AbhG1Fxz (ORCPT + 99 others); Wed, 28 Jul 2021 01:53:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:51728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229814AbhG1Fxy (ORCPT ); Wed, 28 Jul 2021 01:53:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 28F2960F91; Wed, 28 Jul 2021 05:53:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627451633; bh=OLVO5xJIhwHiX7AgTyp2l1mNWBfyWHe5OjPiCsJ891k=; h=References:From:To:Cc:Subject:In-reply-to:Date:From; b=sSZ3Q+zosGSU3L8V950HNs4eIgUXdoiCEfbxfpuvRyspPyZ1jCdh/sljW36z3tT0m pTNMGkpLOuT79IrXDEvQy6/dPShiNsJiIgKbUrvURm8YoQP7+ldi9xlNTXZn0XE35m Ak/PFwJMn8GZVOiXyJmpwfVc8+aaV/tfg+wNyPv3kTBTdQBDe6bLqgvXLuD1CFmh7m GV4+qFcs3uHdaBlq6HDIatibTa++J0A7CHDaqR7AXPYD+mwC9eyt6BCnZGTR9tBX5K S/jgHFwDP10Jb6Mu/YLfT7qStpTO2Byaejv/51GD8L1IneifQjW8Esg7wBhZnATYlB G0HUf0LUwRWMA== References: <1620716636-12422-1-git-send-email-wcheng@codeaurora.org> <87tun9g01v.fsf@kernel.org> <2675db9e-0cab-06b5-2986-0b4456a1f040@codeaurora.org> <5156238d-c1d8-a0d3-47af-8b52467fd071@codeaurora.org> <87v954xjoz.fsf@kernel.org> <3c55dd4f-5ebd-3730-7428-cb15235465a7@codeaurora.org> User-agent: mu4e 1.4.15; emacs 27.2 From: Felipe Balbi To: Wesley Cheng Cc: gregkh@linuxfoundation.org, peter.chen@kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, jackp@codeaurora.org Subject: Re: [PATCH v2] usb: dwc3: gadget: Replace list_for_each_entry_safe() if using giveback In-reply-to: <3c55dd4f-5ebd-3730-7428-cb15235465a7@codeaurora.org> Date: Wed, 28 Jul 2021 08:53:49 +0300 Message-ID: <87pmv3t24y.fsf@kernel.org> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Wesley, Wesley Cheng writes: >>>>> Sorry for the late response. So I tried with a list_replace_init() to >>>>> within the list_for_each_entry_safe() loop to update tmp w/ the >>>>> cancelled_list list head, but the issue was still observed. This is >>>>> because we can't replace the reference the loop already has stored in >>>>> tmp, which is simply updated as the current item on the next iteration. >>>>> >>>>> I believe this is what you were trying to achieve? >>>>> >>>> Was wondering if you had any further inputs on this change? As >>>> mentioned, I tried a few things with list_replace_init(), which did not >>>> work. >>>> >>> >>> Sorry for the ping. Is this change OK to add as is? We've been running >>> into this instance pretty frequently during our testing, so just wanted >>> to close on the proper changes being merged upstream. >> >> The idea is this: >> >> struct list_head local; >> >> spin_lock_irq(&lock); >> list_replace_init(&dwc->cancelled_list, &local); >> spin_unlock_irq(&lock); >> >> list_for_each_entry_safe(req, tmp, &local, list) { >> /* ... */ >> } >> >> It looks to me this should work fine, no? You can also follow what >> drivers/usb/core/hcd.c is doing in usb_giveback_urb_bh() and restarting >> if dwc->cancelled_list is not empty after list_for_each_entry_safe(). >> >> Can you give that one a shot? >> > > Great, thanks for this suggestion! Now I understand what you were > referring to. I gave this a try and it works well. Will prepare a > change to replace both places with list_replace_init() this is great news :-) Thanks for trying it out -- balbi