Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13624655pxu; Sun, 3 Jan 2021 23:01:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJWvGfsQUYFAFmsQHNmnmqne2HqhcVuqlfWIHw6WKggZ9jh/AliDwOW+5MoEMGUD/Pe9UF X-Received: by 2002:aa7:c547:: with SMTP id s7mr16755747edr.240.1609743702198; Sun, 03 Jan 2021 23:01:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609743702; cv=none; d=google.com; s=arc-20160816; b=S9Ao3Hg039zJhUO3+IY7GFdPCtDxQvZt3DB6dd5uP5NbkmBB3zaO7rlak2OLWt6dbd PCl4u+s2S3twWmpRZp/m7be9ZTnTa4poQu94Txl5YM8pACFLgloWq44AQmMlbSZotlED Orna3NAMClwnASZ1tx0uFi13RUeJDO63PmC3gfHWrnUqfGy8oq1X4mhLOI6o7D3q/6KA zFiCafeQWKBdhMwRnflAAQLs5fbAa0sW1RqLHgv9N9rI6eFm1vF00awtn1kYhPtC0KSn Qc50pgLio/5+pPDTF3papOX3NRDWTOqYQQkuG5k6NBPLfY+voZIKMaf6cVjBe5uHbiEl EdxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=J7GCEgOM0YP2MLYJ3+IGPCRjYuPqLGPgVRLx0Cas//4=; b=Tv+wnMpLDsd4xqfdSVrqaJK5gcNWhFamv/T+zGJM75z+TbRtO5j2CthQ0XubXZvIV6 UIImG8lnp9+s4rTRknYJvvS7MSDCKVRVyny0OQ9T725VPb6iFeUWbkZgMl0tIsXJF2Dz v220gsreET1cVRpliGcg9oYOUOsI3vLJXMZd1w8GILD7lZZaLV0sN7d9F8GygxbPQOoL moSIxvs2i3xTzG9phJEaPhaRAiBrpgBJNpwqOpZmNc6VGpUgRU90z5ZqHS2W6bzMd2I7 T/fmfZStAh1p0ba7MPurpHDnjSYT/y7a8GWQ0zjhXqj1UBlZHnWyjnXXKB+nFoqqGyMo eRaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gdDWYRLT; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m14si28656912ejr.242.2021.01.03.23.01.19; Sun, 03 Jan 2021 23:01:42 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=gdDWYRLT; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728216AbhADG5U (ORCPT + 99 others); Mon, 4 Jan 2021 01:57:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:45940 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728180AbhADG5T (ORCPT ); Mon, 4 Jan 2021 01:57:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609743353; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J7GCEgOM0YP2MLYJ3+IGPCRjYuPqLGPgVRLx0Cas//4=; b=gdDWYRLTKF3D5v4flE+QmcMCYItwUSCbUnme6fVGoCxG/nvq+QtvNHuR6cu8U6xradtFLW thvMpofp9OZNU/nrbvgW01k6zq+esFBzThCv36koHGLLDBh8hIMJAVcKvib0Q5eR8O17Cb 2kPBIHzexUA6OSlR/RIu2y3iFGh1/hY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-570-px7fFRkTMzOjEokYxKouww-1; Mon, 04 Jan 2021 01:55:51 -0500 X-MC-Unique: px7fFRkTMzOjEokYxKouww-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D2460800D62; Mon, 4 Jan 2021 06:55:50 +0000 (UTC) Received: from jason-ThinkPad-X1-Carbon-6th.redhat.com (ovpn-13-91.pek2.redhat.com [10.72.13.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 312AB100239A; Mon, 4 Jan 2021 06:55:44 +0000 (UTC) From: Jason Wang To: mst@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Cc: shahafs@mellanox.com, lulu@redhat.com, sgarzare@redhat.com, rdunlap@infradead.org, Jason Wang Subject: [PATCH V3 10/19] virtio-pci-modern: introduce vp_modern_queue_address() Date: Mon, 4 Jan 2021 14:54:54 +0800 Message-Id: <20210104065503.199631-11-jasowang@redhat.com> In-Reply-To: <20210104065503.199631-1-jasowang@redhat.com> References: <20210104065503.199631-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch introduce a helper to set virtqueue address for modern address. Signed-off-by: Jason Wang --- drivers/virtio/virtio_pci_modern.c | 33 ++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c index 05cd409c0731..05b21e18f46c 100644 --- a/drivers/virtio/virtio_pci_modern.c +++ b/drivers/virtio/virtio_pci_modern.c @@ -210,6 +210,30 @@ static u16 vp_modern_queue_vector(struct virtio_pci_modern_device *mdev, return vp_ioread16(&cfg->queue_msix_vector); } +/* + * vp_modern_queue_address - set the virtqueue address + * @mdev: the modern virtio-pci device + * @index: the queue index + * @desc_addr: address of the descriptor area + * @driver_addr: address of the driver area + * @device_addr: address of the device area + */ +static void vp_modern_queue_address(struct virtio_pci_modern_device *mdev, + u16 index, u64 desc_addr, u64 driver_addr, + u64 device_addr) +{ + struct virtio_pci_common_cfg __iomem *cfg = mdev->common; + + vp_iowrite16(index, &cfg->queue_select); + + vp_iowrite64_twopart(desc_addr, &cfg->queue_desc_lo, + &cfg->queue_desc_hi); + vp_iowrite64_twopart(driver_addr, &cfg->queue_avail_lo, + &cfg->queue_avail_hi); + vp_iowrite64_twopart(device_addr, &cfg->queue_used_lo, + &cfg->queue_used_hi); +} + /* virtio config->finalize_features() implementation */ static int vp_finalize_features(struct virtio_device *vdev) { @@ -459,12 +483,9 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev, /* activate the queue */ vp_iowrite16(virtqueue_get_vring_size(vq), &cfg->queue_size); - vp_iowrite64_twopart(virtqueue_get_desc_addr(vq), - &cfg->queue_desc_lo, &cfg->queue_desc_hi); - vp_iowrite64_twopart(virtqueue_get_avail_addr(vq), - &cfg->queue_avail_lo, &cfg->queue_avail_hi); - vp_iowrite64_twopart(virtqueue_get_used_addr(vq), - &cfg->queue_used_lo, &cfg->queue_used_hi); + vp_modern_queue_address(mdev, index, virtqueue_get_desc_addr(vq), + virtqueue_get_avail_addr(vq), + virtqueue_get_used_addr(vq)); if (mdev->notify_base) { /* offset should not wrap */ -- 2.25.1