Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp6791869rwb; Wed, 18 Jan 2023 09:23:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXv0H+jKsun7ZjkpWQxK2+6kiRMdTcUYc47sMxohAch5ozzoIUap6Dmqwmy4BdPoKtMME0pj X-Received: by 2002:a17:906:60d0:b0:877:612e:516e with SMTP id f16-20020a17090660d000b00877612e516emr5154321ejk.61.1674062570972; Wed, 18 Jan 2023 09:22:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674062570; cv=none; d=google.com; s=arc-20160816; b=iVRbzAKb8VqQduh4ZynhWsjmzbZ25ibucXslVoK25DuUwpemm83Gq039bLr3I9kw7F deGPkqIKTvLWpJt8lyt9CHB0tz24lJFbStnQDKCWVtfxKGksypegHVE2aYsTT8Sp0biL 5rhiLw1GMQe4CIJ1+Obgk/s5t2zA6e/dAdjTOsLEFYWP+4DRIsVgGMRfldgHCQ2HNty5 q62h75gDFx/VSdQ8kZqumUVlww75OeJ75O1I+Vf66pqamArjTB4t7ErCMEzC7oze0ZSn MBPhOuocnAzJgqIlgVpd7Rlaiys2ERAlwz9aTAAkzF2Qkis4Z9je4E13n1U2fheaM9xd jasg== 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=fY7ZFKCSeA1/hO616eCT/ffy6ZcVRsbG6pt4HMxlg40=; b=iNoRemITcpVrKijJzTWaURMxu/TD85Nt/ZBlHVqyWwLSvIpPwgQ5WzhnVew5cEBXrA T0AbKxLruINgcwMyHFScukZDq9IEFWt+34Op34lURJtIp1IPerxF/UX+4u877j7KMEVo vs3zsisVuUSKnh8MhNJCU0/ialwL+klJYQM8tWeHBxC/3n0sO7pbyoFEFtBF817GI4n7 FKIXbqU18vuYq+2YY1yKT67N3V5jimeGsS/R4GcrWAZxSkz8hXrsCfoJXvmfZm7oRQXy mnUDgniDobYGqmFiBpNd4GY9VKdewv6QidQlfsjS0BcytdOFZ56xCUuwCunoufeBGJmk E8SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=L8o2q5Pt; 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 nc9-20020a1709071c0900b0086d6cc19f9bsi17576951ejc.166.2023.01.18.09.22.39; Wed, 18 Jan 2023 09:22:50 -0800 (PST) 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=L8o2q5Pt; 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 S230062AbjARQqH (ORCPT + 45 others); Wed, 18 Jan 2023 11:46:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229614AbjARQpg (ORCPT ); Wed, 18 Jan 2023 11:45:36 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AFC358661 for ; Wed, 18 Jan 2023 08:44:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674060254; 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: in-reply-to:in-reply-to:references:references; bh=fY7ZFKCSeA1/hO616eCT/ffy6ZcVRsbG6pt4HMxlg40=; b=L8o2q5PtRBhRqyTubSx1OHweuwc5hXIBUqsGUHU2TnVHC8+aNeNkqAS4ICU7WDD/ZwTx1U YIzukUvWq2HGsqREWSv7Mb7Du1k4GL4RuaWVReVA7k5rImSuQy/lB456rurd11fBE/gD+q +/87dZp3FoCRW5IuRvL/XYeoLHQznmw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-211-CsVoZYk3O1W7FhPQcrc4nQ-1; Wed, 18 Jan 2023 11:44:08 -0500 X-MC-Unique: CsVoZYk3O1W7FhPQcrc4nQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2287B1871DA4; Wed, 18 Jan 2023 16:44:06 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.141]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7DC2140EBF6; Wed, 18 Jan 2023 16:44:03 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: mst@redhat.com Cc: leiyang@redhat.com, Laurent Vivier , sgarzare@redhat.com, jasowang@redhat.com, Zhu Lingshan , virtualization@lists.linux-foundation.org, si-wei.liu@oracle.com, linux-kernel@vger.kernel.org, lulu@redhat.com, Gautam Dawar , alvaro.karsz@solid-run.com Subject: [PATCH 1/2] vdpa_sim: not reset state in vdpasim_queue_ready Date: Wed, 18 Jan 2023 17:43:58 +0100 Message-Id: <20230118164359.1523760-2-eperezma@redhat.com> In-Reply-To: <20230118164359.1523760-1-eperezma@redhat.com> References: <20230118164359.1523760-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham 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 vdpasim_queue_ready calls vringh_init_iotlb, which resets split indexes. But it can be called after setting a ring base with vdpasim_set_vq_state. Fix it by stashing them. They're still resetted in vdpasim_vq_reset. This was discovered and tested live migrating the vdpa_sim_net device. Fixes: 2c53d0f64c06 ("vdpasim: vDPA device simulator") Signed-off-by: Eugenio PĂ©rez --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index cb88891b44a8..8839232a3fcb 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -66,6 +66,7 @@ static void vdpasim_vq_notify(struct vringh *vring) static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx) { struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx]; + uint16_t last_avail_idx = vq->vring.last_avail_idx; vringh_init_iotlb(&vq->vring, vdpasim->features, vq->num, false, (struct vring_desc *)(uintptr_t)vq->desc_addr, @@ -74,6 +75,7 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx) (struct vring_used *) (uintptr_t)vq->device_addr); + vq->vring.last_avail_idx = last_avail_idx; vq->vring.notify = vdpasim_vq_notify; } -- 2.31.1