[Lkw] [PATCH] [PATCH] Ready #9

Francisco Benedetti franbenedetti14 at gmail.com
Fri Sep 15 18:11:40 EDT 2023


Implement the I/O handler

Signed-off-by: Silexis <franbenedetti14 at gmail.com>
---
 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 3e3be2b62..673640d1f 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