linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* linux-next: manual merge of the kmap_atomic tree with the staging tree
@ 2012-01-06  7:40 Stephen Rothwell
  2012-01-06  8:17 ` Cong Wang
  2012-01-06 15:47 ` Haiyang Zhang
  0 siblings, 2 replies; 12+ messages in thread
From: Stephen Rothwell @ 2012-01-06  7:40 UTC (permalink / raw)
  To: Cong Wang
  Cc: linux-next, linux-kernel, Haiyang Zhang, K. Y. Srinivasan, Greg KH

[-- Attachment #1: Type: text/plain, Size: 552 bytes --]

Hi Cong,

Today's linux-next merge of the kmap_atomic tree got conflicts in
drivers/net/hyperv/netvsc_drv.c and drivers/net/hyperv/rndis_filter.c
between commit 453263421f88 ("net/hyperv: Remove unnecessary kmap_atomic
in netvsc driver") from the staging tree and commit e91cd643d15d ("hv:
remove the second argument of k[un]map_atomic()") from the kmap_atomic
tree.

The former removed the code modified by the latter, so I did that.
-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: linux-next: manual merge of the kmap_atomic tree with the staging tree
  2012-01-06  7:40 linux-next: manual merge of the kmap_atomic tree with the staging tree Stephen Rothwell
@ 2012-01-06  8:17 ` Cong Wang
  2012-01-06 15:47 ` Haiyang Zhang
  1 sibling, 0 replies; 12+ messages in thread
From: Cong Wang @ 2012-01-06  8:17 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: linux-next, linux-kernel, Haiyang Zhang, K. Y. Srinivasan, Greg KH

On Fri, 2012-01-06 at 18:40 +1100, Stephen Rothwell wrote:
> Hi Cong,
> 
> Today's linux-next merge of the kmap_atomic tree got conflicts in
> drivers/net/hyperv/netvsc_drv.c and drivers/net/hyperv/rndis_filter.c
> between commit 453263421f88 ("net/hyperv: Remove unnecessary kmap_atomic
> in netvsc driver") from the staging tree and commit e91cd643d15d ("hv:
> remove the second argument of k[un]map_atomic()") from the kmap_atomic
> tree.
> 
> The former removed the code modified by the latter, so I did that.

This makes sense for me.

Thanks for fixing it!



^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: linux-next: manual merge of the kmap_atomic tree with the staging tree
  2012-01-06  7:40 linux-next: manual merge of the kmap_atomic tree with the staging tree Stephen Rothwell
  2012-01-06  8:17 ` Cong Wang
@ 2012-01-06 15:47 ` Haiyang Zhang
  1 sibling, 0 replies; 12+ messages in thread
From: Haiyang Zhang @ 2012-01-06 15:47 UTC (permalink / raw)
  To: Stephen Rothwell, Cong Wang
  Cc: linux-next, linux-kernel, KY Srinivasan, Greg KH



> -----Original Message-----
> From: Stephen Rothwell [mailto:sfr@canb.auug.org.au]
> Sent: Friday, January 06, 2012 2:41 AM
> To: Cong Wang
> Cc: linux-next@vger.kernel.org; linux-kernel@vger.kernel.org; Haiyang Zhang;
> KY Srinivasan; Greg KH
> Subject: linux-next: manual merge of the kmap_atomic tree with the staging
> tree
> 
> Hi Cong,
> 
> Today's linux-next merge of the kmap_atomic tree got conflicts in
> drivers/net/hyperv/netvsc_drv.c and drivers/net/hyperv/rndis_filter.c between
> commit 453263421f88 ("net/hyperv: Remove unnecessary kmap_atomic in
> netvsc driver") from the staging tree and commit e91cd643d15d ("hv:
> remove the second argument of k[un]map_atomic()") from the kmap_atomic
> tree.
> 
> The former removed the code modified by the latter, so I did that.

Good! Thank you for the merging.

- Haiyang



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: linux-next: manual merge of the kmap_atomic tree with the staging tree
       [not found] <20120301170731.e14fb63e606a8e67b0cb919a@canb.auug.org.au>
@ 2012-03-02  5:51 ` Cong Wang
  0 siblings, 0 replies; 12+ messages in thread
From: Cong Wang @ 2012-03-02  5:51 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: linux-next, linux-kernel, . Seth Jennings

On Thu, 2012-03-01 at 17:07 +1100, Stephen Rothwell wrote:
> Hi Cong,
> 
> Today's linux-next merge of the kmap_atomic tree got a conflict in
> drivers/staging/zcache/zcache-main.c between various commits from the
> staging tree and commit 1edbcaee3bbe ("zcache: remove the second argument
> of k[un]map_atomic()") from the kmap_atomic tree.
> 
> I fixed it up (see below) and can carry the fix as necessary.

Hi, Stephen,

Sorry for the delay, it looks correct to me.

Thanks!


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: linux-next: manual merge of the kmap_atomic tree with the staging tree
  2012-02-13  5:08 Stephen Rothwell
@ 2012-02-13  9:02 ` Cong Wang
  0 siblings, 0 replies; 12+ messages in thread
From: Cong Wang @ 2012-02-13  9:02 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: linux-next, linux-kernel, K. Y. Srinivasan, Greg KH

On Mon, 2012-02-13 at 16:08 +1100, Stephen Rothwell wrote:
> Hi Cong,
> 
> Today's linux-next merge of the kmap_atomic tree got a conflict in
> drivers/staging/hv/storvsc_drv.c between various commits from the staging
> tree and commit c41a603a7235 ("hv: remove the second argument of k
> [un]map_atomic()") from the kmap_atomic tree.
> 
> I fixed it up (see below) and can carry the fix as necessary.

Sounds fine, thanks!


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: linux-next: manual merge of the kmap_atomic tree with the staging tree
  2012-02-13  5:15 Stephen Rothwell
@ 2012-02-13  9:01 ` Cong Wang
  0 siblings, 0 replies; 12+ messages in thread
From: Cong Wang @ 2012-02-13  9:01 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: linux-next, linux-kernel, Seth Jennings, Dan Magenheimer, Greg KH

On Mon, 2012-02-13 at 16:15 +1100, Stephen Rothwell wrote:
> Hi Cong,
> 
> Today's linux-next merge of the kmap_atomic tree got a conflict in
> drivers/staging/zcache/zcache-main.c between commit a49aeb1de585
> ("staging: zcache: replace xvmalloc with zsmalloc") (and mayb others)
> from the staging tree and commit 1edbcaee3bbe ("zcache: remove the second
> argument of k [un]map_atomic()") from the kmap_atomic tree.
> 
> I fixed it up (see below) and can carry the fix as necessary.

Looks good.

Thanks!


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: linux-next: manual merge of the kmap_atomic tree with the staging tree
  2012-02-13  5:20 Stephen Rothwell
@ 2012-02-13  9:00 ` Cong Wang
  0 siblings, 0 replies; 12+ messages in thread
From: Cong Wang @ 2012-02-13  9:00 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: linux-next, linux-kernel, Nitin Gupta, Greg KH

On Mon, 2012-02-13 at 16:20 +1100, Stephen Rothwell wrote:
> Hi Cong,
> 
> Today's linux-next merge of the kmap_atomic tree got a conflict in
> drivers/staging/zram/zram_drv.c between commit fd1a30dea194 ("staging:
> zram: replace xvmalloc with zsmalloc") from the staging tree and commit
> ea81cfe7d7fb ("zram: remove the second argument of k[un]map_atomic()")
> from the kmap_atomic tree.
> 
> I fixed it up (see below) and can carry the fix as necessary.
> 

Looks good, thanks!


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: linux-next: manual merge of the kmap_atomic tree with the staging tree
  2012-02-13  5:27 Stephen Rothwell
@ 2012-02-13  9:00 ` Cong Wang
  0 siblings, 0 replies; 12+ messages in thread
From: Cong Wang @ 2012-02-13  9:00 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: linux-next, linux-kernel, Nitin Gupta, Greg KH

On Mon, 2012-02-13 at 16:27 +1100, Stephen Rothwell wrote:
> Hi Cong,
> 
> Today's linux-next merge of the kmap_atomic tree got a conflict in
> drivers/staging/zram/xvmalloc.c between commit b154ff05e1b0 ("staging:
> zram: remove xvmalloc") from the staging tree and commit ea81cfe7d7fb
> ("zram: remove the second argument of k[un]map_atomic()") from the
> kmap_atomic tree.
> 
> The former removed the file, so I did that.

Ok, thanks!


^ permalink raw reply	[flat|nested] 12+ messages in thread

* linux-next: manual merge of the kmap_atomic tree with the staging tree
@ 2012-02-13  5:27 Stephen Rothwell
  2012-02-13  9:00 ` Cong Wang
  0 siblings, 1 reply; 12+ messages in thread
From: Stephen Rothwell @ 2012-02-13  5:27 UTC (permalink / raw)
  To: Cong Wang; +Cc: linux-next, linux-kernel, Nitin Gupta, Greg KH

[-- Attachment #1: Type: text/plain, Size: 429 bytes --]

Hi Cong,

Today's linux-next merge of the kmap_atomic tree got a conflict in
drivers/staging/zram/xvmalloc.c between commit b154ff05e1b0 ("staging:
zram: remove xvmalloc") from the staging tree and commit ea81cfe7d7fb
("zram: remove the second argument of k[un]map_atomic()") from the
kmap_atomic tree.

The former removed the file, so I did that.
-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* linux-next: manual merge of the kmap_atomic tree with the staging tree
@ 2012-02-13  5:20 Stephen Rothwell
  2012-02-13  9:00 ` Cong Wang
  0 siblings, 1 reply; 12+ messages in thread
From: Stephen Rothwell @ 2012-02-13  5:20 UTC (permalink / raw)
  To: Cong Wang; +Cc: linux-next, linux-kernel, Nitin Gupta, Greg KH

[-- Attachment #1: Type: text/plain, Size: 2641 bytes --]

Hi Cong,

Today's linux-next merge of the kmap_atomic tree got a conflict in
drivers/staging/zram/zram_drv.c between commit fd1a30dea194 ("staging:
zram: replace xvmalloc with zsmalloc") from the staging tree and commit
ea81cfe7d7fb ("zram: remove the second argument of k[un]map_atomic()")
from the kmap_atomic tree.

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

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au

diff --cc drivers/staging/zram/zram_drv.c
index 5833156,1cf68ad..0000000
--- a/drivers/staging/zram/zram_drv.c
+++ b/drivers/staging/zram/zram_drv.c
@@@ -188,12 -195,12 +188,12 @@@ static void handle_uncompressed_page(st
  	struct page *page = bvec->bv_page;
  	unsigned char *user_mem, *cmem;
  
- 	user_mem = kmap_atomic(page, KM_USER0);
- 	cmem = kmap_atomic(zram->table[index].handle, KM_USER1);
+ 	user_mem = kmap_atomic(page);
 -	cmem = kmap_atomic(zram->table[index].page);
++	cmem = kmap_atomic(zram->table[index].handle);
  
  	memcpy(user_mem + bvec->bv_offset, cmem + offset, bvec->bv_len);
- 	kunmap_atomic(cmem, KM_USER1);
- 	kunmap_atomic(user_mem, KM_USER0);
+ 	kunmap_atomic(cmem);
+ 	kunmap_atomic(user_mem);
  
  	flush_dcache_page(page);
  }
@@@ -259,8 -267,8 +259,8 @@@ static int zram_bvec_read(struct zram *
  		kfree(uncmem);
  	}
  
 -	kunmap_atomic(cmem);
 +	zs_unmap_object(zram->mem_pool, zram->table[index].handle);
- 	kunmap_atomic(user_mem, KM_USER0);
+ 	kunmap_atomic(user_mem);
  
  	/* Should NEVER happen. Return bio error if it does. */
  	if (unlikely(ret != LZO_E_OK)) {
@@@ -399,9 -407,8 +399,9 @@@ static int zram_bvec_write(struct zram 
  		store_offset = 0;
  		zram_set_flag(zram, index, ZRAM_UNCOMPRESSED);
  		zram_stat_inc(&zram->stats.pages_expand);
 -		zram->table[index].page = page_store;
 +		handle = page_store;
- 		src = kmap_atomic(page, KM_USER0);
- 		cmem = kmap_atomic(page_store, KM_USER1);
+ 		src = kmap_atomic(page);
++		cmem = kmap_atomic(page_store);
  		goto memstore;
  	}
  
@@@ -426,15 -438,9 +426,15 @@@ memstore
  
  	memcpy(cmem, src, clen);
  
 -	kunmap_atomic(cmem);
 -	if (unlikely(zram_test_flag(zram, index, ZRAM_UNCOMPRESSED)))
 +	if (unlikely(zram_test_flag(zram, index, ZRAM_UNCOMPRESSED))) {
- 		kunmap_atomic(cmem, KM_USER1);
- 		kunmap_atomic(src, KM_USER0);
++		kunmap_atomic(cmem);
+ 		kunmap_atomic(src);
 +	} else {
 +		zs_unmap_object(zram->mem_pool, handle);
 +	}
 +
 +	zram->table[index].handle = handle;
 +	zram->table[index].size = clen;
  
  	/* Update stats */
  	zram_stat64_add(zram, &zram->stats.compr_size, clen);

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* linux-next: manual merge of the kmap_atomic tree with the staging tree
@ 2012-02-13  5:15 Stephen Rothwell
  2012-02-13  9:01 ` Cong Wang
  0 siblings, 1 reply; 12+ messages in thread
From: Stephen Rothwell @ 2012-02-13  5:15 UTC (permalink / raw)
  To: Cong Wang
  Cc: linux-next, linux-kernel, Seth Jennings, Dan Magenheimer, Greg KH

[-- Attachment #1: Type: text/plain, Size: 3153 bytes --]

Hi Cong,

Today's linux-next merge of the kmap_atomic tree got a conflict in
drivers/staging/zcache/zcache-main.c between commit a49aeb1de585
("staging: zcache: replace xvmalloc with zsmalloc") (and mayb others)
from the staging tree and commit 1edbcaee3bbe ("zcache: remove the second
argument of k [un]map_atomic()") from the kmap_atomic tree.

I fixed it up (see below) and can carry the fix as necessary.
-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au

diff --cc drivers/staging/zcache/zcache-main.c
index ccfa854,f0843e8a..0000000
--- a/drivers/staging/zcache/zcache-main.c
+++ b/drivers/staging/zcache/zcache-main.c
@@@ -455,14 -421,13 +455,14 @@@ static int zbud_decompress(struct page 
  	}
  	ASSERT_SENTINEL(zh, ZBH);
  	BUG_ON(zh->size == 0 || zh->size > zbud_max_buddy_size());
- 	to_va = kmap_atomic(page, KM_USER0);
+ 	to_va = kmap_atomic(page);
  	size = zh->size;
  	from_va = zbud_data(zh, size);
 -	ret = lzo1x_decompress_safe(from_va, size, to_va, &out_len);
 -	BUG_ON(ret != LZO_E_OK);
 +	ret = zcache_comp_op(ZCACHE_COMPOP_DECOMPRESS, from_va, size,
 +				to_va, &out_len);
 +	BUG_ON(ret);
  	BUG_ON(out_len != PAGE_SIZE);
- 	kunmap_atomic(to_va, KM_USER0);
+ 	kunmap_atomic(to_va);
  out:
  	spin_unlock(&zbpg->lock);
  	return ret;
@@@ -745,22 -708,21 +745,22 @@@ static void zv_free(struct zs_pool *poo
  	local_irq_restore(flags);
  }
  
 -static void zv_decompress(struct page *page, struct zv_hdr *zv)
 +static void zv_decompress(struct page *page, void *handle)
  {
 -	size_t clen = PAGE_SIZE;
 +	unsigned int clen = PAGE_SIZE;
  	char *to_va;
 -	unsigned size;
  	int ret;
 +	struct zv_hdr *zv;
  
 +	zv = zs_map_object(zcache_host.zspool, handle);
 +	BUG_ON(zv->size == 0);
  	ASSERT_SENTINEL(zv, ZVH);
- 	to_va = kmap_atomic(page, KM_USER0);
 -	size = xv_get_object_size(zv) - sizeof(*zv);
 -	BUG_ON(size == 0);
+ 	to_va = kmap_atomic(page);
 -	ret = lzo1x_decompress_safe((char *)zv + sizeof(*zv),
 -					size, to_va, &clen);
 +	ret = zcache_comp_op(ZCACHE_COMPOP_DECOMPRESS, (char *)zv + sizeof(*zv),
 +				zv->size, to_va, &clen);
- 	kunmap_atomic(to_va, KM_USER0);
+ 	kunmap_atomic(to_va);
 -	BUG_ON(ret != LZO_E_OK);
 +	zs_unmap_object(zcache_host.zspool, handle);
 +	BUG_ON(ret);
  	BUG_ON(clen != PAGE_SIZE);
  }
  
@@@ -1333,16 -1297,15 +1333,16 @@@ static int zcache_compress(struct page 
  	char *from_va;
  
  	BUG_ON(!irqs_disabled());
 -	if (unlikely(dmem == NULL || wmem == NULL))
 -		goto out;  /* no buffer, so can't compress */
 +	if (unlikely(dmem == NULL))
 +		goto out;  /* no buffer or no compressor so can't compress */
 +	*out_len = PAGE_SIZE << ZCACHE_DSTMEM_ORDER;
- 	from_va = kmap_atomic(from, KM_USER0);
+ 	from_va = kmap_atomic(from);
  	mb();
 -	ret = lzo1x_1_compress(from_va, PAGE_SIZE, dmem, out_len, wmem);
 -	BUG_ON(ret != LZO_E_OK);
 +	ret = zcache_comp_op(ZCACHE_COMPOP_COMPRESS, from_va, PAGE_SIZE, dmem,
 +				(unsigned int *)out_len);
 +	BUG_ON(ret);
  	*out_va = dmem;
- 	kunmap_atomic(from_va, KM_USER0);
+ 	kunmap_atomic(from_va);
  	ret = 1;
  out:
  	return ret;

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* linux-next: manual merge of the kmap_atomic tree with the staging tree
@ 2012-02-13  5:08 Stephen Rothwell
  2012-02-13  9:02 ` Cong Wang
  0 siblings, 1 reply; 12+ messages in thread
From: Stephen Rothwell @ 2012-02-13  5:08 UTC (permalink / raw)
  To: Cong Wang; +Cc: linux-next, linux-kernel, K. Y. Srinivasan, Greg KH

[-- Attachment #1: Type: text/plain, Size: 14572 bytes --]

Hi Cong,

Today's linux-next merge of the kmap_atomic tree got a conflict in
drivers/staging/hv/storvsc_drv.c between various commits from the staging
tree and commit c41a603a7235 ("hv: remove the second argument of k
[un]map_atomic()") from the kmap_atomic tree.

I fixed it up (see below) and can carry the fix as necessary.
-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au

diff --cc drivers/staging/hv/storvsc_drv.c
index 695ffc3,ddbdec8..0000000
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@@ -408,339 -398,113 +408,335 @@@ get_in_err
  
  }
  
 -static int storvsc_channel_init(struct hv_device *device)
 +static void destroy_bounce_buffer(struct scatterlist *sgl,
 +				  unsigned int sg_count)
  {
 -	struct storvsc_device *stor_device;
 -	struct hv_storvsc_request *request;
 -	struct vstor_packet *vstor_packet;
 -	int ret, t;
 +	int i;
 +	struct page *page_buf;
  
 -	stor_device = get_out_stor_device(device);
 -	if (!stor_device)
 -		return -ENODEV;
 +	for (i = 0; i < sg_count; i++) {
 +		page_buf = sg_page((&sgl[i]));
 +		if (page_buf != NULL)
 +			__free_page(page_buf);
 +	}
  
 -	request = &stor_device->init_request;
 -	vstor_packet = &request->vstor_packet;
 +	kfree(sgl);
 +}
  
 -	/*
 -	 * Now, initiate the vsc/vsp initialization protocol on the open
 -	 * channel
 -	 */
 -	memset(request, 0, sizeof(struct hv_storvsc_request));
 -	init_completion(&request->wait_event);
 -	vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION;
 -	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
 +static int do_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count)
 +{
 +	int i;
  
 -	ret = vmbus_sendpacket(device->channel, vstor_packet,
 -			       sizeof(struct vstor_packet),
 -			       (unsigned long)request,
 -			       VM_PKT_DATA_INBAND,
 -			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 -	if (ret != 0)
 -		goto cleanup;
 +	/* No need to check */
 +	if (sg_count < 2)
 +		return -1;
  
 -	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
 -	if (t == 0) {
 -		ret = -ETIMEDOUT;
 -		goto cleanup;
 +	/* We have at least 2 sg entries */
 +	for (i = 0; i < sg_count; i++) {
 +		if (i == 0) {
 +			/* make sure 1st one does not have hole */
 +			if (sgl[i].offset + sgl[i].length != PAGE_SIZE)
 +				return i;
 +		} else if (i == sg_count - 1) {
 +			/* make sure last one does not have hole */
 +			if (sgl[i].offset != 0)
 +				return i;
 +		} else {
 +			/* make sure no hole in the middle */
 +			if (sgl[i].length != PAGE_SIZE || sgl[i].offset != 0)
 +				return i;
 +		}
  	}
 +	return -1;
 +}
  
 -	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
 -	    vstor_packet->status != 0)
 -		goto cleanup;
 -
 -
 -	/* reuse the packet for version range supported */
 -	memset(vstor_packet, 0, sizeof(struct vstor_packet));
 -	vstor_packet->operation = VSTOR_OPERATION_QUERY_PROTOCOL_VERSION;
 -	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
 +static struct scatterlist *create_bounce_buffer(struct scatterlist *sgl,
 +						unsigned int sg_count,
 +						unsigned int len,
 +						int write)
 +{
 +	int i;
 +	int num_pages;
 +	struct scatterlist *bounce_sgl;
 +	struct page *page_buf;
 +	unsigned int buf_len = ((write == WRITE_TYPE) ? 0 : PAGE_SIZE);
  
 -	vstor_packet->version.major_minor = VMSTOR_PROTOCOL_VERSION_CURRENT;
 -	FILL_VMSTOR_REVISION(vstor_packet->version.revision);
 +	num_pages = ALIGN(len, PAGE_SIZE) >> PAGE_SHIFT;
  
 -	ret = vmbus_sendpacket(device->channel, vstor_packet,
 -			       sizeof(struct vstor_packet),
 -			       (unsigned long)request,
 -			       VM_PKT_DATA_INBAND,
 -			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 -	if (ret != 0)
 -		goto cleanup;
 +	bounce_sgl = kcalloc(num_pages, sizeof(struct scatterlist), GFP_ATOMIC);
 +	if (!bounce_sgl)
 +		return NULL;
  
 -	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
 -	if (t == 0) {
 -		ret = -ETIMEDOUT;
 -		goto cleanup;
 +	for (i = 0; i < num_pages; i++) {
 +		page_buf = alloc_page(GFP_ATOMIC);
 +		if (!page_buf)
 +			goto cleanup;
 +		sg_set_page(&bounce_sgl[i], page_buf, buf_len, 0);
  	}
  
 -	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
 -	    vstor_packet->status != 0)
 -		goto cleanup;
 +	return bounce_sgl;
  
 +cleanup:
 +	destroy_bounce_buffer(bounce_sgl, num_pages);
 +	return NULL;
 +}
  
 -	memset(vstor_packet, 0, sizeof(struct vstor_packet));
 -	vstor_packet->operation = VSTOR_OPERATION_QUERY_PROPERTIES;
 -	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
 -	vstor_packet->storage_channel_properties.port_number =
 -					stor_device->port_number;
 +/* Assume the original sgl has enough room */
 +static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl,
 +					    struct scatterlist *bounce_sgl,
 +					    unsigned int orig_sgl_count,
 +					    unsigned int bounce_sgl_count)
 +{
 +	int i;
 +	int j = 0;
 +	unsigned long src, dest;
 +	unsigned int srclen, destlen, copylen;
 +	unsigned int total_copied = 0;
 +	unsigned long bounce_addr = 0;
 +	unsigned long dest_addr = 0;
 +	unsigned long flags;
  
 -	ret = vmbus_sendpacket(device->channel, vstor_packet,
 -			       sizeof(struct vstor_packet),
 -			       (unsigned long)request,
 -			       VM_PKT_DATA_INBAND,
 -			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 +	local_irq_save(flags);
  
 -	if (ret != 0)
 -		goto cleanup;
 +	for (i = 0; i < orig_sgl_count; i++) {
- 		dest_addr = (unsigned long)kmap_atomic(sg_page((&orig_sgl[i])),
- 					KM_IRQ0) + orig_sgl[i].offset;
++		dest_addr = (unsigned long)kmap_atomic(sg_page((&orig_sgl[i])))
++					+ orig_sgl[i].offset;
 +		dest = dest_addr;
 +		destlen = orig_sgl[i].length;
  
 -	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
 -	if (t == 0) {
 -		ret = -ETIMEDOUT;
 -		goto cleanup;
 -	}
 +		if (bounce_addr == 0)
 +			bounce_addr =
- 			(unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])),
- 							KM_IRQ0);
++			(unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])));
  
 -	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
 -	    vstor_packet->status != 0)
 -		goto cleanup;
 +		while (destlen) {
 +			src = bounce_addr + bounce_sgl[j].offset;
 +			srclen = bounce_sgl[j].length - bounce_sgl[j].offset;
  
 -	stor_device->path_id = vstor_packet->storage_channel_properties.path_id;
 -	stor_device->target_id
 -		= vstor_packet->storage_channel_properties.target_id;
 +			copylen = min(srclen, destlen);
 +			memcpy((void *)dest, (void *)src, copylen);
  
 -	memset(vstor_packet, 0, sizeof(struct vstor_packet));
 -	vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION;
 -	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
 +			total_copied += copylen;
 +			bounce_sgl[j].offset += copylen;
 +			destlen -= copylen;
 +			dest += copylen;
  
 -	ret = vmbus_sendpacket(device->channel, vstor_packet,
 -			       sizeof(struct vstor_packet),
 -			       (unsigned long)request,
 -			       VM_PKT_DATA_INBAND,
 -			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 +			if (bounce_sgl[j].offset == bounce_sgl[j].length) {
 +				/* full */
- 				kunmap_atomic((void *)bounce_addr, KM_IRQ0);
++				kunmap_atomic((void *)bounce_addr);
 +				j++;
 +
 +				/*
 +				 * It is possible that the number of elements
 +				 * in the bounce buffer may not be equal to
 +				 * the number of elements in the original
 +				 * scatter list. Handle this correctly.
 +				 */
 +
 +				if (j == bounce_sgl_count) {
 +					/*
 +					 * We are done; cleanup and return.
 +					 */
 +					kunmap_atomic((void *)(dest_addr -
- 							orig_sgl[i].offset),
- 							KM_IRQ0);
++							orig_sgl[i].offset));
 +					local_irq_restore(flags);
 +					return total_copied;
 +				}
 +
 +				/* if we need to use another bounce buffer */
 +				if (destlen || i != orig_sgl_count - 1)
 +					bounce_addr =
 +					(unsigned long)kmap_atomic(
- 					sg_page((&bounce_sgl[j])), KM_IRQ0);
++					sg_page((&bounce_sgl[j])));
 +			} else if (destlen == 0 && i == orig_sgl_count - 1) {
 +				/* unmap the last bounce that is < PAGE_SIZE */
- 				kunmap_atomic((void *)bounce_addr, KM_IRQ0);
++				kunmap_atomic((void *)bounce_addr);
 +			}
 +		}
 +
- 		kunmap_atomic((void *)(dest_addr - orig_sgl[i].offset),
- 			      KM_IRQ0);
++		kunmap_atomic((void *)(dest_addr - orig_sgl[i].offset));
 +	}
 +
 +	local_irq_restore(flags);
 +
 +	return total_copied;
 +}
 +
 +/* Assume the bounce_sgl has enough room ie using the create_bounce_buffer() */
 +static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
 +					  struct scatterlist *bounce_sgl,
 +					  unsigned int orig_sgl_count)
 +{
 +	int i;
 +	int j = 0;
 +	unsigned long src, dest;
 +	unsigned int srclen, destlen, copylen;
 +	unsigned int total_copied = 0;
 +	unsigned long bounce_addr = 0;
 +	unsigned long src_addr = 0;
 +	unsigned long flags;
 +
 +	local_irq_save(flags);
 +
 +	for (i = 0; i < orig_sgl_count; i++) {
- 		src_addr = (unsigned long)kmap_atomic(sg_page((&orig_sgl[i])),
- 				KM_IRQ0) + orig_sgl[i].offset;
++		src_addr = (unsigned long)kmap_atomic(sg_page((&orig_sgl[i])))
++				+ orig_sgl[i].offset;
 +		src = src_addr;
 +		srclen = orig_sgl[i].length;
 +
 +		if (bounce_addr == 0)
 +			bounce_addr =
- 			(unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])),
- 						KM_IRQ0);
++			(unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])));
 +
 +		while (srclen) {
 +			/* assume bounce offset always == 0 */
 +			dest = bounce_addr + bounce_sgl[j].length;
 +			destlen = PAGE_SIZE - bounce_sgl[j].length;
 +
 +			copylen = min(srclen, destlen);
 +			memcpy((void *)dest, (void *)src, copylen);
 +
 +			total_copied += copylen;
 +			bounce_sgl[j].length += copylen;
 +			srclen -= copylen;
 +			src += copylen;
 +
 +			if (bounce_sgl[j].length == PAGE_SIZE) {
 +				/* full..move to next entry */
- 				kunmap_atomic((void *)bounce_addr, KM_IRQ0);
++				kunmap_atomic((void *)bounce_addr);
 +				j++;
 +
 +				/* if we need to use another bounce buffer */
 +				if (srclen || i != orig_sgl_count - 1)
 +					bounce_addr =
 +					(unsigned long)kmap_atomic(
- 					sg_page((&bounce_sgl[j])), KM_IRQ0);
++					sg_page((&bounce_sgl[j])));
 +
 +			} else if (srclen == 0 && i == orig_sgl_count - 1) {
 +				/* unmap the last bounce that is < PAGE_SIZE */
- 				kunmap_atomic((void *)bounce_addr, KM_IRQ0);
++				kunmap_atomic((void *)bounce_addr);
 +			}
 +		}
 +
- 		kunmap_atomic((void *)(src_addr - orig_sgl[i].offset), KM_IRQ0);
++		kunmap_atomic((void *)(src_addr - orig_sgl[i].offset));
 +	}
 +
 +	local_irq_restore(flags);
 +
 +	return total_copied;
 +}
 +
 +static int storvsc_channel_init(struct hv_device *device)
 +{
 +	struct storvsc_device *stor_device;
 +	struct storvsc_cmd_request *request;
 +	struct vstor_packet *vstor_packet;
 +	int ret, t;
 +
 +	stor_device = get_out_stor_device(device);
 +	if (!stor_device)
 +		return -ENODEV;
 +
 +	request = &stor_device->init_request;
 +	vstor_packet = &request->vstor_packet;
 +
 +	/*
 +	 * Now, initiate the vsc/vsp initialization protocol on the open
 +	 * channel
 +	 */
 +	memset(request, 0, sizeof(struct storvsc_cmd_request));
 +	init_completion(&request->wait_event);
 +	vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION;
 +	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
 +
 +	ret = vmbus_sendpacket(device->channel, vstor_packet,
 +			       sizeof(struct vstor_packet),
 +			       (unsigned long)request,
 +			       VM_PKT_DATA_INBAND,
 +			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 +	if (ret != 0)
 +		goto cleanup;
 +
 +	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
 +	if (t == 0) {
 +		ret = -ETIMEDOUT;
 +		goto cleanup;
 +	}
 +
 +	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
 +	    vstor_packet->status != 0)
 +		goto cleanup;
 +
 +
 +	/* reuse the packet for version range supported */
 +	memset(vstor_packet, 0, sizeof(struct vstor_packet));
 +	vstor_packet->operation = VSTOR_OPERATION_QUERY_PROTOCOL_VERSION;
 +	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
 +
 +	vstor_packet->version.major_minor =
 +		storvsc_get_version(VMSTOR_CURRENT_MAJOR, VMSTOR_CURRENT_MINOR);
 +
 +	/*
 +	 * The revision number is only used in Windows; set it to 0.
 +	 */
 +	vstor_packet->version.revision = 0;
 +
 +	ret = vmbus_sendpacket(device->channel, vstor_packet,
 +			       sizeof(struct vstor_packet),
 +			       (unsigned long)request,
 +			       VM_PKT_DATA_INBAND,
 +			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 +	if (ret != 0)
 +		goto cleanup;
 +
 +	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
 +	if (t == 0) {
 +		ret = -ETIMEDOUT;
 +		goto cleanup;
 +	}
 +
 +	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
 +	    vstor_packet->status != 0)
 +		goto cleanup;
 +
 +
 +	memset(vstor_packet, 0, sizeof(struct vstor_packet));
 +	vstor_packet->operation = VSTOR_OPERATION_QUERY_PROPERTIES;
 +	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
 +	vstor_packet->storage_channel_properties.port_number =
 +					stor_device->port_number;
 +
 +	ret = vmbus_sendpacket(device->channel, vstor_packet,
 +			       sizeof(struct vstor_packet),
 +			       (unsigned long)request,
 +			       VM_PKT_DATA_INBAND,
 +			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 +
 +	if (ret != 0)
 +		goto cleanup;
 +
 +	t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
 +	if (t == 0) {
 +		ret = -ETIMEDOUT;
 +		goto cleanup;
 +	}
 +
 +	if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
 +	    vstor_packet->status != 0)
 +		goto cleanup;
 +
 +	stor_device->path_id = vstor_packet->storage_channel_properties.path_id;
 +	stor_device->target_id
 +		= vstor_packet->storage_channel_properties.target_id;
 +
 +	memset(vstor_packet, 0, sizeof(struct vstor_packet));
 +	vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION;
 +	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
 +
 +	ret = vmbus_sendpacket(device->channel, vstor_packet,
 +			       sizeof(struct vstor_packet),
 +			       (unsigned long)request,
 +			       VM_PKT_DATA_INBAND,
 +			       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
  
  	if (ret != 0)
  		goto cleanup;

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-03-02  5:51 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-06  7:40 linux-next: manual merge of the kmap_atomic tree with the staging tree Stephen Rothwell
2012-01-06  8:17 ` Cong Wang
2012-01-06 15:47 ` Haiyang Zhang
2012-02-13  5:08 Stephen Rothwell
2012-02-13  9:02 ` Cong Wang
2012-02-13  5:15 Stephen Rothwell
2012-02-13  9:01 ` Cong Wang
2012-02-13  5:20 Stephen Rothwell
2012-02-13  9:00 ` Cong Wang
2012-02-13  5:27 Stephen Rothwell
2012-02-13  9:00 ` Cong Wang
     [not found] <20120301170731.e14fb63e606a8e67b0cb919a@canb.auug.org.au>
2012-03-02  5:51 ` Cong Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).