Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13625650pxu; Sun, 3 Jan 2021 23:03:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyBGLjS5ypWT/PrFjmyiu004N2P2S76fdkqy0AooOcGO8q7dU2ogtd0ngjeGe+0XJ5q0Bzz X-Received: by 2002:a17:906:4c55:: with SMTP id d21mr65886779ejw.116.1609743795024; Sun, 03 Jan 2021 23:03:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609743795; cv=none; d=google.com; s=arc-20160816; b=y1KjS9TbqEXcvDCFr/xfiWSbS35F0XBv35eYEnL5d6603w4zM/w0Iqr3258rej/Ojv 8D3j+hcRswl1T1BvaEA7B207TYFGMKB28zcUXIjly5hXuwOmpUvri+OTtUq66KW4iJW3 txkNVfe/BzZG5nYPlMFp9dS+gMB0VRJzCiImkQDqpbkUfNvR1OwpOJwBq9zJnP02y9kB jiGvYqr0Mk3G03hdWu1sXKPiRdAvAQhRlmlXc7/VpS2CRX2juwL1pBvXaXe4/+nsGsgn e56HlH4kO8xghK4iCZij4Qhj7wWggCZuaXza4QcaN4a44NrQ2mJqIEMO3DmMka8Ubo5l W/qA== 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=beqiSug2CHYTN1W6nggpEpwUBNclSVEckxreRjbzJ6U=; b=XmqIkp2O/4MlGFzf2+hTRguNG9onrkk+GTvA9u6Gqo07rhyBb3rOt2xnHI2WwYz/5y dK6GCWt3eYor1gbb6QIT0lbjsQXinYheOZ6iTTQh9RhySSSoxB8cTuGmELvY76c5Im5r yROyJDOp+4Gk4L4Ayjy8tAn9ihDFcfkmce6hsDo35t1b4pXgxMgwcu5qKWMqZngZqqw4 9bU3sCxVAYkPcSA55DsYhNb3DOcNwMTj4TIzBpIFEJR2wbe7ej7T+ynmxyzr19VRg33n OtI9yLx4g6uBTBfzHI7vmkUCOM+H3I8OTrkdBu+JFah02umtkZtwkPJURC+HHZZpjhKG P6eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GHpFDbWy; 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 o27si30887684edi.277.2021.01.03.23.02.52; Sun, 03 Jan 2021 23:03:15 -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=GHpFDbWy; 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 S1728202AbhADG5O (ORCPT + 99 others); Mon, 4 Jan 2021 01:57:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56707 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728180AbhADG5O (ORCPT ); Mon, 4 Jan 2021 01:57:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609743347; 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=beqiSug2CHYTN1W6nggpEpwUBNclSVEckxreRjbzJ6U=; b=GHpFDbWykpsDHOTk+mFUVpQ02szkPu0ELWnj+DSjiFSqfbWXGHmwiHPfhswNcWpaerJg5h /UfiM6J1W/4QAano93CXkP0AhP6ZnDqcBoaTnkg65I2HsDpYuAflZl5qiNnfzTezQ2XNfF /RkAmY/Bir9UgbJz/0g8SLrcFNNeBFo= 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-273-BaJ9tILFPvyJtYXPx6B2PA-1; Mon, 04 Jan 2021 01:55:45 -0500 X-MC-Unique: BaJ9tILFPvyJtYXPx6B2PA-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 7C35859; Mon, 4 Jan 2021 06:55:44 +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 CED121002388; Mon, 4 Jan 2021 06:55:41 +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 09/19] virtio-pci-modern: introduce vp_modern_set_queue_vector() Date: Mon, 4 Jan 2021 14:54:53 +0800 Message-Id: <20210104065503.199631-10-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 introduces a helper to set virtqueue MSI vector. Signed-off-by: Jason Wang --- drivers/virtio/virtio_pci_modern.c | 35 ++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c index a128e5814045..05cd409c0731 100644 --- a/drivers/virtio/virtio_pci_modern.c +++ b/drivers/virtio/virtio_pci_modern.c @@ -191,6 +191,25 @@ static void vp_modern_set_features(struct virtio_pci_modern_device *mdev, vp_iowrite32(features >> 32, &cfg->guest_feature); } +/* + * vp_modern_queue_vector - set the MSIX vector for a specific virtqueue + * @mdev: the modern virtio-pci device + * @index: queue index + * @vector: the config vector + * + * Returns the config vector read from the device + */ +static u16 vp_modern_queue_vector(struct virtio_pci_modern_device *mdev, + u16 index, u16 vector) +{ + struct virtio_pci_common_cfg __iomem *cfg = mdev->common; + + vp_iowrite16(index, &cfg->queue_select); + vp_iowrite16(vector, &cfg->queue_msix_vector); + /* Flush the write out to device */ + return vp_ioread16(&cfg->queue_msix_vector); +} + /* virtio config->finalize_features() implementation */ static int vp_finalize_features(struct virtio_device *vdev) { @@ -474,8 +493,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev, } if (msix_vec != VIRTIO_MSI_NO_VECTOR) { - vp_iowrite16(msix_vec, &cfg->queue_msix_vector); - msix_vec = vp_ioread16(&cfg->queue_msix_vector); + msix_vec = vp_modern_queue_vector(mdev, index, msix_vec); if (msix_vec == VIRTIO_MSI_NO_VECTOR) { err = -EBUSY; goto err_assign_vector; @@ -522,17 +540,10 @@ static void del_vq(struct virtio_pci_vq_info *info) struct virtqueue *vq = info->vq; struct virtio_pci_device *vp_dev = to_vp_device(vq->vdev); struct virtio_pci_modern_device *mdev = &vp_dev->mdev; - struct virtio_pci_common_cfg __iomem *cfg = mdev->common; - - vp_iowrite16(vq->index, &cfg->queue_select); - - if (vp_dev->msix_enabled) { - vp_iowrite16(VIRTIO_MSI_NO_VECTOR, - &cfg->queue_msix_vector); - /* Flush the write out to device */ - vp_ioread16(&cfg->queue_msix_vector); - } + if (vp_dev->msix_enabled) + vp_modern_queue_vector(mdev, vq->index, + VIRTIO_MSI_NO_VECTOR); if (!mdev->notify_base) pci_iounmap(mdev->pci_dev, (void __force __iomem *)vq->priv); -- 2.25.1