linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Fontenot <nfont@linux.vnet.ibm.com>
To: Brian King <brking@linux.vnet.ibm.com>,
	James.Bottomley@HansenPartnership.com
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCHv2 2/2] ibmvscsi: Add memory barriers for send / receive
Date: Tue, 27 May 2014 08:56:04 -0500	[thread overview]
Message-ID: <53849974.2060402@linux.vnet.ibm.com> (raw)
In-Reply-To: <201405231552.s4NFqB4h028030@d01av01.pok.ibm.com>

On 05/23/2014 10:52 AM, Brian King wrote:
> Add a memory barrier prior to sending a new command to the VIOS
> to ensure the VIOS does not receive stale data in the command buffer.
> Also add a memory barrier when processing the CRQ for completed commands.
> 
> Signed-off-by: Brian King <brking@linux.vnet.ibm.com>

Acked-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>

> ---
> 
>  drivers/scsi/ibmvscsi/ibmvscsi.c |   10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff -puN drivers/scsi/ibmvscsi/ibmvscsi.c~ibmvscsi_barrier drivers/scsi/ibmvscsi/ibmvscsi.c
> --- linux/drivers/scsi/ibmvscsi/ibmvscsi.c~ibmvscsi_barrier	2014-05-23 10:41:35.000000000 -0500
> +++ linux-bjking1/drivers/scsi/ibmvscsi/ibmvscsi.c	2014-05-23 10:42:53.000000000 -0500
> @@ -185,6 +185,11 @@ static struct viosrp_crq *crq_queue_next
>  	if (crq->valid & 0x80) {
>  		if (++queue->cur == queue->size)
>  			queue->cur = 0;
> +
> +		/* Ensure the read of the valid bit occurs before reading any
> +		 * other bits of the CRQ entry
> +		 */
> +		rmb();
>  	} else
>  		crq = NULL;
>  	spin_unlock_irqrestore(&queue->lock, flags);
> @@ -203,6 +208,11 @@ static int ibmvscsi_send_crq(struct ibmv
>  {
>  	struct vio_dev *vdev = to_vio_dev(hostdata->dev);
> 
> +	/*
> +	 * Ensure the command buffer is flushed to memory before handing it
> +	 * over to the VIOS to prevent it from fetching any stale data.
> +	 */
> +	mb();
>  	return plpar_hcall_norets(H_SEND_CRQ, vdev->unit_address, word1, word2);
>  }
> 
> _
> 


      reply	other threads:[~2014-05-27 13:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-23 15:52 [PATCHv2 2/2] ibmvscsi: Add memory barriers for send / receive Brian King
2014-05-27 13:56 ` Nathan Fontenot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53849974.2060402@linux.vnet.ibm.com \
    --to=nfont@linux.vnet.ibm.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=brking@linux.vnet.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).