stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ewan D. Milne" <emilne@redhat.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org,
	stable@vger.kernel.org, james.smart@broadcom.com,
	dick.kennedy@broadcom.com, martin.petersen@oracle.com,
	jejb@linux.ibm.com
Subject: Re: [PATCH] scsi: lpfc: fix calls to dma_set_mask_and_coherent()
Date: Tue, 12 Feb 2019 10:37:45 -0500	[thread overview]
Message-ID: <9572ae3b0131ad1c74d6a775f819437e3d4f1795.camel@redhat.com> (raw)
In-Reply-To: <20190212080627.GC10547@infradead.org>

On Tue, 2019-02-12 at 00:06 -0800, Christoph Hellwig wrote:
> On Mon, Feb 11, 2019 at 10:05:02AM -0500, Ewan D. Milne wrote:
> > The change to use dma_set_mask_and_coherent() incorrectly made a second
> > call with the 32 bit DMA mask value when the call with the 64 bit DMA
> > mask value succeeded.  This resulted in NVMe/FC connections failing due
> > to corrupted data buffers, and various other SCSI/FCP I/O errors.
> 
> Ooops, sorry.
> 
> >  	/* Set the device DMA mask size */
> > -	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
> > -	    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))
> > -		return error;
> > +	if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) != 0)
> > +		if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)) != 0)
> 
> But this still looks obsfuctating, why not:
> 
> 	error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
> 	if (error)
> 		error = dma_set_mask_and_coherent(&pdev->dev,
> 				DMA_BIT_MASK(32)));
> 	if (error)
> 		return error;

I agree that making the flow of control explicit would be good, but...

It looks like this would introduce a different problem.  "error" is set to
-ENODEV earlier in the two functions so that the various error paths will return
that value.  If it is overwritten with a successful result from the call to
dma_set_mask_and_coherent() but a later call to e.g. ioremap() fails, the
functions will incorrectly return a value indicating that they have succeeded.

It also appears as if the patches to hptiop, hisi_sas and bfa need to be fixed up.
I don't have a test environment for these, although I might be able to modify the
test environment for bfa.  Martin/James, what about the others?

-Ewan


  reply	other threads:[~2019-02-12 15:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-11 15:05 [PATCH] scsi: lpfc: fix calls to dma_set_mask_and_coherent() Ewan D. Milne
2019-02-11 19:19 ` James Smart
2019-02-12  8:06 ` Christoph Hellwig
2019-02-12 15:37   ` Ewan D. Milne [this message]
2019-02-12 18:34     ` Christoph Hellwig
2019-02-13  3:10     ` Martin K. Petersen
2019-02-13  9:18       ` John Garry

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=9572ae3b0131ad1c74d6a775f819437e3d4f1795.camel@redhat.com \
    --to=emilne@redhat.com \
    --cc=dick.kennedy@broadcom.com \
    --cc=hch@infradead.org \
    --cc=james.smart@broadcom.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=stable@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).