Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp757544ybz; Fri, 17 Apr 2020 09:30:34 -0700 (PDT) X-Google-Smtp-Source: APiQypIEt8Q4u0AEwd3DCGBvO08r52V9uNSL7eXltDZBp2Xh0W94q8ydjCZzXmxmBQkClDAu1HEH X-Received: by 2002:a05:6402:1d89:: with SMTP id dk9mr3780864edb.382.1587141034054; Fri, 17 Apr 2020 09:30:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587141034; cv=none; d=google.com; s=arc-20160816; b=IN4aLVMTYRSoPrcwM5/xKiF9FNsXA7QTSHAySQSHa+kGAgKlWvDpV02h5B55+toRbt jTnxzhMVmz/KAjLtBcTJP+jzxxQqqESBzWTpGYiCOxIY/JPDw5CcrK51tFUhB/Wvmtzj R33Q3dpYZBttfYCULuCijML2C3odiaAAzGYU7nvPISrxBTDeL+0XR32eEi+F08hzOgrX 9eQJoXwVWZH788+9d/A+7WVis/vTJ0PctV5FHK5oOfGKoC7dOgFIw5j81TW1yENLSLv9 y3BKRLj2MNaM+f7IDNHcFWxUs60yYyRszHM/cZ8hKBiUz12sUPkPRDZmX+sXX+gvGUEs jFzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=2z3mooA7/6Ocg3+WvkJvbFNngZHx4PdkcY5PQ8E+L84=; b=N5masEHZMB5tiJJRfR84pDZwg86DQ7JY1+f5oi1vV1d72PjcWX1N/Cfy0XSAYAVwUm a/HGFS9LTGodhkebWT9FRdusMi6IccmPpVX+dhb47/lZC4A/o9nzTyocDGv37t9LX9C1 a61XFz+Fsk98Sc96Aij8wv/OVdhSUIhH42gcwdG4PXhgcy/gPdxGmbmFO/8YUTFCrmdn wwJWiCCxTp0yLzMMKAO5oyu+BWjWGs9FMb7gcaO4qj5bTUsjBFwyjNqa/HKExHSiNIV/ lpj1MqJ2wnB2ZevTfCmleUwSOMW2yY7HBwnKL04h3egnL6LYO4BbHV3/+sRkwLFbOCS6 XH0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=wRo+tMLZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m1si14099786edf.277.2020.04.17.09.30.09; Fri, 17 Apr 2020 09:30:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@ti.com header.s=ti-com-17Q1 header.b=wRo+tMLZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726435AbgDQQ2n (ORCPT + 99 others); Fri, 17 Apr 2020 12:28:43 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:40448 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726366AbgDQQ2n (ORCPT ); Fri, 17 Apr 2020 12:28:43 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 03HGSfU3065131; Fri, 17 Apr 2020 11:28:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1587140921; bh=2z3mooA7/6Ocg3+WvkJvbFNngZHx4PdkcY5PQ8E+L84=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=wRo+tMLZHdlqPLNZIeRd/l5snCcojXUO4Dk815QnJFKe+m7FunSDmHTHKsi1TBkFV JIMfTe3fIqRsOYNXwxBxto0TFkHfYDIXYlsATkg75J7owczFcdFYm4EW45vJ4Y1z2U gq1cG0gmVVzm7VavbKmCFlH+BiL5KYmxc9wvNjMw= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id 03HGSeAA015583; Fri, 17 Apr 2020 11:28:40 -0500 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Fri, 17 Apr 2020 11:28:40 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Fri, 17 Apr 2020 11:28:40 -0500 Received: from [10.250.48.148] (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 03HGSe1s073086; Fri, 17 Apr 2020 11:28:40 -0500 Subject: Re: [PATCH 3/3] remoteproc: qcom_q6v5_mss: fix q6v5_probe() error paths To: Alex Elder , Bjorn Andersson , Ohad Ben-Cohen , Andy Gross CC: , , References: <20200403175005.17130-1-elder@linaro.org> <20200403175005.17130-4-elder@linaro.org> From: Suman Anna Message-ID: <0f0a9d92-bcd9-0fd0-8003-b93ae4d230b4@ti.com> Date: Fri, 17 Apr 2020 11:28:40 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200403175005.17130-4-elder@linaro.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/3/20 12:50 PM, Alex Elder wrote: > If an error occurs in q6v5_probe() after the proxy power domains > are attached, but before qcom_add_ipa_notify_subdev() is called, > qcom_remove_ipa_notify_subdev() is called in the error path, which > is a bug. Fix this by having that call be reached through a > different label. > > Additionally, if qcom_add_sysmon_subdev() returns an error, the > subdevs that had already been added will not be properly removed. > Fix this by having the added subdevs (including the IPA notify one) > be removed in this case. > > Finally, arrange for the sysmon subdev to be removed before the rest > in the event rproc_add() returns an error. > > Have cleanup activity done in q6v5_remove() be done in the reverse > order they are set up in q6v5_probe() (the same order they're done > in the q6v5_probe() error path). Use a local variable for the > remoteproc pointer, which is used repeatedly. > > Remove errant semicolons at the end of two function blocks. > Same as Patch 2, Fixes: line would be good. regards Suman > Signed-off-by: Alex Elder > --- > drivers/remoteproc/qcom_q6v5_mss.c | 31 ++++++++++++++++++------------ > 1 file changed, 19 insertions(+), 12 deletions(-) > > diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c > index 60cdf699ea80..5475d4f808a8 100644 > --- a/drivers/remoteproc/qcom_q6v5_mss.c > +++ b/drivers/remoteproc/qcom_q6v5_mss.c > @@ -367,7 +367,7 @@ static int q6v5_pds_enable(struct q6v5 *qproc, struct device **pds, > } > > return ret; > -}; > +} > > static void q6v5_pds_disable(struct q6v5 *qproc, struct device **pds, > size_t pd_count) > @@ -1527,7 +1527,7 @@ static int q6v5_pds_attach(struct device *dev, struct device **devs, > dev_pm_domain_detach(devs[i], false); > > return ret; > -}; > +} > > static void q6v5_pds_detach(struct q6v5 *qproc, struct device **pds, > size_t pd_count) > @@ -1766,17 +1766,23 @@ static int q6v5_probe(struct platform_device *pdev) > qproc->sysmon = qcom_add_sysmon_subdev(rproc, "modem", 0x12); > if (IS_ERR(qproc->sysmon)) { > ret = PTR_ERR(qproc->sysmon); > - goto detach_proxy_pds; > + goto remove_subdevs; > } > > ret = rproc_add(rproc); > if (ret) > - goto detach_proxy_pds; > + goto remove_sysmon_subdev; > > return 0; > > +remove_sysmon_subdev: > + qcom_remove_sysmon_subdev(qproc->sysmon); > +remove_subdevs: > + qcom_remove_ipa_notify_subdev(qproc->rproc, &qproc->ipa_notify_subdev); > + qcom_remove_ssr_subdev(rproc, &qproc->ssr_subdev); > + qcom_remove_smd_subdev(rproc, &qproc->smd_subdev); > + qcom_remove_glink_subdev(rproc, &qproc->glink_subdev); > detach_proxy_pds: > - qcom_remove_ipa_notify_subdev(qproc->rproc, &qproc->ipa_notify_subdev); > q6v5_pds_detach(qproc, qproc->proxy_pds, qproc->proxy_pd_count); > detach_active_pds: > q6v5_pds_detach(qproc, qproc->active_pds, qproc->active_pd_count); > @@ -1789,19 +1795,20 @@ static int q6v5_probe(struct platform_device *pdev) > static int q6v5_remove(struct platform_device *pdev) > { > struct q6v5 *qproc = platform_get_drvdata(pdev); > + struct rproc *rproc = qproc->rproc; > > - rproc_del(qproc->rproc); > + rproc_del(rproc); > > qcom_remove_sysmon_subdev(qproc->sysmon); > - qcom_remove_ipa_notify_subdev(qproc->rproc, &qproc->ipa_notify_subdev); > - qcom_remove_glink_subdev(qproc->rproc, &qproc->glink_subdev); > - qcom_remove_smd_subdev(qproc->rproc, &qproc->smd_subdev); > - qcom_remove_ssr_subdev(qproc->rproc, &qproc->ssr_subdev); > + qcom_remove_ipa_notify_subdev(rproc, &qproc->ipa_notify_subdev); > + qcom_remove_ssr_subdev(rproc, &qproc->ssr_subdev); > + qcom_remove_smd_subdev(rproc, &qproc->smd_subdev); > + qcom_remove_glink_subdev(rproc, &qproc->glink_subdev); > > - q6v5_pds_detach(qproc, qproc->active_pds, qproc->active_pd_count); > q6v5_pds_detach(qproc, qproc->proxy_pds, qproc->proxy_pd_count); > + q6v5_pds_detach(qproc, qproc->active_pds, qproc->active_pd_count); > > - rproc_free(qproc->rproc); > + rproc_free(rproc); > > return 0; > } >