Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp158811img; Wed, 20 Mar 2019 16:44:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXji9/cexr319yN0Dcu7TtkO4nB+u3ZYB/Kcb1Mgbxj75t6hzqsU40M9lB5OUSZVCVw9Qv X-Received: by 2002:a62:41dc:: with SMTP id g89mr418764pfd.109.1553125452345; Wed, 20 Mar 2019 16:44:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553125452; cv=none; d=google.com; s=arc-20160816; b=LPTQhrAnzETN2BOl11B6rZST94rpRxjuVqseaK1WTKiW0b3gQuwvL4UGMZpgNXjo/z yvpZFpaFa5Zl4v32mQfkLjHpcpZKTLfRJ7CtCz0gn7NvRqLrEawMYJQD+OZwbd5eyDqr Fo7xQWYivKsmKd/4Q3LRFEcYmDssr9YjAj8d1CIonEK3fUk8eePTla2DbjKs4XogsqkA B3gkDvF64IR6yL6k6GP6Dp42j+aDxBnbFwehteWdbUmj1WV0uDh2Z7dBmdrvrbfBT1r8 rHOOGUGTfH+aoe7PO+wacZLa2vCq+GtYgG+9QpbrOzVZUA3IpVjEIn9yCSYTB75RhFVU Js9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Yq9DaKQ00cZ1pNB/118bquMfFjN67tRouuMKGnaosxo=; b=n2+cNcVLeckbveydESMGLinP80+bipapXnPp0zPZ6huUdYrKtj/R8CHilxL865XZKz AcfqAaGYsahQKKSh+YDmxVINZwO2axxlYuJgcSPjGfFcIqIYjx0XJlw6QbfCE1jtVmIm 6KuGQoMD13WvzaLyKJYGQEd0KwJk2XEFnKYvj9ateMUxYhHkRmg44YUAmc5UAQbIqy8W xD4EjOznysDdfA9U7pDalQYQVhl/P5z2EpBQitV++BZhqT+rrwsW+D2y/ZCMRIWhjFyp DU9ArjTWIXLp2N4VvidM1lSBvLnoij5CB78mhsRJNUAJkuIw2/BJHK1QwUv0UCIjkzZ5 zj7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="g/+3+Sio"; 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 g59si3004036plb.281.2019.03.20.16.43.56; Wed, 20 Mar 2019 16:44:12 -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="g/+3+Sio"; 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 S1727478AbfCTXnE (ORCPT + 99 others); Wed, 20 Mar 2019 19:43:04 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:53178 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726753AbfCTXnD (ORCPT ); Wed, 20 Mar 2019 19:43:03 -0400 Received: by mail-wm1-f67.google.com with SMTP id a184so950756wma.2 for ; Wed, 20 Mar 2019 16:43:02 -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:content-transfer-encoding; bh=Yq9DaKQ00cZ1pNB/118bquMfFjN67tRouuMKGnaosxo=; b=g/+3+SiohpvgLWqF76bydKQh5mu3EafovnZgDZ7H6/rShY7jkXb92VfHqPorpwnnyp E5bqm7lBlCiuMSNGgqtLTnYv8+ZkQ3eroyokx08VONoxlJnTd0fqAhhUkMs/BrEYTfki HdiBuMQdrCbPO0jsvDzOqAPk93XqIrdqH+yl2Ii0Yz1BBNBilfyZAivga7sR5AS2YnvJ 0remWZ0gAnTstQl4/jSZCTl2WQef3gSBoiTqztTMb4sVFhTpejS9OoJyoLSNWNEY0aEP EiP/j76a9E7HxcTigiDBoLEzp6TZUEHsElILgMJQho+boyzAYP63Lrawb7C+ccvAFng7 ZrSg== 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=Yq9DaKQ00cZ1pNB/118bquMfFjN67tRouuMKGnaosxo=; b=fmHSy56B5v8MZScFqAc3WwGmTvRkY7ou8d3vyVDZ769LmK6GL+DkFw5OAALsmqOama T2tH4BuONIj6zzu4jNHHkduW2vzMtXDAVtZXwy5Pqvzj6mEdnaDbWPneikhYzSy1PGUc wQGdtio235T0C8xftznBVupFw9RQug2EMRLuT8NtWH/YcZR1Bxx64cgxhcMqeRj1HuZr dCYkvGJW++vJWiIO9MG717pShxk1f69So4/DQl/NteC04ReFDmsP1PLHsX2ErXGBq3yf 5CXf86S6Qe+ivuMiBKqMllMkt0ZbupSLwwVjQpp7uym0U+Zl0ErFQ0fqZoXs2ERT4Ww0 d6Cg== X-Gm-Message-State: APjAAAXIpi7yFweGEtsZavaXmd1PIzhgIvXKDrghVAQ4gigF5TLV30CR a7q3gwjfbHWhQ2QDsesaUbt2tgp5tI5EUC13bEfqCQ== X-Received: by 2002:a1c:9691:: with SMTP id y139mr467757wmd.64.1553125381390; Wed, 20 Mar 2019 16:43:01 -0700 (PDT) MIME-Version: 1.0 References: <1553059940-127038-1-git-send-email-fei.yang@intel.com> <02E7334B1630744CBDC55DA8586225837F7FB935@ORSMSX102.amr.corp.intel.com> In-Reply-To: <02E7334B1630744CBDC55DA8586225837F7FB935@ORSMSX102.amr.corp.intel.com> From: John Stultz Date: Wed, 20 Mar 2019 16:42:48 -0700 Message-ID: Subject: Re: [PATCH V2] usb: gadget: f_fs: don't free buffer prematurely To: "Yang, Fei" Cc: Felipe Balbi , Greg KH , "andrzej.p@collabora.com" , Vincent Pelletier , Linux USB List , lkml , Josh Gao , Alistair Strachan , "Shen, JingX" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 4:28 PM Yang, Fei 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, whi= ch seems to be due to ffs_aio_cancel() taking a spinlock then calling usb_e= p_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 d= wc3 driver has been made to avoid sleeping > > in that path (see fec9095bdef4 ("usb: dwc3: gadget: remove wait_end_tra= nsfer")), which may be why I'm not seeing > > the problem with mainline (and your patch here, of coarse). But that al= so 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 adv= ised? Does usb_ep_dequeue need to avoid > > sleeping or do we need to rework the ffs_aio_cancel logic? > > Are you seeing this issue with Android? When running adb reboot? > I have tried 4.19 and 4.9 kernel with Android P-dessert on one of the Int= el platforms, but no luck on reproducing the issue. You probably need to be running AOSP/master to trigger this. The changes which uncovered this landed just last week. > I will get back to you if I could reproduce the issue. I'm afraid I won= =E2=80=99t be able to do much by just looking at the code. So as discussed in further mails, the main issue seems to be the dwc3 code was sleeping in its ep_dequeue logic, which isn't safe as ffs_aio_cancel calls it while holding a spinlock. Upstream the dw3c driver has been fixed, but -stable kernels still have the issue. thanks -john