From patchwork Fri Apr 3 17:50:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 11473241 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 92A0515AB for ; Fri, 3 Apr 2020 17:50:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 713582080C for ; Fri, 3 Apr 2020 17:50:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="WjEZli5Y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403912AbgDCRuO (ORCPT ); Fri, 3 Apr 2020 13:50:14 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:44308 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404158AbgDCRuN (ORCPT ); Fri, 3 Apr 2020 13:50:13 -0400 Received: by mail-qk1-f195.google.com with SMTP id j4so8857703qkc.11 for ; Fri, 03 Apr 2020 10:50:13 -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=+oLntqojuWdUH12fyW0ncnBZUNvUMEl0ST479v3SavI=; b=WjEZli5Y2ZbsGjbFRuKXBBPa3y4gFEAzTwatQ2IXdzW+4mBALDH3CECyepTjQmyzck 8JlCht3lbpb7d41uQlzpVDj81/Ln3rHLB81SJNxZ3M+Up+aLyA9UEfvA+QQqdRIB1kJO 0pl4vBdS21KLE8SK3DxXqs1t+iVJOgl++mQl2Z6vJVzfrUi7nX0n3487sv+cjzQVdPm5 /tcwo0NG+w25yzkjM0Aedf4IrMwAI77dwAGekhIu5mV/rVgJMrwXcDjKaLxmhBOgBsNr 9EjjTy/+OX4H1N2HGBgAjzg9cGembmRbKgloXYpfw3gsdJbnRH01JDgrXofUh7DGudNB T72w== 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=+oLntqojuWdUH12fyW0ncnBZUNvUMEl0ST479v3SavI=; b=kJFlBqPFilyRjdSzjMOiTjpxXZm3axdJOpKRzNfcYkgn6pY1Fq9Hil8us8xPKJkLDX OGSKg5xr+FFnrz2Ov7mkhDYimkks8jzl2fpwvYOODDRD1R5ji7EZX/ZuezThvZU73zUh 5WTmCU1Xiphv3jrmvm64NVXbLsj9UOx6HMQsLfdXFNvYvtioMV7Y3BOo89m9Pa4q5aEZ AMLiiqOm6Yq19U9fMP2SCfChhaCn1uVcyeplRkzLjIRZ+ZPxec/QuXXsb47K0kWGXH83 T83Kp9PY3aa2Sj44t3Zp0i7sR9sPiP4rkJ0CO3wUz+j2iSaR+QoQUH/8h8lsIdZFiUQ+ cIFw== X-Gm-Message-State: AGi0PuYAmDUmX+mThcMdpNQWe9ndjIL/JDLi8x9qdLIXpf1Y7aTLxJ74 /75Dx0gYTYnDReHFYqayhBoVYg== X-Google-Smtp-Source: APiQypIJYUesBNolCLhwv6B5eaa/K0FLECq529AU39kc1RoB8T/W83qqfbTOjo1T94kludYx50eMcQ== X-Received: by 2002:a37:e115:: with SMTP id c21mr9366907qkm.249.1585936212649; Fri, 03 Apr 2020 10:50:12 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id 77sm6821225qkh.26.2020.04.03.10.50.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 10:50:12 -0700 (PDT) From: Alex Elder To: Bjorn Andersson , Ohad Ben-Cohen , Andy Gross Cc: linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] remoteproc: fix a bug in rproc_alloc() Date: Fri, 3 Apr 2020 12:50:03 -0500 Message-Id: <20200403175005.17130-2-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200403175005.17130-1-elder@linaro.org> References: <20200403175005.17130-1-elder@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org If ida_simple_get() returns an error when called in rproc_alloc(), put_device() is called to clean things up. By this time the rproc device type has been assigned, with rproc_type_release() as the release function. The first thing rproc_type_release() does is call: idr_destroy(&rproc->notifyids); But at the time the ida_simple_get() call is made, the notifyids field in the remoteproc structure has not been initialized. I'm not actually sure this case causes an observable problem, but it's incorrect. Fix this by initializing the notifyids field before calling ida_simple_get() in rproc_alloc(). Signed-off-by: Alex Elder --- drivers/remoteproc/remoteproc_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index e12a54e67588..59b6eb22f01c 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2054,6 +2054,8 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, rproc->dev.class = &rproc_class; rproc->dev.driver_data = rproc; + idr_init(&rproc->notifyids); + /* Assign a unique device index and name */ rproc->index = ida_simple_get(&rproc_dev_index, 0, 0, GFP_KERNEL); if (rproc->index < 0) { @@ -2078,8 +2080,6 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, mutex_init(&rproc->lock); - idr_init(&rproc->notifyids); - INIT_LIST_HEAD(&rproc->carveouts); INIT_LIST_HEAD(&rproc->mappings); INIT_LIST_HEAD(&rproc->traces); From patchwork Fri Apr 3 17:50:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 11473239 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 54180159A for ; Fri, 3 Apr 2020 17:50:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3254E2077D for ; Fri, 3 Apr 2020 17:50:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iVNXp3/4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404324AbgDCRuY (ORCPT ); Fri, 3 Apr 2020 13:50:24 -0400 Received: from mail-qv1-f68.google.com ([209.85.219.68]:39346 "EHLO mail-qv1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404187AbgDCRuP (ORCPT ); Fri, 3 Apr 2020 13:50:15 -0400 Received: by mail-qv1-f68.google.com with SMTP id v38so4022303qvf.6 for ; Fri, 03 Apr 2020 10:50:14 -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=wAONRYcVO4RfP3C96vLmeLLooX/mPDYTON30vhuD5cY=; b=iVNXp3/43clmRsJeacYyRlYtzqzS5AZhSQ+jH/korT8/ktSvyrD0uBudRLip/aSzbx i3fJFMr+zBwDbnWF746bGQS1W+f+TGbLCuvbuOXaXJ7ewQ7lMgSeG3Ssyee9mXg+uzVS Rbu0gz0chlxDH3WByItA3qxFkhkTQV85EHb3nchE3AKLKGqXg8XLT3BVF6iSXkScPZ6I GMlPFqHdj346kWYJfx5lGdmdWN/KtzwrrgutCoguh4oAwvmNkyu3lFIYXare2g/obs1W DbsJZD8F4GEDNnS/+ggh7rbgTZHuuJmelaPmCCxAVtJO4yFwtDbDtXoH01+qbqmngOAN j1bg== 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=wAONRYcVO4RfP3C96vLmeLLooX/mPDYTON30vhuD5cY=; b=BXqAaHy7/iz6hH45wJ27BRfOK1iHNfxJOgR8mJKKlVIMHj2Fzoe58Ssosze3flkYqS q0Y1LWwWBC8GfIXHFROymIVtQYhkbezwdXxHTffWEHQEkGk47rDm83DlDI7/7p5qQR2Q scJXlZiB9HBOdb2WeMT0ILRcOa73hpcYjd17hy5D6hIFg90JRlDvwRc/OeYhwBAPJDYq dWS377MqYFKNJyqREY49za7HdzVkTAIRqKRVC1cnJXB+4I6lW7ze4Ou23MZ9Mu3Y/q6v /NifkCZAnKBejWek6Wqd4XvKuh4pKg1F7VSrhJi/A6I7UumsFyv7ByWczWbICyqC3CxV OrmA== X-Gm-Message-State: AGi0PuazUhfJX3SsgSBd8B3dTnQYN2JIJPxjQeZb3dmjHCF5ku7qcXaO KlQw6S0bUbcPmozMdBq8y10KtA== X-Google-Smtp-Source: APiQypJ8RDEp8OGf/STkumxgjzcqkfiVAr1Uw4MNFcGtFAkjN8HqNzwHWoaFlOk7r8uDk/0Zf+QGkw== X-Received: by 2002:a05:6214:1583:: with SMTP id m3mr9622282qvw.215.1585936213887; Fri, 03 Apr 2020 10:50:13 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id 77sm6821225qkh.26.2020.04.03.10.50.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 10:50:13 -0700 (PDT) From: Alex Elder To: Bjorn Andersson , Ohad Ben-Cohen , Andy Gross Cc: linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] remoteproc: qcom_q6v5_mss: fix a bug in q6v5_probe() Date: Fri, 3 Apr 2020 12:50:04 -0500 Message-Id: <20200403175005.17130-3-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200403175005.17130-1-elder@linaro.org> References: <20200403175005.17130-1-elder@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org If looking up the DT "firmware-name" property fails in q6v6_probe(), the function returns without freeing the remoteproc structure that has been allocated. Fix this by jumping to the free_rproc label, which takes care of this. Signed-off-by: Alex Elder --- drivers/remoteproc/qcom_q6v5_mss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c index ce49c3236ff7..60cdf699ea80 100644 --- a/drivers/remoteproc/qcom_q6v5_mss.c +++ b/drivers/remoteproc/qcom_q6v5_mss.c @@ -1675,7 +1675,7 @@ static int q6v5_probe(struct platform_device *pdev) ret = of_property_read_string_index(pdev->dev.of_node, "firmware-name", 1, &qproc->hexagon_mdt_image); if (ret < 0 && ret != -EINVAL) - return ret; + goto free_rproc; platform_set_drvdata(pdev, qproc); From patchwork Fri Apr 3 17:50:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 11473235 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8730581 for ; Fri, 3 Apr 2020 17:50:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5C8F4207FF for ; Fri, 3 Apr 2020 17:50:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="rLMMh5/u" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404278AbgDCRuR (ORCPT ); Fri, 3 Apr 2020 13:50:17 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:41645 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404238AbgDCRuQ (ORCPT ); Fri, 3 Apr 2020 13:50:16 -0400 Received: by mail-qk1-f194.google.com with SMTP id y3so4102190qky.8 for ; Fri, 03 Apr 2020 10:50:15 -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=9cI4scVoKJKw1b/HO6QaDyp3LKbjdrfchQuuiHLWjWc=; b=rLMMh5/uZTRR5enw62HL/VSaxyamFjN4+UGzBnS8klJ3U4s3RFmAAyCL4wGrLkwMpq 52GPlvDoYnNkCsbId8slVjxMWH/y2XSa5iO/SWWdtbE1VTehRN2UhVzyxcHcweV6tfe7 2trbZ0MYKH6SqYhemT4a9SRZPY9m9xaWs9UVfR90W/8FxBdn/kwXkx4vcMf+OVFV+R+Y MIWBr6DA7YvHjhy/GpAYvvRn0uvyleJk10fTq1YLU2+g57CrXsT8C8V7KL4NSMr6eVf0 KAsUBdiCPDu823eqBD98pLdlOHOXeUqHH9DDsP3fbQrEz/lZdyEyaP9WOpvKfIHaww3B Yfnw== 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=9cI4scVoKJKw1b/HO6QaDyp3LKbjdrfchQuuiHLWjWc=; b=ka3g078AdH7kwkVXvXPOOQdmzVD43uMZusVnwgOI7dSDVREV14KTtOBPfKcN4uLEFm jTQ8PNUVPlhYHkFpR1q9LeHSceZKLqAFLtYShzrNFGH/5+8w8brJMj0euqkiJngaUOZy 6xTo2m5XzSCiaaCxgpFSCpQUDbxNOEAA3S/j5NPVnoLRYD6Qw8p4MjxFsTLTGJdEC/Lh jgNJL6HSekKPbCWrvhO28+fNsscmYpiQV/29lCRhMrjx1YQcOaT6bL9SwPxijIQu0fAb oZnr3OteBJluHJckZfnKAeYxL/8byQt75Q+bmSK+Xxy092+Xwww+aHX6Ben4jBPw0/fZ emaA== X-Gm-Message-State: AGi0Pub2eKd+QSjOM6BI4OyBtZTQlm6AVREiLc0GgHleApDhTuQeNkIt ZBjKdc/PX0xHoBIzZBCVsr2KPA== X-Google-Smtp-Source: APiQypLbHKb7rWYJp6CQb5HJWjxuJFaOwE+O1MVmtbr6e7yua8Mc9Jgufd4yiFLoFk5gnocLafzasQ== X-Received: by 2002:ae9:ee01:: with SMTP id i1mr10181110qkg.498.1585936215146; Fri, 03 Apr 2020 10:50:15 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id 77sm6821225qkh.26.2020.04.03.10.50.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 10:50:14 -0700 (PDT) From: Alex Elder To: Bjorn Andersson , Ohad Ben-Cohen , Andy Gross Cc: linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] remoteproc: qcom_q6v5_mss: fix q6v5_probe() error paths Date: Fri, 3 Apr 2020 12:50:05 -0500 Message-Id: <20200403175005.17130-4-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200403175005.17130-1-elder@linaro.org> References: <20200403175005.17130-1-elder@linaro.org> MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org 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. 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; }