From nobody Sun Sep 14 22:12:04 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13D4DC32793 for ; Wed, 18 Jan 2023 16:46:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230092AbjARQqI (ORCPT ); Wed, 18 Jan 2023 11:46:08 -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: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=C3=A9rez Acked-by: Jason Wang Tested-by: Lei Yang --- 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 =3D &vdpasim->vqs[idx]; + uint16_t last_avail_idx =3D vq->vring.last_avail_idx; =20 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); =20 + vq->vring.last_avail_idx =3D last_avail_idx; vq->vring.notify =3D vdpasim_vq_notify; } =20 --=20 2.31.1