Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp655526ybg; Mon, 1 Jun 2020 10:54:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnLd46wfQyHaUaJSRKsKkCTwBevJ7itfgWCiGveLd4B3cdeydGByPG/+5cGtAb2XwyDvKt X-Received: by 2002:a17:906:77c4:: with SMTP id m4mr11364674ejn.246.1591034060463; Mon, 01 Jun 2020 10:54:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591034060; cv=none; d=google.com; s=arc-20160816; b=o2JEUk2Gq+5TLFRiF1ZxJpl1mghsxVbMuqaWW7MHXykk/4hKOl2aTvZnzpTzwr7B8E mg6d+N+aFmlYamBy6ZfTHNYro1cyxUL4YyCa+x59WzVGIyqr1BsXLqH29Gl/qVE+CSEF om4HrFF3MViqQIRcLXJ4TVKowAzxq7O68kBIh+L7upAAQ5wuVmY/wy3tAjJVjqh9a/5Z 1O3pwt5Xg/mnoMWsUZg3xoWX6RjiqX8CD0N4OoMSwdb6gdXrVV1IboGjfAEqY5Rlak+q 8rj14xLo2OJVNSlD54DPm00UbUf3kPjyuRuc33pTqA3Fdc4ndscgajp+gGcQ1rNekZnv l9lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8/x/Azb6Kg/NbqI55RX5Ve/Ez0un3vqYQH7pMGZ5AbE=; b=KgLwilJN3oPqtgCo8Ccw+BZP5qJX7NUfNm0XIT079Pmup7uPSkLj4q5AgqGc4AcBKf D9ipLvRuJciyhWIC9+Xs4xGBdxsQEegJ476xhj3t5hjAang9sj8EmYWM3wJIwrq0br04 LpLc35h5suwS0K7pOgvX0UUS0xYXyF7IduSY8UECWA7FjR9v8uCK5/uHnvELVKd/pLTG y0x5oBQl8A5WKuwFiKLW73J2r4O8HlkutQOl6oVg6fRgZoM8PhvV9v2JUDShBjSPhimz 4oq/wvy8XGn5z/u5FOKuKKBqVyTy0QZB+h5FTBKnacn/+7gctWmAN+0HA5gMcO63c1sP asEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o5Aq+ozp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id dp9si124573ejc.698.2020.06.01.10.53.56; Mon, 01 Jun 2020 10:54:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o5Aq+ozp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728219AbgFARwA (ORCPT + 99 others); Mon, 1 Jun 2020 13:52:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728145AbgFARvv (ORCPT ); Mon, 1 Jun 2020 13:51:51 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B90BC08C5CA for ; Mon, 1 Jun 2020 10:51:50 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id ga6so148598pjb.1 for ; Mon, 01 Jun 2020 10:51:50 -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 :mime-version:content-transfer-encoding; bh=8/x/Azb6Kg/NbqI55RX5Ve/Ez0un3vqYQH7pMGZ5AbE=; b=o5Aq+ozpRTnKAIKVImlb5AcOZXP4grSiV+mfEH/upXXatlwIxF/j5A5cANcnl0AHgT jwuCkOrSk0rsG3fXuif/iF5bxYGB8prSvJiICxP32EF5/T0GUEPXqLZULvoljkIlZqXM jpJmUm4TBT5etW6/epjCRJxgVL2c2Y2a+a2c7HM6+KoUqyTZ21P7xV+jddLDnzltZ/5D kyFyWW/mg3iu6RClpV91KwnVVSeK9rphak2IroFFJx5NYsHoGz5JVkxucX7oV6qw+DFD 1P6TXhA/dQ1Oxyg6R++p2P44qAoqCS+U1lcjr/nnitGTaM3r700ATuqt+QqHIYyDMW6j XAcQ== 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:mime-version:content-transfer-encoding; bh=8/x/Azb6Kg/NbqI55RX5Ve/Ez0un3vqYQH7pMGZ5AbE=; b=qgXPlystpNKOY1aPA3SipAI9PzAgD3A0SHKmdZ245cOhlXmGpI66Rl/myCfU99PTcJ SeqimUYExubM7Cqg0pbdiG5kCiZW1A4Wfe2DrDkD1wTl7M7PMVSxI2gsFoY69guRtG2f oy0WfscEuE3aAGzj1Op1D9CCt9xquN27Wbsp3qYo3GA33MyrUVJSkylLNO48gQ4Lqswv vlkbnycsrDYoLH/GoO8PYSVDodQraHUJdBN7k0SCr+kNOfTuNjhIzfx+gxN5hDR9UIf1 Oze9INtL3GbuWZJ2KdR53iC51Eb4zSFVSI7UbFw41t4qnUrGdpghERJJmV+E5BenA2Er asQg== X-Gm-Message-State: AOAM533XVadjfZ9XWEyGhBQKcuAox8WxjKu8YXBx1o8y0Hpi814pSEqi zwEJ2WlYQcilVQXusnfZrxNNfA== X-Received: by 2002:a17:902:b097:: with SMTP id p23mr10131955plr.14.1591033909721; Mon, 01 Jun 2020 10:51:49 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id k12sm58219pfg.177.2020.06.01.10.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 10:51:49 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, loic.pallardy@st.com, arnaud.pouliquen@st.com, s-anna@ti.com Subject: [PATCH v4 8/9] remoteproc: Refactor function rproc_free_vring() Date: Mon, 1 Jun 2020 11:51:38 -0600 Message-Id: <20200601175139.22097-9-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200601175139.22097-1-mathieu.poirier@linaro.org> References: <20200601175139.22097-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When function rproc_free_vring() clears the virtio device section it does so on the cached resource table rather than the one installed in the remote processor memory. When a remote processor has been booted by another entity there is no need to use a cached table and as such, no need to clear the virtio device section in it. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_core.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index d32ac8f0c872..0e23284fbd25 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -411,10 +411,22 @@ void rproc_free_vring(struct rproc_vring *rvring) idr_remove(&rproc->notifyids, rvring->notifyid); - /* reset resource entry info */ - rsc = (void *)rproc->table_ptr + rvring->rvdev->rsc_offset; - rsc->vring[idx].da = 0; - rsc->vring[idx].notifyid = -1; + /* + * At this point rproc_stop() has been called and the installed resource + * table in the remote processor memory may no longer be accessible. As + * such and as per rproc_stop(), rproc->table_ptr points to the cached + * resource table (rproc->cached_table). The cached resource table is + * only available when a remote processor has been booted by the + * remoteproc core, otherwise it is NULL. + * + * Based on the above, reset the virtio device section in the cached + * resource table only if there is one to work with. + */ + if (rproc->table_ptr) { + rsc = (void *)rproc->table_ptr + rvring->rvdev->rsc_offset; + rsc->vring[idx].da = 0; + rsc->vring[idx].notifyid = -1; + } } static int rproc_vdev_do_start(struct rproc_subdev *subdev) -- 2.20.1