From patchwork Wed Aug 5 11:37:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Zhu, Lingshan" X-Patchwork-Id: 11702499 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E3CF514DD for ; Wed, 5 Aug 2020 20:09:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D899322B42 for ; Wed, 5 Aug 2020 20:09:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729681AbgHEUJD (ORCPT ); Wed, 5 Aug 2020 16:09:03 -0400 Received: from mga06.intel.com ([134.134.136.31]:6730 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726392AbgHEQce (ORCPT ); Wed, 5 Aug 2020 12:32:34 -0400 IronPort-SDR: jUYgZT5wOinZiVWNnUH5zLCtcgkqC9zo5HWVa7TwAX9VjTeHOmCpgPxv5oE4ZiN6EnMPqTtoTB l5+hiYhLViSg== X-IronPort-AV: E=McAfee;i="6000,8403,9703"; a="214047223" X-IronPort-AV: E=Sophos;i="5.75,436,1589266800"; d="scan'208";a="214047223" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2020 04:41:48 -0700 IronPort-SDR: voInwl4vfbYWzZUXFHCdXSR5TLohsgoXijCOnbprW6erlSv+R5na1gMwKuobZESQFIQPx/W9hx 4A4Yz0c4RE9w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,436,1589266800"; d="scan'208";a="467437398" Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.240.192.131]) by orsmga005.jf.intel.com with ESMTP; 05 Aug 2020 04:41:45 -0700 From: Zhu Lingshan To: jasowang@redhat.com, mst@redhat.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, kvm@vger.kernel.org, eli@mellanox.com, shahafs@mellanox.com, parav@mellanox.com, Zhu Lingshan Subject: [PATCH 1/2] vDPA: get_vq_irq() should be optional Date: Wed, 5 Aug 2020 19:37:59 +0800 Message-Id: <20200805113759.3591-1-lingshan.zhu@intel.com> X-Mailer: git-send-email 2.18.4 MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org get_vq_irq() should be optional, it's required when we need to setup irq offloading, otherwise it‘s OK to be NULL. Signed-off-by: Zhu Lingshan --- include/linux/vdpa.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index 03aa9f77f192..56c6a03db43b 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -87,7 +87,8 @@ struct vdpa_device { * @vdev: vdpa device * @idx: virtqueue index * Returns the notifcation area - * @get_vq_irq: Get the irq number of a virtqueue + * @get_vq_irq: Get the irq number of a virtqueue (optional, + * but must implemented if require vq irq offloading) * @vdev: vdpa device * @idx: virtqueue index * Returns int: irq number of a virtqueue, From patchwork Wed Aug 5 11:38:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhu, Lingshan" X-Patchwork-Id: 11701953 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A255B14E3 for ; Wed, 5 Aug 2020 16:59:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 95BDD22D3E for ; Wed, 5 Aug 2020 16:59:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728378AbgHEQ72 (ORCPT ); Wed, 5 Aug 2020 12:59:28 -0400 Received: from mga05.intel.com ([192.55.52.43]:36356 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728197AbgHEQ6G (ORCPT ); Wed, 5 Aug 2020 12:58:06 -0400 IronPort-SDR: r0cb1ZQZX6dLlWw2Ga5M2var144iy1E0LleoBlrYPIUvzCXQFT+Gsv6AA51+p2vjBHeYyJBeEh ZhtlEorFyx/A== X-IronPort-AV: E=McAfee;i="6000,8403,9703"; a="237376266" X-IronPort-AV: E=Sophos;i="5.75,436,1589266800"; d="scan'208";a="237376266" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2020 04:42:21 -0700 IronPort-SDR: vNbn1vEX5/bKMuCyBYWNsn2Dbcj1dnl8nyAIPRWOxH/odcQoy7qUJGnkOeSSB0b3GEimUs6M4N QU5DANQ0Ryzg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,436,1589266800"; d="scan'208";a="437142946" Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.240.192.131]) by orsmga004.jf.intel.com with ESMTP; 05 Aug 2020 04:42:18 -0700 From: Zhu Lingshan To: jasowang@redhat.com, mst@redhat.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, kvm@vger.kernel.org, eli@mellanox.com, shahafs@mellanox.com, parav@mellanox.com, Zhu Lingshan Subject: [PATCH 2/2] vhost_vdpa: unified set_vq_irq() and update_vq_irq() Date: Wed, 5 Aug 2020 19:38:32 +0800 Message-Id: <20200805113832.3755-1-lingshan.zhu@intel.com> X-Mailer: git-send-email 2.18.4 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This commit merge vhost_vdpa_update_vq_irq() logics into vhost_vdpa_setup_vq_irq(), so that code are unified. In vhost_vdpa_setup_vq_irq(), added checks for the existence for get_vq_irq(). Signed-off-by: Zhu Lingshan --- drivers/vhost/vdpa.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 26f166a8192e..044e1f54582a 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -122,8 +122,12 @@ static void vhost_vdpa_setup_vq_irq(struct vhost_vdpa *v, u16 qid) struct vdpa_device *vdpa = v->vdpa; int ret, irq; - spin_lock(&vq->call_ctx.ctx_lock); + if (!ops->get_vq_irq) + return; + irq = ops->get_vq_irq(vdpa, qid); + spin_lock(&vq->call_ctx.ctx_lock); + irq_bypass_unregister_producer(&vq->call_ctx.producer); if (!vq->call_ctx.ctx || irq < 0) { spin_unlock(&vq->call_ctx.ctx_lock); return; @@ -144,26 +148,6 @@ static void vhost_vdpa_unsetup_vq_irq(struct vhost_vdpa *v, u16 qid) spin_unlock(&vq->call_ctx.ctx_lock); } -static void vhost_vdpa_update_vq_irq(struct vhost_virtqueue *vq) -{ - spin_lock(&vq->call_ctx.ctx_lock); - /* - * if it has a non-zero irq, means there is a - * previsouly registered irq_bypass_producer, - * we should update it when ctx (its token) - * changes. - */ - if (!vq->call_ctx.producer.irq) { - spin_unlock(&vq->call_ctx.ctx_lock); - return; - } - - irq_bypass_unregister_producer(&vq->call_ctx.producer); - vq->call_ctx.producer.token = vq->call_ctx.ctx; - irq_bypass_register_producer(&vq->call_ctx.producer); - spin_unlock(&vq->call_ctx.ctx_lock); -} - static void vhost_vdpa_reset(struct vhost_vdpa *v) { struct vdpa_device *vdpa = v->vdpa; @@ -452,7 +436,7 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, cb.private = NULL; } ops->set_vq_cb(vdpa, idx, &cb); - vhost_vdpa_update_vq_irq(vq); + vhost_vdpa_setup_vq_irq(v, idx); break; case VHOST_SET_VRING_NUM: