diff options
Diffstat (limited to 'drivers/scsi/mpt3sas/mpt3sas_scsih.c')
| -rw-r--r-- | drivers/scsi/mpt3sas/mpt3sas_scsih.c | 94 | 
1 files changed, 50 insertions, 44 deletions
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 18e713db1d32..135f12c20ecf 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -112,8 +112,8 @@ MODULE_PARM_DESC(missing_delay, " device missing delay , io missing delay");  /* scsi-mid layer global parmeter is max_report_luns, which is 511 */  #define MPT3SAS_MAX_LUN (16895) -static int max_lun = MPT3SAS_MAX_LUN; -module_param(max_lun, int, 0); +static u64 max_lun = MPT3SAS_MAX_LUN; +module_param(max_lun, ullong, 0);  MODULE_PARM_DESC(max_lun, " max lun, default=16895 "); @@ -190,7 +190,7 @@ struct fw_event_work {  	u8			VP_ID;  	u8			ignore;  	u16			event; -	void			*event_data; +	char			event_data[0] __aligned(4);  };  /* raid transport support */ @@ -247,7 +247,7 @@ struct _scsi_io_transfer {  /*   * The pci device ids are defined in mpi/mpi2_cnfg.h.   */ -static DEFINE_PCI_DEVICE_TABLE(scsih_pci_table) = { +static const struct pci_device_id scsih_pci_table[] = {  	/* Fury ~ 3004 and 3008 */  	{ MPI2_MFGPAGE_VENDORID_LSI, MPI25_MFGPAGE_DEVID_SAS3004,  		PCI_ANY_ID, PCI_ANY_ID }, @@ -1163,7 +1163,8 @@ _scsih_target_alloc(struct scsi_target *starget)  	unsigned long flags;  	struct sas_rphy *rphy; -	sas_target_priv_data = kzalloc(sizeof(struct scsi_target), GFP_KERNEL); +	sas_target_priv_data = kzalloc(sizeof(*sas_target_priv_data), +				       GFP_KERNEL);  	if (!sas_target_priv_data)  		return -ENOMEM; @@ -1277,7 +1278,8 @@ _scsih_slave_alloc(struct scsi_device *sdev)  	struct _sas_device *sas_device;  	unsigned long flags; -	sas_device_priv_data = kzalloc(sizeof(struct scsi_device), GFP_KERNEL); +	sas_device_priv_data = kzalloc(sizeof(*sas_device_priv_data), +				       GFP_KERNEL);  	if (!sas_device_priv_data)  		return -ENOMEM; @@ -2490,7 +2492,6 @@ _scsih_fw_event_free(struct MPT3SAS_ADAPTER *ioc, struct fw_event_work  	spin_lock_irqsave(&ioc->fw_event_lock, flags);  	list_del(&fw_event->list); -	kfree(fw_event->event_data);  	kfree(fw_event);  	spin_unlock_irqrestore(&ioc->fw_event_lock, flags);  } @@ -2511,12 +2512,10 @@ mpt3sas_send_trigger_data_event(struct MPT3SAS_ADAPTER *ioc,  	if (ioc->is_driver_loading)  		return; -	fw_event = kzalloc(sizeof(struct fw_event_work), GFP_ATOMIC); +	fw_event = kzalloc(sizeof(*fw_event) + sizeof(*event_data), +			   GFP_ATOMIC);  	if (!fw_event)  		return; -	fw_event->event_data = kzalloc(sizeof(*event_data), GFP_ATOMIC); -	if (!fw_event->event_data) -		return;  	fw_event->event = MPT3SAS_PROCESS_TRIGGER_DIAG;  	fw_event->ioc = ioc;  	memcpy(fw_event->event_data, event_data, sizeof(*event_data)); @@ -2582,11 +2581,10 @@ _scsih_fw_event_cleanup_queue(struct MPT3SAS_ADAPTER *ioc)  		return;  	list_for_each_entry_safe(fw_event, next, &ioc->fw_event_list, list) { -		if (cancel_delayed_work(&fw_event->delayed_work)) { +		if (cancel_delayed_work_sync(&fw_event->delayed_work)) {  			_scsih_fw_event_free(ioc, fw_event);  			continue;  		} -		fw_event->cancel_pending_work = 1;  	}  } @@ -3211,7 +3209,8 @@ _scsih_check_topo_delete_events(struct MPT3SAS_ADAPTER *ioc,  		if (fw_event->event != MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST ||  		    fw_event->ignore)  			continue; -		local_event_data = fw_event->event_data; +		local_event_data = (Mpi2EventDataSasTopologyChangeList_t *) +				   fw_event->event_data;  		if (local_event_data->ExpStatus ==  		    MPI2_EVENT_SAS_TOPO_ES_ADDED ||  		    local_event_data->ExpStatus == @@ -5043,7 +5042,9 @@ _scsih_sas_topology_change_event(struct MPT3SAS_ADAPTER *ioc,  	u64 sas_address;  	unsigned long flags;  	u8 link_rate, prev_link_rate; -	Mpi2EventDataSasTopologyChangeList_t *event_data = fw_event->event_data; +	Mpi2EventDataSasTopologyChangeList_t *event_data = +		(Mpi2EventDataSasTopologyChangeList_t *) +		fw_event->event_data;  #ifdef CONFIG_SCSI_MPT3SAS_LOGGING  	if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) @@ -5241,7 +5242,8 @@ _scsih_sas_device_status_change_event(struct MPT3SAS_ADAPTER *ioc,  	u64 sas_address;  	unsigned long flags;  	Mpi2EventDataSasDeviceStatusChange_t *event_data = -	    fw_event->event_data; +		(Mpi2EventDataSasDeviceStatusChange_t *) +		fw_event->event_data;  #ifdef CONFIG_SCSI_MPT3SAS_LOGGING  	if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) @@ -5337,6 +5339,7 @@ _scsih_sas_enclosure_dev_status_change_event(struct MPT3SAS_ADAPTER *ioc,  #ifdef CONFIG_SCSI_MPT3SAS_LOGGING  	if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)  		_scsih_sas_enclosure_dev_status_change_event_debug(ioc, +		     (Mpi2EventDataSasEnclDevStatusChange_t *)  		     fw_event->event_data);  #endif  } @@ -5361,7 +5364,9 @@ _scsih_sas_broadcast_primitive_event(struct MPT3SAS_ADAPTER *ioc,  	u32 termination_count;  	u32 query_count;  	Mpi2SCSITaskManagementReply_t *mpi_reply; -	Mpi2EventDataSasBroadcastPrimitive_t *event_data = fw_event->event_data; +	Mpi2EventDataSasBroadcastPrimitive_t *event_data = +		(Mpi2EventDataSasBroadcastPrimitive_t *) +		fw_event->event_data;  	u16 ioc_status;  	unsigned long flags;  	int r; @@ -5513,7 +5518,8 @@ static void  _scsih_sas_discovery_event(struct MPT3SAS_ADAPTER *ioc,  	struct fw_event_work *fw_event)  { -	Mpi2EventDataSasDiscovery_t *event_data = fw_event->event_data; +	Mpi2EventDataSasDiscovery_t *event_data = +		(Mpi2EventDataSasDiscovery_t *) fw_event->event_data;  #ifdef CONFIG_SCSI_MPT3SAS_LOGGING  	if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) { @@ -5999,7 +6005,9 @@ _scsih_sas_ir_config_change_event(struct MPT3SAS_ADAPTER *ioc,  	Mpi2EventIrConfigElement_t *element;  	int i;  	u8 foreign_config; -	Mpi2EventDataIrConfigChangeList_t *event_data = fw_event->event_data; +	Mpi2EventDataIrConfigChangeList_t *event_data = +		(Mpi2EventDataIrConfigChangeList_t *) +		fw_event->event_data;  #ifdef CONFIG_SCSI_MPT3SAS_LOGGING  	if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) @@ -6069,7 +6077,8 @@ _scsih_sas_ir_volume_event(struct MPT3SAS_ADAPTER *ioc,  	u16 handle;  	u32 state;  	int rc; -	Mpi2EventDataIrVolume_t *event_data = fw_event->event_data; +	Mpi2EventDataIrVolume_t *event_data = +		(Mpi2EventDataIrVolume_t *) fw_event->event_data;  	if (ioc->shost_recovery)  		return; @@ -6152,7 +6161,8 @@ _scsih_sas_ir_physical_disk_event(struct MPT3SAS_ADAPTER *ioc,  	Mpi2ConfigReply_t mpi_reply;  	Mpi2SasDevicePage0_t sas_device_pg0;  	u32 ioc_status; -	Mpi2EventDataIrPhysicalDisk_t *event_data = fw_event->event_data; +	Mpi2EventDataIrPhysicalDisk_t *event_data = +		(Mpi2EventDataIrPhysicalDisk_t *) fw_event->event_data;  	u64 sas_address;  	if (ioc->shost_recovery) @@ -6272,7 +6282,9 @@ static void  _scsih_sas_ir_operation_status_event(struct MPT3SAS_ADAPTER *ioc,  	struct fw_event_work *fw_event)  { -	Mpi2EventDataIrOperationStatus_t *event_data = fw_event->event_data; +	Mpi2EventDataIrOperationStatus_t *event_data = +		(Mpi2EventDataIrOperationStatus_t *) +		fw_event->event_data;  	static struct _raid_device *raid_device;  	unsigned long flags;  	u16 handle; @@ -7026,7 +7038,7 @@ static void  _mpt3sas_fw_work(struct MPT3SAS_ADAPTER *ioc, struct fw_event_work *fw_event)  {  	/* the queue is being flushed so ignore this event */ -	if (ioc->remove_host || fw_event->cancel_pending_work || +	if (ioc->remove_host ||  	    ioc->pci_error_recovery) {  		_scsih_fw_event_free(ioc, fw_event);  		return; @@ -7034,7 +7046,9 @@ _mpt3sas_fw_work(struct MPT3SAS_ADAPTER *ioc, struct fw_event_work *fw_event)  	switch (fw_event->event) {  	case MPT3SAS_PROCESS_TRIGGER_DIAG: -		mpt3sas_process_trigger_data(ioc, fw_event->event_data); +		mpt3sas_process_trigger_data(ioc, +			(struct SL_WH_TRIGGERS_EVENT_DATA_T *) +			fw_event->event_data);  		break;  	case MPT3SAS_REMOVE_UNRESPONDING_DEVICES:  		while (scsi_host_in_recovery(ioc->shost) || ioc->shost_recovery) @@ -7192,18 +7206,11 @@ mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index,  		return 1;  	} -	fw_event = kzalloc(sizeof(struct fw_event_work), GFP_ATOMIC); -	if (!fw_event) { -		pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n", -		    ioc->name, __FILE__, __LINE__, __func__); -		return 1; -	}  	sz = le16_to_cpu(mpi_reply->EventDataLength) * 4; -	fw_event->event_data = kzalloc(sz, GFP_ATOMIC); -	if (!fw_event->event_data) { +	fw_event = kzalloc(sizeof(*fw_event) + sz, GFP_ATOMIC); +	if (!fw_event) {  		pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",  		    ioc->name, __FILE__, __LINE__, __func__); -		kfree(fw_event);  		return 1;  	} @@ -7431,9 +7438,9 @@ static void _scsih_remove(struct pci_dev *pdev)  	}  	sas_remove_host(shost); +	scsi_remove_host(shost);  	mpt3sas_base_detach(ioc);  	list_del(&ioc->list); -	scsi_remove_host(shost);  	scsi_host_put(shost);  } @@ -7801,13 +7808,6 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)  		}  	} -	if ((scsi_add_host(shost, &pdev->dev))) { -		pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n", -		    ioc->name, __FILE__, __LINE__, __func__); -		list_del(&ioc->list); -		goto out_add_shost_fail; -	} -  	/* register EEDP capabilities with SCSI layer */  	if (prot_mask > 0)  		scsi_host_set_prot(shost, prot_mask); @@ -7835,15 +7835,21 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)  		    ioc->name, __FILE__, __LINE__, __func__);  		goto out_attach_fail;  	} +	if ((scsi_add_host(shost, &pdev->dev))) { +		pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n", +		    ioc->name, __FILE__, __LINE__, __func__); +		list_del(&ioc->list); +		goto out_add_shost_fail; +	} +  	scsi_scan_host(shost);  	return 0; - +out_add_shost_fail: +	mpt3sas_base_detach(ioc);   out_attach_fail:  	destroy_workqueue(ioc->firmware_event_thread);   out_thread_fail:  	list_del(&ioc->list); -	scsi_remove_host(shost); - out_add_shost_fail:  	scsi_host_put(shost);  	return -ENODEV;  }  |