Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp743175img; Wed, 20 Mar 2019 09:56:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqyc3fwEpSx58jRx6Lzc10cgPt5pjQxJ3qS+soeB0G8FbjqVlj/aP78c49Ej/vdYDSJLp8WK X-Received: by 2002:a62:fb04:: with SMTP id x4mr8628658pfm.83.1553100990791; Wed, 20 Mar 2019 09:56:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553100990; cv=none; d=google.com; s=arc-20160816; b=SSej69eqF9c6ktwWOh6nH0/Is9fchAwzZYeiKi0eODTg7Sdw3cxwh6oh9mGtOO+zOg 2d3o/vcMfWUkwiZWJdgWqIp3cUPVfqei6KyVUx+tlX67dE3cwG4rKh0dfRzt1el+GX6Y PEq15oNIadp76GhGiufHxhrI/kGocnG41hc2sQc1KRNBcNGtpZx7RUK1zgmKnXtdd8tw ofp0y/uRJXF+Ls9Ri6RLUMWM5anJNegTFBudh1hh3MIPE6Br+jCg6c4rIdN9TtWK3RW6 7orDeRIJa/eSeeKAKsA8zuitHb9hORwruXuABOX7OhYaaasxSu4ZcedDVv4n5pbqLam8 oeag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=RTDjI+RbBB/APbmiNr6t1AVweAu5f4OB7m4SUCNMIm8=; b=bwb25yPrRRmey680iRjSsljybZkTvGY3yTX15rHFQi0M7M51tzo8dm+P4/g3BGPowR 28drNPCkFdvcYoUhsu5wzD6AnzuBjk5T/0OJed9e59+3BbJxz1prPR3zLvUg8Ovw0ni8 bbqHnoAQWrRczukEyG9IPnZjcEaURWfcGKUEPu1QQQ2daij31rIJeA307qI1hjROqfZM T7tO5k9S/epjaAlMpHp9pKQNpAsO4dI42Ngt3M1AEpLi4ubfmjerQbJUmtylCD7vKEQO S4loMdFxKQJPkSA+fXtjI7HLIPSxjWUJFMoyyZ9vdLDpHx8daArVYbYa/rMof6XxYCD0 UB6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LlnsAh4F; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f10si1979111pgp.528.2019.03.20.09.56.15; Wed, 20 Mar 2019 09:56:30 -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; dkim=pass header.i=@linaro.org header.s=google header.b=LlnsAh4F; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726982AbfCTQzg (ORCPT + 99 others); Wed, 20 Mar 2019 12:55:36 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:35622 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726049AbfCTQzf (ORCPT ); Wed, 20 Mar 2019 12:55:35 -0400 Received: by mail-wm1-f68.google.com with SMTP id y197so2821035wmd.0 for ; Wed, 20 Mar 2019 09:55:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RTDjI+RbBB/APbmiNr6t1AVweAu5f4OB7m4SUCNMIm8=; b=LlnsAh4FOgQPAo5yzjVr2zzx+xuQcnJN5/2dLYrSyoWEfRty6NBCEEfpvsERueQzY4 FzXz+z0zK3JF/f4d0S7zyYx8eX2oh2Q9WVUrIHsvYHIfyJwzv7EAlYEOy3YtK+aWHA6U 4sKOq6FGMYtG/eWdxhsgVSd9eSGTPFUN5pSkeM6WftbYltTzj2nHskDw5yH8CKlaPK9z a1cnslJ9sGj00zGZQlm++Vyyz1WhiEJnBhhV1YbkJFUQwqwlB4jK3VxSoaCbHXBfogsy LUiWmpGGxrySMusNCSA5kyYDTB4jLVFFVP9YJfl9TsSPl1wn2zZR/p4uLVgbOXS8O++u rTDQ== 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; bh=RTDjI+RbBB/APbmiNr6t1AVweAu5f4OB7m4SUCNMIm8=; b=GrSeHS8sY9u95Hl+4sXcoTqbR9oYCqs4xqBR5CFQ6d8y+NiQv6gHUTuPQ2HSGcd0Ke M9KgXUc6TCDSeO6O4Aq9RvFHpPg2zSLMkNbBE0rcIn2qSk3Df8y2X3WYfLPWBWhz0OmM drqjTVAfP4cu+RLFi5zPfvmU0634WhkDuMvWkHp66KtOGqhXBU3iKOAaMH9leEvYoM5g fHH2G0XRBvjbw8X636q76E7qJFTV1aIJQ2iDOkQdHHXDCrEZx4geDxs5ozZgCBk5J2tB IlPI4GwuOATVd33HBuxV0ZWvUiFW9Rhu/71L039m3JSfjWqAGX1RveRSwwBJR/jPl7Ie qyzw== X-Gm-Message-State: APjAAAWlZqiTSXEIu9RzE8LbmK11ese+hlsOO992iSHYTLGFvsm/OkAZ 1EtDWFsgGffWoP12lHhjo2kqeWNOf1I+n7emNi4+DQ== X-Received: by 2002:a1c:4e19:: with SMTP id g25mr9466859wmh.9.1553100934116; Wed, 20 Mar 2019 09:55:34 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: John Stultz Date: Wed, 20 Mar 2019 09:55:22 -0700 Message-ID: Subject: Re: [PATCH V2] usb: gadget: f_fs: don't free buffer prematurely To: Alan Stern Cc: fei.yang@intel.com, Felipe Balbi , Greg KH , andrzej.p@collabora.com, Vincent Pelletier , Linux USB List , lkml , Josh Gao , Alistair Strachan , Shen Jing Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 20, 2019 at 9:52 AM Alan Stern wrote: > > On Wed, 20 Mar 2019, John Stultz wrote: > > > Hey Fei, > > So while this patch does resolve the issues I was seeing with > > mainline kernels and recent changes to adbd, Josh pointed out that it > > wouldn't resolve the issues I was seeing with older kernels which is > > slightly different (but still related to aio usage). > > > > On the older kernels I'm hitting scheduling while atomic on reboot, > > which seems to be due to ffs_aio_cancel() taking a spinlock then > > calling usb_ep_dequeue() which might sleep. > > > > It seems a fix for this was tried earlier with d52e4d0c0c428 ("usb: > > gadget: ffs: Fix BUG when userland exits with submitted AIO > > transfers") which was then reverted by a9c859033f6e. > > > > Elsewhere it seems the ffs driver takes effort to drop any locks > > before calling usb_ep_dequeue(), so this seems like that should be > > addressed, but it also seems like recent change to the dwc3 driver has > > been made to avoid sleeping in that path (see fec9095bdef4 ("usb: > > dwc3: gadget: remove wait_end_transfer")), which may be why I'm not > > seeing the problem with mainline (and your patch here, of coarse). > > But that also doesn't clarify if its still a potential issue w/ > > non-dwc3 platforms. > > > > So for older kernels, do you have a suggestion of which approach is > > advised? Does usb_ep_dequeue need to avoid sleeping or do we need to > > rework the ffs_aio_cancel logic? > > usb_ep_dequeue can be called in interrupt context, meaning it is never > allowed to sleep. This is mentioned in the kerneldoc: Thanks for the clarification! Sorry I didn't see the kernel doc! -john