Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2878423rdb; Mon, 12 Feb 2024 22:54:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVTImnQ9rSO0H96t0cGp/RgPfLpf5aeRNZR2TRRhhphAVQtgMgRur8ljORZgHqMdiRKAwEYuliWgZzq6bilTGSBWGmVgDqGneYHUF7lQA== X-Google-Smtp-Source: AGHT+IG71whYodimu5L+f0jxQ2DQToPSKJRbPP1uXUBLlFsgRp0zqUvb2SI9xaoXqNKy6Tr+G9jC X-Received: by 2002:a17:902:da92:b0:1da:1ea9:9a41 with SMTP id j18-20020a170902da9200b001da1ea99a41mr2803706plx.12.1707807283202; Mon, 12 Feb 2024 22:54:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707807283; cv=pass; d=google.com; s=arc-20160816; b=e2ucoKruNnEthchRXFuq82Mz6AW6In1ixRjnzDWF8CHuJoikQvzpene5d4GJ1v2xPG kyjUyM8cQa5vLtyDDxulV8ToXDR3+mcoVsJ3ZN2thQcJCnSNhXwaGzNP9oNMjsrToG1o DdvFmSL6BFQaj5UKp90kD7CK2/XOmMHBc3N1yxjR1UiraXC9GdIdblKmoWzzpMkAsRqD Q+QYtubWaRdoaw8ipiNldhYzAYwTkYDahtPBnSCSCxu8g3Axexn5m7n5PQt1Mom4mLoW PzMyE2jSmyyvnsU/Hdof3+y+iwCzBPeqQ3v1AQQKVTDCQVIY8gIb8G0S6BBX4tByj1fV OSng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=yi0iDmjZx+kDYlUtN3z3kOrJiFq9m+7NuBVj2P9/YL8=; fh=lV6/iJH3/NpDtAJdoVScl7hsE0h7NVIGdWUJTBMrRnk=; b=swVkSQNT2qCIFMXOBF2nKtb3uyQFCgdPRJds4032i9lg3U8GYqL0rNVF5/gjCLcZy8 f9rEYABqU9Hnwrb0qXi0C27R3rKRo0Ay6BS1MH3CrctumfrAQazZfrXD9svhazddeTEp +OLrXAh3ejJ//EdgkVqMkk5dh1hWPNJtmRCXjtGL/HWHck31KhODCEE9cK2teA2cJ5lX xEgnH6kYN7nvbdmuRdpzeJh2HssA1YNI4uIpH+fyq6mjXF6WkYt+EpdQdhTKHEnUai6z AyiV+MZz+X4Pfs+whrQVC4rQ1NQmWSLP5Rpjs2zWX4OPCWpB5oYOQEvnlvvtN5HWvjd/ OBHg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DscRVihF; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-63024-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63024-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCXdScjMrcJ1LXVIDPmvYd6BIIFmRfu5pyPI3Q2r6d7kKVbBEWySU/j86EL83kqpJP3mwGpJefM/xHwBla/LQlGyTSePCft6NcMlVBL67g== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b12-20020a170902d30c00b001da237e483bsi1504723plc.67.2024.02.12.22.54.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 22:54:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63024-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DscRVihF; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-63024-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63024-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3721A2877F3 for ; Tue, 13 Feb 2024 06:54:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5D648171AF; Tue, 13 Feb 2024 06:54:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DscRVihF" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9E6B17593; Tue, 13 Feb 2024 06:54:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707807266; cv=none; b=sIpghHjeJ1H5d37cNxkAYGpBKkBwaXpGH0gfex/m5QOLWvjdVioBh+9JatfrFyOyV/D/d2GWHC+L4+7Clr8XCOZz8jlve0QngDC0tFolxB9rymZ5johbHpIdf4CDcSn+JNQ+TG31ukuFb7uGaJq74mb/xpAd8JYXoCFK1EWO05Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707807266; c=relaxed/simple; bh=dg+czpDpRsfS+ywc/VdeVy3c5O4goOqBngd+M7qerq8=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=A37eCqQzvjHVhFBNe8sjydcFrrCdixensYB668wOamoQa+yXTg/l1wg+UuSLHEvU4uo+FH+GzPw4uYAQyW71BenxmLO8XXE4yrOnrG1jQC6HZVfPiy1Qoc5Eh3Jal7/SRvPjS8698UoMwEnzeZh5NFxTHz7EbfDqAM/Cwczbh0s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=DscRVihF; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707807264; x=1739343264; h=message-id:date:mime-version:subject:to:references:from: in-reply-to:content-transfer-encoding; bh=dg+czpDpRsfS+ywc/VdeVy3c5O4goOqBngd+M7qerq8=; b=DscRVihFtoaYkCjVgJ9Qk4HMldLn0UFC3TpEtEWjsypLr0NMR9Rqqd9M KCj3FUAaU9MafFd1EBNKMGRZctJq7mfxQLCnZe1f6QlIQSqjxxYkEGdAW +OJGLOvOtMjeuzfZayCL/D2SUyh1dz20epecEelrnQJVAh89mc1tohEOn qIHYp1gM5Sdh4GchZ4NJaDIbAHcBwN8HYPxl3VRl22iS+lbiOIpgSfprR 80HdKNo0DMgi/GjLSgLlghw9Yj2WlyLohHTTnv98fuLY4EhAgNbKXXuu1 g0AAIYN3D42jcRTPO167y99lcy7lQnCt5ZfgSaPkWs48CiWx0RVbB7sy/ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="1927759" X-IronPort-AV: E=Sophos;i="6.06,156,1705392000"; d="scan'208";a="1927759" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 22:54:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,156,1705392000"; d="scan'208";a="3149430" Received: from maleekmc-mobl.amr.corp.intel.com (HELO [10.209.16.85]) ([10.209.16.85]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 22:54:24 -0800 Message-ID: <12efa165-b4bb-40ae-ac38-deedceba7b27@linux.intel.com> Date: Mon, 12 Feb 2024 22:54:23 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/1] PCI: hv: Fix ring buffer size calculation Content-Language: en-US To: mhklinux@outlook.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org References: <20240213061910.782060-1-mhklinux@outlook.com> From: Kuppuswamy Sathyanarayanan In-Reply-To: <20240213061910.782060-1-mhklinux@outlook.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/12/24 10:19 PM, mhkelley58@gmail.com wrote: > From: Michael Kelley > > For a physical PCI device that is passed through to a Hyper-V guest VM, > current code specifies the VMBus ring buffer size as 4 pages. But this > is an inappropriate dependency, since the amount of ring buffer space > needed is unrelated to PAGE_SIZE. For example, on x86 the ring buffer > size ends up as 16 Kbytes, while on ARM64 with 64 Kbyte pages, the ring > size bloats to 256 Kbytes. The ring buffer for PCI pass-thru devices > is used for only a few messages during device setup and removal, so any > space above a few Kbytes is wasted. > > Fix this by declaring the ring buffer size to be a fixed 16 Kbytes. > Furthermore, use the VMBUS_RING_SIZE() macro so that the ring buffer > header is properly accounted for, and so the size is rounded up to a > page boundary, using the page size for which the kernel is built. While > w/64 Kbyte pages this results in a 64 Kbyte ring buffer header plus a > 64 Kbyte ring buffer, that's the smallest possible with that page size. > It's still 128 Kbytes better than the current code. > > Cc: # 5.15.x > Signed-off-by: Michael Kelley > --- Looks good to me. Reviewed-by: Kuppuswamy Sathyanarayanan > drivers/pci/controller/pci-hyperv.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c > index 1eaffff40b8d..5f22ad38bb98 100644 > --- a/drivers/pci/controller/pci-hyperv.c > +++ b/drivers/pci/controller/pci-hyperv.c > @@ -465,7 +465,7 @@ struct pci_eject_response { > u32 status; > } __packed; > > -static int pci_ring_size = (4 * PAGE_SIZE); > +static int pci_ring_size = VMBUS_RING_SIZE(16 * 1024); > Nit: I think you can use SZ_16K to make it more readable. > /* > * Driver specific state. -- Sathyanarayanan Kuppuswamy Linux Kernel Developer