Received: by 2002:ac8:156:0:b0:3e0:cd10:60c8 with SMTP id f22csp2650596qtg; Tue, 4 Apr 2023 05:38:20 -0700 (PDT) X-Google-Smtp-Source: AKy350ZxyUEN7iZnQVAdHa+EteliqnSulmG9wyIFfYRrM1ifKhFV7bVfMm5i3F7KOh+/iKn7zjFg X-Received: by 2002:aa7:9a5c:0:b0:62d:d045:386 with SMTP id x28-20020aa79a5c000000b0062dd0450386mr2195341pfj.18.1680611899647; Tue, 04 Apr 2023 05:38:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680611899; cv=none; d=google.com; s=arc-20160816; b=LEF4ROocpxHwhIGE9oqPRp+pi8+IHou1Cw0dpbNt211WUsb6URiq4JGfLrlFmJKuEv sTx367SAv0dYBvjwImoMiZ87THIv+/gfz5Yyi0oNwFacvFjWdwiwEuuK8ZBWH+QEcZp/ nAO2eYGwoHXRhBHnOhh5dRjcfX9gZhxWOghSOlLChxiCyZrfFIB9YkoEcvM2vYrJCpwK F7BgbRQ2u8F8zqUWGoh+h55DqWlUccFAa8Y0XTKAcVEexT2wEAMAWVC8tJJUHugzDKh6 EXyAaiNQ40f4Q1N9EEUzcGhDfoQnSopKD9u4jzVALHzVwL3BaFHMmwFCwJ9kXXu0sFzK X7OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=6LPisD1g8fF1PkVibNy64HeK9w+XONYQHU5C+h/IWUs=; b=qCuBIZWhmETnwDvAzNOS+6GEZJHaZbnJuId4g+tHZlQ8C+gLXjDVQnbnAkuNqwhYdp 2z8Hhs/ida9LOXnloQtg1aEvwW6kY93yMec/nJFIQKEs0hxXb2f3jQjWjLKYJ/dLW273 dh0RHSjvi9UPld/B2vbcD45eNqitm4x+1blao3oUQ+BraX18FWNEvEJGvxxrgcgS5BIV 5uWPcXh8TYXqXpIFSANVoER5bcOR1+14LsR3+ZBTKz+X0lkZtjO9KHRuseGAXWD8sXLi 2lqD1MQhyC4RlzckSFlZbNPLdDt5OpoGReFAVKN9ZbngdxUsmFhhjThsPU2xC8+4L0zx ccLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pfCnm9UE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l5-20020a622505000000b00626214b2915si10460696pfl.219.2023.04.04.05.38.05; Tue, 04 Apr 2023 05:38:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pfCnm9UE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234931AbjDDMhc (ORCPT + 99 others); Tue, 4 Apr 2023 08:37:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234864AbjDDMhZ (ORCPT ); Tue, 4 Apr 2023 08:37:25 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2D3A26A2; Tue, 4 Apr 2023 05:36:51 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id hg25-20020a05600c539900b003f05a99a841so2042323wmb.3; Tue, 04 Apr 2023 05:36:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680611802; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=6LPisD1g8fF1PkVibNy64HeK9w+XONYQHU5C+h/IWUs=; b=pfCnm9UEDOlfMEbjo6usXGtg4l+s5STT98F4BiLoN8XQVdAf3C2GoPM4x2RXhdgVXB qZxcSzJvG7pP3cABy9VxDqLM4J/f6yUrOcQRNYpzXBwDjRdJFma2QU1dFU55rfP6MLYQ j48s92BT3GUBts0IZ0gunLn8hHXDV86ihYISRURREjjKg9t1PSqgtOjMA+gK+nx3DqZ1 J/eINiXfmne5crYwq8FXfChocyhZ8ZYxDC31T7Nhq8Hu8JgsKDerqjHmfiazPq/kJKJD pKvsvrGv8e3rofX8V3S3z4CFuXFHhaNHtT4H5vCmwVhBi9A4aWfWj4OmbCABdl45vKAW /PWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680611802; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6LPisD1g8fF1PkVibNy64HeK9w+XONYQHU5C+h/IWUs=; b=xoZRmtq/QNr+g04h8ACfd/oR+5V49fIqDW6jGMgL44RljK9CPaG+BJwyAqplWMK6nw 6rNVpT2th2i8ncTBp9LkB0DXnNXvD5+/Wcr94bC/zNMvxbtsZ7XCc7IIj2/UG23bxrum hH7vUa8oehj5zTWeEQpOlfqAyEi0GQbMKsdr+hBWGwu+lehym4pP8uAjTGVkBOoksiUm yplGEcvkCaBEz+d5hUljimBzFW6ZiO8jgvVFmndQnmDCEKrmF7/itQF3zv8CDqBUghIx 5gjJucLDiBcu9L0zn6sQMmHQXQ2mqA7UYspWP73h0UMefJY+PCgTb53RARtgTrxl8RE9 dTIw== X-Gm-Message-State: AAQBX9f3tX9KOZkiQVqm1umSbREX6mOhOqm/y+BalsJnN1j9WcqwUwwy T0qye6NwEPr8epeEYdxSrEfCgA5c51w= X-Received: by 2002:a7b:c41a:0:b0:3f0:4428:94fa with SMTP id k26-20020a7bc41a000000b003f0442894famr2097627wmi.26.1680611801910; Tue, 04 Apr 2023 05:36:41 -0700 (PDT) Received: from orome (p200300e41f1c0800f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f1c:800:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id u17-20020a7bcb11000000b003ef5db16176sm15150553wmj.32.2023.04.04.05.36.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 05:36:41 -0700 (PDT) Date: Tue, 4 Apr 2023 14:36:39 +0200 From: Thierry Reding To: Haotien Hsu Cc: Mathias Nyman , Greg Kroah-Hartman , Jonathan Hunter , Philipp Zabel , linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, JC Kuo , Wayne Chang Subject: Re: [PATCH v5] usb: xhci: tegra: fix sleep in atomic call Message-ID: References: <20230327095548.1599470-1-haotienh@nvidia.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="qnhHWXaap8DkTg8Q" Content-Disposition: inline In-Reply-To: <20230327095548.1599470-1-haotienh@nvidia.com> User-Agent: Mutt/2.2.10 (2023-03-25) X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 --qnhHWXaap8DkTg8Q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Mar 27, 2023 at 05:55:48PM +0800, Haotien Hsu wrote: > From: Wayne Chang >=20 > When we set the dual-role port to Host mode, we observed the following > splat: > [ 167.057718] BUG: sleeping function called from invalid context at > include/linux/sched/mm.h:229 > [ 167.057872] Workqueue: events tegra_xusb_usb_phy_work > [ 167.057954] Call trace: > [ 167.057962] dump_backtrace+0x0/0x210 > [ 167.057996] show_stack+0x30/0x50 > [ 167.058020] dump_stack_lvl+0x64/0x84 > [ 167.058065] dump_stack+0x14/0x34 > [ 167.058100] __might_resched+0x144/0x180 > [ 167.058140] __might_sleep+0x64/0xd0 > [ 167.058171] slab_pre_alloc_hook.constprop.0+0xa8/0x110 > [ 167.058202] __kmalloc_track_caller+0x74/0x2b0 > [ 167.058233] kvasprintf+0xa4/0x190 > [ 167.058261] kasprintf+0x58/0x90 > [ 167.058285] tegra_xusb_find_port_node.isra.0+0x58/0xd0 > [ 167.058334] tegra_xusb_find_port+0x38/0xa0 > [ 167.058380] tegra_xusb_padctl_get_usb3_companion+0x38/0xd0 > [ 167.058430] tegra_xhci_id_notify+0x8c/0x1e0 > [ 167.058473] notifier_call_chain+0x88/0x100 > [ 167.058506] atomic_notifier_call_chain+0x44/0x70 > [ 167.058537] tegra_xusb_usb_phy_work+0x60/0xd0 > [ 167.058581] process_one_work+0x1dc/0x4c0 > [ 167.058618] worker_thread+0x54/0x410 > [ 167.058650] kthread+0x188/0x1b0 > [ 167.058672] ret_from_fork+0x10/0x20 >=20 > The function tegra_xusb_padctl_get_usb3_companion eventually calls > tegra_xusb_find_port and this in turn calls kasprintf which might sleep > and so cannot be called from an atomic context. >=20 > Fix this by moving the call to tegra_xusb_padctl_get_usb3_companion to > the tegra_xhci_id_work function where it is really needed. >=20 > Fixes: f836e7843036 ("usb: xhci-tegra: Add OTG support") > Cc: stable@vger.kernel.org > Signed-off-by: Wayne Chang > Signed-off-by: Haotien Hsu > --- > V4 -> V5: Update commit message and code layout with 100 columns > V3 -> V4: Remove copyright change from this patch > V2 -> V3: Add version information > V1 -> V2: Add "Fixes" and "Cc:" lines and update copyright years > --- > drivers/usb/host/xhci-tegra.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) Acked-by: Thierry Reding --qnhHWXaap8DkTg8Q Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAmQsGdUACgkQ3SOs138+ s6Gu2RAAmzYhi+6Q+40Z2gSV1KR50Yz0lE7E1BcmUNQNLFcDrfZYvKgXErcaBXIb lLOz4ZmWwVCy5t7CsqVwn8zJ8XZvUXQPjp4+j1iUdJOf4yHAU2ZTaL86bugiBTm1 /T/Ing42b1bjMsGH3ndJHhzHp29zV9BFYKZy/syVikZqwyUlRHv/cn72OZ5jXnPz 3M9RNERfc/Telp0dte3FgZKus/4TxzOx0kkw2IqpePajvf2kWYcUnDul1AIgN60A 5tZbp40usNGqM//xZ/IdAlnMMBwcaZf4UqihqoNOxj8EuC9b/jFwO0f0pUHNy6ST tI6X2aiSq0OSfLlkim0ChcLY+G0IcHZ0cEbXuVVQHFkub9P7C7IsTp5SPmI1M3ui 5kVMZXlthTvaAP/ccj28euHhPlgE34V3paEv/z5eqLatByTfprVrrFfQ7qe3jSCF N23ZKSos+kDFVImVZFYzbknyExXQA5Zs87O/cHZNLjLho59X41C9pTLtT2J4enF/ leQu8wPU3UdCDTGwfWQji27to1ya5ZFvL1u3+Ilk8PGQZbkY9dkbjvFn3c2XWpYQ fR14w1p+ls7+YJEbNcyN+LvjGKWQAZzujhdoHU+VoBIMnQ8iCXWFGm6QdrCiqOab vwoKdJOMYzlvhOrVsqfYeAw4wjCjoYO8XrbdgHgy95v6kn10rpk= =sHhN -----END PGP SIGNATURE----- --qnhHWXaap8DkTg8Q--