From patchwork Tue Dec 26 20:38:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 122752 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1390121qgn; Tue, 26 Dec 2017 12:39:21 -0800 (PST) X-Google-Smtp-Source: ACJfBovVNgORJnPIQyTQiwGkM48QdAlJbvTdIhuxhAENggqTp9DnT2SLxeRhYmVwMC/qgOV0rrmR X-Received: by 10.98.197.68 with SMTP id j65mr26827101pfg.176.1514320761591; Tue, 26 Dec 2017 12:39:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514320761; cv=none; d=google.com; s=arc-20160816; b=ezEe2Bh+UMxahYsEK/YVe6UGhA+KKxhMHDcfEjybZ+VT45MgQxi6Ur5NSUnPimJ9Tc J976x4nxfDm7W8SzRmGchql2u5A2NqM5sOnpYJIFGShbojIqB/inCqIqJKi1U1VmIkOG IH+uHcjUc1hVGR4j6WVVZKNY7am/uhYzbo1aPk/80c7BASaKvDckvbLKG9q4NXAQOJKL JnrCnlhW8RYcnzASCvZDT/s0PZM4yLud7qIr15SCsMf8M53h5Ra3S8JrtyjoHrCaA6Lq oFLkxPgjCCJFdZAV57ktwllOWmWQ1Y2wxK2vVl5e0uLGWeI3D9bmP67yCJOlffgkU5QN X4Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=afH9QSJQWjrL+EdaLzO9his85vlbQcXic6kkHaMxPv0=; b=KnkVutontgO8VXnBhHQvo0GCtOJMzlI4Gx4IZtCQSQjFSRVaGChckZ/4wKef6FTSoo F5hwJ6HCoChj/Z3Sozcm6gdqBqAz5I+70hJ+QLgK+PMPNyF4BKpStlw9adgIHkJiG44t TYm7hiwB3K7/WFCoG83yzAnDKBoB7LnEP49Odhxb+LJAp39miKVkFNGw6MkRZoeV9izm irAoegqfs01T7K5aDJOi8QOk2y0BTBq6D1T1rtRtcYHnDcfUvjpTNjeEMzQKfSUkDbRF 907dtsmdxAF9SHDnjnhZUXU6DKVA1RAfESlC1SId+GX933IxC0i4kFBai27QA/MwPUjb VJiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h9Q928/F; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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. [209.132.180.67]) by mx.google.com with ESMTP id a12si23686322pfl.63.2017.12.26.12.39.21; Tue, 26 Dec 2017 12:39:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h9Q928/F; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1751569AbdLZUjR (ORCPT + 28 others); Tue, 26 Dec 2017 15:39:17 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:32833 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751357AbdLZUii (ORCPT ); Tue, 26 Dec 2017 15:38:38 -0500 Received: by mail-pl0-f65.google.com with SMTP id 1so16915393plv.0 for ; Tue, 26 Dec 2017 12:38:38 -0800 (PST) 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; bh=afH9QSJQWjrL+EdaLzO9his85vlbQcXic6kkHaMxPv0=; b=h9Q928/F3ggMQ2E/ZmaW4AWO1dto5PjUDAE0owLeMpNumGTQ8dhITyIOgAPPkuobKT /qd9hA4JgH3OsjeOvns8vyM8xXuAriaruUoJh8oXP3Gw36ayvF3GB6wuVirdmWkDIopI kAuJMxWRAcdpj3y3zyYpbxsyL/2+fCSbtNpb0= 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; bh=afH9QSJQWjrL+EdaLzO9his85vlbQcXic6kkHaMxPv0=; b=JBTyAaMMhiMSitzJwfU6vcUT30tuj49cBFef82iYRq+61eG6qmMTxDjxHBw9JUOlJA QLYzR7aT5DWwLWAa5fjqVbzILQzWQMMn6yib7qkgc8C+D/bb/SWJxF02Zw0lOmojBxfP Br0Eyudl9o9JzCC0fVKP/eXg8l6od3WzgrrE4RJxecNdLjaqxW4H1ZMe+X1qHuc2Pj50 QqtK2s/49brsMuVVFMbo/trxIO/PiSaM/G/DkFPx/PhE0RiXadrR9+clJdAWOSAeqR+q eR1b++HahKhaGbaMsj8vE0yMDNKzpBFadr/TC0hPDYkSVIZwUTBLbGrlDsLEwKvk+x8G LjOQ== X-Gm-Message-State: AKGB3mKsfdixHbI6QPocp25uAjpepSoLtFb8YpI2pbnV3a5gZQC3Idhd iOrrcEjMPUUJZdqZO9TyuEP26g== X-Received: by 10.159.206.139 with SMTP id bg11mr25892419plb.216.1514320718248; Tue, 26 Dec 2017 12:38:38 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id 68sm58746339pfx.186.2017.12.26.12.38.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Dec 2017 12:38:37 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, Suman Anna , Avaneesh Kumar Dwivedi Subject: [PATCH v2 2/4] remoteproc: Rename "load_rsc_table" to "parse_fw" Date: Tue, 26 Dec 2017 12:38:30 -0800 Message-Id: <20171226203832.14928-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171226203832.14928-1-bjorn.andersson@linaro.org> References: <20171226203832.14928-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The resource table is just one possible source of information that can be extracted from the firmware file. Generalize this interface to allow drivers to override this with parsers of other types of information. Signed-off-by: Bjorn Andersson --- Changes since v1: - New patch drivers/remoteproc/remoteproc_core.c | 6 +++--- drivers/remoteproc/remoteproc_internal.h | 7 +++---- include/linux/remoteproc.h | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) -- 2.15.0 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 5af7547b9d8d..6a72daa94673 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -944,8 +944,8 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) rproc->bootaddr = rproc_get_boot_addr(rproc, fw); - /* load resource table */ - ret = rproc_load_rsc_table(rproc, fw); + /* parse firmware resources */ + ret = rproc_parse_fw(rproc, fw); if (ret) goto disable_iommu; @@ -1555,7 +1555,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, /* Default to ELF loader if no load function is specified */ if (!rproc->ops->load) { rproc->ops->load = rproc_elf_load_segments; - rproc->ops->load_rsc_table = rproc_elf_load_rsc_table; + rproc->ops->parse_fw = rproc_elf_load_rsc_table; rproc->ops->find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table; rproc->ops->sanity_check = rproc_elf_sanity_check; rproc->ops->get_boot_addr = rproc_elf_get_boot_addr; diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 55a2950c5cb7..7570beb035b5 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -88,11 +88,10 @@ int rproc_load_segments(struct rproc *rproc, const struct firmware *fw) return -EINVAL; } -static inline int rproc_load_rsc_table(struct rproc *rproc, - const struct firmware *fw) +static inline int rproc_parse_fw(struct rproc *rproc, const struct firmware *fw) { - if (rproc->ops->load_rsc_table) - return rproc->ops->load_rsc_table(rproc, fw); + if (rproc->ops->parse_fw) + return rproc->ops->parse_fw(rproc, fw); return 0; } diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index de6e20a3f061..dc93ac3d1692 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -343,7 +343,7 @@ struct rproc_ops { int (*stop)(struct rproc *rproc); void (*kick)(struct rproc *rproc, int vqid); void * (*da_to_va)(struct rproc *rproc, u64 da, int len); - int (*load_rsc_table)(struct rproc *rproc, const struct firmware *fw); + int (*parse_fw)(struct rproc *rproc, const struct firmware *fw); struct resource_table *(*find_loaded_rsc_table)( struct rproc *rproc, const struct firmware *fw); int (*load)(struct rproc *rproc, const struct firmware *fw); From patchwork Tue Dec 26 20:38:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 122751 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1389876qgn; Tue, 26 Dec 2017 12:39:04 -0800 (PST) X-Google-Smtp-Source: ACJfBos9G6PZoTaArGU6KoM7z938WHwvkey4tNuSIK5sUZa1gYfq42NGgqu5QwSqDRCK5Wywiy6T X-Received: by 10.101.100.24 with SMTP id a24mr23446850pgv.185.1514320744275; Tue, 26 Dec 2017 12:39:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514320744; cv=none; d=google.com; s=arc-20160816; b=eQ5dQf3MffEpNAzWcC6ukXI7kbcqvHT0wrrXlgz2t7Bx2VpSyRAbZpi+FoRjy33g+4 PQQoTY0rctziILbl4HwAkvqJ2xkU2ueRIlNJYMwDjWiP0MIj6JS+tNoECdAuwTT6Z/iG Q0pujM1g/dJcO3MgNrk2bkqkVApaNXoOTk2FmzUOLDg3jEZGsGNAFp2hm/16A9/oHgZP nDpxDOV6z34TUuohJzIw0nAHvYCoc8mcaplqzN9RaccJC0eo4eKHNO7p/juK54o9o34C AmybgseyqKlFAu//eB+axbmIvp5pIkZE83n0NJ7JHUK2rQsWMOhEmZy1stVenYNZ5POZ 6odg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=erQmE58i7q/tUkYV3PwrBccKdHhVGiIzA135yyERvMo=; b=ogZZeXxOyGViBb0pDM2L8mvhTRPfE4IddY8FCn7V8g8LljndpBB+AkrmY8ESDKTBrE E6vElX1ZEQPDUKU6xkgzYsOtoIVMacxWQJ1sjvzwNYyBeFm/AAS9sbT9lllM8KlPn0w0 ObkXjApQTFlvU952Kynm4p8MvY9l0fv4kY6DqC9H1x5XVaWIxweG/9L+9rZmR1NLniwI rBa/pWxtfsuz696cSRKdozcubWaP1gRB5A86Fa0b5GKCBJ29M+WD7V9PbaEdKl025NM6 tavpiz1vZVVlORogHQNUQFaGI7/pcSm1BVShpq0PgqnI0UpZr32DQh9PRFATdUrqTCwi fwxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dIl9w/nT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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. [209.132.180.67]) by mx.google.com with ESMTP id m23si12234539pgc.547.2017.12.26.12.39.04; Tue, 26 Dec 2017 12:39:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dIl9w/nT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1751487AbdLZUis (ORCPT + 28 others); Tue, 26 Dec 2017 15:38:48 -0500 Received: from mail-pl0-f68.google.com ([209.85.160.68]:35887 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751432AbdLZUil (ORCPT ); Tue, 26 Dec 2017 15:38:41 -0500 Received: by mail-pl0-f68.google.com with SMTP id b12so18360775plm.3 for ; Tue, 26 Dec 2017 12:38:41 -0800 (PST) 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; bh=erQmE58i7q/tUkYV3PwrBccKdHhVGiIzA135yyERvMo=; b=dIl9w/nTnlh0DnA14y5S4q+3FM8O7K588VmDYgRMgGRl1D0ACQvtcsqvCtItetP+nX pw6EsNCxu/ypbL1prPbQMziK9sYoYLS52PrQ9/S2aRRNhoX0x4wXcZ6Xd4cnnmr/DhJN 4cp67aSCSg8KI6bc72M8f+Ce+U9Pb02YuOzBM= 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; bh=erQmE58i7q/tUkYV3PwrBccKdHhVGiIzA135yyERvMo=; b=Xr8mvOm0z2ct/QnhjBl2OXYEciIu4z9eOvLU6L0inXLm9Yv67xzWAfWyXTHDI04Q0I 0MVUQtrFDyW6zrVSIG7z7JEVFm30GA1BNIPexGHUzNc0Ognx4rCAPoENwmH+jnf9hqgh 75o7URy/n271httrpf3irCQnyhM9dqwUjI5z3pLX/XhtYm1AdlaRehZUdpZkqc2yGRAN bqq0wgvNV5lSRn0s3UlhrVPVoYDmv3mVz2xWNySWxSDVbIGusZS/kfAVrWReSe6puXIS UFTKFbfezMmRj4NQ/WmqbNiHfYa4X8kGKHNLQ0p9bcbRRdrIG+bw0WRe/3aEssf6RpC1 MVVw== X-Gm-Message-State: AKGB3mK3v0dM3i0cilIYVd2Od71LDX90V6TKEklqzlb0bnEGWEy7+Fbo BUQj98Drii8RD0AH/xeBIzCb5Q== X-Received: by 10.84.218.204 with SMTP id g12mr26249165plm.213.1514320720716; Tue, 26 Dec 2017 12:38:40 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id 68sm58746339pfx.186.2017.12.26.12.38.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Dec 2017 12:38:40 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, Suman Anna , Avaneesh Kumar Dwivedi Subject: [PATCH v2 4/4] remoteproc: qcom: Register segments for core dump Date: Tue, 26 Dec 2017 12:38:32 -0800 Message-Id: <20171226203832.14928-5-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171226203832.14928-1-bjorn.andersson@linaro.org> References: <20171226203832.14928-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sarangdhar Joshi Register MDT segments with the remoteproc core dump functionality in order to include them in a core dump, in case of a recovery of the remote processor. Signed-off-by: Sarangdhar Joshi Signed-off-by: Bjorn Andersson --- drivers/remoteproc/qcom_adsp_pil.c | 1 + drivers/remoteproc/qcom_common.c | 44 ++++++++++++++++++++++++++++++++++++++ drivers/remoteproc/qcom_common.h | 2 ++ drivers/remoteproc/qcom_wcnss.c | 1 + 4 files changed, 48 insertions(+) -- 2.15.0 diff --git a/drivers/remoteproc/qcom_adsp_pil.c b/drivers/remoteproc/qcom_adsp_pil.c index 833763aa3f2a..af12cdd45b71 100644 --- a/drivers/remoteproc/qcom_adsp_pil.c +++ b/drivers/remoteproc/qcom_adsp_pil.c @@ -179,6 +179,7 @@ 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, }; diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c index 6eb9161f80b3..f9a0701c94e7 100644 --- a/drivers/remoteproc/qcom_common.c +++ b/drivers/remoteproc/qcom_common.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "remoteproc_internal.h" #include "qcom_common.h" @@ -79,6 +80,49 @@ void qcom_remove_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glin } EXPORT_SYMBOL_GPL(qcom_remove_glink_subdev); +/** + * qcom_register_dump_segments() - register segments for coredump + * @rproc: remoteproc handle + * @fw: firmware header + * + * Register all segments of the ELF in the remoteproc coredump segment list + * + * Return: 0 on success, negative errno on failure. + */ +int qcom_register_dump_segments(struct rproc *rproc, + const struct firmware *fw) +{ + const struct elf32_phdr *phdrs; + const struct elf32_phdr *phdr; + const struct elf32_hdr *ehdr; + int ret; + int i; + + ehdr = (struct elf32_hdr *)fw->data; + phdrs = (struct elf32_phdr *)(ehdr + 1); + + for (i = 0; i < ehdr->e_phnum; i++) { + phdr = &phdrs[i]; + + if (phdr->p_type != PT_LOAD) + continue; + + if ((phdr->p_flags & QCOM_MDT_TYPE_MASK) == QCOM_MDT_TYPE_HASH) + continue; + + if (!phdr->p_memsz) + continue; + + ret = rproc_coredump_add_segment(rproc, phdr->p_paddr, + phdr->p_memsz); + if (ret) + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(qcom_register_dump_segments); + static int smd_subdev_probe(struct rproc_subdev *subdev) { struct qcom_rproc_subdev *smd = to_smd_subdev(subdev); diff --git a/drivers/remoteproc/qcom_common.h b/drivers/remoteproc/qcom_common.h index 728be9834d8b..7e614520fb69 100644 --- a/drivers/remoteproc/qcom_common.h +++ b/drivers/remoteproc/qcom_common.h @@ -30,6 +30,8 @@ struct qcom_rproc_ssr { void qcom_add_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glink); void qcom_remove_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glink); +int qcom_register_dump_segments(struct rproc *rproc, const struct firmware *fw); + void qcom_add_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd); void qcom_remove_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd); diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c index 599c1aa73b7f..e9f9ba4c584d 100644 --- a/drivers/remoteproc/qcom_wcnss.c +++ b/drivers/remoteproc/qcom_wcnss.c @@ -309,6 +309,7 @@ static const struct rproc_ops wcnss_ops = { .start = wcnss_start, .stop = wcnss_stop, .da_to_va = wcnss_da_to_va, + .parse_fw = qcom_register_dump_segments, .load = wcnss_load, };