~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/scsi/hpsa.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno
  • Date: 2011-06-07 12:14:05 UTC
  • mfrom: (43.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110607121405-i3h1rd7nrnd2b73h
Tags: 2.6.39-2
[ Ben Hutchings ]
* [x86] Enable BACKLIGHT_APPLE, replacing BACKLIGHT_MBP_NVIDIA
  (Closes: #627492)
* cgroups: Disable memory resource controller by default. Allow it
  to be enabled using kernel parameter 'cgroup_enable=memory'.
* rt2800usb: Enable support for more USB devices including
  Linksys WUSB600N (Closes: #596626) (this change was accidentally
  omitted from 2.6.39-1)
* [x86] Remove Celeron from list of processors supporting PAE. Most
  'Celeron M' models do not.
* Update debconf template translations:
  - Swedish (Martin Bagge) (Closes: #628932)
  - French (David Prévot) (Closes: #628191)
* aufs: Update for 2.6.39 (Closes: #627837)
* Add stable 2.6.39.1, including:
  - ext4: dont set PageUptodate in ext4_end_bio()
  - pata_cmd64x: fix boot crash on parisc (Closes: #622997, #622745)
  - ext3: Fix fs corruption when make_indexed_dir() fails
  - netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  - sctp: fix race between sctp_bind_addr_free() and
    sctp_bind_addr_conflict()
  - sctp: fix memory leak of the ASCONF queue when free asoc
  - md/bitmap: fix saving of events_cleared and other state
  - cdc_acm: Fix oops when Droids MuIn LCD is connected
  - cx88: Fix conversion from BKL to fine-grained locks (Closes: #619827)
  - keys: Set cred->user_ns in key_replace_session_keyring (CVE-2011-2184)
  - tmpfs: fix race between truncate and writepage
  - nfs41: Correct offset for LAYOUTCOMMIT
  - xen/mmu: fix a race window causing leave_mm BUG()
  - ext4: fix possible use-after-free in ext4_remove_li_request()
  For the complete list of changes, see:
   http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39.1
* Bump ABI to 2
* netfilter: Enable IP_SET, IP_SET_BITMAP_IP, IP_SET_BITMAP_IPMAC,
  IP_SET_BITMAP_PORT, IP_SET_HASH_IP, IP_SET_HASH_IPPORT,
  IP_SET_HASH_IPPORTIP, IP_SET_HASH_IPPORTNET, IP_SET_HASH_NET,
  IP_SET_HASH_NETPORT, IP_SET_LIST_SET, NETFILTER_XT_SET as modules
  (Closes: #629401)

[ Aurelien Jarno ]
* [mipsel/loongson-2f] Disable_SCSI_LPFC to workaround GCC ICE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
module_param(hpsa_allow_any, int, S_IRUGO|S_IWUSR);
75
75
MODULE_PARM_DESC(hpsa_allow_any,
76
76
                "Allow hpsa driver to access unknown HP Smart Array hardware");
 
77
static int hpsa_simple_mode;
 
78
module_param(hpsa_simple_mode, int, S_IRUGO|S_IWUSR);
 
79
MODULE_PARM_DESC(hpsa_simple_mode,
 
80
        "Use 'simple mode' rather than 'performant mode'");
77
81
 
78
82
/* define the PCI info for the cards we can control */
79
83
static const struct pci_device_id hpsa_pci_device_id[] = {
85
89
        {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSE,     0x103C, 0x324a},
86
90
        {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSE,     0x103C, 0x324b},
87
91
        {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSE,     0x103C, 0x3233},
88
 
        {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSE,     0x103C, 0x3250},
89
 
        {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSE,     0x103C, 0x3251},
90
 
        {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSE,     0x103C, 0x3252},
91
 
        {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSE,     0x103C, 0x3253},
92
 
        {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSE,     0x103C, 0x3254},
 
92
        {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSF,     0x103C, 0x3350},
 
93
        {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSF,     0x103C, 0x3351},
 
94
        {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSF,     0x103C, 0x3352},
 
95
        {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSF,     0x103C, 0x3353},
 
96
        {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSF,     0x103C, 0x3354},
 
97
        {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSF,     0x103C, 0x3355},
 
98
        {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSF,     0x103C, 0x3356},
93
99
        {PCI_VENDOR_ID_HP,     PCI_ANY_ID,      PCI_ANY_ID, PCI_ANY_ID,
94
100
                PCI_CLASS_STORAGE_RAID << 8, 0xffff << 8, 0},
95
101
        {0,}
109
115
        {0x3249103C, "Smart Array P812", &SA5_access},
110
116
        {0x324a103C, "Smart Array P712m", &SA5_access},
111
117
        {0x324b103C, "Smart Array P711m", &SA5_access},
112
 
        {0x3250103C, "Smart Array", &SA5_access},
113
 
        {0x3250113C, "Smart Array", &SA5_access},
114
 
        {0x3250123C, "Smart Array", &SA5_access},
115
 
        {0x3250133C, "Smart Array", &SA5_access},
116
 
        {0x3250143C, "Smart Array", &SA5_access},
 
118
        {0x3350103C, "Smart Array", &SA5_access},
 
119
        {0x3351103C, "Smart Array", &SA5_access},
 
120
        {0x3352103C, "Smart Array", &SA5_access},
 
121
        {0x3353103C, "Smart Array", &SA5_access},
 
122
        {0x3354103C, "Smart Array", &SA5_access},
 
123
        {0x3355103C, "Smart Array", &SA5_access},
 
124
        {0x3356103C, "Smart Array", &SA5_access},
117
125
        {0xFFFF103C, "Unknown Smart Array", &SA5_access},
118
126
};
119
127
 
147
155
static int hpsa_slave_alloc(struct scsi_device *sdev);
148
156
static void hpsa_slave_destroy(struct scsi_device *sdev);
149
157
 
150
 
static ssize_t raid_level_show(struct device *dev,
151
 
        struct device_attribute *attr, char *buf);
152
 
static ssize_t lunid_show(struct device *dev,
153
 
        struct device_attribute *attr, char *buf);
154
 
static ssize_t unique_id_show(struct device *dev,
155
 
        struct device_attribute *attr, char *buf);
156
 
static ssize_t host_show_firmware_revision(struct device *dev,
157
 
             struct device_attribute *attr, char *buf);
158
158
static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno);
159
 
static ssize_t host_store_rescan(struct device *dev,
160
 
         struct device_attribute *attr, const char *buf, size_t count);
161
159
static int check_for_unit_attention(struct ctlr_info *h,
162
160
        struct CommandList *c);
163
161
static void check_ioctl_unit_attention(struct ctlr_info *h,
173
171
static int __devinit hpsa_pci_find_memory_BAR(struct pci_dev *pdev,
174
172
        unsigned long *memory_bar);
175
173
static int __devinit hpsa_lookup_board_id(struct pci_dev *pdev, u32 *board_id);
176
 
 
177
 
static DEVICE_ATTR(raid_level, S_IRUGO, raid_level_show, NULL);
178
 
static DEVICE_ATTR(lunid, S_IRUGO, lunid_show, NULL);
179
 
static DEVICE_ATTR(unique_id, S_IRUGO, unique_id_show, NULL);
180
 
static DEVICE_ATTR(rescan, S_IWUSR, NULL, host_store_rescan);
181
 
static DEVICE_ATTR(firmware_revision, S_IRUGO,
182
 
        host_show_firmware_revision, NULL);
183
 
 
184
 
static struct device_attribute *hpsa_sdev_attrs[] = {
185
 
        &dev_attr_raid_level,
186
 
        &dev_attr_lunid,
187
 
        &dev_attr_unique_id,
188
 
        NULL,
189
 
};
190
 
 
191
 
static struct device_attribute *hpsa_shost_attrs[] = {
192
 
        &dev_attr_rescan,
193
 
        &dev_attr_firmware_revision,
194
 
        NULL,
195
 
};
196
 
 
197
 
static struct scsi_host_template hpsa_driver_template = {
198
 
        .module                 = THIS_MODULE,
199
 
        .name                   = "hpsa",
200
 
        .proc_name              = "hpsa",
201
 
        .queuecommand           = hpsa_scsi_queue_command,
202
 
        .scan_start             = hpsa_scan_start,
203
 
        .scan_finished          = hpsa_scan_finished,
204
 
        .change_queue_depth     = hpsa_change_queue_depth,
205
 
        .this_id                = -1,
206
 
        .use_clustering         = ENABLE_CLUSTERING,
207
 
        .eh_device_reset_handler = hpsa_eh_device_reset_handler,
208
 
        .ioctl                  = hpsa_ioctl,
209
 
        .slave_alloc            = hpsa_slave_alloc,
210
 
        .slave_destroy          = hpsa_slave_destroy,
211
 
#ifdef CONFIG_COMPAT
212
 
        .compat_ioctl           = hpsa_compat_ioctl,
213
 
#endif
214
 
        .sdev_attrs = hpsa_sdev_attrs,
215
 
        .shost_attrs = hpsa_shost_attrs,
216
 
};
 
174
static int __devinit hpsa_wait_for_board_state(struct pci_dev *pdev,
 
175
        void __iomem *vaddr, int wait_for_ready);
 
176
#define BOARD_NOT_READY 0
 
177
#define BOARD_READY 1
217
178
 
218
179
static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
219
180
{
291
252
                fwrev[0], fwrev[1], fwrev[2], fwrev[3]);
292
253
}
293
254
 
294
 
/* Enqueuing and dequeuing functions for cmdlists. */
295
 
static inline void addQ(struct hlist_head *list, struct CommandList *c)
296
 
{
297
 
        hlist_add_head(&c->list, list);
298
 
}
299
 
 
300
 
static inline u32 next_command(struct ctlr_info *h)
301
 
{
302
 
        u32 a;
303
 
 
304
 
        if (unlikely(h->transMethod != CFGTBL_Trans_Performant))
305
 
                return h->access.command_completed(h);
306
 
 
307
 
        if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
308
 
                a = *(h->reply_pool_head); /* Next cmd in ring buffer */
309
 
                (h->reply_pool_head)++;
310
 
                h->commands_outstanding--;
311
 
        } else {
312
 
                a = FIFO_EMPTY;
313
 
        }
314
 
        /* Check for wraparound */
315
 
        if (h->reply_pool_head == (h->reply_pool + h->max_commands)) {
316
 
                h->reply_pool_head = h->reply_pool;
317
 
                h->reply_pool_wraparound ^= 1;
318
 
        }
319
 
        return a;
320
 
}
321
 
 
322
 
/* set_performant_mode: Modify the tag for cciss performant
323
 
 * set bit 0 for pull model, bits 3-1 for block fetch
324
 
 * register number
325
 
 */
326
 
static void set_performant_mode(struct ctlr_info *h, struct CommandList *c)
327
 
{
328
 
        if (likely(h->transMethod == CFGTBL_Trans_Performant))
329
 
                c->busaddr |= 1 | (h->blockFetchTable[c->Header.SGList] << 1);
330
 
}
331
 
 
332
 
static void enqueue_cmd_and_start_io(struct ctlr_info *h,
333
 
        struct CommandList *c)
334
 
{
335
 
        unsigned long flags;
336
 
 
337
 
        set_performant_mode(h, c);
338
 
        spin_lock_irqsave(&h->lock, flags);
339
 
        addQ(&h->reqQ, c);
340
 
        h->Qdepth++;
341
 
        start_io(h);
342
 
        spin_unlock_irqrestore(&h->lock, flags);
343
 
}
344
 
 
345
 
static inline void removeQ(struct CommandList *c)
346
 
{
347
 
        if (WARN_ON(hlist_unhashed(&c->list)))
348
 
                return;
349
 
        hlist_del_init(&c->list);
350
 
}
351
 
 
352
 
static inline int is_hba_lunid(unsigned char scsi3addr[])
353
 
{
354
 
        return memcmp(scsi3addr, RAID_CTLR_LUNID, 8) == 0;
 
255
static ssize_t host_show_commands_outstanding(struct device *dev,
 
256
             struct device_attribute *attr, char *buf)
 
257
{
 
258
        struct Scsi_Host *shost = class_to_shost(dev);
 
259
        struct ctlr_info *h = shost_to_hba(shost);
 
260
 
 
261
        return snprintf(buf, 20, "%d\n", h->commands_outstanding);
 
262
}
 
263
 
 
264
static ssize_t host_show_transport_mode(struct device *dev,
 
265
        struct device_attribute *attr, char *buf)
 
266
{
 
267
        struct ctlr_info *h;
 
268
        struct Scsi_Host *shost = class_to_shost(dev);
 
269
 
 
270
        h = shost_to_hba(shost);
 
271
        return snprintf(buf, 20, "%s\n",
 
272
                h->transMethod & CFGTBL_Trans_Performant ?
 
273
                        "performant" : "simple");
 
274
}
 
275
 
 
276
/* List of controllers which cannot be reset on kexec with reset_devices */
 
277
static u32 unresettable_controller[] = {
 
278
        0x324a103C, /* Smart Array P712m */
 
279
        0x324b103C, /* SmartArray P711m */
 
280
        0x3223103C, /* Smart Array P800 */
 
281
        0x3234103C, /* Smart Array P400 */
 
282
        0x3235103C, /* Smart Array P400i */
 
283
        0x3211103C, /* Smart Array E200i */
 
284
        0x3212103C, /* Smart Array E200 */
 
285
        0x3213103C, /* Smart Array E200i */
 
286
        0x3214103C, /* Smart Array E200i */
 
287
        0x3215103C, /* Smart Array E200i */
 
288
        0x3237103C, /* Smart Array E500 */
 
289
        0x323D103C, /* Smart Array P700m */
 
290
        0x409C0E11, /* Smart Array 6400 */
 
291
        0x409D0E11, /* Smart Array 6400 EM */
 
292
};
 
293
 
 
294
static int ctlr_is_resettable(struct ctlr_info *h)
 
295
{
 
296
        int i;
 
297
 
 
298
        for (i = 0; i < ARRAY_SIZE(unresettable_controller); i++)
 
299
                if (unresettable_controller[i] == h->board_id)
 
300
                        return 0;
 
301
        return 1;
 
302
}
 
303
 
 
304
static ssize_t host_show_resettable(struct device *dev,
 
305
        struct device_attribute *attr, char *buf)
 
306
{
 
307
        struct ctlr_info *h;
 
308
        struct Scsi_Host *shost = class_to_shost(dev);
 
309
 
 
310
        h = shost_to_hba(shost);
 
311
        return snprintf(buf, 20, "%d\n", ctlr_is_resettable(h));
355
312
}
356
313
 
357
314
static inline int is_logical_dev_addr_mode(unsigned char scsi3addr[])
359
316
        return (scsi3addr[3] & 0xC0) == 0x40;
360
317
}
361
318
 
362
 
static inline int is_scsi_rev_5(struct ctlr_info *h)
363
 
{
364
 
        if (!h->hba_inquiry_data)
365
 
                return 0;
366
 
        if ((h->hba_inquiry_data[2] & 0x07) == 5)
367
 
                return 1;
368
 
        return 0;
369
 
}
370
 
 
371
319
static const char *raid_label[] = { "0", "4", "1(1+0)", "5", "5+1", "ADG",
372
320
        "UNKNOWN"
373
321
};
459
407
                        sn[12], sn[13], sn[14], sn[15]);
460
408
}
461
409
 
 
410
static DEVICE_ATTR(raid_level, S_IRUGO, raid_level_show, NULL);
 
411
static DEVICE_ATTR(lunid, S_IRUGO, lunid_show, NULL);
 
412
static DEVICE_ATTR(unique_id, S_IRUGO, unique_id_show, NULL);
 
413
static DEVICE_ATTR(rescan, S_IWUSR, NULL, host_store_rescan);
 
414
static DEVICE_ATTR(firmware_revision, S_IRUGO,
 
415
        host_show_firmware_revision, NULL);
 
416
static DEVICE_ATTR(commands_outstanding, S_IRUGO,
 
417
        host_show_commands_outstanding, NULL);
 
418
static DEVICE_ATTR(transport_mode, S_IRUGO,
 
419
        host_show_transport_mode, NULL);
 
420
static DEVICE_ATTR(resettable, S_IRUGO,
 
421
        host_show_resettable, NULL);
 
422
 
 
423
static struct device_attribute *hpsa_sdev_attrs[] = {
 
424
        &dev_attr_raid_level,
 
425
        &dev_attr_lunid,
 
426
        &dev_attr_unique_id,
 
427
        NULL,
 
428
};
 
429
 
 
430
static struct device_attribute *hpsa_shost_attrs[] = {
 
431
        &dev_attr_rescan,
 
432
        &dev_attr_firmware_revision,
 
433
        &dev_attr_commands_outstanding,
 
434
        &dev_attr_transport_mode,
 
435
        &dev_attr_resettable,
 
436
        NULL,
 
437
};
 
438
 
 
439
static struct scsi_host_template hpsa_driver_template = {
 
440
        .module                 = THIS_MODULE,
 
441
        .name                   = "hpsa",
 
442
        .proc_name              = "hpsa",
 
443
        .queuecommand           = hpsa_scsi_queue_command,
 
444
        .scan_start             = hpsa_scan_start,
 
445
        .scan_finished          = hpsa_scan_finished,
 
446
        .change_queue_depth     = hpsa_change_queue_depth,
 
447
        .this_id                = -1,
 
448
        .use_clustering         = ENABLE_CLUSTERING,
 
449
        .eh_device_reset_handler = hpsa_eh_device_reset_handler,
 
450
        .ioctl                  = hpsa_ioctl,
 
451
        .slave_alloc            = hpsa_slave_alloc,
 
452
        .slave_destroy          = hpsa_slave_destroy,
 
453
#ifdef CONFIG_COMPAT
 
454
        .compat_ioctl           = hpsa_compat_ioctl,
 
455
#endif
 
456
        .sdev_attrs = hpsa_sdev_attrs,
 
457
        .shost_attrs = hpsa_shost_attrs,
 
458
};
 
459
 
 
460
 
 
461
/* Enqueuing and dequeuing functions for cmdlists. */
 
462
static inline void addQ(struct list_head *list, struct CommandList *c)
 
463
{
 
464
        list_add_tail(&c->list, list);
 
465
}
 
466
 
 
467
static inline u32 next_command(struct ctlr_info *h)
 
468
{
 
469
        u32 a;
 
470
 
 
471
        if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
 
472
                return h->access.command_completed(h);
 
473
 
 
474
        if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
 
475
                a = *(h->reply_pool_head); /* Next cmd in ring buffer */
 
476
                (h->reply_pool_head)++;
 
477
                h->commands_outstanding--;
 
478
        } else {
 
479
                a = FIFO_EMPTY;
 
480
        }
 
481
        /* Check for wraparound */
 
482
        if (h->reply_pool_head == (h->reply_pool + h->max_commands)) {
 
483
                h->reply_pool_head = h->reply_pool;
 
484
                h->reply_pool_wraparound ^= 1;
 
485
        }
 
486
        return a;
 
487
}
 
488
 
 
489
/* set_performant_mode: Modify the tag for cciss performant
 
490
 * set bit 0 for pull model, bits 3-1 for block fetch
 
491
 * register number
 
492
 */
 
493
static void set_performant_mode(struct ctlr_info *h, struct CommandList *c)
 
494
{
 
495
        if (likely(h->transMethod & CFGTBL_Trans_Performant))
 
496
                c->busaddr |= 1 | (h->blockFetchTable[c->Header.SGList] << 1);
 
497
}
 
498
 
 
499
static void enqueue_cmd_and_start_io(struct ctlr_info *h,
 
500
        struct CommandList *c)
 
501
{
 
502
        unsigned long flags;
 
503
 
 
504
        set_performant_mode(h, c);
 
505
        spin_lock_irqsave(&h->lock, flags);
 
506
        addQ(&h->reqQ, c);
 
507
        h->Qdepth++;
 
508
        start_io(h);
 
509
        spin_unlock_irqrestore(&h->lock, flags);
 
510
}
 
511
 
 
512
static inline void removeQ(struct CommandList *c)
 
513
{
 
514
        if (WARN_ON(list_empty(&c->list)))
 
515
                return;
 
516
        list_del_init(&c->list);
 
517
}
 
518
 
 
519
static inline int is_hba_lunid(unsigned char scsi3addr[])
 
520
{
 
521
        return memcmp(scsi3addr, RAID_CTLR_LUNID, 8) == 0;
 
522
}
 
523
 
 
524
static inline int is_scsi_rev_5(struct ctlr_info *h)
 
525
{
 
526
        if (!h->hba_inquiry_data)
 
527
                return 0;
 
528
        if ((h->hba_inquiry_data[2] & 0x07) == 5)
 
529
                return 1;
 
530
        return 0;
 
531
}
 
532
 
462
533
static int hpsa_find_target_lun(struct ctlr_info *h,
463
534
        unsigned char scsi3addr[], int bus, int *target, int *lun)
464
535
{
1130
1201
                cmd->result = DID_TIME_OUT << 16;
1131
1202
                dev_warn(&h->pdev->dev, "cp %p timedout\n", cp);
1132
1203
                break;
 
1204
        case CMD_UNABORTABLE:
 
1205
                cmd->result = DID_ERROR << 16;
 
1206
                dev_warn(&h->pdev->dev, "Command unabortable\n");
 
1207
                break;
1133
1208
        default:
1134
1209
                cmd->result = DID_ERROR << 16;
1135
1210
                dev_warn(&h->pdev->dev, "cp %p returned unknown status %x\n",
1160
1235
        sh->sg_tablesize = h->maxsgentries;
1161
1236
        h->scsi_host = sh;
1162
1237
        sh->hostdata[0] = (unsigned long) h;
1163
 
        sh->irq = h->intr[PERF_MODE_INT];
 
1238
        sh->irq = h->intr[h->intr_mode];
1164
1239
        sh->unique_id = sh->irq;
1165
1240
        error = scsi_add_host(sh, &h->pdev->dev);
1166
1241
        if (error)
1295
1370
        case CMD_TIMEOUT:
1296
1371
                dev_warn(d, "cp %p timed out\n", cp);
1297
1372
                break;
 
1373
        case CMD_UNABORTABLE:
 
1374
                dev_warn(d, "Command unabortable\n");
 
1375
                break;
1298
1376
        default:
1299
1377
                dev_warn(d, "cp %p returned unknown status %x\n", cp,
1300
1378
                                ei->CommandStatus);
1595
1673
        if (lun == 0) /* if lun is 0, then obviously we have a lun 0. */
1596
1674
                return 0;
1597
1675
 
 
1676
        memset(scsi3addr, 0, 8);
 
1677
        scsi3addr[3] = target;
1598
1678
        if (is_hba_lunid(scsi3addr))
1599
1679
                return 0; /* Don't add the RAID controller here. */
1600
1680
 
1609
1689
                return 0;
1610
1690
        }
1611
1691
 
1612
 
        memset(scsi3addr, 0, 8);
1613
 
        scsi3addr[3] = target;
1614
1692
        if (hpsa_update_device_info(h, scsi3addr, this_device))
1615
1693
                return 0;
1616
1694
        (*nmsa2xxx_enclosures)++;
2199
2277
 
2200
2278
        c->cmdindex = i;
2201
2279
 
2202
 
        INIT_HLIST_NODE(&c->list);
 
2280
        INIT_LIST_HEAD(&c->list);
2203
2281
        c->busaddr = (u32) cmd_dma_handle;
2204
2282
        temp64.val = (u64) err_dma_handle;
2205
2283
        c->ErrDesc.Addr.lower = temp64.val32.lower;
2237
2315
        }
2238
2316
        memset(c->err_info, 0, sizeof(*c->err_info));
2239
2317
 
2240
 
        INIT_HLIST_NODE(&c->list);
 
2318
        INIT_LIST_HEAD(&c->list);
2241
2319
        c->busaddr = (u32) cmd_dma_handle;
2242
2320
        temp64.val = (u64) err_dma_handle;
2243
2321
        c->ErrDesc.Addr.lower = temp64.val32.lower;
2267
2345
        pci_free_consistent(h->pdev, sizeof(*c->err_info),
2268
2346
                            c->err_info, (dma_addr_t) temp64.val);
2269
2347
        pci_free_consistent(h->pdev, sizeof(*c),
2270
 
                            c, (dma_addr_t) c->busaddr);
 
2348
                            c, (dma_addr_t) (c->busaddr & DIRECT_LOOKUP_MASK));
2271
2349
}
2272
2350
 
2273
2351
#ifdef CONFIG_COMPAT
2281
2359
        int err;
2282
2360
        u32 cp;
2283
2361
 
 
2362
        memset(&arg64, 0, sizeof(arg64));
2284
2363
        err = 0;
2285
2364
        err |= copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
2286
2365
                           sizeof(arg64.LUN_info));
