From patchwork Mon Feb 4 14:22:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 157423 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3973923jaa; Mon, 4 Feb 2019 06:24:26 -0800 (PST) X-Google-Smtp-Source: ALg8bN48hgYIIPpNydw3Whs8I+2Qote2xo0xaH2u5di/Ezq1pcPxVQyQE/4bNON15dJ/qUzu4ywC X-Received: by 2002:a62:9fd9:: with SMTP id v86mr51015312pfk.191.1549290266079; Mon, 04 Feb 2019 06:24:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549290266; cv=none; d=google.com; s=arc-20160816; b=FVqIBVstUjUARIeGdHpw1E7ZEsUB1oUvckTFwPwGwk5wPvSu0eSp48dl34lH2v/6kv tkxQQVaZXOXXafKvl6ns4j1IhVyZSiBA6o56hNs6qOOY+exFTYFOTD5ssvyg9QFisAuX nsDHBgQZOeOlRlMpfAOBGZFydV6hPwXpU4DLds0RohY58MRhKjJZ6gZVsgsDfPytg3iw 3Fu3j3EhoxTo2HSBK11TnRz9+ZcI/dQD/CS4iNpo5wKg1/qd6LkZB70Kr6lWbJCfs2hp Nh6ykWNZDU5xZ3mOxEEXId/nbadojsqlVT+ttFblzHh5cFNUXXU25L8fwIFyNRBjB3SO eHYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=0+KyfIOVDeytTSCzB8JNujMdAyrnWVoo29rT5qH9ivQ=; b=SDj0AGgNW7fNXUlyIiVH2bgqU07fb/wj7bcJrgVSAiqtNzPfJZQ6y8ENCdXCQwk62P ymhUJOJPGIPZEBg8M4GQ8HUXafYt80+PDT7EfpV14Z97mC0HEHaaAfJdECBhhwbc74RS MhsSHU0WcxMEmFshFcCRUkTJ+TKlDo+kmMo6E8x7xLNpKQ3LptkA0JTYOhvtFxPKobkj xUmqniA3clkHUUhhhuKa/Aijs/EmgAIGU5KowqglCZFyv9Y14/V9odE3VaHfTs+9YtBz euv/70riidFqSz1O5+wB+NzdobpBX7MoyCB94fRk7rg0A4oDj6AmC2alyvz0/W/pBZ31 byug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="fMj/QMoA"; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a193si168176pfa.214.2019.02.04.06.24.25; Mon, 04 Feb 2019 06:24:26 -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=@ti.com header.s=ti-com-17Q1 header.b="fMj/QMoA"; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729775AbfBDOYX (ORCPT + 31 others); Mon, 4 Feb 2019 09:24:23 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:43186 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729553AbfBDOYT (ORCPT ); Mon, 4 Feb 2019 09:24:19 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x14ENSEF031947; Mon, 4 Feb 2019 08:23:28 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1549290208; bh=0+KyfIOVDeytTSCzB8JNujMdAyrnWVoo29rT5qH9ivQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=fMj/QMoA2crKpPHMx69PccjBGiLr+7UnxRlLm+JPaBsTOzDoRtQC6BJMmCOJPEed+ S3j7ff6mayK93hhMgrq3EhmlzwQ7hFdAHpYO4xZBKe2wbTme2Of/Qv/G4iagly1oGt iEPHkn97OvgIwpqAqJ3Lk9GC+91CVRvOoPGchnG4= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x14ENStT010352 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 4 Feb 2019 08:23:28 -0600 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 4 Feb 2019 08:23:27 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 4 Feb 2019 08:23:27 -0600 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id x14EMoKg012232; Mon, 4 Feb 2019 08:23:24 -0600 From: Roger Quadros To: , , CC: , , , , , , , , , , , , Subject: [PATCH v2 08/14] remoteproc: Add support to handle device specific resource types Date: Mon, 4 Feb 2019 16:22:41 +0200 Message-ID: <1549290167-876-9-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1549290167-876-1-git-send-email-rogerq@ti.com> References: <1549290167-876-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 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 From: Suman Anna The remoteproc framework handles a fixed set of resource table entries today. To make it scalable across multiple platforms, it makes sense for the framework to provide a way for the device specific implementation to define and handle vendor specific resource types. These resource types would be very specific to an implementation instance that it does not make sense for the framework to handle it. For instance, a remoteproc implementation might want timers information embedded in the resource table so that the driver could parse the binary and enable accordingly. Another example would be hwspinlocks that it is using, to properly share system wide resources. The PRU interrupt controller's interrupt-map could be provided via a vendor specific resource. This patch adds a function pointer to the list of rproc_ops for the driver implementation to handle such custom vendor resources. [rogerq@ti.com] Get rid of pre/post loaders. Show in debugfs. Signed-off-by: Suman Anna Signed-off-by: Roger Quadros --- drivers/remoteproc/remoteproc_core.c | 36 +++++++++++++++++++++++++++++++++ drivers/remoteproc/remoteproc_debugfs.c | 3 +++ include/linux/remoteproc.h | 17 ++++++++++++++-- 3 files changed, 54 insertions(+), 2 deletions(-) -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 2d9646f..b43aa40 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -896,6 +896,41 @@ void rproc_add_carveout(struct rproc *rproc, struct rproc_mem_entry *mem) EXPORT_SYMBOL(rproc_add_carveout); /** + * rproc_handle_vendor_rsc() - provide implementation specific hook + * to handle vendor/custom resources + * @rproc: the remote processor + * @rsc: vendor resource to be handled by remoteproc drivers + * @offset: offset of the resource data in resource table + * @avail: size of available data + * + * Remoteproc implementations might want to add resource table entries + * that are not generic enough to be handled by the framework. This + * provides a hook to handle such custom resources. + * + * Returns 0 on success, or an appropriate error code otherwise + */ +static int rproc_handle_vendor_rsc(struct rproc *rproc, + struct fw_rsc_vendor *rsc, + int offset, int avail) +{ + struct device *dev = &rproc->dev; + + if (sizeof(*rsc) > avail) { + dev_err(dev, "vendor rsc is truncated\n"); + return -EINVAL; + } + + dev_dbg(dev, "vendor rsc:"); + + if (!rproc->ops->handle_vendor_rsc) { + dev_err(dev, "no vendor rsc handler! ignoring resource\n"); + return 0; + } + + return rproc->ops->handle_vendor_rsc(rproc, (void *)rsc); +} + +/** * rproc_mem_entry_init() - allocate and initialize rproc_mem_entry struct * @dev: pointer on device struct * @va: virtual address @@ -983,6 +1018,7 @@ static rproc_handle_resource_t rproc_loading_handlers[RSC_LAST] = { [RSC_CARVEOUT] = (rproc_handle_resource_t)rproc_handle_carveout, [RSC_DEVMEM] = (rproc_handle_resource_t)rproc_handle_devmem, [RSC_TRACE] = (rproc_handle_resource_t)rproc_handle_trace, + [RSC_VENDOR] = (rproc_handle_resource_t)rproc_handle_vendor_rsc, [RSC_VDEV] = (rproc_handle_resource_t)rproc_handle_vdev, }; diff --git a/drivers/remoteproc/remoteproc_debugfs.c b/drivers/remoteproc/remoteproc_debugfs.c index e90135c..ef66165 100644 --- a/drivers/remoteproc/remoteproc_debugfs.c +++ b/drivers/remoteproc/remoteproc_debugfs.c @@ -230,6 +230,9 @@ static int rproc_rsc_table_show(struct seq_file *seq, void *p) v->vring[j].pa); } break; + case RSC_VENDOR: + seq_printf(seq, "Entry %d is of type %s [Vendor specific]\n", + i, types[hdr->type]); default: seq_printf(seq, "Unknown resource type found: %d [hdr: %pK]\n", hdr->type, hdr); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index b5aa5fb..9f4c457 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -100,6 +100,7 @@ struct fw_rsc_hdr { * the remote processor will be writing logs. * @RSC_VDEV: declare support for a virtio device, and serve as its * virtio header. + * @RSC_VENDOR: vendor specific resource type. * @RSC_LAST: just keep this one at the end * * For more details regarding a specific resource type, please see its @@ -115,7 +116,8 @@ enum fw_resource_type { RSC_DEVMEM = 1, RSC_TRACE = 2, RSC_VDEV = 3, - RSC_LAST = 4, + RSC_VENDOR = 4, + RSC_LAST, }; #define FW_RSC_ADDR_ANY (-1) @@ -308,6 +310,14 @@ struct fw_rsc_vdev { struct rproc; /** + * struct fw_rsc_vendor - vendor specific resource definition + * @data: resource data. vendor defined. + */ +struct fw_rsc_vendor { + u8 data[0]; +} __packed; + +/** * struct rproc_mem_entry - memory entry descriptor * @va: virtual address * @dma: dma address @@ -347,7 +357,8 @@ struct firmware; * @da_to_va: optional platform hook to perform address translations * @load_rsc_table: load resource table from firmware image * @find_loaded_rsc_table: find the loaded resouce table - * @load: load firmeware to memory, where the remote processor + * @handle_vendor_rsc: hook to handle device specific resource table entries + * @load: load firmware to memory, where the remote processor * expects to find it * @sanity_check: sanity check the fw image * @get_boot_addr: get boot address to entry point specified in firmware @@ -360,6 +371,8 @@ struct rproc_ops { 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 (*handle_vendor_rsc)(struct rproc *rproc, + struct fw_rsc_vendor *rsc); int (*load)(struct rproc *rproc, const struct firmware *fw); int (*sanity_check)(struct rproc *rproc, const struct firmware *fw); u32 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw);