Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp463245pxb; Wed, 13 Apr 2022 06:00:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrPhdGDo3iitMpI5hjxgMQMH+K74sUJL9X+5HX4LbasgLa6WvXG5JmiHw/35BniC7vCwJH X-Received: by 2002:a50:eb8e:0:b0:41d:a5a8:a00f with SMTP id y14-20020a50eb8e000000b0041da5a8a00fmr5186122edr.312.1649854827529; Wed, 13 Apr 2022 06:00:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649854827; cv=none; d=google.com; s=arc-20160816; b=M4zWeUraWmckwSrFM9kGdnSJIYhrf8yp8hAQ2md9fcYnKKmbGPJRFbQCqYMlTyY9Ns iX0/xNqq40lmBnbt7DhWF9dnetX6UAsJH1Fs2VmE2jo1Iypj6UHqPENl35vejWWxnRzi lBhmpar45H3V915BC+q76Xr7GJCkWZdVOx1f/7wCxmKzZ+XmNKpesFLQG4ALgBodgMu5 3pnThOiuYedAC7mylNEvwyWUYMaUOQBVCmsyiIHQHnT9ebpDi3DHGqnX3jZXO3m8X4H2 gTHFU7Pa5WsE1MiwlEn6TAnLBkdDSeBAf2bwlxwEErXSQHSHMQlmXWFVPTuje8WCicjJ a9YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=RAbbqGIzkMLzQKpG2vYmzXt8bBc9Q8IObLSVlsmvLfA=; b=W2TmbA4IYRhP7N8XE7ifTlHT7uw+xrTfcrt3CStcTxQPaSGU9SqNLRRGZ7U21pgFeG YGoyxTsR+vkKSaeutcwVijcwaMF/jDeg0AYqdnPWu1kzs062Voi6zWVm6KfE4E14Xp73 o2VXO1I9V6202hFL2o6/PpwIyWPKPO7nr82My7j07qyUhXfDQBDeriAU6ag8dyO2khNL M2Sm9l1JdcYZr/upMz+49Vi2BqSp8ZhM/VArTm1Txi078tKu5R+RfONMaM9211hLou1w RInIeyFe0bLmPbazetZ+Ls/FE55Gc91hEGReRreweq7xBqhbD88LG9hMBqTYjue6dopc y9hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PklpqsZt; 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t27-20020a170906269b00b006e8d683e515si190245ejc.821.2022.04.13.05.59.59; Wed, 13 Apr 2022 06:00:27 -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=@intel.com header.s=Intel header.b=PklpqsZt; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230025AbiDMGEN (ORCPT + 99 others); Wed, 13 Apr 2022 02:04:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232763AbiDMGEL (ORCPT ); Wed, 13 Apr 2022 02:04:11 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B824525C5A; Tue, 12 Apr 2022 23:01:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649829710; x=1681365710; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+8KRmXihZjR6F7KMu/IkyUTy0vLDDknlzWwTKsgw244=; b=PklpqsZtow600Q6w/Q0vN4CYhawJDCWEoXp8U/wtkF0J/juciqm9LXEi CPo4Qk3foieDr/6Vk1IgHgnQsHQi7OHJjVSx1YRkh7M6M1w0RLLenweF0 yO1lJ8RZ+7yEJmoMq9qgx9OMEwyqMp+12FBs9dsJfHl9f2WoEoX6KVvGC xpCmhSQbGkIly1V/LIc7N2KS+ciQx02S2/EI3eruvhV4M21IOgSihZ9SM KF9CpEf/V351yodAhQeiNA6XSQe0sS373RL9JoOMvZe5zPg+t5A1QJa2e 2leiAkIaI3u/COLk86H6OlaNvktxDTAAzJb9cKIAs84sJV3uRhDGbatE6 A==; X-IronPort-AV: E=McAfee;i="6400,9594,10315"; a="244469508" X-IronPort-AV: E=Sophos;i="5.90,256,1643702400"; d="scan'208";a="244469508" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2022 23:01:33 -0700 X-IronPort-AV: E=Sophos;i="5.90,256,1643702400"; d="scan'208";a="590632232" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2022 23:01:33 -0700 Subject: [PATCH v2 01/12] device-core: Move device_lock() lockdep init to a helper From: Dan Williams To: linux-cxl@vger.kernel.org Cc: Pierre-Louis Bossart , Dave Jiang , Kevin Tian , peterz@infradead.org, vishal.l.verma@intel.com, alison.schofield@intel.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev Date: Tue, 12 Apr 2022 23:01:33 -0700 Message-ID: <164982969345.684294.10649947254613843363.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <164982968798.684294.15817853329823976469.stgit@dwillia2-desk3.amr.corp.intel.com> References: <164982968798.684294.15817853329823976469.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 In preparation for new infrastructure to support lockdep validation of device_lock() usage across driver subsystems, add a device_lockdep_init() helper to contain those updates. Suggested-by: Pierre-Louis Bossart Reviewed-by: Dave Jiang Reviewed-by: Kevin Tian Signed-off-by: Dan Williams --- drivers/base/core.c | 5 +---- include/linux/device.h | 13 +++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 3d6430eb0c6a..cb782299ae44 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2864,10 +2864,7 @@ void device_initialize(struct device *dev) kobject_init(&dev->kobj, &device_ktype); INIT_LIST_HEAD(&dev->dma_pools); mutex_init(&dev->mutex); -#ifdef CONFIG_PROVE_LOCKING - mutex_init(&dev->lockdep_mutex); -#endif - lockdep_set_novalidate_class(&dev->mutex); + device_lockdep_init(dev); spin_lock_init(&dev->devres_lock); INIT_LIST_HEAD(&dev->devres_head); device_pm_init(dev); diff --git a/include/linux/device.h b/include/linux/device.h index 93459724dcde..af2576ace130 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -762,6 +762,19 @@ static inline bool dev_pm_test_driver_flags(struct device *dev, u32 flags) return !!(dev->power.driver_flags & flags); } +#ifdef CONFIG_PROVE_LOCKING +static inline void device_lockdep_init(struct device *dev) +{ + mutex_init(&dev->lockdep_mutex); + lockdep_set_novalidate_class(&dev->mutex); +} +#else +static inline void device_lockdep_init(struct device *dev) +{ + lockdep_set_novalidate_class(&dev->mutex); +} +#endif + static inline void device_lock(struct device *dev) { mutex_lock(&dev->mutex);