From patchwork Thu Oct 20 02:40:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 78380 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp560369qge; Wed, 19 Oct 2016 19:40:35 -0700 (PDT) X-Received: by 10.98.94.7 with SMTP id s7mr16828396pfb.37.1476931235078; Wed, 19 Oct 2016 19:40:35 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b21si39519762pgh.99.2016.10.19.19.40.34; Wed, 19 Oct 2016 19:40:35 -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 S933889AbcJTCkc (ORCPT + 27 others); Wed, 19 Oct 2016 22:40:32 -0400 Received: from mail-pf0-f182.google.com ([209.85.192.182]:36067 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933730AbcJTCk1 (ORCPT ); Wed, 19 Oct 2016 22:40:27 -0400 Received: by mail-pf0-f182.google.com with SMTP id e6so26527795pfk.3 for ; Wed, 19 Oct 2016 19:40:27 -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=nmt7CWN6T6q2zNgeeUYV1ZmLcHJKpHPPT/ElKYfA/nE=; b=MUJzBmPaPB7+y3o55Ie2fARUhgJZavDx5bBXEj8MtMmCBhyzrEmaKAGr8jsR8rnOzx zbTnlwiNAn2khMAaORaLpqoe+B5qgG7oYx2iws5AD+B5zXUZ4uXx6CL/TTek/I0GLbTK hTSHlyBCoCljHt8mC662v2sWvov5Kj1pSPzhQ= 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=nmt7CWN6T6q2zNgeeUYV1ZmLcHJKpHPPT/ElKYfA/nE=; b=dqB4gpiGXAZKzMX6pBT7u0k4e4GkgLxtC6qPb17ulLgJMVWXvFMEJ4hAQxsMkUjhsf Vl5OV7k8sy8gqQuR2PU4z1PKf6CWwXIRMIUnrB21G4b5imUA23sOJt1Ex/cgeCuclY6M /fzj7IfaRdSxTZPtYRSCG8W28Pp6MkJUPGtJs25kM/bNhpzJY1Wrt9qwvBA3Xacyg/dB +V4BLDCz2obUyvCSgOWaqsct+CeJmkJrosTmW1kNeW16B4DCMhNp1EKXeqeehEQdMRUq q8HKOKaw7TJOBS35d9dtAqgfLmyVSvh+kfZbypai8Cnqln1bZfWGYNFJCtPv6NzsQWXS Jl0w== X-Gm-Message-State: AA6/9RlEQtRYoAAnOFUAvMgPxZ/STFE5EH7n/QDjAPcVuBg0kIwV+1zCXR3uOEP+AMONciqx X-Received: by 10.98.63.144 with SMTP id z16mr16871794pfj.61.1476931226828; Wed, 19 Oct 2016 19:40:26 -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 s85sm66780616pfi.17.2016.10.19.19.40.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Oct 2016 19:40:25 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/11] remoteproc: Further extend the vdev life cycle Date: Wed, 19 Oct 2016 19:40:08 -0700 Message-Id: <1476931212-1806-8-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1476931212-1806-1-git-send-email-bjorn.andersson@linaro.org> References: <1476931212-1806-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 Tie the vdev (and hence vring) life cycle to the resource parsing and resource cleanup operations, allowing us to safely register and unregister virtio devices on the go. Signed-off-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 2.5.0 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index e4509c8dd8e8..1d2f4b2dd05d 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -377,6 +377,9 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, goto unwind_vring_allocations; } + /* track the rvdevs list reference */ + kref_get(&rvdev->refcount); + list_add_tail(&rvdev->node, &rproc->rvdevs); /* it is now safe to add the virtio device */ @@ -839,8 +842,10 @@ static void rproc_resource_cleanup(struct rproc *rproc) } /* clean up remote vdev entries */ - list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node) + list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node) { rproc_remove_virtio_dev(rvdev); + kref_put(&rvdev->refcount, rproc_vdev_release); + } } /*