Commit f696cc32 authored by John Garry's avatar John Garry Committed by Martin K. Petersen

scsi: hisi_sas: use atomic64_t for hisi_sas_device.running_req

Sometimes the value of hisi_sas_device.running_req
would go negative unless we have the check for
running_req >= 0 before trying to decrement.

This is because using running_req is not thread-safe.

As such, the value for running_req may be actually incorrect,
so use atomic64_t instead.
Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
Reviewed-by: default avatarXiang Chen <chenxiang66@hisilicon.com>
Reviewed-by: default avatarZhangfei Gao <zhangfei.gao@linaro.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 04708ff4
...@@ -111,7 +111,7 @@ struct hisi_sas_device { ...@@ -111,7 +111,7 @@ struct hisi_sas_device {
struct domain_device *sas_device; struct domain_device *sas_device;
u64 attached_phy; u64 attached_phy;
u64 device_id; u64 device_id;
u64 running_req; atomic64_t running_req;
u8 dev_status; u8 dev_status;
}; };
......
...@@ -162,8 +162,8 @@ static void hisi_sas_slot_abort(struct work_struct *work) ...@@ -162,8 +162,8 @@ static void hisi_sas_slot_abort(struct work_struct *work)
hisi_sas_slot_task_free(hisi_hba, task, abort_slot); hisi_sas_slot_task_free(hisi_hba, task, abort_slot);
if (task->task_done) if (task->task_done)
task->task_done(task); task->task_done(task);
if (sas_dev && sas_dev->running_req) if (sas_dev)
sas_dev->running_req--; atomic64_dec(&sas_dev->running_req);
} }
static int hisi_sas_task_prep(struct sas_task *task, struct hisi_hba *hisi_hba, static int hisi_sas_task_prep(struct sas_task *task, struct hisi_hba *hisi_hba,
...@@ -303,7 +303,7 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_hba *hisi_hba, ...@@ -303,7 +303,7 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_hba *hisi_hba,
hisi_hba->slot_prep = slot; hisi_hba->slot_prep = slot;
sas_dev->running_req++; atomic64_inc(&sas_dev->running_req);
++(*pass); ++(*pass);
return 0; return 0;
...@@ -1027,7 +1027,8 @@ hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, u64 device_id, ...@@ -1027,7 +1027,8 @@ hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, u64 device_id,
hisi_hba->slot_prep = slot; hisi_hba->slot_prep = slot;
sas_dev->running_req++; atomic64_inc(&sas_dev->running_req);
/* send abort command to our chip */ /* send abort command to our chip */
hisi_hba->hw->start_delivery(hisi_hba); hisi_hba->hw->start_delivery(hisi_hba);
......
...@@ -1366,8 +1366,8 @@ static int slot_complete_v1_hw(struct hisi_hba *hisi_hba, ...@@ -1366,8 +1366,8 @@ static int slot_complete_v1_hw(struct hisi_hba *hisi_hba,
} }
out: out:
if (sas_dev && sas_dev->running_req) if (sas_dev)
sas_dev->running_req--; atomic64_dec(&sas_dev->running_req);
hisi_sas_slot_task_free(hisi_hba, task, slot); hisi_sas_slot_task_free(hisi_hba, task, slot);
sts = ts->stat; sts = ts->stat;
......
...@@ -1728,8 +1728,8 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot, ...@@ -1728,8 +1728,8 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot,
} }
out: out:
if (sas_dev && sas_dev->running_req) if (sas_dev)
sas_dev->running_req--; atomic64_dec(&sas_dev->running_req);
hisi_sas_slot_task_free(hisi_hba, task, slot); hisi_sas_slot_task_free(hisi_hba, task, slot);
sts = ts->stat; sts = ts->stat;
......
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