From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D29AF6BFA3 for ; Wed, 4 Sep 2024 20:18:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725481089; cv=none; b=Sv6xWytJ3rK8EfxGOjfXsBqEUIlqii9snGhLmx+IrVvMA6/o8Bxb0I6K8sEdreyqwUq08MYyzPl8qwNXREaA3nofx+uCmwbDWjKHn6z/zKPoAZczTOlWSeO1Vum+l391m6K+N4qLoseaqOFhB2oNXUiy/8S3iKS7RMCbjvkmdqc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725481089; c=relaxed/simple; bh=MAXsiQtJ6WIl6u3XvM9qP/wKwbWvsT+xDAqv0LL9ov0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=cYqSKzbhw1PZqKRwejkDkk/RnnRd78QDy5HPyS6OZ51Q98sCymyADrTxQEnLFZVgVhyqRTMd7TjB776OjRG36qEK+0M5uuolpovcbuXjaQ5GXm6rZ6jDC40vNCESOpQnNEAxB4GiGXRhEFKkgVtaHRLT4Dw/+dgXbnVDvFVe2OY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=clIYixfP; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="clIYixfP" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WzYhT1zxkz6CmLxj; Wed, 4 Sep 2024 20:18:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:x-mailer:message-id:date :date:subject:subject:from:from:received:received; s=mr01; t= 1725481078; x=1728073079; bh=x+LXEvQo2gdj5yh0a6NeCfTwRObOEro4wzw PVHiV6LM=; b=clIYixfPelmKMyl0KRRh6HBSqvzAOs1mAxyG8I9fG2snwZMM7l+ u7nfvQsWeNmWHbxdbjGWlElUs4O10M+ZmGbtJ77t9jA4ndiAXaD1NHyKrQZBgcjl orwd8Ta/eRPBjqhewoRSN63Z5MYeejAqHwWUGox88nOmAheyA+uzsYp3mdRGdaR6 MQ7+0aWLP6hgE+2NoWBygP5Q7LkLcmqUW5IJS0Zusqn2P2MgLREfkBjDEgv1jj0D pze/2FOKLySA+tTLyRwhVXQUL4IuTBR2z+p4pStel64EY4R5nD849CWIEli92Z0A QjRH6wWBu3MdsgPuw/WyUL6VhBFE2egxr2A== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id GoGObcMJ9H_W; Wed, 4 Sep 2024 20:17:58 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4WzYhN4r5Kz6ClbFV; Wed, 4 Sep 2024 20:17:56 +0000 (UTC) From: Bart Van Assche To: Greg Kroah-Hartman Cc: Bart Van Assche , Hans de Goede , Andy Shevchenko , Heikki Krogerus , stable@vger.kernel.org Subject: [PATCH] usb: roles: Fix a false positive recursive locking complaint Date: Wed, 4 Sep 2024 13:17:48 -0700 Message-ID: <20240904201748.2901149-1-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Suppress the following lockdep complaint: INFO: trying to register non-static key. The code is fine but needs lockdep annotation, or maybe you didn't initialize this object before use? turning off the locking correctness validator. Cc: Hans de Goede Cc: Andy Shevchenko Cc: Heikki Krogerus Cc: Greg Kroah-Hartman Cc: stable@vger.kernel.org Fixes: fde0aa6c175a ("usb: common: Small class for USB role switches") Signed-off-by: Bart Van Assche --- drivers/usb/roles/class.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c index d7aa913ceb8a..f648ce3dd9b5 100644 --- a/drivers/usb/roles/class.c +++ b/drivers/usb/roles/class.c @@ -21,6 +21,7 @@ static const struct class role_class =3D { =20 struct usb_role_switch { struct device dev; + struct lock_class_key key; struct mutex lock; /* device lock*/ struct module *module; /* the module this device depends on */ enum usb_role role; @@ -326,6 +327,8 @@ static void usb_role_switch_release(struct device *de= v) { struct usb_role_switch *sw =3D to_role_switch(dev); =20 + mutex_destroy(&sw->lock); + lockdep_unregister_key(&sw->key); kfree(sw); } =20 @@ -364,7 +367,8 @@ usb_role_switch_register(struct device *parent, if (!sw) return ERR_PTR(-ENOMEM); =20 - mutex_init(&sw->lock); + lockdep_register_key(&sw->key); + __mutex_init(&sw->lock, "usb_role_switch_desc::lock", &sw->key); =20 sw->allow_userspace_control =3D desc->allow_userspace_control; sw->usb2_port =3D desc->usb2_port;