Tejun Heo
03cccb9c9e
libata: introduce ata_host->n_tags to avoid oops on SAS controllers
commit 1a112d10f0 upstream.
1871ee134b ("libata: support the ata host which implements a queue
depth less than 32") directly used ata_port->scsi_host->can_queue from
ata_qc_new() to determine the number of tags supported by the host;
unfortunately, SAS controllers doing SATA don't initialize ->scsi_host
leading to the following oops.
BUG: unable to handle kernel NULL pointer dereference at 0000000000000058
IP: [<ffffffff814e0618>] ata_qc_new_init+0x188/0x1b0
PGD 0
Oops: 0002 [#1] SMP
Modules linked in: isci libsas scsi_transport_sas mgag200 drm_kms_helper ttm
CPU: 1 PID: 518 Comm: udevd Not tainted 3.16.0-rc6+ #62
Hardware name: Intel Corporation S2600CO/S2600CO, BIOS SE5C600.86B.02.02.0002.122320131210 12/23/2013
task: ffff880c1a00b280 ti: ffff88061a000000 task.ti: ffff88061a000000
RIP: 0010:[<ffffffff814e0618>] [<ffffffff814e0618>] ata_qc_new_init+0x188/0x1b0
RSP: 0018:ffff88061a003ae8 EFLAGS: 00010012
RAX: 0000000000000001 RBX: ffff88000241ca80 RCX: 00000000000000fa
RDX: 0000000000000020 RSI: 0000000000000020 RDI: ffff8806194aa298
RBP: ffff88061a003ae8 R08: ffff8806194a8000 R09: 0000000000000000
R10: 0000000000000000 R11: ffff88000241ca80 R12: ffff88061ad58200
R13: ffff8806194aa298 R14: ffffffff814e67a0 R15: ffff8806194a8000
FS: 00007f3ad7fe3840(0000) GS:ffff880627620000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000058 CR3: 000000061a118000 CR4: 00000000001407e0
Stack:
ffff88061a003b20 ffffffff814e96e1 ffff88000241ca80 ffff88061ad58200
ffff8800b6bf6000 ffff880c1c988000 ffff880619903850 ffff88061a003b68
ffffffffa0056ce1 ffff88061a003b48 0000000013d6e6f8 ffff88000241ca80
Call Trace:
[<ffffffff814e96e1>] ata_sas_queuecmd+0xa1/0x430
[<ffffffffa0056ce1>] sas_queuecommand+0x191/0x220 [libsas]
[<ffffffff8149afee>] scsi_dispatch_cmd+0x10e/0x300 [<ffffffff814a3bc5>] scsi_request_fn+0x2f5/0x550
[<ffffffff81317613>] __blk_run_queue+0x33/0x40
[<ffffffff8131781a>] queue_unplugged+0x2a/0x90
[<ffffffff8131ceb4>] blk_flush_plug_list+0x1b4/0x210
[<ffffffff8131d274>] blk_finish_plug+0x14/0x50
[<ffffffff8117eaa8>] __do_page_cache_readahead+0x198/0x1f0
[<ffffffff8117ee21>] force_page_cache_readahead+0x31/0x50
[<ffffffff8117ee7e>] page_cache_sync_readahead+0x3e/0x50
[<ffffffff81172ac6>] generic_file_read_iter+0x496/0x5a0
[<ffffffff81219897>] blkdev_read_iter+0x37/0x40
[<ffffffff811e307e>] new_sync_read+0x7e/0xb0
[<ffffffff811e3734>] vfs_read+0x94/0x170
[<ffffffff811e43c6>] SyS_read+0x46/0xb0
[<ffffffff811e33d1>] ? SyS_lseek+0x91/0xb0
[<ffffffff8171ee29>] system_call_fastpath+0x16/0x1b
Code: 00 00 00 88 50 29 83 7f 08 01 19 d2 83 e2 f0 83 ea 50 88 50 34 c6 81 1d 02 00 00 40 c6 81 17 02 00 00 00 5d c3 66 0f 1f 44 00 00 <89> 14 25 58 00 00 00
Fix it by introducing ata_host->n_tags which is initialized to
ATA_MAX_QUEUE - 1 in ata_host_init() for SAS controllers and set to
scsi_host_template->can_queue in ata_host_register() for !SAS ones.
As SAS hosts are never registered, this will give them the same
ATA_MAX_QUEUE - 1 as before. Note that we can't use
scsi_host->can_queue directly for SAS hosts anyway as they can go
higher than the libata maximum.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Mike Qiu <qiudayu@linux.vnet.ibm.com>
Reported-by: Jesse Brandeburg <jesse.brandeburg@gmail.com>
Reported-by: Peter Hurley <peter@hurleysoftware.com>
Reported-by: Peter Zijlstra <peterz@infradead.org>
Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Fixes: 1871ee134b ("libata: support the ata host which implements a queue depth less than 32")
Cc: Kevin Hao <haokexin@gmail.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-07-31 12:53:49 -07:00
..
2013-03-29 09:20:05 -07:00
2013-05-17 14:31:05 -04:00
2014-03-06 21:30:03 -08:00
2014-03-31 09:58:12 -07:00
2013-05-04 12:31:18 -07:00
2013-04-08 16:36:23 +02:00
2013-07-25 14:07:23 -07:00
2013-05-05 17:36:20 -07:00
2013-04-11 03:39:00 -07:00
2013-05-17 00:42:33 +02:00
2013-05-11 16:12:44 -07:00
2013-05-06 15:41:42 -07:00
2013-12-04 10:56:22 -08:00
2013-04-29 20:09:03 +02:00
2013-05-14 13:40:45 +02:00
2013-05-25 20:30:31 -07:00
2013-04-16 17:38:10 -07:00
2013-04-28 02:13:43 +01:00
2013-05-13 18:27:18 +04:00
2013-04-23 14:09:39 -04:00
2014-05-06 07:55:29 -07:00
2014-04-14 06:42:18 -07:00
2013-05-14 10:23:57 +05:30
2013-04-12 00:31:18 +02:00
2013-04-30 15:21:02 -07:00
2013-05-30 10:51:20 -07:00
2013-05-07 19:46:02 -07:00
2013-04-03 19:33:40 -04:00
2014-02-13 13:48:00 -08:00
2014-01-09 12:24:22 -08:00
2014-04-26 17:15:35 -07:00
2013-10-13 16:08:33 -07:00
2013-04-10 23:41:16 +02:00
2013-11-29 11:11:44 -08:00
2013-03-23 14:26:34 -07:00
2014-04-03 12:01:04 -07:00
2013-05-08 10:13:35 -07:00
2013-05-08 10:13:35 -07:00
2013-04-18 09:00:26 -07:00
2013-04-29 15:54:39 -07:00
2013-05-15 14:42:15 -07:00
2013-05-01 08:04:12 -07:00
2014-06-16 13:42:52 -07:00
2013-03-23 16:11:31 -07:00
2013-07-21 18:21:25 -07:00
2013-04-30 17:04:01 -07:00
2013-03-22 15:18:18 -07:00
2013-04-12 11:22:35 -07:00
2013-04-10 16:33:53 -07:00
2013-12-08 07:29:27 -08:00
2013-05-02 09:03:55 -07:00
2013-03-20 13:23:21 -04:00
2014-02-13 13:48:00 -08:00
2014-02-22 12:41:29 -08:00
2013-12-20 07:45:10 -08:00
2013-04-08 17:28:34 +02:00
2013-04-29 18:28:13 -07:00
2013-05-31 11:32:30 +02:00
2013-07-25 14:07:42 -07:00
2013-06-12 16:29:44 -07:00
2014-04-14 06:42:19 -07:00
2013-05-11 15:23:17 -07:00
2013-05-01 17:51:54 -07:00
2013-04-29 18:28:19 -07:00
2013-10-18 07:45:45 -07:00
2013-04-29 15:54:27 -07:00
2013-04-02 01:28:41 +02:00
2013-10-05 07:13:11 -07:00
2013-05-01 13:20:04 -07:00
2013-05-01 16:36:22 +05:30
2013-05-02 21:52:26 +05:30
2013-04-30 17:04:02 -07:00
2013-03-22 22:18:09 -06:00
2013-03-28 10:10:25 -06:00
2013-07-28 16:30:11 -07:00
2013-04-30 16:03:10 +01:00
2013-08-20 08:43:03 -07:00
2013-05-07 18:38:27 -07:00
2013-03-27 13:48:25 +01:00
2013-04-29 18:28:40 -07:00
2013-03-18 21:00:35 +09:00
2013-05-01 17:31:42 -04:00
2013-06-10 22:23:32 -07:00
2014-03-23 21:38:16 -07:00
2013-03-31 11:38:33 -07:00
2013-04-30 17:04:00 -07:00
2013-03-27 07:49:29 -07:00
2013-06-20 19:02:45 +04:00
2013-04-29 18:28:41 -07:00
2014-03-31 09:58:12 -07:00
2014-06-07 13:25:28 -07:00
2014-04-14 06:42:19 -07:00
2013-12-11 22:36:28 -08:00
2013-04-11 10:00:05 +08:00
2013-04-16 18:47:14 +09:00
2013-03-18 10:21:23 +01:00
2013-04-30 10:09:06 +02:00
2013-10-13 16:08:28 -07:00
2013-03-22 16:19:59 -07:00
2014-04-03 12:01:05 -07:00
2014-02-06 11:08:12 -08:00
2014-06-07 13:25:35 -07:00
2013-04-02 07:07:32 +02:00
2013-04-02 07:06:17 +02:00
2013-04-29 13:54:36 -04:00
2013-05-08 11:51:05 -07:00
2013-04-16 15:29:45 +02:00
2013-03-26 12:32:13 -04:00
2014-06-26 15:12:38 -04:00
2013-07-28 16:30:05 -07:00
2013-03-27 13:48:25 +01:00
2013-03-27 13:48:25 +01:00
2014-06-07 13:25:38 -07:00
2013-05-02 12:10:19 +02:00
2013-04-29 15:54:37 -07:00
2014-03-06 21:30:12 -08:00
2013-09-14 06:54:55 -07:00
2013-03-22 16:41:19 -07:00
2014-06-07 13:25:29 -07:00
2014-06-30 20:09:45 -07:00
2013-04-19 17:49:23 -04:00
2013-04-25 15:25:23 +02:00
2014-03-23 21:38:20 -07:00
2013-05-13 09:45:01 -04:00
2013-04-29 15:42:02 -04:00
2013-05-24 16:22:51 -07:00
2013-12-20 07:45:08 -08:00
2013-04-30 17:04:06 -07:00
2013-04-08 17:28:34 +02:00
2013-05-16 07:55:07 -07:00
2013-04-30 17:04:02 -07:00
2013-04-19 16:39:13 -04:00
2013-05-31 11:32:30 +02:00
2013-04-07 13:05:35 +03:00
2013-04-01 11:04:50 -07:00
2014-07-31 12:53:49 -07:00
2013-05-05 10:58:06 -07:00
2014-05-30 21:52:14 -07:00
2013-03-22 22:17:36 -06:00
2013-06-12 16:29:47 -07:00
2013-04-15 14:06:39 +00:00
2013-04-08 16:57:15 -07:00
2013-04-29 15:54:37 -07:00
2013-04-30 17:04:00 -07:00
2013-10-13 16:08:35 -07:00
2014-01-09 12:24:23 -08:00
2014-04-03 12:01:05 -07:00
2013-03-28 17:45:51 -07:00
2013-04-30 09:36:50 -07:00
2013-11-29 11:11:53 -08:00
2013-03-27 07:50:04 -07:00
2013-12-04 10:56:10 -08:00
2013-04-23 09:50:30 -06:00
2013-04-19 09:33:36 +02:00
2013-03-22 10:25:15 -04:00
2013-07-21 18:21:29 -07:00
2014-01-15 15:28:47 -08:00
2013-05-02 07:34:58 -07:00
2014-03-06 21:30:05 -08:00
2013-05-23 11:58:55 +02:00
2013-04-05 21:08:11 +02:00
2014-06-26 15:12:37 -04:00
2013-05-01 15:00:24 -04:00
2013-04-14 12:59:28 -04:00
2013-04-08 22:12:33 -04:00
2013-05-06 17:24:22 -04:00
2013-04-29 15:54:36 -07:00
2013-05-04 14:47:26 -04:00
2013-05-08 09:55:05 -04:00
2013-05-02 21:50:38 +05:30
2013-04-02 16:43:09 -04:00
2013-04-09 14:58:32 -05:00
2013-05-07 11:22:14 -07:00
2013-03-29 17:54:33 -07:00
2013-04-29 15:54:28 -07:00
2013-04-19 22:25:51 +02:00
2013-04-17 10:21:17 -06:00
2013-09-26 17:18:14 -07:00
2013-05-17 14:12:06 -06:00
2013-04-17 10:21:17 -06:00
2013-04-17 10:21:17 -06:00
2013-05-01 14:08:52 -07:00
2013-04-17 10:21:17 -06:00
2014-06-11 12:03:26 -07:00
2013-05-07 20:16:25 -07:00
2014-02-13 13:47:59 -08:00
2013-03-29 09:14:16 -07:00
2013-03-19 09:47:30 +01:00
2013-05-05 13:23:27 -07:00
2013-04-16 18:51:16 -07:00
2013-06-19 12:55:10 +02:00
2013-05-22 01:34:24 +02:00
2013-05-01 17:29:47 -04:00
2013-05-01 17:29:39 -04:00
2013-04-09 14:13:35 -04:00
2013-04-03 21:50:00 -07:00
2014-07-06 18:54:15 -07:00
2013-04-29 15:54:28 -07:00
2013-12-08 07:29:24 -08:00
2013-06-02 20:53:59 -07:00
2013-09-26 17:18:13 -07:00
2013-05-28 22:47:13 -04:00
2013-09-07 22:09:58 -07:00
2013-04-30 17:04:09 -07:00
2013-04-07 14:06:17 +03:00
2013-04-29 19:14:20 -07:00
2013-04-12 10:26:23 +02:00
2013-04-12 10:26:23 +02:00
2014-07-17 15:58:03 -07:00
2013-05-24 16:22:50 -07:00
2013-05-24 16:22:50 -07:00
2013-04-29 18:28:22 -07:00
2013-03-23 15:53:52 -07:00
2013-05-30 09:20:20 +02:00
2013-11-29 11:11:44 -08:00
2013-04-09 13:19:39 -04:00
2013-04-30 16:27:51 -07:00
2013-10-18 07:45:47 -07:00
2013-04-09 14:13:29 -04:00
2013-04-11 13:14:36 -07:00
2013-03-29 15:31:30 -04:00
2013-09-26 17:18:13 -07:00
2014-03-06 21:30:05 -08:00
2013-05-06 09:24:16 +03:00
2013-06-14 19:24:42 -10:00
2014-06-26 15:12:37 -04:00
2013-06-06 11:52:14 -07:00
2013-04-09 10:48:33 -07:00
2014-01-09 12:24:23 -08:00
2013-06-20 19:02:45 +04:00
2013-03-25 10:39:40 -07:00
2013-04-30 17:04:03 -07:00
2013-04-30 15:50:12 +05:30
2013-04-29 15:54:38 -07:00
2013-06-12 16:29:46 -07:00
2013-04-17 12:35:32 -07:00
2013-08-20 08:43:02 -07:00
2013-06-12 16:29:44 -07:00
2013-03-21 11:47:51 -04:00
2013-03-29 18:10:22 -06:00
2013-05-09 09:40:49 -07:00
2013-11-29 11:11:42 -08:00
2013-08-11 18:35:24 -07:00
2013-05-14 20:54:06 +02:00
2013-04-04 13:18:31 -07:00
2013-04-25 21:01:45 +08:00
2013-10-01 09:17:45 -07:00
2014-03-23 21:38:16 -07:00
2013-03-18 16:14:55 -07:00
2013-05-11 14:29:11 -07:00
2013-04-19 00:40:07 +02:00
2013-04-15 21:23:03 +01:00
2013-03-20 12:10:38 -04:00
2013-05-20 10:24:22 +09:30
2013-04-13 15:31:58 +02:00
2013-11-13 12:05:29 +09:00
2013-03-28 11:10:22 -07:00
2013-08-11 18:35:25 -07:00
2013-03-21 15:17:40 +00:00
2013-03-20 14:06:06 +10:30
2013-03-20 14:00:41 +10:30
2013-07-28 16:29:55 -07:00
2013-12-08 07:29:27 -08:00
2013-04-29 15:54:34 -07:00
2013-04-29 15:54:38 -07:00
2014-02-13 13:48:00 -08:00
2013-03-20 14:06:05 +10:30
2013-05-20 12:15:59 -07:00
2013-05-31 11:31:50 +02:00
2013-08-29 09:47:39 -07:00
2013-04-30 17:04:02 -07:00
2013-05-07 20:16:25 -07:00