]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
d3e0045f71b3c0795189fc0aea48fbcbe757e6e6
[thirdparty/kernel/stable-queue.git] /
1 From 338b131a3269881c7431234855c93c219b0979b6 Mon Sep 17 00:00:00 2001
2 From: "sreekanth.reddy@lsi.com" <sreekanth.reddy@lsi.com>
3 Date: Tue, 17 Jul 2012 15:57:05 +0530
4 Subject: SCSI: mpt2sas: Fix for Driver oops, when loading driver with max_queue_depth command line option to a very small value
5
6 From: "sreekanth.reddy@lsi.com" <sreekanth.reddy@lsi.com>
7
8 commit 338b131a3269881c7431234855c93c219b0979b6 upstream.
9
10 If the specified max_queue_depth setting is less than the
11 expected number of internal commands, then driver will calculate
12 the queue depth size to a negitive number. This negitive number
13 is actually a very large number because variable is unsigned
14 16bit integer. So, the driver will ask for a very large amount of
15 memory for message frames and resulting into oops as memory
16 allocation routines will not able to handle such a large request.
17
18 So, in order to limit this kind of oops, The driver need to set
19 the max_queue_depth to a scsi mid layer's can_queue value. Then
20 the overall message frames required for IO is minimum of either
21 (max_queue_depth plus internal commands) or the IOC global
22 credits.
23
24 Signed-off-by: Sreekanth Reddy <sreekanth.reddy@lsi.com>
25 Signed-off-by: James Bottomley <JBottomley@Parallels.com>
26 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27
28 ---
29 drivers/scsi/mpt2sas/mpt2sas_base.c | 13 ++++++++-----
30 1 file changed, 8 insertions(+), 5 deletions(-)
31
32 --- a/drivers/scsi/mpt2sas/mpt2sas_base.c
33 +++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
34 @@ -2424,10 +2424,13 @@ _base_allocate_memory_pools(struct MPT2S
35 }
36
37 /* command line tunables for max controller queue depth */
38 - if (max_queue_depth != -1)
39 - max_request_credit = (max_queue_depth < facts->RequestCredit)
40 - ? max_queue_depth : facts->RequestCredit;
41 - else
42 + if (max_queue_depth != -1 && max_queue_depth != 0) {
43 + max_request_credit = min_t(u16, max_queue_depth +
44 + ioc->hi_priority_depth + ioc->internal_depth,
45 + facts->RequestCredit);
46 + if (max_request_credit > MAX_HBA_QUEUE_DEPTH)
47 + max_request_credit = MAX_HBA_QUEUE_DEPTH;
48 + } else
49 max_request_credit = min_t(u16, facts->RequestCredit,
50 MAX_HBA_QUEUE_DEPTH);
51
52 @@ -2502,7 +2505,7 @@ _base_allocate_memory_pools(struct MPT2S
53 /* set the scsi host can_queue depth
54 * with some internal commands that could be outstanding
55 */
56 - ioc->shost->can_queue = ioc->scsiio_depth - (2);
57 + ioc->shost->can_queue = ioc->scsiio_depth;
58 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scsi host: "
59 "can_queue depth (%d)\n", ioc->name, ioc->shost->can_queue));
60