Subject: linux-next: manual merge of the block tree with Linus' tree

From: Stephen Rothwell <[email-masked]>
Date: Thu, 4 Jun 2015 14:36:15 +1000

Hi Jens,

Today's linux-next merge of the block tree got a conflict in
drivers/block/nvme-core.c between commit fec558b5f178 ("NVMe: fix type
warning on 32-bit") from Linus' tree and commit d29ec8241c10 ("nvme:
submit internal commands through the block layer") from the block tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwell                    [email-masked]

diff --cc drivers/block/nvme-core.c
index 683dff272562,513908ff46c4..000000000000
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@@ -1745,12 -1714,10 +1714,11 @@@ static int nvme_submit_io(struct nvme_n
  	struct nvme_dev *dev = ns->dev;
  	struct nvme_user_io io;
  	struct nvme_command c;
- 	unsigned length, meta_len, prp_len;
+ 	unsigned length, meta_len;
  	int status, write;
- 	struct nvme_iod *iod;
  	dma_addr_t meta_dma = 0;
  	void *meta = NULL;
 +	void __user *metadata;
  
  	if (copy_from_user(&io, uio, sizeof(io)))
  		return -EFAULT;
@@@ -1778,18 -1731,21 +1732,23 @@@
  		return -EINVAL;
  	}
  
- 	if (IS_ERR(iod))
- 		return PTR_ERR(iod);
+ 	length = (io.nblocks + 1) << ns->lba_shift;
+ 	meta_len = (io.nblocks + 1) * ns->ms;
+ 	write = io.opcode & 1;
++	metadata = (void __user *)(unsigned long)io.metadata;
  
- 	prp_len = nvme_setup_prps(dev, iod, length, GFP_KERNEL);
- 	if (length != prp_len) {
- 		status = -ENOMEM;
- 		goto unmap;
- 	}
  	if (meta_len) {
- 		meta = dma_alloc_coherent(&dev->pci_dev->dev, meta_len,
+ 		if (((io.metadata & 3) || !io.metadata) && !ns->ext)
+ 			return -EINVAL;
+ 
+ 		if (ns->ext) {
+ 			length += meta_len;
+ 			meta_len = 0;
+ 		}
+ 
+ 		meta = dma_alloc_coherent(dev->dev, meta_len,
  						&meta_dma, GFP_KERNEL);
 +
  		if (!meta) {
  			status = -ENOMEM;
  			goto unmap;
@@@ -1813,19 -1770,18 +1772,17 @@@
  	c.rw.reftag = cpu_to_le32(io.reftag);
  	c.rw.apptag = cpu_to_le16(io.apptag);
  	c.rw.appmask = cpu_to_le16(io.appmask);
- 	c.rw.prp1 = cpu_to_le64(sg_dma_address(iod->sg));
- 	c.rw.prp2 = cpu_to_le64(iod->first_dma);
  	c.rw.metadata = cpu_to_le64(meta_dma);
- 	status = nvme_submit_io_cmd(dev, ns, &c, NULL);
+ 
+ 	status = __nvme_submit_sync_cmd(ns->queue, &c, NULL,
+ 			(void __user *)io.addr, length, NULL, 0);
   unmap:
- 	nvme_unmap_user_pages(dev, write, iod);
- 	nvme_free_iod(dev, iod);
  	if (meta) {
  		if (status == NVME_SC_SUCCESS && !write) {
 -			if (copy_to_user((void __user *)io.metadata, meta,
 -								meta_len))
 +			if (copy_to_user(metadata, meta, meta_len))
  				status = -EFAULT;
  		}
- 		dma_free_coherent(&dev->pci_dev->dev, meta_len, meta, meta_dma);
+ 		dma_free_coherent(dev->dev, meta_len, meta, meta_dma);
  	}
  	return status;
  }