From patchwork Wed Mar 29 14:24:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Liu X-Patchwork-Id: 668116 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp394223wrt; Wed, 29 Mar 2023 07:26:19 -0700 (PDT) X-Google-Smtp-Source: AKy350b6v67IJyP4atHzuUUcT2SttVv0FExX5ndxwA9j/3B9NmB7Xh2uuyg0EOrJY+yg1fmFmHr1 X-Received: by 2002:a17:903:32d2:b0:19e:68b1:65b9 with SMTP id i18-20020a17090332d200b0019e68b165b9mr24856162plr.12.1680099979639; Wed, 29 Mar 2023 07:26:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680099979; cv=none; d=google.com; s=arc-20160816; b=tdC7F3n/LE8sNjvToBJGYtCqx8JUXJ3vGwswHPjUq9cV2t0MBr70NkgS1H+ThHtb/b j9JO2rXK/i58G5C4xPU6iWLPw0vACXGaYDHXexZekZa2FYnJp9baPYmGcQsTm5ri6+VH aeKJXY7lJ8jx5nZmppoT9njc2AWocXgKYMb/OTYY3ljhixdeulOeJziUyHNrf0sswlgj d0ssGpfrcpIFFCPlp59DJo2x4u4wffcA7e4iDm4+h6TVDE3Mw0vuFSBb8r3F3L+jVH50 mdtaZaD0tlwoQgtvT9TfbrrZJtOkAq6gD3EIWQHPGf0/dRlCPnU2rwf0lKxqZjY19wwH 8K2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LpDtt87OxGD+muZENoIEPV8oFk/2pLQeuGUBm3CU2UM=; b=oOJNJK0WxZ+WO/8RVWtiOXIVszDd0nTZMieF5z6TJ6Ox1w5SE2pWQbUXn42HS3rO+X akg8eJMeiJ9x5vRFfkBmfKlSR3punQ371FxlNtjbkMCc9BWG/Q/DjGoP7Q3yNEvAY6hT sB2e0m3QreTOeXExKHv5amYruG6ks+36NnCXrPebEbAYuKQKQemowDbya1ekhqUwf59J ALH3m0h33eH25E7lrgYoGCGWIpiO0LJTQkS7YLSlS4KONBEp1B1AaboiePKa4vROlWX8 QJ/SIdHpAU5fUUgHeq9jdLCcDis1aAePPtuKfZSoc1C203wBbSYVBa2PRXTndj0BmmCn +aKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IKRh8YEQ; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id e12-20020a17090301cc00b001a221acb462si11686532plh.73.2023.03.29.07.26.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Mar 2023 07:26:19 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IKRh8YEQ; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4201086027; Wed, 29 Mar 2023 16:25:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="IKRh8YEQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3647485858; Wed, 29 Mar 2023 16:25:25 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3BBF585D4E for ; Wed, 29 Mar 2023 16:25:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=paul.liu@linaro.org Received: by mail-pl1-x629.google.com with SMTP id u10so15074813plz.7 for ; Wed, 29 Mar 2023 07:25:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680099913; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LpDtt87OxGD+muZENoIEPV8oFk/2pLQeuGUBm3CU2UM=; b=IKRh8YEQ77Q2szFi8TIHUbaQWSRXptcwxxuZ6lOaXrfOLfHmBJtgBkIXcLfHHGNkLv XKwR7AxzwOCxk/4MkyZY6ZDZiqOaVfi9dWWpBAuZTbrg0XPnVxMt1CjiEs3/zq4JU7n4 xMlrO6m7QwdKAV3tvTcaefDc/+PMxxRMD9AqF46+gC0VRRYTloUeVe+QvBCcWgd9Eeru A26LmCtMOyaFstFKLuDUPfu/IaMlcuugOxAChvPN8QhvswmyAp8GKyEInoiLkYCHS8zW 7mHkHcNqDr1MUEE4/T6y6Vs3bx+cwANl251GE4mAiH01qjdpJX/jVUpTxqYQzOKnbcwz VInA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680099913; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LpDtt87OxGD+muZENoIEPV8oFk/2pLQeuGUBm3CU2UM=; b=paVpq0lqSFgYRvTuzl5INHlVCVglHgNuwHgbCZ27Rs8RoA42iVd1ApXtESUwxiqVdv loR6FWNn04KS7iLg/L1rnJDBstia2PIZ9qSAKUqiTweqrELnYke6E1iBE1dqoBVe2N5M 7W2xafF69YXRSB+SUl+ALrMj+dmw7dblzwdH7qPz5z0vzHLPy1zOj9RHrvoN/YtRmYs2 0pb+a1EdkHCJfwqAFURVUwFX5vGEp3LdrHQkw9qW63PyJcEfECv9GdELN9YTidJhtMSb C+WOCY9abotbZC2J8aF2T5i1oHto2v2w2VJMyzUn1k1V7FZ67jbZ2hCmjabuYh3tants 4dvA== X-Gm-Message-State: AAQBX9cgHiZNR24a+TzctOpaYPp98rRRBK5w2blLtQ6ObR3aFGC1kRtr dSlSmsePoIOMnOn3NGMMu90WwECAwqwgdKeUbl4= X-Received: by 2002:a17:90b:4f8c:b0:23f:ef7:7897 with SMTP id qe12-20020a17090b4f8c00b0023f0ef77897mr20055566pjb.49.1680099912993; Wed, 29 Mar 2023 07:25:12 -0700 (PDT) Received: from localhost ([111.184.129.17]) by smtp.gmail.com with ESMTPSA id z12-20020a17090a1fcc00b0023b15e61f07sm1505239pjz.12.2023.03.29.07.25.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Mar 2023 07:25:12 -0700 (PDT) From: "Ying-Chun Liu (PaulLiu)" To: u-boot@lists.denx.de Cc: Will Deacon , Ying-Chun Liu , Bin Meng Subject: [PATCH 4/6] virtio: Add helper functions to attach/detach vring descriptors Date: Wed, 29 Mar 2023 22:24:58 +0800 Message-Id: <20230329142500.682922-5-paul.liu@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230329142500.682922-1-paul.liu@linaro.org> References: <20230329142500.682922-1-paul.liu@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Will Deacon Move the attach and detach logic for manipulating vring descriptors out into their own functions so that we can later extend these to bounce the data for devices with VIRTIO_F_IOMMU_PLATFORM set. Signed-off-by: Will Deacon [ Paul: pick from the Android tree. Rebase to the upstream ] Signed-off-by: Ying-Chun Liu (PaulLiu) Cc: Bin Meng Link: https://android.googlesource.com/platform/external/u-boot/+/f73258a4bfe968c5f935db45f2ec5cc0104ee796 Reviewed-by: Simon Glass --- drivers/virtio/virtio_ring.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 5aeb13fd59..1bd19add75 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -47,6 +47,10 @@ static unsigned int virtqueue_attach_desc(struct virtqueue *vq, unsigned int i, return desc_shadow->next; } +static void virtqueue_detach_desc(struct virtqueue *vq, unsigned int idx) +{ +} + int virtqueue_add(struct virtqueue *vq, struct virtio_sg *sgs[], unsigned int out_sgs, unsigned int in_sgs) { @@ -165,10 +169,12 @@ static void detach_buf(struct virtqueue *vq, unsigned int head) i = head; while (vq->vring_desc_shadow[i].flags & VRING_DESC_F_NEXT) { + virtqueue_detach_desc(vq, i); i = vq->vring_desc_shadow[i].next; vq->num_free++; } + virtqueue_detach_desc(vq, i); vq->vring_desc_shadow[i].next = vq->free_head; vq->free_head = head;