Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | #include <linux/bio.h> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 3 | #include <linux/export.h> |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 4 | #include <xen/xen.h> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 5 | #include <xen/page.h> |
| 6 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 7 | /* check if @page can be merged with 'vec1' */ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 8 | bool xen_biovec_phys_mergeable(const struct bio_vec *vec1, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 9 | const struct page *page) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 10 | { |
| 11 | #if XEN_PAGE_SIZE == PAGE_SIZE |
| 12 | unsigned long bfn1 = pfn_to_bfn(page_to_pfn(vec1->bv_page)); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 13 | unsigned long bfn2 = pfn_to_bfn(page_to_pfn(page)); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 14 | |
| 15 | return bfn1 + PFN_DOWN(vec1->bv_offset + vec1->bv_len) == bfn2; |
| 16 | #else |
| 17 | /* |
| 18 | * XXX: Add support for merging bio_vec when using different page |
| 19 | * size in Xen and Linux. |
| 20 | */ |
| 21 | return false; |
| 22 | #endif |
| 23 | } |