2317
2396
        int err;
2318
2397
        u32 cp;
2319
2398
 
 
2399
        memset(&arg64, 0, sizeof(arg64));
2320
2400
        err = 0;
2321
2401
        err |= copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
2322
2402
                           sizeof(arg64.LUN_info));
2433
2513
                buff = kmalloc(iocommand.buf_size, GFP_KERNEL);
2434
2514
                if (buff == NULL)
2435
2515
                        return -EFAULT;
2436
 
        }
2437
 
        if (iocommand.Request.Type.Direction == XFER_WRITE) {
2438
 
                /* Copy the data into the buffer we created */
2439
 
                if (copy_from_user(buff, iocommand.buf, iocommand.buf_size)) {
2440
 
                        kfree(buff);
2441
 
                        return -EFAULT;
 
2516
                if (iocommand.Request.Type.Direction == XFER_WRITE) {
 
2517
                        /* Copy the data into the buffer we created */
 
2518
                        if (copy_from_user(buff, iocommand.buf,
 
2519
                                iocommand.buf_size)) {
 
2520
                                kfree(buff);
 
2521
                                return -EFAULT;
 
2522
                        }
 
2523
                } else {
 
2524
                        memset(buff, 0, iocommand.buf_size);
2442
2525
                }
2443
 
        } else
2444
 
                memset(buff, 0, iocommand.buf_size);
 
2526
        }
