Message ID | 20230621144019.3219858-3-abel.vesa@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4439652vqr; Wed, 21 Jun 2023 08:15:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4SZIyhoi6ELXfg2grifGQahaej7+Xke7VoFJjLgFguHhQP9bqava+ckuHWRZgLb7N9OhH0 X-Received: by 2002:a17:902:f816:b0:1ae:89a:a4 with SMTP id ix22-20020a170902f81600b001ae089a00a4mr18905502plb.8.1687360530176; Wed, 21 Jun 2023 08:15:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687360530; cv=none; d=google.com; s=arc-20160816; b=R71sNmXuGeli6lexSklEsEhYUlQYLC0MeR89zzFk/UZMkkP3nrI1AobeoB8594ipws eKF9OJt3FNTUoQykl/gE2R82cEL5sVxDKOyROEMX7jH8Mu33fj6qQASksOd1yvEbA+CV VrGx6qND5fJmAt0K1Ekxfu0lXyIqfzTlyKxYaT3idmsb6S7TWYWHcnMOdl/l3MkruF01 KhFj2NU1DYa4yao84xyCtoTswZU3vF23HLHWUuwMCCeOdciSn0xl+AQQKKKEhVJmlv01 uGTQOYA/Q94ZizT6Jr/MJtSScZrxroyF9Yert8sVwfSHQi5CR5wZ/dyv010pOKwEH4kk 8J/w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2W3Kf4ey7QY4pTA3JpFMV/TNECBh7Gq30HfrcLuf2lU=; b=fTJi9IpT/s/GQezIrGkj00NjUvf31w+973s49+D/ooyqRRRQ/0QX1ahY7e7xUMCF7K ZrxroIaQdU9XlC91zeLG5OhKtQv5aDiDltGmrgUwjKLiC5rUbxORGm97HNbQz+99cqlI R7aFaHP55DXMNvSC9+iBW4yhs60xHZWT3WLAq01NnTIzEnsk8sl6o+ZjqtThqzaFAUHT cAZEIUwHyhTSmlGHbHxzxK+H8nx9lg96PWIjLyap17yXc9uY4qYs1zpWd8CHCi5IcBSI T1JdPW9Nhw2m1rCplJDneLIJbq7t4k9p3pC3SxYhmPItQEgRR5qK3nJGlhH+86dgOfU8 YfUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qvokshYU; 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=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m21-20020a170902d19500b001afada38c64si3865921plb.302.2023.06.21.08.15.16; Wed, 21 Jun 2023 08:15:30 -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=@linaro.org header.s=google header.b=qvokshYU; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231327AbjFUOkf (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Wed, 21 Jun 2023 10:40:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230506AbjFUOk2 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 21 Jun 2023 10:40:28 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51A45173F for <linux-kernel@vger.kernel.org>; Wed, 21 Jun 2023 07:40:27 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-51a2de3385fso7904035a12.0 for <linux-kernel@vger.kernel.org>; Wed, 21 Jun 2023 07:40:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687358426; x=1689950426; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2W3Kf4ey7QY4pTA3JpFMV/TNECBh7Gq30HfrcLuf2lU=; b=qvokshYUKY7HCe7qvXfL6wjYYLXu4sLS55Nbn5MMSRaW3ci8oSwdrPhew+rcuX2SGB ttF+BrNowbQuVuwKWys48yk9Pp0Rqcb8/qlhp3OiBdxnhHoN0cNYjwyl2jlRW3nIJnbP XSOR9VS87RpPQWiKFJHP5L0cJX0OAjgyeIkzIPN1YHYbGcaiD/eqsXgwwYd76a/cee65 gOf3sJhWtsKrOBhZTFPntSptaEMNKExo8zFZoqU4t94AQH59SXnYGMOn8JeiYbbh1Tdo xgKZP+jAeulj6cyNtmCOXXXogsSB3bnXaTruagohS/wdx+Sfv8zc0cM4+ifmo9z/x7QA fBOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687358426; x=1689950426; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2W3Kf4ey7QY4pTA3JpFMV/TNECBh7Gq30HfrcLuf2lU=; b=Q0FEytZRrrAiz5x8Rsh1VvxQ2ZzKNoeIt2J2nvisP4b6Zoi1DsmfhDjhBVfAL1Jc7k bJgSAt7R3h4vfwX2oVtb7+23jwUMFopgl4eAaeJFCmODjH6Q0hudjxSqZDb344fMluy/ rtQMaPzAvxxW+24cm2PC2on0Q5cwq0OvMdZ27ATObJzk9HHd64N8zs7gKimDiLd9BRYj A8UBcmhJu1x/StqMrod2gXmwe2BRns02/dvYrxPehN9lk7ZuIHEGt1aVOKmN2yrg3asy mHnftSOGUHkA150W9P1c8uILPVdNursG1PIKBwCN7PwH/8Bo/8+A1kBcnBeh3QDbIxkz JwJg== X-Gm-Message-State: AC+VfDzgTXFvw9G18ovevk4PezacxjbHq/igcJufXR3ShS19bYOxYXSj QjmA8kbVhlNd/pfPTqhPxzvC7w== X-Received: by 2002:a05:6402:642:b0:51a:5ebe:4ab9 with SMTP id u2-20020a056402064200b0051a5ebe4ab9mr5948602edx.14.1687358425839; Wed, 21 Jun 2023 07:40:25 -0700 (PDT) Received: from hackbox.lan ([82.79.124.17]) by smtp.gmail.com with ESMTPSA id l13-20020a056402344d00b0051879c4f598sm2689505edc.66.2023.06.21.07.40.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 07:40:25 -0700 (PDT) From: Abel Vesa <abel.vesa@linaro.org> To: "Rafael J . Wysocki" <rafael@kernel.org>, Kevin Hilman <khilman@kernel.org>, Ulf Hansson <ulf.hansson@linaro.org>, Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Saravana Kannan <saravanak@google.com> Cc: Bjorn Andersson <andersson@kernel.org>, linux-pm@vger.kernel.org, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, linux-arm-msm@vger.kernel.org, Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Subject: [RFC PATCH v5 2/4] driver core: Add dev_is_drv_state_synced() Date: Wed, 21 Jun 2023 17:40:17 +0300 Message-Id: <20230621144019.3219858-3-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230621144019.3219858-1-abel.vesa@linaro.org> References: <20230621144019.3219858-1-abel.vesa@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769325755201500817?= X-GMAIL-MSGID: =?utf-8?q?1769325755201500817?= |
Series |
PM: domain: Support skiping disabling unused domains until sync state
|
|
Commit Message
Abel Vesa
June 21, 2023, 2:40 p.m. UTC
This can be used by drivers to figure out if a different device
driver has state synced or not for a specific device.
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
---
include/linux/device.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
Comments
On Wed, Jun 21, 2023 at 05:40:17PM +0300, Abel Vesa wrote: > This can be used by drivers to figure out if a different device > driver has state synced or not for a specific device. > > Signed-off-by: Abel Vesa <abel.vesa@linaro.org> > --- > include/linux/device.h | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/include/linux/device.h b/include/linux/device.h > index bae11928ef7e..8f042f04b5d9 100644 > --- a/include/linux/device.h > +++ b/include/linux/device.h > @@ -1007,6 +1007,20 @@ static inline int dev_set_drv_sync_state(struct device *dev, > return 0; > } > > +static inline bool dev_is_drv_state_synced(struct device *dev) > +{ > + bool ret = false; > + > + if (!dev) > + return ret; > + > + device_lock(dev); > + ret = dev->state_synced; > + device_unlock(dev); This lock is "protecting" nothing, given that the value can instantly change after it is read. Because it can change, how will this function actually show anything relevant? thanks, greg k-h
On 23-06-21 17:22:54, Greg Kroah-Hartman wrote: > On Wed, Jun 21, 2023 at 05:40:17PM +0300, Abel Vesa wrote: > > This can be used by drivers to figure out if a different device > > driver has state synced or not for a specific device. > > > > Signed-off-by: Abel Vesa <abel.vesa@linaro.org> > > --- > > include/linux/device.h | 14 ++++++++++++++ > > 1 file changed, 14 insertions(+) > > > > diff --git a/include/linux/device.h b/include/linux/device.h > > index bae11928ef7e..8f042f04b5d9 100644 > > --- a/include/linux/device.h > > +++ b/include/linux/device.h > > @@ -1007,6 +1007,20 @@ static inline int dev_set_drv_sync_state(struct device *dev, > > return 0; > > } > > > > +static inline bool dev_is_drv_state_synced(struct device *dev) > > +{ > > + bool ret = false; > > + > > + if (!dev) > > + return ret; > > + > > + device_lock(dev); > > + ret = dev->state_synced; > > + device_unlock(dev); > > This lock is "protecting" nothing, given that the value can instantly > change after it is read. Hmm, for some reason I thought it needs to be synchronized with the sync state callback being called already. But I just noticed that call to the sync state callback is independently locked after state_synced is set. So I guess the lock can go away here. > > Because it can change, how will this function actually show anything > relevant? The only usecase I can think of for this new API is for some driver to delay an action until ultimately the driver for a specific device gets state synced. So even if the value can change after it has been checked, such consumer driver will most likely retry later on. Hope that makes sense. > > thanks, > > greg k-h
diff --git a/include/linux/device.h b/include/linux/device.h index bae11928ef7e..8f042f04b5d9 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -1007,6 +1007,20 @@ static inline int dev_set_drv_sync_state(struct device *dev, return 0; } +static inline bool dev_is_drv_state_synced(struct device *dev) +{ + bool ret = false; + + if (!dev) + return ret; + + device_lock(dev); + ret = dev->state_synced; + device_unlock(dev); + + return ret; +} + static inline void dev_set_removable(struct device *dev, enum device_removable removable) {