Re: [PATCHv2 2/2] ibmvscsi: Add memory barriers for send / receive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx>

Acked-by: Nathan Fontenot <nfont@xxxxxxxxxxxxxxxxxx>

> ---
> 
>  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);
>  }
> 
> _
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux