Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13624866pxu; Sun, 3 Jan 2021 23:02:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzo+WPA92ioxlCAnlw7Y7a4wwB3afU7J/rU7o0yN5QOAabPbu5/sWXvU2KYe9JI3wjYLtVy X-Received: by 2002:a05:6402:229c:: with SMTP id cw28mr69755048edb.285.1609743721999; Sun, 03 Jan 2021 23:02:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609743721; cv=none; d=google.com; s=arc-20160816; b=kmWk6lBKxatxm021JbdoY6s2S5RgNXq3veOYi4ziUGBA0do6z2CTJDSKAKrVArqYDr JFY/HbpzHPWlf5CKVc5Gv/2+Xuh/z9pULaOxJ+GrhqZL1hU+NgMx4z0NTkgVbA0S2d6H K2CE4cMpZfJhH9Da/8CqHSnBcU3sduYVcAw9WY5SCF2iliCpQtwBzfSvfRkk0+ddVJTr b5Yv3gunHDWrBFHzt2qsPo6wCZJ/BVDo6y2VbunwIPVT0aw6tzKQNLnkHSjqz2M0Ml5x NkcGV8udd245mPGPpXjHb2c7P2ezpZ2kXw8T2YRZmZ9B74XzqTVXYSLMa/urAZ5xEnFV Gqyw== 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=Gdm0UB4on1QPgytzzFxIDva39FIn9LEMmAgWsGGDne4=; b=xu7sJYoT70HJ0AVdjyRVmse3XWODTqD91p6Lm5acM+1IWUKlDWohHsF9zdMzqt9A4/ Xs+R/8t2FHlh2VXPoE/CV/jjDI6ZJbFB4qvll+F6bKVnIhPp7358wfqoHd3F6gLyJOAa iDUGTmVhXi4wzzE9kfXedE5x7TZkRA+IxbFCeuk0wGifHlhpQtxeYATFSYU8kjSH2i+M U+1bBmOlWd1BqsKxYgaLRBoDJUu2g1m/n0U7xy1ragnEJDlaoQoNQ+3GuAE1LjRMLomR q3m72wBteWtuO8uQLkBBDM2MlPRSpZoC90jDw02tiId7TQG4bqK3v0UajRimd8j93L/r TD3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GzwxRnC7; 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 y1si30692681eds.331.2021.01.03.23.01.39; Sun, 03 Jan 2021 23:02:01 -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=GzwxRnC7; 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 S1728280AbhADG5g (ORCPT + 99 others); Mon, 4 Jan 2021 01:57:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36249 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728261AbhADG5c (ORCPT ); Mon, 4 Jan 2021 01:57:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609743366; 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=Gdm0UB4on1QPgytzzFxIDva39FIn9LEMmAgWsGGDne4=; b=GzwxRnC7VmKfw9cKX4dApDSYcaY2fsoz5SBrBBKH8iFQTE8zL5Mui1mk2Hq7nnQZPT8XlM XpUrjcqKJwG7BddUqjoque+rZzNbTTCc0w4yjXBHbyPFBWEG57LE2nj/z7DjUm1LxTWlG0 nQg1MzEt5s26mua2+TfqThINKnPh7qs= 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-351-EXJiTV6vOpypAyDm6AO38g-1; Mon, 04 Jan 2021 01:56:04 -0500 X-MC-Unique: EXJiTV6vOpypAyDm6AO38g-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 B1A0A107ACE3; Mon, 4 Jan 2021 06:56:03 +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 110D51002388; Mon, 4 Jan 2021 06:56:00 +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 14/19] virtio-pci-modern: introduce helper to get notification offset Date: Mon, 4 Jan 2021 14:54:58 +0800 Message-Id: <20210104065503.199631-15-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 help to get notification offset of modern device. Signed-off-by: Jason Wang --- drivers/virtio/virtio_pci_modern.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c index bccad1329871..217573f2588d 100644 --- a/drivers/virtio/virtio_pci_modern.c +++ b/drivers/virtio/virtio_pci_modern.c @@ -303,6 +303,21 @@ static u16 vp_modern_get_num_queues(struct virtio_pci_modern_device *mdev) return vp_ioread16(&mdev->common->num_queues); } +/* + * vp_modern_get_queue_notify_off - get notification offset for a virtqueue + * @mdev: the modern virtio-pci device + * @index: the queue index + * + * Returns the notification offset for a virtqueue + */ +static u16 vp_modern_get_queue_notify_off(struct virtio_pci_modern_device *mdev, + u16 index) +{ + vp_iowrite16(index, &mdev->common->queue_select); + + return vp_ioread16(&mdev->common->queue_notify_off); +} + /* virtio config->finalize_features() implementation */ static int vp_finalize_features(struct virtio_device *vdev) { @@ -516,7 +531,6 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev, { struct virtio_pci_modern_device *mdev = &vp_dev->mdev; - struct virtio_pci_common_cfg __iomem *cfg = mdev->common; struct virtqueue *vq; u16 num, off; int err; @@ -524,9 +538,6 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev, if (index >= vp_modern_get_num_queues(mdev)) return ERR_PTR(-ENOENT); - /* Select the queue we're interested in */ - vp_iowrite16(index, &cfg->queue_select); - /* Check if queue is either not available or already active. */ num = vp_modern_get_queue_size(mdev, index); if (!num || vp_modern_get_queue_enable(mdev, index)) @@ -538,7 +549,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev, } /* get offset of notification word for this vq */ - off = vp_ioread16(&cfg->queue_notify_off); + off = vp_modern_get_queue_notify_off(mdev, index); info->msix_vector = msix_vec; -- 2.25.1