From e2d025895965986899525a75fa7532983fdc7b6b Mon Sep 17 00:00:00 2001 From: Mark Haverkamp Date: Wed, 22 Oct 2003 23:27:44 -0500 Subject: [PATCH] [PATCH] Work around aacraid FW problem If you have a 4gig or greater system, some versions of aacraid firmware have problems if you set HostPhysMemPages >= 0x100000. This can potentially cause data corruption. If you have 4gig or greater memory, this patch sets the HostPhysMemPages to something that the firmware can deal with. --- drivers/scsi/aacraid/aacraid.h | 2 ++ drivers/scsi/aacraid/comminit.c | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 24cb71bf05122..b6da218464a0a 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -14,6 +14,8 @@ #define AAC_MAX_TARGET (MAXIMUM_NUM_CONTAINERS+1) #define AAC_MAX_LUN (8) +#define AAC_MAX_HOSTPHYSMEMPAGES (0xfffff) + /* * These macros convert from physical channels to virtual channels */ diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index 3509d8768313e..87671a1055ef9 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c @@ -92,7 +92,21 @@ static int aac_alloc_comm(struct aac_dev *dev, void **commaddr, unsigned long co init->AdapterFibsPhysicalAddress = cpu_to_le32((u32)phys); init->AdapterFibsSize = cpu_to_le32(fibsize); init->AdapterFibAlign = cpu_to_le32(sizeof(struct hw_fib)); - init->HostPhysMemPages = cpu_to_le32(num_physpages); // number of 4k pages of host physical memory + /* + * number of 4k pages of host physical memory. The aacraid fw needs + * this number to be less than 4gb worth of pages. num_physpages is in + * system page units. New firmware doesn't have any issues with the + * mapping system, but older Firmware did, and had *troubles* dealing + * with the math overloading past 32 bits, thus we must limit this + * field. + */ + if ((num_physpages << (PAGE_SHIFT - 12)) <= AAC_MAX_HOSTPHYSMEMPAGES) { + init->HostPhysMemPages = + cpu_to_le32(num_physpages << (PAGE_SHIFT-12)); + } else { + init->HostPhysMemPages = cpu_to_le32(AAC_MAX_HOSTPHYSMEMPAGES); + } + /* * Increment the base address by the amount already used -- 2.53.0