From nobody Sun Dec 14 20:13:59 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE08A3C2C; Sat, 30 Mar 2024 08:52:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711788731; cv=none; b=OIsy2/5zncrPDDDv1SmbSfoJZbQrxMXwLvs279O35EZFVQCH7ye/9Swsc0vGkEk/zjSCRdZvVBFzJSnUMY0qckVwdUyjmvFKJCcJ6m2OOj0W00sjnQQ4bi/gTpL2mQZGSH9+Z/STTqtjRTwTxQHrVGCKnlizHx6SWebU/NkjkIs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711788731; c=relaxed/simple; bh=JvItBV8S7Y31HMTBenjNqg15k1PnGv+HzKdN7fwkC+Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=TBa0ltExKXXF1Ou2+D77LPWx7mwpku8pLAIMt5e2dh4rsvorH1htnZfl1Uuag6OpFrRHYTBRXf24QnhNLXf+xpmsUd7jcDnI9khZ/NQwSaOU7E9EH28W1z8+F/QcHI6p7ivB+kCT8FNN6fVUFNIwg/qEOTTOwfdiTj6bsmUjOAA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=iJIgd8nj; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="iJIgd8nj" Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 40B5520E7039; Sat, 30 Mar 2024 01:52:08 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 40B5520E7039 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1711788728; bh=BtKE7O5OWVM7SyPdRoHlAAnjh2otvkVJidlO3O/WDfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iJIgd8njauEFfrqab1aHlcM8q6HjkukZ6SmfRUHRtttswzVuFTjGIJAFAlHb9vzeB pz9jaClMEtTXns1dXkYp3ODhFJufdDI47sAKnRvsSbiEX1W2EGW2dY0fYlNVTQ/4vz X/9mWe/yPSL2QgYHC7cSJkvTw+6UH74KqYsLVRiA= From: Saurabh Sengar To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org Cc: longli@microsoft.com, ssengar@microsoft.com Subject: [PATCH v3 1/7] Drivers: hv: vmbus: Add utility function for querying ring size Date: Sat, 30 Mar 2024 01:51:57 -0700 Message-Id: <1711788723-8593-2-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1711788723-8593-1-git-send-email-ssengar@linux.microsoft.com> References: <1711788723-8593-1-git-send-email-ssengar@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a function to query for the preferred ring buffer size of VMBus device. This will allow the drivers (eg. UIO) to allocate the most optimized ring buffer size for devices. Signed-off-by: Saurabh Sengar Reviewed-by: Long Li --- [V2] - Added more details in commit message. - Added comments for preferred ring sizes and there values. - Added reviewed-by from Long Li. drivers/hv/channel_mgmt.c | 15 ++++++++++++--- drivers/hv/hyperv_vmbus.h | 5 +++++ include/linux/hyperv.h | 2 ++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index 2f4d09ce027a..3c6011a48dab 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -120,7 +120,9 @@ const struct vmbus_device vmbus_devs[] =3D { }, =20 /* File copy */ - { .dev_type =3D HV_FCOPY, + /* fcopy always uses 16KB ring buffer size and is working well for last m= any years */ + { .pref_ring_size =3D 0x4000, + .dev_type =3D HV_FCOPY, HV_FCOPY_GUID, .perf_device =3D false, .allowed_in_isolated =3D false, @@ -140,12 +142,19 @@ const struct vmbus_device vmbus_devs[] =3D { .allowed_in_isolated =3D false, }, =20 - /* Unknown GUID */ - { .dev_type =3D HV_UNKNOWN, + /* + * Unknown GUID + * 64 KB ring buffer + 4 KB header should be sufficient size for any Hype= r-V device apart + * from HV_NIC and HV_SCSI. This case avoid the fallback for unknown devi= ces to allocate + * much bigger (2 MB) of ring size. + */ + { .pref_ring_size =3D 0x11000, + .dev_type =3D HV_UNKNOWN, .perf_device =3D false, .allowed_in_isolated =3D false, }, }; +EXPORT_SYMBOL_GPL(vmbus_devs); =20 static const struct { guid_t guid; diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h index f6b1e710f805..76ac5185a01a 100644 --- a/drivers/hv/hyperv_vmbus.h +++ b/drivers/hv/hyperv_vmbus.h @@ -417,6 +417,11 @@ static inline bool hv_is_perf_channel(struct vmbus_cha= nnel *channel) return vmbus_devs[channel->device_id].perf_device; } =20 +static inline size_t hv_dev_ring_size(struct vmbus_channel *channel) +{ + return vmbus_devs[channel->device_id].pref_ring_size; +} + static inline bool hv_is_allocated_cpu(unsigned int cpu) { struct vmbus_channel *channel, *sc; diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 6ef0557b4bff..7de9f90d3f95 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -820,6 +820,8 @@ struct vmbus_requestor { #define VMBUS_RQST_RESET (U64_MAX - 3) =20 struct vmbus_device { + /* preferred ring buffer size in KB, 0 means no preferred size for this d= evice */ + size_t pref_ring_size; u16 dev_type; guid_t guid; bool perf_device; --=20 2.34.1