From patchwork Fri Jan 5 23:57:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 123580 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1429324qgn; Fri, 5 Jan 2018 16:00:05 -0800 (PST) X-Google-Smtp-Source: ACJfBosKdWefLn95UQYznrHSPn1z7lk+ap8P3VwhoraskwtwxtUCqiUvoZEgiwESvt2m+PGONSJn X-Received: by 10.84.129.36 with SMTP id 33mr4621437plb.69.1515196805216; Fri, 05 Jan 2018 16:00:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515196805; cv=none; d=google.com; s=arc-20160816; b=LT/XmEj8CNIaSvrOnD52bAe3oaC3LRrjW4XxavXKOP32J69m6tbQFBkHWuOJuRIycM 2+PBmuyQKoMjHv9N3QoCj6V3IIb8Yuyd0XAqbxdY80qjhsquzwGpfvuWP30SlFJ2qh1R 6mBqRLJfCM0nU+rm1nE24zftFVaex0GtSsw3uk3fcnguMrX2XrQbtDKviqdWl6X7xkjz SsSb0VtC/7H3JX8l32rOOUybY1kWUC2HeogniFrvke+EdTii65vZSkKhYyjjTnwPvLEu 17bnCoZUlHmSyfgp4MiTTqUBoEwX3OaDkRfXa5QnIFJxDPtBlubkD8Hx3R0JWfCnhFNt mr+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=MyAujyRV4KT3zFlegLXQFsBHCi2qd1voVZmo+WdUOn0=; b=rvX0nhwqb8DTDpGXHGV09ThQwDsz9atiqVVglyg4/HFx08TwvgaC82XK2zU+ADCUKL XfA8fIQdAr1hQWAAxWkeu7il83zFSybxb/9CikxHPu/Zq+ugrKSUASS2jgFhxOpNzQYF dV1B7lyAysEQhBZSNnxZ0gLX4n3I7jrnDIf54JHgjAn0Xt8TRAYR4g2+mS2OwHezxj8W KmkGbeeTu149kR/ekp9gSVdXTXW33+K/2n7MbSVAzuHtHcmtRvYVDt+355zN1dmGS8hD IOmF0mASS7kmfGhp1YhZ3bcZ9yZFOfyUGHD2JyN2MoWAPh78lJi33Oye05+h2qV2e3ip mBtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TBhHphKK; 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 v10si4636838ply.324.2018.01.05.16.00.04; Fri, 05 Jan 2018 16:00:05 -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=TBhHphKK; 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 S1753510AbeAFAAD (ORCPT + 28 others); Fri, 5 Jan 2018 19:00:03 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:37995 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752735AbeAEX6L (ORCPT ); Fri, 5 Jan 2018 18:58:11 -0500 Received: by mail-pg0-f67.google.com with SMTP id t67so2567807pgc.5 for ; Fri, 05 Jan 2018 15:58:11 -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=MyAujyRV4KT3zFlegLXQFsBHCi2qd1voVZmo+WdUOn0=; b=TBhHphKK11uSoOsgd5igbYTtsUCv8uoI3rAVKhf/7KbA/Qu1Zz6f6a29ZkaTJsAolg XlwOYxV73xI4W1mpRXnZeVREGpwBCLf4tlK5R5+tdd4dRgiIuh5+onkAly6YcSWsknaM +ccgnMF3YYZU6zsWXdjenwk7qDLx0SQYWeN58= 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=MyAujyRV4KT3zFlegLXQFsBHCi2qd1voVZmo+WdUOn0=; b=RMrIymnEXnuU2K8crPXx7F17uKbLDPHvQjKHEgRRlDpgCPOpL99psSDj3xKB1EVFM4 txeH5UxS2h085uSXGfsuJJ6wdoFIQW8/wAr7xAlEftiCkvX8Bxte0Qk58i6gBdvdR+P/ kkYIISTyfbSy2YCekKyDjhger0igAEmQxN3Rpe3iXArefjHTlAZDeMq9JhOuB6QqSA/G Zslfcca3FYAvUFgZGrDnh8fxX5ML3qM48/ogxbFPh17+DhLVTdcKdhCiuwBTFP3AcU1J UqyxJtlWg9JYsHHrXyGblJmdlu50/NNhQ6IEt/FCKzp3XeugKzaAdCH/GW9MbZXtQfR+ KbVQ== X-Gm-Message-State: AKGB3mKpgq4s966OVwuwYnlgBQzHHSZHHNcvrai8P3U3giohKnU1xErN 51DQsFbplLpQhp0nTqEyPMno8w== X-Received: by 10.99.42.83 with SMTP id q80mr3765875pgq.183.1515196691003; Fri, 05 Jan 2018 15:58:11 -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 x4sm14473188pfk.51.2018.01.05.15.58.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 15:58:10 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Loic Pallardy Subject: [PATCH v2 1/8] remoteproc: Remove depricated crash completion Date: Fri, 5 Jan 2018 15:57:58 -0800 Message-Id: <20180105235805.9948-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180105235805.9948-1-bjorn.andersson@linaro.org> References: <20180105235805.9948-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 --- Changes since v1: - None 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 eab14b414bf0..758fad3131a3 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1028,10 +1028,6 @@ static int rproc_stop(struct rproc *rproc) 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 44e630eb3d94..6f1d8e025c81 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 Fri Jan 5 23:57:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 123573 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1428097qgn; Fri, 5 Jan 2018 15:58:18 -0800 (PST) X-Google-Smtp-Source: ACJfBotSyjET8PPROkPfVTETWrD3akb2mxfUpTQYKKN6q1/0TZ1lrXzVEbczL4Fx0sU+ZU5TnLvM X-Received: by 10.124.25.17 with SMTP id c17mr102496plz.90.1515196697919; Fri, 05 Jan 2018 15:58:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515196697; cv=none; d=google.com; s=arc-20160816; b=vSW3mY42xV/mPT4DwoZU69jWsZH3/lQEft93kZ8JZoq2Ep6K1t+4jF5FZGm9pK6MA5 6GredLLsVm2M0uqBklfmv23riQMZ9NKwcBi905UFLoy11lO+fxcBy1+ixAtNOs7nGMHO m8ukgQcb8lWITfsQVOXPBlKE3lhK38lSbQr2LD+gtCM45H5Mb5YpWPadsrQFWBaTL2Me dE+jeW1bzIOq88x/2reVHt/cxB5MzlnWh7X7Lh8JPgghj3F0k+ZhmWmgwvdvoJTJu9Az h+RqWpdFVhVZfF52+ZgPsExoCwuRbrM9W01E/bnfdCcOhLCxW33FWifQafDX8isWPhR0 YOTg== 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=uVfw65ecBEIs0WbFb7RKr44rjgHi008nQKdIuSy6IQg=; b=VcbOXIOUxXe/A8pcRVOOSDXVXMi8KA0eReU/kT8UtUj2WAz3AylUQvF+RjK5bDdyvn hnxTARBPycM0dvP+yKZA2hSVzPrm7ysqmI2QD63/lXpLGopzrUltLItNJYY02oRkyahc isTVcOfR3KZnKSj7M0JugAPnXKX1tkTAglnvn6+SbGbjh5rnxfalYn7yabxh5E7245mo ddWd2hYqa0u3TU5a7D8iZOPoKzNawLgb6vmvq6KwbxB8DDUmyuXo1UgLbFIIef2ukqxC xtn3WBYQmVNAGgVubKIdA6STVvuC5U/ZJbb5VrV4TLEMSVoaxkWVMU+YX2j0uqV+NfNf Sp2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gctGiDpl; 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 1si4695311plj.8.2018.01.05.15.58.17; Fri, 05 Jan 2018 15:58:17 -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=gctGiDpl; 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 S1752848AbeAEX6Q (ORCPT + 28 others); Fri, 5 Jan 2018 18:58:16 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:38011 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753346AbeAEX6M (ORCPT ); Fri, 5 Jan 2018 18:58:12 -0500 Received: by mail-pf0-f195.google.com with SMTP id u25so2815115pfg.5 for ; Fri, 05 Jan 2018 15:58:12 -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=uVfw65ecBEIs0WbFb7RKr44rjgHi008nQKdIuSy6IQg=; b=gctGiDplmSETKV5y4JXDNWlke5qUh7BtB8PTO3wGgtVXwe8IM1y3KK0Is/xO7nYkSB MnM+jDGHT2xqzIuRaOS2RLomzYos6F2wjNgHVYyZc9iq5EIONIjSI0p4TkAblwn/akJ8 mGVfLB/ktT9vjOOE48HHvlr++jghZVsH0aio0= 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=uVfw65ecBEIs0WbFb7RKr44rjgHi008nQKdIuSy6IQg=; b=Z93nzo+bcPD8b+JQq+315unSDQg6vsq7VJ9SCEJVdnkkdJNJ9iayj7zAkYzp6NTgjZ NaiyLqw3KvJridNgcWjGo3ifJ8VJ4xMajd8RI86IIfXE1eSZKyOHJHFLT/UXGYCKnWgh 0euw8uvVipk2Z0HqmG2m2seUNRTfNh9I4VJnTtAZuS3oFRxysy4iGVZXhcd8GiznnPHk OF8d5DDOas1cMz/PTpzgZqD1VrmZtGw2SJjcdkN5q4aeCr+QT5yfoKIJ4Bwh+jVb28gW fZgBWi7r9oyypvJnRMhT7u+E3ZY2YRYk786Fsm9X5kU+Jd+HCWPMUbFnkEctu5+8pOl9 2xeg== X-Gm-Message-State: AKGB3mLp4LY6XRlvsdIfbAAWV7m1vBhHPIoddel9zSp3Dn3sMHEsXgX/ DmpvyboWOZn6Oa0HKXu+xx7lnQ== X-Received: by 10.101.64.67 with SMTP id h3mr3912584pgp.123.1515196692118; Fri, 05 Jan 2018 15:58:12 -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 x4sm14473188pfk.51.2018.01.05.15.58.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 15:58:11 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Loic Pallardy Subject: [PATCH v2 2/8] remoteproc: Cache resource table size Date: Fri, 5 Jan 2018 15:57:59 -0800 Message-Id: <20180105235805.9948-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180105235805.9948-1-bjorn.andersson@linaro.org> References: <20180105235805.9948-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 --- Changes since v1: - None 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 758fad3131a3..208ccf709cad 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 6f1d8e025c81..6fdc62e29d6f 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 Fri Jan 5 23:58:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 123579 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1428977qgn; Fri, 5 Jan 2018 15:59:38 -0800 (PST) X-Google-Smtp-Source: ACJfBouTZzpaPIaPGJui3O4+TgXRVS6IQEBKEyZFJNJ7PLOfK+AHHd/hpWtP1Kp/PuBgzcBzTpvk X-Received: by 10.159.231.20 with SMTP id w20mr4666540plq.7.1515196777998; Fri, 05 Jan 2018 15:59:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515196777; cv=none; d=google.com; s=arc-20160816; b=ZghJ64cjBbCQcZs5lbt0O7/4gdS8serbVwvNTobdolb0yvQ2p7c4sS6RwxlGNehv23 Jdr9w7wbyZ83BdSGV+QPZL5qD7ITj8bDBM/loKlXWOMs3/RKx9U5vBN0e868xWXY/IlD fkcU1E2xSd+MDtzlNv+eNzt1ci6fXWJXfM79HV+8epKEK6hPv5uaJhU04AWlsxY3qnCG eQ70WghNq8664TNm+fqeUK8nkyv/+pyT9kTnX2ympAFhGb88Y6mP90aw5X2m4AR+6SXF qTJYeq5N0uaI4FxBH4J6mgn9+CKkOyjXltnkjSgSOu+S3rfUPL6adB5fn1vjB0IcX6dl ml6Q== 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=iqTyD6hBhmrQc6ar/FJCMW8Pf/57ABnqf+HauxLQSiA=; b=YgEEFdFpbM+Gj/rJHSwialRRy09cj3qjfKJwWLES30/XprBmfrDD+RRj+W/TORBvBu hRwLSab9ChknqHXIh8AVcbRvOJxlh61d59SFGcJ1vF3yB3S7UitkjExpeHycmHhr7swM 098es1eRINIaiVSMAieBLuNCoOSWCUrZzcMJb+QJxBEjTWykf9RDD3vIn1Sqw0/mgEmd iu4CHmeyacFHZczTZlyZwTmQBuY2kmt6CEblBpLIHgExWkDRLIBUs14X/VqcWEln3nxH 7Axzw94/yncvwTe6oN/3mzqU5at3wAozZjSb9f2DYtDwQuT1hCjKAFQOOQJ3edMa/B7b 7B5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bDId6vbr; 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 q13si4147846pgc.706.2018.01.05.15.59.37; Fri, 05 Jan 2018 15:59: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=bDId6vbr; 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 S1753490AbeAEX7g (ORCPT + 28 others); Fri, 5 Jan 2018 18:59:36 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:44113 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753355AbeAEX6O (ORCPT ); Fri, 5 Jan 2018 18:58:14 -0500 Received: by mail-pf0-f196.google.com with SMTP id m26so2804926pfj.11 for ; Fri, 05 Jan 2018 15:58:13 -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=iqTyD6hBhmrQc6ar/FJCMW8Pf/57ABnqf+HauxLQSiA=; b=bDId6vbrfxkuWix8+tKzEv2+aWtjKFor3oVhqrax0oHpNxI6NA0qpVs32q975OCRFM mDtruzsW9oNquOP4S0Rkzf7qKqDtjFi3joyWupp2WjJwJMv3oBiSKZX9JoFy9ZI5x1uK YCs18/Myr3R8o0y5CK+WaBhTWxPlq4xpcz5Vo= 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=iqTyD6hBhmrQc6ar/FJCMW8Pf/57ABnqf+HauxLQSiA=; b=H5Z5Hr3TpNC2lEO8J9N4iwEgaX8g9YKNuw6NPgh2EDxnXezmDkQjdO1jhBgTHT707l E31Zr4oNXO1k2NJsMcxPkB35Lvao8A3pYEXVdeiInVWflkm+415buJfSsOWCPSrcI4tO tea8mllfRPl82QQ4gSAZeqzF5iAS9acMBHIjw15SJz1z2kBUSAIHfvhElaXuqNQbygDm ROKM61V8kMeR4BisICj2fgzdzVfldiR/RVaRRN1sQhTUOJeBsJN5o0wHH+mYw3C6arPI Llhp7HAJ8knNKR1AT3fKGWT0uxTySSqkrO/XgBrx2Vh157Giw/Xv+Vs27dsXcRJSio42 c5tw== X-Gm-Message-State: AKGB3mK2B13A8M6eO4Ac6d8wW97TCo0rn+9CBXWJryohJAuAEeV9Id1c 0JiqapnKiLEKy2FQ2P7Y2ixHNQeNFJs= X-Received: by 10.99.126.89 with SMTP id o25mr2726385pgn.161.1515196693366; Fri, 05 Jan 2018 15:58:13 -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 x4sm14473188pfk.51.2018.01.05.15.58.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 15:58:12 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Loic Pallardy Subject: [PATCH v2 3/8] remoteproc: Clone rproc_ops in rproc_alloc() Date: Fri, 5 Jan 2018 15:58:00 -0800 Message-Id: <20180105235805.9948-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180105235805.9948-1-bjorn.andersson@linaro.org> References: <20180105235805.9948-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 --- Changes since v1: - None 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 208ccf709cad..dbf685dbafcf 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 6fdc62e29d6f..cc4d30a790b3 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 Fri Jan 5 23:58:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 123576 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1428380qgn; Fri, 5 Jan 2018 15:58:39 -0800 (PST) X-Google-Smtp-Source: ACJfBoteC8gTS7D0PXIOxEn6ilnqJmnLmksWOSj1E9d5NaLZWTtYkpV03sleXq+YCChSSboOYM/d X-Received: by 10.98.233.1 with SMTP id j1mr4455460pfh.123.1515196719591; Fri, 05 Jan 2018 15:58:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515196719; cv=none; d=google.com; s=arc-20160816; b=KKoP1qK/4aCG3S7Bek/t7NsUht0GvLni6lSutTM9Dv63y4WV7TuPL0rQekqcfcEWGO 17gZFmiKJWmFT5OtmdvfAl7BCwRk7XGFin3ljZRkg77tmsWRlPEgFZtLluRcSUsqBFEK jsD9Ete2CJcQ7bSrYFjIlAkEFP8nYgVyJEhrOUs5XNwkYZuVia0ufZfyH8vxnwIJ771f 3xj0QXfPXkIMNwHp0RlU4Omdl7bBhpx3Go7W3PsZzF2OCiG66K62QP1vkyr2yf2Oicva 5pVIfYB/KXNjphn9W2s+yfxOYXNy/7FhifM6m1txQ0AHrDW+/G0kZtS/cNAXdPy5CvP0 MWng== 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=AmMMbNZow63+GUbl8sMMzYJW04b3LHjxdCfoBHY6EO0=; b=Z0vmLdTjU5uI4ue/0c7/+lq9FOxNcRT3cv3nr8fOOqnEi5oT7bHOYhZ0k5sg2IU1aU pwEsj/h7I0a+ZcjLxc8RJLb9cPRtmrb8VlMMMKaxnRNYjF+83HtBaQONwC+D2+U9QDFR UBzueB3Njk5ASVCHMrrqZszOD6Q0nO7A7dhGIzHz6SyAZiwCGcPKvgcdgUNXkirzxBRA XbAI28HNeokrxMDnIiFdJMsUI8w2HoZW7u5rm+foNGX132R/+PWN5engxZ4RXKbqHpwc YEabXJYt8ws8rprxdYOvb50n41IkdGaG47uqMVA1I5iry5NNP5ekc/lroKvKf3Dna0a2 z4xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q1MzhLDj; 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 l12si4143833pgs.787.2018.01.05.15.58.39; Fri, 05 Jan 2018 15:58:39 -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=Q1MzhLDj; 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 S1753432AbeAEX6X (ORCPT + 28 others); Fri, 5 Jan 2018 18:58:23 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:37713 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753361AbeAEX6P (ORCPT ); Fri, 5 Jan 2018 18:58:15 -0500 Received: by mail-pf0-f195.google.com with SMTP id n6so2815868pfa.4 for ; Fri, 05 Jan 2018 15:58:15 -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=AmMMbNZow63+GUbl8sMMzYJW04b3LHjxdCfoBHY6EO0=; b=Q1MzhLDjuMLpzzQ8SKziQe1pICgDFAA/MnPVKVAa6GinJZgJI7nMaWmETLB67EB3Z7 LqlG/ouekVxn1Smui0bFEpXw9WmApHNpzmDM2BuP0/EWq5pA+rKacOlRCbfiVC2bJ0Ff S0FLC3WZtZwWpRBvjg+0Xl2iITXBqC/QbJJF0= 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=AmMMbNZow63+GUbl8sMMzYJW04b3LHjxdCfoBHY6EO0=; b=mer43NI9J37uXhGDQ/0rqlxv2PyOJksJRF4aMx0Bohnc5EKdPnSdhw07b3mrpDd+TU LtKC69K9bQmMIWvmXE0vXnSCOoauWa4O+2QeK42amkWxASvCOcRF0wPLNPd87Hlh7q4w uKGTErfbsl4DU9iao6eZLg0Ps1ZbPjkqRoEFX5ahE6/Grn+vpDbN0oZanJTgiDBxINia hAbYd91KQD9f1FD7QgT9CbvyvVZfjp5mjhw+2mWOhD7oHlrhQf1yQ9E0SflYhPbomD0S MiY7jB7nQWEbNG4bp3G31qWEQhqeIiI6J/dOsBte5Tyt6X55P+t+1xXKXU739JNVJoUk kLoA== X-Gm-Message-State: AKGB3mIwd5r7qOl7VIQ05j+TSLUX72ANeVKXwihFABefBFBukv0DMOK6 CGcjFq0bcsiltziuVid4dMoSfw== X-Received: by 10.99.0.214 with SMTP id 205mr3992185pga.236.1515196694542; Fri, 05 Jan 2018 15:58:14 -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 x4sm14473188pfk.51.2018.01.05.15.58.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 15:58:13 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Loic Pallardy Subject: [PATCH v2 4/8] remoteproc: Merge rproc_ops and rproc_fw_ops Date: Fri, 5 Jan 2018 15:58:01 -0800 Message-Id: <20180105235805.9948-5-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180105235805.9948-1-bjorn.andersson@linaro.org> References: <20180105235805.9948-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 --- Changes since v1: - Fill load, sanity_check and get_boot_addr for st_slim 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 | 22 ++++--------- include/linux/remoteproc.h | 17 ++++++++-- 8 files changed, 67 insertions(+), 90 deletions(-) -- 2.15.0 diff --git a/drivers/remoteproc/qcom_adsp_pil.c b/drivers/remoteproc/qcom_adsp_pil.c index 3f6af54dbc96..56156c12bd73 100644 --- a/drivers/remoteproc/qcom_adsp_pil.c +++ b/drivers/remoteproc/qcom_adsp_pil.c @@ -85,11 +85,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; @@ -182,6 +177,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) @@ -344,8 +341,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 8a3fa2bcc9f6..3ea668d9fd4c 100644 --- a/drivers/remoteproc/qcom_q6v5_pil.c +++ b/drivers/remoteproc/qcom_q6v5_pil.c @@ -342,11 +342,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; @@ -931,6 +926,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) @@ -1150,8 +1147,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 c7686393d505..e53fc6f268fc 100644 --- a/drivers/remoteproc/qcom_wcnss.c +++ b/drivers/remoteproc/qcom_wcnss.c @@ -156,11 +156,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; @@ -313,6 +308,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) @@ -492,8 +489,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 dbf685dbafcf..2c669a73e77d 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..1bce63a06424 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,8 +217,14 @@ 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, + .get_boot_addr = rproc_elf_get_boot_addr, + .load = rproc_elf_load_segments, + .sanity_check = rproc_elf_sanity_check, }; /** @@ -249,7 +249,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 +266,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 cc4d30a790b3..ca2021cf7b39 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 Fri Jan 5 23:58:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 123574 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1428201qgn; Fri, 5 Jan 2018 15:58:24 -0800 (PST) X-Google-Smtp-Source: ACJfBouXS7ouG+jRPn2YaXaU5KglkJIJ2XFln4fVMQ6ZD/BTDpPEWKY00LM163FXp4ssnsWOW1Kh X-Received: by 10.98.111.200 with SMTP id k191mr4453404pfc.75.1515196704384; Fri, 05 Jan 2018 15:58:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515196704; cv=none; d=google.com; s=arc-20160816; b=1LGsnVKk2K2kjKmEv5zNfkLKOw/p2EsxRFIet7vvpzMqPmsVebzxKdnSxXb+hQCXXz n2BYdhncSYVhBOC80TIY0yQLwvSFJqLf49mToa+G85rqigPp47Ui4ryCqb9aQlv9Pu+r MhWBJffAm0D9BhEcb6KkJo9UMHoVHEaNs5GfmODa3ZlZHKK4dLgXkyl18qucQ0zyD73T Ue+T+Cn/fuEvOk2gH/2tktADgV5NmEewBSSdtwZKO+NwAcT5LxMqdb8opOZdHQjLWOXA G1gkmmeblLwyFnZRCrQX3LQWuaBr9FZ0JZSUwuOhtdHh4SXz7MNjMpnSgSXGGN4rYW2r BDlw== 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=nWwXEBhoA7y6hYbvILx1bdPCbR83/acQmwWJfbBNYTU=; b=OdoE46F2IXy6u63D4anhgFwvsO7FiP5QayF1rrXZS5fyBDiISje0/1FdheqOpQj/4l 85B2UrvfBqWmDD7PGIY+VOf/pFa1XktFdXomrQCV270wMEYq2d+f6822JWrnt/xxmI/P DSUGXomhZ78I/3lxkeDszPM671Ce1CT+dBB4pFtuRIZHDeZ/VbyUU4jPbD/p9AAFAAFN RP/XRUMtSkMRYAK+YbWp8DaZ7A7O+KYTWws71l6JmyQ2tz6BA66YJXcAbdVe4b9X9QXO BhNCZz5VuuRFEl+Uj27R7F/exZxmqyCXaKa0gGivl0x5tfaxQy8eBIKobMeBE4SKRf+U PqEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LPZl+QH1; 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 98si4705984pls.543.2018.01.05.15.58.24; Fri, 05 Jan 2018 15:58:24 -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=LPZl+QH1; 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 S1753413AbeAEX6W (ORCPT + 28 others); Fri, 5 Jan 2018 18:58:22 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:41393 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752956AbeAEX6Q (ORCPT ); Fri, 5 Jan 2018 18:58:16 -0500 Received: by mail-pl0-f66.google.com with SMTP id g2so3980506pli.8 for ; Fri, 05 Jan 2018 15:58:16 -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=nWwXEBhoA7y6hYbvILx1bdPCbR83/acQmwWJfbBNYTU=; b=LPZl+QH17WQiCzbErkQNn21skdyG4OC7tXz1qNp4/Pg3pRtxIDsONJ8HZVLzj5Vv7d ayjDXg1ONYW1fQdTQFYuWPJCuCC9H9TEDlB72/R6k59b0X8QVzXiRG+bWdfzGXj3qZee Yi5Clz/cLtomk15JU/2sfqlS6hNBLklzibqlY= 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=nWwXEBhoA7y6hYbvILx1bdPCbR83/acQmwWJfbBNYTU=; b=oCjg6bdPNdDG3Ey8Oq6WbF8AAVzuhuUIr2daGHfROCvpdd6dJNv8QzNtMLjdDAgl8j HlTMJ72YRctyN344i8d0wMuIfvjSFBlgXEoEZU0UbQQAX4SuzJMXgdHjGLqFKEYz/DiF pPAymQUGCO/rxPF8XRk+RcARYjF9OzA72xTHecwn65jfXplGb5E3Pb3S/pC5/vYTy7k1 p98zJ3xdWKj7N8zQtK71SsI/jrJ8Af+GRvfMSNivT8rL0MASEsqOi7j/pBNx7UPf1vuj hpWNte8gPxeni8txnUmDgwTUXk7Youi/npRdgAKLPdcJDl05vWtB/wB6S7BHLw2MKCL7 RltQ== X-Gm-Message-State: AKGB3mJY0HhAJUQz3dFAy/lGXszCTkt3kk8qKVbaU4CV1t9aqD2mceE5 jLTBnjZaKC5ez99UabdrKVxviA== X-Received: by 10.84.128.15 with SMTP id 15mr775106pla.417.1515196695681; Fri, 05 Jan 2018 15:58:15 -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 x4sm14473188pfk.51.2018.01.05.15.58.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 15:58:14 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Loic Pallardy Subject: [PATCH v2 5/8] remoteproc: Don't handle empty resource table Date: Fri, 5 Jan 2018 15:58:02 -0800 Message-Id: <20180105235805.9948-6-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180105235805.9948-1-bjorn.andersson@linaro.org> References: <20180105235805.9948-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 --- Changes since v1: - None 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 2c669a73e77d..3160cfe897da 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 Fri Jan 5 23:58:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 123575 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1428229qgn; Fri, 5 Jan 2018 15:58:27 -0800 (PST) X-Google-Smtp-Source: ACJfBosP8SzoMgJwrIdqLouVuzckwO0uQ61Hl4/tmOFrOWb4mRtMof7PvFH9HuN+jRIiW9gWxc5Q X-Received: by 10.101.98.216 with SMTP id m24mr3793916pgv.100.1515196707192; Fri, 05 Jan 2018 15:58:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515196707; cv=none; d=google.com; s=arc-20160816; b=MboK8Kc54ZWhY6EOklz86Qb+ulZYRjxd7Hd8VyG7Cdawoy/xAfNnDd0vCEx7EljPpd Ib9JI22cclUr54LYjS3oI9vO91Duc+ub6iQBWuRhkYOfsEvu/lv369eV8sCRGOMEHx1N kWeoCI9CMtBcU0VZyjieTw4+Yd/P5qP+2C96W7zkH+c01DJfu+TIGfjPQwJocNIUQl2N mv1MrrRdNO8Jfick9ZI+9rQS8Aqu/GG+GSk9vObI/JZNi4jLnS06xrWFuY/BBdK9pgA4 keYYd6zJSTWq/XnIsL6eLLmCkjiwNfPu7MlctiHUp5dZoxh6/xNtUS+jYM5BE8+mN8tX pKXA== 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=Kp5gI5rm/IRFCRZd606gEcuBj2jnQLgx6zq5s0kNi18=; b=BoGmoMb/MO/RBzxUnINL27sA0moHTcm2gC7gwjxFmxMNAJ/JEOcuziv9dkt3psi9Va zFKsFm07wNTsFqFydKzrn7h55HDt+x4fkEjL5ddUtuWaboJwO4l4cATkiJpq8is9E3+Z xKCCmbTcu3Tbq2gHqa25KM8TXUnjQva0UJpTPYxtiWonGQFYIlUfTC7VQcBarNqg17mZ dh359QB+UteddEMcNksjl3RIUfeCKQzRGPhzvEE8qEUP8G1qiHc/OpH3HuYLXYT/coLx +9OY08W9JqKuEjUsx2en8o5XTK16zx5vK1K3YicRJ3kuoU8k67upHmMCdQO1YzDMfmJZ 5AEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NCsTAwOt; 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 98si4705984pls.543.2018.01.05.15.58.26; Fri, 05 Jan 2018 15:58: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=NCsTAwOt; 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 S1753454AbeAEX6Z (ORCPT + 28 others); Fri, 5 Jan 2018 18:58:25 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:41209 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753386AbeAEX6R (ORCPT ); Fri, 5 Jan 2018 18:58:17 -0500 Received: by mail-pg0-f67.google.com with SMTP id m17so218132pgd.8 for ; Fri, 05 Jan 2018 15:58: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=Kp5gI5rm/IRFCRZd606gEcuBj2jnQLgx6zq5s0kNi18=; b=NCsTAwOt1AVdL7I7yKRpZ1E2yEoh6L8g+yKGoJdu3udWe0DJCbGxNqFouBXFmC6Wav Ejd5P+HcnnmA4NgbJOWoDovaQiTeod+ApEAL1zGuxKBdkRHhorz1fN6JFX9aULAuBSkJ 0huPY7UA4M/kyAKqbv/eAMS5RrDKyV5mrOvig= 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=Kp5gI5rm/IRFCRZd606gEcuBj2jnQLgx6zq5s0kNi18=; b=DCe4uZ4fqKdH+HtH5On9hnansZ2UhZQO0MuDH3thJiNFLcl00rV7IdtfzerBDJeYyd GbDyzsXqJF9q459b/01wgNzRsddGaYtHwjMV9o/rcyXPiRfR97OiI6KoTmVNKm0CdnBy taf1hWEVpt5u/ZPosf+BpjzuJeE20Fw49yP3/4jYCyuTkKAcAcK/lKgemCVNF5n84cu6 iIIjES0HR95d8T819wiLIGc4Pqa3a9A21AAsrmbZ9li4WlrRYsXAhLEUx373BoKlSmY/ ErJAbnNiMdZJp/yj91nloYlueKp9D0mAxaz4S3jPwNutU0eXcrBOItJi05vr8iJs+Rok kTaw== X-Gm-Message-State: AKGB3mLEO/3RGqP13EbLkkRGWiI7kWcVlxg74GTfVYrFmakDFT3gWA4y RGPnLh0xmpVanUjO3VE+Chx3YplEtJI= X-Received: by 10.98.81.67 with SMTP id f64mr4423084pfb.122.1515196696835; Fri, 05 Jan 2018 15:58:16 -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 x4sm14473188pfk.51.2018.01.05.15.58.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 15:58:16 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Loic Pallardy Subject: [PATCH v2 6/8] remoteproc: Move resource table load logic to find Date: Fri, 5 Jan 2018 15:58:03 -0800 Message-Id: <20180105235805.9948-7-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180105235805.9948-1-bjorn.andersson@linaro.org> References: <20180105235805.9948-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 --- Changes since v1: - None drivers/remoteproc/remoteproc_core.c | 32 ++++++-------------------- drivers/remoteproc/remoteproc_elf_loader.c | 37 ++++++++++++++++++------------ drivers/remoteproc/remoteproc_internal.h | 16 +++++-------- include/linux/remoteproc.h | 2 ++ 4 files changed, 37 insertions(+), 50 deletions(-) -- 2.15.0 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 3160cfe897da..84e07d5b7c2c 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 ca2021cf7b39..cc853745e3a1 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -332,6 +332,7 @@ 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 + * @load_rsc_table: load resource table from firmware image * @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 @@ -344,6 +345,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 Fri Jan 5 23:58:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 123578 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1428767qgn; Fri, 5 Jan 2018 15:59:18 -0800 (PST) X-Google-Smtp-Source: ACJfBoulUm3MoS6rI+wAZs+C65a6JNBDr9q8lVU6FcGMLgs1tMZT1JisAVp96X1kNNxbiyljgblB X-Received: by 10.84.253.133 with SMTP id a5mr4620717plm.96.1515196758141; Fri, 05 Jan 2018 15:59:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515196758; cv=none; d=google.com; s=arc-20160816; b=ejKiI5hiIwahQEypbJ/UP2Q8cwJRncttncPtt+Nyq6Vzq1qp4LmvJgKxGR08M6ZbB9 jV9i0rNGK1eBbr5uTSUfPG91nX9k6UIRN6hK1MGry0qkcgC/kbaHPiqoMscorhW/jFUe /2bzGDoU1vgwQovef5RA9eNGXelqm+aijQ+Ecq6Y70fcoJmzQCgV7jOrON8F2hoOC9jV T2rRcyypxN7d6ZNk0FmmlaEBS3p8Shbmv+2rYUnioEHs0vtabt33zBxVRQ3bJ5oKBEVz eXch7lJKxQCwyjfugVHPk/TNZlQw5wH6lYXdjJlIcIvxn21rewtbXTjNSKuCT6mQm1Uo 1nVA== 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=0FTXsY+dMAMEQ9VdpNvs0ss1ap3PWV++7EMlqaRuwp4=; b=Or0+Nh6ftEuyeefuYJxABiQlRsA+s5CCTkia3uOk8zenzZl4p5FPFnnZz//iEDt9WZ qEPGvMTM1I8iUxl1paVHi4K8cQOexyxBuCtzVLmdjCuftVWc2+tS+iuc2fTRtN7WsdJp tOFk1CXIc+nTB8R7v4kHT8leaHdiurRwgyId9eaoefAE4epLd8GXVNGk7Snta1Iw791/ ytIx9q/Qt96Kr5aMsZArjzGsePKg8KJ2t911zEjcwbpScgHirnjbRBJQ0DhcHaNoZRIo NWgdOT1Vl6F23XXZOczcD24jvipWBKp7lAUv0sBIufrnKBHlbI7d0AU/GqUkmhIA3cXX Iunw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xqjn411J; 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 1si4712802plp.167.2018.01.05.15.59.17; Fri, 05 Jan 2018 15:59:18 -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=Xqjn411J; 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 S1753478AbeAEX7Q (ORCPT + 28 others); Fri, 5 Jan 2018 18:59:16 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:38016 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753388AbeAEX6T (ORCPT ); Fri, 5 Jan 2018 18:58:19 -0500 Received: by mail-pf0-f195.google.com with SMTP id u25so2815197pfg.5 for ; Fri, 05 Jan 2018 15:58: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=0FTXsY+dMAMEQ9VdpNvs0ss1ap3PWV++7EMlqaRuwp4=; b=Xqjn411JHI5MPkfzlJSUNRjzCo2qwtDaZMTZSTvSAzx0FJsY+rAdArlk0Fz4Gyp8mb w8gHfZ9BPfgpmmFnzjs69sNItVpvAy/VdaSgGTxlWCnUvcfOx4dlvUcllqnERHkZZapy EfaX3m9Ef4p4pgMGe+MoDgTwzNZA8ptNne8QI= 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=0FTXsY+dMAMEQ9VdpNvs0ss1ap3PWV++7EMlqaRuwp4=; b=WXMfcleQ89b0amrff0REVSqRetP46FLIOYnibW8Tef8QMHgiJCnMaf7Sthx49kw79f FJRuPYiLTpF5TFge064zeu85nYYx7FC42MMkmPY2jZbVeQz6q6EkhwNnIFzaMGrVzztz Hcwb0GINIluz1xl1lZE4ST7WAvfNmjr0zIQr5FUDP73erO5YdbtyBLQQrgIdslonJUnI eo8c6FbGyIS5hs7bqPw5J6s/KgIdDGpZEMWKf9tbwpkGVNWWYBAeH8lVkQNbk47eUCX3 Lv44S4gLzyul5qkiWVzuuZUp2DGeGVMMABfLe9ue8ixU/Lro18EQmL/9hCFwm2/MNHxh HYbw== X-Gm-Message-State: AKGB3mKvX6y99OsRktMK8ImCgtpcxe9OTQ6BHaLQVjATKG2cLPyxnhiZ mqmlxHhZeZkRgxHbpifijavxBw== X-Received: by 10.98.75.7 with SMTP id y7mr4392262pfa.196.1515196698437; Fri, 05 Jan 2018 15:58: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 x4sm14473188pfk.51.2018.01.05.15.58.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 15:58:17 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Loic Pallardy Subject: [PATCH v2 7/8] remoteproc: Drop dangling find_rsc_table dummies Date: Fri, 5 Jan 2018 15:58:04 -0800 Message-Id: <20180105235805.9948-8-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180105235805.9948-1-bjorn.andersson@linaro.org> References: <20180105235805.9948-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 --- Changes since v1: - None 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 56156c12bd73..373c167892d7 100644 --- a/drivers/remoteproc/qcom_adsp_pil.c +++ b/drivers/remoteproc/qcom_adsp_pil.c @@ -177,7 +177,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 d487040b528b..6eb9161f80b3 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 832e20271664..728be9834d8b 100644 --- a/drivers/remoteproc/qcom_common.h +++ b/drivers/remoteproc/qcom_common.h @@ -27,10 +27,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 3ea668d9fd4c..b4e5e725848d 100644 --- a/drivers/remoteproc/qcom_q6v5_pil.c +++ b/drivers/remoteproc/qcom_q6v5_pil.c @@ -303,16 +303,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) @@ -926,7 +916,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 e53fc6f268fc..3f0609236a76 100644 --- a/drivers/remoteproc/qcom_wcnss.c +++ b/drivers/remoteproc/qcom_wcnss.c @@ -308,7 +308,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 1bce63a06424..1ffb1f0c43d6 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, .get_boot_addr = rproc_elf_get_boot_addr, .load = rproc_elf_load_segments, .sanity_check = rproc_elf_sanity_check, diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index cc853745e3a1..728d421fffe9 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -333,7 +333,6 @@ struct firmware; * @kick: kick a virtqueue (virtqueue id given as a parameter) * @da_to_va: optional platform hook to perform address translations * @load_rsc_table: load resource table from firmware image - * @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 @@ -346,9 +345,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 Fri Jan 5 23:58:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 123577 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1428623qgn; Fri, 5 Jan 2018 15:59:02 -0800 (PST) X-Google-Smtp-Source: ACJfBotn9fGsSodvS7uvJDsGXCjym88rqG7cERNPd6oXMsM7i+zOs4Ba1WnXQabQH8zu/prMoYdD X-Received: by 10.99.176.74 with SMTP id z10mr3730732pgo.83.1515196742844; Fri, 05 Jan 2018 15:59:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515196742; cv=none; d=google.com; s=arc-20160816; b=Nh18fAkantZFuXqXRnsgTavwEukUTA9EgqLXEZc+ybw5h7h6frCdL6mod5uD1gV0YJ Zd/a8pPXBLMuJ1RNA+bcbsBHSNyBhMzcuQ8HxKk1EeI7pSMwUbZ8C6LmlyT8tznhQ5Wi 2MEfLaWVcU0Nx2i/CLEHOIoW1AoPwJbHZk0+/z35nuSmm26DzqfLJIMJ9chxCi9+1Bwm VCIr99skxxTRLuHNawiigH1OPG7t3gdm1UHQNKmU2CPtR89uXdcxHGs4rjSqMea95HpZ TKaTTFhPXy4bN5yW0sK5483cXNmxL2f4EC2+50VTCmAlGkNxmtkKXXZD+xR4NMoTCqTn u9mQ== 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=c76S7ibwsj0bv8215EGQcbowDMuGFLZXzMgLuuMZmTw=; b=jiMkyAlSFykZCGGLHoIwOtVWlL5YSrsRb9w4myZg7XaY88n5zXfTcfcMGFRvN//MLd Jff5rYAEglXD8ysYvzhdd/oBKMyVJlTWQJhNStSf9L8E2kubpZrLB+3DoUpUwVUEe/iv 3M6TlWZfmodut5+X+LolH1WAfn0UFqrD4c5tu6f2Hu1AIe0eRsihDSRJl0av/y0sQFPJ AOvF0YbKDURpUr40I2I6oR7mu/NAeMIXZ4+Lxa/P05+TKn5sDIk8c101aAueUWkRnxrd cCkBwtHSNYAyW4xynBdm/1hyRyA2lhiAHFrJGEKRkID2S/IBt10n4PthPbvHyFFaHn2a r2IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OSvMcxcR; 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 e1si4773587plk.761.2018.01.05.15.59.02; Fri, 05 Jan 2018 15:59:02 -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=OSvMcxcR; 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 S1753469AbeAEX7B (ORCPT + 28 others); Fri, 5 Jan 2018 18:59:01 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:46894 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753393AbeAEX6U (ORCPT ); Fri, 5 Jan 2018 18:58:20 -0500 Received: by mail-pf0-f195.google.com with SMTP id c204so2805564pfc.13 for ; Fri, 05 Jan 2018 15:58: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=c76S7ibwsj0bv8215EGQcbowDMuGFLZXzMgLuuMZmTw=; b=OSvMcxcR2vjteXoiD9TwHConzSwfDq/iq/FEP86Nfto77KH09akGKtrtAhak80HJxi TnQezomb8QYEtSwqN0fIeQZGVGVpKpkvVwM8+s2NseBxOmruByzgmel8sVULheH69uho 3gNMatqW7GNATvHeg8W1Lf4rucGbaAc1OSN8M= 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=c76S7ibwsj0bv8215EGQcbowDMuGFLZXzMgLuuMZmTw=; b=Mfb/fMk8pjtt8tqdrEiQe7aCY31qKcMPMELP7kDmBdpR3GZd3Qvhp7YwgNKET5dzPB 9+eTfQGpDjYjNY7/woVAl6e2yT3a+8ApTgVwSt4TPmIpNF4SJxGhTSdPktveTslSwe+s wGfoenidGbaaXY50FP7aGzQ8MXVgBU92+nVPIKeSM2jjuRQq8xgEIv2z3XDQmhfd25IP Va3/4i+MGld12ap+zbNc/m11EID3qtxDoF0OamxXqIt7LxRR/ouGV+zzIDu4R26VVxE7 Uxz5nyQx0ntx83LfLCa3F/mJUK1SvJcxOdZhJlPBAdTbKJtTFYo1v6Tvzq1ulTO+dg/A nvYg== X-Gm-Message-State: AKGB3mIN/Zl2mXeZvw4PMN8Lp5nzu6ujxmbPU2291/htVt5nTtqSCuau Of3sXq3RSOegUBPXlslv/bXhoA== X-Received: by 10.98.13.78 with SMTP id v75mr4395141pfi.59.1515196699606; Fri, 05 Jan 2018 15:58: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 x4sm14473188pfk.51.2018.01.05.15.58.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 15:58:18 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Loic Pallardy Subject: [PATCH v2 8/8] remoteproc: Reset table_ptr on stop Date: Fri, 5 Jan 2018 15:58:05 -0800 Message-Id: <20180105235805.9948-9-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180105235805.9948-1-bjorn.andersson@linaro.org> References: <20180105235805.9948-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 --- Changes since v1: - None 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 84e07d5b7c2c..4170dfbd93bd 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1000,6 +1000,9 @@ static int rproc_stop(struct rproc *rproc) /* remove any subdevices for the remote processor */ rproc_remove_subdevices(rproc); + /* 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) {