Re: [PATCH 5/5] esp_scsi: move dma mapping into the core code

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

 



On Thu, 11 Oct 2018, Christoph Hellwig wrote:

> diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
> index 90604bff8dd2..73fcbd65b9fe 100644
> --- a/drivers/scsi/esp_scsi.c
> +++ b/drivers/scsi/esp_scsi.c
> @@ -369,19 +369,25 @@ static void esp_map_dma(struct esp *esp, struct scsi_cmnd *cmd)
>  {
>  	struct esp_cmd_priv *spriv = ESP_CMD_PRIV(cmd);
>  	struct scatterlist *sg = scsi_sglist(cmd);
> -	int dir = cmd->sc_data_direction;
> -	int total, i;
> +	int total = 0, i;
>  
> -	if (dir == DMA_NONE)
> -		return;
> -

Removing this DMA_NONE test caused an oops in my test. sg becomes a NULL 
pointer.

> -	spriv->u.num_sg = esp->ops->map_sg(esp, sg, scsi_sg_count(cmd), dir);

Does anyone happen to know whether the union 'u' serves any purpose?

-- 

> +	if (esp->flags & ESP_FLAG_NO_DMA_MAP) {
> +		/*
> +		 * For pseudo DMA and PIO we need the virtual address instead of
> +		 * a dma address, so perform an identity mapping.
> +		 */
> +		spriv->u.num_sg = scsi_sg_count(cmd);
> +		for (i = 0; i < spriv->u.num_sg; i++) {
> +			sg[i].dma_address = (uintptr_t)sg_virt(&sg[i]);
> +			total += sg_dma_len(&sg[i]);
> +		}
> +	} else {
> +		spriv->u.num_sg = scsi_dma_map(cmd);
> +		for (i = 0; i < spriv->u.num_sg; i++)
> +			total += sg_dma_len(&sg[i]);
> +	}
>  	spriv->cur_residue = sg_dma_len(sg);
>  	spriv->cur_sg = sg;
> -
> -	total = 0;
> -	for (i = 0; i < spriv->u.num_sg; i++)
> -		total += sg_dma_len(&sg[i]);
>  	spriv->tot_residue = total;
>  }
>  



[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