From patchwork Sat Jan 6 00:04:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 123584 Delivered-To: patch@linaro.org Received: by 10.80.135.92 with SMTP id 28csp1420677edv; Fri, 5 Jan 2018 16:06:56 -0800 (PST) X-Google-Smtp-Source: ACJfBouqddjaWgPYRRNnc3IeSOibdcmZnc9p3fZAD64GEbselLjaduNGoEfsNPOL2TXYDV2GkYGG X-Received: by 10.101.65.203 with SMTP id b11mr3829388pgq.44.1515197115627; Fri, 05 Jan 2018 16:05:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515197115; cv=none; d=google.com; s=arc-20160816; b=uXH6D+GPKvKYiR28CkgmTJpU5rUWLAPIwP9Si2J+2/BhIdXSH7ok6Z+esJpSuNdDCi gEi3hVg8E93NqWwJl25lyrxWv8UnV64GBQevHd/jG6FZlLEhZpao8TPv820hh72moFkP YqOdWPUvHHfj+LkmTKdE/U03UBooEXIHcO2fSESZx3x4VgeU5639U/7cv4MM5gR98dd+ HM5jbZRQWuy2MQ0yhAl3UYTTSkxfbp3wXg819cCyYPfUMIcY8kvVsr9+hl7zb4yUxArc eb73GgagfyE4nMsYpdBwFroXwF30Acqg7duyYRY/ZkxIljBao1gcdaUA8Q6EdjbX2MuC b3Xw== 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=L+eGoahfCUzcAmGrqUJCKMaB7xxNDoyT8SUt7B6S4UM=; b=EqKrt5niIzsEySCdm3Pk3c4EWsMFAu953jBQUyuN5+uC2LHBK6EeS16EypW+I6tqRR nVrvNfYacrSmwxTutlNKof2wMdhBKco7fXxWFkdIPNnuXDYRyucUSin9uIeXBSkmdJJk Wo6pIxJ42K1TUhJ8YazpO3pVZStj4e0SD6D+pYHcCnBSC5E3vxFT3Yrnd6RPFCyrW3Gi nQA717vMUfv9+i6GdZu7Dbj+M4GwgGxrQV+kwQDA8KVI+h31InQnjnm3eJHSkzZX24yT MDqoIrCXcDYgy+IBZGTxiLdVHLJjl8l8Nw/mHlfvzllkoTRl0X/c8eWgEIGYqAf+ZsxQ jEmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=f8fUfUEX; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (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 x1si4762712pfj.295.2018.01.05.16.05.15; Fri, 05 Jan 2018 16:05:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=f8fUfUEX; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753346AbeAFAFN (ORCPT + 10 others); Fri, 5 Jan 2018 19:05:13 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:45940 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753386AbeAFAE0 (ORCPT ); Fri, 5 Jan 2018 19:04:26 -0500 Received: by mail-pl0-f65.google.com with SMTP id o2so3976638plk.12 for ; Fri, 05 Jan 2018 16:04:25 -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=g/tkBwY3qvXaRoQ3KkMModOj5KcAfCU0hmGkDILb0Cs=; b=f8fUfUEXIsW/izpi6HJx3tPpQw9NGcW6dlZI2jpZuuLZzj8SccV0ToXpNTd4rviLSU jXbDrQIQVM/g11YLa/gxP9tiBoFmybwPw5aBxwV5yvwopS678ec97gkDpm/cDUOdS2nm 01BlkdCr5cJFdvxGKzLZlrKzA9fwwKJdN8NNw= 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=g/tkBwY3qvXaRoQ3KkMModOj5KcAfCU0hmGkDILb0Cs=; b=bpNWLtVDxh1nUyr0Y8w2dtr1aQ6yWZk0166j730j5ZjNdrgHcozOcQphQXLR+1zYCQ uX+Wh3W7zbYq5nbtcock+k3v+AqLL3t0PPpsXfW74UcCvzetVR54chQSioOIXEo5LAvy cC/jkEZiSUU3jFEtDaIS0lO7bWk6CU0RdC6fA6MRGmVobBgllwaunEJv9/9gtDvvxDvH 2ZBjTsFRON+dHn8BiKJzTafLysaJjCK/C4mJvGVoQyIFGB2vhFIAqRfm+MZGOhQP6929 0uNsr5mB7dpQBleEctmUC7yrYTIF1m9JGM0WmdxzM06z2unDkiJqTZvMiyPLyaX+pLzB fONA== X-Gm-Message-State: AKGB3mLgWsa4rqtGk2PJpF0rb2/78LPTwNnn2E9gVUsfbCjcCZwxFTut FTzoDYXpqfX28L2tB56UZZbX1g== X-Received: by 10.84.149.168 with SMTP id m37mr4630726pla.353.1515197065173; Fri, 05 Jan 2018 16:04:25 -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 n186sm9385177pgn.11.2018.01.05.16.04.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 16:04:24 -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 , Loic Pallardy Subject: [PATCH v3 1/4] remoteproc: Add remote processor coredump support Date: Fri, 5 Jan 2018 16:04:17 -0800 Message-Id: <20180106000420.10070-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180106000420.10070-1-bjorn.andersson@linaro.org> References: <20180106000420.10070-1-bjorn.andersson@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Sarangdhar Joshi As the remoteproc framework restarts the remote processor after a fatal event, it's useful to be able to acquire a coredump of the remote processor's state, for post mortem debugging. This patch introduces a mechanism for extracting the memory contents after the remote has stopped and before the restart sequence has begun in the recovery path. The remoteproc framework builds the core dump in memory and use devcoredump to expose this to user space. Signed-off-by: Sarangdhar Joshi [bjorn: Use vmalloc instead of composing the ELF on the fly] Signed-off-by: Bjorn Andersson --- Changes since v2: - None Changes since v1: - vmalloc() memory to build ELF file before registering devcoredump - life cycle of segment list is from boot to shutdown (not start/shutdown) - add WANT_DEV_COREDUMP select - use dma_addr_t to denote device addresses drivers/remoteproc/Kconfig | 1 + drivers/remoteproc/remoteproc_core.c | 128 +++++++++++++++++++++++++++++++++++ include/linux/remoteproc.h | 18 +++++ 3 files changed, 147 insertions(+) -- 2.15.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index b609e1d3654b..3e4bca77188d 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -6,6 +6,7 @@ config REMOTEPROC select CRC32 select FW_LOADER select VIRTIO + select WANT_DEV_COREDUMP help Support for remote processors (such as DSP coprocessors). These are mainly used on embedded systems. diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 4170dfbd93bd..5af7547b9d8d 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -801,6 +802,20 @@ static void rproc_remove_subdevices(struct rproc *rproc) subdev->remove(subdev); } +/** + * rproc_coredump_cleanup() - clean up dump_segments list + * @rproc: the remote processor handle + */ +static void rproc_coredump_cleanup(struct rproc *rproc) +{ + struct rproc_dump_segment *entry, *tmp; + + list_for_each_entry_safe(entry, tmp, &rproc->dump_segments, node) { + list_del(&entry->node); + kfree(entry); + } +} + /** * rproc_resource_cleanup() - clean up and free all acquired resources * @rproc: rproc handle @@ -848,6 +863,8 @@ static void rproc_resource_cleanup(struct rproc *rproc) /* clean up remote vdev entries */ list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node) kref_put(&rvdev->refcount, rproc_vdev_release); + + rproc_coredump_cleanup(rproc); } static int rproc_start(struct rproc *rproc, const struct firmware *fw) @@ -1017,6 +1034,113 @@ static int rproc_stop(struct rproc *rproc) return 0; } +/** + * rproc_coredump_add_segment() - add segment of device memory to coredump + * @rproc: handle of a remote processor + * @da: device address + * @size: size of segment + * + * Add device memory to the list of segments to be included in a coredump for + * the remoteproc. + * + * Return: 0 on success, negative errno on error. + */ +int rproc_coredump_add_segment(struct rproc *rproc, dma_addr_t da, size_t size) +{ + struct rproc_dump_segment *segment; + + segment = kzalloc(sizeof(*segment), GFP_KERNEL); + if (!segment) + return -ENOMEM; + + segment->da = da; + segment->size = size; + + list_add_tail(&segment->node, &rproc->dump_segments); + + return 0; +} +EXPORT_SYMBOL(rproc_coredump_add_segment); + +/** + * rproc_coredump() - perform coredump + * @rproc: rproc handle + * + * This function will generate an ELF header for the registered segments + * and create a devcoredump device associated with rproc. + */ +static void rproc_coredump(struct rproc *rproc) +{ + struct rproc_dump_segment *segment; + struct elf32_phdr *phdr; + struct elf32_hdr *ehdr; + size_t data_size; + size_t offset; + void *data; + void *ptr; + int phnum = 0; + + if (list_empty(&rproc->dump_segments)) + return; + + data_size = sizeof(*ehdr); + list_for_each_entry(segment, &rproc->dump_segments, node) { + data_size += sizeof(*phdr) + segment->size; + + phnum++; + } + + data = vmalloc(data_size); + if (!data) + return; + + ehdr = data; + + memset(ehdr, 0, sizeof(*ehdr)); + memcpy(ehdr->e_ident, ELFMAG, SELFMAG); + ehdr->e_ident[EI_CLASS] = ELFCLASS32; + ehdr->e_ident[EI_DATA] = ELFDATA2LSB; + ehdr->e_ident[EI_VERSION] = EV_CURRENT; + ehdr->e_ident[EI_OSABI] = ELFOSABI_NONE; + ehdr->e_type = ET_CORE; + ehdr->e_machine = EM_NONE; + ehdr->e_version = EV_CURRENT; + ehdr->e_entry = rproc->bootaddr; + ehdr->e_phoff = sizeof(*ehdr); + ehdr->e_ehsize = sizeof(*ehdr); + ehdr->e_phentsize = sizeof(*phdr); + ehdr->e_phnum = phnum; + + phdr = data + ehdr->e_phoff; + offset = ehdr->e_phoff + sizeof(*phdr) * ehdr->e_phnum; + list_for_each_entry(segment, &rproc->dump_segments, node) { + memset(phdr, 0, sizeof(*phdr)); + phdr->p_type = PT_LOAD; + phdr->p_offset = offset; + phdr->p_vaddr = segment->da; + phdr->p_paddr = segment->da; + phdr->p_filesz = segment->size; + phdr->p_memsz = segment->size; + phdr->p_flags = PF_R | PF_W | PF_X; + phdr->p_align = 0; + + ptr = rproc_da_to_va(rproc, segment->da, segment->size); + if (!ptr) { + dev_err(&rproc->dev, + "invalid coredump segment (%pad, %zu)\n", + &segment->da, segment->size); + memset(data + offset, 0xff, segment->size); + } else { + memcpy(data + offset, ptr, segment->size); + } + + offset += phdr->p_filesz; + phdr++; + } + + dev_coredumpv(&rproc->dev, data, data_size, GFP_KERNEL); +} + /** * rproc_trigger_recovery() - recover a remoteproc * @rproc: the remote processor @@ -1043,6 +1167,9 @@ int rproc_trigger_recovery(struct rproc *rproc) if (ret) goto unlock_mutex; + /* generate coredump */ + rproc_coredump(rproc); + /* load firmware */ ret = request_firmware(&firmware_p, rproc->firmware, dev); if (ret < 0) { @@ -1443,6 +1570,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, INIT_LIST_HEAD(&rproc->traces); INIT_LIST_HEAD(&rproc->rvdevs); INIT_LIST_HEAD(&rproc->subdevs); + INIT_LIST_HEAD(&rproc->dump_segments); INIT_WORK(&rproc->crash_handler, rproc_crash_handler_work); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 728d421fffe9..b60c3a31b75d 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -394,6 +394,21 @@ enum rproc_crash_type { RPROC_FATAL_ERROR, }; +/** + * struct rproc_dump_segment - segment info from ELF header + * @node: list node related to the rproc segment list + * @da: device address of the segment + * @size: size of the segment + */ +struct rproc_dump_segment { + struct list_head node; + + dma_addr_t da; + size_t size; + + loff_t offset; +}; + /** * struct rproc - represents a physical remote processor device * @node: list node of this rproc object @@ -424,6 +439,7 @@ enum rproc_crash_type { * @cached_table: copy of the resource table * @table_sz: size of @cached_table * @has_iommu: flag to indicate if remote processor is behind an MMU + * @dump_segments: list of segments in the firmware */ struct rproc { struct list_head node; @@ -455,6 +471,7 @@ struct rproc { size_t table_sz; bool has_iommu; bool auto_boot; + struct list_head dump_segments; }; /** @@ -534,6 +551,7 @@ void rproc_free(struct rproc *rproc); int rproc_boot(struct rproc *rproc); void rproc_shutdown(struct rproc *rproc); void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type); +int rproc_coredump_add_segment(struct rproc *rproc, dma_addr_t da, size_t size); static inline struct rproc_vdev *vdev_to_rvdev(struct virtio_device *vdev) { From patchwork Sat Jan 6 00:04:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 123585 Delivered-To: patch@linaro.org Received: by 10.80.135.92 with SMTP id 28csp1420900edv; Fri, 5 Jan 2018 16:07:14 -0800 (PST) X-Google-Smtp-Source: ACJfBouh6bt95jxDHdxwups8V308sZ2apk3qO4R7nV2EuF5y2+vsU0JHgpIGsCRbssI1O4SVZZb0 X-Received: by 10.99.0.216 with SMTP id 207mr3837281pga.192.1515197097825; Fri, 05 Jan 2018 16:04:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515197097; cv=none; d=google.com; s=arc-20160816; b=eJoERh67F0UJAzPkXoyJHgdyzPm7VH6T4QL8fuXky/EfuQdRuyYH4fKlm2OoUlb0IV tTIerGMA8qs4U95Ft8qQbXUcy9dHBcwHSLa+9+MuN2AQfvGDDUzdaJgmoYnKyVKQCbet 2rFwWo33LQxetL/Jll0B0RkHuIEJFdC0o1iTJNPrZ+hKysGOqHtEC42l4hX65aR+CmY1 GWQWP4xkwlcqlXjexYv6SxSiL3howT35+O+od4/FSRQWOTg/jo1yqDibeMPtf6t2y5/5 j+2/mGOQEc7pfOKJoFVnmjy08mJyqnQ83m7CQ03J+JcJ+HwcAz8KHT4rucCdp/qrbF7s XQEw== 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=23QbT2DBKCVsJUzMbv75GiHVpcHYLzXmgv6O+KVWW7k=; b=hxYD5h8UOc8rcdAblR4BOATiDsZKhK7o5H00TjOjG12Yk/xUjrplTNSjs/qJF4RXhL Dv0bawYoPA40W8suVj7gghkHlirg6Qd/97M7OfKKZM0WR4Rd7pWdHQHUsV4ZIGW8jc/r aTZHc2vAKHw0GTKfP+Jmxoj0VydidTlJjA46MyUWyahDjubPmhkXJw6KdlctHg9x0buA A/2l6NmvtAFrmlmbYmVqvck6nF8UeKUMI9k+F7mll9E+ILo/28FW5M91WD5WhCwmr8xe egxLGKDyZrDr4VQHC1Al23uAjRMAypP9xWmN2o6VR516L5N5yli2tUGRsasSpbF++4bo zWaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=afMh0pVe; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (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 x1si4762712pfj.295.2018.01.05.16.04.55; Fri, 05 Jan 2018 16:04:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=afMh0pVe; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753463AbeAFAEb (ORCPT + 10 others); Fri, 5 Jan 2018 19:04:31 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:42358 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753393AbeAFAE1 (ORCPT ); Fri, 5 Jan 2018 19:04:27 -0500 Received: by mail-pl0-f65.google.com with SMTP id bd8so3992010plb.9 for ; Fri, 05 Jan 2018 16:04:26 -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=iofOirkLKA0Lu5kMv0lzYQT1jsJL1xNOvOzWNVrugIY=; b=afMh0pVe7j/Ig/OdEbMDtHKQ3Kfy/7jF0FLSRekhi48EqleXajhioScvCYqR4MUX8Z KCWYvE0Fj39AoC62+dxzh0rdqqxAmClzyINFdBW6H0HivKfHAKRfLYtjWdHEOTxDP+DH 7fwBlmYdighu5thTz8X/YwDaEKIzoasarW9ug= 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=iofOirkLKA0Lu5kMv0lzYQT1jsJL1xNOvOzWNVrugIY=; b=XPzaixjAaxI3PfUBLw3VSWTEkoVqH/tRnKXczZouDJTq094YMDgtUZEZnbgFwWZQFV NUZVG+bV+A3eCxQro0kJlQyzFtWcH/28I+Y5+XZSlF5eEIPtYys1QDae1pJSkb0B4shq QxQAj8zKaZ6vWF/Urvy3IM7qbbI5bnzezSN7vYeABg3GzdyXdbULdGEBP4lRFRVbU9hW cnVGvfoCDWW5/j1pV1XzFSU2LJ75KF3S/Vv+FCRS3qwKrt8U1USy4r3EFtqMIckZXa7E ZmsINYqW0rHi8NclCPnx9/ZEG/l6WTW1IyvuPJSo5liCIrfV4eR5asokqTAKg+qeT5pD TPyw== X-Gm-Message-State: AKGB3mLJ5xAMYrZ4V7gDfqrqaTLpIedha/J70kNylsXSHXkRt2YtHQDk M0fxjIGjysB2632KofajQd/fog== X-Received: by 10.159.218.67 with SMTP id x3mr4797070plv.45.1515197066391; Fri, 05 Jan 2018 16:04:26 -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 n186sm9385177pgn.11.2018.01.05.16.04.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 16:04:25 -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 , Loic Pallardy Subject: [PATCH v3 2/4] remoteproc: Rename "load_rsc_table" to "parse_fw" Date: Fri, 5 Jan 2018 16:04:18 -0800 Message-Id: <20180106000420.10070-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180106000420.10070-1-bjorn.andersson@linaro.org> References: <20180106000420.10070-1-bjorn.andersson@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 v2: - Improved comment by call to rproc_parse_fw 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 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 5af7547b9d8d..fd257607a578 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); + /* Load resource table, core dump segment list etc from the firmware */ + 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 b60c3a31b75d..f16864acedad 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -344,7 +344,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);