From patchwork Tue Jul 2 09:09:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13719181 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B820C30658 for ; Tue, 2 Jul 2024 09:11:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 416146B00C4; Tue, 2 Jul 2024 05:11:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C6CC6B00C5; Tue, 2 Jul 2024 05:11:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2668D6B00C6; Tue, 2 Jul 2024 05:11:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 06A256B00C4 for ; Tue, 2 Jul 2024 05:11:08 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id AD14A8203C for ; Tue, 2 Jul 2024 09:11:08 +0000 (UTC) X-FDA: 82294243416.20.9793324 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id 11FAF1C0008 for ; Tue, 2 Jul 2024 09:11:06 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tmMV07HW; spf=pass (imf18.hostedemail.com: domain of leon@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=leon@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719911444; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=QtKqiS2FdqQyx5V42cRxrrsXLbP2wtKYMXoP2kKFaO4=; b=sr9wZT6dfluMNxeyNe03nV0wEkxzuGASZCBCd/xZaDRQMHFWJZs3LCO0SBqROFpRY5M6MW R+2Ou+uA/LTynynX6N8dG7qYvSqwyawJuth+yhSBFciXpmS7EVqQ2vEV54755id+PoGcRc /x5i8WuavlmlWTpEVO9Xg7mgwJ2qr/M= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719911444; a=rsa-sha256; cv=none; b=J8AlVDO8XFd8LK9CqOzn2vpYqtKLI5mAS0EiKi6CJjYY1nch9JMsX0rqQpSiHIKzwxdXB2 uzXPrwOle2Xux/YK/N4GJbIivJqTiZBufMCQUqlsh2qPbD6Uqgli6TsKGS6a6qfvt7Rt+s tZ+fRfZcPQE9Bj/Ne/Idkk1nhOvK3oA= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tmMV07HW; spf=pass (imf18.hostedemail.com: domain of leon@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=leon@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 2FA6561A27; Tue, 2 Jul 2024 09:11:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38628C116B1; Tue, 2 Jul 2024 09:11:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719911466; bh=awqNz5OGdWfjQsJN8aSzpTwPuTxHlPEDhpz1xfEBgC0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tmMV07HWOakUhLEx0CG5Sw8D1u/vJiFeT/1LOA4/MYdwbWSy8GvydRXDag+XzNQuF 8Mrby6JUZOtPEv8fs7zqbYmgnJ3vQ0E8UKqg2AiGbf2B4rjUPAo8OMiBBUtmXlUtED I7lOY1LwtkVhj5RlocDgysGvTm0aU3G+jzWGhM9DlHlbRQ+NQwCweNkMi/QFwfNt5f Zt/8qIdBUHskSlNSHY+lwUUXkwkAM2VZSfuGEizQOnbvlLYGPXRFfuO7ZnqRmHvzP3 sHQW3H4gZFNAN04PzGFcNOHwkG6/bvqhEaQ9QjvKDRliH9gVdc0oevJLqLUVJ+y2YD 4NmY108G1I3Ow== From: Leon Romanovsky To: Jens Axboe , Jason Gunthorpe , Robin Murphy , Joerg Roedel , Will Deacon , Keith Busch , Christoph Hellwig , "Zeng, Oak" , Chaitanya Kulkarni Cc: Sagi Grimberg , Bjorn Helgaas , Logan Gunthorpe , Yishai Hadas , Shameer Kolothum , Kevin Tian , Alex Williamson , Marek Szyprowski , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Andrew Morton , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, linux-nvme@lists.infradead.org, linux-pci@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v1 17/18] block: export helper to get segment max size Date: Tue, 2 Jul 2024 12:09:47 +0300 Message-ID: <3649c1dc673ea0a49a90f3e01b76ef91fb90f076.1719909395.git.leon@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 11FAF1C0008 X-Stat-Signature: po5yyxt55xdq7t6mrk3neucqgpsiwwd7 X-HE-Tag: 1719911466-561274 X-HE-Meta: U2FsdGVkX1/SD+rS3BwXnUZiE0nJ3nhk3lehn9RO0E6MAVaNoBuKrFw8DOxvimSjVRvfXU0XhspjqxihSne65vzFZMJv6isYT2KimgW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kZ7JLm4fWG0MW3+UQdU2YTGsbFjexZAY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Chaitanya Kulkarni Export the get_max_segment_size() so driver can do use that to create DMA mapping when it receives the request. Signed-off-by: Chaitanya Kulkarni Signed-off-by: Leon Romanovsky --- block/blk-merge.c | 3 ++- include/linux/blk-mq.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 8534c35e0497..0561e728ef95 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -190,7 +190,7 @@ static inline unsigned get_max_io_size(struct bio *bio, * * Returns the maximum number of bytes that can be added as a single segment. */ -static inline unsigned get_max_segment_size(const struct queue_limits *lim, +inline unsigned get_max_segment_size(const struct queue_limits *lim, struct page *start_page, unsigned long offset) { unsigned long mask = lim->seg_boundary_mask; @@ -203,6 +203,7 @@ static inline unsigned get_max_segment_size(const struct queue_limits *lim, */ return min(mask - offset, (unsigned long)lim->max_segment_size - 1) + 1; } +EXPORT_SYMBOL_GPL(get_max_segment_size); /** * bvec_split_segs - verify whether or not a bvec should be split in the middle diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 89ba6b16fe8b..008c77c9b518 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -1150,4 +1150,7 @@ static inline int blk_rq_map_sg(struct request_queue *q, struct request *rq, } void blk_dump_rq_flags(struct request *, char *); +unsigned get_max_segment_size(const struct queue_limits *lim, + struct page *start_page, unsigned long offset); + #endif /* BLK_MQ_H */