From: Can Guo <cang@codeaurora.org>
To: Bart Van Assche <bvanassche@acm.org>
Cc: "Martin K . Petersen" <martin.petersen@oracle.com>,
linux-scsi@vger.kernel.org,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
Stanley Chu <stanley.chu@mediatek.com>,
Bean Huo <beanhuo@micron.com>, Avri Altman <avri.altman@wdc.com>,
Jaegeuk Kim <jaegeuk@kernel.org>,
Asutosh Das <asutoshd@codeaurora.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Kiwoong Kim <kwmad.kim@samsung.com>
Subject: Re: [PATCH RFC 3/4] ufs: Improve static type checking for the host controller state
Date: Wed, 23 Jun 2021 15:42:40 +0800 [thread overview]
Message-ID: <1b508ae21e3c81c690a8b875b8ed84b3@codeaurora.org> (raw)
In-Reply-To: <20210619005228.28569-4-bvanassche@acm.org>
Hi Bart,
On 2021-06-19 08:52, Bart Van Assche wrote:
> Assign a name to the enumeration type for UFS host controller states
> and
> remove the default clause from switch statements on this enumeration
> type
> to make the compiler warn about unhandled enumeration labels.
>
> Cc: Can Guo <cang@codeaurora.org>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> drivers/scsi/ufs/ufshcd.c | 15 ---------------
> drivers/scsi/ufs/ufshcd.h | 25 +++++++++++++++++++++++--
> 2 files changed, 23 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 71c720d940a3..c213daec20f7 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -128,15 +128,6 @@ enum {
> UFSHCD_CAN_QUEUE = 32,
> };
>
> -/* UFSHCD states */
> -enum {
> - UFSHCD_STATE_RESET,
> - UFSHCD_STATE_ERROR,
> - UFSHCD_STATE_OPERATIONAL,
> - UFSHCD_STATE_EH_SCHEDULED_FATAL,
> - UFSHCD_STATE_EH_SCHEDULED_NON_FATAL,
> -};
> -
> /* UFSHCD error handling flags */
> enum {
> UFSHCD_EH_IN_PROGRESS = (1 << 0),
> @@ -2738,12 +2729,6 @@ static int ufshcd_queuecommand(struct Scsi_Host
> *host, struct scsi_cmnd *cmd)
> set_host_byte(cmd, DID_ERROR);
> cmd->scsi_done(cmd);
> goto out;
> - default:
> - dev_WARN_ONCE(hba->dev, 1, "%s: invalid state %d\n",
> - __func__, hba->ufshcd_state);
> - set_host_byte(cmd, DID_BAD_TARGET);
> - cmd->scsi_done(cmd);
> - goto out;
> }
>
> hba->req_abort_count = 0;
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> index c98d540ac044..f2796ea25598 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -476,6 +476,27 @@ struct ufs_stats {
> struct ufs_event_hist event[UFS_EVT_CNT];
> };
>
> +/**
> + * enum ufshcd_state - UFS host controller state
> + * @UFSHCD_STATE_RESET: Link is not operational. Postpone SCSI command
> + * processing.
> + * @UFSHCD_STATE_OPERATIONAL: The host controller is operational and
> can process
> + * SCSI commands.
> + * @UFSHCD_STATE_EH_SCHEDULED_NON_FATAL: The error handler has been
> scheduled.
> + * SCSI commands may be submitted to the controller.
> + * @UFSHCD_STATE_EH_SCHEDULED_FATAL: The error handler has been
> scheduled. Fail
> + * newly submitted SCSI commands with error code DID_BAD_TARGET.
> + * @UFSHCD_STATE_ERROR: An unrecoverable error occurred, e.g. link
> recovery
> + * failed. Fail all SCSI commands with error code DID_ERROR.
> + */
> +enum ufshcd_state {
> + UFSHCD_STATE_RESET,
> + UFSHCD_STATE_OPERATIONAL,
> + UFSHCD_STATE_EH_SCHEDULED_NON_FATAL,
> + UFSHCD_STATE_EH_SCHEDULED_FATAL,
> + UFSHCD_STATE_ERROR,
> +};
> +
Hi Bart,
FYI, in my error handling update change series, I have one change
(https://lore.kernel.org/patchwork/patch/1450656/) which moves the
enumeration from ufshcd.c to ufshcd.h, which shall conflict with
this one. What shall we do?
Thanks,
Can Guo.
> enum ufshcd_quirks {
> /* Interrupt aggregation support is broken */
> UFSHCD_QUIRK_BROKEN_INTR_AGGR = 1 << 0,
> @@ -687,7 +708,7 @@ struct ufs_hba_monitor {
> * @tmf_tag_set: TMF tag set.
> * @tmf_queue: Used to allocate TMF tags.
> * @pwr_done: completion for power mode change
> - * @ufshcd_state: UFSHCD states
> + * @ufshcd_state: UFSHCD state
> * @eh_flags: Error handling flags
> * @intr_mask: Interrupt Mask Bits
> * @ee_ctrl_mask: Exception event control mask
> @@ -785,7 +806,7 @@ struct ufs_hba {
> struct mutex uic_cmd_mutex;
> struct completion *uic_async_done;
>
> - u32 ufshcd_state;
> + enum ufshcd_state ufshcd_state;
> u32 eh_flags;
> u32 intr_mask;
> u16 ee_ctrl_mask; /* Exception event mask */
next prev parent reply other threads:[~2021-06-23 7:42 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-19 0:52 [PATCH RFC 0/4] UFS patches for Linux kernel v5.14 Bart Van Assche
2021-06-19 0:52 ` [PATCH RFC 1/4] ufs: Rename the second ufshcd_probe_hba() argument Bart Van Assche
2021-06-21 8:13 ` Avri Altman
2021-06-19 0:52 ` [PATCH RFC 2/4] ufs: Remove a check from ufshcd_queuecommand() Bart Van Assche
2021-06-21 8:22 ` Avri Altman
2021-06-21 17:31 ` Bart Van Assche
2021-06-19 0:52 ` [PATCH RFC 3/4] ufs: Improve static type checking for the host controller state Bart Van Assche
2021-06-21 8:26 ` Avri Altman
2021-06-23 7:42 ` Can Guo [this message]
2021-06-23 16:10 ` Bart Van Assche
2021-06-19 0:52 ` [PATCH RFC 4/4] ufs: Make host controller state change handling more systematic Bart Van Assche
2021-06-21 8:55 ` Avri Altman
2021-06-21 17:38 ` Bart Van Assche
2021-06-23 8:08 ` Can Guo
2021-06-23 12:02 ` Can Guo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1b508ae21e3c81c690a8b875b8ed84b3@codeaurora.org \
--to=cang@codeaurora.org \
--cc=adrian.hunter@intel.com \
--cc=asutoshd@codeaurora.org \
--cc=avri.altman@wdc.com \
--cc=beanhuo@micron.com \
--cc=bvanassche@acm.org \
--cc=jaegeuk@kernel.org \
--cc=jejb@linux.ibm.com \
--cc=kwmad.kim@samsung.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=stanley.chu@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox