From patchwork Fri Jul 9 12:56:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 471817 Delivered-To: patches@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp265556jao; Fri, 9 Jul 2021 05:56:21 -0700 (PDT) X-Received: by 2002:a2e:5812:: with SMTP id m18mr11123630ljb.394.1625835381343; Fri, 09 Jul 2021 05:56:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625835381; cv=none; d=google.com; s=arc-20160816; b=G9E2XopS4RIYF5qUdD4Jc8EH48Oq9oCJC2JfXOq7CMMeL2IuisONGnaLEuby2Qx0j3 y6tVkm0F+ZTZxDQETyHvy3gxr9/YOIJlyzEGbr6a4zNKiAmF7Vwwde0zEBn2yOVr96ct r8uo6W19K5YqS/+2YdBAf0iXtMBFUkuTEB1PE8Zm9s01c456YZ3f7pWJa1ZjpCocunUF jYY5piHjEMm9OO87uSmNSNJnyQcei8gAgFCKTuHhM3rHdY7HhHGxdH3cgUbImImjVj+Z fDbST804CwMxSvHq1pPhnq9n9v63MM7CKV6Jb/g6hOf/3mPRvp6CGknAMbpHH/vVCF/P Z6aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=pmQouUwnHXSB4OdiUD3dDMTm+uNqG32/fIygOWS1rqk=; b=tFjCWdg0nqGVWAfWDAxDhKy94XOw6wg3jCGpbW/e6kFoDJHGNFnTvpGUUFyQof2kge cN19qtb2vPLyXoeIaOz36QUBr+OqP7EN+JUT67H5f+Zodritvt7zZ/fn1reKQxZfPY2y dvI9tLpyYu7Hpg9PHEIxdss6TNIY6Mxk6XptQCcO9xqHPO8w1opVcLx2XYaT9P3xDZpt hZkoO+lmyEN7ybfCcLOE6znGZv8JL3LHgRgLa13I6VHZC+sD+qSENmfcV50Tmafg/cvZ QLdq3K2LPQk8X+LmzWsmeFr5813rLfhAuWjwL4IIO2Bfk+aY/8cO2aoCHD/aaqcoAiGK RsBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TNKFzaJY; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id i7sor2194257ljn.54.2021.07.09.05.56.21 for (Google Transport Security); Fri, 09 Jul 2021 05:56:21 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TNKFzaJY; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pmQouUwnHXSB4OdiUD3dDMTm+uNqG32/fIygOWS1rqk=; b=TNKFzaJYG6b/K8hMZsQR7UYuFjKqUsAHnAEfeDxwl7ckEscf2i5Exwp88H0e7TaCgf M1afe6FMM0NJYlHmc1SSrDADUNI7CMYsSyXfFNww2GK55OFVtTNVep48yJuhNHe07xSo ZoLL+JQ20Yuwct0eB1oNBH1gJ650Z+SNC9hmpVOPQeDzNJLFYbh/WipSsiYTAlPUJbCg ZytnNWUbSRGFe69YGizzFEevlVfn8N1Sdwz3y0j6SZMrZoaM6X1ULChOtDXQEFgy2NIL ux+oyFxFuDHErBIjFhDiDFzwCyDPMyFNnpZeycoBxp4ToRXu4UyXZDsNymtrnLoihPA3 ABjQ== 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:mime-version :content-transfer-encoding; bh=pmQouUwnHXSB4OdiUD3dDMTm+uNqG32/fIygOWS1rqk=; b=Lp4JRQnEY+Ka6uLgkm7ScMhjgh8KYB4mfQeHwtZgxD6R9P58SUlvca+7gJBp4Dbwb9 xHIt1tmRvfqeqb3CtQk/tPZAydoSQTTdioDIK0kEoISyb/NFEDMgIeCcPmgHoP71R+nL 0QLs1lsGs6IVak5F4fACjO7A3lhXvLCqaSea/pePo304Y+LtCXGplCjkHzxqYi9KVr2C rP12TdLh3+xSQ+EjybavDfYY4XO+tb9EySzvVyIPBo4pl5qWPTU/ye8Hf7Bp2Bak5w87 uGuCSrQSIpoAVmECctd67DVQD4wgQsA0+B9uANiORvMtRyiF4G88ynTmnM+iv6Aq+IY8 aAwQ== X-Gm-Message-State: AOAM532q8Wa/+hxXRlE4rszMQTf8aOQ/7lksi1gVU769C4JyitTQCb8E zBwcNYFWS/jaqRE0CFrR2gTL8EZR X-Google-Smtp-Source: ABdhPJws6OEf65ZuRSjGD6inMZ75FyrYIUnjQzy1kEHtRfxPsLOsHjSEXRvBaqrzpe/ko9aygtFZRA== X-Received: by 2002:a05:651c:210:: with SMTP id y16mr14067901ljn.437.1625835380940; Fri, 09 Jul 2021 05:56:20 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-129-146.NA.cust.bahnhof.se. [155.4.129.146]) by smtp.gmail.com with ESMTPSA id q5sm462097lfr.37.2021.07.09.05.56.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 05:56:19 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Bjorn Andersson , Stephen Boyd , Saravana Kannan , Dmitry Baryshkov , Kevin Hilman , Geert Uytterhoeven , Ulf Hansson , linux-kernel@vger.kernel.org Subject: [PATCH] PM: domains: Don't attach a device to genpd that corresponds to a provider Date: Fri, 9 Jul 2021 14:56:11 +0200 Message-Id: <20210709125611.135920-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 According to the common power domain DT bindings, a power domain provider must have a "#power-domain-cells" property in its OF node. Additionally, if a provider has a "power-domains" property, it means that it has a parent domain. It has turned out that some OF nodes that represents a genpd provider may also be compatible with a regular platform device. This leads to, during probe, genpd_dev_pm_attach(), genpd_dev_pm_attach_by_name() and genpd_dev_pm_attach_by_id() tries to attach the corresponding struct device to the genpd provider's parent domain, which is wrong. Instead the genpd provider should only assign a parent domain, through pm_genpd_add_subdomain() or of_genpd_add_subdomain(). Let's fix this problem in genpd by checking for the "#power-domain-cells" property in the OF node for the struct device that is about to be attached. Signed-off-by: Ulf Hansson --- This turned up when I was reviewing a couple of genpd realted Qcom patches [1], from Dmitry Baryshkov (on cc). I haven't been able to run much tests, so help with that would be greatly appreciated. If someone encounter issues, I am happy to help to fix those. Kind regards Ulf Hansson [1] https://lkml.org/lkml/2021/7/9/7 https://lkml.org/lkml/2021/7/9/8 --- drivers/base/power/domain.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.25.1 Reported-by: kernel test robot Reported-by: kernel test robot diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index a934c679e6ce..21991fb56a19 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2699,6 +2699,10 @@ int genpd_dev_pm_attach(struct device *dev) if (!dev->of_node) return 0; + /* Don't try to attach a genpd provider. */ + if (of_find_property(dev->of_node, "#power-domain-cells", NULL)) + return NULL; + /* * Devices with multiple PM domains must be attached separately, as we * can only attach one PM domain per device. @@ -2737,6 +2741,10 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev, if (!dev->of_node) return NULL; + /* Don't try to attach a genpd provider. */ + if (of_find_property(dev->of_node, "#power-domain-cells", NULL)) + return NULL; + /* Verify that the index is within a valid range. */ num_domains = of_count_phandle_with_args(dev->of_node, "power-domains", "#power-domain-cells");