blob: 05a286d24f1482f77ccea9999577b46cb96ee3c7 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Jeremy Fitzhardinged8e04202009-02-09 12:05:46 -08002#include <linux/bio.h>
Stephen Rothwell9ef9b202012-01-19 10:24:31 +11003#include <linux/export.h>
Christoph Hellwigc39ae602018-09-25 13:30:08 -07004#include <xen/xen.h>
Jeremy Fitzhardinged8e04202009-02-09 12:05:46 -08005#include <xen/page.h>
6
Ming Lei0383ad42019-03-29 15:07:54 +08007/* check if @page can be merged with 'vec1' */
Jeremy Fitzhardinged8e04202009-02-09 12:05:46 -08008bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
Ming Lei0383ad42019-03-29 15:07:54 +08009 const struct page *page)
Jeremy Fitzhardinged8e04202009-02-09 12:05:46 -080010{
Julien Grall36f8abd2015-05-11 13:44:21 +010011#if XEN_PAGE_SIZE == PAGE_SIZE
Julien Grall32e09872015-08-07 17:34:35 +010012 unsigned long bfn1 = pfn_to_bfn(page_to_pfn(vec1->bv_page));
Ming Lei0383ad42019-03-29 15:07:54 +080013 unsigned long bfn2 = pfn_to_bfn(page_to_pfn(page));
Jeremy Fitzhardinged8e04202009-02-09 12:05:46 -080014
Roger Pau Monne462cdac2017-07-18 15:01:00 +010015 return bfn1 + PFN_DOWN(vec1->bv_offset + vec1->bv_len) == bfn2;
Julien Grall36f8abd2015-05-11 13:44:21 +010016#else
17 /*
18 * XXX: Add support for merging bio_vec when using different page
19 * size in Xen and Linux.
20 */
Gustavo A. R. Silvabf06bad2018-08-04 19:50:14 -050021 return false;
Julien Grall36f8abd2015-05-11 13:44:21 +010022#endif
Jeremy Fitzhardinged8e04202009-02-09 12:05:46 -080023}