Re: [PATCH v4 4/4] scsi: ufs: inject errors to verify error handling

From: Akinobu Mita
Date: Wed Mar 04 2015 - 08:51:04 EST


2015-03-02 23:56 GMT+09:00 Gilad Broner <gbroner@xxxxxxxxxxxxxx>:
> From: Sujit Reddy Thumma <sthumma@xxxxxxxxxxxxxx>
>
> Use fault-injection framework to simulate error conditions
> in the controller and verify error handling mechanisms
> implemented in UFS host controller driver.
>
> This is used only during development and hence
> guarded by CONFIG_UFS_FAULT_INJECTION debug config option.

This feature looks useful, but I have a couple of comments and
question.

> +static bool inject_cmd_hang_tr(struct ufs_hba *hba)
> +{
> + int tag;
> +
> + tag = find_first_bit(&hba->outstanding_reqs, hba->nutrs);
> + if (tag == hba->nutrs)
> + return 0;
> +
> + __clear_bit(tag, &hba->outstanding_reqs);
> + hba->lrb[tag].cmd = NULL;
> + __clear_bit(tag, &hba->lrb_in_use);

hba->lrb_in_use is a bitmap set by test_and_set_bit_lock(). So
this should be cleared by clear_bit_unlock().

And as soon as the bit corresponds to this slot in hba->lrb_in_use is
cleared, this slot could be reused. But if the request corresponds
to the slot is not completed yet, it could sacrifice the new request,
too. So should we only inject into the commands which have been
completed like this?

tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);
completed_reqs = tr_doorbell ^ hba->outstanding_reqs;
tag = find_first_bit(&completed_reqs, hba->nutrs);
...

Or clear the corresponding bit in REG_UTP_TASK_REQ_LIST_CLEAR, just
like what inject_fatal_err_tr() does?

> +
> + /* command hang injected */
> + return 1;
> +}
> +
> +static int inject_cmd_hang_tm(struct ufs_hba *hba)
> +{
> + int tag;
> +
> + tag = find_first_bit(&hba->outstanding_tasks, hba->nutmrs);
> + if (tag == hba->nutmrs)
> + return 0;
> +
> + __clear_bit(tag, &hba->outstanding_tasks);
> + __clear_bit(tag, &hba->tm_slots_in_use);
> +
> + /* command hang injected */
> + return 1;
> +}

The same goes for hba->tm_slots_in_use.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/