Re: [PATCH] Stop using num_physpages in aacraid

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

 



On Fri, 2008-05-09 at 02:39 -0400, Mark Salyzyn wrote:
> with comment, I had chosen to perform the sizeof check as it optimized  
> out the code on the 32 bit platforms and could have merged the  
> aac_scsi_32_64 and aac_scsi_32 functions (such considerations are my  
> penance for writing peephole optimizers and BIOS code in C/C++). Never  
> sacrifice clarity/maintainability for optimization if you can afford it.

Actually, point taken on the queuecommand check and the lesson in
optimisation.  This should actually be a better optimised version,
getting rid of the check altogether.

James

---

From: James Bottomley <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx>
Subject: [SCSI] aacraid: don't use num_physpages

aacraid uses num_physpages as a check to see if it needs to fail
commands to physical drives which can only be sent as 32 bit fibs for
certain cards (those with AAC_QUIRK_SCSI_32 set).  The correct API for
this is dma_get_required_mask(), so make it use that.  Also tidy up
the 64 bit fib enabling code so we only enable it if the kernel is 64
bit and the dma mask goes over 32 bits (i.e. it has memory above 4GB).

Acked-by: Mark Salyzyn <Mark_Salyzyn@xxxxxxxxxxx>
Signed-off-by: James Bottomley <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx>
---
 drivers/scsi/aacraid/aachba.c |   37 +++++++++++++++++++++++--------------
 1 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index aa4e77c..2cc2c09 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -1204,13 +1204,14 @@ static int aac_scsi_32(struct fib * fib, struct scsi_cmnd * cmd)
 				  (fib_callback) aac_srb_callback, (void *) cmd);
 }
 
+/*
+ * This routine is only used if we have memory > 4GB and the adapter
+ * is one of the quirky ones that can't do dma above 4GB to physical
+ * disks
+ */
 static int aac_scsi_32_64(struct fib * fib, struct scsi_cmnd * cmd)
 {
-	if ((sizeof(dma_addr_t) > 4) &&
-	 (num_physpages > (0xFFFFFFFFULL >> PAGE_SHIFT)) &&
-	 (fib->dev->adapter_info.options & AAC_OPT_SGMAP_HOST64))
-		return FAILED;
-	return aac_scsi_32(fib, cmd);
+	return FAILED;
 }
 
 int aac_get_adapter_info(struct aac_dev* dev)
@@ -1372,16 +1373,29 @@ int aac_get_adapter_info(struct aac_dev* dev)
 		printk(KERN_INFO "%s%d: Non-DASD support enabled.\n",dev->name, dev->id);
 
 	dev->dac_support = 0;
-	if( (sizeof(dma_addr_t) > 4) && (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64)){
+	dev->a_ops.adapter_scsi = aac_scsi_32;
+	if ((dma_get_required_mask(&dev->pdev->dev) > DMA_32BIT_MASK
+	     && (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64)
+	     && dacmode == -1) ||
+	    dacmode == 1) {
 		if (!dev->in_reset)
 			printk(KERN_INFO "%s%d: 64bit support enabled.\n",
 				dev->name, dev->id);
 		dev->dac_support = 1;
-	}
+		dev->a_ops.adapter_scsi = aac_scsi_64;
 
-	if(dacmode != -1) {
-		dev->dac_support = (dacmode!=0);
+		/*
+		 * Adapters with AAC_QUIRK_SCSI_32 can only send pass
+		 * through commands as 32 bit fibs (although they can
+		 * send RAID commands as 64 bit fibs) flag these here
+		 * so we fail direct SCSI commands in the special
+		 * aac_scsi_32_64 routine
+		 */
+		if (aac_get_driver_ident(dev->cardtype)->quirks
+		    & AAC_QUIRK_SCSI_32)
+			dev->a_ops.adapter_scsi = aac_scsi_32_64;
 	}
+
 	if(dev->dac_support != 0) {
 		if (!pci_set_dma_mask(dev->pdev, DMA_64BIT_MASK) &&
 			!pci_set_consistent_dma_mask(dev->pdev, DMA_64BIT_MASK)) {
@@ -1403,11 +1417,6 @@ int aac_get_adapter_info(struct aac_dev* dev)
 	 * Deal with configuring for the individualized limits of each packet
 	 * interface.
 	 */
-	dev->a_ops.adapter_scsi = (dev->dac_support)
-	  ? ((aac_get_driver_ident(dev->cardtype)->quirks & AAC_QUIRK_SCSI_32)
-				? aac_scsi_32_64
-				: aac_scsi_64)
-				: aac_scsi_32;
 	if (dev->raw_io_interface) {
 		dev->a_ops.adapter_bounds = (dev->raw_io_64)
 					? aac_bounds_64
-- 
1.5.4.1



--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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