From patchwork Thu Jan 21 11:17:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 367812 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp471908jam; Thu, 21 Jan 2021 03:22:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUoQAp2i7qbIN2aJgW79CpVUxVzY1Z1xWBv0gRDY27dIgJva9qyb4bPQAXgDA3gXMXcG3Q X-Received: by 2002:a05:6402:79a:: with SMTP id d26mr7074929edy.266.1611228129690; Thu, 21 Jan 2021 03:22:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611228129; cv=none; d=google.com; s=arc-20160816; b=WhEksIQglQRsP5CVFxSAkOYb7ETlDmhx9Q6q/tJp83DVDKy9dbIZRexvGQDV1JiCKu cMpRlRAcnJWrwMLqb65334PsFWrKWelhqHqzb162ditomrAtcZtTNmsj5I17Rj/2mt9s ZikIcFIx9uW4wmDQjqyMei4HmfljUGA4tMi5lc7SOB3lcCvjiTm3XqPPy6cbiXQVbWue F3rwtOaAjAq+ffbiCZwRfKDFcLMA0cgsANVVFJ90bDWxZQbp3XUDedGwSt8EIyvvcgbI eFFZPYjSVzn8Gn+NhmRKFEy60qTvERIAuBq50BWcZ7vM7M3uElvXc27B5I/YCXjuiJw3 wFIA== 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=ztcbVczwcxvX+Nme8Zu1bVyHZiwA0aS5UzQfgwSCEM4=; b=vwd3w4Tjiy1/5sZfo4Qf93UI76lJxuH7EXXgELFW7D7hX6jEcJ6ICcJbLBh3dxbJmc 9TOtSH07DORsvilxjohZoeomBL+3gcRKXbxoqaomKt7fuTpfAKmXSdYZDanuCIu5h6Qr 2aFT+A+qYljjqgzfODO/ct0iDvrqS7+UGCqv8Cv84kU9OFUtYPgBQtXOXYvK/uiLGly1 lkg5CLNYwCaVPKVZwDu9TmwRfmvxnqxoOj4BhX1xbcPv7+vCRu6CuSWls6XL2CBr4T+u nG4yanwSkO1BfsOFXT0YN8pUMi4IWX9BSml81sftgyZAn87hKvQgLE2mRGX/jEd/TnJU 2YGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uvEyLQq5; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h6si1753700ejq.244.2021.01.21.03.22.09; Thu, 21 Jan 2021 03:22:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-pm-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=@linaro.org header.s=google header.b=uvEyLQq5; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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 S1729925AbhAULVQ (ORCPT + 7 others); Thu, 21 Jan 2021 06:21:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728983AbhAULVA (ORCPT ); Thu, 21 Jan 2021 06:21:00 -0500 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F8A2C0617A2 for ; Thu, 21 Jan 2021 03:19:10 -0800 (PST) Received: by mail-pg1-x532.google.com with SMTP id v19so1132993pgj.12 for ; Thu, 21 Jan 2021 03:19:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ztcbVczwcxvX+Nme8Zu1bVyHZiwA0aS5UzQfgwSCEM4=; b=uvEyLQq53T//ZW0fW9IuJXmQ0IpdbzBOHOZkvCWGZ4qs23KbdM1qBbTqsBvRapbFjQ GFTzRYWISYJfZppc2Zk7RHboU5zZ4TVr9NOy3uFsFZN3WNsrlkPVDczNsuKmY3q5BE+B WJn2+aBHGJLNiN6/ELjw0OPDd33iZ3H6kAA4chYfT/sr2Gd/6TnwEmeW8lfDuPWeru/u C7NgP8XEQydN5j4ZOwOQDckF78X8cApKr6rG9CXIybnq9UjECRHrVggyvlYqLI+ZC7T7 3ywLOkm13JVjMF9xUIgRTuNR6fYT/JHPI2hQ8dokW8N1jPAkvjp3iKDDfY80HBbwF3Xp Or9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ztcbVczwcxvX+Nme8Zu1bVyHZiwA0aS5UzQfgwSCEM4=; b=XY2WpXdeAJFqSDrR5LecaDLFgGXTKv7zZ4fMT6+ZBRen5H6rdj6qzd6yv8U8CBbx6F zuee4/8/pl/eU7mo34FSYXRE0bWXA5tI29ciPL7edL7PgWkgnFJa27sPuODVvA+G599p H3kxyG6dB39xTxXqek7ZlRoG74mBl9RNT1HWfSBsi7B5NmCzYnvNOOsQA3hQL5MJZ2eS 5GLzb1e8y42D+7KILx87MXqcmFuA37sYlY60ndVCLZvzpjziwrPTk+UZUVJ8vYKdUpBH K8mFT2NNhLwCG0DvL3L4k/oyLPBq6MSUMwlU+BiorMfXBn+hVzVz0xFMNcBJs3vFdjMc mhfQ== X-Gm-Message-State: AOAM532ZWH8dZVllz63ly/l/7l0te2jSKkg4QuIHZFgr8YyfcYBZgWoi kpugOCfjDUElAzVwhE91ihvdpA== X-Received: by 2002:a63:d446:: with SMTP id i6mr14020045pgj.446.1611227949698; Thu, 21 Jan 2021 03:19:09 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id u189sm5203484pfb.51.2021.01.21.03.19.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jan 2021 03:19:09 -0800 (PST) From: Viresh Kumar To: Dmitry Osipenko , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Sibi Sankar , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 09/13] opp: Implement dev_pm_opp_set_opp() Date: Thu, 21 Jan 2021 16:47:49 +0530 Message-Id: <7d62f63ac64e59ee3327789ff1bc9cebc2da6944.1611227342.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The new helper dev_pm_opp_set_opp() can be used for configuring the devices for a particular OPP and can be used by different type of devices, even the ones which don't change frequency (like power domains). Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 28 ++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 ++++++ 2 files changed, 34 insertions(+) -- 2.25.0.rc1.19.g042ed3e048af diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 3500cc9de66b..5a367ef02b92 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1130,6 +1130,34 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) } EXPORT_SYMBOL_GPL(dev_pm_opp_set_rate); +/** + * dev_pm_opp_set_opp() - Configure device for OPP + * @dev: device for which we do this operation + * @opp: OPP to set to + * + * This configures the device based on the properties of the OPP passed to this + * routine. + * + * Return: 0 on success, a negative error number otherwise. + */ +int dev_pm_opp_set_opp(struct device *dev, struct dev_pm_opp *opp) +{ + struct opp_table *opp_table; + int ret; + + opp_table = _find_opp_table(dev); + if (IS_ERR(opp_table)) { + dev_err(dev, "%s: device opp doesn't exist\n", __func__); + return PTR_ERR(opp_table); + } + + ret = _set_opp(dev, opp_table, opp, opp->rate); + dev_pm_opp_put_opp_table(opp_table); + + return ret; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_set_opp); + /* OPP-dev Helpers */ static void _remove_opp_dev(struct opp_device *opp_dev, struct opp_table *opp_table) diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index f8e9a8e3eb59..2d8a706f8d00 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -158,6 +158,7 @@ void dev_pm_opp_detach_genpd(struct opp_table *opp_table); struct opp_table *devm_pm_opp_attach_genpd(struct device *dev, const char **names, struct device ***virt_devs); int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate); int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq); +int dev_pm_opp_set_opp(struct device *dev, struct dev_pm_opp *opp); int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp); int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask); int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); @@ -376,6 +377,11 @@ static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_f return -ENOTSUPP; } +static inline int dev_pm_opp_set_opp(struct device *dev, struct dev_pm_opp *opp) +{ + return -ENOTSUPP; +} + static inline int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp) { return -EOPNOTSUPP;