isci: enable isci for dmar builds
[deliverable/linux.git] / drivers / scsi / isci / init.c
CommitLineData
6f231dda
DW
1/*
2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
4 *
5 * GPL LICENSE SUMMARY
6 *
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * BSD LICENSE
25 *
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
28 *
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
32 *
33 * * Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * * Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in
37 * the documentation and/or other materials provided with the
38 * distribution.
39 * * Neither the name of Intel Corporation nor the names of its
40 * contributors may be used to endorse or promote products derived
41 * from this software without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 */
55
56#include <linux/kernel.h>
57#include <linux/init.h>
58#include <linux/module.h>
59#include <asm/string.h>
60#include "isci.h"
61#include "task.h"
62#include "sci_controller_constants.h"
63#include "scic_remote_device.h"
64#include "sci_environment.h"
65
66static struct scsi_transport_template *isci_transport_template;
67struct kmem_cache *isci_kmem_cache;
68
69static DEFINE_PCI_DEVICE_TABLE(isci_id_table) = {
70 { PCI_VDEVICE(INTEL, 0x1D61),},
71 { PCI_VDEVICE(INTEL, 0x1D63),},
72 { PCI_VDEVICE(INTEL, 0x1D65),},
73 { PCI_VDEVICE(INTEL, 0x1D67),},
74 { PCI_VDEVICE(INTEL, 0x1D69),},
75 { PCI_VDEVICE(INTEL, 0x1D6B),},
76 { PCI_VDEVICE(INTEL, 0x1D60),},
77 { PCI_VDEVICE(INTEL, 0x1D62),},
78 { PCI_VDEVICE(INTEL, 0x1D64),},
79 { PCI_VDEVICE(INTEL, 0x1D66),},
80 { PCI_VDEVICE(INTEL, 0x1D68),},
81 { PCI_VDEVICE(INTEL, 0x1D6A),},
82 {}
83};
84
858d4aa7
DJ
85struct isci_firmware *isci_firmware;
86
6f231dda
DW
87static int __devinit isci_pci_probe(
88 struct pci_dev *pdev,
89 const struct pci_device_id *device_id_p);
90
91static void __devexit isci_pci_remove(struct pci_dev *pdev);
92
93MODULE_DEVICE_TABLE(pci, isci_id_table);
94
95static struct pci_driver isci_pci_driver = {
96 .name = DRV_NAME,
97 .id_table = isci_id_table,
98 .probe = isci_pci_probe,
99 .remove = __devexit_p(isci_pci_remove),
100};
101
102/* linux isci specific settings */
6f231dda
DW
103
104#if defined(CONFIG_PBG_HBA_A0)
105int isci_si_rev = ISCI_SI_REVA0;
106#elif defined(CONFIG_PBG_HBA_A2)
107int isci_si_rev = ISCI_SI_REVA2;
108#else
109int isci_si_rev = ISCI_SI_REVB0;
110#endif
111module_param(isci_si_rev, int, S_IRUGO | S_IWUSR);
112MODULE_PARM_DESC(isci_si_rev, "override default si rev (0: A0 1: A2 2: B0)");
113
114static struct scsi_host_template isci_sht = {
115
116 .module = THIS_MODULE,
117 .name = DRV_NAME,
92cd5115 118 .proc_name = DRV_NAME,
6f231dda
DW
119 .queuecommand = sas_queuecommand,
120 .target_alloc = sas_target_alloc,
121 .slave_configure = sas_slave_configure,
122 .slave_destroy = sas_slave_destroy,
123 .scan_finished = isci_host_scan_finished,
124 .scan_start = isci_host_scan_start,
125 .change_queue_depth = sas_change_queue_depth,
126 .change_queue_type = sas_change_queue_type,
127 .bios_param = sas_bios_param,
128 .can_queue = ISCI_CAN_QUEUE_VAL,
129 .cmd_per_lun = 1,
130 .this_id = -1,
131 .sg_tablesize = SG_ALL,
132 .max_sectors = SCSI_DEFAULT_MAX_SECTORS,
133 .use_clustering = ENABLE_CLUSTERING,
134 .eh_device_reset_handler = sas_eh_device_reset_handler,
135 .eh_bus_reset_handler = isci_bus_reset_handler,
136 .slave_alloc = sas_slave_alloc,
137 .target_destroy = sas_target_destroy,
138 .ioctl = sas_ioctl,
139};
140
141static struct sas_domain_function_template isci_transport_ops = {
142
143 /* The class calls these to notify the LLDD of an event. */
144 .lldd_port_formed = isci_port_formed,
145 .lldd_port_deformed = isci_port_deformed,
146
147 /* The class calls these when a device is found or gone. */
148 .lldd_dev_found = isci_remote_device_found,
149 .lldd_dev_gone = isci_remote_device_gone,
150
151 .lldd_execute_task = isci_task_execute_task,
152 /* Task Management Functions. Must be called from process context. */
153 .lldd_abort_task = isci_task_abort_task,
154 .lldd_abort_task_set = isci_task_abort_task_set,
155 .lldd_clear_aca = isci_task_clear_aca,
156 .lldd_clear_task_set = isci_task_clear_task_set,
157 .lldd_I_T_nexus_reset = isci_task_I_T_nexus_reset,
158 .lldd_lu_reset = isci_task_lu_reset,
159 .lldd_query_task = isci_task_query_task,
160
161 /* Port and Adapter management */
162 .lldd_clear_nexus_port = isci_task_clear_nexus_port,
163 .lldd_clear_nexus_ha = isci_task_clear_nexus_ha,
164
165 /* Phy management */
166 .lldd_control_phy = isci_phy_control,
167};
168
169
170/******************************************************************************
171* P R O T E C T E D M E T H O D S
172******************************************************************************/
173
174
175
176/**
177 * isci_register_sas_ha() - This method initializes various lldd
178 * specific members of the sas_ha struct and calls the libsas
179 * sas_register_ha() function.
180 * @isci_host: This parameter specifies the lldd specific wrapper for the
181 * libsas sas_ha struct.
182 *
183 * This method returns an error code indicating sucess or failure. The user
184 * should check for possible memory allocation error return otherwise, a zero
185 * indicates success.
186 */
187static int isci_register_sas_ha(struct isci_host *isci_host)
188{
189 int i;
190 struct sas_ha_struct *sas_ha = &(isci_host->sas_ha);
191 struct asd_sas_phy **sas_phys;
192 struct asd_sas_port **sas_ports;
193
194 sas_phys = devm_kzalloc(&isci_host->pdev->dev,
195 SCI_MAX_PHYS * sizeof(void *),
196 GFP_KERNEL);
197 if (!sas_phys)
198 return -ENOMEM;
199
200 sas_ports = devm_kzalloc(&isci_host->pdev->dev,
201 SCI_MAX_PORTS * sizeof(void *),
202 GFP_KERNEL);
203 if (!sas_ports)
204 return -ENOMEM;
205
206 /*----------------- Libsas Initialization Stuff----------------------
207 * Set various fields in the sas_ha struct:
208 */
209
210 sas_ha->sas_ha_name = DRV_NAME;
211 sas_ha->lldd_module = THIS_MODULE;
150fc6fc 212 sas_ha->sas_addr = &isci_host->phys[0].sas_addr[0];
6f231dda
DW
213
214 /* set the array of phy and port structs. */
215 for (i = 0; i < SCI_MAX_PHYS; i++) {
216 sas_phys[i] = &(isci_host->phys[i].sas_phy);
217 sas_ports[i] = &(isci_host->sas_ports[i]);
218 }
219
220 sas_ha->sas_phy = sas_phys;
221 sas_ha->sas_port = sas_ports;
222 sas_ha->num_phys = SCI_MAX_PHYS;
223
224 sas_ha->lldd_queue_size = ISCI_CAN_QUEUE_VAL;
225 sas_ha->lldd_max_execute_num = 1;
226 sas_ha->strict_wide_ports = 1;
227
228 sas_register_ha(sas_ha);
229
230 return 0;
231}
232
233static void isci_unregister_sas_ha(struct isci_host *isci_host)
234{
235 if (!isci_host)
236 return;
237
238 sas_unregister_ha(&(isci_host->sas_ha));
239
240 sas_remove_host(isci_host->shost);
241 scsi_remove_host(isci_host->shost);
242 scsi_host_put(isci_host->shost);
243}
244
245static int __devinit isci_pci_init(struct pci_dev *pdev)
246{
247 int err, bar_num, bar_mask;
248 void __iomem * const *iomap;
249
250 err = pcim_enable_device(pdev);
251 if (err) {
252 dev_err(&pdev->dev,
253 "failed enable PCI device %s!\n",
254 pci_name(pdev));
255 return err;
256 }
257
258 for (bar_num = 0; bar_num < SCI_PCI_BAR_COUNT; bar_num++)
259 bar_mask |= 1 << (bar_num * 2);
260
261 err = pcim_iomap_regions(pdev, bar_mask, DRV_NAME);
262 if (err)
263 return err;
264
265 iomap = pcim_iomap_table(pdev);
266 if (!iomap)
267 return -ENOMEM;
268
269 pci_set_master(pdev);
270
271 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
272 if (err) {
273 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
274 if (err)
275 return err;
276 }
277
278 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
279 if (err) {
280 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
281 if (err)
282 return err;
283 }
284
285 return 0;
286}
287
288static struct isci_host *isci_host_by_id(struct pci_dev *pdev, int id)
289{
290 struct isci_host *h;
291
292 for_each_isci_host(h, pdev)
293 if (h->id == id)
294 return h;
295 return NULL;
296}
297
298static int num_controllers(struct pci_dev *pdev)
299{
300 /* bar size alone can tell us if we are running with a dual controller
301 * part, no need to trust revision ids that might be under broken firmware
302 * control
303 */
304 resource_size_t scu_bar_size = pci_resource_len(pdev, SCI_SCU_BAR*2);
305 resource_size_t smu_bar_size = pci_resource_len(pdev, SCI_SMU_BAR*2);
306
307 if (scu_bar_size >= SCI_SCU_BAR_SIZE*SCI_MAX_CONTROLLERS &&
308 smu_bar_size >= SCI_SMU_BAR_SIZE*SCI_MAX_CONTROLLERS)
309 return SCI_MAX_CONTROLLERS;
310 else
311 return 1;
312}
313
314static int isci_setup_interrupts(struct pci_dev *pdev)
315{
316 int err, i, num_msix;
317 struct isci_pci_info *pci_info = to_pci_info(pdev);
318
319 /*
320 * Determine the number of vectors associated with this
321 * PCI function.
322 */
323 num_msix = num_controllers(pdev) * SCI_NUM_MSI_X_INT;
324
325 for (i = 0; i < num_msix; i++)
326 pci_info->msix_entries[i].entry = i;
327
328 err = pci_enable_msix(pdev, pci_info->msix_entries, num_msix);
329 if (err)
330 goto intx;
331
332 for (i = 0; i < num_msix; i++) {
333 int id = i / SCI_NUM_MSI_X_INT;
334 struct msix_entry *msix = &pci_info->msix_entries[i];
335 struct isci_host *isci_host = isci_host_by_id(pdev, id);
92f4f0f5
DW
336 irq_handler_t isr;
337
338 /* odd numbered vectors are error interrupts */
339 if (i & 1)
340 isr = isci_error_isr;
341 else
342 isr = isci_msix_isr;
6f231dda
DW
343
344 BUG_ON(!isci_host);
345
92f4f0f5 346 err = devm_request_irq(&pdev->dev, msix->vector, isr, 0,
6f231dda
DW
347 DRV_NAME"-msix", isci_host);
348 if (!err)
349 continue;
350
351 dev_info(&pdev->dev, "msix setup failed falling back to intx\n");
352 while (i--) {
353 id = i / SCI_NUM_MSI_X_INT;
354 isci_host = isci_host_by_id(pdev, id);
355 msix = &pci_info->msix_entries[i];
356 devm_free_irq(&pdev->dev, msix->vector, isci_host);
357 }
358 pci_disable_msix(pdev);
359 goto intx;
360 }
361
362 return 0;
363
364 intx:
c7ef4031 365 err = devm_request_irq(&pdev->dev, pdev->irq, isci_intx_isr,
6f231dda
DW
366 IRQF_SHARED, DRV_NAME"-intx", pdev);
367
368 return err;
369}
370
371/**
372 * isci_parse_oem_parameters() - This method will take OEM parameters
373 * from the module init parameters and copy them to oem_params. This will
374 * only copy values that are not set to the module parameter default values
375 * @oem_parameters: This parameter specifies the controller default OEM
376 * parameters. It is expected that this has been initialized to the default
377 * parameters for the controller
378 *
379 *
380 */
381enum sci_status isci_parse_oem_parameters(union scic_oem_parameters *oem_params,
382 int scu_index,
383 struct isci_firmware *fw)
384{
385 int i;
386
387 /* check for valid inputs */
388 if (!(scu_index >= 0
389 && scu_index < SCI_MAX_CONTROLLERS
390 && oem_params != NULL)) {
391 return SCI_FAILURE;
392 }
393
394 for (i = 0; i < SCI_MAX_PHYS; i++) {
395 int array_idx = i + (SCI_MAX_PHYS * scu_index);
396 u64 sas_addr = fw->sas_addrs[array_idx];
397
398 if (sas_addr != 0) {
399 oem_params->sds1.phys[i].sas_address.low =
400 (u32)(sas_addr & 0xffffffff);
401 oem_params->sds1.phys[i].sas_address.high =
402 (u32)((sas_addr >> 32) & 0xffffffff);
403 }
404 }
405
406 for (i = 0; i < SCI_MAX_PORTS; i++) {
407 int array_idx = i + (SCI_MAX_PORTS * scu_index);
408 u32 pmask = fw->phy_masks[array_idx];
409
410 oem_params->sds1.ports[i].phy_mask = pmask;
411 }
412
413 return SCI_SUCCESS;
414}
415
416/**
417 * isci_parse_user_parameters() - This method will take user parameters
418 * from the module init parameters and copy them to user_params. This will
419 * only copy values that are not set to the module parameter default values
420 * @user_parameters: This parameter specifies the controller default user
421 * parameters. It is expected that this has been initialized to the default
422 * parameters for the controller
423 *
424 *
425 */
426enum sci_status isci_parse_user_parameters(
427 union scic_user_parameters *user_params,
428 int scu_index,
429 struct isci_firmware *fw)
430{
431 int i;
432
433 if (!(scu_index >= 0
434 && scu_index < SCI_MAX_CONTROLLERS
435 && user_params != NULL)) {
436 return SCI_FAILURE;
437 }
438
439 for (i = 0; i < SCI_MAX_PORTS; i++) {
440 int array_idx = i + (SCI_MAX_PORTS * scu_index);
441 u32 gen = fw->phy_gens[array_idx];
442
443 user_params->sds1.phys[i].max_speed_generation = gen;
444
445 }
446
447 return SCI_SUCCESS;
448}
449
450static struct isci_host *isci_host_alloc(struct pci_dev *pdev, int id)
451{
452 struct isci_host *isci_host;
453 struct Scsi_Host *shost;
454 int err;
455
456 isci_host = devm_kzalloc(&pdev->dev, sizeof(*isci_host), GFP_KERNEL);
457 if (!isci_host)
458 return NULL;
459
460 isci_host->pdev = pdev;
461 isci_host->id = id;
462
463 shost = scsi_host_alloc(&isci_sht, sizeof(void *));
464 if (!shost)
465 return NULL;
466 isci_host->shost = shost;
467
468 err = isci_host_init(isci_host);
469 if (err)
470 goto err_shost;
471
472 SHOST_TO_SAS_HA(shost) = &isci_host->sas_ha;
473 isci_host->sas_ha.core.shost = shost;
474 shost->transportt = isci_transport_template;
475
476 shost->max_id = ~0;
477 shost->max_lun = ~0;
478 shost->max_cmd_len = MAX_COMMAND_SIZE;
479
480 err = scsi_add_host(shost, &pdev->dev);
481 if (err)
482 goto err_shost;
483
484 err = isci_register_sas_ha(isci_host);
485 if (err)
486 goto err_shost_remove;
487
488 return isci_host;
489
490 err_shost_remove:
491 scsi_remove_host(shost);
492 err_shost:
493 scsi_host_put(shost);
494
495 return NULL;
496}
497
498static void check_si_rev(struct pci_dev *pdev)
499{
500 if (num_controllers(pdev) > 1)
501 isci_si_rev = ISCI_SI_REVB0;
502 else {
503 switch (pdev->revision) {
504 case 0:
505 case 1:
506 /* if the id is ambiguous don't update isci_si_rev */
507 break;
508 case 3:
509 isci_si_rev = ISCI_SI_REVA2;
510 break;
511 default:
512 case 4:
513 isci_si_rev = ISCI_SI_REVB0;
514 break;
515 }
516 }
517
518 dev_info(&pdev->dev, "driver configured for %s silicon (rev: %d)\n",
519 isci_si_rev == ISCI_SI_REVA0 ? "A0" :
520 isci_si_rev == ISCI_SI_REVA2 ? "A2" : "B0", pdev->revision);
521
522}
523
858d4aa7
DJ
524static int isci_verify_firmware(const struct firmware *fw,
525 struct isci_firmware *isci_fw)
526{
527 const u8 *tmp;
528
529 if (fw->size < ISCI_FIRMWARE_MIN_SIZE)
530 return -EINVAL;
531
532 tmp = fw->data;
533
534 /* 12th char should be the NULL terminate for the ID string */
535 if (tmp[11] != '\0')
536 return -EINVAL;
537
538 if (strncmp("#SCU MAGIC#", tmp, 11) != 0)
539 return -EINVAL;
540
541 isci_fw->id = tmp;
542 isci_fw->version = fw->data[ISCI_FW_VER_OFS];
543 isci_fw->subversion = fw->data[ISCI_FW_SUBVER_OFS];
544
545 tmp = fw->data + ISCI_FW_DATA_OFS;
546
547 while (*tmp != ISCI_FW_HDR_EOF) {
548 switch (*tmp) {
549 case ISCI_FW_HDR_PHYMASK:
550 tmp++;
551 isci_fw->phy_masks_size = *tmp;
552 tmp++;
553 isci_fw->phy_masks = (const u32 *)tmp;
554 tmp += sizeof(u32) * isci_fw->phy_masks_size;
555 break;
556
557 case ISCI_FW_HDR_PHYGEN:
558 tmp++;
559 isci_fw->phy_gens_size = *tmp;
560 tmp++;
561 isci_fw->phy_gens = (const u32 *)tmp;
562 tmp += sizeof(u32) * isci_fw->phy_gens_size;
563 break;
564
565 case ISCI_FW_HDR_SASADDR:
566 tmp++;
567 isci_fw->sas_addrs_size = *tmp;
568 tmp++;
569 isci_fw->sas_addrs = (const u64 *)tmp;
570 tmp += sizeof(u64) * isci_fw->sas_addrs_size;
571 break;
572
573 default:
574 pr_err("bad field in firmware binary blob\n");
575 return -EINVAL;
576 }
577 }
578
579 pr_info("isci firmware v%u.%u loaded.\n",
580 isci_fw->version, isci_fw->subversion);
581
582 return SCI_SUCCESS;
583}
584
6f231dda
DW
585static int __devinit isci_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
586{
587 struct isci_pci_info *pci_info;
588 int err, i;
589 struct isci_host *isci_host;
858d4aa7 590 const struct firmware *fw = NULL;
6f231dda
DW
591
592 check_si_rev(pdev);
593
594 pci_info = devm_kzalloc(&pdev->dev, sizeof(*pci_info), GFP_KERNEL);
595 if (!pci_info)
596 return -ENOMEM;
597 pci_set_drvdata(pdev, pci_info);
598
858d4aa7
DJ
599 err = request_firmware(&fw, ISCI_FW_NAME, &pdev->dev);
600 if (err) {
601 dev_warn(&pdev->dev,
602 "Loading firmware failed, using default values\n");
603 dev_warn(&pdev->dev,
604 "Default OEM configuration being used:"
605 " 4 narrow ports, and default SAS Addresses\n");
606 } else {
607 isci_firmware = devm_kzalloc(&pdev->dev,
608 sizeof(struct isci_firmware),
609 GFP_KERNEL);
610 if (isci_firmware) {
611 err = isci_verify_firmware(fw, isci_firmware);
612 if (err != SCI_SUCCESS) {
613 dev_warn(&pdev->dev,
614 "firmware verification failed\n");
615 dev_warn(&pdev->dev,
616 "Default OEM configuration being used:"
617 " 4 narrow ports, and default SAS "
618 "Addresses\n");
619 devm_kfree(&pdev->dev, isci_firmware);
620 isci_firmware = NULL;
621 }
622 }
623 release_firmware(fw);
624 }
625
6f231dda
DW
626 err = isci_pci_init(pdev);
627 if (err)
628 return err;
629
630 for (i = 0; i < num_controllers(pdev); i++) {
631 struct isci_host *h = isci_host_alloc(pdev, i);
632
633 if (!h) {
634 err = -ENOMEM;
635 goto err_host_alloc;
636 }
637
638 h->next = pci_info->hosts;
639 pci_info->hosts = h;
640 }
641
642 err = isci_setup_interrupts(pdev);
643 if (err)
644 goto err_host_alloc;
645
646 for_each_isci_host(isci_host, pdev)
647 scsi_scan_host(isci_host->shost);
648
649 return 0;
650
651 err_host_alloc:
652 for_each_isci_host(isci_host, pdev)
653 isci_unregister_sas_ha(isci_host);
654 return err;
655}
656
657static void __devexit isci_pci_remove(struct pci_dev *pdev)
658{
659 struct isci_host *isci_host;
660
661 for_each_isci_host(isci_host, pdev) {
662 isci_unregister_sas_ha(isci_host);
663 isci_host_deinit(isci_host);
664 scic_controller_disable_interrupts(isci_host->core_controller);
665 }
666}
667
668static __init int isci_init(void)
669{
670 int err = -ENOMEM;
671
672 pr_info("%s: Intel(R) C600 SAS Controller Driver\n", DRV_NAME);
673
674 isci_kmem_cache = kmem_cache_create(DRV_NAME,
675 sizeof(struct isci_remote_device) +
676 scic_remote_device_get_object_size(),
677 0, 0, NULL);
678 if (!isci_kmem_cache)
679 return err;
680
681 isci_transport_template = sas_domain_attach_transport(&isci_transport_ops);
682 if (!isci_transport_template)
683 goto err_kmem;
684
685 err = pci_register_driver(&isci_pci_driver);
686 if (err)
687 goto err_sas;
688
689 return 0;
690
691 err_sas:
692 sas_release_transport(isci_transport_template);
693 err_kmem:
694 kmem_cache_destroy(isci_kmem_cache);
695
696 return err;
697}
698
699static __exit void isci_exit(void)
700{
701 pci_unregister_driver(&isci_pci_driver);
702 sas_release_transport(isci_transport_template);
703 kmem_cache_destroy(isci_kmem_cache);
704}
705
706MODULE_LICENSE("Dual BSD/GPL");
707MODULE_FIRMWARE(ISCI_FW_NAME);
708module_init(isci_init);
709module_exit(isci_exit);
This page took 0.084285 seconds and 5 git commands to generate.