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