Re: [PATCH 4/4] gdth: use generic DMA API

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

 



On Fri, Oct 19, 2018 at 09:42:28AM +1100, Finn Thain wrote:
> On Thu, 18 Oct 2018, Christoph Hellwig wrote:
> 
> > Switch from the legacy PCI DMA API to the generic DMA API.  Also switch
> > to dma_map_single from pci_map_page in one case where this makes the code
> > simpler.
> > 
> > Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> > ---
> >  drivers/scsi/gdth.c      | 111 +++++++++++++++++++--------------------
> >  drivers/scsi/gdth_proc.c |   4 +-
> >  2 files changed, 56 insertions(+), 59 deletions(-)
> > 
> > diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
> > index 7274d09b2a6c..3d856554b1b1 100644
> > --- a/drivers/scsi/gdth.c
> > +++ b/drivers/scsi/gdth.c
> > @@ -2518,9 +2518,9 @@ static int gdth_fill_cache_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp,
> >  
> >          if (scsi_bufflen(scp)) {
> >              cmndinfo->dma_dir = (read_write == 1 ?
> > -                PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);   
> > -            sgcnt = pci_map_sg(ha->pdev, scsi_sglist(scp), scsi_sg_count(scp),
> > -                               cmndinfo->dma_dir);
> > +                DMA_TO_DEVICE : DMA_FROM_DEVICE);   
> > +            sgcnt = dma_map_sg(&ha->pdev->dev, scsi_sglist(scp),
> > +			       scsi_sg_count(scp), cmndinfo->dma_dir);
> >              if (mode64) {
> >                  struct scatterlist *sl;
> >  
> > @@ -2603,8 +2603,6 @@ static int gdth_fill_raw_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp, u8 b)
> >      dma_addr_t sense_paddr;
> >      int cmd_index, sgcnt, mode64;
> >      u8 t,l;
> > -    struct page *page;
> > -    unsigned long offset;
> >      struct gdth_cmndinfo *cmndinfo;
> >  
> >      t = scp->device->id;
> > @@ -2649,10 +2647,8 @@ static int gdth_fill_raw_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp, u8 b)
> >          }
> >  
> >      } else {
> > -        page = virt_to_page(scp->sense_buffer);
> > -        offset = (unsigned long)scp->sense_buffer & ~PAGE_MASK;
> > -        sense_paddr = pci_map_page(ha->pdev,page,offset,
> > -                                   16,PCI_DMA_FROMDEVICE);
> > +        sense_paddr = dma_map_single(&ha->pdev->dev, scp->sense_buffer, 16,
> > +				     DMA_FROM_DEVICE);
> >  
> >  	cmndinfo->sense_paddr  = sense_paddr;
> >          cmdp->OpCode           = GDT_WRITE;             /* always */
> > @@ -2693,9 +2689,9 @@ static int gdth_fill_raw_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp, u8 b)
> >          }
> >  
> >          if (scsi_bufflen(scp)) {
> > -            cmndinfo->dma_dir = PCI_DMA_BIDIRECTIONAL;
> > -            sgcnt = pci_map_sg(ha->pdev, scsi_sglist(scp), scsi_sg_count(scp),
> > -                               cmndinfo->dma_dir);
> > +            cmndinfo->dma_dir = DMA_BIDIRECTIONAL;
> > +            sgcnt = dma_map_sg(&ha->pdev->dev, scsi_sglist(scp),
> > +			       scsi_sg_count(scp), cmndinfo->dma_dir);
> >              if (mode64) {
> >                  struct scatterlist *sl;
> >  
> > @@ -3313,12 +3309,12 @@ static int gdth_sync_event(gdth_ha_str *ha, int service, u8 index,
> >              return 2;
> >          }
> >          if (scsi_bufflen(scp))
> > -            pci_unmap_sg(ha->pdev, scsi_sglist(scp), scsi_sg_count(scp),
> > +            dma_unmap_sg(&ha->pdev->dev, scsi_sglist(scp), scsi_sg_count(scp),
> >                           cmndinfo->dma_dir);
> >  
> >          if (cmndinfo->sense_paddr)
> > -            pci_unmap_page(ha->pdev, cmndinfo->sense_paddr, 16,
> > -                                                           PCI_DMA_FROMDEVICE);
> > +            dma_unmap_page(&ha->pdev->dev, cmndinfo->sense_paddr, 16,
> > +	    		   DMA_FROM_DEVICE);
> >  
> >          if (ha->status == S_OK) {
> >              cmndinfo->status = S_OK;
> > @@ -4251,8 +4247,8 @@ static int ioc_general(void __user *arg, char *cmnd)
> >  	if (gen.data_len + gen.sense_len == 0)
> >  		goto execute;
> >  
> > -        buf = pci_alloc_consistent(ha->pdev, gen.data_len + gen.sense_len,
> > -			&paddr);
> > +        buf = dma_alloc_coherent(&ha->pdev->dev, gen.data_len + gen.sense_len,
> > +			&paddr, GFP_KERNEL);
> >  	if (!buf)
> >  		return -EFAULT;
> >  
> > @@ -4292,7 +4288,8 @@ static int ioc_general(void __user *arg, char *cmnd)
> >  
> >  	rval = 0;
> >  out_free_buf:
> > -	pci_free_consistent(ha->pdev, gen.data_len + gen.sense_len, buf, paddr);
> > +	dma_free_coherent(&ha->pdev->dev, gen.data_len + gen.sense_len, buf,
> > +			paddr);
> >  	return 0;
> >  }
> >   
> > @@ -4749,22 +4746,22 @@ static int __init gdth_isa_probe_one(u32 isa_bios)
> >  
> >  	error = -ENOMEM;
> >  
> > -	ha->pscratch = pci_alloc_consistent(ha->pdev, GDTH_SCRATCH,
> > -						&scratch_dma_handle);
> > +	ha->pscratch = dma_alloc_coherent(&ha->pdev->dev, GDTH_SCRATCH,
> > +				&scratch_dma_handle, GFP_KERNEL);
> >  	if (!ha->pscratch)
> >  		goto out_dec_counters;
> >  	ha->scratch_phys = scratch_dma_handle;
> >  
> > -	ha->pmsg = pci_alloc_consistent(ha->pdev, sizeof(gdth_msg_str),
> > -						&scratch_dma_handle);
> > +	ha->pmsg = dma_alloc_coherent(&ha->pdev->dev, sizeof(gdth_msg_str),
> > +				&scratch_dma_handle, GFP_KERNEL);
> >  	if (!ha->pmsg)
> >  		goto out_free_pscratch;
> >  	ha->msg_phys = scratch_dma_handle;
> >  
> >  #ifdef INT_COAL
> > -	ha->coal_stat = pci_alloc_consistent(ha->pdev,
> > +	ha->coal_stat = dma_alloc_coherent(&ha->pdev->dev,
> >  				sizeof(gdth_coal_status) * MAXOFFSETS,
> > -				&scratch_dma_handle);
> > +				&scratch_dma_handle, GFP_KERNEL);
> >  	if (!ha->coal_stat)
> >  		goto out_free_pmsg;
> >  	ha->coal_stat_phys = scratch_dma_handle;
> > @@ -4811,14 +4808,14 @@ static int __init gdth_isa_probe_one(u32 isa_bios)
> >  
> >   out_free_coal_stat:
> >  #ifdef INT_COAL
> > -	pci_free_consistent(ha->pdev, sizeof(gdth_coal_status) * MAXOFFSETS,
> > +	dma_free_coherent(&ha->pdev->dev, sizeof(gdth_coal_status) * MAXOFFSETS,
> >  				ha->coal_stat, ha->coal_stat_phys);
> >   out_free_pmsg:
> >  #endif
> > -	pci_free_consistent(ha->pdev, sizeof(gdth_msg_str),
> > +	dma_free_coherent(&ha->pdev->dev, sizeof(gdth_msg_str),
> >  				ha->pmsg, ha->msg_phys);
> >   out_free_pscratch:
> > -	pci_free_consistent(ha->pdev, GDTH_SCRATCH,
> > +	dma_free_coherent(&ha->pdev->dev, GDTH_SCRATCH,
> >  				ha->pscratch, ha->scratch_phys);
> >   out_dec_counters:
> >  	gdth_ctr_count--;
> > @@ -4875,29 +4872,29 @@ static int __init gdth_eisa_probe_one(u16 eisa_slot)
> >  	error = -ENOMEM;
> >  
> >  	ha->pdev = NULL;
> > -	ha->pscratch = pci_alloc_consistent(ha->pdev, GDTH_SCRATCH,
> > -						&scratch_dma_handle);
> > +	ha->pscratch = dma_alloc_coherent(&ha->pdev->dev, GDTH_SCRATCH,
> > +				&scratch_dma_handle, GFP_KERNEL);
> >  	if (!ha->pscratch)
> >  		goto out_free_irq;
> >  	ha->scratch_phys = scratch_dma_handle;
> >  
> > -	ha->pmsg = pci_alloc_consistent(ha->pdev, sizeof(gdth_msg_str),
> > -						&scratch_dma_handle);
> > +	ha->pmsg = dma_alloc_coherent(&ha->pdev->dev, sizeof(gdth_msg_str),
> > +				&scratch_dma_handle, GFP_KERNEL);
> >  	if (!ha->pmsg)
> >  		goto out_free_pscratch;
> >  	ha->msg_phys = scratch_dma_handle;
> >  
> >  #ifdef INT_COAL
> > -	ha->coal_stat = pci_alloc_consistent(ha->pdev,
> > +	ha->coal_stat = dma_alloc_coherent(&ha->pdev->dev,
> >  			sizeof(gdth_coal_status) * MAXOFFSETS,
> > -			&scratch_dma_handle);
> > +			&scratch_dma_handle, GFP_KERNEL);
> >  	if (!ha->coal_stat)
> >  		goto out_free_pmsg;
> >  	ha->coal_stat_phys = scratch_dma_handle;
> >  #endif
> >  
> > -	ha->ccb_phys = pci_map_single(ha->pdev,ha->pccb,
> > -			sizeof(gdth_cmd_str), PCI_DMA_BIDIRECTIONAL);
> > +	ha->ccb_phys = dma_map_single(&ha->pdev->dev, ha->pccb,
> > +			sizeof(gdth_cmd_str), DMA_BIDIRECTIONAL);
> >  	if (!ha->ccb_phys)
> >  		goto out_free_coal_stat;
> >  
> > @@ -4941,18 +4938,18 @@ static int __init gdth_eisa_probe_one(u16 eisa_slot)
> >  	return 0;
> >  
> >   out_free_ccb_phys:
> > -	pci_unmap_single(ha->pdev,ha->ccb_phys, sizeof(gdth_cmd_str),
> > -			PCI_DMA_BIDIRECTIONAL);
> > +	dma_unmap_single(&ha->pdev->dev, ha->ccb_phys, sizeof(gdth_cmd_str),
> > +			DMA_BIDIRECTIONAL);
> >   out_free_coal_stat:
> >  #ifdef INT_COAL
> > -	pci_free_consistent(ha->pdev, sizeof(gdth_coal_status) * MAXOFFSETS,
> > +	dma_free_coherent(&ha->pdev->dev, sizeof(gdth_coal_status) * MAXOFFSETS,
> >  				ha->coal_stat, ha->coal_stat_phys);
> >   out_free_pmsg:
> >  #endif
> > -	pci_free_consistent(ha->pdev, sizeof(gdth_msg_str),
> > +	dma_free_coherent(&ha->pdev->dev, sizeof(gdth_msg_str),
> >  				ha->pmsg, ha->msg_phys);
> >   out_free_pscratch:
> > -	pci_free_consistent(ha->pdev, GDTH_SCRATCH,
> > +	dma_free_coherent(&ha->pdev->dev, GDTH_SCRATCH,
> >  				ha->pscratch, ha->scratch_phys);
> >   out_free_irq:
> >  	free_irq(ha->irq, ha);
> > @@ -5008,22 +5005,22 @@ static int gdth_pci_probe_one(gdth_pci_str *pcistr, gdth_ha_str **ha_out)
> >  
> >  	error = -ENOMEM;
> >  
> > -	ha->pscratch = pci_alloc_consistent(ha->pdev, GDTH_SCRATCH,
> > -						&scratch_dma_handle);
> > +	ha->pscratch = dma_alloc_coherent(&ha->pdev->dev, GDTH_SCRATCH,
> > +				&scratch_dma_handle, GFP_KERNEL);
> >  	if (!ha->pscratch)
> >  		goto out_free_irq;
> >  	ha->scratch_phys = scratch_dma_handle;
> >  
> > -	ha->pmsg = pci_alloc_consistent(ha->pdev, sizeof(gdth_msg_str),
> > -					&scratch_dma_handle);
> > +	ha->pmsg = dma_alloc_coherent(&ha->pdev->dev, sizeof(gdth_msg_str),
> > +				&scratch_dma_handle, GFP_KERNEL);
> >  	if (!ha->pmsg)
> >  		goto out_free_pscratch;
> >  	ha->msg_phys = scratch_dma_handle;
> >  
> >  #ifdef INT_COAL
> > -	ha->coal_stat = pci_alloc_consistent(ha->pdev,
> > +	ha->coal_stat = dma_alloc_coherent(&ha->pdev->dev,
> >  			sizeof(gdth_coal_status) * MAXOFFSETS,
> > -			&scratch_dma_handle);
> > +			&scratch_dma_handle, GFP_KERNEL
> >  	if (!ha->coal_stat)
> >  		goto out_free_pmsg;
> >  	ha->coal_stat_phys = scratch_dma_handle;
> 
> Missing closing parenthesis and semi-colon.

Indeed.  But this code is entirely dead and can't be compiled,
so I've just added a new patch to just remove it.



[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