From patchwork Thu Aug 11 21:52:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 73821 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp322875qga; Thu, 11 Aug 2016 14:53:17 -0700 (PDT) X-Received: by 10.98.135.13 with SMTP id i13mr21214091pfe.44.1470952397128; Thu, 11 Aug 2016 14:53:17 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i7si5034832pai.287.2016.08.11.14.53.14; Thu, 11 Aug 2016 14:53:17 -0700 (PDT) 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; 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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752547AbcHKVxD (ORCPT + 27 others); Thu, 11 Aug 2016 17:53:03 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:35284 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932473AbcHKVw7 (ORCPT ); Thu, 11 Aug 2016 17:52:59 -0400 Received: by mail-pa0-f43.google.com with SMTP id i5so2241122pat.2 for ; Thu, 11 Aug 2016 14:52:59 -0700 (PDT) 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=kwVPY0mj05EU3MR3eq1OELSZusadUHH/78cNMFauOPc=; b=fG8FbyO3rQzweZxc5K5k2fBI8+gaxCLFAf9GpY5eLm7E9BOHtNnN3NbDiS/ORjxUda 7pvUQY9wLYy9EPzGSaklCU3yyCwLbGNC1HVzdHLSfttfVKJITHX+vmXb4d8cr4Zpug6I FpVVwnOdhlxgGygxDEQV4QSAgM1MTOGNxHnlQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kwVPY0mj05EU3MR3eq1OELSZusadUHH/78cNMFauOPc=; b=P+sOu2WN5i9TTHofNe4sHy3rhjyN2R8zf6MRGqXYQEHGg7Ry9QFkMTRR0bGxNvkb5w 9X711PtMngiv+5LJ5SMzUeMxv5ppDtd90TYHLLxNZh6DcP2X0lQhH4RoJ80lbEsRzLWQ p+Qqbf2aHPv0kUVDqNSSPYgijAEzMV03sqRxWox8vnVQz+YTKLlgtv9QAttN1RxkZUR1 Z16j0TZvrESDyOc9YEPfv0GMWRx2tenCmv/o6dzTZ3jzEnR/VZjlnsq8y1TAJ5wZOb8n OJM+ccq3od9mHcTdyTPhnKjZ/vyZZZ4W7m5FIxJroB3NJrkX56y4hd034+aQCVubRwNN AuKA== X-Gm-Message-State: AEkoousSd2zF6QsDffqavy9jiYluA4n/SC5eXh21Qak2fG43TPGhyEuTIgrtqO03EX7GsQWh X-Received: by 10.66.72.106 with SMTP id c10mr21029957pav.18.1470952378869; Thu, 11 Aug 2016 14:52:58 -0700 (PDT) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id bx9sm7547908pab.17.2016.08.11.14.52.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Aug 2016 14:52:58 -0700 (PDT) From: Bjorn Andersson To: linux-remoteproc@vger.kernel.org Cc: Ohad Ben-Cohen , linux-kernel@vger.kernel.org, Suman Anna , Lee Jones , Loic Pallardy Subject: [PATCH v2 4/4] remoteproc: Move handling of cached table to boot/shutdown Date: Thu, 11 Aug 2016 14:52:53 -0700 Message-Id: <1470952373-4823-4-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1470952373-4823-1-git-send-email-bjorn.andersson@linaro.org> References: <1470952373-4823-1-git-send-email-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As we moved the vdev handling to the main boot/shutdown code path we can further simplify the resource table handling by moving the parsing spet to boot as well. The lifespan of the resource table is changed to live from rproc_boot() to rproc_shutdown(). Cc: Lee Jones Cc: Loic Pallardy Signed-off-by: Bjorn Andersson --- Changes since v1: - None drivers/remoteproc/remoteproc_core.c | 55 ++++++++++++------------------------ include/linux/remoteproc.h | 2 -- 2 files changed, 18 insertions(+), 39 deletions(-) -- 2.5.0 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index e86200f978e2..36c019148f7e 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -802,9 +802,6 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) struct resource_table *table, *loaded_table; int ret, tablesz; - if (!rproc->table_ptr) - return -ENOMEM; - ret = rproc_fw_sanity_check(rproc, fw); if (ret) return ret; @@ -831,11 +828,17 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) goto clean_up; } - /* Verify that resource table in loaded fw is unchanged */ - if (rproc->table_csum != crc32(0, table, tablesz)) { - dev_err(dev, "resource checksum failed, fw changed?\n"); + /* + * 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 devic memory. + */ + rproc->cached_table = kmemdup(table, tablesz, GFP_KERNEL); + if (!rproc->cached_table) goto clean_up; - } + + rproc->table_ptr = rproc->cached_table; /* reset max_notifyid */ rproc->max_notifyid = -1; @@ -893,6 +896,10 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) return 0; clean_up: + kfree(rproc->cached_table); + rproc->cached_table = NULL; + rproc->table_ptr = NULL; + rproc_resource_cleanup(rproc); rproc_disable_iommu(rproc); return ret; @@ -909,36 +916,11 @@ clean_up: static void rproc_fw_config_virtio(const struct firmware *fw, void *context) { struct rproc *rproc = context; - struct resource_table *table; - int tablesz; - - if (rproc_fw_sanity_check(rproc, fw) < 0) - goto out; - - /* look for the resource table */ - table = rproc_find_rsc_table(rproc, fw, &tablesz); - if (!table) - goto out; - - rproc->table_csum = crc32(0, table, tablesz); - - /* - * 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 devic memory. - */ - rproc->cached_table = kmemdup(table, tablesz, GFP_KERNEL); - if (!rproc->cached_table) - goto out; - - rproc->table_ptr = rproc->cached_table; /* if rproc is marked always-on, request it to boot */ if (rproc->auto_boot) rproc_boot_nowait(rproc); -out: release_firmware(fw); /* allow rproc_del() contexts, if any, to proceed */ complete_all(&rproc->firmware_loading_complete); @@ -1178,8 +1160,10 @@ void rproc_shutdown(struct rproc *rproc) rproc_disable_iommu(rproc); - /* Give the next start a clean resource table */ - rproc->table_ptr = rproc->cached_table; + /* Free the copy of the resource table */ + kfree(rproc->cached_table); + rproc->cached_table = NULL; + rproc->table_ptr = NULL; /* if in crash state, unlock crash handler */ if (rproc->state == RPROC_CRASHED) @@ -1467,9 +1451,6 @@ int rproc_del(struct rproc *rproc) list_for_each_entry_safe(rvdev, tmp, &rproc->rvdevs, node) rproc_remove_virtio_dev(rvdev); - /* Free the copy of the resource table */ - kfree(rproc->cached_table); - /* the rproc is downref'ed as soon as it's removed from the klist */ mutex_lock(&rproc_list_mutex); list_del(&rproc->node); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 76d936cabbf8..7cd0279bfe6a 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -409,7 +409,6 @@ 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_csum: checksum of the resource table * @has_iommu: flag to indicate if remote processor is behind an MMU */ struct rproc { @@ -441,7 +440,6 @@ struct rproc { int max_notifyid; struct resource_table *table_ptr; struct resource_table *cached_table; - u32 table_csum; bool has_iommu; bool auto_boot; };