From patchwork Wed Sep 16 03:48:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boqun Feng X-Patchwork-Id: 11778887 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4C48E139F for ; Wed, 16 Sep 2020 03:51:29 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1C0AE21655 for ; Wed, 16 Sep 2020 03:51:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="K/wUgl4j"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UBmUL5im" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C0AE21655 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RCJl0sk8WueYiZ9erv+hOuos5nV4rwA4UmCSjYXDDLw=; b=K/wUgl4j9PjBYgMzdMoQ94oaG jlmK6LnryrHzJvD0SFS8tfSyBxgluj7hLfKh+vJsB+FbRtnxTeRKftfababdDdGKb4Wb8prtPAezF esfkd9FeSLBJIdWi98pHyf200qupX9J4hcPu/XfnHK35Lnk4Jb0dY0d5jg3BuOlv4C3WQ4cMmrkCe BT0qwbLBE+HTrUNB3ncK8ixOLXmddkMzbfd8ThEKBU0VX11BZv2dNdhAnDyfzOJ2lRmWkNUXRmnah wtLtOYY65ob22RMUTxz8zqm2a4wIpxNUrpRkJannitqywX6rwrN63PWWqzcS4vMbjruQh52BIy3dD a4w/PrZpA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIOS3-0001HJ-3F; Wed, 16 Sep 2020 03:49:47 +0000 Received: from mail-qv1-xf44.google.com ([2607:f8b0:4864:20::f44]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIOR2-0000rs-N7 for linux-arm-kernel@lists.infradead.org; Wed, 16 Sep 2020 03:48:45 +0000 Received: by mail-qv1-xf44.google.com with SMTP id db4so2870962qvb.4 for ; Tue, 15 Sep 2020 20:48:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IPzYc5oOvMVdMHVpg+qxDCWW0PFGNi+WRPFIeIhdQ+4=; b=UBmUL5imT2j/cAef5pU2ubcootYalanp00Q0SOtR0X1Mfwyx/vG8QDzJ4eJixQwFH9 Jw8PfJ9WABmZt/3E4kyhm5eqlc2U4XMDczru8aSqgWLzNIxXY8fhxi4MT3JsQYC13yJe dQ04rZcX1+sdntILqxBpJrd3X3MRzAaSGbyRCDY09IjGS82Rv0X/WAa///spAWDgtVXT Ww0gIASu1wMqkbVhh9C7wu5FdxXGq5ByKaM++yx6X0blwyr3r/Q0/ZkI6aA4nBfpQq7V w7JoNxYdw5pGoT7JvRMV4VPzveKBft5Ej8Ck2+wI7hpF+0tE8NdbDEO0z/6UKziiw7go nVLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IPzYc5oOvMVdMHVpg+qxDCWW0PFGNi+WRPFIeIhdQ+4=; b=rz4xOl3wVDJwDasLG77Q+QRYupiAZeKLzbHTe5UixgwTRk7KvN5Wqxc8cJt/deAYX5 VXEJB3V0vGHzjfCEjm9SrvPffetdzSege+VtGhNFE19C6m8fNBFddcRFd7VyBeQBc9qJ wVJqEYzwbd6cSXnJP6VpgIrpbIPPRvOCqkXNIgvxAwJQXs2bJ80TVRGbDnZ+IWJ945f7 nSOq1x1H9rxqygeSZiO2SkAOYMUDdZ3f49aVc1rIkPZbLm9PBppCPpn+1V3AtFZBVS4K 3+CAGy3CVmhAldhuNu85zFClvHStz471ibC4FkT7jhMOcx6QHq8hw1RF9iWf39pTfkpx YVMQ== X-Gm-Message-State: AOAM533iaBDT/ht7w9ip9kH/K9cvrNyR4UtRIyuJW4c9dj/YlV4IFLhO 3Alt/PX/bNdL3VkgeiTA2fM= X-Google-Smtp-Source: ABdhPJxw67/g8JIwHipwsztQj6OaLWAJc9TPPhurLPhDJ/oaP1keV/t4sSDY07GQIzhJunNP79tamQ== X-Received: by 2002:ad4:4b34:: with SMTP id s20mr5039311qvw.51.1600228123063; Tue, 15 Sep 2020 20:48:43 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id s10sm97289qkg.61.2020.09.15.20.48.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2020 20:48:42 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailauth.nyi.internal (Postfix) with ESMTP id B6B6527C0054; Tue, 15 Sep 2020 23:48:41 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 15 Sep 2020 23:48:41 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrtddugdeikecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenog fuohhrthgvugftvggtihhpvdculdegtddmnecujfgurhephffvufffkffojghfggfgsedt keertdertddtnecuhfhrohhmpeeuohhquhhnucfhvghnghcuoegsohhquhhnrdhfvghngh esghhmrghilhdrtghomheqnecuggftrfgrthhtvghrnhephedvveetfefgiedutedtfeev vddvleekjeeuffffleeguefhhfejteekieeuueelnecukfhppeehvddrudehhedrudduud drjedunecuvehluhhsthgvrhfuihiivgepjeenucfrrghrrghmpehmrghilhhfrhhomhep sghoqhhunhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqieelvdeghedtie egqddujeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeepghhmrghilhdrtghomhesfhhi gihmvgdrnhgrmhgv X-ME-Proxy: Received: from localhost (unknown [52.155.111.71]) by mail.messagingengine.com (Postfix) with ESMTPA id 16516328005E; Tue, 15 Sep 2020 23:48:41 -0400 (EDT) From: Boqun Feng To: linux-hyperv@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-scsi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 10/11] Driver: hv: util: Use VMBUS_RING_SIZE() for ringbuffer sizes Date: Wed, 16 Sep 2020 11:48:16 +0800 Message-Id: <20200916034817.30282-11-boqun.feng@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200916034817.30282-1-boqun.feng@gmail.com> References: <20200916034817.30282-1-boqun.feng@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200915_234844_831791_F3A96C95 X-CRM114-Status: GOOD ( 16.09 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:f44 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [boqun.feng[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, maz@kernel.org, Wei Liu , Dmitry Torokhov , Stephen Hemminger , arnd@arndb.de, "Martin K. Petersen" , ardb@kernel.org, will@kernel.org, Haiyang Zhang , Jiri Kosina , Boqun Feng , Michael Kelley , Benjamin Tissoires , catalin.marinas@arm.com, Jakub Kicinski , "K. Y. Srinivasan" , "James E.J. Bottomley" , "David S. Miller" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org For a Hyper-V vmbus, the size of the ringbuffer has two requirements: 1) it has to take one PAGE_SIZE for the header 2) it has to be PAGE_SIZE aligned so that double-mapping can work VMBUS_RING_SIZE() could calculate a correct ringbuffer size which fulfills both requirements, therefore use it to make sure vmbus work when PAGE_SIZE != HV_HYP_PAGE_SIZE (4K). Note that since the argument for VMBUS_RING_SIZE() is the size of payload (data part), so it will be minus 4k (the size of header when PAGE_SIZE = 4k) than the original value to keep the ringbuffer total size unchanged when PAGE_SIZE = 4k. Signed-off-by: Boqun Feng Cc: Michael Kelley Reviewed-by: Michael Kelley --- Michael, I drop your Reviewed-by tag because of the page align issue. Could you review this updated version? Thanks! Regards, Boqun drivers/hv/hv_util.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c index a4e8d96513c2..05566ecdbe4b 100644 --- a/drivers/hv/hv_util.c +++ b/drivers/hv/hv_util.c @@ -500,6 +500,9 @@ static void heartbeat_onchannelcallback(void *context) } } +#define HV_UTIL_RING_SEND_SIZE VMBUS_RING_SIZE(3 * HV_HYP_PAGE_SIZE) +#define HV_UTIL_RING_RECV_SIZE VMBUS_RING_SIZE(3 * HV_HYP_PAGE_SIZE) + static int util_probe(struct hv_device *dev, const struct hv_vmbus_device_id *dev_id) { @@ -530,8 +533,8 @@ static int util_probe(struct hv_device *dev, hv_set_drvdata(dev, srv); - ret = vmbus_open(dev->channel, 4 * HV_HYP_PAGE_SIZE, - 4 * HV_HYP_PAGE_SIZE, NULL, 0, srv->util_cb, + ret = vmbus_open(dev->channel, HV_UTIL_RING_SEND_SIZE, + HV_UTIL_RING_RECV_SIZE, NULL, 0, srv->util_cb, dev->channel); if (ret) goto error; @@ -590,8 +593,8 @@ static int util_resume(struct hv_device *dev) return ret; } - ret = vmbus_open(dev->channel, 4 * HV_HYP_PAGE_SIZE, - 4 * HV_HYP_PAGE_SIZE, NULL, 0, srv->util_cb, + ret = vmbus_open(dev->channel, HV_UTIL_RING_SEND_SIZE, + HV_UTIL_RING_RECV_SIZE, NULL, 0, srv->util_cb, dev->channel); return ret; }