From patchwork Wed Aug 10 18:57:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 73685 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp547920qga; Wed, 10 Aug 2016 11:57:33 -0700 (PDT) X-Received: by 10.66.253.101 with SMTP id zz5mr9755421pac.32.1470855453407; Wed, 10 Aug 2016 11:57:33 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r71si49790408pfa.279.2016.08.10.11.57.33; Wed, 10 Aug 2016 11:57:33 -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 S965168AbcHJS5J (ORCPT + 27 others); Wed, 10 Aug 2016 14:57:09 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:34201 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938911AbcHJS5G (ORCPT ); Wed, 10 Aug 2016 14:57:06 -0400 Received: by mail-pa0-f47.google.com with SMTP id fi15so18272133pac.1 for ; Wed, 10 Aug 2016 11:57:06 -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; bh=6hp5JGgvlmOpjT6joetpjcyV4VcIkmUlg3oi/ie7VA0=; b=L/54ZgXPuTNobRdLdd/9S9M4TTRets/z7u3lVl5ldwlxIIaEmEdRwfN3w+tPR6JfRi yYyGItZciRRZHKg7puCI2l6rLihVVR0mtS9JkCyuEaH03/8FT4bDpVAcw46mMP9VT53/ oIGSAdNruJrL/oYYlTL9WPDbwnY6Hh8qbUk5s= 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; bh=6hp5JGgvlmOpjT6joetpjcyV4VcIkmUlg3oi/ie7VA0=; b=en7DAS/4kXZmcDkwJ9PBI0tgsgBZUlY/GBaiIU4dplerFEB9ERS373X/UDZZIy6AuY bS3xknsfmTSPOdhE823j35bg7KPkws2T/fLwEjmhSjC4ENJfdN0Y3amK5cidZm3Rva72 aUXsBmn8ZiJOqUGkCFnJBN3Vkg6Y+2Nz7JgYfGSX9XFq3j0KuVN9SXjNI9+ANKmD1GOX NfPvPJTDJdf6rAenoV0p+6hINkoVoCE0HJQIwH1vR+hKP25bZa9S99XqesCMQhZLcq58 ZFi6wUxkEBM32wkfjCfuYtoQtyRxp8x7Kx5DcmaNoo395y9pFqkOVXw+lzN8JxydZ0nJ OsVA== X-Gm-Message-State: AEkoouvQX5RoNCUmUI45kE/21E+DyAZFeHOndPTH2eUk7S44QFSB2wLNLax7Ow/3FdMIM3Ep X-Received: by 10.66.165.67 with SMTP id yw3mr9983659pab.8.1470855425943; Wed, 10 Aug 2016 11:57:05 -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 d9sm65970701pan.7.2016.08.10.11.57.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Aug 2016 11:57:05 -0700 (PDT) From: Bjorn Andersson To: Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] remoteproc: Only update table_ptr if we have a loaded table Date: Wed, 10 Aug 2016 11:57:03 -0700 Message-Id: <1470855423-32472-1-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the case that we have a resource table, but not a loaded one we should leave the table_ptr intact, as subsequent resource handling could otherwise dereference the NULL pointer. Cc: stable@vger.kernel.org Fixes: e395f9ce49eb ("remoteproc: core: Make the loaded resource table optional") Signed-off-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_core.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) -- 2.5.0 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index fe0539ed9cb5..29f3d7e045aa 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -854,12 +854,15 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) * The starting device has been given the rproc->cached_table as the * resource table. The address of the vring along with the other * allocated resources (carveouts etc) is stored in cached_table. - * In order to pass this information to the remote device we must - * copy this information to device memory. + * In order to pass this information to the remote device we must copy + * this information to device memory. We also update the table_ptr so + * that any subsequent changes will be applied to the loaded version. */ loaded_table = rproc_find_loaded_rsc_table(rproc, fw); - if (loaded_table) + if (loaded_table) { memcpy(loaded_table, rproc->cached_table, tablesz); + rproc->table_ptr = loaded_table; + } /* power up the remote processor */ ret = rproc->ops->start(rproc); @@ -868,13 +871,6 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) goto clean_up; } - /* - * Update table_ptr so that all subsequent vring allocations and - * virtio fields manipulation update the actual loaded resource table - * in device memory. - */ - rproc->table_ptr = loaded_table; - rproc->state = RPROC_RUNNING; dev_info(dev, "remote processor %s is now up\n", rproc->name); @@ -882,6 +878,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) return 0; clean_up: + rproc->table_ptr = rproc->cached_table; rproc_resource_cleanup(rproc); rproc_disable_iommu(rproc); return ret;