Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1568774

Re: [PATCH] wd719x: add check for dma mapping errors

Path csiph.com!news.freedyn.net!open-news-network.org!aioe.org!bofh.it!news.nic.it!robomod
From James Bottomley <jejb@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject Re: [PATCH] wd719x: add check for dma mapping errors
Date Sat, 28 Jan 2017 00:00:02 +0100
Message-ID <t4nES-1F5-9@gated-at.bofh.it> (permalink)
References <t4nvc-1BT-21@gated-at.bofh.it>
X-Original-To Alexey Khoroshilov <khoroshilov@ispras.ru>, Ondrej Zary <linux@rainbow-software.org>, "Martin K. Petersen" <martin.petersen@oracle.com>
Content-Type text/plain; charset="UTF-8"
X-Mailer Evolution 3.16.5
MIME-Version 1.0
Content-Transfer-Encoding 7bit
X-Tm-As-Gconf 00
X-Content-Scanned Fidelis XPS MAILER
X-Cbid 17012722-0040-0000-0000-0000027A80AC
X-Ibm-Spammodules-Versions BY=3.00006509; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000201; SDB=6.00813641; UDB=6.00396941; IPR=6.00591056; BA=6.00005093; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014078; XFM=3.00000011; UTC=2017-01-27 22:53:10
X-Ibm-Av-Detection SAVI=unused REMOTE=unused XFE=unused
X-Cbparentid 17012722-0041-0000-0000-0000066D8353
X-Proofpoint-Virus-Version vendor=fsecure engine=2.50.10432:,, definitions=2017-01-27_16:,, signatures=0
X-Proofpoint-Spam-Details rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=21 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1701270220
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 38
Organization linux.* mail to news gateway
X-Original-Cc linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org
X-Original-Date Fri, 27 Jan 2017 14:53:05 -0800
X-Original-Message-ID <1485557585.3229.28.camel@linux.vnet.ibm.com>
X-Original-References <1485556252-10888-1-git-send-email-khoroshilov@ispras.ru>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1568774

Show key headers only | View raw


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

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

[PATCH] wd719x: add check for dma mapping errors Alexey Khoroshilov <khoroshilov@ispras.ru> - 2017-01-27 23:50 +0100
  Re: [PATCH] wd719x: add check for dma mapping errors James Bottomley <jejb@linux.vnet.ibm.com> - 2017-01-28 00:00 +0100

csiph-web