2 * Adaptec AAC series RAID controller driver
3 * (c) Copyright 2001 Red Hat Inc.
5 * based on the old aacraid driver that is..
6 * Adaptec aacraid device driver for Linux.
8 * Copyright (c) 2000-2010 Adaptec, Inc.
9 * 2010-2015 PMC-Sierra, Inc. (aacraid@pmc-sierra.com)
10 * 2016-2017 Microsemi Corp. (aacraid@microsemi.com)
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2, or (at your option)
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; see the file COPYING. If not, write to
24 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
29 * Abstract: This supports the initialization of the host adapter commuication interface.
30 * This is a platform dependent module for the pci cyclone board.
34 #include <linux/kernel.h>
35 #include <linux/init.h>
36 #include <linux/types.h>
37 #include <linux/pci.h>
38 #include <linux/spinlock.h>
39 #include <linux/slab.h>
40 #include <linux/blkdev.h>
41 #include <linux/delay.h>
42 #include <linux/completion.h>
44 #include <scsi/scsi_host.h>
45 #include <scsi/scsi_device.h>
46 #include <scsi/scsi_cmnd.h>
50 struct aac_common aac_config
= {
54 static inline int aac_is_msix_mode(struct aac_dev
*dev
)
59 status
= src_readl(dev
, MUnit
.OMR
);
60 return (status
& AAC_INT_MODE_MSIX
);
63 static inline void aac_change_to_intx(struct aac_dev
*dev
)
65 aac_src_access_devreg(dev
, AAC_DISABLE_MSIX
);
66 aac_src_access_devreg(dev
, AAC_ENABLE_INTX
);
69 static int aac_alloc_comm(struct aac_dev
*dev
, void **commaddr
, unsigned long commsize
, unsigned long commalign
)
72 unsigned long size
, align
;
73 const unsigned long fibsize
= dev
->max_fib_size
;
74 const unsigned long printfbufsiz
= 256;
75 unsigned long host_rrq_size
, aac_init_size
;
78 unsigned long aac_max_hostphysmempages
;
80 if ((dev
->comm_interface
== AAC_COMM_MESSAGE_TYPE1
) ||
81 (dev
->comm_interface
== AAC_COMM_MESSAGE_TYPE2
) ||
82 (dev
->comm_interface
== AAC_COMM_MESSAGE_TYPE3
&&
85 (dev
->scsi_host_ptr
->can_queue
+ AAC_NUM_MGT_FIB
)
87 aac_init_size
= sizeof(union aac_init
);
88 } else if (dev
->comm_interface
== AAC_COMM_MESSAGE_TYPE3
&&
90 host_rrq_size
= (dev
->scsi_host_ptr
->can_queue
91 + AAC_NUM_MGT_FIB
) * sizeof(u32
) * AAC_MAX_MSIX
;
92 aac_init_size
= sizeof(union aac_init
) +
93 (AAC_MAX_HRRQ
- 1) * sizeof(struct _rrq
);
96 aac_init_size
= sizeof(union aac_init
);
98 size
= fibsize
+ aac_init_size
+ commsize
+ commalign
+
99 printfbufsiz
+ host_rrq_size
;
101 base
= dma_alloc_coherent(&dev
->pdev
->dev
, size
, &phys
, GFP_KERNEL
);
103 printk(KERN_ERR
"aacraid: unable to create mapping.\n");
107 dev
->comm_addr
= (void *)base
;
108 dev
->comm_phys
= phys
;
109 dev
->comm_size
= size
;
111 if ((dev
->comm_interface
== AAC_COMM_MESSAGE_TYPE1
) ||
112 (dev
->comm_interface
== AAC_COMM_MESSAGE_TYPE2
) ||
113 (dev
->comm_interface
== AAC_COMM_MESSAGE_TYPE3
)) {
114 dev
->host_rrq
= (u32
*)(base
+ fibsize
);
115 dev
->host_rrq_pa
= phys
+ fibsize
;
116 memset(dev
->host_rrq
, 0, host_rrq_size
);
119 dev
->init
= (union aac_init
*)(base
+ fibsize
+ host_rrq_size
);
120 dev
->init_pa
= phys
+ fibsize
+ host_rrq_size
;
124 if (dev
->comm_interface
== AAC_COMM_MESSAGE_TYPE3
) {
128 init
->r8
.init_struct_revision
=
129 cpu_to_le32(ADAPTER_INIT_STRUCT_REVISION_8
);
130 init
->r8
.init_flags
= cpu_to_le32(INITFLAGS_NEW_COMM_SUPPORTED
|
131 INITFLAGS_DRIVER_USES_UTC_TIME
|
132 INITFLAGS_DRIVER_SUPPORTS_PM
);
133 init
->r8
.init_flags
|=
134 cpu_to_le32(INITFLAGS_DRIVER_SUPPORTS_HBA_MODE
);
135 init
->r8
.rr_queue_count
= cpu_to_le32(dev
->max_msix
);
136 init
->r8
.max_io_size
=
137 cpu_to_le32(dev
->scsi_host_ptr
->max_sectors
<< 9);
138 init
->r8
.max_num_aif
= init
->r8
.reserved1
=
139 init
->r8
.reserved2
= 0;
141 for (i
= 0; i
< dev
->max_msix
; i
++) {
142 addr
= (u64
)dev
->host_rrq_pa
+ dev
->vector_cap
* i
*
144 init
->r8
.rrq
[i
].host_addr_high
= cpu_to_le32(
145 upper_32_bits(addr
));
146 init
->r8
.rrq
[i
].host_addr_low
= cpu_to_le32(
147 lower_32_bits(addr
));
148 init
->r8
.rrq
[i
].msix_id
= i
;
149 init
->r8
.rrq
[i
].element_count
= cpu_to_le16(
150 (u16
)dev
->vector_cap
);
151 init
->r8
.rrq
[i
].comp_thresh
=
152 init
->r8
.rrq
[i
].unused
= 0;
155 pr_warn("aacraid: Comm Interface type3 enabled\n");
157 init
->r7
.init_struct_revision
=
158 cpu_to_le32(ADAPTER_INIT_STRUCT_REVISION
);
159 if (dev
->max_fib_size
!= sizeof(struct hw_fib
))
160 init
->r7
.init_struct_revision
=
161 cpu_to_le32(ADAPTER_INIT_STRUCT_REVISION_4
);
162 init
->r7
.no_of_msix_vectors
= cpu_to_le32(SA_MINIPORT_REVISION
);
163 init
->r7
.fsrev
= cpu_to_le32(dev
->fsrev
);
166 * Adapter Fibs are the first thing allocated so that they
169 dev
->aif_base_va
= (struct hw_fib
*)base
;
171 init
->r7
.adapter_fibs_virtual_address
= 0;
172 init
->r7
.adapter_fibs_physical_address
= cpu_to_le32((u32
)phys
);
173 init
->r7
.adapter_fibs_size
= cpu_to_le32(fibsize
);
174 init
->r7
.adapter_fib_align
= cpu_to_le32(sizeof(struct hw_fib
));
177 * number of 4k pages of host physical memory. The aacraid fw
178 * needs this number to be less than 4gb worth of pages. New
179 * firmware doesn't have any issues with the mapping system, but
180 * older Firmware did, and had *troubles* dealing with the math
181 * overloading past 32 bits, thus we must limit this field.
183 aac_max_hostphysmempages
=
184 dma_get_required_mask(&dev
->pdev
->dev
) >> 12;
185 if (aac_max_hostphysmempages
< AAC_MAX_HOSTPHYSMEMPAGES
)
186 init
->r7
.host_phys_mem_pages
=
187 cpu_to_le32(aac_max_hostphysmempages
);
189 init
->r7
.host_phys_mem_pages
=
190 cpu_to_le32(AAC_MAX_HOSTPHYSMEMPAGES
);
192 init
->r7
.init_flags
=
193 cpu_to_le32(INITFLAGS_DRIVER_USES_UTC_TIME
|
194 INITFLAGS_DRIVER_SUPPORTS_PM
);
195 init
->r7
.max_io_commands
=
196 cpu_to_le32(dev
->scsi_host_ptr
->can_queue
+
198 init
->r7
.max_io_size
=
199 cpu_to_le32(dev
->scsi_host_ptr
->max_sectors
<< 9);
200 init
->r7
.max_fib_size
= cpu_to_le32(dev
->max_fib_size
);
201 init
->r7
.max_num_aif
= cpu_to_le32(dev
->max_num_aif
);
203 if (dev
->comm_interface
== AAC_COMM_MESSAGE
) {
204 init
->r7
.init_flags
|=
205 cpu_to_le32(INITFLAGS_NEW_COMM_SUPPORTED
);
206 pr_warn("aacraid: Comm Interface enabled\n");
207 } else if (dev
->comm_interface
== AAC_COMM_MESSAGE_TYPE1
) {
208 init
->r7
.init_struct_revision
=
209 cpu_to_le32(ADAPTER_INIT_STRUCT_REVISION_6
);
210 init
->r7
.init_flags
|=
211 cpu_to_le32(INITFLAGS_NEW_COMM_SUPPORTED
|
212 INITFLAGS_NEW_COMM_TYPE1_SUPPORTED
|
213 INITFLAGS_FAST_JBOD_SUPPORTED
);
214 init
->r7
.host_rrq_addr_high
=
215 cpu_to_le32(upper_32_bits(dev
->host_rrq_pa
));
216 init
->r7
.host_rrq_addr_low
=
217 cpu_to_le32(lower_32_bits(dev
->host_rrq_pa
));
218 pr_warn("aacraid: Comm Interface type1 enabled\n");
219 } else if (dev
->comm_interface
== AAC_COMM_MESSAGE_TYPE2
) {
220 init
->r7
.init_struct_revision
=
221 cpu_to_le32(ADAPTER_INIT_STRUCT_REVISION_7
);
222 init
->r7
.init_flags
|=
223 cpu_to_le32(INITFLAGS_NEW_COMM_SUPPORTED
|
224 INITFLAGS_NEW_COMM_TYPE2_SUPPORTED
|
225 INITFLAGS_FAST_JBOD_SUPPORTED
);
226 init
->r7
.host_rrq_addr_high
=
227 cpu_to_le32(upper_32_bits(dev
->host_rrq_pa
));
228 init
->r7
.host_rrq_addr_low
=
229 cpu_to_le32(lower_32_bits(dev
->host_rrq_pa
));
230 init
->r7
.no_of_msix_vectors
=
231 cpu_to_le32(dev
->max_msix
);
232 /* must be the COMM_PREFERRED_SETTINGS values */
233 pr_warn("aacraid: Comm Interface type2 enabled\n");
238 * Increment the base address by the amount already used
240 base
= base
+ fibsize
+ host_rrq_size
+ aac_init_size
;
241 phys
= (dma_addr_t
)((ulong
)phys
+ fibsize
+ host_rrq_size
+
245 * Align the beginning of Headers to commalign
247 align
= (commalign
- ((uintptr_t)(base
) & (commalign
- 1)));
251 * Fill in addresses of the Comm Area Headers and Queues
254 if (dev
->comm_interface
!= AAC_COMM_MESSAGE_TYPE3
)
255 init
->r7
.comm_header_address
= cpu_to_le32((u32
)phys
);
257 * Increment the base address by the size of the CommArea
259 base
= base
+ commsize
;
260 phys
= phys
+ commsize
;
262 * Place the Printf buffer area after the Fast I/O comm area.
264 dev
->printfbuf
= (void *)base
;
265 if (dev
->comm_interface
!= AAC_COMM_MESSAGE_TYPE3
) {
266 init
->r7
.printfbuf
= cpu_to_le32(phys
);
267 init
->r7
.printfbufsiz
= cpu_to_le32(printfbufsiz
);
269 memset(base
, 0, printfbufsiz
);
273 static void aac_queue_init(struct aac_dev
* dev
, struct aac_queue
* q
, u32
*mem
, int qsize
)
275 atomic_set(&q
->numpending
, 0);
277 init_waitqueue_head(&q
->cmdready
);
278 INIT_LIST_HEAD(&q
->cmdq
);
279 init_waitqueue_head(&q
->qfull
);
280 spin_lock_init(&q
->lockdata
);
281 q
->lock
= &q
->lockdata
;
282 q
->headers
.producer
= (__le32
*)mem
;
283 q
->headers
.consumer
= (__le32
*)(mem
+1);
284 *(q
->headers
.producer
) = cpu_to_le32(qsize
);
285 *(q
->headers
.consumer
) = cpu_to_le32(qsize
);
289 static void aac_wait_for_io_completion(struct aac_dev
*aac
)
291 unsigned long flagv
= 0;
294 for (i
= 60; i
; --i
) {
295 struct scsi_device
*dev
;
296 struct scsi_cmnd
*command
;
299 __shost_for_each_device(dev
, aac
->scsi_host_ptr
) {
300 spin_lock_irqsave(&dev
->list_lock
, flagv
);
301 list_for_each_entry(command
, &dev
->cmd_list
, list
) {
302 if (command
->SCp
.phase
== AAC_OWNER_FIRMWARE
) {
307 spin_unlock_irqrestore(&dev
->list_lock
, flagv
);
313 * We can exit If all the commands are complete
322 * aac_send_shutdown - shutdown an adapter
323 * @dev: Adapter to shutdown
325 * This routine will send a VM_CloseAll (shutdown) request to the adapter.
328 int aac_send_shutdown(struct aac_dev
* dev
)
331 struct aac_close
*cmd
;
334 if (aac_adapter_check_health(dev
))
337 if (!dev
->adapter_shutdown
) {
338 mutex_lock(&dev
->ioctl_mutex
);
339 dev
->adapter_shutdown
= 1;
340 mutex_unlock(&dev
->ioctl_mutex
);
343 aac_wait_for_io_completion(dev
);
345 fibctx
= aac_fib_alloc(dev
);
348 aac_fib_init(fibctx
);
350 cmd
= (struct aac_close
*) fib_data(fibctx
);
351 cmd
->command
= cpu_to_le32(VM_CloseAll
);
352 cmd
->cid
= cpu_to_le32(0xfffffffe);
354 status
= aac_fib_send(ContainerCommand
,
356 sizeof(struct aac_close
),
358 -2 /* Timeout silently */, 1,
362 aac_fib_complete(fibctx
);
363 /* FIB should be freed only after getting the response from the F/W */
364 if (status
!= -ERESTARTSYS
)
365 aac_fib_free(fibctx
);
366 if (aac_is_src(dev
) &&
368 aac_set_intx_mode(dev
);
373 * aac_comm_init - Initialise FSA data structures
374 * @dev: Adapter to initialise
376 * Initializes the data structures that are required for the FSA commuication
377 * interface to operate.
379 * 1 - if we were able to init the commuication interface.
380 * 0 - If there were errors initing. This is a fatal error.
383 static int aac_comm_init(struct aac_dev
* dev
)
385 unsigned long hdrsize
= (sizeof(u32
) * NUMBER_OF_COMM_QUEUES
) * 2;
386 unsigned long queuesize
= sizeof(struct aac_entry
) * TOTAL_QUEUE_ENTRIES
;
388 struct aac_entry
* queues
;
390 struct aac_queue_block
* comm
= dev
->queues
;
392 * Now allocate and initialize the zone structures used as our
393 * pool of FIB context records. The size of the zone is based
394 * on the system memory size. We also initialize the mutex used
395 * to protect the zone.
397 spin_lock_init(&dev
->fib_lock
);
400 * Allocate the physically contiguous space for the commuication
404 size
= hdrsize
+ queuesize
;
406 if (!aac_alloc_comm(dev
, (void * *)&headers
, size
, QUEUE_ALIGNMENT
))
409 queues
= (struct aac_entry
*)(((ulong
)headers
) + hdrsize
);
411 /* Adapter to Host normal priority Command queue */
412 comm
->queue
[HostNormCmdQueue
].base
= queues
;
413 aac_queue_init(dev
, &comm
->queue
[HostNormCmdQueue
], headers
, HOST_NORM_CMD_ENTRIES
);
414 queues
+= HOST_NORM_CMD_ENTRIES
;
417 /* Adapter to Host high priority command queue */
418 comm
->queue
[HostHighCmdQueue
].base
= queues
;
419 aac_queue_init(dev
, &comm
->queue
[HostHighCmdQueue
], headers
, HOST_HIGH_CMD_ENTRIES
);
421 queues
+= HOST_HIGH_CMD_ENTRIES
;
424 /* Host to adapter normal priority command queue */
425 comm
->queue
[AdapNormCmdQueue
].base
= queues
;
426 aac_queue_init(dev
, &comm
->queue
[AdapNormCmdQueue
], headers
, ADAP_NORM_CMD_ENTRIES
);
428 queues
+= ADAP_NORM_CMD_ENTRIES
;
431 /* host to adapter high priority command queue */
432 comm
->queue
[AdapHighCmdQueue
].base
= queues
;
433 aac_queue_init(dev
, &comm
->queue
[AdapHighCmdQueue
], headers
, ADAP_HIGH_CMD_ENTRIES
);
435 queues
+= ADAP_HIGH_CMD_ENTRIES
;
438 /* adapter to host normal priority response queue */
439 comm
->queue
[HostNormRespQueue
].base
= queues
;
440 aac_queue_init(dev
, &comm
->queue
[HostNormRespQueue
], headers
, HOST_NORM_RESP_ENTRIES
);
441 queues
+= HOST_NORM_RESP_ENTRIES
;
444 /* adapter to host high priority response queue */
445 comm
->queue
[HostHighRespQueue
].base
= queues
;
446 aac_queue_init(dev
, &comm
->queue
[HostHighRespQueue
], headers
, HOST_HIGH_RESP_ENTRIES
);
448 queues
+= HOST_HIGH_RESP_ENTRIES
;
451 /* host to adapter normal priority response queue */
452 comm
->queue
[AdapNormRespQueue
].base
= queues
;
453 aac_queue_init(dev
, &comm
->queue
[AdapNormRespQueue
], headers
, ADAP_NORM_RESP_ENTRIES
);
455 queues
+= ADAP_NORM_RESP_ENTRIES
;
458 /* host to adapter high priority response queue */
459 comm
->queue
[AdapHighRespQueue
].base
= queues
;
460 aac_queue_init(dev
, &comm
->queue
[AdapHighRespQueue
], headers
, ADAP_HIGH_RESP_ENTRIES
);
462 comm
->queue
[AdapNormCmdQueue
].lock
= comm
->queue
[HostNormRespQueue
].lock
;
463 comm
->queue
[AdapHighCmdQueue
].lock
= comm
->queue
[HostHighRespQueue
].lock
;
464 comm
->queue
[AdapNormRespQueue
].lock
= comm
->queue
[HostNormCmdQueue
].lock
;
465 comm
->queue
[AdapHighRespQueue
].lock
= comm
->queue
[HostHighCmdQueue
].lock
;
470 void aac_define_int_mode(struct aac_dev
*dev
)
472 int i
, msi_count
, min_msix
;
475 /* max. vectors from GET_COMM_PREFERRED_SETTINGS */
476 if (dev
->max_msix
== 0 ||
477 dev
->pdev
->device
== PMC_DEVICE_S6
||
481 dev
->scsi_host_ptr
->can_queue
+
486 /* Don't bother allocating more MSI-X vectors than cpus */
487 msi_count
= min(dev
->max_msix
,
488 (unsigned int)num_online_cpus());
490 dev
->max_msix
= msi_count
;
492 if (msi_count
> AAC_MAX_MSIX
)
493 msi_count
= AAC_MAX_MSIX
;
496 pci_find_capability(dev
->pdev
, PCI_CAP_ID_MSIX
)) {
498 i
= pci_alloc_irq_vectors(dev
->pdev
,
500 PCI_IRQ_MSIX
| PCI_IRQ_AFFINITY
);
502 dev
->msi_enabled
= 1;
505 dev
->msi_enabled
= 0;
506 dev_err(&dev
->pdev
->dev
,
507 "MSIX not supported!! Will try INTX 0x%x.\n", i
);
511 if (!dev
->msi_enabled
)
512 dev
->max_msix
= msi_count
= 1;
514 if (dev
->max_msix
> msi_count
)
515 dev
->max_msix
= msi_count
;
517 if (dev
->comm_interface
== AAC_COMM_MESSAGE_TYPE3
&& dev
->sa_firmware
)
518 dev
->vector_cap
= dev
->scsi_host_ptr
->can_queue
+
521 dev
->vector_cap
= (dev
->scsi_host_ptr
->can_queue
+
522 AAC_NUM_MGT_FIB
) / msi_count
;
525 struct aac_dev
*aac_init_adapter(struct aac_dev
*dev
)
528 struct Scsi_Host
* host
= dev
->scsi_host_ptr
;
529 extern int aac_sync_mode
;
532 * Check the preferred comm settings, defaults from template.
534 dev
->management_fib_count
= 0;
535 spin_lock_init(&dev
->manage_lock
);
536 spin_lock_init(&dev
->sync_lock
);
537 spin_lock_init(&dev
->iq_lock
);
538 dev
->max_fib_size
= sizeof(struct hw_fib
);
539 dev
->sg_tablesize
= host
->sg_tablesize
= (dev
->max_fib_size
540 - sizeof(struct aac_fibhdr
)
541 - sizeof(struct aac_write
) + sizeof(struct sgentry
))
542 / sizeof(struct sgentry
);
543 dev
->comm_interface
= AAC_COMM_PRODUCER
;
544 dev
->raw_io_interface
= dev
->raw_io_64
= 0;
548 * Enable INTX mode, if not done already Enabled
550 if (aac_is_msix_mode(dev
)) {
551 aac_change_to_intx(dev
);
552 dev_info(&dev
->pdev
->dev
, "Changed firmware to INTX mode");
555 if ((!aac_adapter_sync_cmd(dev
, GET_ADAPTER_PROPERTIES
,
557 status
+0, status
+1, status
+2, status
+3, status
+4)) &&
558 (status
[0] == 0x00000001)) {
559 dev
->doorbell_mask
= status
[3];
560 if (status
[1] & AAC_OPT_NEW_COMM_64
)
562 dev
->sync_mode
= aac_sync_mode
;
563 if (dev
->a_ops
.adapter_comm
&&
564 (status
[1] & AAC_OPT_NEW_COMM
)) {
565 dev
->comm_interface
= AAC_COMM_MESSAGE
;
566 dev
->raw_io_interface
= 1;
567 if ((status
[1] & AAC_OPT_NEW_COMM_TYPE1
)) {
568 /* driver supports TYPE1 (Tupelo) */
569 dev
->comm_interface
= AAC_COMM_MESSAGE_TYPE1
;
570 } else if (status
[1] & AAC_OPT_NEW_COMM_TYPE2
) {
571 /* driver supports TYPE2 (Denali, Yosemite) */
572 dev
->comm_interface
= AAC_COMM_MESSAGE_TYPE2
;
573 } else if (status
[1] & AAC_OPT_NEW_COMM_TYPE3
) {
574 /* driver supports TYPE3 (Yosemite, Thor) */
575 dev
->comm_interface
= AAC_COMM_MESSAGE_TYPE3
;
576 } else if (status
[1] & AAC_OPT_NEW_COMM_TYPE4
) {
577 /* not supported TYPE - switch to sync. mode */
578 dev
->comm_interface
= AAC_COMM_MESSAGE_TYPE2
;
582 if ((status
[1] & le32_to_cpu(AAC_OPT_EXTENDED
)) &&
583 (status
[4] & le32_to_cpu(AAC_EXTOPT_SA_FIRMWARE
)))
584 dev
->sa_firmware
= 1;
586 dev
->sa_firmware
= 0;
588 if ((dev
->comm_interface
== AAC_COMM_MESSAGE
) &&
589 (status
[2] > dev
->base_size
)) {
590 aac_adapter_ioremap(dev
, 0);
591 dev
->base_size
= status
[2];
592 if (aac_adapter_ioremap(dev
, status
[2])) {
593 /* remap failed, go back ... */
594 dev
->comm_interface
= AAC_COMM_PRODUCER
;
595 if (aac_adapter_ioremap(dev
, AAC_MIN_FOOTPRINT_SIZE
)) {
597 "aacraid: unable to map adapter.\n");
604 dev
->msi_enabled
= 0;
605 dev
->adapter_shutdown
= 0;
606 if ((!aac_adapter_sync_cmd(dev
, GET_COMM_PREFERRED_SETTINGS
,
608 status
+0, status
+1, status
+2, status
+3, status
+4))
609 && (status
[0] == 0x00000001)) {
611 * status[1] >> 16 maximum command size in KB
612 * status[1] & 0xFFFF maximum FIB size
613 * status[2] >> 16 maximum SG elements to driver
614 * status[2] & 0xFFFF maximum SG elements from driver
615 * status[3] & 0xFFFF maximum number FIBs outstanding
617 host
->max_sectors
= (status
[1] >> 16) << 1;
618 /* Multiple of 32 for PMC */
619 dev
->max_fib_size
= status
[1] & 0xFFE0;
620 host
->sg_tablesize
= status
[2] >> 16;
621 dev
->sg_tablesize
= status
[2] & 0xFFFF;
622 if (aac_is_src(dev
)) {
623 if (host
->can_queue
> (status
[3] >> 16) -
625 host
->can_queue
= (status
[3] >> 16) -
627 } else if (host
->can_queue
> (status
[3] & 0xFFFF) -
629 host
->can_queue
= (status
[3] & 0xFFFF) -
632 dev
->max_num_aif
= status
[4] & 0xFFFF;
635 if (numacb
< host
->can_queue
)
636 host
->can_queue
= numacb
;
638 pr_warn("numacb=%d ignored\n", numacb
);
642 aac_define_int_mode(dev
);
644 * Ok now init the communication subsystem
647 dev
->queues
= kzalloc(sizeof(struct aac_queue_block
), GFP_KERNEL
);
648 if (dev
->queues
== NULL
) {
649 printk(KERN_ERR
"Error could not allocate comm region.\n");
653 if (aac_comm_init(dev
)<0){
658 * Initialize the list of fibs
660 if (aac_fib_setup(dev
) < 0) {
665 INIT_LIST_HEAD(&dev
->fib_list
);
666 INIT_LIST_HEAD(&dev
->sync_fib_list
);