From patchwork Tue Mar 24 05:29:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 189868 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADCA8C2BAEE for ; Tue, 24 Mar 2020 05:29:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 852D920663 for ; Tue, 24 Mar 2020 05:29:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AeJERwRS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725869AbgCXF3L (ORCPT ); Tue, 24 Mar 2020 01:29:11 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:41266 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726034AbgCXF3L (ORCPT ); Tue, 24 Mar 2020 01:29:11 -0400 Received: by mail-pg1-f196.google.com with SMTP id b1so8451104pgm.8 for ; Mon, 23 Mar 2020 22:29:10 -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=GksRJuQygj8iEw4+FLEhSTTKNuAXjcLxWomfet7/TQc=; b=AeJERwRSpJgnUUI1sktI8LwnrhuSGSz3vYH1BFGxcVqWMRFulqPzEU+WQgIDtowBid DY0kGUla4Ru00rBlZA6ZdZE8lKd1/wJoWuf0lfY+cj2pDSnteABWfDjOZQsvKM+QFXa3 sMkhhNfGBHxaoBmA97f4vTJUIS1/CiwlZbeWU+TAt0eAlf/M7HCTuKV4oURSn8ECY4sC iX3F68HmPtaSvXgjFbClRcp4WaMOa4pIhb2bRBGX1JuaJ2bryB0/Lnge5pkrunV1IAMe 3x+OLXURB5P9kmJSJkyX2vCL4/RwyaFE97vy31wFojuM9pWgkikB1TK966do/hubMOas w5LQ== 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=GksRJuQygj8iEw4+FLEhSTTKNuAXjcLxWomfet7/TQc=; b=Zdm7+TxWjOzRQ6E+QqwCOObD18VCsNI1HIm51PEXnkphEh8U3afrgfnrs/1MgAy74+ Y/zanPp6oX9ewIk9ebU6VDRxfzpcAghWrt3azeUraGev648QK/4bopPBUi7Iusnk/bm8 Ou40qv+A/2Xrbql7px+aPflZQiDMXpmu8I5uH1jQOzs7ZUFyr6qivX7gaU+fdPI6PrDM vj4BnATXj336cIKWvz+fFYPbn4AQ5r6FITkugGT9LiMH5iOPZAC0+gQ3vs06sAE18t53 t8Rw8meEFOYBmcfvUkeAm8ELZGL/T6hZBAt7f+PB9dkn+RdsH8K6DDn0DtDkFw1y+Gqz CAiQ== X-Gm-Message-State: ANhLgQ3jtBg/nFng5ifUYeEVs0qSAaaG6CYG3eQxcmbEhL6Hqfgk6Aj7 CaAqZKBC+FjJSLHDX9uBcjtkiA== X-Google-Smtp-Source: ADFU+vvQ57kvoZi+N9uQpIwZoXOTeauhh9IYgweVQ3UD9AqMO2B6kX+AF3DFoI0AvOUD007/H1wUOw== X-Received: by 2002:a62:4e4c:: with SMTP id c73mr28422516pfb.254.1585027750135; Mon, 23 Mar 2020 22:29:10 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id j14sm2795413pgk.74.2020.03.23.22.29.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2020 22:29:09 -0700 (PDT) From: Bjorn Andersson To: Andy Gross , Bjorn Andersson , Ohad Ben-Cohen Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Mathieu Poirier Subject: [PATCH v5 1/4] remoteproc: Traverse rproc_list under RCU read lock Date: Mon, 23 Mar 2020 22:29:01 -0700 Message-Id: <20200324052904.738594-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200324052904.738594-1-bjorn.andersson@linaro.org> References: <20200324052904.738594-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In order to be able to traverse the mostly read-only rproc_list without locking during panic migrate traversal to be done under rcu_read_lock(). Mutual exclusion for modifications of the list continues to be handled by the rproc_list_mutex and a synchronization point is added before releasing objects that are popped from the list. Reviewed-by: Mathieu Poirier Signed-off-by: Bjorn Andersson --- Changes since v4: - Added rculist include - Picked up Mathieu's r-b drivers/remoteproc/remoteproc_core.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index a9ac1d01e09b..7ee976ee2044 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -1868,8 +1869,8 @@ struct rproc *rproc_get_by_phandle(phandle phandle) if (!np) return NULL; - mutex_lock(&rproc_list_mutex); - list_for_each_entry(r, &rproc_list, node) { + rcu_read_lock(); + list_for_each_entry_rcu(r, &rproc_list, node) { if (r->dev.parent && r->dev.parent->of_node == np) { /* prevent underlying implementation from being removed */ if (!try_module_get(r->dev.parent->driver->owner)) { @@ -1882,7 +1883,7 @@ struct rproc *rproc_get_by_phandle(phandle phandle) break; } } - mutex_unlock(&rproc_list_mutex); + rcu_read_unlock(); of_node_put(np); @@ -1939,7 +1940,7 @@ int rproc_add(struct rproc *rproc) /* expose to rproc_get_by_phandle users */ mutex_lock(&rproc_list_mutex); - list_add(&rproc->node, &rproc_list); + list_add_rcu(&rproc->node, &rproc_list); mutex_unlock(&rproc_list_mutex); return 0; @@ -2156,9 +2157,12 @@ int rproc_del(struct rproc *rproc) /* the rproc is downref'ed as soon as it's removed from the klist */ mutex_lock(&rproc_list_mutex); - list_del(&rproc->node); + list_del_rcu(&rproc->node); mutex_unlock(&rproc_list_mutex); + /* Ensure that no readers of rproc_list are still active */ + synchronize_rcu(); + device_del(&rproc->dev); return 0; From patchwork Tue Mar 24 05:29:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 189867 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9429C10DCE for ; Tue, 24 Mar 2020 05:29:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7F1072078A for ; Tue, 24 Mar 2020 05:29:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iMrML+KB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725905AbgCXF3S (ORCPT ); Tue, 24 Mar 2020 01:29:18 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:38139 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727064AbgCXF3P (ORCPT ); Tue, 24 Mar 2020 01:29:15 -0400 Received: by mail-pf1-f195.google.com with SMTP id z25so4386344pfa.5 for ; Mon, 23 Mar 2020 22:29: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=VWBRcEyMTW+WEEQt5SQF5x0ROI7z/m3lM/vgJNL3hXc=; b=iMrML+KBB5l6Ri6XlYTp/N4rYhFdoHCnP7QF50uxsXOpRFiKMrfs0dVaox9kc0xcpk hDjTamvLPXs8Upj4Txl/ZHG7p5o0uh/h4CBrV7yV+cqh9b2XxArrbKrfNKS7mThX4n87 lh8OPKocwkJvWLbmZX6QAE0HQHdUs3bpdkUs/OgRPxtXRRP9LCE32J1PWeMPGXIhfLO3 fbLOb+gkZJEbUiZtlW1cDNsxO/3I7cck8/8NDOeazkFQSG+hVXlbBRhsRG4hIBNxfSBd WF/XUlVoJlJVU4w5XTa67bZLj16R7bdlhJiwPTYveSpjX/bQIMr8cOg1aIx8hJF/Edc6 nD5A== 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=VWBRcEyMTW+WEEQt5SQF5x0ROI7z/m3lM/vgJNL3hXc=; b=Uye7SKP4pcWOlY3LitET/h0uE2jtn9vHl+MD3nfM57RORF55ryFP0dOrYBYyermYBH P7+iN2nzhKAwJG974R1eMKIyE0usTF+0V/45fpn2gwbtTxgFY/BsUFVjSu3Y+pGsW9ki vbOZnC4887ggG8Fft6ymlbVvhvxP2Ra3jfd4TzJhYN8wlCHUq/zF4U5JDQv4+csw9Lkk 4CKF33vMKEqKhRP6WBrA6yLoqsQMabUaCVdyh6mdrop5lisdMDSzlywBAzmZPf8qcJ55 F8FAvMI7AuJNMtfRffIhhBBA2NQpE4GI13GIRprbTPhsATF5v6fJm17M5bTZ9eWwZbW8 FBRA== X-Gm-Message-State: ANhLgQ33NgXww7fB/Xe3xdw7fU9XJfA8uC9I1htBK3GBirmojD7D0jm6 SoT0GPUEJ54gCnJqQ5ZggATYBA== X-Google-Smtp-Source: ADFU+vtOqgoS3fw1vbaf1mdZpAWooFoKkJLbDx+LEZkLb5acpopnw2DgJmwSlrkhIO+GwxuRyZ3Fww== X-Received: by 2002:a63:6a4a:: with SMTP id f71mr26576969pgc.365.1585027753896; Mon, 23 Mar 2020 22:29:13 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id j14sm2795413pgk.74.2020.03.23.22.29.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2020 22:29:13 -0700 (PDT) From: Bjorn Andersson To: Andy Gross , Bjorn Andersson , Ohad Ben-Cohen Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Mathieu Poirier Subject: [PATCH v5 4/4] remoteproc: qcom: Introduce panic handler for PAS and ADSP Date: Mon, 23 Mar 2020 22:29:04 -0700 Message-Id: <20200324052904.738594-5-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200324052904.738594-1-bjorn.andersson@linaro.org> References: <20200324052904.738594-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Make the PAS and ADSP/CDSP remoteproc drivers implement the panic handler that will invoke a stop to prepare the remoteprocs for post mortem debugging. Reviewed-by: Mathieu Poirier Signed-off-by: Bjorn Andersson --- Changes since v4: - Picked up Mathieu's r-b drivers/remoteproc/qcom_q6v5_adsp.c | 8 ++++++++ drivers/remoteproc/qcom_q6v5_pas.c | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/remoteproc/qcom_q6v5_adsp.c b/drivers/remoteproc/qcom_q6v5_adsp.c index 2b01f2282062..24a3db961d5e 100644 --- a/drivers/remoteproc/qcom_q6v5_adsp.c +++ b/drivers/remoteproc/qcom_q6v5_adsp.c @@ -282,12 +282,20 @@ static void *adsp_da_to_va(struct rproc *rproc, u64 da, size_t len) return adsp->mem_region + offset; } +static unsigned long adsp_panic(struct rproc *rproc) +{ + struct qcom_adsp *adsp = rproc->priv; + + return qcom_q6v5_panic(&adsp->q6v5); +} + static const struct rproc_ops adsp_ops = { .start = adsp_start, .stop = adsp_stop, .da_to_va = adsp_da_to_va, .parse_fw = qcom_register_dump_segments, .load = adsp_load, + .panic = adsp_panic, }; static int adsp_init_clock(struct qcom_adsp *adsp, const char **clk_ids) diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c index a41860d2243a..7a63efb85405 100644 --- a/drivers/remoteproc/qcom_q6v5_pas.c +++ b/drivers/remoteproc/qcom_q6v5_pas.c @@ -234,12 +234,20 @@ static void *adsp_da_to_va(struct rproc *rproc, u64 da, size_t len) return adsp->mem_region + offset; } +static unsigned long adsp_panic(struct rproc *rproc) +{ + struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; + + return qcom_q6v5_panic(&adsp->q6v5); +} + static const struct rproc_ops adsp_ops = { .start = adsp_start, .stop = adsp_stop, .da_to_va = adsp_da_to_va, .parse_fw = qcom_register_dump_segments, .load = adsp_load, + .panic = adsp_panic, }; static int adsp_init_clock(struct qcom_adsp *adsp)