2445
2527
        c = cmd_special_alloc(h);
2446
2528
        if (c == NULL) {
2447
2529
                kfree(buff);
2487
2569
                cmd_special_free(h, c);
2488
2570
                return -EFAULT;
2489
2571
        }
2490
 
 
2491
 
        if (iocommand.Request.Type.Direction == XFER_READ) {
 
2572
        if (iocommand.Request.Type.Direction == XFER_READ &&
 
2573
                iocommand.buf_size > 0) {
2492
2574
                /* Copy the data out of the buffer we created */
2493
2575
                if (copy_to_user(iocommand.buf, buff, iocommand.buf_size)) {
2494
2576
                        kfree(buff);
2581
2663
        }
2582
2664
        c->cmd_type = CMD_IOCTL_PEND;
2583
2665
        c->Header.ReplyQueue = 0;
2584
 
 
2585
 
        if (ioc->buf_size > 0) {
2586
 
                c->Header.SGList = sg_used;
2587
 
                c->Header.SGTotal = sg_used;
2588
 
        } else {
2589
 
                c->Header.SGList = 0;
2590
 
                c->Header.SGTotal = 0;
2591
 
        }
 
2666
        c->Header.SGList = c->Header.SGTotal = sg_used;
2592
2667
        memcpy(&c->Header.LUN, &ioc->LUN_info, sizeof(c->Header.LUN));
2593
2668
        c->Header.Tag.lower = c->busaddr;
2594
2669
        memcpy(&c->Request, &ioc->Request, sizeof(c->Request));
2605
2680
                }
2606
2681
        }
