All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <jejb@linux.vnet.ibm.com>
To: Alexey Khoroshilov <khoroshilov@ispras.ru>,
	Ondrej Zary <linux@rainbow-software.org>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	ldv-project@linuxtesting.org
Subject: Re: [PATCH] wd719x: add check for dma mapping errors
Date: Fri, 27 Jan 2017 14:53:05 -0800	[thread overview]
Message-ID: <1485557585.3229.28.camel@linux.vnet.ibm.com> (raw)
In-Reply-To: <1485556252-10888-1-git-send-email-khoroshilov@ispras.ru>

On Sat, 2017-01-28 at 01:30 +0300, Alexey Khoroshilov wrote:
> wd719x_queuecommand() doesn't check if mapping dma memory succeed.
> The patch adds the check and failure handling.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
>  drivers/scsi/wd719x.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c
> index 2a9da2e0ea6b..41ddbdcf02e0 100644
> --- a/drivers/scsi/wd719x.c
> +++ b/drivers/scsi/wd719x.c
> @@ -244,6 +244,12 @@ static int wd719x_queuecommand(struct Scsi_Host
> *sh, struct scsi_cmnd *cmd)
>  	scb->sense_buf_length = SCSI_SENSE_BUFFERSIZE;
>  	cmd->SCp.dma_handle = dma_map_single(&wd->pdev->dev, cmd
> ->sense_buffer,
>  			SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
> +	if (dma_mapping_error(&wd->pdev->dev, cmd->SCp.dma_handle))
> {
> +		dev_err(&wd->pdev->dev, "unable to map dma\n");
> +		wd719x_finish_cmd(cmd, DID_ERROR);
> +		spin_unlock_irqrestore(wd->sh->host_lock, flags);
> +		return 0;
> +	}

I'm not at all convinced of the wisdom of doing this for an ancient
driver: this thing is presumably x86 and ancient in which case it will
never fail anyway.

However, for the future, a mapping error is transient, meaning we want
the command retried, not errored, so from queuecommand you return
 SCSI_MLQUEUE_HOST_BUSY to induce a pause and retry.

James

      reply	other threads:[~2017-01-27 22:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-27 22:30 [PATCH] wd719x: add check for dma mapping errors Alexey Khoroshilov
2017-01-27 22:53 ` James Bottomley [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=1485557585.3229.28.camel@linux.vnet.ibm.com \
    --to=jejb@linux.vnet.ibm.com \
    --cc=khoroshilov@ispras.ru \
    --cc=ldv-project@linuxtesting.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux@rainbow-software.org \
    --cc=martin.petersen@oracle.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.