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: 9385761 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 77E7760CDC for ; Thu, 20 Oct 2016 02:40:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F9C728623 for ; Thu, 20 Oct 2016 02:40:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AFEF20246; Thu, 20 Oct 2016 02:40:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D51062993D for ; Thu, 20 Oct 2016 02:40:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757538AbcJTCk3 (ORCPT ); Wed, 19 Oct 2016 22:40:29 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:35123 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933735AbcJTCk1 (ORCPT ); Wed, 19 Oct 2016 22:40:27 -0400 Received: by mail-pf0-f174.google.com with SMTP id s8so26524394pfj.2 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=lFDz1/kxuJYg06ZaTQYAlMIoGsOTN+IEexnndLP67j+9ru7aNISy2o9/uDq+FLqAY1 0wacsSzX1bP9k/hsYiUzN8Aw4CURBMzZX14V5tbqGVRgrTO7GQjNjOytzEnA0U4uW/KO MKsry3rt1YxSoL/5/vWHMp7KgmG2pBD/wAGl7G1Ny9gNmfililQOXyUuGtNvI946U2sF KuawrcKrsHURFvLRKrvsJuuWjZa2gqXbuF1Se63aWGQW9gOEoaFuG/Et1TCHHOIPCqP3 HdjrjXrRkOq5/zNa01rlKMZWASP42CCezsgSD7bFH1iNeSJqHP1Y568YI5+ZitYR6LuC sMFg== X-Gm-Message-State: AA6/9RloA7d+uNKmNso87fUYhgjos9yRqG7fHaPn3XAYp4Rt0vp+DiD/x36fEqsAhCGNf0j6 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-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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); + } } /*