From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web09.8202.1630071928471280384 for ; Fri, 27 Aug 2021 06:45:29 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DNFB/vt3; spf=pass (domain: redhat.com, ip: 216.205.24.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630071927; 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=gPRpy7+ERmJSMpwHfxaaZYFO5cW477DW5kAUp2P/UZ0=; b=DNFB/vt3JbzGV2IXdVfmcxqiAea0x9pO3DPtur2BMGQUr9GG+aX3WcvamyHlpideqQZOKX mRxhNYZSpq+0Til7qADs7OWBQ5v6OhuKRCs7TMHz/eBGijBxZKPlkoD468LH1W0kJriDbj fKt+0SRkf+Uki+i+59kmXnJBjn8Wl5E= 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-67-XX4O-WMaN5G_MeWrkHY-zw-1; Fri, 27 Aug 2021 09:45:26 -0400 X-MC-Unique: XX4O-WMaN5G_MeWrkHY-zw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4EE5F100E421; Fri, 27 Aug 2021 13:45:25 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1C34A60C5F; Fri, 27 Aug 2021 13:45:21 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D9D491800918; Fri, 27 Aug 2021 15:44:59 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jiewen Yao , Gerd Hoffmann , Ard Biesheuvel , Jordan Justen , Philippe Mathieu-Daude Subject: [PATCH v5 5/7] OvmfPkg/VirtioMmioDeviceLib: virtio 1.0: Add default QueueNum Date: Fri, 27 Aug 2021 15:44:57 +0200 Message-Id: <20210827134459.635098-6-kraxel@redhat.com> In-Reply-To: <20210827134459.635098-1-kraxel@redhat.com> References: <20210827134459.635098-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Use QueueNumMax as QueueNum default for drivers which do not explicitly call VIRTIO_DEVICE_PROTOCOL->SetQueueSize(). Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daude --- .../Library/VirtioMmioDeviceLib/VirtioMmioDevice.h | 1 + .../VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h index 0c2f99633c46..5ad951f4154a 100644 --- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h +++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h @@ -30,6 +30,7 @@ typedef struct { UINT32 Signature; UINT32 Version; + UINT16 QueueNum; VIRTIO_DEVICE_PROTOCOL VirtioDevice; PHYSICAL_ADDRESS BaseAddress; } VIRTIO_MMIO_DEVICE; diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c index cb1f9358eabd..436da2a2b497 100644 --- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c +++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c @@ -83,7 +83,11 @@ VirtioMmioSetQueueSize ( Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This); - VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_NUM, QueueSize); + if (Device->Version == VIRTIO_MMIO_DEVICE_VERSION_0_95) { + VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_NUM, QueueSize); + } else { + Device->QueueNum = QueueSize; + } return EFI_SUCCESS; } @@ -171,6 +175,10 @@ VirtioMmioSetQueueSel ( VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_SEL, Sel); + if (Device->Version == VIRTIO_MMIO_DEVICE_VERSION_0_95) { + Device->QueueNum = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_QUEUE_NUM_MAX) & 0xFFFF; + } + return EFI_SUCCESS; } @@ -193,6 +201,8 @@ VirtioMmioSetQueueAddress ( VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_PFN, (UINT32)((UINTN)Ring->Base >> EFI_PAGE_SHIFT)); } else { + VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_NUM, Device->QueueNum); + Address = (UINTN)Ring->Base; VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_DESC_LO, (UINT32)Address); -- 2.31.1