From patchwork Wed Jun 30 22:59:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 468741 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp786440jao; Wed, 30 Jun 2021 16:00:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHmZoizXRLvKh6oHOniW4fgz4kmXesr/NeAz0pSGd+419AIjWZSfZnzrY+FpWEf0yY9AWU X-Received: by 2002:a17:907:3d8e:: with SMTP id he14mr37580302ejc.374.1625094003386; Wed, 30 Jun 2021 16:00:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625094003; cv=none; d=google.com; s=arc-20160816; b=Eado6NTxA3pIYD+BHyGKZTeVlsPqVVMPXuy1ldhb/k8OMZOnFJVkENEsanr53FG0hB y12IEW+5HnXeh5xnMkVveLzHATiAXZ5ubES2FaiRg5rgWZVEDNfn7TUxpVr1xVHkjy+r 5KO5cBeGgvAJ6xX9fj4OF6AGm6Vscrksoka+BEUA/k2AV37YvyMmZ2vM8Kpj+cuJjP13 S7OKKVrP+YLFuywqPaXy/E7iiWiCy4I0EHM+AIBxUQiFU3C4qnyqJ1hjovHuq/Ixxgj5 fPdrX60C+r0US0svmZgDPCuxt4tRcxWm6E3tc9/mEv8w0mBjR8wJmW1BDdabnST8WL9H 7njQ== 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=lPH2sT2kWyJ067X+i8qH7IKutZ8IRpZkl3/aR7wJJdc=; b=PsaLzOXS3/mRmA1Th5vTwj+bzPHJ9fPkF8LQ6fBi0b9smz0Nm5jigcqn6xyqMuPAtd Im+b8+4GYmYLWOh4/0zd8yFZ2KaRXO0VXrVoxDEGVL1PjEbAEswdIPHwJNkIPcXoHgwF XS2MQcOnkk1CR9RWSmvaLAbgUK7dbTRjvvc8jJe8uo00fIhtonjNjBDd0ndh0NPeJK6/ OjS6g6ga2kY7Tzx7SSsf6q5nylwY94CwnCw9F67psvT7Ei5+xDAQ012xep8sEyJvOi2L Aro6yt5K+/jJRSss3mNAXzD4QgpSWowpTIqD+8Ulnv5MX+jckTcexLDbRdhtubtLIFeS G8sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=emPuOvHn; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 g22si291785edp.69.2021.06.30.16.00.02; Wed, 30 Jun 2021 16:00:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-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=emPuOvHn; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S233650AbhF3XCb (ORCPT + 17 others); Wed, 30 Jun 2021 19:02:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232559AbhF3XCa (ORCPT ); Wed, 30 Jun 2021 19:02:30 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9658BC0617AE for ; Wed, 30 Jun 2021 16:00:00 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id k10so8041769lfv.13 for ; Wed, 30 Jun 2021 16:00:00 -0700 (PDT) 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=lPH2sT2kWyJ067X+i8qH7IKutZ8IRpZkl3/aR7wJJdc=; b=emPuOvHntGovS+gGBec8JXp3MFU3Fqi64Tat79stxSN9pfzFwJZqYAYafN42s302Gf xiZXXQGLinDFP0+CV0NnGCypjPPOe4tQS2ztvaSxA3LiR0lunHuAmnfaI8VmfyWQVddq 3ibrZdLam7hT/lY70r8jnF0ZZ3BNCKjWrKhtfEu6kK5m1ZrZ88gAIkEQd7ly5XXMHNnN UzF9U/xEBi1QXuoEPkymcsgedTOBRLJLcJZN/A1CpTyYjrsb8M1OF812ozi/T0QvvHS2 wp5YZaBtBjl+XasmpQGHlG2M7K9BLyeRtBaqTQQgyC2OOvU+MUy9Y/XEvI7cvR5u4HRA 8Nqw== 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=lPH2sT2kWyJ067X+i8qH7IKutZ8IRpZkl3/aR7wJJdc=; b=QeYtR+QiafhkZiewu6QRrNQlTR1Bi4Q7EldsuRP/t01X7CwMxw44p8FWzPYKr+gWQr vBnMXNdCnkZI8GzkhRNJpdAI2CG0+atW3E9FqEMCRfLWqi5VXUwG871qSuY5rWkotrix OGNy0tscSo+Kk1SRgcO2jqGrwQ2zBmp164z1Iz/XGYyPCvf3wN4VkK/rjvquSzyaQbPu MECjoIC+C4n7Iu1nJFS6jqYZ4lvIewvz0S5Y2CODmNFKc+TwBJ331oA//mdw45tPdFSo htL2EuRjFYACRxy1eUJmDjyyJqT9c4JA1/3FxGzD764U+M19gscGoBytHhRDrvoagW2Q T/vg== X-Gm-Message-State: AOAM531pePJphIrVy7v2dWTFpm7tdGqAnb0QBqxSdsfr8R/Xpf71wiWV mWIpaHHMwcRM4+0e5jRFYxB4dSD+3X7BCw== X-Received: by 2002:a19:f11a:: with SMTP id p26mr888825lfh.113.1625093998965; Wed, 30 Jun 2021 15:59:58 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id e17sm2324444ljn.125.2021.06.30.15.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 15:59:58 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Stephen Boyd , Michael Turquette , Taniya Das Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org Subject: [PATCH v2 1/2] clk: qcom: fix error_path in gdsc_register Date: Thu, 1 Jul 2021 01:59:51 +0300 Message-Id: <20210630225952.3337630-2-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210630225952.3337630-1-dmitry.baryshkov@linaro.org> References: <20210630225952.3337630-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Properly handle and cleanup errors in gdsc_register() instead of just returning an error and leaving some of resources registered/hanging in the system. Fixes: c2c7f0a47493 ("clk: qcom: gdsc: Add support for hierarchical power domains") Fixes: 45dd0e55317c ("clk: qcom: Add support for GDSCs") Signed-off-by: Dmitry Baryshkov --- drivers/clk/qcom/gdsc.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) -- 2.30.2 diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c index 51ed640e527b..241186d9d08c 100644 --- a/drivers/clk/qcom/gdsc.c +++ b/drivers/clk/qcom/gdsc.c @@ -429,7 +429,7 @@ int gdsc_register(struct gdsc_desc *desc, scs[i]->rcdev = rcdev; ret = gdsc_init(scs[i]); if (ret) - return ret; + goto err_init; data->domains[i] = &scs[i]->pd; } @@ -437,11 +437,35 @@ int gdsc_register(struct gdsc_desc *desc, for (i = 0; i < num; i++) { if (!scs[i]) continue; - if (scs[i]->parent) - pm_genpd_add_subdomain(scs[i]->parent, &scs[i]->pd); + if (scs[i]->parent) { + ret = pm_genpd_add_subdomain(scs[i]->parent, &scs[i]->pd); + if (ret) + goto err_subdomain; + } } - return of_genpd_add_provider_onecell(dev->of_node, data); + ret = of_genpd_add_provider_onecell(dev->of_node, data); + if (!ret) + return 0; + +err_subdomain: + i--; + for (; i >= 0; i--) { + if (!scs[i] || !scs[i]->parent) + continue; + pm_genpd_remove_subdomain(scs[i]->parent, &scs[i]->pd); + } + i = num; + +err_init: + i--; + for (; i >= 0; i--) { + if (!scs[i]) + continue; + pm_genpd_remove(&scs[i]->pd); + } + + return ret; } void gdsc_unregister(struct gdsc_desc *desc) From patchwork Wed Jun 30 22:59:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 468743 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp786477jao; Wed, 30 Jun 2021 16:00:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxt3yYORSox3rzrHUwSzeS5yDBw7JHq7nmoHI/yeTb+ohBE+fUnPUynbldGrK+/Zywa7mwE X-Received: by 2002:a05:6402:1297:: with SMTP id w23mr1270810edv.311.1625094005704; Wed, 30 Jun 2021 16:00:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625094005; cv=none; d=google.com; s=arc-20160816; b=HxHEpIJHm924dB3RpkgWt2s/VMht5i26FzUG+45eWJaTAytfp33CAh+VCz+oFwNi46 pvxVQ/MUopxs81vQyMSL31GJTK2++/swESTr472OLUUV4ic20Z8z7Q2DBvePPUNBOMVf lpV5TJgRiMEDzTdY9p8rUAPGbY0Fu+t1ptg158FOQprMC608xNgRMp4E2kLYn09GgRPh YvLXOzFDLEH7RFB0VfN8X7CsPuyVP3vGqZTMyx8SD5nH1475WRLzhEyvDTibSJqymlAE BNxPGxSlUWe4RYr0PqzgQpSpFPkn1CQyqFtgcqGajpp16H4O4NdcejyvueFhBUYDBX9k vEHw== 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=k2pJB7kzaE3cwUXfHhNQ/snYVpRf0hIxIEPV1H568iM=; b=me7qxnQPfajl7JZB9m2GPyIsaLefW36zjrZDtRDHf3dGc/6eREPEnX9vqSJF1JWPmK bkvs9QuCreck0ceE595v80i5sJb0Zn8mKj5BmwH4aMy39TYM7SWff+Bgik/HgkSZIBUN 88D6IkMqJjUwQoZddZYjhSBzrKlLiL4T68ZkUbawGi9oM7xIEqy9815VxYNHO3srDmHH 5tiPS8KuZmVUdgNZtJ+HGQ9Tj9Z/xQ/3um/7tFJH25KSdeEgjrIiLBC4Pc85BlbPm7vs 0bJgNCtg+41tTfJAgQzCVz3zOAzZWSEKK2bpSfxSUjMAFky8eU0r9iNxyTqt4vSXY1Pa gnmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WQMWBbh5; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 g22si291785edp.69.2021.06.30.16.00.05; Wed, 30 Jun 2021 16:00:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-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=WQMWBbh5; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S234014AbhF3XCc (ORCPT + 17 others); Wed, 30 Jun 2021 19:02:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233996AbhF3XCc (ORCPT ); Wed, 30 Jun 2021 19:02:32 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69B74C0617AF for ; Wed, 30 Jun 2021 16:00:01 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id q4so5535883ljp.13 for ; Wed, 30 Jun 2021 16:00:01 -0700 (PDT) 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=k2pJB7kzaE3cwUXfHhNQ/snYVpRf0hIxIEPV1H568iM=; b=WQMWBbh5E7uFL+sdKynMR23K2epZrvv3d4qdbf6GF8N9TPFO3CTH0nNaPMpQr18zHI NchhLl8+kfXh/baqTNO1GQ4rAya8/b7DrXUKXQaEN3I5ypnoERDP8gc9GS6Sv2oTbBYX DaljhoS7YvfdC4yRH9Mq28F6CpU/ksYEadAkiTrFWciqbkP6YOLfgALE8w7PrzBOeU2T /N4Im75cLDoShtIRLMI8noQL+QMpYvvMUa9+i4NqG7vwPe599oMj9VB6F8K0/nodcTGC i5B53MoDqmG+Ut53PmgeiYGgw26akNXOD/Uxpn9NUkbuI2R//4vE1uUW7pFeycjMMEpS kAow== 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=k2pJB7kzaE3cwUXfHhNQ/snYVpRf0hIxIEPV1H568iM=; b=bZpdssgGpmlGTuki7J+yHGjbPJviqdfHdlPMLj3OLBbbc0f4hYWuN8Uh+wWnurcAni ADAAQ1f2+hWFFw5DPqkgOIbr8yK2to+kKXgPzyypomPmqmJyEulnF6cTlKCOEObanvbZ SN0RGg07ec/jC+3QvlJjtar1IzZC0ZDNkJtY4VP++1uLziBI5r8HjtnPBGj6pkfLj87K b4qyu7+NRtDOHmYwIqv8Yk74o5khHpXAgHha0L8ZwgF+pfmDJRJmRIrc8VnWkhH5pkrA F0/fo97Ik0Fqvi/ohUCw3FuOySdZsyRuJZRgJUXlGoHiQ6+eqyg1HEY+uOqmQQUKUyf4 ATJg== X-Gm-Message-State: AOAM532wD1HSmm5hZjh4y8igaxD2fAm/0X/sTybRZx5u7ffaihWaLOje 9iAiXQOMmhVCc2lPmYfaKY+png== X-Received: by 2002:a2e:6d12:: with SMTP id i18mr9640228ljc.88.1625093999698; Wed, 30 Jun 2021 15:59:59 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id e17sm2324444ljn.125.2021.06.30.15.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 15:59:59 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Stephen Boyd , Michael Turquette , Taniya Das Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org Subject: [PATCH v2 2/2] clk: qcom: fix domains cleanup in gdsc_unregister Date: Thu, 1 Jul 2021 01:59:52 +0300 Message-Id: <20210630225952.3337630-3-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210630225952.3337630-1-dmitry.baryshkov@linaro.org> References: <20210630225952.3337630-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Properly remove registered genpds. Also remove the provider before breaking parent/child links, so that the system is consistent at remove time. Fixes: c2c7f0a47493 ("clk: qcom: gdsc: Add support for hierarchical power domains") Fixes: 45dd0e55317c ("clk: qcom: Add support for GDSCs") Signed-off-by: Dmitry Baryshkov --- drivers/clk/qcom/gdsc.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) -- 2.30.2 diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c index 241186d9d08c..9e16f234ce6c 100644 --- a/drivers/clk/qcom/gdsc.c +++ b/drivers/clk/qcom/gdsc.c @@ -475,14 +475,26 @@ void gdsc_unregister(struct gdsc_desc *desc) struct gdsc **scs = desc->scs; size_t num = desc->num; - /* Remove subdomains */ + /* + * Remove provider first so that we can remove the genpds without + * worrying about consumers getting them during the removal process. + */ + of_genpd_del_provider(dev->of_node); + + /* Break subdomain relationship */ for (i = 0; i < num; i++) { if (!scs[i]) continue; if (scs[i]->parent) pm_genpd_remove_subdomain(scs[i]->parent, &scs[i]->pd); } - of_genpd_del_provider(dev->of_node); + + /* And finally remove domains themselves */ + for (i = 0; i < num; i++) { + if (!scs[i]) + continue; + pm_genpd_remove(&scs[i]->pd); + } } /*