SCSI: mpt2sas: Fix for Driver oops, when loading driver with max_queue_depth command...
authorsreekanth.reddy@lsi.com <sreekanth.reddy@lsi.com>
Tue, 17 Jul 2012 10:27:05 +0000 (15:57 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Sep 2012 17:00:50 +0000 (10:00 -0700)
commita87c6c9daa67fc9cecd4c65ed4180ede25bc0343
tree0ab003563c5de21da7d833d003d5a3f79c95ea8f
parentb787880f60d492c28a5638bc7c59017c067377d3
SCSI: mpt2sas: Fix for Driver oops, when loading driver with max_queue_depth command line option to a very small value

commit 338b131a3269881c7431234855c93c219b0979b6 upstream.

If the specified max_queue_depth setting is less than the
expected number of internal commands, then driver will calculate
the queue depth size to a negitive number. This negitive number
is actually a very large number because variable is unsigned
16bit integer. So, the driver will ask for a very large amount of
memory for message frames and resulting into oops as memory
allocation routines will not able to handle such a large request.

So, in order to limit this kind of oops, The driver need to set
the max_queue_depth to a scsi mid layer's can_queue value. Then
the overall message frames required for IO is minimum of either
(max_queue_depth plus internal commands) or the IOC global
credits.

Signed-off-by: Sreekanth Reddy <sreekanth.reddy@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/scsi/mpt2sas/mpt2sas_base.c