diff mbox series

[RFC,1/4] Drivers: hv: vmbus: Remove special code for unsolicited messages

Message ID 20220328144244.100228-2-parri.andrea@gmail.com (mailing list archive)
State Superseded
Delegated to: Lorenzo Pieralisi
Headers show
Series PCI: hv: Miscellaneous changes | expand

Commit Message

Andrea Parri March 28, 2022, 2:42 p.m. UTC
vmbus_requestor has included code for handling unsolicited messages
since its introduction with commit e8b7db38449ac ("Drivers: hv: vmbus:
Add vmbus_requestor data structure for VMBus hardening"); such code was
motivated by the early use of vmbus_requestor from storvsc.  Since
storvsc moved to a tag-based mechanism to generate/retrieve request IDs
with commit bf5fd8cae3c8f ("scsi: storvsc: Use blk_mq_unique_tag() to
generate requestIDs"), the special handling of unsolicited messages in
vmbus_requestor is not useful and can be removed.

Signed-off-by: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
---
 drivers/hv/channel.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

Comments

Michael Kelley (LINUX) March 31, 2022, 6 p.m. UTC | #1
From: Andrea Parri (Microsoft) <parri.andrea@gmail.com> Sent: Monday, March 28, 2022 7:43 AM
> 
> vmbus_requestor has included code for handling unsolicited messages
> since its introduction with commit e8b7db38449ac ("Drivers: hv: vmbus:
> Add vmbus_requestor data structure for VMBus hardening"); such code was
> motivated by the early use of vmbus_requestor from storvsc.  Since
> storvsc moved to a tag-based mechanism to generate/retrieve request IDs
> with commit bf5fd8cae3c8f ("scsi: storvsc: Use blk_mq_unique_tag() to
> generate requestIDs"), the special handling of unsolicited messages in
> vmbus_requestor is not useful and can be removed.
> 
> Signed-off-by: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
> ---
>  drivers/hv/channel.c | 13 +------------
>  1 file changed, 1 insertion(+), 12 deletions(-)
> 
> diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
> index dc5c35210c16a..a253eee3aeb1a 100644
> --- a/drivers/hv/channel.c
> +++ b/drivers/hv/channel.c
> @@ -1243,11 +1243,7 @@ u64 vmbus_next_request_id(struct vmbus_channel
> *channel, u64 rqst_addr)
> 
>  	spin_unlock_irqrestore(&rqstor->req_lock, flags);
> 
> -	/*
> -	 * Cannot return an ID of 0, which is reserved for an unsolicited
> -	 * message from Hyper-V.
> -	 */
> -	return current_id + 1;
> +	return current_id;
>  }
>  EXPORT_SYMBOL_GPL(vmbus_next_request_id);
> 
> @@ -1268,15 +1264,8 @@ u64 vmbus_request_addr(struct vmbus_channel *channel,
> u64 trans_id)
>  	if (!channel->rqstor_size)
>  		return VMBUS_NO_RQSTOR;
> 
> -	/* Hyper-V can send an unsolicited message with ID of 0 */
> -	if (!trans_id)
> -		return trans_id;
> -
>  	spin_lock_irqsave(&rqstor->req_lock, flags);
> 
> -	/* Data corresponding to trans_id is stored at trans_id - 1 */
> -	trans_id--;
> -
>  	/* Invalid trans_id */
>  	if (trans_id >= rqstor->size || !test_bit(trans_id, rqstor->req_bitmap)) {
>  		spin_unlock_irqrestore(&rqstor->req_lock, flags);
> --
> 2.25.1

Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Andrea Parri April 7, 2022, 2:54 a.m. UTC | #2
On Mon, Mar 28, 2022 at 04:42:41PM +0200, Andrea Parri (Microsoft) wrote:
> vmbus_requestor has included code for handling unsolicited messages
> since its introduction with commit e8b7db38449ac ("Drivers: hv: vmbus:
> Add vmbus_requestor data structure for VMBus hardening"); such code was
> motivated by the early use of vmbus_requestor from storvsc.  Since
> storvsc moved to a tag-based mechanism to generate/retrieve request IDs
> with commit bf5fd8cae3c8f ("scsi: storvsc: Use blk_mq_unique_tag() to
> generate requestIDs"), the special handling of unsolicited messages in
> vmbus_requestor is not useful and can be removed.

As it turns out, this is not quite right.  In particular...


> @@ -1243,11 +1243,7 @@ u64 vmbus_next_request_id(struct vmbus_channel *channel, u64 rqst_addr)
>  
>  	spin_unlock_irqrestore(&rqstor->req_lock, flags);
>  
> -	/*
> -	 * Cannot return an ID of 0, which is reserved for an unsolicited
> -	 * message from Hyper-V.
> -	 */
> -	return current_id + 1;
> +	return current_id;

Hyper-V treats requests with ID of 0 as "non-transactional" and it does
not respond to such requests.


> @@ -1268,15 +1264,8 @@ u64 vmbus_request_addr(struct vmbus_channel *channel, u64 trans_id)
>  	if (!channel->rqstor_size)
>  		return VMBUS_NO_RQSTOR;
>  
> -	/* Hyper-V can send an unsolicited message with ID of 0 */
> -	if (!trans_id)
> -		return trans_id;

This remains problematic: I will elaborate and propose some solution in
the next iteration (to be sent shortly).

Thanks,
  Andrea

> -
>  	spin_lock_irqsave(&rqstor->req_lock, flags);
>  
> -	/* Data corresponding to trans_id is stored at trans_id - 1 */
> -	trans_id--;
> -
>  	/* Invalid trans_id */
>  	if (trans_id >= rqstor->size || !test_bit(trans_id, rqstor->req_bitmap)) {
>  		spin_unlock_irqrestore(&rqstor->req_lock, flags);
diff mbox series

Patch

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index dc5c35210c16a..a253eee3aeb1a 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -1243,11 +1243,7 @@  u64 vmbus_next_request_id(struct vmbus_channel *channel, u64 rqst_addr)
 
 	spin_unlock_irqrestore(&rqstor->req_lock, flags);
 
-	/*
-	 * Cannot return an ID of 0, which is reserved for an unsolicited
-	 * message from Hyper-V.
-	 */
-	return current_id + 1;
+	return current_id;
 }
 EXPORT_SYMBOL_GPL(vmbus_next_request_id);
 
@@ -1268,15 +1264,8 @@  u64 vmbus_request_addr(struct vmbus_channel *channel, u64 trans_id)
 	if (!channel->rqstor_size)
 		return VMBUS_NO_RQSTOR;
 
-	/* Hyper-V can send an unsolicited message with ID of 0 */
-	if (!trans_id)
-		return trans_id;
-
 	spin_lock_irqsave(&rqstor->req_lock, flags);
 
-	/* Data corresponding to trans_id is stored at trans_id - 1 */
-	trans_id--;
-
 	/* Invalid trans_id */
 	if (trans_id >= rqstor->size || !test_bit(trans_id, rqstor->req_bitmap)) {
 		spin_unlock_irqrestore(&rqstor->req_lock, flags);