[PATCH][SCSI] resend: hptiop: add more adapter models and other fixes

2007-12-11 Thread HighPoint Linux Team
this patch is against 2.6.24-rc4-mm1. last one was made agaist 2.6.24-rc5 so it 
does
not compile in the -mm tree.

Most code changes were made to support adapters based on Marvell IOP, plus some
other fixes.

- add more PCI device IDs
- support for adapters based on Marvell IOP
- fix a result code translation error on big-endian systems
- fix resource releasing bug when scsi_host_alloc() fail in hptiop_probe()
- update scsi_cmnd.resid when finishing a request
- correct some coding style issues

Signed-off-by: HighPoint Linux Team <[EMAIL PROTECTED]>
---

 Documentation/scsi/hptiop.txt |   30 ++-
 drivers/scsi/Kconfig  |4 +-
 drivers/scsi/hptiop.c |  587 -
 drivers/scsi/hptiop.h |  101 ++--
 4 files changed, 567 insertions(+), 155 deletions(-)

diff --git a/Documentation/scsi/hptiop.txt b/Documentation/scsi/hptiop.txt
index d28a312..a6eb4ad 100644
--- a/Documentation/scsi/hptiop.txt
+++ b/Documentation/scsi/hptiop.txt
@@ -1,9 +1,9 @@
-HIGHPOINT ROCKETRAID 3xxx RAID DRIVER (hptiop)
+HIGHPOINT ROCKETRAID 3xxx/4xxx ADAPTER DRIVER (hptiop)
 
 Controller Register Map
 -
 
-The controller IOP is accessed via PCI BAR0.
+For Intel IOP based adapters, the controller IOP is accessed via PCI BAR0:
 
  BAR0 offsetRegister
 0x10Inbound Message Register 0
@@ -18,6 +18,24 @@ The controller IOP is accessed via PCI BAR0.
 0x40Inbound Queue Port
 0x44Outbound Queue Port
 
+For Marvell IOP based adapters, the IOP is accessed via PCI BAR0 and BAR1:
+
+ BAR0 offsetRegister
+ 0x20400Inbound Doorbell Register
+ 0x20404Inbound Interrupt Mask Register
+ 0x20408Outbound Doorbell Register
+ 0x2040COutbound Interrupt Mask Register
+
+ BAR1 offsetRegister
+ 0x0Inbound Queue Head Pointer
+ 0x4Inbound Queue Tail Pointer
+ 0x8Outbound Queue Head Pointer
+ 0xCOutbound Queue Tail Pointer
+0x10Inbound Message Register
+0x14Outbound Message Register
+ 0x40-0x1040Inbound Queue
+   0x1040-0x2040Outbound Queue
+
 
 I/O Request Workflow
 --
@@ -73,15 +91,9 @@ The driver exposes following sysfs attributes:
  driver-versionR driver version string
  firmware-version  R firmware version string
 
-The driver registers char device "hptiop" to communicate with HighPoint RAID
-management software. Its ioctl routine acts as a general binary interface 
-between the IOP firmware and HighPoint RAID management software. New management
-functions can be implemented in application/firmware without modification
-in driver code.
-
 
 -
-Copyright (C) 2006 HighPoint Technologies, Inc. All Rights Reserved.
+Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
 
   This file is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index becbb09..e397599 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -573,10 +573,10 @@ config SCSI_ARCMSR_AER
 source "drivers/scsi/megaraid/Kconfig.megaraid"
 
 config SCSI_HPTIOP
-   tristate "HighPoint RocketRAID 3xxx Controller support"
+   tristate "HighPoint RocketRAID 3xxx/4xxx Controller support"
depends on SCSI && PCI
help
- This option enables support for HighPoint RocketRAID 3xxx
+ This option enables support for HighPoint RocketRAID 3xxx/4xxx
  controllers.
 
  To compile this driver as a module, choose M here; the module
diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
index 7fc532b..7febfd5 100644
--- a/drivers/scsi/hptiop.c
+++ b/drivers/scsi/hptiop.c
@@ -1,5 +1,5 @@
 /*
- * HighPoint RR3xxx controller driver for Linux
+ * HighPoint RR3xxx/4xxx controller driver for Linux
  * Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify
@@ -38,80 +38,84 @@
 #include "hptiop.h"
 
 MODULE_AUTHOR("HighPoint Technologies, Inc.");
-MODULE_DESCRIPTION("HighPoint RocketRAID 3xxx SATA Controller Driver");
+MODULE_DESCRIPTION("HighPoint RocketRAID 3xxx/4xxx Controller Driver");
 
 static char driver_name[] = "hptiop";
-static const char driver_name_long[] = "RocketRAID 3xxx SATA Controller 
driver";
-static const char driver_ver[] = "v1.2 (070830)";
-
-static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 tag);
-static void hptiop_iop_request_callback(struct hptiop_hba *hba, u32 tag);
+static const char driver_name_long[] = "RocketRAID 3xxx/4x

[PATCH][SCSI] resend: hptiop: add more adapter models and other fixes

2007-12-11 Thread HighPoint Linux Team
this patch is against 2.6.24-rc4-mm1. last one was made agaist 2.6.24-rc5 so it 
does
not compile in the -mm tree.

Most code changes were made to support adapters based on Marvell IOP, plus some
other fixes.

- add more PCI device IDs
- support for adapters based on Marvell IOP
- fix a result code translation error on big-endian systems
- fix resource releasing bug when scsi_host_alloc() fail in hptiop_probe()
- update scsi_cmnd.resid when finishing a request
- correct some coding style issues

Signed-off-by: HighPoint Linux Team [EMAIL PROTECTED]
---

 Documentation/scsi/hptiop.txt |   30 ++-
 drivers/scsi/Kconfig  |4 +-
 drivers/scsi/hptiop.c |  587 -
 drivers/scsi/hptiop.h |  101 ++--
 4 files changed, 567 insertions(+), 155 deletions(-)

diff --git a/Documentation/scsi/hptiop.txt b/Documentation/scsi/hptiop.txt
index d28a312..a6eb4ad 100644
--- a/Documentation/scsi/hptiop.txt
+++ b/Documentation/scsi/hptiop.txt
@@ -1,9 +1,9 @@
-HIGHPOINT ROCKETRAID 3xxx RAID DRIVER (hptiop)
+HIGHPOINT ROCKETRAID 3xxx/4xxx ADAPTER DRIVER (hptiop)
 
 Controller Register Map
 -
 
-The controller IOP is accessed via PCI BAR0.
+For Intel IOP based adapters, the controller IOP is accessed via PCI BAR0:
 
  BAR0 offsetRegister
 0x10Inbound Message Register 0
@@ -18,6 +18,24 @@ The controller IOP is accessed via PCI BAR0.
 0x40Inbound Queue Port
 0x44Outbound Queue Port
 
+For Marvell IOP based adapters, the IOP is accessed via PCI BAR0 and BAR1:
+
+ BAR0 offsetRegister
+ 0x20400Inbound Doorbell Register
+ 0x20404Inbound Interrupt Mask Register
+ 0x20408Outbound Doorbell Register
+ 0x2040COutbound Interrupt Mask Register
+
+ BAR1 offsetRegister
+ 0x0Inbound Queue Head Pointer
+ 0x4Inbound Queue Tail Pointer
+ 0x8Outbound Queue Head Pointer
+ 0xCOutbound Queue Tail Pointer
+0x10Inbound Message Register
+0x14Outbound Message Register
+ 0x40-0x1040Inbound Queue
+   0x1040-0x2040Outbound Queue
+
 
 I/O Request Workflow
 --
@@ -73,15 +91,9 @@ The driver exposes following sysfs attributes:
  driver-versionR driver version string
  firmware-version  R firmware version string
 
-The driver registers char device hptiop to communicate with HighPoint RAID
-management software. Its ioctl routine acts as a general binary interface 
-between the IOP firmware and HighPoint RAID management software. New management
-functions can be implemented in application/firmware without modification
-in driver code.
-
 
 -
-Copyright (C) 2006 HighPoint Technologies, Inc. All Rights Reserved.
+Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
 
   This file is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index becbb09..e397599 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -573,10 +573,10 @@ config SCSI_ARCMSR_AER
 source drivers/scsi/megaraid/Kconfig.megaraid
 
 config SCSI_HPTIOP
-   tristate HighPoint RocketRAID 3xxx Controller support
+   tristate HighPoint RocketRAID 3xxx/4xxx Controller support
depends on SCSI  PCI
help
- This option enables support for HighPoint RocketRAID 3xxx
+ This option enables support for HighPoint RocketRAID 3xxx/4xxx
  controllers.
 
  To compile this driver as a module, choose M here; the module
diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
index 7fc532b..7febfd5 100644
--- a/drivers/scsi/hptiop.c
+++ b/drivers/scsi/hptiop.c
@@ -1,5 +1,5 @@
 /*
- * HighPoint RR3xxx controller driver for Linux
+ * HighPoint RR3xxx/4xxx controller driver for Linux
  * Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify
@@ -38,80 +38,84 @@
 #include hptiop.h
 
 MODULE_AUTHOR(HighPoint Technologies, Inc.);
-MODULE_DESCRIPTION(HighPoint RocketRAID 3xxx SATA Controller Driver);
+MODULE_DESCRIPTION(HighPoint RocketRAID 3xxx/4xxx Controller Driver);
 
 static char driver_name[] = hptiop;
-static const char driver_name_long[] = RocketRAID 3xxx SATA Controller 
driver;
-static const char driver_ver[] = v1.2 (070830);
-
-static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 tag);
-static void hptiop_iop_request_callback(struct hptiop_hba *hba, u32 tag);
+static const char driver_name_long[] = RocketRAID 3xxx/4xxx Controller 
driver;
+static const char driver_ver[] = v1.3 (071203);
+
+static int iop_send_sync_msg(struct hptiop_hba *hba, u32 msg, u32 millisec

Re: [PATCH][SCSI] hptiop: add more adapter models and other fixes

2007-12-10 Thread HighPoint Linux Team

Matthew Wilcox wrote:
>> - add more PCI device IDs
>> - support for adapters based on Marvell IOP
>
> Are you sure it's a good idea to do this?  This patch is 1200 lines long
> ... the same size as the existing driver:
>
> $ wc drivers/scsi/hptiop.*
>   947  2273 24531 drivers/scsi/hptiop.c
>   256   612  6175 drivers/scsi/hptiop.h
>   1203  2885 30706 total
>
> That suggests to me there's not much commonality between the two drivers,
> and you'd be better off adding a second driver for the 4xxx cards

The new adapter implementation adds to the driver about 300 lines of
code (some lines in the original driver was changed slightly to accommodate
the difference). It is only different from the original models on the
messaging interface, and still shares same firmware command block
structures and work flow.

HighPoint Linux Team

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH][SCSI] hptiop: add more adapter models and other fixes

2007-12-10 Thread HighPoint Linux Team

Matthew Wilcox wrote:
 - add more PCI device IDs
 - support for adapters based on Marvell IOP

 Are you sure it's a good idea to do this?  This patch is 1200 lines long
 ... the same size as the existing driver:

 $ wc drivers/scsi/hptiop.*
   947  2273 24531 drivers/scsi/hptiop.c
   256   612  6175 drivers/scsi/hptiop.h
   1203  2885 30706 total

 That suggests to me there's not much commonality between the two drivers,
 and you'd be better off adding a second driver for the 4xxx cards

The new adapter implementation adds to the driver about 300 lines of
code (some lines in the original driver was changed slightly to accommodate
the difference). It is only different from the original models on the
messaging interface, and still shares same firmware command block
structures and work flow.

HighPoint Linux Team

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH][SCSI] hptiop: add more adapter models and other fixes

2007-12-09 Thread HighPoint Linux Team
Most code changes were made to support adapters based on Marvell IOP, plus some
other fixes.

- add more PCI device IDs
- support for adapters based on Marvell IOP
- fix a result code translation error on big-endian systems
- fix resource releasing bug when scsi_host_alloc() fail in hptiop_probe()
- update scsi_cmnd.resid when finishing a request
- correct some coding style issues

Signed-off-by: HighPoint Linux Team <[EMAIL PROTECTED]>
---

 Documentation/scsi/hptiop.txt |   30 ++-
 drivers/scsi/Kconfig  |4 +-
 drivers/scsi/hptiop.c |  589 -
 drivers/scsi/hptiop.h |  101 ++--
 4 files changed, 568 insertions(+), 156 deletions(-)

diff --git a/Documentation/scsi/hptiop.txt b/Documentation/scsi/hptiop.txt
index d28a312..a6eb4ad 100644
--- a/Documentation/scsi/hptiop.txt
+++ b/Documentation/scsi/hptiop.txt
@@ -1,9 +1,9 @@
-HIGHPOINT ROCKETRAID 3xxx RAID DRIVER (hptiop)
+HIGHPOINT ROCKETRAID 3xxx/4xxx ADAPTER DRIVER (hptiop)
 
 Controller Register Map
 -
 
-The controller IOP is accessed via PCI BAR0.
+For Intel IOP based adapters, the controller IOP is accessed via PCI BAR0:
 
  BAR0 offsetRegister
 0x10Inbound Message Register 0
@@ -18,6 +18,24 @@ The controller IOP is accessed via PCI BAR0.
 0x40Inbound Queue Port
 0x44Outbound Queue Port
 
+For Marvell IOP based adapters, the IOP is accessed via PCI BAR0 and BAR1:
+
+ BAR0 offsetRegister
+ 0x20400Inbound Doorbell Register
+ 0x20404Inbound Interrupt Mask Register
+ 0x20408Outbound Doorbell Register
+ 0x2040COutbound Interrupt Mask Register
+
+ BAR1 offsetRegister
+ 0x0Inbound Queue Head Pointer
+ 0x4Inbound Queue Tail Pointer
+ 0x8Outbound Queue Head Pointer
+ 0xCOutbound Queue Tail Pointer
+0x10Inbound Message Register
+0x14Outbound Message Register
+ 0x40-0x1040Inbound Queue
+   0x1040-0x2040Outbound Queue
+
 
 I/O Request Workflow
 --
@@ -73,15 +91,9 @@ The driver exposes following sysfs attributes:
  driver-versionR driver version string
  firmware-version  R firmware version string
 
-The driver registers char device "hptiop" to communicate with HighPoint RAID
-management software. Its ioctl routine acts as a general binary interface 
-between the IOP firmware and HighPoint RAID management software. New management
-functions can be implemented in application/firmware without modification
-in driver code.
-
 
 -
-Copyright (C) 2006 HighPoint Technologies, Inc. All Rights Reserved.
+Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
 
   This file is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 86cf10e..ba118ba 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -573,10 +573,10 @@ config SCSI_ARCMSR_AER
 source "drivers/scsi/megaraid/Kconfig.megaraid"
 
 config SCSI_HPTIOP
-   tristate "HighPoint RocketRAID 3xxx Controller support"
+   tristate "HighPoint RocketRAID 3xxx/4xxx Controller support"
depends on SCSI && PCI
help
- This option enables support for HighPoint RocketRAID 3xxx
+ This option enables support for HighPoint RocketRAID 3xxx/4xxx
  controllers.
 
  To compile this driver as a module, choose M here; the module
diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
index 0844331..7febfd5 100644
--- a/drivers/scsi/hptiop.c
+++ b/drivers/scsi/hptiop.c
@@ -1,5 +1,5 @@
 /*
- * HighPoint RR3xxx controller driver for Linux
+ * HighPoint RR3xxx/4xxx controller driver for Linux
  * Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify
@@ -38,80 +38,84 @@
 #include "hptiop.h"
 
 MODULE_AUTHOR("HighPoint Technologies, Inc.");
-MODULE_DESCRIPTION("HighPoint RocketRAID 3xxx SATA Controller Driver");
+MODULE_DESCRIPTION("HighPoint RocketRAID 3xxx/4xxx Controller Driver");
 
 static char driver_name[] = "hptiop";
-static const char driver_name_long[] = "RocketRAID 3xxx SATA Controller 
driver";
-static const char driver_ver[] = "v1.2 (070830)";
-
-static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 tag);
-static void hptiop_iop_request_callback(struct hptiop_hba *hba, u32 tag);
+static const char driver_name_long[] = "RocketRAID 3xxx/4xxx Controller 
driver";
+static const char driver_ver[] = "v1.3 (071203)";
+
+

[PATCH][SCSI] hptiop: add more adapter models and other fixes

2007-12-09 Thread HighPoint Linux Team
Most code changes were made to support adapters based on Marvell IOP, plus some
other fixes.

- add more PCI device IDs
- support for adapters based on Marvell IOP
- fix a result code translation error on big-endian systems
- fix resource releasing bug when scsi_host_alloc() fail in hptiop_probe()
- update scsi_cmnd.resid when finishing a request
- correct some coding style issues

Signed-off-by: HighPoint Linux Team [EMAIL PROTECTED]
---

 Documentation/scsi/hptiop.txt |   30 ++-
 drivers/scsi/Kconfig  |4 +-
 drivers/scsi/hptiop.c |  589 -
 drivers/scsi/hptiop.h |  101 ++--
 4 files changed, 568 insertions(+), 156 deletions(-)

diff --git a/Documentation/scsi/hptiop.txt b/Documentation/scsi/hptiop.txt
index d28a312..a6eb4ad 100644
--- a/Documentation/scsi/hptiop.txt
+++ b/Documentation/scsi/hptiop.txt
@@ -1,9 +1,9 @@
-HIGHPOINT ROCKETRAID 3xxx RAID DRIVER (hptiop)
+HIGHPOINT ROCKETRAID 3xxx/4xxx ADAPTER DRIVER (hptiop)
 
 Controller Register Map
 -
 
-The controller IOP is accessed via PCI BAR0.
+For Intel IOP based adapters, the controller IOP is accessed via PCI BAR0:
 
  BAR0 offsetRegister
 0x10Inbound Message Register 0
@@ -18,6 +18,24 @@ The controller IOP is accessed via PCI BAR0.
 0x40Inbound Queue Port
 0x44Outbound Queue Port
 
+For Marvell IOP based adapters, the IOP is accessed via PCI BAR0 and BAR1:
+
+ BAR0 offsetRegister
+ 0x20400Inbound Doorbell Register
+ 0x20404Inbound Interrupt Mask Register
+ 0x20408Outbound Doorbell Register
+ 0x2040COutbound Interrupt Mask Register
+
+ BAR1 offsetRegister
+ 0x0Inbound Queue Head Pointer
+ 0x4Inbound Queue Tail Pointer
+ 0x8Outbound Queue Head Pointer
+ 0xCOutbound Queue Tail Pointer
+0x10Inbound Message Register
+0x14Outbound Message Register
+ 0x40-0x1040Inbound Queue
+   0x1040-0x2040Outbound Queue
+
 
 I/O Request Workflow
 --
@@ -73,15 +91,9 @@ The driver exposes following sysfs attributes:
  driver-versionR driver version string
  firmware-version  R firmware version string
 
-The driver registers char device hptiop to communicate with HighPoint RAID
-management software. Its ioctl routine acts as a general binary interface 
-between the IOP firmware and HighPoint RAID management software. New management
-functions can be implemented in application/firmware without modification
-in driver code.
-
 
 -
-Copyright (C) 2006 HighPoint Technologies, Inc. All Rights Reserved.
+Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
 
   This file is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 86cf10e..ba118ba 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -573,10 +573,10 @@ config SCSI_ARCMSR_AER
 source drivers/scsi/megaraid/Kconfig.megaraid
 
 config SCSI_HPTIOP
-   tristate HighPoint RocketRAID 3xxx Controller support
+   tristate HighPoint RocketRAID 3xxx/4xxx Controller support
depends on SCSI  PCI
help
- This option enables support for HighPoint RocketRAID 3xxx
+ This option enables support for HighPoint RocketRAID 3xxx/4xxx
  controllers.
 
  To compile this driver as a module, choose M here; the module
diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
index 0844331..7febfd5 100644
--- a/drivers/scsi/hptiop.c
+++ b/drivers/scsi/hptiop.c
@@ -1,5 +1,5 @@
 /*
- * HighPoint RR3xxx controller driver for Linux
+ * HighPoint RR3xxx/4xxx controller driver for Linux
  * Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify
@@ -38,80 +38,84 @@
 #include hptiop.h
 
 MODULE_AUTHOR(HighPoint Technologies, Inc.);
-MODULE_DESCRIPTION(HighPoint RocketRAID 3xxx SATA Controller Driver);
+MODULE_DESCRIPTION(HighPoint RocketRAID 3xxx/4xxx Controller Driver);
 
 static char driver_name[] = hptiop;
-static const char driver_name_long[] = RocketRAID 3xxx SATA Controller 
driver;
-static const char driver_ver[] = v1.2 (070830);
-
-static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 tag);
-static void hptiop_iop_request_callback(struct hptiop_hba *hba, u32 tag);
+static const char driver_name_long[] = RocketRAID 3xxx/4xxx Controller 
driver;
+static const char driver_ver[] = v1.3 (071203);
+
+static int iop_send_sync_msg(struct hptiop_hba *hba, u32 msg, u32 millisec);
+static void hptiop_finish_scsi_req(struct hptiop_hba *hba, u32 tag,
+   struct

Re: [PATCH] hptiop: avoid buffer overflow when returning sense data

2007-10-15 Thread HighPoint Linux Team
Andrew Morton wrote:
> > 
> > avoid buffer overflow when returning sense data.
> > 
>
> That's really not enough information, sorry.
>
> > index 8b384fa..d32a4a9 100644
> > --- a/drivers/scsi/hptiop.c
> > +++ b/drivers/scsi/hptiop.c
> > @@ -375,8 +375,9 @@ static void hptiop_host_request_callback
> > scp->result = SAM_STAT_CHECK_CONDITION;
> > memset(>sense_buffer,
> > 0, sizeof(scp->sense_buffer));
> > -   memcpy(>sense_buffer,
> > -   >sg_list, le32_to_cpu(req->dataxfer_length));
> > +   memcpy(>sense_buffer, >sg_list,
> > +   min(sizeof(scp->sense_buffer),
> > +   le32_to_cpu(req->dataxfer_length)));
> > break;
> >  
> > default:
>
> See, we know what the fix does, but we don't know what the consequences are
> if the user's kernel doesn't have this fix.
> 
> So we are not able to work out whether this fix should be backported to
> 2.6.23.x and even to 2.6.22.x?

Sorry for ambiguity. With current adapter firmware the driver is working but 
future
firmware updates may return sense data larger than 96 bytes, causing overflow
on scp->sense_buffer and a kernel crash.

This fix should be backported to earlier kernels.

HighPoint Linux Team

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] hptiop: avoid buffer overflow when returning sense data

2007-10-15 Thread HighPoint Linux Team

avoid buffer overflow when returning sense data.

Signed-off-by: HighPoint Linux Team <[EMAIL PROTECTED]>
---

diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
index 8b384fa..d32a4a9 100644
--- a/drivers/scsi/hptiop.c
+++ b/drivers/scsi/hptiop.c
@@ -375,8 +375,9 @@ static void hptiop_host_request_callback
scp->result = SAM_STAT_CHECK_CONDITION;
memset(>sense_buffer,
0, sizeof(scp->sense_buffer));
-   memcpy(>sense_buffer,
-   >sg_list, le32_to_cpu(req->dataxfer_length));
+   memcpy(>sense_buffer, >sg_list,
+   min(sizeof(scp->sense_buffer),
+   le32_to_cpu(req->dataxfer_length)));
break;
 
default:

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] hptiop: avoid buffer overflow when returning sense data

2007-10-15 Thread HighPoint Linux Team

avoid buffer overflow when returning sense data.

Signed-off-by: HighPoint Linux Team [EMAIL PROTECTED]
---

diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
index 8b384fa..d32a4a9 100644
--- a/drivers/scsi/hptiop.c
+++ b/drivers/scsi/hptiop.c
@@ -375,8 +375,9 @@ static void hptiop_host_request_callback
scp-result = SAM_STAT_CHECK_CONDITION;
memset(scp-sense_buffer,
0, sizeof(scp-sense_buffer));
-   memcpy(scp-sense_buffer,
-   req-sg_list, le32_to_cpu(req-dataxfer_length));
+   memcpy(scp-sense_buffer, req-sg_list,
+   min(sizeof(scp-sense_buffer),
+   le32_to_cpu(req-dataxfer_length)));
break;
 
default:

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] hptiop: avoid buffer overflow when returning sense data

2007-10-15 Thread HighPoint Linux Team
Andrew Morton wrote:
  
  avoid buffer overflow when returning sense data.
  

 That's really not enough information, sorry.

  index 8b384fa..d32a4a9 100644
  --- a/drivers/scsi/hptiop.c
  +++ b/drivers/scsi/hptiop.c
  @@ -375,8 +375,9 @@ static void hptiop_host_request_callback
  scp-result = SAM_STAT_CHECK_CONDITION;
  memset(scp-sense_buffer,
  0, sizeof(scp-sense_buffer));
  -   memcpy(scp-sense_buffer,
  -   req-sg_list, le32_to_cpu(req-dataxfer_length));
  +   memcpy(scp-sense_buffer, req-sg_list,
  +   min(sizeof(scp-sense_buffer),
  +   le32_to_cpu(req-dataxfer_length)));
  break;
   
  default:

 See, we know what the fix does, but we don't know what the consequences are
 if the user's kernel doesn't have this fix.
 
 So we are not able to work out whether this fix should be backported to
 2.6.23.x and even to 2.6.22.x?

Sorry for ambiguity. With current adapter firmware the driver is working but 
future
firmware updates may return sense data larger than 96 bytes, causing overflow
on scp-sense_buffer and a kernel crash.

This fix should be backported to earlier kernels.

HighPoint Linux Team

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH/RESENT] hptiop: adding new firmware interface and more PCI device IDs

2007-08-30 Thread HighPoint Linux Team
updated patch based on Jeff Garzik's comments.

- check adapter firmware version and use appropriate interface accordingly
- add new PCI device IDs and use PCI_VDEVICE macro
- update driver version string
- remove unused data structures
- remove unnecessary typecasts

Signed-off-by: HighPoint Linux Team <[EMAIL PROTECTED]>
---
 drivers/scsi/hptiop.c |   63 +
 drivers/scsi/hptiop.h |  229 
++-
 2 files changed, 58 insertions(+), 234 deletions(-)

diff -urpN a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
--- a/drivers/scsi/hptiop.c 2007-08-28 22:52:20.0 -0700
+++ b/drivers/scsi/hptiop.c 2007-08-30 10:08:13.0 -0700
@@ -1,6 +1,6 @@
 /*
  * HighPoint RR3xxx controller driver for Linux
- * Copyright (C) 2006 HighPoint Technologies, Inc. All Rights Reserved.
+ * Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -42,7 +42,7 @@ MODULE_DESCRIPTION("HighPoint RocketRAID
 
 static char driver_name[] = "hptiop";
 static const char driver_name_long[] = "RocketRAID 3xxx SATA Controller 
driver";
-static const char driver_ver[] = "v1.0 (060426)";
+static const char driver_ver[] = "v1.2 (070830)";
 
 static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 tag);
 static void hptiop_iop_request_callback(struct hptiop_hba *hba, u32 tag);
@@ -76,7 +76,7 @@ static int iop_wait_ready(struct hpt_iop
 
 static void hptiop_request_callback(struct hptiop_hba *hba, u32 tag)
 {
-   if ((tag & IOPMU_QUEUE_MASK_HOST_BITS) == IOPMU_QUEUE_ADDR_HOST_BIT)
+   if (tag & IOPMU_QUEUE_ADDR_HOST_BIT)
return hptiop_host_request_callback(hba,
tag & ~IOPMU_QUEUE_ADDR_HOST_BIT);
else
@@ -323,12 +323,22 @@ static inline void free_req(struct hptio
hba->req_list = req;
 }
 
-static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 tag)
+static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 _tag)
 {
struct hpt_iop_request_scsi_command *req;
struct scsi_cmnd *scp;
+   u32 tag;
+
+   if (hba->iopintf_v2) {
+   tag = _tag & ~ IOPMU_QUEUE_REQUEST_RESULT_BIT;
+   req = hba->reqs[tag].req_virt;
+   if (likely(_tag & IOPMU_QUEUE_REQUEST_RESULT_BIT))
+   req->header.result = IOP_RESULT_SUCCESS;
+   } else {
+   tag = _tag;
+   req = hba->reqs[tag].req_virt;
+   }
 
-   req = (struct hpt_iop_request_scsi_command *)hba->reqs[tag].req_virt;
dprintk("hptiop_host_request_callback: req=%p, type=%d, "
"result=%d, context=0x%x tag=%d\n",
req, req->header.type, req->header.result,
@@ -497,7 +507,7 @@ static int hptiop_queuecommand(struct sc
goto cmd_done;
}
 
-   req = (struct hpt_iop_request_scsi_command *)_req->req_virt;
+   req = _req->req_virt;
 
/* build S/G table */
sg_count = hptiop_buildsgl(scp, req->sg_list);
@@ -521,8 +531,19 @@ static int hptiop_queuecommand(struct sc
 
memcpy(req->cdb, scp->cmnd, sizeof(req->cdb));
 
-   writel(IOPMU_QUEUE_ADDR_HOST_BIT | _req->req_shifted_phy,
-   >iop->inbound_queue);
+   if (hba->iopintf_v2) {
+   u32 size_bits;
+   if (req->header.size < 256)
+   size_bits = IOPMU_QUEUE_REQUEST_SIZE_BIT;
+   else if (req->header.size < 512)
+   size_bits = IOPMU_QUEUE_ADDR_HOST_BIT;
+   else
+   size_bits = IOPMU_QUEUE_REQUEST_SIZE_BIT |
+   IOPMU_QUEUE_ADDR_HOST_BIT;
+   writel(_req->req_shifted_phy | size_bits, 
>iop->inbound_queue);
+   } else
+   writel(_req->req_shifted_phy | IOPMU_QUEUE_ADDR_HOST_BIT,
+   >iop->inbound_queue);
 
return 0;
 
@@ -688,6 +709,7 @@ static int __devinit hptiop_probe(struct
hba->pcidev = pcidev;
hba->host = host;
hba->initialized = 0;
+   hba->iopintf_v2 = 0;
 
atomic_set(>resetting, 0);
atomic_set(>reset_count, 0);
@@ -722,8 +744,13 @@ static int __devinit hptiop_probe(struct
hba->max_request_size = le32_to_cpu(iop_config.request_size);
hba->max_sg_descriptors = le32_to_cpu(iop_config.max_sg_count);
hba->firmware_version = le32_to_cpu(iop_config.firmware_version);
+   hba->interface_version = le32_to_cpu(iop_config.interface_version);
hba->sdram_size = le32_

[PATCH/RESENT] hptiop: adding new firmware interface and more PCI device IDs

2007-08-30 Thread HighPoint Linux Team
updated patch based on Jeff Garzik's comments.

- check adapter firmware version and use appropriate interface accordingly
- add new PCI device IDs and use PCI_VDEVICE macro
- update driver version string
- remove unused data structures
- remove unnecessary typecasts

Signed-off-by: HighPoint Linux Team [EMAIL PROTECTED]
---
 drivers/scsi/hptiop.c |   63 +
 drivers/scsi/hptiop.h |  229 
++-
 2 files changed, 58 insertions(+), 234 deletions(-)

diff -urpN a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
--- a/drivers/scsi/hptiop.c 2007-08-28 22:52:20.0 -0700
+++ b/drivers/scsi/hptiop.c 2007-08-30 10:08:13.0 -0700
@@ -1,6 +1,6 @@
 /*
  * HighPoint RR3xxx controller driver for Linux
- * Copyright (C) 2006 HighPoint Technologies, Inc. All Rights Reserved.
+ * Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -42,7 +42,7 @@ MODULE_DESCRIPTION(HighPoint RocketRAID
 
 static char driver_name[] = hptiop;
 static const char driver_name_long[] = RocketRAID 3xxx SATA Controller 
driver;
-static const char driver_ver[] = v1.0 (060426);
+static const char driver_ver[] = v1.2 (070830);
 
 static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 tag);
 static void hptiop_iop_request_callback(struct hptiop_hba *hba, u32 tag);
@@ -76,7 +76,7 @@ static int iop_wait_ready(struct hpt_iop
 
 static void hptiop_request_callback(struct hptiop_hba *hba, u32 tag)
 {
-   if ((tag  IOPMU_QUEUE_MASK_HOST_BITS) == IOPMU_QUEUE_ADDR_HOST_BIT)
+   if (tag  IOPMU_QUEUE_ADDR_HOST_BIT)
return hptiop_host_request_callback(hba,
tag  ~IOPMU_QUEUE_ADDR_HOST_BIT);
else
@@ -323,12 +323,22 @@ static inline void free_req(struct hptio
hba-req_list = req;
 }
 
-static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 tag)
+static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 _tag)
 {
struct hpt_iop_request_scsi_command *req;
struct scsi_cmnd *scp;
+   u32 tag;
+
+   if (hba-iopintf_v2) {
+   tag = _tag  ~ IOPMU_QUEUE_REQUEST_RESULT_BIT;
+   req = hba-reqs[tag].req_virt;
+   if (likely(_tag  IOPMU_QUEUE_REQUEST_RESULT_BIT))
+   req-header.result = IOP_RESULT_SUCCESS;
+   } else {
+   tag = _tag;
+   req = hba-reqs[tag].req_virt;
+   }
 
-   req = (struct hpt_iop_request_scsi_command *)hba-reqs[tag].req_virt;
dprintk(hptiop_host_request_callback: req=%p, type=%d, 
result=%d, context=0x%x tag=%d\n,
req, req-header.type, req-header.result,
@@ -497,7 +507,7 @@ static int hptiop_queuecommand(struct sc
goto cmd_done;
}
 
-   req = (struct hpt_iop_request_scsi_command *)_req-req_virt;
+   req = _req-req_virt;
 
/* build S/G table */
sg_count = hptiop_buildsgl(scp, req-sg_list);
@@ -521,8 +531,19 @@ static int hptiop_queuecommand(struct sc
 
memcpy(req-cdb, scp-cmnd, sizeof(req-cdb));
 
-   writel(IOPMU_QUEUE_ADDR_HOST_BIT | _req-req_shifted_phy,
-   hba-iop-inbound_queue);
+   if (hba-iopintf_v2) {
+   u32 size_bits;
+   if (req-header.size  256)
+   size_bits = IOPMU_QUEUE_REQUEST_SIZE_BIT;
+   else if (req-header.size  512)
+   size_bits = IOPMU_QUEUE_ADDR_HOST_BIT;
+   else
+   size_bits = IOPMU_QUEUE_REQUEST_SIZE_BIT |
+   IOPMU_QUEUE_ADDR_HOST_BIT;
+   writel(_req-req_shifted_phy | size_bits, 
hba-iop-inbound_queue);
+   } else
+   writel(_req-req_shifted_phy | IOPMU_QUEUE_ADDR_HOST_BIT,
+   hba-iop-inbound_queue);
 
return 0;
 
@@ -688,6 +709,7 @@ static int __devinit hptiop_probe(struct
hba-pcidev = pcidev;
hba-host = host;
hba-initialized = 0;
+   hba-iopintf_v2 = 0;
 
atomic_set(hba-resetting, 0);
atomic_set(hba-reset_count, 0);
@@ -722,8 +744,13 @@ static int __devinit hptiop_probe(struct
hba-max_request_size = le32_to_cpu(iop_config.request_size);
hba-max_sg_descriptors = le32_to_cpu(iop_config.max_sg_count);
hba-firmware_version = le32_to_cpu(iop_config.firmware_version);
+   hba-interface_version = le32_to_cpu(iop_config.interface_version);
hba-sdram_size = le32_to_cpu(iop_config.sdram_size);
 
+   if (hba-firmware_version  0x0102 ||
+   hba-interface_version  0x0102)
+   hba-iopintf_v2 = 1;
+
host-max_sectors = le32_to_cpu(iop_config.data_transfer_length)  9

[PATCH] hptiop: adding new firmware interface and more PCI device IDs

2007-08-29 Thread HighPoint Linux Team

- check adapter firmware version and using appropriate interface accordingly
- add new PCI device IDs
- update driver version string

Signed-off-by: HighPoint Linux Team <[EMAIL PROTECTED]>
---

 hptiop.c |   57 +++--
 hptiop.h |9 +++--
 2 files changed, 50 insertions(+), 16 deletions(-)

diff -uprN a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
--- a/drivers/scsi/hptiop.c 2007-08-29 13:52:20.0 +0800
+++ b/drivers/scsi/hptiop.c 2007-08-29 13:52:39.0 +0800
@@ -1,6 +1,6 @@
 /*
  * HighPoint RR3xxx controller driver for Linux
- * Copyright (C) 2006 HighPoint Technologies, Inc. All Rights Reserved.
+ * Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -42,7 +42,7 @@ MODULE_DESCRIPTION("HighPoint RocketRAID
 
 static char driver_name[] = "hptiop";
 static const char driver_name_long[] = "RocketRAID 3xxx SATA Controller 
driver";
-static const char driver_ver[] = "v1.0 (060426)";
+static const char driver_ver[] = "v1.2 (070810)";
 
 static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 tag);
 static void hptiop_iop_request_callback(struct hptiop_hba *hba, u32 tag);
@@ -76,7 +76,7 @@ static int iop_wait_ready(struct hpt_iop
 
 static void hptiop_request_callback(struct hptiop_hba *hba, u32 tag)
 {
-   if ((tag & IOPMU_QUEUE_MASK_HOST_BITS) == IOPMU_QUEUE_ADDR_HOST_BIT)
+   if (tag & IOPMU_QUEUE_ADDR_HOST_BIT)
return hptiop_host_request_callback(hba,
tag & ~IOPMU_QUEUE_ADDR_HOST_BIT);
else
@@ -323,12 +323,22 @@ static inline void free_req(struct hptio
hba->req_list = req;
 }
 
-static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 tag)
+static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 _tag)
 {
struct hpt_iop_request_scsi_command *req;
struct scsi_cmnd *scp;
+   u32 tag;
+
+   if (hba->firmware_version > 0x0102 || hba->interface_version > 
0x0102) {
+   tag = _tag & ~ IOPMU_QUEUE_REQUEST_RESULT_BIT;
+   req = (struct hpt_iop_request_scsi_command 
*)hba->reqs[tag].req_virt;
+   if (likely(_tag & IOPMU_QUEUE_REQUEST_RESULT_BIT))
+   req->header.result = IOP_RESULT_SUCCESS;
+   } else {
+   tag = _tag;
+   req = (struct hpt_iop_request_scsi_command 
*)hba->reqs[tag].req_virt;
+   }
 
-   req = (struct hpt_iop_request_scsi_command *)hba->reqs[tag].req_virt;
dprintk("hptiop_host_request_callback: req=%p, type=%d, "
"result=%d, context=0x%x tag=%d\n",
req, req->header.type, req->header.result,
@@ -521,8 +531,20 @@ static int hptiop_queuecommand(struct sc
 
memcpy(req->cdb, scp->cmnd, sizeof(req->cdb));
 
-   writel(IOPMU_QUEUE_ADDR_HOST_BIT | _req->req_shifted_phy,
-   >iop->inbound_queue);
+   if (hba->firmware_version > 0x0102 ||
+   hba->interface_version > 0x0102) {
+   u32 size_bits;
+   if (req->header.size < 256)
+   size_bits = IOPMU_QUEUE_REQUEST_SIZE_BIT;
+   else if (req->header.size < 512)
+   size_bits = IOPMU_QUEUE_ADDR_HOST_BIT;
+   else
+   size_bits = IOPMU_QUEUE_REQUEST_SIZE_BIT |
+   IOPMU_QUEUE_ADDR_HOST_BIT;
+   writel(_req->req_shifted_phy | size_bits, 
>iop->inbound_queue);
+   } else
+   writel(_req->req_shifted_phy | IOPMU_QUEUE_ADDR_HOST_BIT,
+   >iop->inbound_queue);
 
return 0;
 
@@ -722,6 +744,7 @@ static int __devinit hptiop_probe(struct
hba->max_request_size = le32_to_cpu(iop_config.request_size);
hba->max_sg_descriptors = le32_to_cpu(iop_config.max_sg_count);
hba->firmware_version = le32_to_cpu(iop_config.firmware_version);
+   hba->interface_version = le32_to_cpu(iop_config.interface_version);
hba->sdram_size = le32_to_cpu(iop_config.sdram_size);
 
host->max_sectors = le32_to_cpu(iop_config.data_transfer_length) >> 9;
@@ -731,8 +754,15 @@ static int __devinit hptiop_probe(struct
host->cmd_per_lun = le32_to_cpu(iop_config.max_requests);
host->max_cmd_len = 16;
 
-   set_config.vbus_id = cpu_to_le32(host->host_no);
+   req_size = sizeof(struct hpt_iop_request_scsi_command)
+   + sizeof(struct hpt_iopsg) * (hba->max_sg_descriptors - 

[PATCH] hptiop: adding new firmware interface and more PCI device IDs

2007-08-29 Thread HighPoint Linux Team

- check adapter firmware version and using appropriate interface accordingly
- add new PCI device IDs
- update driver version string

Signed-off-by: HighPoint Linux Team [EMAIL PROTECTED]
---

 hptiop.c |   57 +++--
 hptiop.h |9 +++--
 2 files changed, 50 insertions(+), 16 deletions(-)

diff -uprN a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
--- a/drivers/scsi/hptiop.c 2007-08-29 13:52:20.0 +0800
+++ b/drivers/scsi/hptiop.c 2007-08-29 13:52:39.0 +0800
@@ -1,6 +1,6 @@
 /*
  * HighPoint RR3xxx controller driver for Linux
- * Copyright (C) 2006 HighPoint Technologies, Inc. All Rights Reserved.
+ * Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -42,7 +42,7 @@ MODULE_DESCRIPTION(HighPoint RocketRAID
 
 static char driver_name[] = hptiop;
 static const char driver_name_long[] = RocketRAID 3xxx SATA Controller 
driver;
-static const char driver_ver[] = v1.0 (060426);
+static const char driver_ver[] = v1.2 (070810);
 
 static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 tag);
 static void hptiop_iop_request_callback(struct hptiop_hba *hba, u32 tag);
@@ -76,7 +76,7 @@ static int iop_wait_ready(struct hpt_iop
 
 static void hptiop_request_callback(struct hptiop_hba *hba, u32 tag)
 {
-   if ((tag  IOPMU_QUEUE_MASK_HOST_BITS) == IOPMU_QUEUE_ADDR_HOST_BIT)
+   if (tag  IOPMU_QUEUE_ADDR_HOST_BIT)
return hptiop_host_request_callback(hba,
tag  ~IOPMU_QUEUE_ADDR_HOST_BIT);
else
@@ -323,12 +323,22 @@ static inline void free_req(struct hptio
hba-req_list = req;
 }
 
-static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 tag)
+static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 _tag)
 {
struct hpt_iop_request_scsi_command *req;
struct scsi_cmnd *scp;
+   u32 tag;
+
+   if (hba-firmware_version  0x0102 || hba-interface_version  
0x0102) {
+   tag = _tag  ~ IOPMU_QUEUE_REQUEST_RESULT_BIT;
+   req = (struct hpt_iop_request_scsi_command 
*)hba-reqs[tag].req_virt;
+   if (likely(_tag  IOPMU_QUEUE_REQUEST_RESULT_BIT))
+   req-header.result = IOP_RESULT_SUCCESS;
+   } else {
+   tag = _tag;
+   req = (struct hpt_iop_request_scsi_command 
*)hba-reqs[tag].req_virt;
+   }
 
-   req = (struct hpt_iop_request_scsi_command *)hba-reqs[tag].req_virt;
dprintk(hptiop_host_request_callback: req=%p, type=%d, 
result=%d, context=0x%x tag=%d\n,
req, req-header.type, req-header.result,
@@ -521,8 +531,20 @@ static int hptiop_queuecommand(struct sc
 
memcpy(req-cdb, scp-cmnd, sizeof(req-cdb));
 
-   writel(IOPMU_QUEUE_ADDR_HOST_BIT | _req-req_shifted_phy,
-   hba-iop-inbound_queue);
+   if (hba-firmware_version  0x0102 ||
+   hba-interface_version  0x0102) {
+   u32 size_bits;
+   if (req-header.size  256)
+   size_bits = IOPMU_QUEUE_REQUEST_SIZE_BIT;
+   else if (req-header.size  512)
+   size_bits = IOPMU_QUEUE_ADDR_HOST_BIT;
+   else
+   size_bits = IOPMU_QUEUE_REQUEST_SIZE_BIT |
+   IOPMU_QUEUE_ADDR_HOST_BIT;
+   writel(_req-req_shifted_phy | size_bits, 
hba-iop-inbound_queue);
+   } else
+   writel(_req-req_shifted_phy | IOPMU_QUEUE_ADDR_HOST_BIT,
+   hba-iop-inbound_queue);
 
return 0;
 
@@ -722,6 +744,7 @@ static int __devinit hptiop_probe(struct
hba-max_request_size = le32_to_cpu(iop_config.request_size);
hba-max_sg_descriptors = le32_to_cpu(iop_config.max_sg_count);
hba-firmware_version = le32_to_cpu(iop_config.firmware_version);
+   hba-interface_version = le32_to_cpu(iop_config.interface_version);
hba-sdram_size = le32_to_cpu(iop_config.sdram_size);
 
host-max_sectors = le32_to_cpu(iop_config.data_transfer_length)  9;
@@ -731,8 +754,15 @@ static int __devinit hptiop_probe(struct
host-cmd_per_lun = le32_to_cpu(iop_config.max_requests);
host-max_cmd_len = 16;
 
-   set_config.vbus_id = cpu_to_le32(host-host_no);
+   req_size = sizeof(struct hpt_iop_request_scsi_command)
+   + sizeof(struct hpt_iopsg) * (hba-max_sg_descriptors - 1);
+   if ((req_size  0x1f) != 0)
+   req_size = (req_size + 0x1f)  ~0x1f;
+
+   memset(set_config, 0, sizeof(struct hpt_iop_request_set_config));
set_config.iop_id = cpu_to_le32(host-host_no);
+   set_config.vbus_id = cpu_to_le16(host-host_no