Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mpt3sas: Move Gen3 HBA's device registration to a separate file

Created a mpt3sas_module.c file for mpt3sas driver where it can register
SAS3 HBA devices with PCI, SML, IOCTL subsystems. Also removed the
corresponding interfaces from mpt3sas_scsih.c file.

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Sreekanth Reddy and committed by
Martin K. Petersen
7497392a 8a7e4c24

+261 -159
+2 -1
drivers/scsi/mpt3sas/Makefile
··· 5 5 mpt3sas_scsih.o \ 6 6 mpt3sas_transport.o \ 7 7 mpt3sas_ctl.o \ 8 - mpt3sas_trigger_diag.o 8 + mpt3sas_trigger_diag.o \ 9 + mpt3sas_module.o
+3 -1
drivers/scsi/mpt3sas/mpt3sas_base.h
··· 1084 1084 1085 1085 1086 1086 /* scsih shared API */ 1087 + extern struct raid_template *mpt3sas_raid_template; 1087 1088 u8 mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index, 1088 1089 u32 reply); 1089 1090 void mpt3sas_scsih_reset_handler(struct MPT3SAS_ADAPTER *ioc, int reset_phase); ··· 1109 1108 1110 1109 void scsih_exit(void); 1111 1110 int scsih_init(void); 1112 - int scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id); 1111 + int scsih_probe(struct pci_dev *pdev, struct Scsi_Host *shost); 1113 1112 void scsih_remove(struct pci_dev *pdev); 1114 1113 void scsih_shutdown(struct pci_dev *pdev); 1115 1114 pci_ers_result_t scsih_pci_error_detected(struct pci_dev *pdev, ··· 1242 1241 u8 *issue_reset); 1243 1242 1244 1243 /* transport shared API */ 1244 + extern struct scsi_transport_template *mpt3sas_transport_template; 1245 1245 u8 mpt3sas_transport_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, 1246 1246 u32 reply); 1247 1247 struct _sas_port *mpt3sas_transport_port_add(struct MPT3SAS_ADAPTER *ioc,
-21
drivers/scsi/mpt3sas/mpt3sas_ctl.c
··· 3218 3218 NULL, 3219 3219 }; 3220 3220 3221 - static const struct file_operations ctl_fops = { 3222 - .owner = THIS_MODULE, 3223 - .unlocked_ioctl = ctl_ioctl, 3224 - .poll = ctl_poll, 3225 - .fasync = ctl_fasync, 3226 - #ifdef CONFIG_COMPAT 3227 - .compat_ioctl = ctl_ioctl_compat, 3228 - #endif 3229 - }; 3230 - 3231 - static struct miscdevice ctl_dev = { 3232 - .minor = MPT3SAS_MINOR, 3233 - .name = MPT3SAS_DEV_NAME, 3234 - .fops = &ctl_fops, 3235 - }; 3236 - 3237 3221 /** 3238 3222 * ctl_init - main entry point for ctl. 3239 3223 * ··· 3226 3242 ctl_init(void) 3227 3243 { 3228 3244 async_queue = NULL; 3229 - if (misc_register(&ctl_dev) < 0) 3230 - pr_err("%s can't register misc device [minor=%d]\n", 3231 - MPT3SAS_DRIVER_NAME, MPT3SAS_MINOR); 3232 - 3233 3245 init_waitqueue_head(&ctl_poll_wait); 3234 3246 } 3235 3247 ··· 3259 3279 3260 3280 kfree(ioc->event_log); 3261 3281 } 3262 - misc_deregister(&ctl_dev); 3263 3282 }
+252
drivers/scsi/mpt3sas/mpt3sas_module.c
··· 1 + /* 2 + * Scsi Host Layer for MPT (Message Passing Technology) based controllers 3 + * 4 + * Copyright (C) 2012-2014 LSI Corporation 5 + * Copyright (C) 2013-2015 Avago Technologies 6 + * (mailto: MPT-FusionLinux.pdl@avagotech.com) 7 + * 8 + * This program is free software; you can redistribute it and/or 9 + * modify it under the terms of the GNU General Public License 10 + * as published by the Free Software Foundation; either version 2 11 + * of the License, or (at your option) any later version. 12 + * 13 + * This program is distributed in the hope that it will be useful, 14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 + * GNU General Public License for more details. 17 + * 18 + * NO WARRANTY 19 + * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR 20 + * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT 21 + * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 22 + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is 23 + * solely responsible for determining the appropriateness of using and 24 + * distributing the Program and assumes all risks associated with its 25 + * exercise of rights under this Agreement, including but not limited to 26 + * the risks and costs of program errors, damage to or loss of data, 27 + * programs or equipment, and unavailability or interruption of operations. 28 + 29 + * DISCLAIMER OF LIABILITY 30 + * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY 31 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 + * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND 33 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 34 + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 35 + * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED 36 + * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES 37 + 38 + * You should have received a copy of the GNU General Public License 39 + * along with this program. 40 + */ 41 + 42 + #include <linux/module.h> 43 + #include <linux/pci.h> 44 + #include <linux/raid_class.h> 45 + 46 + #include "mpt3sas_base.h" 47 + #include "mpt3sas_ctl.h" 48 + 49 + MODULE_AUTHOR(MPT3SAS_AUTHOR); 50 + MODULE_DESCRIPTION(MPT3SAS_DESCRIPTION); 51 + MODULE_LICENSE("GPL"); 52 + MODULE_VERSION(MPT3SAS_DRIVER_VERSION); 53 + 54 + /* shost template */ 55 + static struct scsi_host_template mpt3sas_driver_template = { 56 + .module = THIS_MODULE, 57 + .name = "Fusion MPT SAS Host", 58 + .proc_name = MPT3SAS_DRIVER_NAME, 59 + .queuecommand = scsih_qcmd, 60 + .target_alloc = scsih_target_alloc, 61 + .slave_alloc = scsih_slave_alloc, 62 + .slave_configure = scsih_slave_configure, 63 + .target_destroy = scsih_target_destroy, 64 + .slave_destroy = scsih_slave_destroy, 65 + .scan_finished = scsih_scan_finished, 66 + .scan_start = scsih_scan_start, 67 + .change_queue_depth = scsih_change_queue_depth, 68 + .eh_abort_handler = scsih_abort, 69 + .eh_device_reset_handler = scsih_dev_reset, 70 + .eh_target_reset_handler = scsih_target_reset, 71 + .eh_host_reset_handler = scsih_host_reset, 72 + .bios_param = scsih_bios_param, 73 + .can_queue = 1, 74 + .this_id = -1, 75 + .sg_tablesize = MPT3SAS_SG_DEPTH, 76 + .max_sectors = 32767, 77 + .cmd_per_lun = 7, 78 + .use_clustering = ENABLE_CLUSTERING, 79 + .shost_attrs = mpt3sas_host_attrs, 80 + .sdev_attrs = mpt3sas_dev_attrs, 81 + .track_queue_depth = 1, 82 + }; 83 + 84 + /* raid transport support */ 85 + static struct raid_function_template mpt3sas_raid_functions = { 86 + .cookie = &mpt3sas_driver_template, 87 + .is_raid = scsih_is_raid, 88 + .get_resync = scsih_get_resync, 89 + .get_state = scsih_get_state, 90 + }; 91 + 92 + /* 93 + * The pci device ids are defined in mpi/mpi2_cnfg.h. 94 + */ 95 + static const struct pci_device_id mpt3sas_pci_table[] = { 96 + { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3004, 97 + PCI_ANY_ID, PCI_ANY_ID }, 98 + { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3008, 99 + PCI_ANY_ID, PCI_ANY_ID }, 100 + /* Invader ~ 3108 */ 101 + { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3108_1, 102 + PCI_ANY_ID, PCI_ANY_ID }, 103 + { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3108_2, 104 + PCI_ANY_ID, PCI_ANY_ID }, 105 + { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3108_5, 106 + PCI_ANY_ID, PCI_ANY_ID }, 107 + { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3108_6, 108 + PCI_ANY_ID, PCI_ANY_ID }, 109 + {0} /* Terminating entry */ 110 + }; 111 + MODULE_DEVICE_TABLE(pci, mpt3sas_pci_table); 112 + 113 + static const struct file_operations mpt3sas_ctl_fops = { 114 + .owner = THIS_MODULE, 115 + .unlocked_ioctl = ctl_ioctl, 116 + .poll = ctl_poll, 117 + .fasync = ctl_fasync, 118 + #ifdef CONFIG_COMPAT 119 + .compat_ioctl = ctl_ioctl_compat, 120 + #endif 121 + }; 122 + 123 + static struct miscdevice mpt3sas_ctl_dev = { 124 + .minor = MPT3SAS_MINOR, 125 + .name = MPT3SAS_DEV_NAME, 126 + .fops = &mpt3sas_ctl_fops, 127 + }; 128 + 129 + /** 130 + * mpt3sas_ctl_init - main entry point for ctl. 131 + * 132 + */ 133 + void 134 + mpt3sas_ctl_init(void) 135 + { 136 + ctl_init(); 137 + if (misc_register(&mpt3sas_ctl_dev) < 0) 138 + pr_err("%s can't register misc device [minor=%d]\n", 139 + MPT3SAS_DRIVER_NAME, MPT3SAS_MINOR); 140 + } 141 + 142 + /** 143 + * mpt3sas_ctl_exit - exit point for ctl 144 + * 145 + */ 146 + void 147 + mpt3sas_ctl_exit(void) 148 + { 149 + ctl_exit(); 150 + misc_deregister(&mpt3sas_ctl_dev); 151 + } 152 + 153 + /** 154 + * _mpt3sas_probe - attach and add scsi host 155 + * @pdev: PCI device struct 156 + * @id: pci device id 157 + * 158 + * Returns 0 success, anything else error. 159 + */ 160 + static int 161 + _mpt3sas_probe(struct pci_dev *pdev, const struct pci_device_id *id) 162 + { 163 + struct Scsi_Host *shost; 164 + int rv; 165 + 166 + shost = scsi_host_alloc(&mpt3sas_driver_template, 167 + sizeof(struct MPT3SAS_ADAPTER)); 168 + if (!shost) 169 + return -ENODEV; 170 + 171 + rv = scsih_probe(pdev, shost); 172 + return rv; 173 + } 174 + 175 + static struct pci_error_handlers _mpt3sas_err_handler = { 176 + .error_detected = scsih_pci_error_detected, 177 + .mmio_enabled = scsih_pci_mmio_enabled, 178 + .slot_reset = scsih_pci_slot_reset, 179 + .resume = scsih_pci_resume, 180 + }; 181 + 182 + static struct pci_driver mpt3sas_driver = { 183 + .name = MPT3SAS_DRIVER_NAME, 184 + .id_table = mpt3sas_pci_table, 185 + .probe = _mpt3sas_probe, 186 + .remove = scsih_remove, 187 + .shutdown = scsih_shutdown, 188 + .err_handler = &_mpt3sas_err_handler, 189 + #ifdef CONFIG_PM 190 + .suspend = scsih_suspend, 191 + .resume = scsih_resume, 192 + #endif 193 + }; 194 + 195 + /** 196 + * _mpt3sas_init - main entry point for this driver. 197 + * 198 + * Returns 0 success, anything else error. 199 + */ 200 + static int __init 201 + _mpt3sas_init(void) 202 + { 203 + int error; 204 + 205 + pr_info("%s version %s loaded\n", MPT3SAS_DRIVER_NAME, 206 + MPT3SAS_DRIVER_VERSION); 207 + 208 + mpt3sas_transport_template = 209 + sas_attach_transport(&mpt3sas_transport_functions); 210 + if (!mpt3sas_transport_template) 211 + return -ENODEV; 212 + 213 + mpt3sas_raid_template = raid_class_attach(&mpt3sas_raid_functions); 214 + if (!mpt3sas_raid_template) { 215 + sas_release_transport(mpt3sas_transport_template); 216 + return -ENODEV; 217 + } 218 + 219 + error = scsih_init(); 220 + if (error) { 221 + scsih_exit(); 222 + return error; 223 + } 224 + 225 + mpt3sas_ctl_init(); 226 + 227 + error = pci_register_driver(&mpt3sas_driver); 228 + if (error) 229 + scsih_exit(); 230 + 231 + return error; 232 + } 233 + 234 + /** 235 + * _mpt3sas_exit - exit point for this driver (when it is a module). 236 + * 237 + */ 238 + static void __exit 239 + _mpt3sas_exit(void) 240 + { 241 + pr_info("mpt3sas version %s unloading\n", 242 + MPT3SAS_DRIVER_VERSION); 243 + 244 + pci_unregister_driver(&mpt3sas_driver); 245 + 246 + mpt3sas_ctl_exit(); 247 + 248 + scsih_exit(); 249 + } 250 + 251 + module_init(_mpt3sas_init); 252 + module_exit(_mpt3sas_exit);
+4 -136
drivers/scsi/mpt3sas/mpt3sas_scsih.c
··· 57 57 58 58 #include "mpt3sas_base.h" 59 59 60 - MODULE_AUTHOR(MPT3SAS_AUTHOR); 61 - MODULE_DESCRIPTION(MPT3SAS_DESCRIPTION); 62 - MODULE_LICENSE("GPL"); 63 - MODULE_VERSION(MPT3SAS_DRIVER_VERSION); 64 - 65 60 #define RAID_CHANNEL 1 66 61 /* forward proto's */ 67 62 static void _scsih_expander_node_remove(struct MPT3SAS_ADAPTER *ioc, ··· 136 141 137 142 138 143 /* raid transport support */ 139 - 140 - static struct raid_template *mpt3sas_raid_template; 144 + struct raid_template *mpt3sas_raid_template; 141 145 142 146 143 147 /** ··· 186 192 char event_data[0] __aligned(4); 187 193 }; 188 194 189 - /* raid transport support */ 190 - static struct raid_template *mpt3sas_raid_template; 191 - 192 195 /** 193 196 * struct _scsi_io_transfer - scsi io transfer 194 197 * @handle: sas device handle (assigned by firmware) ··· 233 242 u32 log_info; 234 243 u32 transfer_length; 235 244 }; 236 - 237 - /* 238 - * The pci device ids are defined in mpi/mpi2_cnfg.h. 239 - */ 240 - static const struct pci_device_id scsih_pci_table[] = { 241 - /* Fury ~ 3004 and 3008 */ 242 - { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3004, 243 - PCI_ANY_ID, PCI_ANY_ID }, 244 - { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3008, 245 - PCI_ANY_ID, PCI_ANY_ID }, 246 - /* Invader ~ 3108 */ 247 - { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3108_1, 248 - PCI_ANY_ID, PCI_ANY_ID }, 249 - { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3108_2, 250 - PCI_ANY_ID, PCI_ANY_ID }, 251 - { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3108_5, 252 - PCI_ANY_ID, PCI_ANY_ID }, 253 - { MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3108_6, 254 - PCI_ANY_ID, PCI_ANY_ID }, 255 - {0} /* Terminating entry */ 256 - }; 257 - MODULE_DEVICE_TABLE(pci, scsih_pci_table); 258 245 259 246 /** 260 247 * _scsih_set_debug_level - global setting of ioc->logging_level. ··· 7455 7486 return 1; 7456 7487 } 7457 7488 7458 - /* shost template */ 7459 - static struct scsi_host_template scsih_driver_template = { 7460 - .module = THIS_MODULE, 7461 - .name = "Fusion MPT SAS Host", 7462 - .proc_name = MPT3SAS_DRIVER_NAME, 7463 - .queuecommand = scsih_qcmd, 7464 - .target_alloc = scsih_target_alloc, 7465 - .slave_alloc = scsih_slave_alloc, 7466 - .slave_configure = scsih_slave_configure, 7467 - .target_destroy = scsih_target_destroy, 7468 - .slave_destroy = scsih_slave_destroy, 7469 - .scan_finished = scsih_scan_finished, 7470 - .scan_start = scsih_scan_start, 7471 - .change_queue_depth = scsih_change_queue_depth, 7472 - .eh_abort_handler = scsih_abort, 7473 - .eh_device_reset_handler = scsih_dev_reset, 7474 - .eh_target_reset_handler = scsih_target_reset, 7475 - .eh_host_reset_handler = scsih_host_reset, 7476 - .bios_param = scsih_bios_param, 7477 - .can_queue = 1, 7478 - .this_id = -1, 7479 - .sg_tablesize = MPT3SAS_SG_DEPTH, 7480 - .max_sectors = 32767, 7481 - .cmd_per_lun = 7, 7482 - .use_clustering = ENABLE_CLUSTERING, 7483 - .shost_attrs = mpt3sas_host_attrs, 7484 - .sdev_attrs = mpt3sas_dev_attrs, 7485 - .track_queue_depth = 1, 7486 - }; 7487 - 7488 7489 /** 7489 7490 * _scsih_expander_node_remove - removing expander device from list. 7490 7491 * @ioc: per adapter object ··· 7932 7993 * Returns 0 success, anything else error. 7933 7994 */ 7934 7995 int 7935 - scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id) 7996 + scsih_probe(struct pci_dev *pdev, struct Scsi_Host *shost) 7936 7997 { 7937 7998 struct MPT3SAS_ADAPTER *ioc; 7938 - struct Scsi_Host *shost; 7939 7999 int rv; 7940 - 7941 - shost = scsi_host_alloc(&scsih_driver_template, 7942 - sizeof(struct MPT3SAS_ADAPTER)); 7943 - if (!shost) 7944 - return -ENODEV; 7945 8000 7946 8001 /* init local params */ 7947 8002 ioc = shost_priv(shost); ··· 8231 8298 return PCI_ERS_RESULT_NEED_RESET; 8232 8299 } 8233 8300 8234 - /* raid transport support */ 8235 - static struct raid_function_template mpt3sas_raid_functions = { 8236 - .cookie = &scsih_driver_template, 8237 - .is_raid = scsih_is_raid, 8238 - .get_resync = scsih_get_resync, 8239 - .get_state = scsih_get_state, 8240 - }; 8241 - 8242 - static struct pci_error_handlers _scsih_err_handler = { 8243 - .error_detected = scsih_pci_error_detected, 8244 - .mmio_enabled = scsih_pci_mmio_enabled, 8245 - .slot_reset = scsih_pci_slot_reset, 8246 - .resume = scsih_pci_resume, 8247 - }; 8248 - 8249 - static struct pci_driver scsih_driver = { 8250 - .name = MPT3SAS_DRIVER_NAME, 8251 - .id_table = scsih_pci_table, 8252 - .probe = scsih_probe, 8253 - .remove = scsih_remove, 8254 - .shutdown = scsih_shutdown, 8255 - .err_handler = &_scsih_err_handler, 8256 - #ifdef CONFIG_PM 8257 - .suspend = scsih_suspend, 8258 - .resume = scsih_resume, 8259 - #endif 8260 - }; 8261 - 8262 - 8263 8301 /** 8264 8302 * scsih_init - main entry point for this driver. 8265 8303 * ··· 8239 8335 int 8240 8336 scsih_init(void) 8241 8337 { 8242 - int error; 8243 - 8244 8338 mpt_ids = 0; 8245 - 8246 - pr_info("%s version %s loaded\n", MPT3SAS_DRIVER_NAME, 8247 - MPT3SAS_DRIVER_VERSION); 8248 - 8249 - mpt3sas_transport_template = 8250 - sas_attach_transport(&mpt3sas_transport_functions); 8251 - if (!mpt3sas_transport_template) 8252 - return -ENODEV; 8253 - 8254 - /* raid transport support */ 8255 - mpt3sas_raid_template = raid_class_attach(&mpt3sas_raid_functions); 8256 - if (!mpt3sas_raid_template) { 8257 - sas_release_transport(mpt3sas_transport_template); 8258 - return -ENODEV; 8259 - } 8260 8339 8261 8340 mpt3sas_base_initialize_callback_handler(); 8262 8341 ··· 8277 8390 tm_sas_control_cb_idx = mpt3sas_base_register_callback_handler( 8278 8391 _scsih_sas_control_complete); 8279 8392 8280 - ctl_init(); 8281 - 8282 - error = pci_register_driver(&scsih_driver); 8283 - if (error) { 8284 - /* raid transport support */ 8285 - raid_class_release(mpt3sas_raid_template); 8286 - sas_release_transport(mpt3sas_transport_template); 8287 - } 8288 - 8289 - return error; 8393 + return 0; 8290 8394 } 8291 8395 8292 8396 /** 8293 - * _scsih_exit - exit point for this driver (when it is a module). 8397 + * scsih_exit - exit point for this driver (when it is a module). 8294 8398 * 8295 8399 * Returns 0 success, anything else error. 8296 8400 */ 8297 8401 void 8298 8402 scsih_exit(void) 8299 8403 { 8300 - pr_info("mpt3sas version %s unloading\n", 8301 - MPT3SAS_DRIVER_VERSION); 8302 - 8303 - ctl_exit(); 8304 - 8305 - pci_unregister_driver(&scsih_driver); 8306 - 8307 8404 8308 8405 mpt3sas_base_release_callback_handler(scsi_io_cb_idx); 8309 8406 mpt3sas_base_release_callback_handler(tm_cb_idx); ··· 8306 8435 raid_class_release(mpt3sas_raid_template); 8307 8436 sas_release_transport(mpt3sas_transport_template); 8308 8437 } 8309 - 8310 - module_init(scsih_init); 8311 - module_exit(scsih_exit);