@@ -288,6 +288,37 @@ int nvm_erase_ppa(struct nvm_dev *dev, struct ppa_addr ppa)
}
EXPORT_SYMBOL(nvm_erase_ppa);
+int nvm_submit_ppa(struct nvm_dev *dev, struct ppa_addr ppa, int opcode,
+ void *buf, int len)
+{
+ struct nvm_rq rqd;
+ struct bio *bio;
+ int ret;
+
+ bio = bio_map_kern(dev->q, buf, len, GFP_KERNEL);
+ if (IS_ERR_OR_NULL(bio))
+ return -ENOMEM;
+
+ memset(&rqd, 0, sizeof(struct nvm_rq));
+ ret = nvm_set_rqd_ppalist(dev, &rqd, &ppa, 1);
+ if (ret) {
+ bio_put(bio);
+ return ret;
+ }
+
+ rqd.opcode = opcode;
+ rqd.flags = NVM_IO_F_SYNC;
+ rqd.bio = bio;
+ nvm_generic_to_addr_mode(dev, &rqd);
+
+ ret = dev->ops->submit_io(dev, &rqd);
+
+ nvm_free_rqd_ppalist(dev, &rqd);
+
+ return ret;
+}
+EXPORT_SYMBOL(nvm_submit_ppa);
+
static int nvm_core_init(struct nvm_dev *dev)
{
struct nvm_id *id = &dev->identity;
@@ -437,6 +437,7 @@ extern int nvm_set_rqd_ppalist(struct nvm_dev *, struct nvm_rq *,
extern void nvm_free_rqd_ppalist(struct nvm_dev *, struct nvm_rq *);
extern int nvm_erase_ppa(struct nvm_dev *, struct ppa_addr);
extern int nvm_erase_blk(struct nvm_dev *, struct nvm_block *);
+extern int nvm_submit_ppa(struct nvm_dev *, struct ppa_addr, int, void *, int);
#else /* CONFIG_NVM */
struct nvm_dev_ops;
Internal logic for both core and media managers, does not have a backing bio for issuing I/Os. Introduce nvm_submit_ppa to allow raw I/Os to be submitted to the underlying device driver. The function request the device, ppa, data buffer and its length and will submit the I/O synchronously to the device. The return value may therefore be used to detect any errors regarding the issued I/O. Signed-off-by: Matias Bjørling <m@bjorling.me> --- drivers/lightnvm/core.c | 31 +++++++++++++++++++++++++++++++ include/linux/lightnvm.h | 1 + 2 files changed, 32 insertions(+)