Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2014285iob; Thu, 19 May 2022 22:53:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxX358xuK4q+7w6J1vil5FCosWsSRygFK5FcCoc4XWr6V0aEujYcZI64IDNwFxXFJV+2r0J X-Received: by 2002:a05:6402:4408:b0:427:ab6f:a383 with SMTP id y8-20020a056402440800b00427ab6fa383mr9169524eda.249.1653026022518; Thu, 19 May 2022 22:53:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653026022; cv=none; d=google.com; s=arc-20160816; b=bizJVA5ZN9wYhKGsp1tTQi+3rvnwIbS1KdKzTyUA5A9ffLPAtCHmQG9X9B5+vgtgBR 0UmwDcARVnO68CGi8EPeFLfCjkRngO0+UsLAM4jI5I/Zby42kpBppQsARhAmm9mQU0h/ /mfpfSpWoocjIfjASQnp9oZHH8gXHjUVIV35rqmkIOAth74I9qhtRZvGJ0sw1If96EbX ZTLkXwmSp0oN3B9aN0LqT5pDJcn1t7DOkJHTp81u/AnCMm6EGh910E12nKU0inWtGsWF iVCbVxh0L2HdB/TJQndXkmlmhu0WPFruU39gEDECko8cY4DznqxSpuh1csc/OgPwYxMX gn5w== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=vLDeLvmK1CDBbyiav0ZvmXrDMQAvb2K5oFXxMwO8ya4=; b=zp6KTsifC3Vb+eSCOXId/XO0QhekERBZa+qGR84yVkJM3h+hL0Vz9avUuZls4ahNck E+G330z1Tv+BWUgmoqVjmSit/MnOalqpyZxjQej2Mq2gxJuxsOwVwjaQd2pe8vvDYkyT Iatys6fWS5yc3FPdx72+qkwm6O4OjcUNooUD3f5C0CHCG1N1MmtYhAjjSUJC/E6FZZo7 0BIcEZvlqh7qgVFORaZtvcR58zkwpDXU8gRK3XbgjY64xNe5NNDgC0WfIJZjUPoi9VT6 Ex3bbLxz7d2qPBtMqsmDg888+iJS1IDN42Rke3N7NC5XoZX2bfpNT22Bc99+FN4Ekkf7 DOSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QzI3Yy62; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fu14-20020a170907b00e00b006f3911626bfsi6068559ejc.604.2022.05.19.22.53.16; Thu, 19 May 2022 22:53:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QzI3Yy62; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S238798AbiESPCJ (ORCPT + 99 others); Thu, 19 May 2022 11:02:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240081AbiESPAK (ORCPT ); Thu, 19 May 2022 11:00:10 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2E48DEBA98 for ; Thu, 19 May 2022 07:59:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652972367; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vLDeLvmK1CDBbyiav0ZvmXrDMQAvb2K5oFXxMwO8ya4=; b=QzI3Yy62MBpnKqlvrrWiF9eQUa47thUydE5x5t0JkjnBdF8+cRxvcEL1nNEuWbZC02QFvK OoHBxJtRJ7upl7kLB8pmfQaDnds5vy4kXbTqZOLxPm3HGCkNpaAPBkGuAA+8Q869weqYDD Kh7A5ZE4PX6wBrJCRV5Q5RXq0vVbN/Y= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-661-Q7coxSBeOFSsVPOL9aBFtQ-1; Thu, 19 May 2022 10:59:24 -0400 X-MC-Unique: Q7coxSBeOFSsVPOL9aBFtQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7F881294EDE4; Thu, 19 May 2022 14:59:23 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F566400E89E; Thu, 19 May 2022 14:59:21 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: mst@redhat.com, jasowang@redhat.com Cc: lvivier@redhat.com, netdev@vger.kernel.org, lulu@redhat.com, eli@mellanox.com, sgarzare@redhat.com, parav@nvidia.com, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, lingshan.zhu@intel.com, linux-kernel@vger.kernel.org, gdawar@xilinx.com Subject: [PATCH v2] vdpasim: allow to enable a vq repeatedly Date: Thu, 19 May 2022 16:59:19 +0200 Message-Id: <20220519145919.772896-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Code must be resilient to enable a queue many times. At the moment the queue is resetting so it's definitely not the expected behavior. v2: set vq->ready = 0 at disable. Fixes: 2c53d0f64c06 ("vdpasim: vDPA device simulator") Cc: stable@vger.kernel.org Signed-off-by: Eugenio PĂ©rez --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index ddbe142af09a..881f9864c437 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -353,11 +353,14 @@ static void vdpasim_set_vq_ready(struct vdpa_device *vdpa, u16 idx, bool ready) { struct vdpasim *vdpasim = vdpa_to_sim(vdpa); struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx]; + bool old_ready; spin_lock(&vdpasim->lock); + old_ready = vq->ready; vq->ready = ready; - if (vq->ready) + if (vq->ready && !old_ready) { vdpasim_queue_ready(vdpasim, idx); + } spin_unlock(&vdpasim->lock); } -- 2.27.0