Skip to contentSkip to conversation

qla1280: user pci_map_single

PATCH In review Christoph Hellwig 2 participants 4 messages Feb 10, 2005 – Feb 25, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/3 qla1280: user pci_map_single

drivers/scsi/qla1280.c +12 -20
@@ -1571,16 +1465,12 @@ qla1280_done(struct scsi_qla_host *ha)
 
 		/* Release memory used for this I/O */
 		if (cmd->use_sg) {
-			dprintk(3, "S/G unmap_sg cmd=%p\n", cmd);
-
 			pci_unmap_sg(ha->pdev, cmd->request_buffer,
-				     cmd->use_sg, cmd->sc_data_direction);
+					cmd->use_sg, cmd->sc_data_direction);
 		} else if (cmd->request_bufflen) {
-			/*dprintk(1, "No S/G unmap_single cmd=%x saved_dma_handle=%lx\n",
-			  cmd, sp->saved_dma_handle); */
-
-			pci_unmap_page(ha->pdev, sp->saved_dma_handle,
-				       cmd->request_bufflen, cmd->sc_data_direction);
+			pci_unmap_single(ha->pdev, sp->saved_dma_handle,
+					cmd->request_bufflen,
+					cmd->sc_data_direction);
 		}
 
 		/* Call the mid-level driver interrupt handler */
@@ -3354,14 +3244,11 @@ qla1280_64bit_start_scsi(struct scsi_qla
 						    REQUEST_ENTRY_SIZE);
 			}
 		} else {	/* No scatter gather data transfer */
-			struct page *page = virt_to_page(cmd->request_buffer);
-			unsigned long off = (unsigned long)cmd->request_buffer & ~PAGE_MASK;
-
-			dma_handle = pci_map_page(ha->pdev, page, off,
-						  cmd->request_bufflen,
-						  cmd->sc_data_direction);
+			dma_handle = pci_map_single(ha->pdev,
+					cmd->request_buffer,
+					cmd->request_bufflen,
+					cmd->sc_data_direction);
 
-			/* save dma_handle for pci_unmap_page */
 			sp->saved_dma_handle = dma_handle;
 #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2)
 			if (ha->flags.use_pci_vchannel)
@@ -3636,11 +3523,10 @@ qla1280_32bit_start_scsi(struct scsi_qla
 						    REQUEST_ENTRY_SIZE);
 			}
 		} else {	/* No S/G data transfer */
-			struct page *page = virt_to_page(cmd->request_buffer);
-			unsigned long off = (unsigned long)cmd->request_buffer & ~PAGE_MASK;
-			dma_handle = pci_map_page(ha->pdev, page, off,
-						  cmd->request_bufflen,
-						  cmd->sc_data_direction);
+			dma_handle = pci_map_single(ha->pdev,
+					cmd->request_buffer,
+					cmd->request_bufflen,
+					cmd->sc_data_direction);
 			sp->saved_dma_handle = dma_handle;
 
 			*dword_ptr++ = cpu_to_le32(pci_dma_lo32(dma_handle));
#1 lore raw

Christoph,

When pci_map_page was originally introduced it was meant to deprecate pci_map_single, at least thats what my memory tells me.

If pci_map_single is suddenly recommended again we can change it back to that, but I don't really see the gain.

Cheers,
Jes

#2 lore raw
Quoted 4 lines · Jes Sorensen

Christoph,

When pci_map_page was originally introduced it was meant to deprecate pci_map_single, at least thats what my memory tells me.

No, it's for rather different uses. pci_map_page would be nice to get rid of in favour of pci_map_sg OTOH..

Quoted 2 lines

If pci_map_single is suddenly recommended again we can change it back to that, but I don't really see the gain.

it's a micro-speedup by avoiding totally useless address arithmetics. You first convert a buffer to page + offset and then it needs to be converted back, e.g. in include/asm-ia64/dma-mapping.h:

#define dma_map_page(dev, pg, off, size, dir)			\
        dma_map_single(dev, page_address(pg) + (off), (size), (dir))

(pci_map_page is mapped to dma_map_page)

#3 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Christoph" == Christoph Hellwig <[email protected]> writes:

Christoph> On Fri, Feb 18, 2005 at 04:48:00AM -0500, Jes Sorensen

Quoted 4 lines · Christoph> wrote:
Quoted 4 lines

Christoph,

When pci_map_page was originally introduced it was meant to deprecate pci_map_single, at least thats what my memory tells me.

Christoph> No, it's for rather different uses. pci_map_page would be Christoph> nice to get rid of in favour of pci_map_sg OTOH..

I guess things have changed a bit since it was introduced. Anyway go ahead and push the patch.

Cheers,
Jes