Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2634966pxa; Mon, 17 Aug 2020 15:03:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdmkr0MAYXVmgohzf2QDdL+qsl0v3cCWiETcT/z5wrSOCPJXYwphG/RkLIE61yf/3qeyy3 X-Received: by 2002:a17:906:4d89:: with SMTP id s9mr16396718eju.365.1597701812231; Mon, 17 Aug 2020 15:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597701812; cv=none; d=google.com; s=arc-20160816; b=UQ0+XmCUnFytpLpTE1L28gmJxPR1r2+4tC/1JRKVxCFj9bEPIRgpYEII7cn6o4sR4V +sozZAWEW0dXaxoe4N6sbiK/xI7MMgZgKA3XbiFFKVetNJTtukSvBjDh6HnzyXLdlCbU Tfc9leQed5JlgTHhlgWEEqPDDODVhD3pLdlC2u9iQ6gNBi1dZ1m+Sni2Tc5GQACObwxh 6eXT6p8POnBLaNKMJwWggNpJtAU3LzInLHZJpNFyAUrbb4oC/CcrXSqktX4kpQDmPEvn nkClzRU3guZotK4LQJGYa50Aq84IoD5y8l4idsZ+U7XUk1MDlmuqu7K6Ll0ZJvpj9Zfw gs4w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FjBcw4l7mGIYXs2G6N3cSVqHYVI6P6xSpKPnVSdlfo4=; b=dlqhVH+DONE86iyXS+eX2PgKdQiClnwiObcGIoJlECVMMyFGoxF9UHtrikj5vCkPhx Kp32vilJOwsXoH4YXnGFM0qdGTVDW5f1cC34D5NBae4oXXwER3la254AwmTP2Z5T8WQt L9IPoPx5v8D7Mu6hrMIUMBixIe7IKDkaGdZb6GnpXMLnN7gE6DVN4P0sLZWy764redZO xp9WCaJp6yhC8Mf3RKJeCxLJw8Y7hH5XMwKtyX1Z2Fh64waOxuS7UKyPs9MP0NgIH9rb GFze1egc+mGBMhojSFuLU7hORaXU88MqT2PyeHw+6xtNqzZN9Sjs56aOmYfuP3D1AK5N jLgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oaQ4GnKX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lo3si12003739ejb.46.2020.08.17.15.03.08; Mon, 17 Aug 2020 15:03:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oaQ4GnKX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387524AbgHQPmU (ORCPT + 99 others); Mon, 17 Aug 2020 11:42:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:41688 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730462AbgHQPfZ (ORCPT ); Mon, 17 Aug 2020 11:35:25 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3995A20888; Mon, 17 Aug 2020 15:35:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678524; bh=Y+FG7RM+Q3Rp+cwe025luEF0XzlNXVbOZX4opB1cR5I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oaQ4GnKX+M6XuP1w0mhHyQEDKUQPcb9fk2T5dcfHIKem/s1bQcukwplAN8La1pZBW EK+eZ7d/CFCqe2yO5cscZUw9w4vv2feOjjwnH51obTcByuukiB4L7MOIqowFpL8t+g W3W2h414gIv2oQcm10aGJRU6goGz2uxBtR4zxj8w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ahmad Fatoum , Andy Shevchenko , Bartosz Golaszewski , Linus Walleij , Sasha Levin Subject: [PATCH 5.8 365/464] gpio: dont use same lockdep class for all devm_gpiochip_add_data users Date: Mon, 17 Aug 2020 17:15:18 +0200 Message-Id: <20200817143851.257112713@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ahmad Fatoum [ Upstream commit 5f402bb17533113c21d61c2d4bc4ef4a6fa1c9a5 ] Commit 959bc7b22bd2 ("gpio: Automatically add lockdep keys") documents in its commits message its intention to "create a unique class key for each driver". It does so by having gpiochip_add_data add in-place the definition of two static lockdep classes for LOCKDEP use. That way, every caller of the macro adds their gpiochip with unique lockdep classes. There are many indirect callers of gpiochip_add_data, however, via use of devm_gpiochip_add_data. devm_gpiochip_add_data has external linkage and all its users will share the same lockdep classes, which probably is not intended. Fix this by replicating the gpio_chip_add_data statics-in-macro for the devm_ version as well. Fixes: 959bc7b22bd2 ("gpio: Automatically add lockdep keys") Signed-off-by: Ahmad Fatoum Reviewed-by: Andy Shevchenko Reviewed-by: Bartosz Golaszewski Link: https://lore.kernel.org/r/20200731123835.8003-1-a.fatoum@pengutronix.de Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/gpio/gpiolib-devres.c | 13 ++++++++----- include/linux/gpio/driver.h | 13 +++++++++++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpiolib-devres.c b/drivers/gpio/gpiolib-devres.c index 5c91c4365da1f..7dbce4c4ebdf4 100644 --- a/drivers/gpio/gpiolib-devres.c +++ b/drivers/gpio/gpiolib-devres.c @@ -487,10 +487,12 @@ static void devm_gpio_chip_release(struct device *dev, void *res) } /** - * devm_gpiochip_add_data() - Resource managed gpiochip_add_data() + * devm_gpiochip_add_data_with_key() - Resource managed gpiochip_add_data_with_key() * @dev: pointer to the device that gpio_chip belongs to. * @gc: the GPIO chip to register * @data: driver-private data associated with this chip + * @lock_key: lockdep class for IRQ lock + * @request_key: lockdep class for IRQ request * * Context: potentially before irqs will work * @@ -501,8 +503,9 @@ static void devm_gpio_chip_release(struct device *dev, void *res) * gc->base is invalid or already associated with a different chip. * Otherwise it returns zero as a success code. */ -int devm_gpiochip_add_data(struct device *dev, struct gpio_chip *gc, - void *data) +int devm_gpiochip_add_data_with_key(struct device *dev, struct gpio_chip *gc, void *data, + struct lock_class_key *lock_key, + struct lock_class_key *request_key) { struct gpio_chip **ptr; int ret; @@ -512,7 +515,7 @@ int devm_gpiochip_add_data(struct device *dev, struct gpio_chip *gc, if (!ptr) return -ENOMEM; - ret = gpiochip_add_data(gc, data); + ret = gpiochip_add_data_with_key(gc, data, lock_key, request_key); if (ret < 0) { devres_free(ptr); return ret; @@ -523,4 +526,4 @@ int devm_gpiochip_add_data(struct device *dev, struct gpio_chip *gc, return 0; } -EXPORT_SYMBOL_GPL(devm_gpiochip_add_data); +EXPORT_SYMBOL_GPL(devm_gpiochip_add_data_with_key); diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index c4f272af7af59..e6217d8e2e9f6 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -509,8 +509,16 @@ extern int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, gpiochip_add_data_with_key(gc, data, &lock_key, \ &request_key); \ }) +#define devm_gpiochip_add_data(dev, gc, data) ({ \ + static struct lock_class_key lock_key; \ + static struct lock_class_key request_key; \ + devm_gpiochip_add_data_with_key(dev, gc, data, &lock_key, \ + &request_key); \ + }) #else #define gpiochip_add_data(gc, data) gpiochip_add_data_with_key(gc, data, NULL, NULL) +#define devm_gpiochip_add_data(dev, gc, data) \ + devm_gpiochip_add_data_with_key(dev, gc, data, NULL, NULL) #endif /* CONFIG_LOCKDEP */ static inline int gpiochip_add(struct gpio_chip *gc) @@ -518,8 +526,9 @@ static inline int gpiochip_add(struct gpio_chip *gc) return gpiochip_add_data(gc, NULL); } extern void gpiochip_remove(struct gpio_chip *gc); -extern int devm_gpiochip_add_data(struct device *dev, struct gpio_chip *gc, - void *data); +extern int devm_gpiochip_add_data_with_key(struct device *dev, struct gpio_chip *gc, void *data, + struct lock_class_key *lock_key, + struct lock_class_key *request_key); extern struct gpio_chip *gpiochip_find(void *data, int (*match)(struct gpio_chip *gc, void *data)); -- 2.25.1