From patchwork Wed Dec 13 22:41:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 121872 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6064840qgn; Wed, 13 Dec 2017 14:43:01 -0800 (PST) X-Google-Smtp-Source: ACJfBouZxvs7GO/C1ws1vglgDpf7rsYaMl9P3VF+M2/4AKaV5S7994sHxl/duAUCvolPZyKhsMB5 X-Received: by 10.98.46.7 with SMTP id u7mr7545808pfu.37.1513204981461; Wed, 13 Dec 2017 14:43:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513204981; cv=none; d=google.com; s=arc-20160816; b=HlyDITHVteKNEtQ0j9uSGiq4X4t0YyS+pTdwlbqGm12wjh6U/qEoO1fZ7ab8l+Wf1l rA+OXYHt+70MubuZ9s29zvkCgH6GvmXQ6x1Y5KU85bqfsA3jQjrpVgnavtiLrOIwhETr 7DbAMU6uLFjFboRH7uvTeuIBQCEs9onGgxrMrX6kA2PfHdeYy2+Dw28kONoikvRzCnZS Jiy62zAATMqUGEpuWD0DLvUqcEm3/NXbDE3Agm543xgS+0OsfO+LJPE89YHQmemCOv7y cF1SPFfg19DSAFM+uk5m2gxObGgPX9KF/QdXUVn7LylfzlgG2oiy64/wBkHJUBbeVqwP xNZw== 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=bq8TdGQjagZoow55sXdxLaQ04rt/+nuXUXQV/0cUf1c=; b=mPfbV/H3affL5P1rGP8YbvvBRtq9KYYXQhQreSjliFmffymAMn/iRXWZoWhROrjyhO t/AE3twTCDj+CPIee0xqgnk2LDraje1/iES4BsFmvztagOIWvyTLXjiSoR1lwPMMq1MX tHveKFJiGFZmHIzXnIUmm5Xg+wEtrBddyTw74C3Cac2bJOV4Bw85sAtQA0RqU1oFSHMz mDVN1GOBNWcd1daCgxbVl9nsXSe5FfFnLGARwAHu+QEc/b6FhzgJ1iz9fxSvHK/uLvqk DbNvC5LSb++LXjRAYjq12JpceehHiPxp8vM2W+HgpnT8wgZlgfPuSoiywcV+8l2UPNpl FFOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fPRWtqBR; 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 t25si1877854pgv.644.2017.12.13.14.43.01; Wed, 13 Dec 2017 14:43:01 -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=fPRWtqBR; 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 S1753190AbdLMWm5 (ORCPT + 23 others); Wed, 13 Dec 2017 17:42:57 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33866 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752434AbdLMWlR (ORCPT ); Wed, 13 Dec 2017 17:41:17 -0500 Received: by mail-pf0-f195.google.com with SMTP id a90so2202861pfk.1 for ; Wed, 13 Dec 2017 14:41:17 -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=bq8TdGQjagZoow55sXdxLaQ04rt/+nuXUXQV/0cUf1c=; b=fPRWtqBR5Wr46ahCySP6KQf/LsxPAKAB2OhG5hLtPoMQD+TY1iVQ29dGt30JqYi1Ud lWYsGaUfuRWs6JYnpiMsuCTzpNzNe3TDvb6JP7HG7iY9Ba9/tbV/HIb0ifDbXpjiFDCt F7s92lAQid/RC9UJRbP68qz1XoeIZUpjcDWKE= 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=bq8TdGQjagZoow55sXdxLaQ04rt/+nuXUXQV/0cUf1c=; b=qZao5d1yf7H7m71dWDrDDbLpozASeY9FB72U+S9q+5R7IfvHscIM5kqG/mx+Jw/BnZ nK+LP6BgQpY79Eecrx5zXs+V4mamwPqi3WuK4H9jrk0aPUP+eCxgHsW5RkzohA6KON5C Hyess6f//oKIwDK9BzjV0pHnFURMaT5927/7W2Liq1/BVZWUupFSiVQY9i+IPbiabXY5 kEXYsO+CmBaHIVtkkivh/PQG2F4NTpZXG3GALN9u1Oy9LdsG2i53At+wgQ0yirawcgQv N1JLLW2Nrlgp8N6q16/BA4/Ei9DG3LDOwMmtp2jYGd4+kNkut1NBnHmACUbMPATyfZnQ mElw== X-Gm-Message-State: AKGB3mLXIiiDzurE6fwkRXX6YOk0F/scpou5sjAJYJCjKy4qvRiV7KgJ 4AG+bkYs06ripKRUFBAOtSeqSw== X-Received: by 10.84.217.131 with SMTP id p3mr163810pli.270.1513204877004; Wed, 13 Dec 2017 14:41:17 -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 x15sm4464205pfh.27.2017.12.13.14.41.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 14:41:15 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/8] remoteproc: Remove depricated crash completion Date: Wed, 13 Dec 2017 14:41:04 -0800 Message-Id: <20171213224111.17864-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171213224111.17864-1-bjorn.andersson@linaro.org> References: <20171213224111.17864-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 crash handling now happens in a single execution context, so there's no longer a need for a completion to synchronize this. Signed-off-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_core.c | 10 ---------- include/linux/remoteproc.h | 2 -- 2 files changed, 12 deletions(-) -- 2.15.0 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index b2f8afee2b67..15e2c4530a0a 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1028,10 +1028,6 @@ static int rproc_stop(struct rproc *rproc, bool graceful) return ret; } - /* if in crash state, unlock crash handler */ - if (rproc->state == RPROC_CRASHED) - complete_all(&rproc->crash_comp); - rproc->state = RPROC_OFFLINE; dev_info(dev, "stopped remote processor %s\n", rproc->name); @@ -1057,8 +1053,6 @@ int rproc_trigger_recovery(struct rproc *rproc) dev_err(dev, "recovering %s\n", rproc->name); - init_completion(&rproc->crash_comp); - ret = mutex_lock_interruptible(&rproc->lock); if (ret) return ret; @@ -1067,9 +1061,6 @@ int rproc_trigger_recovery(struct rproc *rproc) if (ret) goto unlock_mutex; - /* wait until there is no more rproc users */ - wait_for_completion(&rproc->crash_comp); - /* load firmware */ ret = request_firmware(&firmware_p, rproc->firmware, dev); if (ret < 0) { @@ -1459,7 +1450,6 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, INIT_LIST_HEAD(&rproc->subdevs); INIT_WORK(&rproc->crash_handler, rproc_crash_handler_work); - init_completion(&rproc->crash_comp); rproc->state = RPROC_OFFLINE; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 20a9467744ea..2d1058111e57 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -406,7 +406,6 @@ enum rproc_crash_type { * @index: index of this rproc device * @crash_handler: workqueue for handling a crash * @crash_cnt: crash counter - * @crash_comp: completion used to sync crash handler and the rproc reload * @recovery_disabled: flag that state if recovery was disabled * @max_notifyid: largest allocated notify id. * @table_ptr: pointer to the resource table in effect @@ -437,7 +436,6 @@ struct rproc { int index; struct work_struct crash_handler; unsigned int crash_cnt; - struct completion crash_comp; bool recovery_disabled; int max_notifyid; struct resource_table *table_ptr; From patchwork Wed Dec 13 22:41:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 121865 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6063496qgn; Wed, 13 Dec 2017 14:41:27 -0800 (PST) X-Google-Smtp-Source: ACJfBovU5oyVsfvtMuxjdhdu680qe8hJyp/8H3cg7svhGI4vz03A4jKvG6wGnsxC/b+qq+l/wDiK X-Received: by 10.101.88.76 with SMTP id s12mr6720838pgr.215.1513204887603; Wed, 13 Dec 2017 14:41:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513204887; cv=none; d=google.com; s=arc-20160816; b=hGgy4kgtweV8sTkeLkFCOikoNoTvnbMs9Of+x54kPH+W36hLodmCfI8moHH5oD+btl u8L1eFHDoeMG36xcHMbQxaLbmWsAOwN7Mj+PWw3a3V8L/r6ydHByphnMc8asuTPavFfa U1oT2InsHBr9UDSFbjVGVe/+VmXXWidltgnCV1uEDtpZ4HGjTCR8Bx2h2HLsdDACQyo1 1Zk29OffqN5B6oGyqyceB4ZGcyKMfFMXTgjfqJHq+z21/2kvBlpjmghCXmxNGxt2ogrq OfJdMEt1JrySAae3snaIhAItor9GvN2xiZKzCYmZA8QnK9twixFpqeXhUg6g4D3kNt0R zZmg== 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=vybEUD2Ym1nB0jZPhcn21y0tKF2tB8Iopk+yfmykgkg=; b=pk+rTi1GG8ISBwCy47UJ/Fl9DokcPaunXSfY8G+1xlwmQV4kIdsh0xCOxWy/7Av1Ty yWMarYYwrk1za2EhcmBEYorVbV8Iq1joGg7+x5u3Dq0GiUv8Imzi8taYvo+3vaKNK8D9 g0ISxPckIzPzxFG9ZFPP3WSv+eJuyuIx+q57v2V+ZkkEBVX6S6WkBp76k0ivbpmlElAZ UfxT9S73auFfiUB8ztpKap3Eow/saWFcP6teSyfZ9D32LO/2W41871AjwqPpw0zuSvm0 taybmsz0/2X6rtcbWCaet6P3+/3y/bgQh0qvINhE1zMrjL4zMGIpSNtayuwI2ZMC5+X5 P1wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=huInVnI+; 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 s189si1914114pgc.225.2017.12.13.14.41.27; Wed, 13 Dec 2017 14:41:27 -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=huInVnI+; 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 S1752903AbdLMWlV (ORCPT + 23 others); Wed, 13 Dec 2017 17:41:21 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:36890 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752805AbdLMWlT (ORCPT ); Wed, 13 Dec 2017 17:41:19 -0500 Received: by mail-pg0-f68.google.com with SMTP id y6so2060493pgp.4 for ; Wed, 13 Dec 2017 14:41:18 -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=vybEUD2Ym1nB0jZPhcn21y0tKF2tB8Iopk+yfmykgkg=; b=huInVnI+4EV5qbFVx5QCaNXZbbwAAgdqvG9uBPbRTYaoZPpHtrjQm5jkmtghTOMjgA oSZTfieB/inWce3L8HpaVCV1Z/sjEzNheHl9pMw9SS4g3jdJZhbVD9tXxH0XeWci84I1 TV4P13p0IBmE1AUoEsOGu7nZt0dsxnSoJpDLY= 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=vybEUD2Ym1nB0jZPhcn21y0tKF2tB8Iopk+yfmykgkg=; b=jrkUn69sVQ/HzQlXra0JcA3p6wRGFtfdIAH/FDgDjZjEMrBCvwo3LjLtIydPgj57om x09iMnZLHxmU4PiWlhLCs8hEHFN0FUcC0mzxDt220hLNyNAeMMU+M80oIt0LAUf2BoNg NkFyq0q2gJi/01REvdR1gm7kcdWq8aFoGPXDvqKEoi2+QTOi6bfVdOH9CD2AiHJMyAEv rv/Jyc3Fm6MAP/VWq93ZTEAXPxNMblxwFUeG6GgtKrdlYdmAptmMTgrD8pqd2MeZh2D0 3GCFX34/Imd7D3wBF5txxhU9U0hNjnkPHTUKDW5D80sKpsjgOWh8IldHMv4flbznoZzD y3OA== X-Gm-Message-State: AKGB3mIAg0TAmmgYTdvM/JXyMpbY62ZetfxCu4gc8HGuN/DwP0G5195/ 4Jv5fT9THzeBl1wW5hfdN4yrm93Otww= X-Received: by 10.98.89.220 with SMTP id k89mr7590119pfj.36.1513204878300; Wed, 13 Dec 2017 14:41:18 -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 x15sm4464205pfh.27.2017.12.13.14.41.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 14:41:17 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/8] remoteproc: Cache resource table size Date: Wed, 13 Dec 2017 14:41:05 -0800 Message-Id: <20171213224111.17864-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171213224111.17864-1-bjorn.andersson@linaro.org> References: <20171213224111.17864-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We don't re-read the resource table during a recovery, so it is possible in the recovery path that the resource table has a different size than cached_table. Store the original size of cached_table to avoid these getting out of sync. Signed-off-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_core.c | 20 +++++++------------- include/linux/remoteproc.h | 2 ++ 2 files changed, 9 insertions(+), 13 deletions(-) -- 2.15.0 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 15e2c4530a0a..761268096fe0 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -732,7 +732,7 @@ static rproc_handle_resource_t rproc_loading_handlers[RSC_LAST] = { }; /* handle firmware resource entries before booting the remote processor */ -static int rproc_handle_resources(struct rproc *rproc, int len, +static int rproc_handle_resources(struct rproc *rproc, rproc_handle_resource_t handlers[RSC_LAST]) { struct device *dev = &rproc->dev; @@ -742,7 +742,7 @@ static int rproc_handle_resources(struct rproc *rproc, int len, for (i = 0; i < rproc->table_ptr->num; i++) { int offset = rproc->table_ptr->offset[i]; struct fw_rsc_hdr *hdr = (void *)rproc->table_ptr + offset; - int avail = len - offset - sizeof(*hdr); + int avail = rproc->table_sz - offset - sizeof(*hdr); void *rsc = (void *)hdr + sizeof(*hdr); /* make sure table isn't truncated */ @@ -849,16 +849,9 @@ static void rproc_resource_cleanup(struct rproc *rproc) static int rproc_start(struct rproc *rproc, const struct firmware *fw) { - struct resource_table *table, *loaded_table; + struct resource_table *loaded_table; struct device *dev = &rproc->dev; - int ret, tablesz; - - /* look for the resource table */ - table = rproc_find_rsc_table(rproc, fw, &tablesz); - if (!table) { - dev_err(dev, "Resource table look up failed\n"); - return -EINVAL; - } + int ret; /* load the ELF segments to memory */ ret = rproc_load_segments(rproc, fw); @@ -877,7 +870,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) */ loaded_table = rproc_find_loaded_rsc_table(rproc, fw); if (loaded_table) { - memcpy(loaded_table, rproc->cached_table, tablesz); + memcpy(loaded_table, rproc->cached_table, rproc->table_sz); rproc->table_ptr = loaded_table; } @@ -951,12 +944,13 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) goto clean_up; rproc->table_ptr = rproc->cached_table; + rproc->table_sz = tablesz; /* reset max_notifyid */ rproc->max_notifyid = -1; /* handle fw resources which are required to boot rproc */ - ret = rproc_handle_resources(rproc, tablesz, rproc_loading_handlers); + ret = rproc_handle_resources(rproc, rproc_loading_handlers); if (ret) { dev_err(dev, "Failed to process resources: %d\n", ret); goto clean_up_resources; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 2d1058111e57..b72be13d773d 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -410,6 +410,7 @@ enum rproc_crash_type { * @max_notifyid: largest allocated notify id. * @table_ptr: pointer to the resource table in effect * @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 */ struct rproc { @@ -440,6 +441,7 @@ struct rproc { int max_notifyid; struct resource_table *table_ptr; struct resource_table *cached_table; + size_t table_sz; bool has_iommu; bool auto_boot; }; From patchwork Wed Dec 13 22:41:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 121871 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6064624qgn; Wed, 13 Dec 2017 14:42:44 -0800 (PST) X-Google-Smtp-Source: ACJfBotcIaSQGp3crUiCNzke2Tkv9mPtgg3fAAuT+TcqoLudNShvn1QNXLi6iu66G44mBlASHiqd X-Received: by 10.159.214.138 with SMTP id n10mr7563562plp.362.1513204964371; Wed, 13 Dec 2017 14:42:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513204964; cv=none; d=google.com; s=arc-20160816; b=tO/qQyaQv6AjcUqblHie1yToTmZpe2T9BX9OcnTOODzOyL36TnDYpO62499DicfuNb 6Y5sDVs0LvFQkubtBrzn0DOzlP+KekQokTsG/HMQnQ3qnvZukOwDJUyKhY+WwfzJG5l1 YiDvLNgfsiFpMbrCS2meC5hFmiX1cIDIq8OGYeR+92LyFxmPQ890INJVh9YpoHqxJ7M2 RUXSXqLDNhmvWEeAhEHZRhmt7R+lJubY4c9vbE8IcdYV0SRWrg6zRoLLKuJVSdyXnf8r NZx6OQtunk6JoESMm9mjDJ9Zr3wdJ3qVp8PFQEPxtA9iAPFubULAQzwvBbf2thzAgJso xDVw== 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=xhCBnesiLjhoYEEDZ5FhKfryaBuOCtv9nmTPhUeGhnk=; b=EBJCDv3se/y4gnmbitXo0QJ02KRlqfmnVh+Qc+WIcGh3FS/EhRc8Do9dItUCMlYTwN YKQvxZADtYX93JQxP9g9524v3IzjfeI+B3otG16BQiM40IpOgtLbQBSDwSf5owi93ziV iHBlqV3z2x/R+hNhiShV8WYewyrh8R3MyuWRRom9a9Vs/iGRRY9tOLo1wvO7IqnYkMlY Lws/f5stEkmBSctC06r3I9LalFVOaU3Rzb4HcHMmLXNs6Tk+jceZ4y/YN2yR1HcGCSak 0tN9qI4LjyGGAo6GOFXltV6WgqXmbTSEjCFg3s8geXbQ1YtT35wuLcmWuqow1lCtdIiw 5jwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LfAabWRX; 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 t25si1877854pgv.644.2017.12.13.14.42.44; Wed, 13 Dec 2017 14:42:44 -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=LfAabWRX; 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 S1753187AbdLMWml (ORCPT + 23 others); Wed, 13 Dec 2017 17:42:41 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:44352 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752811AbdLMWlU (ORCPT ); Wed, 13 Dec 2017 17:41:20 -0500 Received: by mail-pf0-f195.google.com with SMTP id m26so2183611pfj.11 for ; Wed, 13 Dec 2017 14:41:20 -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=xhCBnesiLjhoYEEDZ5FhKfryaBuOCtv9nmTPhUeGhnk=; b=LfAabWRXEH9qPoYmSxSVs2YvALfcGI2YJpwEw/y0K5s/JipPPWaqqpUw0OT3bFPxtO cCb4nIMnP3vXQdgk9bWimyHFNKkvw2JhFblC9YFfdiiKGvI5/EqgVMdOYT+Y1s2Bm6kC f3YQpSZ0Ay+Sf3jzVATEHIT7YHQ5sBq1LOk6U= 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=xhCBnesiLjhoYEEDZ5FhKfryaBuOCtv9nmTPhUeGhnk=; b=MvnVWvaYActig3JhD4yoOZjQ6mnnBWa+TB3EOBYp4GBynjBpMR4mpfSMsVjA6KynNA dojFWtXcu2YNL8Htc8mYYcBp9s64B5OO/0BiR5kexspWgS/oSEa+hoQRy1slBxgO6YUQ ncxbTFfVGhOur5JF0DxbjhuPgaLbKQdr8qjmQFyAo0xO/5dh77irZAoG9o4QANtmOcGy iWTDUqxnB7qHl/MDi/RqwFg+LO0lQ5SG18VI5DklOuG9WrKN8dZ+XW8uvN88jAQ5ct8f 2b9bufMnr7G2F7tyQ5wzmISVbpDwS/rGFeQVrs9rUbVIp2FDgNt1YzH0E2nOMlVv0bT0 RFvw== X-Gm-Message-State: AKGB3mJaMSv17Jwb5yogSylYis4O4nDOKS1TiosZeRaAY0bbZTcGNvhc PYNHmqIjYgcatx20cJOEEbe6LA== X-Received: by 10.98.76.90 with SMTP id z87mr7604905pfa.194.1513204879510; Wed, 13 Dec 2017 14:41:19 -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 x15sm4464205pfh.27.2017.12.13.14.41.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 14:41:18 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/8] remoteproc: Clone rproc_ops in rproc_alloc() Date: Wed, 13 Dec 2017 14:41:06 -0800 Message-Id: <20171213224111.17864-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171213224111.17864-1-bjorn.andersson@linaro.org> References: <20171213224111.17864-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to allow rproc_alloc() to, in a future patch, update entries in the "ops" struct we need to make a local copy of it. Signed-off-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_core.c | 9 ++++++++- include/linux/remoteproc.h | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) -- 2.15.0 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 761268096fe0..9bc9ee8f4513 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1342,6 +1342,7 @@ static void rproc_type_release(struct device *dev) ida_simple_remove(&rproc_dev_index, rproc->index); kfree(rproc->firmware); + kfree(rproc->ops); kfree(rproc); } @@ -1406,9 +1407,15 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, return NULL; } + rproc->ops = kmemdup(ops, sizeof(*ops), GFP_KERNEL); + if (!rproc->ops) { + kfree(p); + kfree(rproc); + return NULL; + } + rproc->firmware = p; rproc->name = name; - rproc->ops = ops; rproc->priv = &rproc[1]; rproc->auto_boot = true; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index b72be13d773d..6cbc0379a926 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -419,7 +419,7 @@ struct rproc { const char *name; char *firmware; void *priv; - const struct rproc_ops *ops; + struct rproc_ops *ops; struct device dev; const struct rproc_fw_ops *fw_ops; atomic_t power; From patchwork Wed Dec 13 22:41:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 121866 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6063591qgn; Wed, 13 Dec 2017 14:41:37 -0800 (PST) X-Google-Smtp-Source: ACJfBosaH563axKu1O9NpiEhwVvrVZYandKPW09I+NwP/rYCQ4yrE70XjbHDekeIhVD4AeCWYJ5k X-Received: by 10.84.212.16 with SMTP id d16mr7198772pli.61.1513204897030; Wed, 13 Dec 2017 14:41:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513204897; cv=none; d=google.com; s=arc-20160816; b=dwEYLGHTdClry/7GHDgtteBn1H9Tod2IrtoAjm//7QMGa+MMM1ypUmI7pE1XppCRiV kIRQYR4HbzQXG+8b/yeFTZVpTDJ6tlzdilMwtnfDjnEo2y5ezYQA4K5EGgTijj2jh0c7 EjhQHR5VG9Ul4eUyf0J2MY20u1TftG+ZzRoWNwMt4HndECHMKrdCEsitgrj7Gl5tTO95 2Z50Q0KGge+yIu9LsCtXAk9q7KiXnEwcjgbYe1oqA2UuhwtDcwtP6Jq+6Kx18CZN/y95 5MtP2LrLiW1WiU0xCLvv9lwYF9c8ce3u4s72kJTmTftciO3RqjnrV+yA72CxebcHsBy1 rzWQ== 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=UXo8nuklhPxLm/wIRtMWtB3df01W6RrvH8KhFgST1ss=; b=XpS7MDDyDzFEA8eJ6f5lYaG/OGyfATdL8ABuIFQQ5s6V0s/LnvqH28PvNpWBgX22Y0 2jKW6Ag5yDhFl12TBYdiQYRPPLLDwMeA9S9nKggnLKksZvSocV3VkZqdMLQKlPYA3Jss ZRBuyjGk8JLeMVZdhTjzkDwPITvxduti8laaFmeFOSVhwvy6zs1TK3iYNH+RU8dzmi8K 2XLDm0ZSksF5r3VAMJtRvnveNYJ5M8OUQc8nLRw/oW7YwUNnFlArVUaMQE86IBQ3MdJP lA2OBIjXsA0ttiC2yxFp2TcALjOK3xzkkk2SycsMQvEv4a3LThkFEvSyvcxkgbBvtnaQ sDXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DJu75wV1; 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 c78si2106352pfe.384.2017.12.13.14.41.36; Wed, 13 Dec 2017 14:41:37 -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=DJu75wV1; 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 S1753066AbdLMWlc (ORCPT + 23 others); Wed, 13 Dec 2017 17:41:32 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:42835 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752805AbdLMWlV (ORCPT ); Wed, 13 Dec 2017 17:41:21 -0500 Received: by mail-pg0-f67.google.com with SMTP id e14so2052686pgr.9 for ; Wed, 13 Dec 2017 14:41:21 -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=UXo8nuklhPxLm/wIRtMWtB3df01W6RrvH8KhFgST1ss=; b=DJu75wV1PPF4jQxNl/zXCQVyoouQFTlw/rPKi6EgByNkiqJzlNJRmtFohgpG8yoIXj zMkCYrD3ynUVCJ89cbA00gaFmHzZTR93n0Sf33kkrHf61Y2JcV0ecltuEblo5aG8VoFb PmUKGiixsW6iwbUN1rmWJZI04oXsXauRAmcoY= 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=UXo8nuklhPxLm/wIRtMWtB3df01W6RrvH8KhFgST1ss=; b=QaHVi3kF3ZiByKdTs6qGqvoWS37AwzNTIf2GGWUrB2xc2i/RCT4RUjyPMuyyE2nyxg wHbonZHRzYZ7IoFGVdS0yJsEPazVZsYNjPBENlaYxvn3bnntk+1I1uBfu1LJnB4h7IDr 50THXLPjtAg4ZaVmELrvuuGQEqt859MuaGWFozm9G+1wUSrjztaZrKrlMT7OitsriaJR NoLJy6D9armfmglOkTmxv+dmDBqjuGZyqisw2U6eOBhSambuWsi8FyFdaJIno1HDejsC DFaUyi55ZUA/XPMVgK2U6ULmD3dA9YoxmLLHE9aAQJ0V/jdZHgKpz62DseWVbal/HUWy 7+Ug== X-Gm-Message-State: AKGB3mJ7Y4bkD7msWxe6csJdJMhU3zA3Lpq4aJK8DhPMBIiMkz+9+BZF Ia5DHQjhATfARvrAbcrhcF56fw== X-Received: by 10.98.130.4 with SMTP id w4mr7414518pfd.238.1513204880862; Wed, 13 Dec 2017 14:41:20 -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 x15sm4464205pfh.27.2017.12.13.14.41.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 14:41:19 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/8] remoteproc: Merge rproc_ops and rproc_fw_ops Date: Wed, 13 Dec 2017 14:41:07 -0800 Message-Id: <20171213224111.17864-5-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171213224111.17864-1-bjorn.andersson@linaro.org> References: <20171213224111.17864-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are currently a few different schemes used for overriding fw_ops or parts of fw_ops. Merge fw_ops into rproc_ops and expose the default ELF-loader symbols so that they can be assigned by the drivers. To keep backwards compatibility with the "default" case, a driver not specifying the "load" operation is assumed to want the full ELF-loader suit of functions. Signed-off-by: Bjorn Andersson --- drivers/remoteproc/qcom_adsp_pil.c | 9 ++---- drivers/remoteproc/qcom_q6v5_pil.c | 9 ++---- drivers/remoteproc/qcom_wcnss.c | 9 ++---- drivers/remoteproc/remoteproc_core.c | 10 ++++-- drivers/remoteproc/remoteproc_elf_loader.c | 30 +++++++----------- drivers/remoteproc/remoteproc_internal.h | 51 +++++++++++------------------- drivers/remoteproc/st_slim_rproc.c | 19 +++-------- include/linux/remoteproc.h | 17 ++++++++-- 8 files changed, 64 insertions(+), 90 deletions(-) -- 2.15.0 diff --git a/drivers/remoteproc/qcom_adsp_pil.c b/drivers/remoteproc/qcom_adsp_pil.c index 45e7e66604d4..7b9d810b23f1 100644 --- a/drivers/remoteproc/qcom_adsp_pil.c +++ b/drivers/remoteproc/qcom_adsp_pil.c @@ -89,11 +89,6 @@ static int adsp_load(struct rproc *rproc, const struct firmware *fw) adsp->mem_region, adsp->mem_phys, adsp->mem_size); } -static const struct rproc_fw_ops adsp_fw_ops = { - .find_rsc_table = qcom_mdt_find_rsc_table, - .load = adsp_load, -}; - static int adsp_start(struct rproc *rproc) { struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; @@ -186,6 +181,8 @@ static const struct rproc_ops adsp_ops = { .start = adsp_start, .stop = adsp_stop, .da_to_va = adsp_da_to_va, + .find_rsc_table = qcom_mdt_find_rsc_table, + .load = adsp_load, }; static irqreturn_t adsp_wdog_interrupt(int irq, void *dev) @@ -348,8 +345,6 @@ static int adsp_probe(struct platform_device *pdev) return -ENOMEM; } - rproc->fw_ops = &adsp_fw_ops; - adsp = (struct qcom_adsp *)rproc->priv; adsp->dev = &pdev->dev; adsp->rproc = rproc; diff --git a/drivers/remoteproc/qcom_q6v5_pil.c b/drivers/remoteproc/qcom_q6v5_pil.c index 342d5eb5d6ed..fbff5d842581 100644 --- a/drivers/remoteproc/qcom_q6v5_pil.c +++ b/drivers/remoteproc/qcom_q6v5_pil.c @@ -343,11 +343,6 @@ static int q6v5_load(struct rproc *rproc, const struct firmware *fw) return 0; } -static const struct rproc_fw_ops q6v5_fw_ops = { - .find_rsc_table = q6v5_find_rsc_table, - .load = q6v5_load, -}; - static int q6v5_rmb_pbl_wait(struct q6v5 *qproc, int ms) { unsigned long timeout; @@ -932,6 +927,8 @@ static const struct rproc_ops q6v5_ops = { .start = q6v5_start, .stop = q6v5_stop, .da_to_va = q6v5_da_to_va, + .find_rsc_table = q6v5_find_rsc_table, + .load = q6v5_load, }; static irqreturn_t q6v5_wdog_interrupt(int irq, void *dev) @@ -1151,8 +1148,6 @@ static int q6v5_probe(struct platform_device *pdev) return -ENOMEM; } - rproc->fw_ops = &q6v5_fw_ops; - qproc = (struct q6v5 *)rproc->priv; qproc->dev = &pdev->dev; qproc->rproc = rproc; diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c index dc79239c43f9..cc44ec598522 100644 --- a/drivers/remoteproc/qcom_wcnss.c +++ b/drivers/remoteproc/qcom_wcnss.c @@ -158,11 +158,6 @@ static int wcnss_load(struct rproc *rproc, const struct firmware *fw) wcnss->mem_region, wcnss->mem_phys, wcnss->mem_size); } -static const struct rproc_fw_ops wcnss_fw_ops = { - .find_rsc_table = qcom_mdt_find_rsc_table, - .load = wcnss_load, -}; - static void wcnss_indicate_nv_download(struct qcom_wcnss *wcnss) { u32 val; @@ -315,6 +310,8 @@ static const struct rproc_ops wcnss_ops = { .start = wcnss_start, .stop = wcnss_stop, .da_to_va = wcnss_da_to_va, + .find_rsc_table = qcom_mdt_find_rsc_table, + .load = wcnss_load, }; static irqreturn_t wcnss_wdog_interrupt(int irq, void *dev) @@ -494,8 +491,6 @@ static int wcnss_probe(struct platform_device *pdev) return -ENOMEM; } - rproc->fw_ops = &wcnss_fw_ops; - wcnss = (struct qcom_wcnss *)rproc->priv; wcnss->dev = &pdev->dev; wcnss->rproc = rproc; diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 9bc9ee8f4513..f2b6aa5d204c 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1437,8 +1437,14 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, atomic_set(&rproc->power, 0); - /* Set ELF as the default fw_ops handler */ - rproc->fw_ops = &rproc_elf_fw_ops; + /* Default to ELF loader if no load function is specified */ + if (!rproc->ops->load) { + rproc->ops->load = rproc_elf_load_segments; + rproc->ops->find_rsc_table = rproc_elf_find_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; + } mutex_init(&rproc->lock); diff --git a/drivers/remoteproc/remoteproc_elf_loader.c b/drivers/remoteproc/remoteproc_elf_loader.c index c523983a4aec..822fa1bf893f 100644 --- a/drivers/remoteproc/remoteproc_elf_loader.c +++ b/drivers/remoteproc/remoteproc_elf_loader.c @@ -39,8 +39,7 @@ * * Make sure this fw image is sane. */ -static int -rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw) +int rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw) { const char *name = rproc->firmware; struct device *dev = &rproc->dev; @@ -98,6 +97,7 @@ rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw) return 0; } +EXPORT_SYMBOL(rproc_elf_sanity_check); /** * rproc_elf_get_boot_addr() - Get rproc's boot address. @@ -110,13 +110,13 @@ rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw) * Note that the boot address is not a configurable property of all remote * processors. Some will always boot at a specific hard-coded address. */ -static u32 rproc_elf_get_boot_addr(struct rproc *rproc, const struct firmware *fw) { struct elf32_hdr *ehdr = (struct elf32_hdr *)fw->data; return ehdr->e_entry; } +EXPORT_SYMBOL(rproc_elf_get_boot_addr); /** * rproc_elf_load_segments() - load firmware segments to memory @@ -142,8 +142,7 @@ u32 rproc_elf_get_boot_addr(struct rproc *rproc, const struct firmware *fw) * directly allocate memory for every segment/resource. This is not yet * supported, though. */ -static int -rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) +int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) { struct device *dev = &rproc->dev; struct elf32_hdr *ehdr; @@ -207,6 +206,7 @@ rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) return ret; } +EXPORT_SYMBOL(rproc_elf_load_segments); static struct elf32_shdr * find_table(struct device *dev, struct elf32_hdr *ehdr, size_t fw_size) @@ -282,9 +282,9 @@ find_table(struct device *dev, struct elf32_hdr *ehdr, size_t fw_size) * size into @tablesz. If a valid table isn't found, NULL is returned * (and @tablesz isn't set). */ -static struct resource_table * -rproc_elf_find_rsc_table(struct rproc *rproc, const struct firmware *fw, - int *tablesz) +struct resource_table *rproc_elf_find_rsc_table(struct rproc *rproc, + const struct firmware *fw, + int *tablesz) { struct elf32_hdr *ehdr; struct elf32_shdr *shdr; @@ -303,6 +303,7 @@ rproc_elf_find_rsc_table(struct rproc *rproc, const struct firmware *fw, return table; } +EXPORT_SYMBOL(rproc_elf_find_rsc_table); /** * rproc_elf_find_loaded_rsc_table() - find the loaded resource table @@ -315,8 +316,8 @@ rproc_elf_find_rsc_table(struct rproc *rproc, const struct firmware *fw, * Returns the pointer to the resource table if it is found or NULL otherwise. * If the table wasn't loaded yet the result is unspecified. */ -static struct resource_table * -rproc_elf_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *fw) +struct resource_table *rproc_elf_find_loaded_rsc_table(struct rproc *rproc, + const struct firmware *fw) { struct elf32_hdr *ehdr = (struct elf32_hdr *)fw->data; struct elf32_shdr *shdr; @@ -327,11 +328,4 @@ rproc_elf_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *fw) return rproc_da_to_va(rproc, shdr->sh_addr, shdr->sh_size); } - -const struct rproc_fw_ops rproc_elf_fw_ops = { - .load = rproc_elf_load_segments, - .find_rsc_table = rproc_elf_find_rsc_table, - .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table, - .sanity_check = rproc_elf_sanity_check, - .get_boot_addr = rproc_elf_get_boot_addr -}; +EXPORT_SYMBOL(rproc_elf_find_loaded_rsc_table); diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index c1077bec5d0b..a42690c514e2 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -25,26 +25,6 @@ struct rproc; -/** - * struct rproc_fw_ops - firmware format specific operations. - * @find_rsc_table: find the resource table inside the firmware image - * @find_loaded_rsc_table: find the loaded resouce table - * @load: load firmeware 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 - */ -struct rproc_fw_ops { - struct resource_table *(*find_rsc_table)(struct rproc *rproc, - const struct firmware *fw, - int *tablesz); - struct resource_table *(*find_loaded_rsc_table)( - struct rproc *rproc, const struct firmware *fw); - 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); -}; - /* from remoteproc_core.c */ void rproc_release(struct kref *kref); irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id); @@ -74,11 +54,20 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i); void *rproc_da_to_va(struct rproc *rproc, u64 da, int len); int rproc_trigger_recovery(struct rproc *rproc); +int rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw); +u32 rproc_elf_get_boot_addr(struct rproc *rproc, const struct firmware *fw); +int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw); +struct resource_table *rproc_elf_find_rsc_table(struct rproc *rproc, + const struct firmware *fw, + int *tablesz); +struct resource_table *rproc_elf_find_loaded_rsc_table(struct rproc *rproc, + const struct firmware *fw); + static inline int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) { - if (rproc->fw_ops->sanity_check) - return rproc->fw_ops->sanity_check(rproc, fw); + if (rproc->ops->sanity_check) + return rproc->ops->sanity_check(rproc, fw); return 0; } @@ -86,8 +75,8 @@ int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) static inline u32 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw) { - if (rproc->fw_ops->get_boot_addr) - return rproc->fw_ops->get_boot_addr(rproc, fw); + if (rproc->ops->get_boot_addr) + return rproc->ops->get_boot_addr(rproc, fw); return 0; } @@ -95,8 +84,8 @@ u32 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw) static inline int rproc_load_segments(struct rproc *rproc, const struct firmware *fw) { - if (rproc->fw_ops->load) - return rproc->fw_ops->load(rproc, fw); + if (rproc->ops->load) + return rproc->ops->load(rproc, fw); return -EINVAL; } @@ -106,8 +95,8 @@ struct resource_table *rproc_find_rsc_table(struct rproc *rproc, const struct firmware *fw, int *tablesz) { - if (rproc->fw_ops->find_rsc_table) - return rproc->fw_ops->find_rsc_table(rproc, fw, tablesz); + if (rproc->ops->find_rsc_table) + return rproc->ops->find_rsc_table(rproc, fw, tablesz); return NULL; } @@ -116,12 +105,10 @@ static inline struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *fw) { - if (rproc->fw_ops->find_loaded_rsc_table) - return rproc->fw_ops->find_loaded_rsc_table(rproc, fw); + if (rproc->ops->find_loaded_rsc_table) + return rproc->ops->find_loaded_rsc_table(rproc, fw); return NULL; } -extern const struct rproc_fw_ops rproc_elf_fw_ops; - #endif /* REMOTEPROC_INTERNAL_H */ diff --git a/drivers/remoteproc/st_slim_rproc.c b/drivers/remoteproc/st_slim_rproc.c index 6cfd862f945b..1538ea915c49 100644 --- a/drivers/remoteproc/st_slim_rproc.c +++ b/drivers/remoteproc/st_slim_rproc.c @@ -200,12 +200,6 @@ static void *slim_rproc_da_to_va(struct rproc *rproc, u64 da, int len) return va; } -static const struct rproc_ops slim_rproc_ops = { - .start = slim_rproc_start, - .stop = slim_rproc_stop, - .da_to_va = slim_rproc_da_to_va, -}; - /* * Firmware handler operations: sanity, boot address, load ... */ @@ -223,7 +217,10 @@ static struct resource_table *slim_rproc_find_rsc_table(struct rproc *rproc, return &empty_rsc_tbl; } -static struct rproc_fw_ops slim_rproc_fw_ops = { +static const struct rproc_ops slim_rproc_ops = { + .start = slim_rproc_start, + .stop = slim_rproc_stop, + .da_to_va = slim_rproc_da_to_va, .find_rsc_table = slim_rproc_find_rsc_table, }; @@ -249,7 +246,6 @@ struct st_slim_rproc *st_slim_rproc_alloc(struct platform_device *pdev, struct rproc *rproc; struct resource *res; int err, i; - const struct rproc_fw_ops *elf_ops; if (!fw_name) return ERR_PTR(-EINVAL); @@ -267,13 +263,6 @@ struct st_slim_rproc *st_slim_rproc_alloc(struct platform_device *pdev, slim_rproc = rproc->priv; slim_rproc->rproc = rproc; - elf_ops = rproc->fw_ops; - /* Use some generic elf ops */ - slim_rproc_fw_ops.load = elf_ops->load; - slim_rproc_fw_ops.sanity_check = elf_ops->sanity_check; - - rproc->fw_ops = &slim_rproc_fw_ops; - /* get imem and dmem */ for (i = 0; i < ARRAY_SIZE(mem_names); i++) { res = platform_get_resource_byname(pdev, IORESOURCE_MEM, diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 6cbc0379a926..e21de55e19d1 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -324,6 +324,7 @@ struct rproc_mem_entry { }; struct rproc; +struct firmware; /** * struct rproc_ops - platform-specific device handlers @@ -331,12 +332,26 @@ struct rproc; * @stop: power off the device * @kick: kick a virtqueue (virtqueue id given as a parameter) * @da_to_va: optional platform hook to perform address translations + * @find_rsc_table: find the resource table inside the firmware image + * @find_loaded_rsc_table: find the loaded resouce table + * @load: load firmeware 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 */ struct rproc_ops { int (*start)(struct rproc *rproc); int (*stop)(struct rproc *rproc); void (*kick)(struct rproc *rproc, int vqid); void * (*da_to_va)(struct rproc *rproc, u64 da, int len); + struct resource_table *(*find_rsc_table)(struct rproc *rproc, + const struct firmware *fw, + int *tablesz); + struct resource_table *(*find_loaded_rsc_table)( + struct rproc *rproc, const struct firmware *fw); + 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); }; /** @@ -390,7 +405,6 @@ enum rproc_crash_type { * @priv: private data which belongs to the platform-specific rproc module * @ops: platform-specific start/stop rproc handlers * @dev: virtual device for refcounting and common remoteproc behavior - * @fw_ops: firmware-specific handlers * @power: refcount of users who need this rproc powered up * @state: state of the device * @lock: lock which protects concurrent manipulations of the rproc @@ -421,7 +435,6 @@ struct rproc { void *priv; struct rproc_ops *ops; struct device dev; - const struct rproc_fw_ops *fw_ops; atomic_t power; unsigned int state; struct mutex lock; From patchwork Wed Dec 13 22:41:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 121867 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6063793qgn; Wed, 13 Dec 2017 14:41:48 -0800 (PST) X-Google-Smtp-Source: ACJfBouF/rRMecxlxQvDZJyxyjHS8eceJisK+PCZ1GhfrtJ39jtGd1jV0jctDdeAbNYIyqT8ahjO X-Received: by 10.98.149.72 with SMTP id p69mr7598778pfd.76.1513204908621; Wed, 13 Dec 2017 14:41:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513204908; cv=none; d=google.com; s=arc-20160816; b=vy5Wfu94POKblNuA+gbUxDS3KU+Ohkc2dC6g+fifwdzvRm6gP6Fa4dKtIxVMdkoO1e Cmueei+H1S9zlmjYp7leGmS/QvXcYvhUg8cJumNyh/1gTP6n4wc/FZijEReL0WYG1PPB 7Yzbb9uS7vlriiDH2Q7XSmKHe4KFHS1FXajbZV0mrz37rUh+cc+5ZfFhAx481Gy6iARa Zsw3LpsYGrk/ra9Rjic1kVrXXXrm6nibQbPRqhyGB5qcmCjeYeUYbsr+2HgTcwEZdl61 pc7ZmCdWWGoQENwYZdX87HyQKyJyX+NysOdq9YmCQQjGlW9ZX4fkugiNfI1H/1CT9gaV FI+w== 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=Zcmq7LN6XwZSTJJcZ3bU/gby1PmpQujyigPB6KR2Kcg=; b=TuDSGamJ8TJqo9mgomhL+E+ywcd0Fa7f2kSeddBNKFzhZh8z7CUvZZbe+xOpPVAX7N NgLT62aplkyhsztsFX50+wKWifGW0ExjKwvUrapT0frLzo8LVm/OH24N04gHLi3aTKrD 7EIqVSb0UDh5YG9+HYS9+qyPGGpMIOHsSCVbG580s0iFIHcnB1aU3IUno5gM5e1DQt5P IrhvKPkK37oS37X9zvWjJNmR9Gbi9iTHf25dA6q4p9ybLeF1ZgSwbqmoPF8zxe3bESBl lWIicM7wYeanH9rr4CFLPSEgKlyVmdN/OgQzQoBC/SiVT9RwAoH8xiTlvLDPbYqWUFo8 +vcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YyEEZakf; 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 c78si2106352pfe.384.2017.12.13.14.41.48; Wed, 13 Dec 2017 14:41:48 -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=YyEEZakf; 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 S1753041AbdLMWlb (ORCPT + 23 others); Wed, 13 Dec 2017 17:41:31 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:45835 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752910AbdLMWlW (ORCPT ); Wed, 13 Dec 2017 17:41:22 -0500 Received: by mail-pf0-f195.google.com with SMTP id u19so2176922pfa.12 for ; Wed, 13 Dec 2017 14:41:22 -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=Zcmq7LN6XwZSTJJcZ3bU/gby1PmpQujyigPB6KR2Kcg=; b=YyEEZakfzjIQvHKvjP0CzkOA7XpRTu4YwMLjikZWmgf5/jgEINZ6zo47ERyxDQ8Y3o 6NOu+y6+Xaz01Pmo6tuY7KiBWXnkBRSujpVO2hSeaPJZqK6A+sbJd0edxyDpYHBD/oZk VOL6CVbR4o1uvVS6XViIZf7Km/a9pZIYg+8r0= 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=Zcmq7LN6XwZSTJJcZ3bU/gby1PmpQujyigPB6KR2Kcg=; b=nCKpMc8b1bk8RDUACximBJan3DCSgcWQ4v8V8dJU6OoqzJIJbwntOeB0QcOH1Ibpl5 /3hae0A+c+9bFkDrOjzOU1Qha4NTieCWXyg/0TWqIhUwcy+V5J07cd8F8VVxTe5Iq9YU BegdwjvNIW+2EnTgAYRkP5OcZt4o8Zeayxl1uANACg+x+mdPwXoLnzee3kgmU7zTgA1x 29vTcHE/unidSYkVGDVhCaIgusQDp6StV4AYLRa9jemo1++QAo5sCbbvpVknrfvq4pQ1 dN/36jHj8vcqaocEntMyt11Vk14M0kI2MknkZNRuJFxEhqOOSd+c1lyOBC6TYLsSPrv2 blzg== X-Gm-Message-State: AKGB3mLnf/G3DP5V3GYiMXPomX+X3sQeAuybDTAE/dDDVl2BCO7VscY2 aP/jyPi1vnGAyP5/nrA2slxVQg== X-Received: by 10.98.111.137 with SMTP id k131mr7543707pfc.105.1513204881787; Wed, 13 Dec 2017 14:41:21 -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 x15sm4464205pfh.27.2017.12.13.14.41.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 14:41:21 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/8] remoteproc: Don't handle empty resource table Date: Wed, 13 Dec 2017 14:41:08 -0800 Message-Id: <20171213224111.17864-6-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171213224111.17864-1-bjorn.andersson@linaro.org> References: <20171213224111.17864-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow a NULL table_ptr to have the same meaning as a table with 0 entries, allowing a subsequent patch to skip the assignment step. A few other places in the implementation does dereference table_ptr, but they are currently all coming from rproc_handle_resources(). Signed-off-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_core.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.15.0 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index f2b6aa5d204c..63d88d1d206e 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -739,6 +739,9 @@ static int rproc_handle_resources(struct rproc *rproc, rproc_handle_resource_t handler; int ret = 0, i; + if (!rproc->table_ptr) + return 0; + for (i = 0; i < rproc->table_ptr->num; i++) { int offset = rproc->table_ptr->offset[i]; struct fw_rsc_hdr *hdr = (void *)rproc->table_ptr + offset; From patchwork Wed Dec 13 22:41:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 121868 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6063917qgn; Wed, 13 Dec 2017 14:41:58 -0800 (PST) X-Google-Smtp-Source: ACJfBotYVAk7HXJLorccUNnBKj3Md2wedsKqPAo25g7tDVFL1kW0GCmlQzs8ooSagxABJ3kA/TGu X-Received: by 10.84.128.76 with SMTP id 70mr7251736pla.171.1513204918489; Wed, 13 Dec 2017 14:41:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513204918; cv=none; d=google.com; s=arc-20160816; b=WgHBFrPYIAiJIlvJd+R2kGS2Ro2K+kbvnkLUM+FYy6NopYCV4q9yKCTqMJqoNu3oIr AIIjW8CNuuxp+otmOifHQB8vza8I+AvX6EU9mb36lizKIA8f96BA6Hk4X60r+QFBzwC8 sL2cnp/mbEMaDw6kyZ+vjE7QNz4gZVqqqwmEQ+imotF8CwcEVOXru5ySuFjLsaVwsOM7 /QXUtuuhVfXysQsb4+3fiH02Ajox8g+G56U88s7cdRpvrmtP0OAH6BUGwd0KDkYy480u PYLPPBgT2iyJISeGKuKks6nJwsGuZLmv52lBa5/LvlTVBDzr5bbs08Pqw+ANQ8bEi25G fbyg== 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=DOQgzMfTDUb90/2B4qbuBm8PYVJoXD6OEUcFe7jgas4=; b=D9tT7C4CbcTDkrK+o/33//inDgd8ZALohyff2jWVL+ZXRN3G9vb8uMZzKpvNok7dSQ odRtVzrWPHHl0XiVfSoOlI+K392VWpZebr3gnIhYgOiL0RVZD/QwC0Ad1NYBq7LHuXV0 sJ6CPM1KlX8otByLLZ9d/EFdNrDvUCV54uW1Hm4nzYtPlqlRxJ9L78BMb9GddyJX4beN juAvkcwjnkRrS8sGxL66+pvwrPknZJBEuY6986JVF0cK9zSVbkOsOHPtR7pvEvAk0Vi4 XfQtU9UMmqF2fGEENA37A0fcWQcpdswXjTvPyebVJZqRXJvLAJkg44TfMk8z7waTQ/Ou mLEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GN0mp4rm; 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 l5si1873271pgr.469.2017.12.13.14.41.58; Wed, 13 Dec 2017 14:41:58 -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=GN0mp4rm; 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 S1753003AbdLMWla (ORCPT + 23 others); Wed, 13 Dec 2017 17:41:30 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:43982 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752914AbdLMWlY (ORCPT ); Wed, 13 Dec 2017 17:41:24 -0500 Received: by mail-pf0-f194.google.com with SMTP id e3so2184338pfi.10 for ; Wed, 13 Dec 2017 14:41:23 -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=DOQgzMfTDUb90/2B4qbuBm8PYVJoXD6OEUcFe7jgas4=; b=GN0mp4rmQhSLezPdGjML0c7SxYfpWRfFC/IcukuipZqWn20WVxg5ZTtymb0hWUX5Lo McFZSUWFNtDT5DFUAsnFApPIHMpPHa/RrVsYLqxQGe7lBAP9/xe7AHj+6lG4AAfpxhdG pFQsdqxBjGv+5wX8kRyXJEq6koIPWcyLwYVr8= 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=DOQgzMfTDUb90/2B4qbuBm8PYVJoXD6OEUcFe7jgas4=; b=ONUu206sEgMwHt43GHK9jfQSozv9/R6L4Q4M8+zx7y2JuvZkrbu7Fgnj591KVvCSVm /JSjOvd8qqycuF4JTcsj2xnnBhWVackg9/ZUjZfT6s5xkMVCm+CMESbJeGm3TnXwNNRU nKkQFMV9fOLx375W4gGdNQT6MrJ2MZ7LcD2ctVAuzWRvfC/1jbVDi4N10F8bgVI5WWoq 4cYU3CNMGr0LTrZQELsoGeUM8+dt42t84CItGxEmiQ9qs73dYlYjfm0IYOesuuuF5a3Q vDkD0Tj4PBibE+YnAv8Vf7VqBjxME9wfBRisMnHyU4MZbZb98fY+lJteIEY+1kFxjJUF IObA== X-Gm-Message-State: AKGB3mLRzhKBOlmg5COnKWEMcmvm9nrzP3u/j7kQ7QDmWdOZBWwadQJB ETiAnz7qzY5DkeWxa5T8qUitQw== X-Received: by 10.159.251.151 with SMTP id m23mr7218832pls.347.1513204883036; Wed, 13 Dec 2017 14:41:23 -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 x15sm4464205pfh.27.2017.12.13.14.41.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 14:41:22 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/8] remoteproc: Move resource table load logic to find Date: Wed, 13 Dec 2017 14:41:09 -0800 Message-Id: <20171213224111.17864-7-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171213224111.17864-1-bjorn.andersson@linaro.org> References: <20171213224111.17864-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Extend the previous operation of finding the resource table in the ELF with the extra step of populating the rproc struct with a copy and the size. This allows drivers to override the mechanism used for acquiring the resource table, or omit it for firmware that is known not to have a resource table. This leaves the custom, dummy, find_rsc_table implementations found in some drivers dangling. Signed-off-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_core.c | 32 ++++++-------------------- drivers/remoteproc/remoteproc_elf_loader.c | 37 ++++++++++++++++++------------ drivers/remoteproc/remoteproc_internal.h | 16 +++++-------- include/linux/remoteproc.h | 1 + 4 files changed, 36 insertions(+), 50 deletions(-) -- 2.15.0 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 63d88d1d206e..cbd12382b219 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -907,8 +907,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) { struct device *dev = &rproc->dev; const char *name = rproc->firmware; - struct resource_table *table; - int ret, tablesz; + int ret; ret = rproc_fw_sanity_check(rproc, fw); if (ret) @@ -927,27 +926,11 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) } rproc->bootaddr = rproc_get_boot_addr(rproc, fw); - ret = -EINVAL; - - /* look for the resource table */ - table = rproc_find_rsc_table(rproc, fw, &tablesz); - if (!table) { - dev_err(dev, "Failed to find resource table\n"); - goto clean_up; - } - - /* - * Create a copy of the resource table. When a virtio device starts - * and calls vring_new_virtqueue() the address of the allocated vring - * will be stored in the cached_table. Before the device is started, - * cached_table will be copied into device memory. - */ - rproc->cached_table = kmemdup(table, tablesz, GFP_KERNEL); - if (!rproc->cached_table) - goto clean_up; - rproc->table_ptr = rproc->cached_table; - rproc->table_sz = tablesz; + /* load resource table */ + ret = rproc_load_rsc_table(rproc, fw); + if (ret) + goto disable_iommu; /* reset max_notifyid */ rproc->max_notifyid = -1; @@ -967,11 +950,10 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) clean_up_resources: rproc_resource_cleanup(rproc); -clean_up: kfree(rproc->cached_table); rproc->cached_table = NULL; rproc->table_ptr = NULL; - +disable_iommu: rproc_disable_iommu(rproc); return ret; } @@ -1443,7 +1425,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->find_rsc_table = rproc_elf_find_rsc_table; + rproc->ops->load_rsc_table = 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_elf_loader.c b/drivers/remoteproc/remoteproc_elf_loader.c index 822fa1bf893f..b17d72ec8603 100644 --- a/drivers/remoteproc/remoteproc_elf_loader.c +++ b/drivers/remoteproc/remoteproc_elf_loader.c @@ -268,42 +268,49 @@ find_table(struct device *dev, struct elf32_hdr *ehdr, size_t fw_size) } /** - * rproc_elf_find_rsc_table() - find the resource table + * rproc_elf_load_rsc_table() - load the resource table * @rproc: the rproc handle * @fw: the ELF firmware image - * @tablesz: place holder for providing back the table size * * This function finds the resource table inside the remote processor's - * firmware. It is used both upon the registration of @rproc (in order - * to look for and register the supported virito devices), and when the - * @rproc is booted. + * firmware, load it into the @cached_table and update @table_ptr. * - * Returns the pointer to the resource table if it is found, and write its - * size into @tablesz. If a valid table isn't found, NULL is returned - * (and @tablesz isn't set). + * Return: 0 on success, negative errno on failure. */ -struct resource_table *rproc_elf_find_rsc_table(struct rproc *rproc, - const struct firmware *fw, - int *tablesz) +int rproc_elf_load_rsc_table(struct rproc *rproc, const struct firmware *fw) { struct elf32_hdr *ehdr; struct elf32_shdr *shdr; struct device *dev = &rproc->dev; struct resource_table *table = NULL; const u8 *elf_data = fw->data; + size_t tablesz; ehdr = (struct elf32_hdr *)elf_data; shdr = find_table(dev, ehdr, fw->size); if (!shdr) - return NULL; + return -EINVAL; table = (struct resource_table *)(elf_data + shdr->sh_offset); - *tablesz = shdr->sh_size; + tablesz = shdr->sh_size; + + /* + * Create a copy of the resource table. When a virtio device starts + * and calls vring_new_virtqueue() the address of the allocated vring + * will be stored in the cached_table. Before the device is started, + * cached_table will be copied into device memory. + */ + rproc->cached_table = kmemdup(table, tablesz, GFP_KERNEL); + if (!rproc->cached_table) + return -ENOMEM; - return table; + rproc->table_ptr = rproc->cached_table; + rproc->table_sz = tablesz; + + return 0; } -EXPORT_SYMBOL(rproc_elf_find_rsc_table); +EXPORT_SYMBOL(rproc_elf_load_rsc_table); /** * rproc_elf_find_loaded_rsc_table() - find the loaded resource table diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index a42690c514e2..55a2950c5cb7 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -57,9 +57,7 @@ int rproc_trigger_recovery(struct rproc *rproc); int rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw); u32 rproc_elf_get_boot_addr(struct rproc *rproc, const struct firmware *fw); int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw); -struct resource_table *rproc_elf_find_rsc_table(struct rproc *rproc, - const struct firmware *fw, - int *tablesz); +int rproc_elf_load_rsc_table(struct rproc *rproc, const struct firmware *fw); struct resource_table *rproc_elf_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *fw); @@ -90,15 +88,13 @@ int rproc_load_segments(struct rproc *rproc, const struct firmware *fw) return -EINVAL; } -static inline -struct resource_table *rproc_find_rsc_table(struct rproc *rproc, - const struct firmware *fw, - int *tablesz) +static inline int rproc_load_rsc_table(struct rproc *rproc, + const struct firmware *fw) { - if (rproc->ops->find_rsc_table) - return rproc->ops->find_rsc_table(rproc, fw, tablesz); + if (rproc->ops->load_rsc_table) + return rproc->ops->load_rsc_table(rproc, fw); - return NULL; + return 0; } static inline diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index e21de55e19d1..ec1ada7cc6d7 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -344,6 +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); struct resource_table *(*find_rsc_table)(struct rproc *rproc, const struct firmware *fw, int *tablesz); From patchwork Wed Dec 13 22:41:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 121869 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6064181qgn; Wed, 13 Dec 2017 14:42:14 -0800 (PST) X-Google-Smtp-Source: ACJfBovUwNpHUX89LJ4h5AoqCbVSuMOaFVnnGHIN+/B1bE5iQ4jEfLhe9GzL4HCiNwbE9XKmpr8a X-Received: by 10.101.97.129 with SMTP id c1mr6801235pgv.223.1513204934847; Wed, 13 Dec 2017 14:42:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513204934; cv=none; d=google.com; s=arc-20160816; b=kwRnEK6zyHNM0HP8ut37bKeo7lPfciNTCyN8niLxSaiqBJkdpjGFjxYvEUVO85kgJ0 cN9+1G+6LDNFEJvBsyH1iTNejuhYYVJEviCUpaFA/6j3ecPo4/Y5gy0MwGQAhCBI7xhi t27JrFmvNJ0QtzDMLXqXpUEeBhk8+8cFsPTgRijh0t+Uac/jK/susTTqq38SaW9hMdyI SWwnkut+Wu1q+qfZajeZQMMoeJS7QpVcxD9ssNU2py2FcDZixn9EIztYPMW+IwVDCt1F bQ7nvKuSxBR2KAObBNfVfYNXH1G8GYD/TYA2CdKmSRH2ZxF3yDF1gAoyud/9SUp5MjHs mdQg== 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=GixXrPtN7C4F1IbFKY5NE0N5KCRHgkl7tgsQwa53cu8=; b=DldbkYHHpUXBuYwpnvYQ/cp8mHDJjq1RB+pHqEYaPPTvL19s5MLeDUhHOgCUshFNuk S0I7DUuypDQiM4SOI58UntOcHqazzEKaFvcRaXJAr4KOlPbMLrEORWT4tdnaZ1AoInwz xjIFJdj68mWy16N6KHUJJnf1npMLwteNJntVQMHYof1dZqAxAbK2Qvy5OXhTtUhll/LJ tEkDm4Bf/100aSMkAz+kynHOgWXtF/uucTTZUGgwQ8RCa7jfWfD/agGJzmD9Mt/I5hHF oTBGrIZI3kfaSuccz/dX+XT7jfTb5jioQDX3uxI4zuw0saawcoYYjpP17z8wNyfRwXn1 YOyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dafV7x3O; 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 l5si1873271pgr.469.2017.12.13.14.42.14; Wed, 13 Dec 2017 14:42:14 -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=dafV7x3O; 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 S1753180AbdLMWmJ (ORCPT + 23 others); Wed, 13 Dec 2017 17:42:09 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:46300 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752931AbdLMWlY (ORCPT ); Wed, 13 Dec 2017 17:41:24 -0500 Received: by mail-pg0-f68.google.com with SMTP id b11so2044488pgu.13 for ; Wed, 13 Dec 2017 14:41:24 -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=GixXrPtN7C4F1IbFKY5NE0N5KCRHgkl7tgsQwa53cu8=; b=dafV7x3OIbz9qFeABCEqo6y+XgkwBLJix0wQ4uwY+xfv29AjMwooIuvRs17tbGx16D x4zzeBMBLGF/W0xm11syLDOSQ3/b6ANdylN0eo+JtChvD3hRi9vmKqes9rIpHD1/FuyJ BVZiLSpvMKFEkXBtsHQ2c4uxDeltamnRCt/2E= 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=GixXrPtN7C4F1IbFKY5NE0N5KCRHgkl7tgsQwa53cu8=; b=mMtdkAFf6sJAxO7/d/pxGII7sXGLziCOGkvtMoG+JsyElUb4yi/ZJSyx14VNL4Nknz SW/NTWXbVqxOlYUeYppbmR+5IPtPaQJDwkuWXo0ge49+YlIHL4rA7h1iivLFA/qqb37R 3BvqyTrm6rqA2ONWq+2NkLBBZgp3xtwZTiGpwKiXU710NVWYyhuy9KxZU97gklFohwj9 Abf95HYYYY9P+nkxpr4PsFEsCEvFiCCXor7Xy5aNuyu0TpFZJb1EiYkkv2tG6MdX3oj9 11pqu+sU+a+eKV2c1jf1uI0lNIdmyg/rUfRQvc5J4f/3sOWI5CjcsKc3sBMYroMp9ZbD 4qpQ== X-Gm-Message-State: AKGB3mKDpTAjaXTgSsEiyzZyOtwrmFHxnkI6ILhm898brlU4d/TNHczb GOMHiovPfK5dRIHUlObzLdNNb/DQz44= X-Received: by 10.159.197.67 with SMTP id d3mr7347817plo.409.1513204883835; Wed, 13 Dec 2017 14:41:23 -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 x15sm4464205pfh.27.2017.12.13.14.41.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 14:41:23 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/8] remoteproc: Drop dangling find_rsc_table dummies Date: Wed, 13 Dec 2017 14:41:10 -0800 Message-Id: <20171213224111.17864-8-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171213224111.17864-1-bjorn.andersson@linaro.org> References: <20171213224111.17864-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As the core now deals with the lack of a resource table, remove the dangling custom dummy implementations of find_rsc_table from drivers. Signed-off-by: Bjorn Andersson --- drivers/remoteproc/qcom_adsp_pil.c | 1 - drivers/remoteproc/qcom_common.c | 19 ------------------- drivers/remoteproc/qcom_common.h | 4 ---- drivers/remoteproc/qcom_q6v5_pil.c | 11 ----------- drivers/remoteproc/qcom_wcnss.c | 1 - drivers/remoteproc/st_slim_rproc.c | 18 ------------------ include/linux/remoteproc.h | 4 ---- 7 files changed, 58 deletions(-) -- 2.15.0 diff --git a/drivers/remoteproc/qcom_adsp_pil.c b/drivers/remoteproc/qcom_adsp_pil.c index 7b9d810b23f1..b0b0d5ca1ca0 100644 --- a/drivers/remoteproc/qcom_adsp_pil.c +++ b/drivers/remoteproc/qcom_adsp_pil.c @@ -181,7 +181,6 @@ static const struct rproc_ops adsp_ops = { .start = adsp_start, .stop = adsp_stop, .da_to_va = adsp_da_to_va, - .find_rsc_table = qcom_mdt_find_rsc_table, .load = adsp_load, }; diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c index 818ee3657043..ce2dcc4f7de7 100644 --- a/drivers/remoteproc/qcom_common.c +++ b/drivers/remoteproc/qcom_common.c @@ -32,25 +32,6 @@ static BLOCKING_NOTIFIER_HEAD(ssr_notifiers); -/** - * qcom_mdt_find_rsc_table() - provide dummy resource table for remoteproc - * @rproc: remoteproc handle - * @fw: firmware header - * @tablesz: outgoing size of the table - * - * Returns a dummy table. - */ -struct resource_table *qcom_mdt_find_rsc_table(struct rproc *rproc, - const struct firmware *fw, - int *tablesz) -{ - static struct resource_table table = { .ver = 1, }; - - *tablesz = sizeof(table); - return &table; -} -EXPORT_SYMBOL_GPL(qcom_mdt_find_rsc_table); - static int glink_subdev_probe(struct rproc_subdev *subdev) { struct qcom_rproc_glink *glink = to_glink_subdev(subdev); diff --git a/drivers/remoteproc/qcom_common.h b/drivers/remoteproc/qcom_common.h index 541586e528b3..73efed969bfd 100644 --- a/drivers/remoteproc/qcom_common.h +++ b/drivers/remoteproc/qcom_common.h @@ -30,10 +30,6 @@ struct qcom_rproc_ssr { const char *name; }; -struct resource_table *qcom_mdt_find_rsc_table(struct rproc *rproc, - const struct firmware *fw, - int *tablesz); - 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); diff --git a/drivers/remoteproc/qcom_q6v5_pil.c b/drivers/remoteproc/qcom_q6v5_pil.c index fbff5d842581..6f6ea0414366 100644 --- a/drivers/remoteproc/qcom_q6v5_pil.c +++ b/drivers/remoteproc/qcom_q6v5_pil.c @@ -304,16 +304,6 @@ static void q6v5_clk_disable(struct device *dev, clk_disable_unprepare(clks[i]); } -static struct resource_table *q6v5_find_rsc_table(struct rproc *rproc, - const struct firmware *fw, - int *tablesz) -{ - static struct resource_table table = { .ver = 1, }; - - *tablesz = sizeof(table); - return &table; -} - static int q6v5_xfer_mem_ownership(struct q6v5 *qproc, int *current_perm, bool remote_owner, phys_addr_t addr, size_t size) @@ -927,7 +917,6 @@ static const struct rproc_ops q6v5_ops = { .start = q6v5_start, .stop = q6v5_stop, .da_to_va = q6v5_da_to_va, - .find_rsc_table = q6v5_find_rsc_table, .load = q6v5_load, }; diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c index cc44ec598522..1fa5253020dd 100644 --- a/drivers/remoteproc/qcom_wcnss.c +++ b/drivers/remoteproc/qcom_wcnss.c @@ -310,7 +310,6 @@ static const struct rproc_ops wcnss_ops = { .start = wcnss_start, .stop = wcnss_stop, .da_to_va = wcnss_da_to_va, - .find_rsc_table = qcom_mdt_find_rsc_table, .load = wcnss_load, }; diff --git a/drivers/remoteproc/st_slim_rproc.c b/drivers/remoteproc/st_slim_rproc.c index 1538ea915c49..c6a2a8b68c7a 100644 --- a/drivers/remoteproc/st_slim_rproc.c +++ b/drivers/remoteproc/st_slim_rproc.c @@ -200,28 +200,10 @@ static void *slim_rproc_da_to_va(struct rproc *rproc, u64 da, int len) return va; } -/* - * Firmware handler operations: sanity, boot address, load ... - */ - -static struct resource_table empty_rsc_tbl = { - .ver = 1, - .num = 0, -}; - -static struct resource_table *slim_rproc_find_rsc_table(struct rproc *rproc, - const struct firmware *fw, - int *tablesz) -{ - *tablesz = sizeof(empty_rsc_tbl); - return &empty_rsc_tbl; -} - static const struct rproc_ops slim_rproc_ops = { .start = slim_rproc_start, .stop = slim_rproc_stop, .da_to_va = slim_rproc_da_to_va, - .find_rsc_table = slim_rproc_find_rsc_table, }; /** diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index ec1ada7cc6d7..51ddde7535b9 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -332,7 +332,6 @@ struct firmware; * @stop: power off the device * @kick: kick a virtqueue (virtqueue id given as a parameter) * @da_to_va: optional platform hook to perform address translations - * @find_rsc_table: find the resource table inside the firmware image * @find_loaded_rsc_table: find the loaded resouce table * @load: load firmeware to memory, where the remote processor * expects to find it @@ -345,9 +344,6 @@ struct rproc_ops { 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); - struct resource_table *(*find_rsc_table)(struct rproc *rproc, - const struct firmware *fw, - int *tablesz); 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 Wed Dec 13 22:41:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 121870 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6064374qgn; Wed, 13 Dec 2017 14:42:25 -0800 (PST) X-Google-Smtp-Source: ACJfBotAvYVcUVH4em86eigr88q7EsMYb9VuHG5cg4nbLU4EhcoDoQ+SXGnjHM473MOn5cUzm7tp X-Received: by 10.159.230.16 with SMTP id u16mr7385520plq.41.1513204945309; Wed, 13 Dec 2017 14:42:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513204945; cv=none; d=google.com; s=arc-20160816; b=dYxSBGypweMJ/odacrbAZjCRcbPg/Lk9TzcH4NIqXTQLjZgQZ/uBP10Lg7Gq6uudxN PCp6OKwQxy6l7xescgGZshRdKWg916+/Wo7iZ2x8AnNjNCd6Sc+Ynwj/4/09sKqLb2uh bUmigNy+N/7w1ZuCS2xOdhrTL+uNnsrI6sy4b9kmcoGyQFsiAbZOoxh94IZj1AyTec/d nAJ2b51CRQwhMPufWu/jKCXfI+fzjIURLSiJiHXhCPhCFc3LiZVjEZ5EtQ/0Fs2SYwQJ sRhc/mJlQy7P9LB0GzzaT65F+1FVAIToMJJ0290rjzKV66UAdtEGnZHrA4ZfVU425aIc GxCQ== 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=lyeeivph6fo9yKXJxQ+ouvVRR51z7KpFpnIT45BPY4M=; b=ky1nQ4bruQjzizdPoZYvzXpbq9/8QuDTj0qwHYepLQMAb35HMMd8/fbooZMx/IrCzy tit71ddMQDj6W7hnks9768EvPGKqVdd7VZKullJCI4RrBZ4LETJGNw3umSbyQW6qBhyo 4zDTrposPPYgEsFAtOYfIWN3p0eesJthLwjGC5FIUwDGx5we+2ptoDwdMvTTtxcwkgS8 TDGaQibswxirMgr1+r5qfsZBoOhFFTFJj8RYVqbV9ERXpAHjr+zNSTlSNXVe+1pH3gPS 1w/L4DKlp4T/g+a5BeC3Fq8JX2N64prm6c45HGKgHnyRTNCZ/cgMjl6X1/jeTGcw8+JT LyVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VmqLxrVP; 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 l5si1873271pgr.469.2017.12.13.14.42.25; Wed, 13 Dec 2017 14:42:25 -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=VmqLxrVP; 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 S1753131AbdLMWmI (ORCPT + 23 others); Wed, 13 Dec 2017 17:42:08 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:43821 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752936AbdLMWlZ (ORCPT ); Wed, 13 Dec 2017 17:41:25 -0500 Received: by mail-pg0-f65.google.com with SMTP id b18so2050101pgv.10 for ; Wed, 13 Dec 2017 14:41: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=lyeeivph6fo9yKXJxQ+ouvVRR51z7KpFpnIT45BPY4M=; b=VmqLxrVPRO+SstG6Sd+ICy8p/+XMUEoAIrsNjf67hObtasfTswhrFvvONKSjhRR1YC sbdmcqf1982/sBi3qHffuwoki7oWYhzbZJRLakxi9ZXVlgCyFCtLXKBx87arRh5IcuQB 7AopeFmzZx67QxyidvT2UYd1pzoguAI4VJNtc= 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=lyeeivph6fo9yKXJxQ+ouvVRR51z7KpFpnIT45BPY4M=; b=MMJVbz8Yz1FdS+ctNTDXFjocUmDcbuvKZStnSOJ3DNdnV1lR8po698oF7VauGN7CvL xa15rxms/UjaYuRXzdsAXnomtFHzKejf9IYltARvyp46knF3SpT5QP1h/jM7fGWoWdmn 3f0ND7mHfY4pRlGLPlY49slr7JrwWqBmLf/ROPhkoZJnsti1h3uC4X/RUOo6vKd0e7BW g4Acn0FWin4sCqTLri3bCBdHiROZj1v7IxtR43zQJkJCgVelucqgJs4Ujdn5jWBoYkgu Wr5jbIPkdy0eSU/jkSkbVLpEe5rsyLz53gNLMZ+vD0/qFAP1wqlyuNOh8stv7RUjn3hm MpXg== X-Gm-Message-State: AKGB3mIyc237Rc1pt5/eJXUopRyZb9LvUp0q9hvFk0QBeYuEA06gSTmG 7mJUGwqQ6wNOPJBUCTSoHlVFBA== X-Received: by 10.159.218.12 with SMTP id v12mr7505850plp.224.1513204885091; Wed, 13 Dec 2017 14:41: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 x15sm4464205pfh.27.2017.12.13.14.41.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 14:41:24 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 8/8] remoteproc: Reset table_ptr on stop Date: Wed, 13 Dec 2017 14:41:11 -0800 Message-Id: <20171213224111.17864-9-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171213224111.17864-1-bjorn.andersson@linaro.org> References: <20171213224111.17864-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 installed resource table is no longer accessible after stopping the remote, so update table_ptr to point to the local copy. Signed-off-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_core.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.15.0 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index cbd12382b219..98c088d80b3d 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1000,6 +1000,9 @@ static int rproc_stop(struct rproc *rproc, bool graceful) /* remove any subdevices for the remote processor */ rproc_remove_subdevices(rproc, graceful); + /* the installed resource table is no longer accessible */ + rproc->table_ptr = rproc->cached_table; + /* power off the remote processor */ ret = rproc->ops->stop(rproc); if (ret) {