Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp406441lqo; Fri, 10 May 2024 03:44:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUs4a3noRjLg+LBWivkrDbntxZ29WOBCjpssd73br1viDr8JLjjRLBmh2gAsRbAVzR5Y2eUeeVx2LdogM7M2FD+Dl0q4jNCca9XZyu09Q== X-Google-Smtp-Source: AGHT+IFXOXzmCI2c2T4YPBlwhp/Sugd5woXkRAgUnxMiPyN/X0hKedAvyWu3YTXFTY77uNUIO9Xz X-Received: by 2002:a05:622a:199f:b0:43a:c1a3:e283 with SMTP id d75a77b69052e-43dfce3ca89mr38376321cf.28.1715337852599; Fri, 10 May 2024 03:44:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715337852; cv=pass; d=google.com; s=arc-20160816; b=Dk4uonokMKfDxF9o+HHpVIalKRd3uallYybkPxj4MMvZvlp6gfv37QsTrhFFcUgWx5 /OymqKrBcNfkTtIwSIr9UMgClMIXMPJlWcHvRbmwRgwavSFYepTEJeua+bawmwizR0Bu 0Ts3lwcnoiIC4VkxveiTNULdwjOA9gS/QExiKa/zRU5GQKJlPWYNbw3Siyjj+hQteOAV upfrkEb5K4NhBfhPzkbYPj251yHzea7JzcuyvAVKkJux9UK/QRBC8mManI8c7v4mI8Pp nvnt7wKpv9JevnYDUf78qg9hc64etaxa2mrWFVH9q3ukWt4Va7TLR3tWFeasZ8DiRtCi c5kg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=1ogNqw3uEWxZLRhr+XjfNFFQFaORnUkcs+lj7HFycVM=; fh=xRSc4aHv7Mztxp3Pzgp1AEIaTY6HFgph6KYraE/b0FA=; b=qh3T1U1TdV3WoSybyULWtQviAwUqjnBpZ2Ltcinkd8uqXWub+wm5MEk7TfWKek/fbd XUHqVpMJkfYvBJfTpuUa1CenlHoZiQ1Efx4GlK/WvRtmRhkUigOJIp7PuoiapOK6zGps mgc6w+wrBebk+8//DmesFh42bhQ4K3iMCSEhXInbrE/ver2Bu1Hz8JMVxgKE9AzVF4em xSUP/EVQEj+IB9w09+4v0X8CU1j79uw1ypXL3zbFKdEKygSmJ8cgqGa+rZCK3/pkY/Cr LXsGK1riUYdn5de9n9EcAzAS3PyY2f1r9S+sEEQGpTMrkqRM2aFYSdSXxWzIlG/4HFV/ M0Cg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E32pxLO0; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-175603-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175603-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43df566fb82si33328391cf.244.2024.05.10.03.44.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 03:44:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175603-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E32pxLO0; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-175603-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175603-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 45C9A1C20FEC for ; Fri, 10 May 2024 10:44:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 552C416ABC3; Fri, 10 May 2024 10:44:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="E32pxLO0" Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 908E27EEF8 for ; Fri, 10 May 2024 10:44:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715337846; cv=none; b=FiMFpEqbOpkmrHMjUk/1fKs1NhtY3aP+uk9Z3p6YnH6URaNO795zA7v7SoZbwSXyTc3Fpatj+ShhYodfjRjMVphGyK7vPqkCmnT8seDf5VewAIVqIoGnzK4EC73FRfLadr/Wn39k8Uytq11GFyMkMQUYjHwxkEJ2hUIMUUBqQ/o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715337846; c=relaxed/simple; bh=i3iJDF0NWxCzPjjHIcKEVQFJMAJAK0g33+1KtcRzxbk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=fvNekZXGmMlXt7bD7PozS6BZsAO+3msQszJDxjLc1lNIqDwcnlMTg9s8I+z8mbZsRd7LJtMnSQguNOHAXOCv0AwzHN18UbooafaPK3VUWzEY4JMJFeDrB8Y827VfjCANCjpSIFnHiudPrc2VcEf/qsU6bhCXpRIAmPnZYzZqJi4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=E32pxLO0; arc=none smtp.client-ip=209.85.219.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-de8b66d1726so2473818276.0 for ; Fri, 10 May 2024 03:44:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715337842; x=1715942642; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=1ogNqw3uEWxZLRhr+XjfNFFQFaORnUkcs+lj7HFycVM=; b=E32pxLO0gLhD+zW6tagdCjBVHmdzv/TlxW0ZTW0vXsCufSgTddMCnX6jm4bxD0dN7X 8ns2G38DXtDWiKNJTdszfQUyIL34wxHKBPbjqfZmKNK4Z5wqJlNoZ4d6NINlA7KasiSv 7SKgTJm2deIwW5wUCDnkItNq/pbCYI206agPexPCAWnIATxcrgV+YUXKxOlNdYGdQ1qm 73iolMC5Q+ptJNylqGJHA6GOU72jeyZg0SeIdrTnu7ktYbvAz569Mhidjgs8pus4DBOa lW6r+lxnj5se5a6s0gX777wu6ZxlxVAeTOw7lwZprzz9vi5PQYVSKcO6ZzBjySe21R7G f9/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715337842; x=1715942642; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1ogNqw3uEWxZLRhr+XjfNFFQFaORnUkcs+lj7HFycVM=; b=KsQMhWvqCtDyXJ9YL96KJFIJXzXbfmEKDnvQtbFHVgFV2AZ7dLhMzhTMrQOXb6Nek/ QmhOHiWGcmc79vBVZhlFE5RikMZ+iXOdY8UfFdC1g9SnWZGhBkltD/X5wLGDwmNdV98m KOSR2Y75ZEbd8m+710U+eIlEzvBK6mCnbS4gGrIKJzRMEe+huvU9tvhPvMobrnMqEZv/ TpKjya0q2Xs4YUMocT14wCZiCM6lGAzxkNxl0rAZgrxg22BVVTmIdIesrhHW4xATQoU4 6fWYM1kclMfwRzZZkvInXbdS28KpXLXO0FsVKCFTADJaWMLgQehtrhDCtg6++lY3GqS+ 8cZg== X-Forwarded-Encrypted: i=1; AJvYcCVcTZAZR5+xVz2F/51QfgdwMqzlBhe8pxnBddnjZ+pbFf+MPYsNEYRD0Q/Tl/jfVmBIQJa5qD2IJpND/AJ/Zw95d1FVtVqzkG8AeGwR X-Gm-Message-State: AOJu0YwgfetH7/bwHQqny3ilJTIM8lR7AGIiN0G1g4f6A+/wlQi1oLmN chrHPHziY1prpO4qFkHNYEsDrwdnazdazvy39ykNcmJUK1cowZyaUzjnrGzHWGm7OHM0EVRAu98 hnJjEpghH01eYRThcgIvZIztYxvOJnwxsmU2kJcosL7ODGZkQ X-Received: by 2002:a25:d009:0:b0:dc6:d1a9:d858 with SMTP id 3f1490d57ef6-dee4e4a641cmr1871935276.8.1715337841207; Fri, 10 May 2024 03:44:01 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <2eb72832e852c80e5c11cd69e7d2f14cefd8b1cb.1712903998.git.viresh.kumar@linaro.org> <7c6df194-fce1-401a-98c5-c903d78627c4@leemhuis.info> In-Reply-To: <7c6df194-fce1-401a-98c5-c903d78627c4@leemhuis.info> From: Ulf Hansson Date: Fri, 10 May 2024 12:43:25 +0200 Message-ID: Subject: Re: [PATCH V2] OPP: Fix required_opp_tables for multiple genpds using same table To: Linux regressions mailing list , Viresh Kumar Cc: Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , linux-pm@vger.kernel.org, Vincent Guittot , Vladimir Lypak , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Fri, 10 May 2024 at 10:54, Linux regression tracking (Thorsten Leemhuis) wrote: > > On 10.05.24 10:37, Ulf Hansson wrote: > > On Thu, 9 May 2024 at 14:35, Thorsten Leemhuis > > wrote: > >> On 12.04.24 08:41, Viresh Kumar wrote: > >>> The required_opp_tables parsing is not perfect, as the OPP core does the > >>> parsing solely based on the DT node pointers. > >>> > >>> The core sets the required_opp_tables entry to the first OPP table in > >>> the "opp_tables" list, that matches with the node pointer. > >>> > >>> If the target DT OPP table is used by multiple devices and they all > >>> create separate instances of 'struct opp_table' from it, then it is > >>> possible that the required_opp_tables entry may be set to the incorrect > >>> sibling device. > >>> > >>> Unfortunately, there is no clear way to initialize the right values > >>> during the initial parsing and we need to do this at a later point of > >>> time. > >>> > >>> Cross check the OPP table again while the genpds are attached and fix > >>> them if required. > >>> > >>> Also add a new API for the genpd core to fetch the device pointer for > >>> the genpd. > >>> > >>> Cc: Thorsten Leemhuis > >>> Reported-by: Vladimir Lypak > >>> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218682 > >> > >> Did this fall through the cracks? Just wondering, as from here it looks > >> like for about four weeks now nothing happened to fix the regression > >> linked above. But I might have missed something. Or is everybody waiting > >> for a test from the reporter? > > > > I have chatted a bit with Viresh about this problem offlist, while > > both me and him are/have been on vacations. Sorry for the delay and > > confusion. > > > > The latest update from my side is that I am working on a solution, > > that aim to remove the entire dev|devm_pm_opp_detach_genpd() API. > > That sounds like something that would have to wait for a merge window; > so given the timing I assume this would mean that the earliest point in > time to merge this would be for 6.11-rc1, which is ~2 months away -- > plus another 9 or 10 weeks until the fix would reach users. Right. > > > Instead, the plan is to move consumer drivers to use > > dev_pm_domain_attach_list() to attach multiple PM domains per device. > > When it comes to hooking up the required-opps-tables/devs, I think > > genpd should be able to manage this during the device attach process. > > In this way, consumer drivers shouldn't need to care about this at > > all. > > > > That said, I am hoping that $subject patch should not be needed. > > Although, I need a bit more time before I am ready to post a patchset > > for the above. > > > > What do you think? > > Given that the report is already more than a month old now and what I > assumed above (which might be wrong), this makes me wonder: is there a > downside if we apply this patch now, and simply revert this later when > your proper solution is merged? I would assume that is what Linus want > in this case to honor the "no regressions" rule. Sure, I am certainly okay with this approach too! > > Might be something different if this is something like a really odd > corner case we assume nobody (or nearly nobody) will run into in > practice. But as somebody noticed this, I assume that is not the case. I wasn't sure of the level of urgency in this case, as I don't think we have that many DTSes upstream that could hit this case. But nevermind, it should be easy to revert/replace the change when we have something better to take over. Viresh, feel pick this up - or let me know if you prefer me to pick it. Reviewed-by: Ulf Hansson Kind regards Uffe > > Ciao, Thorsten > > >>> Co-developed-by: Vladimir Lypak > >>> Signed-off-by: Viresh Kumar > >>> --- > >>> V2: > >>> - Fix an `if` condition. > >>> - s/Bugzilla/Closes/ and change ordering. > >>> > >>> drivers/opp/core.c | 31 ++++++++++++++++++++++++++++++- > >>> drivers/pmdomain/core.c | 10 ++++++++++ > >>> include/linux/pm_domain.h | 6 ++++++ > >>> 3 files changed, 46 insertions(+), 1 deletion(-) > >>> > >>> diff --git a/drivers/opp/core.c b/drivers/opp/core.c > >>> index e233734b7220..cb4611fe1b5b 100644 > >>> --- a/drivers/opp/core.c > >>> +++ b/drivers/opp/core.c > >>> @@ -2394,7 +2394,8 @@ static void _opp_detach_genpd(struct opp_table *opp_table) > >>> static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev, > >>> const char * const *names, struct device ***virt_devs) > >>> { > >>> - struct device *virt_dev; > >>> + struct device *virt_dev, *gdev; > >>> + struct opp_table *genpd_table; > >>> int index = 0, ret = -EINVAL; > >>> const char * const *name = names; > >>> > >>> @@ -2427,6 +2428,34 @@ static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev, > >>> goto err; > >>> } > >>> > >>> + /* > >>> + * The required_opp_tables parsing is not perfect, as the OPP > >>> + * core does the parsing solely based on the DT node pointers. > >>> + * The core sets the required_opp_tables entry to the first OPP > >>> + * table in the "opp_tables" list, that matches with the node > >>> + * pointer. > >>> + * > >>> + * If the target DT OPP table is used by multiple devices and > >>> + * they all create separate instances of 'struct opp_table' from > >>> + * it, then it is possible that the required_opp_tables entry > >>> + * may be set to the incorrect sibling device. > >>> + * > >>> + * Cross check it again and fix if required. > >>> + */ > >>> + gdev = dev_to_genpd_dev(virt_dev); > >>> + if (IS_ERR(gdev)) > >>> + return PTR_ERR(gdev); > >>> + > >>> + genpd_table = _find_opp_table(gdev); > >>> + if (!IS_ERR(genpd_table)) { > >>> + if (genpd_table != opp_table->required_opp_tables[index]) { > >>> + dev_pm_opp_put_opp_table(opp_table->required_opp_tables[index]); > >>> + opp_table->required_opp_tables[index] = genpd_table; > >>> + } else { > >>> + dev_pm_opp_put_opp_table(genpd_table); > >>> + } > >>> + } > >>> + > >>> /* > >>> * Add the virtual genpd device as a user of the OPP table, so > >>> * we can call dev_pm_opp_set_opp() on it directly. > >>> diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c > >>> index 4215ffd9b11c..c40eda92a85a 100644 > >>> --- a/drivers/pmdomain/core.c > >>> +++ b/drivers/pmdomain/core.c > >>> @@ -184,6 +184,16 @@ static struct generic_pm_domain *dev_to_genpd(struct device *dev) > >>> return pd_to_genpd(dev->pm_domain); > >>> } > >>> > >>> +struct device *dev_to_genpd_dev(struct device *dev) > >>> +{ > >>> + struct generic_pm_domain *genpd = dev_to_genpd(dev); > >>> + > >>> + if (IS_ERR(genpd)) > >>> + return ERR_CAST(genpd); > >>> + > >>> + return &genpd->dev; > >>> +} > >>> + > >>> static int genpd_stop_dev(const struct generic_pm_domain *genpd, > >>> struct device *dev) > >>> { > >>> diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h > >>> index 772d3280d35f..f24546a3d3db 100644 > >>> --- a/include/linux/pm_domain.h > >>> +++ b/include/linux/pm_domain.h > >>> @@ -260,6 +260,7 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, > >>> int pm_genpd_init(struct generic_pm_domain *genpd, > >>> struct dev_power_governor *gov, bool is_off); > >>> int pm_genpd_remove(struct generic_pm_domain *genpd); > >>> +struct device *dev_to_genpd_dev(struct device *dev); > >>> int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state); > >>> int dev_pm_genpd_add_notifier(struct device *dev, struct notifier_block *nb); > >>> int dev_pm_genpd_remove_notifier(struct device *dev); > >>> @@ -307,6 +308,11 @@ static inline int pm_genpd_remove(struct generic_pm_domain *genpd) > >>> return -EOPNOTSUPP; > >>> } > >>> > >>> +static inline struct device *dev_to_genpd_dev(struct device *dev) > >>> +{ > >>> + return ERR_PTR(-EOPNOTSUPP); > >>> +} > >>> + > >>> static inline int dev_pm_genpd_set_performance_state(struct device *dev, > >>> unsigned int state) > >>> { > > > >