Commit 97ee2088 authored by jack_wang's avatar jack_wang Committed by James Bottomley

[SCSI] pm8001: Fixes for tag alloc, error goto and code cleanup

Allocate right size for bitmap tag,fix error goto and cleanup print
message and undocable commemts. patch attached.
Signed-off-by: default avatarLindar Liu <lindar_liu@usish.com>
Signed-off-by: default avatarJack Wang <jack_wang@usish.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 72d0baa0
...@@ -203,9 +203,9 @@ static int __devinit pm8001_alloc(struct pm8001_hba_info *pm8001_ha) ...@@ -203,9 +203,9 @@ static int __devinit pm8001_alloc(struct pm8001_hba_info *pm8001_ha)
for (i = 0; i < pm8001_ha->chip->n_phy; i++) for (i = 0; i < pm8001_ha->chip->n_phy; i++)
pm8001_phy_init(pm8001_ha, i); pm8001_phy_init(pm8001_ha, i);
pm8001_ha->tags = kmalloc(sizeof(*pm8001_ha->tags)*PM8001_MAX_DEVICES, pm8001_ha->tags = kzalloc(PM8001_MAX_CCB, GFP_KERNEL);
GFP_KERNEL); if (!pm8001_ha->tags)
goto err_out;
/* MPI Memory region 1 for AAP Event Log for fw */ /* MPI Memory region 1 for AAP Event Log for fw */
pm8001_ha->memoryMap.region[AAP1].num_elements = 1; pm8001_ha->memoryMap.region[AAP1].num_elements = 1;
pm8001_ha->memoryMap.region[AAP1].element_size = PM8001_EVENT_LOG_SIZE; pm8001_ha->memoryMap.region[AAP1].element_size = PM8001_EVENT_LOG_SIZE;
...@@ -287,6 +287,9 @@ static int __devinit pm8001_alloc(struct pm8001_hba_info *pm8001_ha) ...@@ -287,6 +287,9 @@ static int __devinit pm8001_alloc(struct pm8001_hba_info *pm8001_ha)
pm8001_ha->ccb_info[i].ccb_dma_handle = pm8001_ha->ccb_info[i].ccb_dma_handle =
pm8001_ha->memoryMap.region[CCB_MEM].phys_addr + pm8001_ha->memoryMap.region[CCB_MEM].phys_addr +
i * sizeof(struct pm8001_ccb_info); i * sizeof(struct pm8001_ccb_info);
pm8001_ha->ccb_info[i].task = NULL;
pm8001_ha->ccb_info[i].ccb_tag = 0xffffffff;
pm8001_ha->ccb_info[i].device = NULL;
++pm8001_ha->tags_num; ++pm8001_ha->tags_num;
} }
pm8001_ha->flags = PM8001F_INIT_TIME; pm8001_ha->flags = PM8001F_INIT_TIME;
...@@ -578,7 +581,7 @@ static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha) ...@@ -578,7 +581,7 @@ static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha)
{ {
struct pci_dev *pdev; struct pci_dev *pdev;
irq_handler_t irq_handler = pm8001_interrupt; irq_handler_t irq_handler = pm8001_interrupt;
u32 rc; int rc;
pdev = pm8001_ha->pdev; pdev = pm8001_ha->pdev;
......
...@@ -330,15 +330,12 @@ int pm8001_slave_configure(struct scsi_device *sdev) ...@@ -330,15 +330,12 @@ int pm8001_slave_configure(struct scsi_device *sdev)
return 0; return 0;
} }
/** /**
* pm8001_task_exec -execute the task which come from upper level, send the * pm8001_task_exec - queue the task(ssp, smp && ata) to the hardware.
* command or data to DMA area and then increase CI,for queuecommand(ssp),
* it is from upper layer and for smp command,it is from libsas,
* for ata command it is from libata.
* @task: the task to be execute. * @task: the task to be execute.
* @num: if can_queue great than 1, the task can be queued up. for SMP task, * @num: if can_queue great than 1, the task can be queued up. for SMP task,
* we always execute one one time. * we always execute one one time.
* @gfp_flags: gfp_flags. * @gfp_flags: gfp_flags.
* @is tmf: if it is task management task. * @is_tmf: if it is task management task.
* @tmf: the task management IU * @tmf: the task management IU
*/ */
#define DEV_IS_GONE(pm8001_dev) \ #define DEV_IS_GONE(pm8001_dev) \
...@@ -379,7 +376,7 @@ static int pm8001_task_exec(struct sas_task *task, const int num, ...@@ -379,7 +376,7 @@ static int pm8001_task_exec(struct sas_task *task, const int num,
pm8001_printk("device %016llx not " pm8001_printk("device %016llx not "
"ready.\n", SAS_ADDR(dev->sas_addr))); "ready.\n", SAS_ADDR(dev->sas_addr)));
} }
rc = SAS_PHY_DOWN; rc = SAS_PHY_DOWN;
goto out_done; goto out_done;
} }
rc = pm8001_tag_alloc(pm8001_ha, &tag); rc = pm8001_tag_alloc(pm8001_ha, &tag);
...@@ -395,14 +392,14 @@ static int pm8001_task_exec(struct sas_task *task, const int num, ...@@ -395,14 +392,14 @@ static int pm8001_task_exec(struct sas_task *task, const int num,
t->data_dir); t->data_dir);
if (!n_elem) { if (!n_elem) {
rc = -ENOMEM; rc = -ENOMEM;
goto err_out; goto err_out_tag;
} }
} }
} else { } else {
n_elem = t->num_scatter; n_elem = t->num_scatter;
} }
t->lldd_task = NULL; t->lldd_task = ccb;
ccb->n_elem = n_elem; ccb->n_elem = n_elem;
ccb->ccb_tag = tag; ccb->ccb_tag = tag;
ccb->task = t; ccb->task = t;
...@@ -435,7 +432,6 @@ static int pm8001_task_exec(struct sas_task *task, const int num, ...@@ -435,7 +432,6 @@ static int pm8001_task_exec(struct sas_task *task, const int num,
pm8001_printk("rc is %x\n", rc)); pm8001_printk("rc is %x\n", rc));
goto err_out_tag; goto err_out_tag;
} }
t->lldd_task = ccb;
/* TODO: select normal or high priority */ /* TODO: select normal or high priority */
spin_lock(&t->task_state_lock); spin_lock(&t->task_state_lock);
t->task_state_flags |= SAS_TASK_AT_INITIATOR; t->task_state_flags |= SAS_TASK_AT_INITIATOR;
...@@ -518,8 +514,7 @@ void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha, ...@@ -518,8 +514,7 @@ void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha,
} }
/** /**
* pm8001_alloc_dev - find the empty pm8001_device structure, allocate and * pm8001_alloc_dev - find a empty pm8001_device
* return it for use.
* @pm8001_ha: our hba card information * @pm8001_ha: our hba card information
*/ */
struct pm8001_device *pm8001_alloc_dev(struct pm8001_hba_info *pm8001_ha) struct pm8001_device *pm8001_alloc_dev(struct pm8001_hba_info *pm8001_ha)
...@@ -550,14 +545,16 @@ static void pm8001_free_dev(struct pm8001_device *pm8001_dev) ...@@ -550,14 +545,16 @@ static void pm8001_free_dev(struct pm8001_device *pm8001_dev)
} }
/** /**
* pm8001_dev_found_notify - when libsas find a sas domain device, it should * pm8001_dev_found_notify - libsas notify a device is found.
* tell the LLDD that device is found, and then LLDD register this device to * @dev: the device structure which sas layer used.
* HBA FW by the command "OPC_INB_REG_DEV", after that the HBA will assign *
* a device ID(according to device's sas address) and returned it to LLDD.from * when libsas find a sas domain device, it should tell the LLDD that
* device is found, and then LLDD register this device to HBA firmware
* by the command "OPC_INB_REG_DEV", after that the HBA will assign a
* device ID(according to device's sas address) and returned it to LLDD. From
* now on, we communicate with HBA FW with the device ID which HBA assigned * now on, we communicate with HBA FW with the device ID which HBA assigned
* rather than sas address. it is the neccessary step for our HBA but it is * rather than sas address. it is the neccessary step for our HBA but it is
* the optional for other HBA driver. * the optional for other HBA driver.
* @dev: the device structure which sas layer used.
*/ */
static int pm8001_dev_found_notify(struct domain_device *dev) static int pm8001_dev_found_notify(struct domain_device *dev)
{ {
...@@ -665,14 +662,15 @@ static void pm8001_tmf_timedout(unsigned long data) ...@@ -665,14 +662,15 @@ static void pm8001_tmf_timedout(unsigned long data)
#define PM8001_TASK_TIMEOUT 20 #define PM8001_TASK_TIMEOUT 20
/** /**
* pm8001_exec_internal_tmf_task - when errors or exception happened, we may * pm8001_exec_internal_tmf_task - execute some task management commands.
* want to do something, for example abort issued task which result in this
* execption, this is by calling this function, note it is also with the task
* execute interface.
* @dev: the wanted device. * @dev: the wanted device.
* @tmf: which task management wanted to be take. * @tmf: which task management wanted to be take.
* @para_len: para_len. * @para_len: para_len.
* @parameter: ssp task parameter. * @parameter: ssp task parameter.
*
* when errors or exception happened, we may want to do something, for example
* abort the issued task which result in this execption, it is done by calling
* this function, note it is also with the task execute interface.
*/ */
static int pm8001_exec_internal_tmf_task(struct domain_device *dev, static int pm8001_exec_internal_tmf_task(struct domain_device *dev,
void *parameter, u32 para_len, struct pm8001_tmf_task *tmf) void *parameter, u32 para_len, struct pm8001_tmf_task *tmf)
...@@ -737,9 +735,9 @@ static int pm8001_exec_internal_tmf_task(struct domain_device *dev, ...@@ -737,9 +735,9 @@ static int pm8001_exec_internal_tmf_task(struct domain_device *dev,
res = -EMSGSIZE; res = -EMSGSIZE;
break; break;
} else { } else {
PM8001_IO_DBG(pm8001_ha, PM8001_EH_DBG(pm8001_ha,
pm8001_printk(" Task to dev %016llx response: 0x%x" pm8001_printk(" Task to dev %016llx response:"
"status 0x%x\n", "0x%x status 0x%x\n",
SAS_ADDR(dev->sas_addr), SAS_ADDR(dev->sas_addr),
task->task_status.resp, task->task_status.resp,
task->task_status.stat)); task->task_status.stat));
...@@ -760,7 +758,7 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha, ...@@ -760,7 +758,7 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha,
u32 task_tag) u32 task_tag)
{ {
int res, retry; int res, retry;
u32 rc, ccb_tag; u32 ccb_tag;
struct pm8001_ccb_info *ccb; struct pm8001_ccb_info *ccb;
struct sas_task *task = NULL; struct sas_task *task = NULL;
...@@ -777,9 +775,9 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha, ...@@ -777,9 +775,9 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha,
task->timer.expires = jiffies + PM8001_TASK_TIMEOUT*HZ; task->timer.expires = jiffies + PM8001_TASK_TIMEOUT*HZ;
add_timer(&task->timer); add_timer(&task->timer);
rc = pm8001_tag_alloc(pm8001_ha, &ccb_tag); res = pm8001_tag_alloc(pm8001_ha, &ccb_tag);
if (rc) if (res)
return rc; return res;
ccb = &pm8001_ha->ccb_info[ccb_tag]; ccb = &pm8001_ha->ccb_info[ccb_tag];
ccb->device = pm8001_dev; ccb->device = pm8001_dev;
ccb->ccb_tag = ccb_tag; ccb->ccb_tag = ccb_tag;
...@@ -812,7 +810,7 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha, ...@@ -812,7 +810,7 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha,
break; break;
} else { } else {
PM8001_IO_DBG(pm8001_ha, PM8001_EH_DBG(pm8001_ha,
pm8001_printk(" Task to dev %016llx response: " pm8001_printk(" Task to dev %016llx response: "
"0x%x status 0x%x\n", "0x%x status 0x%x\n",
SAS_ADDR(dev->sas_addr), SAS_ADDR(dev->sas_addr),
...@@ -1027,11 +1025,11 @@ int pm8001_abort_task(struct sas_task *task) ...@@ -1027,11 +1025,11 @@ int pm8001_abort_task(struct sas_task *task)
} }
device_id = pm8001_dev->device_id; device_id = pm8001_dev->device_id;
PM8001_EH_DBG(pm8001_ha, PM8001_EH_DBG(pm8001_ha,
pm8001_printk("abort io to device_id = %d\n", device_id)); pm8001_printk("abort io to deviceid= %d\n", device_id));
tmf_task.tmf = TMF_ABORT_TASK; tmf_task.tmf = TMF_ABORT_TASK;
tmf_task.tag_of_task_to_be_managed = tag; tmf_task.tag_of_task_to_be_managed = tag;
rc = pm8001_issue_ssp_tmf(dev, lun.scsi_lun, &tmf_task); rc = pm8001_issue_ssp_tmf(dev, lun.scsi_lun, &tmf_task);
rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev, pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev,
pm8001_dev->sas_device, 0, tag); pm8001_dev->sas_device, 0, tag);
} else if (task->task_proto & SAS_PROTOCOL_SATA || } else if (task->task_proto & SAS_PROTOCOL_SATA ||
task->task_proto & SAS_PROTOCOL_STP) { task->task_proto & SAS_PROTOCOL_STP) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment