diff options
Diffstat (limited to 'drivers/scsi/pm8001/pm8001_sas.c')
-rw-r--r-- | drivers/scsi/pm8001/pm8001_sas.c | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index 8a44bc92bc7..76570e6a547 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -58,25 +58,14 @@ static int pm8001_find_tag(struct sas_task *task, u32 *tag) } /** - * pm8001_tag_clear - clear the tags bitmap + * pm8001_tag_free - free the no more needed tag * @pm8001_ha: our hba struct * @tag: the found tag associated with the task */ -static void pm8001_tag_clear(struct pm8001_hba_info *pm8001_ha, u32 tag) -{ - void *bitmap = pm8001_ha->tags; - clear_bit(tag, bitmap); -} - void pm8001_tag_free(struct pm8001_hba_info *pm8001_ha, u32 tag) { - pm8001_tag_clear(pm8001_ha, tag); -} - -static void pm8001_tag_set(struct pm8001_hba_info *pm8001_ha, u32 tag) -{ void *bitmap = pm8001_ha->tags; - set_bit(tag, bitmap); + clear_bit(tag, bitmap); } /** @@ -86,14 +75,18 @@ static void pm8001_tag_set(struct pm8001_hba_info *pm8001_ha, u32 tag) */ inline int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out) { - unsigned int index, tag; + unsigned int tag; void *bitmap = pm8001_ha->tags; + unsigned long flags; - index = find_first_zero_bit(bitmap, pm8001_ha->tags_num); - tag = index; - if (tag >= pm8001_ha->tags_num) + spin_lock_irqsave(&pm8001_ha->bitmap_lock, flags); + tag = find_first_zero_bit(bitmap, pm8001_ha->tags_num); + if (tag >= pm8001_ha->tags_num) { + spin_unlock_irqrestore(&pm8001_ha->bitmap_lock, flags); return -SAS_QUEUE_FULL; - pm8001_tag_set(pm8001_ha, tag); + } + set_bit(tag, bitmap); + spin_unlock_irqrestore(&pm8001_ha->bitmap_lock, flags); *tag_out = tag; return 0; } @@ -102,7 +95,7 @@ void pm8001_tag_init(struct pm8001_hba_info *pm8001_ha) { int i; for (i = 0; i < pm8001_ha->tags_num; ++i) - pm8001_tag_clear(pm8001_ha, i); + pm8001_tag_free(pm8001_ha, i); } /** @@ -123,13 +116,12 @@ int pm8001_mem_alloc(struct pci_dev *pdev, void **virt_addr, u64 align_offset = 0; if (align) align_offset = (dma_addr_t)align - 1; - mem_virt_alloc = - pci_alloc_consistent(pdev, mem_size + align, &mem_dma_handle); + mem_virt_alloc = pci_zalloc_consistent(pdev, mem_size + align, + &mem_dma_handle); if (!mem_virt_alloc) { pm8001_printk("memory allocation error\n"); return -1; } - memset((void *)mem_virt_alloc, 0, mem_size+align); *pphys_addr = mem_dma_handle; phys_align = (*pphys_addr + align_offset) & ~align_offset; *virt_addr = (void *)mem_virt_alloc + phys_align - *pphys_addr; @@ -501,11 +493,6 @@ int pm8001_queue_command(struct sas_task *task, const int num, return pm8001_task_exec(task, num, gfp_flags, 0, NULL); } -void pm8001_ccb_free(struct pm8001_hba_info *pm8001_ha, u32 ccb_idx) -{ - pm8001_tag_clear(pm8001_ha, ccb_idx); -} - /** * pm8001_ccb_task_free - free the sg for ssp and smp command, free the ccb. * @pm8001_ha: our hba card information @@ -542,7 +529,7 @@ void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha, ccb->task = NULL; ccb->ccb_tag = 0xFFFFFFFF; ccb->open_retry = 0; - pm8001_ccb_free(pm8001_ha, ccb_idx); + pm8001_tag_free(pm8001_ha, ccb_idx); } /** |