[Lkw] [PATCH 10/10] nvme-cmb: implemento the I/O handler

Damian Gonzalez damian.gonzalez at mi.unc.edu.ar
Fri Sep 15 18:32:57 EDT 2023


Signed-off-by: Damian Gonzalez <damian.gonzalez at mi.unc.edu.ar>
---
 drivers/block/nvme-cmb.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c
index 6ffb4d824..2c7844149 100644
--- a/drivers/block/nvme-cmb.c
+++ b/drivers/block/nvme-cmb.c
@@ -29,7 +29,23 @@ struct nvme_cmb_dev {
 
 static void nvme_cmb_submit_bio(struct bio *bio)
 {
-       bio_io_error(bio);
+        struct nvme_cmb_dev *dev = bio->bi_bdev->bd_disk->private_data;
+        void __iomem *buffer = dev->buffer_bar + dev->buffer_offset;
+        struct bvec_iter iter;
+        struct bio_vec bv;
+
+        bio_for_each_segment(bv, bio, iter) {
+               void __iomem *dev_addr = buffer +
+                   (iter.bi_sector << SECTOR_SHIFT);
+               void *kaddr = bvec_virt(&bv);
+
+               if (bio_op(bio) == REQ_OP_READ)
+                       memcpy_fromio(kaddr, dev_addr, bv.bv_len);
+               else
+                       memcpy_toio(dev_addr, kaddr, bv.bv_len);
+        }
+
+        bio_endio(bio);
 }
 
 static const struct block_device_operations nvme_cmb_ops = {
-- 
2.39.2




More information about the LKW mailing list