aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/linux/bvec.h
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2024-07-06 09:52:17 +0200
committerJens Axboe <axboe@kernel.dk>2024-07-08 01:51:05 -0600
commit25f76c3db2f08428b5acd082a52787164001eb6e (patch)
tree7c73e1146750721b46a0869742cff0d4b3282a86 /include/linux/bvec.h
parentblk-lib: check for kill signal in ioctl BLKZEROOUT (diff)
downloadwireguard-linux-25f76c3db2f08428b5acd082a52787164001eb6e.tar.xz
wireguard-linux-25f76c3db2f08428b5acd082a52787164001eb6e.zip
block: add a bvec_phys helper
Get callers out of poking into bvec internals a bit more. Not a huge win right now, but with the proposed new DMA mapping API we might end up with a lot more of this otherwise. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Link: https://lore.kernel.org/r/20240706075228.2350978-2-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to '')
-rw-r--r--include/linux/bvec.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/bvec.h b/include/linux/bvec.h
index bd1e361b351c..f41c7f0ef91e 100644
--- a/include/linux/bvec.h
+++ b/include/linux/bvec.h
@@ -280,4 +280,18 @@ static inline void *bvec_virt(struct bio_vec *bvec)
return page_address(bvec->bv_page) + bvec->bv_offset;
}
+/**
+ * bvec_phys - return the physical address for a bvec
+ * @bvec: bvec to return the physical address for
+ */
+static inline phys_addr_t bvec_phys(const struct bio_vec *bvec)
+{
+ /*
+ * Note this open codes page_to_phys because page_to_phys is defined in
+ * <asm/io.h>, which we don't want to pull in here. If it ever moves to
+ * a sensible place we should start using it.
+ */
+ return PFN_PHYS(page_to_pfn(bvec->bv_page)) + bvec->bv_offset;
+}
+
#endif /* __LINUX_BVEC_H */