From patchwork Fri Jun 28 18:24:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 168120 Delivered-To: patches@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4020527ilk; Fri, 28 Jun 2019 11:24:18 -0700 (PDT) X-Received: by 2002:a17:90a:30cf:: with SMTP id h73mr15059803pjb.42.1561746257980; Fri, 28 Jun 2019 11:24:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561746257; cv=none; d=google.com; s=arc-20160816; b=AOJdAQJPxG8YymeCE3xq5kQDmCD0+9yVPQ4w1Na7rDoFlYfO/11XSaa9Ce1Rs9xkl1 8qfJKV9xwroCaLjwAfm4a7D2JIW68Xsjhqe8FmrWWD3hxY1QgETKzIwFOILIjV3LV6CP zBEPaXgYfOc9KzMoLKntL6iP7sglEb678OOJBYbOF9rrTTy8PsY8eEoEjvJfNL8pkx/k o33ckO/u3OPnKCeI8aPbE3VTvAVTVTImu/FWbrP2Vm7f1fKwFFO8MulYgahohoeM+DgZ VU0PDGAOg5MZBna0sfgL81P+TcU/69piY0tqGJsc5UpaelhNudZn3tjdHejo830V5eVg TV8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=Lui3xxG+jUxHBZj//7cb1eS4egCiB5B/SX3zID9r9OU=; b=y33FIU/AAMAKfnVjmGCGE+YFOGNK+GY5eryUnmWtkIAHfZN2OrFPSc6uVwa6ET5weE yrGc/VhbS61UaCkvHNcB+Zp/oFpirzbe4JQK0cTe5T37LjEpn3IbHATvKjrTX2rXFu9y FiCjMld4E6x1RamnKclcy5re8LFFmL4RvV3QuWgGVHAtYnKP3iDft443MQgdqGCXeAMN w5tKcREvJORgyNczIHDHmQ1RReVIC6s00L2ix9JKBgDMZ3A7JLLC2pGTiPq5DMzXMdIP NNohjVqzx/T8D24jcgIlwb9B6kPfxEa6O6u+HOXE2Z43bSa8rA7K/hNx5gVtcRYzFEin X9bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iYx+PZHP; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id v10sor3550895plg.28.2019.06.28.11.24.17 for (Google Transport Security); Fri, 28 Jun 2019 11:24:17 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iYx+PZHP; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=Lui3xxG+jUxHBZj//7cb1eS4egCiB5B/SX3zID9r9OU=; b=iYx+PZHPfVmdW5etNZ+RS83FEtBUrZ7pZMN9PI2pP6nCZR+REurZv8JdDysfhHYwXA q4m+qa4gvoBEjQ9f9OFDuAmDXO+iOdAr50cRe1Y/8HZSBTf7rws2Wk1wf1BOOJGip1SP Jn9z4jqAUaXUeQhJ/k1RSmEetn4Y9stjBOM6LDqWATPf1czqS0Q4vDNZkGfRZ4/s8SaQ etMHT5N9J+T/7xN4NFZumbOpp8BcKD1E2YlVU7vZL6bO6r+1+mvPlsWcVCYctZ0ES/jG ZVLciF5eArnbAR2ramfq30d3VYF1mnXyUBHDXPkBFMTvdQl9TxFpRlIfQDnv0olBSTc0 GQxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Lui3xxG+jUxHBZj//7cb1eS4egCiB5B/SX3zID9r9OU=; b=N+75FRXE7JWhfOOYYGh2k5PzXa/lFJlqqSVQ0xX82ru/T6LMNAiuPIGPhuxJitOaPb IuViWKvxbmnY2CjAqXzLjgmxBx3UsStxQQJAzBGu6lgCrns1dh1YN8735SkX8pfvZLcm ddBy0EAvcFhO5AXEoSXyC4/VIzI7vDZSEIjm/Ynqx3eq2N2UYBsjBAcrx47ouKFwjSQi yic3xFCPIltw65Yjzhf21HoCxxVjphIuD1E4x3JU8CJ6vnZGK/agJHgMXl/QM7fbgzdN RLvUFVI4sNnpMyPXaQV1yiIaGy6xGfF69b9Ot3ZmV9OW+Hd/rNGe/NwX8DVh43h8AS/6 BhFg== X-Gm-Message-State: APjAAAVfquuhEEUFvhRm1IEGQfqwQCtZnQVPF/AGBiBgX5vghfix1SBL 1pkBfQh3Gi6TOZEAW8dzP/T1CsxW X-Google-Smtp-Source: APXvYqxS8O+2ugxIClJkG+iQuKCU0kL/+QCqeqEOCq1YVQiab6kk18FcwGCfKCfCMj3/CDrnfa235A== X-Received: by 2002:a17:902:2be8:: with SMTP id l95mr12325680plb.231.1561746257338; Fri, 28 Jun 2019 11:24:17 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id s15sm2916223pfd.183.2019.06.28.11.24.15 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 28 Jun 2019 11:24:16 -0700 (PDT) From: John Stultz To: stable@vger.kernel.org Cc: John Stultz , Fei Yang , Sam Protsenko , Felipe Balbi , Jack Pham , linux-usb@vger.kernel.org Subject: [PATCH 4.19.y v2 0/9] Fix scheduling while atomic in dwc3_gadget_ep_dequeue Date: Fri, 28 Jun 2019 18:24:04 +0000 Message-Id: <20190628182413.33225-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 With recent changes in AOSP, adb is using asynchronous io, which causes the following crash usually on a reboot: [ 184.278302] BUG: scheduling while atomic: ksoftirqd/0/9/0x00000104 [ 184.284617] Modules linked in: wl18xx wlcore snd_soc_hdmi_codec wlcore_sdio tcpci_rt1711h tcpci tcpm typec adv7511 cec dwc3 phy_hi3660_usb3 snd_soc_simple_card snd_soc_a [ 184.316034] Preemption disabled at: [ 184.316072] [] __do_softirq+0x64/0x398 [ 184.324953] CPU: 0 PID: 9 Comm: ksoftirqd/0 Tainted: G S 4.19.43-00669-g8e4970572c43-dirty #356 [ 184.334963] Hardware name: HiKey960 (DT) [ 184.338892] Call trace: [ 184.341352] dump_backtrace+0x0/0x158 [ 184.345025] show_stack+0x14/0x20 [ 184.348355] dump_stack+0x80/0xa4 [ 184.351685] __schedule_bug+0x6c/0xc0 [ 184.355363] __schedule+0x64c/0x978 [ 184.358863] schedule+0x2c/0x90 [ 184.362053] dwc3_gadget_ep_dequeue+0x274/0x388 [dwc3] [ 184.367210] usb_ep_dequeue+0x24/0xf8 [ 184.370884] ffs_aio_cancel+0x3c/0x80 [ 184.374561] free_ioctx_users+0x40/0x148 [ 184.378500] percpu_ref_switch_to_atomic_rcu+0x180/0x1c0 [ 184.383830] rcu_process_callbacks+0x24c/0x5d8 [ 184.388283] __do_softirq+0x13c/0x398 [ 184.391959] run_ksoftirqd+0x3c/0x48 [ 184.395549] smpboot_thread_fn+0x220/0x288 [ 184.399660] kthread+0x12c/0x130 [ 184.402901] ret_from_fork+0x10/0x1c This happens as usb_ep_dequeue can be called in interrupt context, and dwc3_gadget_ep_dequeue() then calls wait_event_lock_irq() which can sleep. Upstream kernels are not affected due to the change fec9095bdef4 ("dwc3: gadget: remove wait_end_transfer") which removes the wait_even_lock_irq code. Unfortunately that change has a number of dependencies, which I'm submitting here. Also, to match upstream, in this series I've reverted one change that was backported to -stable, to replace it with the cherry-picked upstream commit (as the dependencies are now there) This issue also affects 4.14,4.9 and I believe 4.4 kernels, however I don't know how to best backport this functionality that far back. Help from the maintainers would be very much appreciated! New in v2: * Reordered the patchset to put the revert patch first, which avoids any bisection build issues. (Thanks to Jack Pham for the suggestion!) Feedback and comments would be welcome! thanks -john Cc: Fei Yang Cc: Sam Protsenko Cc: Felipe Balbi Cc: Jack Pham Cc: linux-usb@vger.kernel.org Cc: stable@vger.kernel.org # 4.19.y Felipe Balbi (7): usb: dwc3: gadget: combine unaligned and zero flags usb: dwc3: gadget: track number of TRBs per request usb: dwc3: gadget: use num_trbs when skipping TRBs on ->dequeue() usb: dwc3: gadget: extract dwc3_gadget_ep_skip_trbs() usb: dwc3: gadget: introduce cancelled_list usb: dwc3: gadget: move requests to cancelled_list usb: dwc3: gadget: remove wait_end_transfer Jack Pham (1): usb: dwc3: gadget: Clear req->needs_extra_trb flag on cleanup John Stultz (1): Revert "usb: dwc3: gadget: Clear req->needs_extra_trb flag on cleanup" drivers/usb/dwc3/core.h | 15 ++-- drivers/usb/dwc3/gadget.c | 158 +++++++++++++------------------------- drivers/usb/dwc3/gadget.h | 15 ++++ 3 files changed, 75 insertions(+), 113 deletions(-) -- 2.17.1