2607
2682
        hpsa_scsi_do_simple_cmd_core(h, c);
2608
 
        hpsa_pci_unmap(h->pdev, c, sg_used, PCI_DMA_BIDIRECTIONAL);
 
2683
        if (sg_used)
 
2684
                hpsa_pci_unmap(h->pdev, c, sg_used, PCI_DMA_BIDIRECTIONAL);
2609
2685
        check_ioctl_unit_attention(h, c);
2610
2686
        /* Copy the error information out */
2611
2687
        memcpy(&ioc->error_info, c->err_info, sizeof(ioc->error_info));
2614
2690
                status = -EFAULT;
2615
2691
                goto cleanup1;
2616
2692
        }
2617
 
        if (ioc->Request.Type.Direction == XFER_READ) {
 
2693
        if (ioc->Request.Type.Direction == XFER_READ && ioc->buf_size > 0) {
2618
2694
                /* Copy the data out of the buffer we created */
2619
2695
                BYTE __user *ptr = ioc->buf;
2620
2696
                for (i = 0; i < sg_used; i++) {
2810
2886
{
2811
2887
        struct CommandList *c;
2812
2888
 
2813
 
        while (!hlist_empty(&h->reqQ)) {
2814
 
                c = hlist_entry(h->reqQ.first, struct CommandList, list);
 
2889
        while (!list_empty(&h->reqQ)) {
 
2890
                c = list_entry(h->reqQ.next, struct CommandList, list);
2815
2891
                /* can't do anything if fifo is full */
2816
2892
                if ((h->access.fifo_full(h))) {
2817
2893
                        dev_warn(&h->pdev->dev, "fifo full\n");
2867
2943
 
2868
2944
static inline u32 hpsa_tag_contains_index(u32 tag)
2869
2945
{
2870
 
#define DIRECT_LOOKUP_BIT 0x10
2871
2946
        return tag & DIRECT_LOOKUP_BIT;
2872
2947
}
2873
2948
 
2874
2949
static inline u32 hpsa_tag_to_index(u32 tag)
2875
2950
{
2876
 
#define DIRECT_LOOKUP_SHIFT 5
2877
2951
        return tag >> DIRECT_LOOKUP_SHIFT;
2878
2952
}
2879
2953
 
2880
 
static inline u32 hpsa_tag_discard_error_bits(u32 tag)
 
2954
 
 
2955
static inline u32 hpsa_tag_discard_error_bits(struct ctlr_info *h, u32 tag)
2881
2956
{
2882
 
#define HPSA_ERROR_BITS 0x03
2883
 
        return tag & ~HPSA_ERROR_BITS;
 
2957
#define HPSA_PERF_ERROR_BITS ((1 << DIRECT_LOOKUP_SHIFT) - 1)
 
2958
#define HPSA_SIMPLE_ERROR_BITS 0x03
 
2959
        if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
 
2960
                return tag & ~HPSA_SIMPLE_ERROR_BITS;
 
2961
        return tag & ~HPSA_PERF_ERROR_BITS;
2884
2962
}
2885
2963
 
2886
2964
/* process completion of an indexed ("direct lookup") command */
2904
2982
{
2905
2983
        u32 tag;
2906
2984
        struct CommandList *c = NULL;
2907
 
        struct hlist_node *tmp;
2908
2985
 
2909
 
        tag = hpsa_tag_discard_error_bits(raw_tag);
2910
 
        hlist_for_each_entry(c, tmp, &h->cmpQ, list) {
 
2986
        tag = hpsa_tag_discard_error_bits(h, raw_tag);
 
2987
        list_for_each_entry(c, &h->cmpQ, list) {
2911
2988
                if ((c->busaddr & 0xFFFFFFE0) == (tag & 0xFFFFFFE0)) {
2912
2989
                        finish_cmd(c, raw_tag);
2913
2990
                        return next_command(h);
2957
3034
        return IRQ_HANDLED;
2958
3035
}
2959
3036
 
2960
 
/* Send a message CDB to the firmware. */
 
3037
/* Send a message CDB to the firmware. Careful, this only works
 
3038
 * in simple mode, not performant mode due to the tag lookup.
 
3039
 * We only ever use this immediately after a controller reset.
 
3040
 */
2961
3041
static __devinit int hpsa_message(struct pci_dev *pdev, unsigned char opcode,
2962
3042
                                                unsigned char type)
2963
3043
{
3023
3103
 
3024
3104
        for (i = 0; i < HPSA_MSG_SEND_RETRY_LIMIT; i++) {
3025
3105
                tag = readl(vaddr + SA5_REPLY_PORT_OFFSET);
3026
 
                if (hpsa_tag_discard_error_bits(tag) == paddr32)
 
3106
                if ((tag & ~HPSA_SIMPLE_ERROR_BITS) == paddr32)
3027
3107
                        break;
3028
3108
                msleep(HPSA_MSG_SEND_RETRY_INTERVAL_MSECS);
3029
3109
        }
3055
3135
#define hpsa_soft_reset_controller(p) hpsa_message(p, 1, 0)
3056
3136
#define hpsa_noop(p) hpsa_message(p, 3, 0)
3057
3137
 
3058
 
static __devinit int hpsa_reset_msi(struct pci_dev *pdev)
3059
 
{
3060
 
/* the #defines are stolen from drivers/pci/msi.h. */
3061
 
#define msi_control_reg(base)           (base + PCI_MSI_FLAGS)
3062
 
#define PCI_MSIX_FLAGS_ENABLE           (1 << 15)
3063
 
 
3064
 
        int pos;
3065
 
        u16 control = 0;
3066
 
 
3067
 
        pos = pci_find_capability(pdev, PCI_CAP_ID_MSI);
3068
 
        if (pos) {
3069
 
                pci_read_config_word(pdev, msi_control_reg(pos), &control);
3070
 
                if (control & PCI_MSI_FLAGS_ENABLE) {
3071
 
                        dev_info(&pdev->dev, "resetting MSI\n");
3072
 
                        pci_write_config_word(pdev, msi_control_reg(pos),
3073
 
                                        control & ~PCI_MSI_FLAGS_ENABLE);
3074
 
                }
3075
 
        }
3076
 
 
3077
 
        pos = pci_find_capability(pdev, PCI_CAP_ID_MSIX);
3078
 
        if (pos) {
3079
 
                pci_read_config_word(pdev, msi_control_reg(pos), &control);
3080
 
                if (control & PCI_MSIX_FLAGS_ENABLE) {
3081
 
                        dev_info(&pdev->dev, "resetting MSI-X\n");
3082
 
                        pci_write_config_word(pdev, msi_control_reg(pos),
3083
 
                                        control & ~PCI_MSIX_FLAGS_ENABLE);
3084
 
                }
3085
 
        }
3086
 
 
3087
 
        return 0;
3088
 
}
3089
 
 
3090
3138
static int hpsa_controller_hard_reset(struct pci_dev *pdev,
3091
3139
        void * __iomem vaddr, bool use_doorbell)
3092
3140
{
3142
3190
 */
3143
3191
static __devinit int hpsa_kdump_hard_reset_controller(struct pci_dev *pdev)
3144
3192
{
3145
 
        u16 saved_config_space[32];
3146
3193
        u64 cfg_offset;
3147
3194
        u32 cfg_base_addr;
3148
3195
        u64 cfg_base_addr_index;
3149
3196
        void __iomem *vaddr;
3150
3197
        unsigned long paddr;
3151
3198
        u32 misc_fw_support, active_transport;
3152
 
        int rc, i;
 
3199
        int rc;
3153
3200
        struct CfgTable __iomem *cfgtable;
3154
3201
        bool use_doorbell;
3155
3202
        u32 board_id;
 
3203
        u16 command_register;
3156
3204
 
3157
3205
        /* For controllers as old as the P600, this is very nearly
3158
3206
         * the same thing as
3162
3210
         * pci_set_power_state(pci_dev, PCI_D0);
3163
3211
         * pci_restore_state(pci_dev);
3164
3212
         *
3165
 
         * but we can't use these nice canned kernel routines on
3166
 
         * kexec, because they also check the MSI/MSI-X state in PCI
3167
 
         * configuration space and do the wrong thing when it is
3168
 
         * set/cleared.  Also, the pci_save/restore_state functions
3169
 
         * violate the ordering requirements for restoring the
3170
 
         * configuration space from the CCISS document (see the
3171
 
         * comment below).  So we roll our own ....
3172
 
         *
3173
3213
         * For controllers newer than the P600, the pci power state
3174
3214
         * method of resetting doesn't work so we have another way
3175
3215
         * using the doorbell register.
3182
3222
         * likely not be happy.  Just forbid resetting this conjoined mess.
3183
3223
         * The 640x isn't really supported by hpsa anyway.
3184
3224
         */
3185
 
        hpsa_lookup_board_id(pdev, &board_id);
 
3225
        rc = hpsa_lookup_board_id(pdev, &board_id);
 
3226
        if (rc < 0) {
 
3227
                dev_warn(&pdev->dev, "Not resetting device.\n");
 
3228
                return -ENODEV;
 
3229
        }
3186
3230
        if (board_id == 0x409C0E11 || board_id == 0x409D0E11)
3187
3231
                return -ENOTSUPP;
3188
3232
 
3189
 
        for (i = 0; i < 32; i++)
3190
 
                pci_read_config_word(pdev, 2*i, &saved_config_space[i]);
3191
 
 
 
3233
        /* Save the PCI command register */
 
3234
        pci_read_config_word(pdev, 4, &command_register);
 
3235
        /* Turn the board off.  This is so that later pci_restore_state()
 
3236
         * won't turn the board on before the rest of config space is ready.
 
3237
         */
 
3238
        pci_disable_device(pdev);
 
3239
        pci_save_state(pdev);
3192
3240
 
3193
3241
        /* find the first memory BAR, so we can find the cfg table */
3194
3242
        rc = hpsa_pci_find_memory_BAR(pdev, &paddr);
3214
3262
        misc_fw_support = readl(&cfgtable->misc_fw_support);
3215
3263
        use_doorbell = misc_fw_support & MISC_FW_DOORBELL_RESET;
3216
3264
 
3217
 
        /* The doorbell reset seems to cause lockups on some Smart
3218
 
         * Arrays (e.g. P410, P410i, maybe others).  Until this is
3219
 
         * fixed or at least isolated, avoid the doorbell reset.
3220
 
         */
3221
 
        use_doorbell = 0;
3222
 
 
3223
3265
        rc = hpsa_controller_hard_reset(pdev, vaddr, use_doorbell);
3224
3266
        if (rc)
3225
3267
                goto unmap_cfgtable;
3226
3268
 
3227
 
        /* Restore the PCI configuration space.  The Open CISS
3228
 
         * Specification says, "Restore the PCI Configuration
3229
 
         * Registers, offsets 00h through 60h. It is important to
3230
 
         * restore the command register, 16-bits at offset 04h,
3231
 
         * last. Do not restore the configuration status register,
3232
 
         * 16-bits at offset 06h."  Note that the offset is 2*i.
3233
 
         */
3234
 
        for (i = 0; i < 32; i++) {
3235
 
                if (i == 2 || i == 3)
3236
 
                        continue;
3237
 
                pci_write_config_word(pdev, 2*i, saved_config_space[i]);
 
3269
        pci_restore_state(pdev);
 
3270
        rc = pci_enable_device(pdev);
 
3271
        if (rc) {
 
3272
                dev_warn(&pdev->dev, "failed to enable device.\n");
 
3273
                goto unmap_cfgtable;
3238
3274
        }
3239
 
        wmb();
3240
 
        pci_write_config_word(pdev, 4, saved_config_space[2]);
 
3275
        pci_write_config_word(pdev, 4, command_register);
3241
3276
 
3242
3277
        /* Some devices (notably the HP Smart Array 5i Controller)
3243
3278
           need a little pause here */
3244
3279
        msleep(HPSA_POST_RESET_PAUSE_MSECS);
3245
3280
 
 
3281
        /* Wait for board to become not ready, then ready. */
 
3282
        dev_info(&pdev->dev, "Waiting for board to become ready.\n");
 
3283
        rc = hpsa_wait_for_board_state(pdev, vaddr, BOARD_NOT_READY);
 
3284
        if (rc)
 
3285
                dev_warn(&pdev->dev,
 
3286
                        "failed waiting for board to become not ready\n");
 
3287
        rc = hpsa_wait_for_board_state(pdev, vaddr, BOARD_READY);
 
3288
        if (rc) {
 
3289
                dev_warn(&pdev->dev,
 
3290
                        "failed waiting for board to become ready\n");
 
3291
                goto unmap_cfgtable;
 
3292
        }
 
3293
        dev_info(&pdev->dev, "board ready.\n");
 
3294
 
3246
3295
        /* Controller should be in simple mode at this point.  If it's not,
3247
3296
         * It means we're on one of those controllers which doesn't support
3248
3297
         * the doorbell reset method and on which the PCI power management reset
3249
3298
         * method doesn't work (P800, for example.)
3250
 
         * In those cases, pretend the reset worked and hope for the best.
 
3299
         * In those cases, don't try to proceed, as it generally doesn't work.
3251
3300
         */
3252
3301
        active_transport = readl(&cfgtable->TransportActive);
3253
3302
        if (active_transport & PERFORMANT_MODE) {
3254
3303
                dev_warn(&pdev->dev, "Unable to successfully reset controller,"
3255
 
                        " proceeding anyway.\n");
3256
 
                rc = -ENOTSUPP;
 
3304
                        " Ignoring controller.\n");
 
3305
                rc = -ENODEV;
3257
3306
        }
3258
3307
 
3259
3308
unmap_cfgtable:
3386
3435
default_int_mode:
3387
3436
#endif                          /* CONFIG_PCI_MSI */
3388
3437
        /* if we get here we're going to use the default interrupt mode */
3389
 
        h->intr[PERF_MODE_INT] = h->pdev->irq;
 
3438
        h->intr[h->intr_mode] = h->pdev->irq;
3390
3439
}
3391
3440
 
3392
3441
static int __devinit hpsa_lookup_board_id(struct pci_dev *pdev, u32 *board_id)
3438
3487
        return -ENODEV;
3439
3488
}
3440
3489
 
3441
 
static int __devinit hpsa_wait_for_board_ready(struct ctlr_info *h)
 
3490
static int __devinit hpsa_wait_for_board_state(struct pci_dev *pdev,
 
3491
        void __iomem *vaddr, int wait_for_ready)
3442
3492
{
3443
 
        int i;
 
3493
        int i, iterations;
3444
3494
        u32 scratchpad;
 
3495
        if (wait_for_ready)
 
3496
                iterations = HPSA_BOARD_READY_ITERATIONS;
 
3497
        else
 
3498
                iterations = HPSA_BOARD_NOT_READY_ITERATIONS;
3445
3499
 
3446
 
        for (i = 0; i < HPSA_BOARD_READY_ITERATIONS; i++) {
3447
 
                scratchpad = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
3448
 
                if (scratchpad == HPSA_FIRMWARE_READY)
3449
 
                        return 0;
 
3500
        for (i = 0; i < iterations; i++) {
 
3501
                scratchpad = readl(vaddr + SA5_SCRATCHPAD_OFFSET);
 
3502
                if (wait_for_ready) {
 
3503
                        if (scratchpad == HPSA_FIRMWARE_READY)
 
3504
                                return 0;
 
3505
                } else {
 
3506
                        if (scratchpad != HPSA_FIRMWARE_READY)
 
3507
                                return 0;
 
3508
                }
3450
3509
                msleep(HPSA_BOARD_READY_POLL_INTERVAL_MSECS);
3451
3510
        }
3452
 
        dev_warn(&h->pdev->dev, "board not ready, timed out.\n");
 
3511
        dev_warn(&pdev->dev, "board not ready, timed out.\n");
3453
3512
        return -ENODEV;
3454
3513
}
3455
3514
 
3497
3556
static void __devinit hpsa_get_max_perf_mode_cmds(struct ctlr_info *h)
3498
3557
{
3499
3558
        h->max_commands = readl(&(h->cfgtable->MaxPerformantModeCommands));
 
3559
 
 
3560
        /* Limit commands in memory limited kdump scenario. */
 
3561
        if (reset_devices && h->max_commands > 32)
 
3562
                h->max_commands = 32;
 
3563
 
3500
3564
        if (h->max_commands < 16) {
3501
3565
                dev_warn(&h->pdev->dev, "Controller reports "
3502
3566
                        "max supported commands of %d, an obvious lie. "
3571
3635
static void __devinit hpsa_wait_for_mode_change_ack(struct ctlr_info *h)
3572
3636
{
3573
3637
        int i;
 
3638
        u32 doorbell_value;
 
3639
        unsigned long flags;
3574
3640
 
3575
3641
        /* under certain very rare conditions, this can take awhile.
3576
3642
         * (e.g.: hot replace a failed 144GB drive in a RAID 5 set right
3577
3643
         * as we enter this code.)
3578
3644
         */
3579
3645
        for (i = 0; i < MAX_CONFIG_WAIT; i++) {
3580
 
                if (!(readl(h->vaddr + SA5_DOORBELL) & CFGTBL_ChangeReq))
 
3646
                spin_lock_irqsave(&h->lock, flags);
 
3647
                doorbell_value = readl(h->vaddr + SA5_DOORBELL);
 
3648
                spin_unlock_irqrestore(&h->lock, flags);
 
3649
                if (!(doorbell_value & CFGTBL_ChangeReq))
3581
3650
                        break;
3582
3651
                /* delay and try again */
3583
 
                msleep(10);
 
3652
                usleep_range(10000, 20000);
3584
3653
        }
3585
3654
}
3586
3655
 
3603
3672
                        "unable to get board into simple mode\n");
3604
3673
                return -ENODEV;
3605
3674
        }
 
3675
        h->transMethod = CFGTBL_Trans_Simple;
3606
3676
        return 0;
3607
3677
}
3608
3678
 
3641
3711
                err = -ENOMEM;
3642
3712
                goto err_out_free_res;
3643
3713
        }
3644
 
        err = hpsa_wait_for_board_ready(h);
 
3714
        err = hpsa_wait_for_board_state(h->pdev, h->vaddr, BOARD_READY);
3645
3715
        if (err)
3646
3716
                goto err_out_free_res;
3647
3717
        err = hpsa_find_cfgtables(h);
3710
3780
                return 0; /* just try to do the kdump anyhow. */
3711
3781
        if (rc)
3712
3782
                return -ENODEV;
3713
 
        if (hpsa_reset_msi(pdev))
3714
 
                return -ENODEV;
3715
3783
 
3716
3784
        /* Now try to get the controller to respond to a no-op */
3717
3785
        for (i = 0; i < HPSA_POST_RESET_NOOP_RETRIES; i++) {
3749
3817
 
3750
3818
        h->pdev = pdev;
3751
3819
        h->busy_initializing = 1;
3752
 
        INIT_HLIST_HEAD(&h->cmpQ);
3753
 
        INIT_HLIST_HEAD(&h->reqQ);
 
3820
        h->intr_mode = hpsa_simple_mode ? SIMPLE_MODE_INT : PERF_MODE_INT;
 
3821
        INIT_LIST_HEAD(&h->cmpQ);
 
3822
        INIT_LIST_HEAD(&h->reqQ);
 
3823
        spin_lock_init(&h->lock);
 
3824
        spin_lock_init(&h->scan_lock);
3754
3825
        rc = hpsa_pci_init(h);
3755
3826
        if (rc != 0)
3756
3827
                goto clean1;
3777
3848
        h->access.set_intr_mask(h, HPSA_INTR_OFF);
3778
3849
 
3779
3850
        if (h->msix_vector || h->msi_vector)
3780
 
                rc = request_irq(h->intr[PERF_MODE_INT], do_hpsa_intr_msi,
 
3851
                rc = request_irq(h->intr[h->intr_mode], do_hpsa_intr_msi,
3781
3852
                                IRQF_DISABLED, h->devname, h);
3782
3853
        else
3783
 
                rc = request_irq(h->intr[PERF_MODE_INT], do_hpsa_intr_intx,
 
3854
                rc = request_irq(h->intr[h->intr_mode], do_hpsa_intr_intx,
3784
3855
                                IRQF_DISABLED, h->devname, h);
3785
3856
        if (rc) {
3786
3857
                dev_err(&pdev->dev, "unable to get irq %d for %s\n",
3787
 
                       h->intr[PERF_MODE_INT], h->devname);
 
3858
                       h->intr[h->intr_mode], h->devname);
3788
3859
                goto clean2;
3789
3860
        }
3790
3861
 
3791
3862
        dev_info(&pdev->dev, "%s: <0x%x> at IRQ %d%s using DAC\n",
3792
3863
               h->devname, pdev->device,
3793
 
               h->intr[PERF_MODE_INT], dac ? "" : " not");
 
3864
               h->intr[h->intr_mode], dac ? "" : " not");
3794
3865
 
3795
3866
        h->cmd_pool_bits =
3796
3867
            kmalloc(((h->nr_cmds + BITS_PER_LONG -
3810
3881
        }
3811
3882
        if (hpsa_allocate_sg_chain_blocks(h))
3812
3883
                goto clean4;
3813
 
        spin_lock_init(&h->lock);
3814
 
        spin_lock_init(&h->scan_lock);
3815
3884
        init_waitqueue_head(&h->scan_wait_queue);
3816
3885
        h->scan_finished = 1; /* no scan currently in progress */
3817
3886
 
3843
3912
                            h->nr_cmds * sizeof(struct ErrorInfo),
3844
3913
                            h->errinfo_pool,
3845
3914
                            h->errinfo_pool_dhandle);
3846
 
        free_irq(h->intr[PERF_MODE_INT], h);
 
3915
        free_irq(h->intr[h->intr_mode], h);
3847
3916
clean2:
3848
3917
clean1:
3849
3918
        h->busy_initializing = 0;
3887
3956
         */
3888
3957
        hpsa_flush_cache(h);
3889
3958
        h->access.set_intr_mask(h, HPSA_INTR_OFF);
3890
 
        free_irq(h->intr[PERF_MODE_INT], h);
 
3959
        free_irq(h->intr[h->intr_mode], h);
3891
3960
#ifdef CONFIG_PCI_MSI
3892
3961
        if (h->msix_vector)
3893
3962
                pci_disable_msix(h->pdev);
3989
4058
        }
3990
4059
}
3991
4060
 
3992
 
static __devinit void hpsa_enter_performant_mode(struct ctlr_info *h)
 
4061
static __devinit void hpsa_enter_performant_mode(struct ctlr_info *h,
 
4062
        u32 use_short_tags)
3993
4063
{
3994
4064
        int i;
3995
4065
        unsigned long register_value;
4037
4107
        writel(0, &h->transtable->RepQCtrAddrHigh32);
4038
4108
        writel(h->reply_pool_dhandle, &h->transtable->RepQAddr0Low32);
4039
4109
        writel(0, &h->transtable->RepQAddr0High32);
4040
 
        writel(CFGTBL_Trans_Performant,
 
4110
        writel(CFGTBL_Trans_Performant | use_short_tags,
4041
4111
                &(h->cfgtable->HostWrite.TransportRequest));
4042
4112
        writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL);
4043
4113
        hpsa_wait_for_mode_change_ack(h);
4047
4117
                                        " performant mode\n");
4048
4118
                return;
4049
4119
        }
 
4120
        /* Change the access methods to the performant access methods */
 
4121
        h->access = SA5_performant_access;
 
4122
        h->transMethod = CFGTBL_Trans_Performant;
4050
4123
}
4051
4124
 
4052
4125
static __devinit void hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h)
4053
4126
{
4054
4127
        u32 trans_support;
4055
4128
 
 
4129
        if (hpsa_simple_mode)
 
4130
                return;
 
4131
 
4056
4132
        trans_support = readl(&(h->cfgtable->TransportSupport));
4057
4133
        if (!(trans_support & PERFORMANT_MODE))
4058
4134
                return;
4072
4148
                || (h->blockFetchTable == NULL))
4073
4149
                goto clean_up;
4074
4150
 
4075
 
        hpsa_enter_performant_mode(h);
4076
 
 
4077
 
        /* Change the access methods to the performant access methods */
4078
 
        h->access = SA5_performant_access;
4079
 
        h->transMethod = CFGTBL_Trans_Performant;
 
4151
        hpsa_enter_performant_mode(h,
 
4152
                trans_support & CFGTBL_Trans_use_short_tags);
4080
4153
 
4081
4154
        return;
4082
4155