Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp512818img; Mon, 18 Mar 2019 08:07:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkUnUyX2ME2+P6/NQ8dWZ7u70minAvaKkHuy+po67wGms9rRmHQPUDLX2IJYvNYGsBPfjE X-Received: by 2002:a63:460a:: with SMTP id t10mr17622699pga.354.1552921638675; Mon, 18 Mar 2019 08:07:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552921638; cv=none; d=google.com; s=arc-20160816; b=R69hSmBzBSc3hIVGaQVthMhj1c72nVmwCUyLyMojT7z6G714U8sPe56eFHwfgnRr1k hQMnHv4tY8qDuaY13rd2n66VBVxpFmxvdKCAEF9czdUccyPfELwpjwBEe2ZLe8+qiryw 0S2hlC7e7c8wKBghieJurglxDvyjlpxUQkza9pz7Bc64yHbLFTf/s70stf2M5bxZ8DyT Xefzxj3H/raL6Xh46e/3Vwl9zADQ3ygmxcj3+hBas5W3f3nTXWsq7Gh+QXjDvCU1a7Kq 1aa0XvK/VT3XaErx/6ERb4nZ3mdiwmehQJ2sVfdLdDd2eb8292Y9bye5NFS2WaWwv1EX +LaA== 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:mime-version :message-id:date:subject:cc:to:from; bh=xLCrA/Af5545OXmownu82dhuJnDDEFk01LSE2GNzLuc=; b=Gjhoi07tUcsff8CLrggI3x6/V+Cf2aWVDGadYPU6D9hbXE1usJZoEdMZi93yV4t8Ez d5kpTclxWVb1uZIBJMAMVtl+12ZXaw0cVEDyXolCO6tu/fF82vQ5xIwdjysmE1c6/+cC nxqwRw0DJgMawSXk3eSGPzd93na5hMwZK5ux8aoePJEifmOowicyZBH7YKqJ5zUfldcT ezBiUY9cX5qFwtioY4/MjD2/+CmKfWsFPXhs9e9pe8ugw0EnkhiHtG1Ck5mOohlBWQ9u 3uFwVIvHf6+0mfK0GuFDbocwhWFSqTILdtTORWlj+j8GCbXZ+rKFdxKS2svWcoBl6Pda LU/w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ct1si9932802plb.419.2019.03.18.08.07.01; Mon, 18 Mar 2019 08:07:18 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726922AbfCRPGW (ORCPT + 99 others); Mon, 18 Mar 2019 11:06:22 -0400 Received: from foss.arm.com ([217.140.101.70]:35988 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726435AbfCRPGW (ORCPT ); Mon, 18 Mar 2019 11:06:22 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 633851650; Mon, 18 Mar 2019 08:06:21 -0700 (PDT) Received: from why.lan (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 14C483F59C; Mon, 18 Mar 2019 08:06:19 -0700 (PDT) From: Marc Zyngier To: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usb: typec: fusb302: Fix debugfs mutex initialisation Date: Mon, 18 Mar 2019 15:06:00 +0000 Message-Id: <20190318150600.23417-1-marc.zyngier@arm.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Running a kernel with the fusb302 driver and lockdep enabled leads to an unpleasant warning: [ 4.617477] INFO: trying to register non-static key. [ 4.617930] the code is fine but needs lockdep annotation. [ 4.618418] turning off the locking correctness validator. [ 4.618913] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.1.0-rc1-00007-g3542533f3fc9 #13 [ 4.619620] Hardware name: rockchip evb_rk3399/evb_rk3399, BIOS 2019.04-rc3-00124-g2feec69fb1 03/15/2019 [ 4.620454] Call trace: [ 4.620693] dump_backtrace+0x0/0x138 [ 4.621028] show_stack+0x24/0x30 [ 4.621336] dump_stack+0xbc/0x104 [ 4.621649] register_lock_class+0x594/0x598 [ 4.622036] __lock_acquire+0x80/0x11b8 [ 4.622384] lock_acquire+0xdc/0x260 [ 4.622711] __mutex_lock+0x90/0x8a0 [ 4.623037] mutex_lock_nested+0x3c/0x50 [ 4.623394] _fusb302_log+0x88/0x1f0 [ 4.623721] fusb302_log+0x7c/0xa0 [ 4.624033] tcpm_init+0x5c/0x190 [ 4.624336] tcpm_init+0x3c/0x130 [ 4.624640] tcpm_register_port+0x574/0x878 [ 4.625019] fusb302_probe+0x2c8/0x590 Despite what the message says, the code isn't fine, as it tries to make use of the fusb302_log facility pretty early. This requires the logbuffer_lock mutex to be initialised, but that only happens much later. Boo. Hoist the fusb302_debugfs_init call before tcpm_register_port so that we can enjoy a working mutex. Signed-off-by: Marc Zyngier --- drivers/usb/typec/tcpm/fusb302.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c index e9344997329c..7e3f8901daf6 100644 --- a/drivers/usb/typec/tcpm/fusb302.c +++ b/drivers/usb/typec/tcpm/fusb302.c @@ -1790,6 +1790,7 @@ static int fusb302_probe(struct i2c_client *client, goto destroy_workqueue; } + fusb302_debugfs_init(chip); chip->tcpm_port = tcpm_register_port(&client->dev, &chip->tcpc_dev); if (IS_ERR(chip->tcpm_port)) { ret = PTR_ERR(chip->tcpm_port); @@ -1807,7 +1808,6 @@ static int fusb302_probe(struct i2c_client *client, goto tcpm_unregister_port; } enable_irq_wake(chip->gpio_int_n_irq); - fusb302_debugfs_init(chip); i2c_set_clientdata(client, chip); return ret; -- 2.20.1