Merge branch 'for-4.5/lightnvm' of git://git.kernel.dk/linux-block
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 22 Jan 2016 03:01:55 +0000 (19:01 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 22 Jan 2016 03:01:55 +0000 (19:01 -0800)
Pull lightnvm fixes and updates from Jens Axboe:
 "This should have been part of the drivers branch, but it arrived a bit
  late and wasn't based on the official core block driver branch.  So
  they got a small scolding, but got a pass since it's still new.  Hence
  it's in a separate branch.

  This is mostly pure fixes, contained to lightnvm/, and minor feature
  additions"

* 'for-4.5/lightnvm' of git://git.kernel.dk/linux-block: (26 commits)
  lightnvm: ensure that nvm_dev_ops can be used without CONFIG_NVM
  lightnvm: introduce factory reset
  lightnvm: use system block for mm initialization
  lightnvm: introduce ioctl to initialize device
  lightnvm: core on-disk initialization
  lightnvm: introduce mlc lower page table mappings
  lightnvm: add mccap support
  lightnvm: manage open and closed blocks separately
  lightnvm: fix missing grown bad block type
  lightnvm: reference rrpc lun in rrpc block
  lightnvm: introduce nvm_submit_ppa
  lightnvm: move rq->error to nvm_rq->error
  lightnvm: support multiple ppas in nvm_erase_ppa
  lightnvm: move the pages per block check out of the loop
  lightnvm: sectors first in ppa list
  lightnvm: fix locking and mempool in rrpc_lun_gc
  lightnvm: put block back to gc list on its reclaim fail
  lightnvm: check bi_error in gc
  lightnvm: return the get_bb_tbl return value
  lightnvm: refactor end_io functions for sync
  ...

1  2 
drivers/block/null_blk.c
drivers/nvme/host/lightnvm.c

diff --combined drivers/block/null_blk.c
@@@ -436,9 -436,8 +436,8 @@@ static void null_del_dev(struct nullb *
  static void null_lnvm_end_io(struct request *rq, int error)
  {
        struct nvm_rq *rqd = rq->end_io_data;
-       struct nvm_dev *dev = rqd->dev;
  
-       dev->mt->end_io(rqd, error);
+       nvm_end_io(rqd, error);
  
        blk_put_request(rq);
  }
@@@ -449,7 -448,7 +448,7 @@@ static int null_lnvm_submit_io(struct n
        struct request *rq;
        struct bio *bio = rqd->bio;
  
 -      rq = blk_mq_alloc_request(q, bio_rw(bio), GFP_KERNEL, 0);
 +      rq = blk_mq_alloc_request(q, bio_rw(bio), 0);
        if (IS_ERR(rq))
                return -ENOMEM;
  
@@@ -495,17 -494,17 +494,17 @@@ static int null_lnvm_id(struct nvm_dev 
        id->ppaf.ch_offset = 56;
        id->ppaf.ch_len = 8;
  
 -      do_div(size, bs); /* convert size to pages */
 -      do_div(size, 256); /* concert size to pgs pr blk */
 +      sector_div(size, bs); /* convert size to pages */
 +      size >>= 8; /* concert size to pgs pr blk */
        grp = &id->groups[0];
        grp->mtype = 0;
        grp->fmtype = 0;
        grp->num_ch = 1;
        grp->num_pg = 256;
        blksize = size;
 -      do_div(size, (1 << 16));
 +      size >>= 16;
        grp->num_lun = size + 1;
 -      do_div(blksize, grp->num_lun);
 +      sector_div(blksize, grp->num_lun);
        grp->num_blk = blksize;
        grp->num_pln = 1;
  
@@@ -146,6 -146,16 +146,16 @@@ struct nvme_nvm_command 
        };
  };
  
+ struct nvme_nvm_lp_mlc {
+       __u16                   num_pairs;
+       __u8                    pairs[886];
+ };
+ struct nvme_nvm_lp_tbl {
+       __u8                    id[8];
+       struct nvme_nvm_lp_mlc  mlc;
+ };
  struct nvme_nvm_id_group {
        __u8                    mtype;
        __u8                    fmtype;
        __le32                  mpos;
        __le32                  mccap;
        __le16                  cpar;
-       __u8                    reserved[906];
+       __u8                    reserved[10];
+       struct nvme_nvm_lp_tbl lptbl;
  } __packed;
  
  struct nvme_nvm_addr_format {
@@@ -266,6 -277,15 +277,15 @@@ static int init_grps(struct nvm_id *nvm
                dst->mccap = le32_to_cpu(src->mccap);
  
                dst->cpar = le16_to_cpu(src->cpar);
+               if (dst->fmtype == NVM_ID_FMTYPE_MLC) {
+                       memcpy(dst->lptbl.id, src->lptbl.id, 8);
+                       dst->lptbl.mlc.num_pairs =
+                                       le16_to_cpu(src->lptbl.mlc.num_pairs);
+                       /* 4 bits per pair */
+                       memcpy(dst->lptbl.mlc.pairs, src->lptbl.mlc.pairs,
+                                               dst->lptbl.mlc.num_pairs >> 1);
+               }
        }
  
        return 0;
@@@ -405,11 -425,6 +425,6 @@@ static int nvme_nvm_get_bb_tbl(struct n
  
        ppa = dev_to_generic_addr(nvmdev, ppa);
        ret = update_bbtbl(ppa, nr_blocks, bb_tbl->blk, priv);
-       if (ret) {
-               ret = -EINTR;
-               goto out;
-       }
  out:
        kfree(bb_tbl);
        return ret;
@@@ -453,11 -468,8 +468,8 @@@ static inline void nvme_nvm_rqtocmd(str
  static void nvme_nvm_end_io(struct request *rq, int error)
  {
        struct nvm_rq *rqd = rq->end_io_data;
-       struct nvm_dev *dev = rqd->dev;
  
-       if (dev->mt && dev->mt->end_io(rqd, error))
-               pr_err("nvme: err status: %x result: %lx\n",
-                               rq->errors, (unsigned long)rq->special);
+       nvm_end_io(rqd, error);
  
        kfree(rq->cmd);
        blk_mq_free_request(rq);
@@@ -471,7 -483,7 +483,7 @@@ static int nvme_nvm_submit_io(struct nv
        struct bio *bio = rqd->bio;
        struct nvme_nvm_command *cmd;
  
 -      rq = blk_mq_alloc_request(q, bio_rw(bio), GFP_KERNEL, 0);
 +      rq = blk_mq_alloc_request(q, bio_rw(bio), 0);
        if (IS_ERR(rq))
                return -ENOMEM;