From patchwork Thu Sep 10 14:34:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boqun Feng X-Patchwork-Id: 11767939 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 E8A5C13B1 for ; Thu, 10 Sep 2020 14:36:33 +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 B2E5820720 for ; Thu, 10 Sep 2020 14:36:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="om1jVcJR"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nUxVcG8/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B2E5820720 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=jEgWEwsApH6j6dk9tLcX3DSDAIkqTlHj7sANzXURWN8=; b=om1jVcJR3+tz5XODRUm6iA95z pXQAB/62swAKpTNn4f8vsZP6lCMyuNNP5uLCHZUdDPIG0YMipy0CTcT04nlVBx7x2d5PgFnoMe1nq zMNXHF0fArsRxPsvfLj01lsCwYMJLmQ7Yaa6idFmw6s2sr2r8z2aSZxuVEdBmT3ld5qiyp87LY/LP 8XIQbNqq+y0mnyENEd5/MhMle8Tpf/bOWMUsfsnv9cqSJbfi7ReE5Ry93oRVVVQulp1PZoJ/LPyNx 7jZzHotuM10rcaLwGQAklH1RSH8B56ezFG2lPsjaP4RndQIAX3eA4d9VM5a/VS7TVqjNCscmYeOMy 3f4NR3mEg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGNgU-0000F3-Sb; Thu, 10 Sep 2020 14:36:22 +0000 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGNfa-0008Hw-9B for linux-arm-kernel@lists.infradead.org; Thu, 10 Sep 2020 14:35:27 +0000 Received: by mail-ed1-x541.google.com with SMTP id i1so6573303edv.2 for ; Thu, 10 Sep 2020 07:35:26 -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=8HvRoiCT6Kaqw+ME0No79Ijetq5cFPuTsghNfxraGwU=; b=nUxVcG8/Gc71+4ot2A2Swhq1iHl5I5udIPQA5pErGqnEZcNyUf/HZVQqQqCohsrxzn 5cyDq7J56l7uFC0o2cj7YN1PoGuVFh7yqFbJ7iWrPT347WXmOVmFTwvpUtGLy7JXESll 8/YNkAbKEh22aN2uPfGV656lszd48mEZuuoyIJqvOynJpsKoolic0DdiX1khR5k/09fF xMGnXkMj1Jz7+55GFmHszF/42TLtQO3wg6BLZRCyTF4z6ZTLKY5Uu1P8Zs4+eN74SIsT ISomZMNoJvDbRDkqsk+mDo0Uwa8AdajBskyTH88+9FVf25WlpAHJWFIKWSmjqt+UvkDB l5tw== 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=8HvRoiCT6Kaqw+ME0No79Ijetq5cFPuTsghNfxraGwU=; b=nQ60VrfFeAHJ6CTe7MlRypbCu1tzXxRjV6ONX9dO1+HGKMC409SUUetml7Q45Wt42k Dz0GF6fGijysb9Z0Ga3qDOB1OvWJu8tTva8MRLe76YD3YjCZFyfSocnoYHJ2bJhcj87c P7ZarKLagDs8zmLPwr4S8HKJUjDuMYQUhrbb62fn3XZNEuH6XULtZuy3p2T8Qn8iUa29 GOMUj343i3//tIHWfdhl3D+GFXtcu2BZpf0Xs+VqpgxY68qWwuahxlemC0uQtwPLoWHM CTs2R9w3imJZbYSsUaNlmCfqdfliu+BvG7V/cAkD+l85gXdDLz9EVaYAk6pSUyYJeq/i HFSA== X-Gm-Message-State: AOAM533JFWa9F1BNWCrPXt0TIOPrXkW978wsMSc9X0rSnZMT/hQioE9I +lEx3lDD41O6NrEVIGRXFjk= X-Google-Smtp-Source: ABdhPJwNXgGLyf78LllCxiKYdXIqr7RFMl9vsJSHfdNs3cPpKF5gm4SQXM9MIAPD1KxMYSw9WhyOOA== X-Received: by 2002:aa7:c987:: with SMTP id c7mr9890667edt.385.1599748525404; Thu, 10 Sep 2020 07:35:25 -0700 (PDT) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com. [66.111.4.228]) by smtp.gmail.com with ESMTPSA id e16sm7311945ejk.68.2020.09.10.07.35.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Sep 2020 07:35:24 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailauth.nyi.internal (Postfix) with ESMTP id 5BC2827C00A3; Thu, 10 Sep 2020 10:35:21 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 10 Sep 2020 10:35:21 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudehjedgjedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne goufhorhhtvggutfgvtghiphdvucdlgedtmdenucfjughrpefhvffufffkofgjfhgggfes tdekredtredttdenucfhrhhomhepuehoqhhunhcuhfgvnhhguceosghoqhhunhdrfhgvnh hgsehgmhgrihhlrdgtohhmqeenucggtffrrghtthgvrhhnpeehvdevteefgfeiudettdef vedvvdelkeejueffffelgeeuhffhjeetkeeiueeuleenucfkphephedvrdduheehrdduud durdejudenucevlhhushhtvghrufhiiigvpeeknecurfgrrhgrmhepmhgrihhlfhhrohhm pegsohhquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtd eigedqudejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehf ihigmhgvrdhnrghmvg X-ME-Proxy: Received: from localhost (unknown [52.155.111.71]) by mail.messagingengine.com (Postfix) with ESMTPA id 92ED73280059; Thu, 10 Sep 2020 10:35:20 -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 v3 10/11] Driver: hv: util: Make ringbuffer at least take two pages Date: Thu, 10 Sep 2020 22:34:54 +0800 Message-Id: <20200910143455.109293-11-boqun.feng@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200910143455.109293-1-boqun.feng@gmail.com> References: <20200910143455.109293-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-20200910_103526_356416_847CBCDB X-CRM114-Status: GOOD ( 15.85 ) 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 [2a00:1450:4864:20:0:0:0:541 listed in] [list.dnswl.org] 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.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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 When PAGE_SIZE > HV_HYP_PAGE_SIZE, we need the ringbuffer size to be at least 2 * PAGE_SIZE: one page for the header and at least one page of the data part (because of the alignment requirement for double mapping). So make sure the ringbuffer sizes to be at least 2 * PAGE_SIZE when using vmbus_open() to establish the vmbus connection. Signed-off-by: Boqun Feng Reviewed-by: Michael Kelley --- drivers/hv/hv_util.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c index a4e8d96513c2..3996c16568a3 100644 --- a/drivers/hv/hv_util.c +++ b/drivers/hv/hv_util.c @@ -500,6 +500,14 @@ static void heartbeat_onchannelcallback(void *context) } } +/* + * The size of each ring should be at least 2 * PAGE_SIZE, because we need one + * page for the header and at least another page (because of the alignment + * requirement for double mapping) for data part. + */ +#define HV_UTIL_RING_SEND_SIZE max(4 * HV_HYP_PAGE_SIZE, 2 * PAGE_SIZE) +#define HV_UTIL_RING_RECV_SIZE max(4 * HV_HYP_PAGE_SIZE, 2 * PAGE_SIZE) + static int util_probe(struct hv_device *dev, const struct hv_vmbus_device_id *dev_id) { @@ -530,8 +538,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 +598,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; }