Multiple cleanup patches for the UFS driver
Subsystems (7)
Bart Van Assche
reviewerv2 cover Multiple cleanup patches for the UFS driver
Hi Martin,
This patch includes the following changes, none of which should change the functionality of the UFS host controller driver:
- Improve the kernel-doc headers further.
- Fix multiple W=2 compiler warnings.
- Simplify ufshcd_abort_all().
- Simplify the code for creating and parsing UFS Transport Protocol (UTP) headers.
Please consider this patch series for the next merge window.
Thanks,
Bart.
Changes compared to v1:
- Introduced a name for the data direction enumeration type.
- Instead of introducing struct utp_upiu_hdr as an alias for struct utp_upiu_header, introduce a union in the latter data structure.
Bart Van Assche (12):
scsi: ufs: Follow the kernel-doc syntax for documenting return values
scsi: ufs: Document all return values
scsi: ufs: Fix kernel-doc headers
scsi: ufs: Rename a function argument
scsi: ufs: Minimize #include directives
scsi: ufs: Simplify zero-initialization
scsi: ufs: Improve type safety
scsi: ufs: Remove a local variable from ufshcd_abort_all()
scsi: ufs: Simplify ufshcd_abort_all()
scsi: ufs: Remove a member variable
scsi: ufs: Simplify transfer request header initialization
scsi: ufs: Simplify response header parsing
drivers/ufs/core/ufs-hwmon.c | 3 +- drivers/ufs/core/ufs-mcq.c | 17 +- drivers/ufs/core/ufs_bsg.c | 2 + drivers/ufs/core/ufshcd-crypto.h | 20 +- drivers/ufs/core/ufshcd-priv.h | 4 +- drivers/ufs/core/ufshcd.c | 529 +++++++++++++++-------------- drivers/ufs/host/cdns-pltfrm.c | 27 +- drivers/ufs/host/tc-dwc-g210-pci.c | 2 +- drivers/ufs/host/tc-dwc-g210.c | 32 +- drivers/ufs/host/ufs-mediatek.c | 6 +- drivers/ufs/host/ufs-qcom.c | 8 +- drivers/ufs/host/ufshcd-dwc.c | 22 +- drivers/ufs/host/ufshcd-pci.c | 2 +- drivers/ufs/host/ufshcd-pltfrm.c | 6 +- include/uapi/scsi/scsi_bsg_ufs.h | 52 ++- include/ufs/ufs.h | 47 +-- include/ufs/ufshcd.h | 26 +- include/ufs/ufshci.h | 53 ++- 18 files changed, 460 insertions(+), 398 deletions(-)
Bart Van Assche
reviewerPATCH v2 1/12 scsi: ufs: Follow the kernel-doc syntax for documenting return values
Use 'Return:' to document the return value instead of 'Returns' as required by the kernel-doc documentation.
--- drivers/ufs/core/ufs-mcq.c | 10 +- drivers/ufs/core/ufshcd-priv.h | 2 +- drivers/ufs/core/ufshcd.c | 186 +++++++++++++++-------------- drivers/ufs/host/cdns-pltfrm.c | 10 +- drivers/ufs/host/tc-dwc-g210-pci.c | 2 +- drivers/ufs/host/tc-dwc-g210.c | 12 +- drivers/ufs/host/ufs-mediatek.c | 6 +- drivers/ufs/host/ufs-qcom.c | 8 +- drivers/ufs/host/ufshcd-dwc.c | 6 +- drivers/ufs/host/ufshcd-pci.c | 2 +- drivers/ufs/host/ufshcd-pltfrm.c | 4 +- 11 files changed, 126 insertions(+), 122 deletions(-)
drivers/ufs/core/ufs-mcq.c +5 -5
@@ -105,7 +105,7 @@ EXPORT_SYMBOL_GPL(ufshcd_mcq_config_mac);* @hba: per adapter instance * @req: pointer to the request to be issued * -* Returns the hardware queue instance on which the request would +* Return: the hardware queue instance on which the request would * be queued. */ struct ufs_hw_queue *ufshcd_mcq_req_to_hwq(struct ufs_hba *hba,
@@ -121,7 +121,7 @@ struct ufs_hw_queue *ufshcd_mcq_req_to_hwq(struct ufs_hba *hba,* ufshcd_mcq_decide_queue_depth - decide the queue depth * @hba: per adapter instance * -* Returns queue-depth on success, non-zero on error +* Return: queue-depth on success, non-zero on error * * MAC - Max. Active Command of the Host Controller (HC) * HC wouldn't send more than this commands to the device.
@@ -493,7 +493,7 @@ static int ufshcd_mcq_sq_start(struct ufs_hba *hba, struct ufs_hw_queue *hwq)* @hba: per adapter instance. * @task_tag: The command's task tag. * -* Returns 0 for success; error code otherwise. +* Return: 0 for success; error code otherwise. */ int ufshcd_mcq_sq_cleanup (struct ufs_hba *hba,int task_tag) {
@@ -575,7 +575,7 @@ static void ufshcd_mcq_nullify_sqe(struct utp_transfer_req_desc *utrd)* @hwq: Hardware Queue to be searched. * @task_tag: The command's task tag. * -* Returns true if the SQE containing the command is present in the SQ +* Return: true if the SQE containing the command is present in the SQ * (not fetched by the controller); returns false if the SQE is not in the SQ. */ static bool ufshcd_mcq_sqe_search(struct ufs_hba *hba,
@@ -624,7 +624,7 @@ static bool ufshcd_mcq_sqe_search(struct ufs_hba *hba,* ufshcd_mcq_abort - Abort the command in MCQ. * @cmd: The command to be aborted. * -* Returns SUCCESS or FAILED error codes +* Return: SUCCESS or FAILED error codes */ int ufshcd_mcq_abort (struct scsi_cmnd *cmd) {
drivers/ufs/core/ufshcd-priv.h +1 -1
@@ -294,7 +294,7 @@ extern const struct ufs_pm_lvl_states ufs_pm_lvl_states[];* ufshcd_scsi_to_upiu_lun - maps scsi LUN to UPIU LUN * @scsi_lun: scsi LUN id * -* Returns UPIU LUN id +* Return: UPIU LUN id */ static inline u8 ufshcd_scsi_to_upiu_lun (unsigned int scsi_lun) {
drivers/ufs/core/ufshcd.c +95 -91
686 lines not on this page · raw message
drivers/ufs/host/cdns-pltfrm.c +5 -5
@@ -105,7 +105,7 @@ static void cdns_ufs_set_l4_attr(struct ufs_hba *hba)* Sets HCLKDIV register value based on the core_clk * @hba: host controller instance * -* Return zero for success and non-zero for failure +* Return: zero for success and non-zero for failure. */ static int cdns_ufs_set_hclkdiv (struct ufs_hba *hba) {
@@ -148,7 +148,7 @@ static int cdns_ufs_set_hclkdiv(struct ufs_hba *hba)* @hba: host controller instance * @status: notify stage (pre, post change) * -* Return zero for success and non-zero for failure +* Return: zero for success and non-zero for failure. */ static int cdns_ufs_hce_enable_notify (struct ufs_hba *hba,enum ufs_notify_change_status status)
@@ -182,7 +182,7 @@ static void cdns_ufs_hibern8_notify(struct ufs_hba *hba, enum uic_cmd_dme cmd,* @hba: host controller instance * @status: notify stage (pre, post change) * -* Return zero for success and non-zero for failure +* Return: zero for success and non-zero for failure. */ static int cdns_ufs_link_startup_notify (struct ufs_hba *hba,enum ufs_notify_change_status status)
@@ -212,7 +212,7 @@ static int cdns_ufs_link_startup_notify(struct ufs_hba *hba,* cdns_ufs_init - performs additional ufs initialization * @hba: host controller instance * -* Returns status of initialization +* Return: status of initialization. */ static int cdns_ufs_init (struct ufs_hba *hba) {
@@ -284,7 +284,7 @@ MODULE_DEVICE_TABLE(of, cdns_ufs_of_match);* cdns_ufs_pltfrm_probe - probe routine of the driver * @pdev: pointer to platform device handle * -* Return zero for success and non-zero for failure +* Return: zero for success and non-zero for failure. */ static int cdns_ufs_pltfrm_probe (struct platform_device *pdev) {
drivers/ufs/host/tc-dwc-g210-pci.c +1 -1
@@ -51,7 +51,7 @@ static void tc_dwc_g210_pci_remove(struct pci_dev *pdev)* @pdev: pointer to PCI device handle * @id: PCI device id * -* Returns 0 on success, non-zero value on failure +* Return: 0 on success, non-zero value on failure. */ static int tc_dwc_g210_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id)
drivers/ufs/host/tc-dwc-g210.c +6 -6
@@ -21,7 +21,7 @@* This function configures Synopsys TC specific atributes (40-bit RMMI) * @hba: Pointer to drivers structure * -* Returns 0 on success or non-zero value on failure +* Return: 0 on success or non-zero value on failure. */ static int tc_dwc_g210_setup_40bit_rmmi (struct ufs_hba *hba) {
@@ -85,7 +85,7 @@ static int tc_dwc_g210_setup_40bit_rmmi(struct ufs_hba *hba)* This function configures Synopsys TC 20-bit RMMI Lane 0 * @hba: Pointer to drivers structure * -* Returns 0 on success or non-zero value on failure +* Return: 0 on success or non-zero value on failure. */ static int tc_dwc_g210_setup_20bit_rmmi_lane0 (struct ufs_hba *hba) {
@@ -138,7 +138,7 @@ static int tc_dwc_g210_setup_20bit_rmmi_lane0(struct ufs_hba *hba)* This function configures Synopsys TC 20-bit RMMI Lane 1 * @hba: Pointer to drivers structure * -* Returns 0 on success or non-zero value on failure +* Return: 0 on success or non-zero value on failure. */ static int tc_dwc_g210_setup_20bit_rmmi_lane1 (struct ufs_hba *hba) {
@@ -215,7 +215,7 @@ static int tc_dwc_g210_setup_20bit_rmmi_lane1(struct ufs_hba *hba)* This function configures Synopsys TC specific atributes (20-bit RMMI) * @hba: Pointer to drivers structure * -* Returns 0 on success or non-zero value on failure +* Return: 0 on success or non-zero value on failure. */ static int tc_dwc_g210_setup_20bit_rmmi (struct ufs_hba *hba) {
@@ -256,7 +256,7 @@ static int tc_dwc_g210_setup_20bit_rmmi(struct ufs_hba *hba)* * @hba: Pointer to drivers structure * -* Returns 0 on success non-zero value on failure +* Return: 0 on success non-zero value on failure. */ int tc_dwc_g210_config_40_bit (struct ufs_hba *hba) {
@@ -288,7 +288,7 @@ EXPORT_SYMBOL(tc_dwc_g210_config_40_bit);* * @hba: Pointer to drivers structure * -* Returns 0 on success non-zero value on failure +* Return: 0 on success non-zero value on failure. */ int tc_dwc_g210_config_20_bit (struct ufs_hba *hba) {
drivers/ufs/host/ufs-mediatek.c +3 -3
@@ -666,7 +666,7 @@ static void ufs_mtk_pwr_ctrl(struct ufs_hba *hba, bool on)* @on: If true, enable clocks else disable them. * @status: PRE_CHANGE or POST_CHANGE notify * -* Returns 0 on success, non-zero on failure. +* Return: 0 on success, non-zero on failure. */ static int ufs_mtk_setup_clocks (struct ufs_hba *hba,bool on,enum ufs_notify_change_status status)
@@ -885,7 +885,7 @@ static void ufs_mtk_init_mcq_irq(struct ufs_hba *hba)* Binds PHY with controller and powers up PHY enabling clocks * and regulators. * -* Returns -EPROBE_DEFER if binding fails, returns negative error +* Return: -EPROBE_DEFER if binding fails, returns negative error * on phy power up failure and returns zero on success. */ static int ufs_mtk_init (struct ufs_hba *hba)
@@ -1696,7 +1696,7 @@ static const struct ufs_hba_variant_ops ufs_hba_mtk_vops = {* ufs_mtk_probe - probe routine of the driver * @pdev: pointer to Platform device handle * -* Return zero for success and non-zero for failure +* Return: zero for success and non-zero for failure. */ static int ufs_mtk_probe (struct platform_device *pdev) {
drivers/ufs/host/ufs-qcom.c +4 -4
@@ -485,7 +485,7 @@ static int ufs_qcom_hce_enable_notify(struct ufs_hba *hba, }/* -* Returns zero for success and non-zero in case of a failure +* Return: zero for success and non-zero in case of a failure. */ static int ufs_qcom_cfg_timers (struct ufs_hba *hba,u32 gear,u32 hs,u32 rate,bool update_link_startup_timer)
@@ -964,7 +964,7 @@ static void ufs_qcom_set_caps(struct ufs_hba *hba)* @on: If true, enable clocks else disable them. * @status: PRE_CHANGE or POST_CHANGE notify * -* Returns 0 on success, non-zero on failure. +* Return: 0 on success, non-zero on failure. */ static int ufs_qcom_setup_clocks (struct ufs_hba *hba,bool on,enum ufs_notify_change_status status)
@@ -1038,7 +1038,7 @@ static const struct reset_control_ops ufs_qcom_reset_ops = {* Binds PHY with controller and powers up PHY enabling clocks * and regulators. * -* Returns -EPROBE_DEFER if binding fails, returns negative error +* Return: -EPROBE_DEFER if binding fails, returns negative error * on phy power up failure and returns zero on success. */ static int ufs_qcom_init (struct ufs_hba *hba)
@@ -1756,7 +1756,7 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = {* ufs_qcom_probe - probe routine of the driver * @pdev: pointer to Platform device handle * -* Return zero for success and non-zero for failure +* Return: zero for success and non-zero for failure. */ static int ufs_qcom_probe (struct platform_device *pdev) {
drivers/ufs/host/ufshcd-dwc.c +3 -3
@@ -51,7 +51,7 @@ static void ufshcd_dwc_program_clk_div(struct ufs_hba *hba, u32 divider_val)* Check if link is up * @hba: private structure pointer * -* Returns 0 on success, non-zero value on failure +* Return: 0 on success, non-zero value on failure. */ static int ufshcd_dwc_link_is_up (struct ufs_hba *hba) {
@@ -78,7 +78,7 @@ static int ufshcd_dwc_link_is_up(struct ufs_hba *hba)* * @hba: pointer to drivers private data * -* Returns 0 on success non-zero value on failure +* Return: 0 on success non-zero value on failure. */ static int ufshcd_dwc_connection_setup (struct ufs_hba *hba) {
@@ -112,7 +112,7 @@ static int ufshcd_dwc_connection_setup(struct ufs_hba *hba)* @hba: private structure pointer * @status: Callback notify status * -* Returns 0 on success, non-zero value on failure +* Return: 0 on success, non-zero value on failure. */ int ufshcd_dwc_link_startup_notify (struct ufs_hba *hba,enum ufs_notify_change_status status)
drivers/ufs/host/ufshcd-pci.c +1 -1
@@ -524,7 +524,7 @@ static void ufshcd_pci_remove(struct pci_dev *pdev)* @pdev: pointer to PCI device handle * @id: PCI device id * -* Returns 0 on success, non-zero value on failure +* Return: 0 on success, non-zero value on failure. */ static int ufshcd_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id)
drivers/ufs/host/ufshcd-pltfrm.c +2 -2
@@ -212,7 +212,7 @@ static void ufshcd_init_lanes_per_dir(struct ufs_hba *hba)* @dev_max: pointer to device attributes * @agreed_pwr: returned agreed attributes * -* Returns 0 on success, non-zero value on failure +* Return: 0 on success, non-zero value on failure. */ int ufshcd_get_pwr_dev_param(const struct ufs_dev_params *pltfrm_param, const struct ufs_pa_layer_attr *dev_max,
@@ -326,7 +326,7 @@ EXPORT_SYMBOL_GPL(ufshcd_init_pwr_dev_param);* @pdev: pointer to Platform device handle * @vops: pointer to variant ops * -* Returns 0 on success, non-zero value on failure +* Return: 0 on success, non-zero value on failure. */ int ufshcd_pltfrm_init (struct platform_device *pdev,const struct ufs_hba_variant_ops *vops)
Bart Van Assche
reviewerPATCH v2 2/12 scsi: ufs: Document all return values
In reply to Bart Van AsscheThis patch fixes multiple W=2 kernel-doc warnings.
--- drivers/ufs/core/ufs_bsg.c | 2 ++ drivers/ufs/core/ufshcd.c | 38 ++++++++++++++++++++++++++++++++ drivers/ufs/host/cdns-pltfrm.c | 4 ++-- drivers/ufs/host/ufshcd-pltfrm.c | 2 ++ 4 files changed, 44 insertions(+), 2 deletions(-)
drivers/ufs/core/ufs_bsg.c +2 -0
@@ -232,6 +232,8 @@ static inline void ufs_bsg_node_release(struct device *dev)* @hba: per adapter object * * Called during initial loading of the driver, and before scsi_scan_host. +* +* Returns: 0 (success). */ int ufs_bsg_probe (struct ufs_hba *hba) {
drivers/ufs/core/ufshcd.c +38 -0
@@ -876,6 +876,8 @@ static inline u32 ufshcd_get_dme_attr_val(struct ufs_hba *hba)/** * ufshcd_get_req_rsp - returns the TR response transaction type * @ucd_rsp_ptr: pointer to response UPIU +* +* Return: UPIU type. */ static inline int ufshcd_get_req_rsp (struct utp_upiu_rsp *ucd_rsp_ptr)
@@ -2241,6 +2243,8 @@ static inline void ufshcd_copy_sense_data(struct ufshcd_lrb *lrbp)* descriptor * @hba: per adapter instance * @lrbp: pointer to local reference block +* +* Return: 0 upon success; < 0 upon failure. */ static int ufshcd_copy_query_response (struct ufs_hba *hba,struct ufshcd_lrb *lrbp)
@@ -2713,6 +2717,8 @@ static inline void ufshcd_prepare_utp_nop_upiu(struct ufshcd_lrb *lrbp)* for Device Management Purposes * @hba: per adapter instance * @lrbp: pointer to local reference block +* +* Return: 0 upon success; < 0 upon failure. */ static int ufshcd_compose_devman_upiu (struct ufs_hba *hba,struct ufshcd_lrb *lrbp)
@@ -2741,6 +2747,8 @@ static int ufshcd_compose_devman_upiu(struct ufs_hba *hba,* for SCSI Purposes * @hba: per adapter instance * @lrbp: pointer to local reference block +* +* Return: 0 upon success; < 0 upon failure. */ static int ufshcd_comp_scsi_upiu (struct ufs_hba *hba,struct ufshcd_lrb *lrbp) {
@@ -3018,6 +3026,8 @@ ufshcd_check_query_response(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)* ufshcd_dev_cmd_completion() - handles device management command responses * @hba: per adapter instance * @lrbp: pointer to local reference block +* +* Return: 0 upon success; < 0 upon failure. */ static int ufshcd_dev_cmd_completion (struct ufs_hba *hba,struct ufshcd_lrb *lrbp)
@@ -3155,6 +3165,8 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba,* @cmd_type: specifies the type (NOP, Query...) * @timeout: timeout in milliseconds * +* Return: 0 upon success; < 0 upon failure. +* * NOTE: Since there is only one available tag for device management commands, * it is expected you hold the hba->dev_cmd.lock mutex. */
@@ -4387,6 +4399,8 @@ static void ufshcd_init_pwr_info(struct ufs_hba *hba)/** * ufshcd_get_max_pwr_mode - reads the max power mode negotiated with device * @hba: per-adapter instance +* +* Return: 0 upon success; < 0 upon failure. */ static int ufshcd_get_max_pwr_mode (struct ufs_hba *hba) {
@@ -4544,6 +4558,8 @@ static int ufshcd_change_power_mode(struct ufs_hba *hba,* ufshcd_config_pwr_mode - configure a new power mode * @hba: per-adapter instance * @desired_pwr_mode: desired power configuration +* +* Return: 0 upon success; < 0 upon failure. */ int ufshcd_config_pwr_mode (struct ufs_hba *hba,struct ufs_pa_layer_attr *desired_pwr_mode)
@@ -4568,6 +4584,8 @@ EXPORT_SYMBOL_GPL(ufshcd_config_pwr_mode);* @hba: per-adapter instance * * Set fDeviceInit flag and poll until device toggles it. +* +* Return: 0 upon success; < 0 upon failure. */ static int ufshcd_complete_dev_init (struct ufs_hba *hba) {
@@ -4939,6 +4957,8 @@ static int ufshcd_link_startup(struct ufs_hba *hba)* If the UTP layer at the device side is not initialized, it may * not respond with NOP IN UPIU within timeout of %NOP_OUT_TIMEOUT * and we retry sending NOP OUT for %NOP_OUT_RETRIES iterations. +* +* Return: 0 upon success; < 0 upon failure. */ static int ufshcd_verify_dev_init (struct ufs_hba *hba) {
@@ -5099,6 +5119,8 @@ static int ufshcd_slave_alloc(struct scsi_device *sdev)* @depth: required depth to set * * Change queue depth and make sure the max. limits are not crossed. +* +* Return: new queue depth. */ static int ufshcd_change_queue_depth (struct scsi_device *sdev,int depth) {
@@ -5108,6 +5130,8 @@ static int ufshcd_change_queue_depth(struct scsi_device *sdev, int depth)/** * ufshcd_slave_configure - adjust SCSI device configurations * @sdev: pointer to SCSI device +* +* Return: 0 (success). */ static int ufshcd_slave_configure (struct scsi_device *sdev) {
@@ -5824,6 +5848,8 @@ static int ufshcd_bkops_ctrl(struct ufs_hba *hba,* * If BKOPs is enabled, this function returns 0, 1 if the bkops in not enabled * and negative error value for any other failure. +* +* Return: 0 upon success; < 0 upon failure. */ static int ufshcd_urgent_bkops (struct ufs_hba *hba) {
@@ -7064,6 +7090,8 @@ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id,* * Since there is only one available tag for device management commands, * the caller is expected to hold the hba->dev_cmd.lock mutex. +* +* Return: 0 upon success; < 0 upon failure. */ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, struct utp_upiu_req *req_upiu,
@@ -7165,6 +7193,8 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba,* Management requests. * It is up to the caller to fill the upiu conent properly, as it will * be copied without any further input validations. +* +* Return: 0 upon success; < 0 upon failure. */ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba, struct utp_upiu_req *req_upiu,
@@ -8478,6 +8508,8 @@ static int ufshcd_device_params_init(struct ufs_hba *hba)/** * ufshcd_add_lus - probe and add UFS logical units * @hba: per-adapter instance +* +* Return: 0 upon success; < 0 upon failure. */ static int ufshcd_add_lus (struct ufs_hba *hba) {
@@ -8687,6 +8719,8 @@ static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params)* @init_dev_params: whether or not to call ufshcd_device_params_init(). * * Execute link-startup and verify device initialization +* +* Return: 0 upon success; < 0 upon failure. */ static int ufshcd_probe_hba (struct ufs_hba *hba,bool init_dev_params) {
@@ -9841,6 +9875,8 @@ static int ufshcd_wl_resume(struct device *dev)* * This function will put disable irqs, turn off clocks * and set vreg and hba-vreg in lpm mode. +* +* Return: 0 upon success; < 0 upon failure. */ static int ufshcd_suspend (struct ufs_hba *hba) {
@@ -10002,6 +10038,8 @@ EXPORT_SYMBOL(ufshcd_runtime_suspend);* * 1. Turn on all the controller related clocks * 2. Turn ON VCC rail +* +* Return: 0 upon success; < 0 upon failure. */ int ufshcd_runtime_resume (struct device *dev) {
drivers/ufs/host/cdns-pltfrm.c +2 -2
@@ -235,7 +235,7 @@ static int cdns_ufs_init(struct ufs_hba *hba)* cdns_ufs_m31_16nm_phy_initialization - performs m31 phy initialization * @hba: host controller instance * -* Always returns 0 +* Return: 0 (success). */ static int cdns_ufs_m31_16nm_phy_initialization (struct ufs_hba *hba) {
@@ -308,7 +308,7 @@ static int cdns_ufs_pltfrm_probe(struct platform_device *pdev)* cdns_ufs_pltfrm_remove - removes the ufs driver * @pdev: pointer to platform device handle * -* Always returns 0 +* Return: 0 (success). */ static int cdns_ufs_pltfrm_remove (struct platform_device *pdev) {
drivers/ufs/host/ufshcd-pltfrm.c +2 -0
@@ -166,6 +166,8 @@ EXPORT_SYMBOL_GPL(ufshcd_populate_vreg);* If any of the supplies are not defined it is assumed that they are always-on * and hence return zero. If the property is defined but parsing is failed * then return corresponding error. +* +* Return: 0 upon success; < 0 upon failure. */ static int ufshcd_parse_regulator_info (struct ufs_hba *hba) {
Bart Van Assche
reviewerPATCH v2 3/12 scsi: ufs: Fix kernel-doc headers
In reply to Bart Van AsscheFix the remaining kernel-doc warnings that are reported when building with W=2.
--- drivers/ufs/host/cdns-pltfrm.c | 13 ++++--------- drivers/ufs/host/tc-dwc-g210.c | 20 ++++++-------------- drivers/ufs/host/ufshcd-dwc.c | 16 ++++++---------- 3 files changed, 16 insertions(+), 33 deletions(-)
drivers/ufs/host/cdns-pltfrm.c +4 -9
@@ -101,8 +101,7 @@ static void cdns_ufs_set_l4_attr(struct ufs_hba *hba) }/** -* cdns_ufs_set_hclkdiv() -* Sets HCLKDIV register value based on the core_clk +* cdns_ufs_set_hclkdiv() - set HCLKDIV register value based on the core_clk. * @hba: host controller instance * * Return: zero for success and non-zero for failure.
@@ -143,8 +142,7 @@ static int cdns_ufs_set_hclkdiv(struct ufs_hba *hba) }/** -* cdns_ufs_hce_enable_notify() -* Called before and after HCE enable bit is set. +* cdns_ufs_hce_enable_notify() - set HCLKDIV register * @hba: host controller instance * @status: notify stage (pre, post change) *
@@ -160,12 +158,10 @@ static int cdns_ufs_hce_enable_notify(struct ufs_hba *hba, }/** -* cdns_ufs_hibern8_notify() -* Called around hibern8 enter/exit. +* cdns_ufs_hibern8_notify() - save and restore L4 attributes. * @hba: host controller instance * @cmd: UIC Command * @status: notify stage (pre, post change) -* */ static void cdns_ufs_hibern8_notify (struct ufs_hba *hba,enum uic_cmd_dme cmd,enum ufs_notify_change_status status)
@@ -177,8 +173,7 @@ static void cdns_ufs_hibern8_notify(struct ufs_hba *hba, enum uic_cmd_dme cmd, }/** -* cdns_ufs_link_startup_notify() -* Called before and after Link startup is carried out. +* cdns_ufs_link_startup_notify() - handle link startup. * @hba: host controller instance * @status: notify stage (pre, post change) *
drivers/ufs/host/tc-dwc-g210.c +6 -14
@@ -17,8 +17,7 @@#include "tc-dwc-g210.h" /** -* tc_dwc_g210_setup_40bit_rmmi() -* This function configures Synopsys TC specific atributes (40-bit RMMI) +* tc_dwc_g210_setup_40bit_rmmi() - configure 40-bit RMMI. * @hba: Pointer to drivers structure * * Return: 0 on success or non-zero value on failure.
@@ -81,8 +80,7 @@ static int tc_dwc_g210_setup_40bit_rmmi(struct ufs_hba *hba) }/** -* tc_dwc_g210_setup_20bit_rmmi_lane0() -* This function configures Synopsys TC 20-bit RMMI Lane 0 +* tc_dwc_g210_setup_20bit_rmmi_lane0() - configure 20-bit RMMI Lane 0. * @hba: Pointer to drivers structure * * Return: 0 on success or non-zero value on failure.
@@ -134,8 +132,7 @@ static int tc_dwc_g210_setup_20bit_rmmi_lane0(struct ufs_hba *hba) }/** -* tc_dwc_g210_setup_20bit_rmmi_lane1() -* This function configures Synopsys TC 20-bit RMMI Lane 1 +* tc_dwc_g210_setup_20bit_rmmi_lane1() - configure 20-bit RMMI Lane 1. * @hba: Pointer to drivers structure * * Return: 0 on success or non-zero value on failure.
@@ -211,8 +208,7 @@ static int tc_dwc_g210_setup_20bit_rmmi_lane1(struct ufs_hba *hba) }/** -* tc_dwc_g210_setup_20bit_rmmi() -* This function configures Synopsys TC specific atributes (20-bit RMMI) +* tc_dwc_g210_setup_20bit_rmmi() - configure 20-bit RMMI. * @hba: Pointer to drivers structure * * Return: 0 on success or non-zero value on failure.
@@ -251,9 +247,7 @@ static int tc_dwc_g210_setup_20bit_rmmi(struct ufs_hba *hba) }/** -* tc_dwc_g210_config_40_bit() -* This function configures Local (host) Synopsys 40-bit TC specific attributes -* +* tc_dwc_g210_config_40_bit() - configure 40-bit TC specific attributes. * @hba: Pointer to drivers structure * * Return: 0 on success non-zero value on failure.
@@ -283,9 +277,7 @@ int tc_dwc_g210_config_40_bit(struct ufs_hba *hba)EXPORT_SYMBOL (tc_dwc_g210_config_40_bit);/** -* tc_dwc_g210_config_20_bit() -* This function configures Local (host) Synopsys 20-bit TC specific attributes -* +* tc_dwc_g210_config_20_bit() - configure 20-bit TC specific attributes. * @hba: Pointer to drivers structure * * Return: 0 on success non-zero value on failure.
drivers/ufs/host/ufshcd-dwc.c +6 -10
@@ -34,9 +34,7 @@ int ufshcd_dwc_dme_set_attrs(struct ufs_hba *hba,EXPORT_SYMBOL (ufshcd_dwc_dme_set_attrs);/** -* ufshcd_dwc_program_clk_div() -* This function programs the clk divider value. This value is needed to -* provide 1 microsecond tick to unipro layer. +* ufshcd_dwc_program_clk_div() - program clock divider. * @hba: Private Structure pointer * @divider_val: clock divider value to be programmed *
@@ -47,8 +45,7 @@ static void ufshcd_dwc_program_clk_div(struct ufs_hba *hba, u32 divider_val) }/** -* ufshcd_dwc_link_is_up() -* Check if link is up +* ufshcd_dwc_link_is_up() - check if link is up. * @hba: private structure pointer * * Return: 0 on success, non-zero value on failure.
@@ -68,7 +65,9 @@ static int ufshcd_dwc_link_is_up(struct ufs_hba *hba) }/** -* ufshcd_dwc_connection_setup() +* ufshcd_dwc_connection_setup() - configure unipro attributes. +* @hba: pointer to drivers private data +* * This function configures both the local side (host) and the peer side * (device) unipro attributes to establish the connection to application/ * cport.
@@ -76,8 +75,6 @@ static int ufshcd_dwc_link_is_up(struct ufs_hba *hba)* have this connection setup on reset. But invoking this function does no * harm and should be fine even working with any ufs device. * -* @hba: pointer to drivers private data -* * Return: 0 on success non-zero value on failure. */ static int ufshcd_dwc_connection_setup (struct ufs_hba *hba)
@@ -107,8 +104,7 @@ static int ufshcd_dwc_connection_setup(struct ufs_hba *hba) }/** -* ufshcd_dwc_link_startup_notify() -* UFS Host DWC specific link startup sequence +* ufshcd_dwc_link_startup_notify() - program clock divider. * @hba: private structure pointer * @status: Callback notify status *
Bart Van Assche
reviewerPATCH v2 4/12 scsi: ufs: Rename a function argument
In reply to Bart Van AsscheThis patch suppresses the following W=2 warning:
drivers/ufs/core/ufs-hwmon.c:130:49: warning: declaration of ‘_data’ shadows a global declaration [-Wshadow]
--- drivers/ufs/core/ufs-hwmon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/ufs/core/ufs-hwmon.c +2 -1
@@ -127,7 +127,8 @@ static int ufs_hwmon_write(struct device *dev, enum hwmon_sensor_types type, u32return err; } -static umode_t ufs_hwmon_is_visible (const void *_data,enum hwmon_sensor_types type,u32 attr, +static umode_t ufs_hwmon_is_visible (const void *data, +enum hwmon_sensor_types type,u32 attr,int channel) {if (type != hwmon_temp)
Bart Van Assche
reviewerPATCH v2 5/12 scsi: ufs: Minimize #include directives
In reply to Bart Van AsscheOnly #include those header files that are needed.
Note: include/ufs/ufshcd.h needs <scsi/scsi_host.h> because of SG_ALL.
--- include/ufs/ufs.h | 2 +- include/ufs/ufshcd.h | 1 + include/ufs/ufshci.h | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-)
include/ufs/ufs.h +1 -1
@@ -11,7 +11,7 @@#ifndef _UFS_H#define _UFS_H -#include <linux/mutex.h> +#include <linux/bitops.h> #include <linux/types.h> #include <uapi/scsi/scsi_bsg_ufs.h>
include/ufs/ufshcd.h +1 -0
@@ -20,6 +20,7 @@#include <linux/pm_runtime.h> #include <linux/dma-direction.h> #include <scsi/scsi_device.h> +#include <scsi/scsi_host.h> #include <ufs/unipro.h> #include <ufs/ufs.h> #include <ufs/ufs_quirks.h>
include/ufs/ufshci.h +2 -1
@@ -11,7 +11,8 @@#ifndef _UFSHCI_H#define _UFSHCI_H -#include <scsi/scsi_host.h> +#include <linux/types.h> +#include <ufs/ufs.h> enum { TASK_REQ_UPIU_SIZE_DWORDS = 8,
Bart Van Assche
reviewerPATCH v2 6/12 scsi: ufs: Simplify zero-initialization
In reply to Bart Van AsscheUse { } instead of { { 0 }, } to zero-initialize data structures on the stack. This patch fixes two W=2 warnings.
--- drivers/ufs/core/ufshcd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ufs/core/ufshcd.c +2 -2
@@ -7040,7 +7040,7 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba,static int ufshcd_issue_tm_cmd (struct ufs_hba *hba,int lun_id,int task_id,u8 tm_function,u8 *tm_response) { -struct utp_task_req_desc treq = { {0 }, }; +struct utp_task_req_desc treq = { };enum utp_ocs ocs_value;int err;
@@ -7205,7 +7205,7 @@ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba, {int err;enum dev_cmd_type cmd_type =DEV_CMD_TYPE_QUERY ; -struct utp_task_req_desc treq = { {0 }, }; +struct utp_task_req_desc treq = { };enum utp_ocs ocs_value;u8 tm_f =be32_to_cpu (req_upiu->header.dword_1) >>16 &MASK_TM_FUNC ;
Bart Van Assche
reviewerPATCH v2 7/12 scsi: ufs: Improve type safety
In reply to Bart Van AsscheAssign names to the enumeration types for UPIU types. Use these enumeration types where appropriate.
--- drivers/ufs/core/ufshcd-priv.h | 2 +- drivers/ufs/core/ufshcd.c | 9 ++++----- include/ufs/ufs.h | 4 ++-- include/ufs/ufshcd.h | 6 ------ 4 files changed, 7 insertions(+), 14 deletions(-)
drivers/ufs/core/ufshcd-priv.h +1 -1
@@ -93,7 +93,7 @@ int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd);int ufshcd_exec_raw_upiu_cmd (struct ufs_hba *hba,struct utp_upiu_req *req_upiu,struct utp_upiu_req *rsp_upiu, -int msgcode, +enum upiu_request_transaction msgcode,u8 *desc_buff,int *buff_len,enum query_opcode desc_op);
drivers/ufs/core/ufshcd.c +4 -5
@@ -879,7 +879,7 @@ static inline u32 ufshcd_get_dme_attr_val(struct ufs_hba *hba)* * Return: UPIU type. */ -static inline int +static inline enum upiu_response_transaction ufshcd_get_req_rsp (struct utp_upiu_rsp *ucd_rsp_ptr) {return be32_to_cpu (ucd_rsp_ptr->header.dword_0) >>24 ;
@@ -3032,7 +3032,7 @@ ufshcd_check_query_response(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)static int ufshcd_dev_cmd_completion (struct ufs_hba *hba,struct ufshcd_lrb *lrbp) { -int resp; +enum upiu_response_transaction resp;int err =0 ; hba->ufs_stats.last_hibern8_exit_tstamp =ktime_set (0 ,0 );
@@ -5271,9 +5271,8 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp,switch (ocs) {case OCS_SUCCESS : - result =ufshcd_get_req_rsp (lrbp->ucd_rsp_ptr); hba->ufs_stats.last_hibern8_exit_tstamp =ktime_set (0 ,0 ); -switch (result) { +switch (ufshcd_get_req_rsp (lrbp->ucd_rsp_ptr)) {case UPIU_TRANSACTION_RESPONSE :/* * get the response UPIU result to extract
@@ -7199,7 +7198,7 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba,int ufshcd_exec_raw_upiu_cmd (struct ufs_hba *hba,struct utp_upiu_req *req_upiu,struct utp_upiu_req *rsp_upiu, -int msgcode, +enum upiu_request_transaction msgcode,u8 *desc_buff,int *buff_len,enum query_opcode desc_op) {
include/ufs/ufs.h +2 -2
@@ -78,7 +78,7 @@ enum { };/* UTP UPIU Transaction Codes Initiator to Target */ -enum { +enum upiu_request_transaction {UPIU_TRANSACTION_NOP_OUT =0x00 ,UPIU_TRANSACTION_COMMAND =0x01 ,UPIU_TRANSACTION_DATA_OUT =0x02 ,
@@ -87,7 +87,7 @@ enum { };/* UTP UPIU Transaction Codes Target to Initiator */ -enum { +enum upiu_response_transaction {UPIU_TRANSACTION_NOP_IN =0x20 ,UPIU_TRANSACTION_RESPONSE =0x21 ,UPIU_TRANSACTION_DATA_IN =0x22 ,
include/ufs/ufshcd.h +0 -6
@@ -1357,12 +1357,6 @@ int ufshcd_get_vreg(struct device *dev, struct ufs_vreg *vreg);int ufshcd_send_uic_cmd (struct ufs_hba *hba,struct uic_command *uic_cmd); -int ufshcd_exec_raw_upiu_cmd (struct ufs_hba *hba, -struct utp_upiu_req *req_upiu, -struct utp_upiu_req *rsp_upiu, -int msgcode, -u8 *desc_buff,int *buff_len, -enum query_opcode desc_op); int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *req_upiu, struct utp_upiu_req *rsp_upiu, struct ufs_ehs *ehs_req, struct ufs_ehs *ehs_rsp, int sg_cnt,
Bart Van Assche
reviewerPATCH v2 8/12 scsi: ufs: Remove a local variable from ufshcd_abort_all()
In reply to Bart Van AsscheNo functionality is changed. This patch prepares for unifying the MCQ and legacy code paths in this function.
--- drivers/ufs/core/ufshcd.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/ufs/core/ufshcd.c +11 -11
@@ -6387,9 +6387,14 @@ static bool ufshcd_is_pwr_mode_restore_needed(struct ufs_hba *hba)return false; } +/** +* ufshcd_abort_all - Abort all pending commands. +* @hba: Host bus adapter pointer. +* +* Return: true if and only if the host controller needs to be reset. +*/ static bool ufshcd_abort_all (struct ufs_hba *hba) { -bool needs_reset = false;int tag, ret;if (is_mcq_enabled (hba)) {
@@ -6404,10 +6409,8 @@ static bool ufshcd_abort_all(struct ufs_hba *hba)dev_err (hba->dev,"Aborting tag %d / CDB %#02x %s\n" , tag, hba->lrb[tag].cmd ? hba->lrb[tag].cmd->cmnd[0 ] :-1 , ret ?"failed" :"succeeded" ); -if (ret) { - needs_reset = true; +if (ret) goto out; - } } }else {/* Clear pending transfer requests */
@@ -6416,25 +6419,22 @@ static bool ufshcd_abort_all(struct ufs_hba *hba)dev_err (hba->dev,"Aborting tag %d / CDB %#02x %s\n" , tag, hba->lrb[tag].cmd ? hba->lrb[tag].cmd->cmnd[0 ] :-1 , ret ?"failed" :"succeeded" ); -if (ret) { - needs_reset = true; +if (ret) goto out; - } } }/* Clear pending task management requests */ for_each_set_bit (tag, &hba->outstanding_tasks, hba->nutmrs) { -if (ufshcd_clear_tm_cmd (hba, tag)) { - needs_reset = true; + ret =ufshcd_clear_tm_cmd (hba, tag); +if (ret) goto out; - } } out:/* Complete the requests that are cleared by s/w */ ufshcd_complete_requests (hba, false); -return needs_reset; +return ret !=0 ; }/**
Bart Van Assche
reviewerPATCH v2 9/12 scsi: ufs: Simplify ufshcd_abort_all()
In reply to Bart Van AsscheUnify the MCQ and legacy code paths. This patch reworks code introduced by commit ab248643d3d6 ("scsi: ufs: core: Add error handling for MCQ mode").
--- drivers/ufs/core/ufshcd.c | 46 +++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 26 deletions(-)
drivers/ufs/core/ufshcd.c +20 -26
@@ -6387,6 +6387,22 @@ static bool ufshcd_is_pwr_mode_restore_needed(struct ufs_hba *hba)return false; } +static bool ufshcd_abort_one (struct request *rq,void *priv) +{ +int *ret = priv; +u32 tag = rq->tag; +struct scsi_cmnd *cmd =blk_mq_rq_to_pdu (rq); +struct scsi_device *sdev = cmd->device; +struct Scsi_Host *shost = sdev->host; +struct ufs_hba *hba =shost_priv (shost); + + *ret =ufshcd_try_to_abort_task (hba, tag); +dev_err (hba->dev,"Aborting tag %d / CDB %#02x %s\n" , tag, + hba->lrb[tag].cmd ? hba->lrb[tag].cmd->cmnd[0 ] :-1 , + *ret ?"failed" :"succeeded" ); +return *ret ==0 ; +} +/** * ufshcd_abort_all - Abort all pending commands. * @hba: Host bus adapter pointer.
@@ -6395,34 +6411,12 @@ static bool ufshcd_is_pwr_mode_restore_needed(struct ufs_hba *hba)*/ static bool ufshcd_abort_all (struct ufs_hba *hba) { -int tag, ret; +int tag, ret =0 ; -if (is_mcq_enabled (hba)) { -struct ufshcd_lrb *lrbp; -int tag; +blk_mq_tagset_busy_iter (&hba->host->tag_set, ufshcd_abort_one, &ret); +if (ret) + goto out; -for (tag =0 ; tag < hba->nutrs; tag++) { - lrbp = &hba->lrb[tag]; -if (!ufshcd_cmd_inflight (lrbp->cmd)) -continue ; - ret =ufshcd_try_to_abort_task (hba, tag); -dev_err (hba->dev,"Aborting tag %d / CDB %#02x %s\n" , tag, - hba->lrb[tag].cmd ? hba->lrb[tag].cmd->cmnd[0 ] :-1 , - ret ?"failed" :"succeeded" ); -if (ret) - goto out; - } - }else { -/* Clear pending transfer requests */ -for_each_set_bit (tag, &hba->outstanding_reqs, hba->nutrs) { - ret =ufshcd_try_to_abort_task (hba, tag); -dev_err (hba->dev,"Aborting tag %d / CDB %#02x %s\n" , tag, - hba->lrb[tag].cmd ? hba->lrb[tag].cmd->cmnd[0 ] :-1 , - ret ?"failed" :"succeeded" ); -if (ret) - goto out; - } - }/* Clear pending task management requests */ for_each_set_bit (tag, &hba->outstanding_tasks, hba->nutmrs) { ret =ufshcd_clear_tm_cmd (hba, tag);
Peter Wang (王信友)
maintainerRe: [PATCH v2 09/12] scsi: ufs: Simplify ufshcd_abort_all()
Quoted 78 lines · Bart Van Assche
Unify the MCQ and legacy code paths. This patch reworks code introduced by
commitab248643d3d6("scsi: ufs: core: Add error handling for MCQ mode").Cc Bao D. Nguyen <[email protected]>Signed-off-by Bart Van Assche <[email protected]>--- drivers/ufs/core/ufshcd.c | 46 +++++++++++++++++------------------ ---- 1 file changed, 20 insertions(+), 26 deletions(-)drivers/ufs/core/ufshcd.c +16
-0@@ -6387,6 +6387,22 @@ static bool ufshcd_is_pwr_mode_restore_needed(struct ufs_hba *hba) return false; } +static bool ufshcd_abort_one (struct request *rq,void *priv) +{ +int *ret = priv; +u32 tag = rq->tag; +struct scsi_cmnd *cmd =blk_mq_rq_to_pdu (rq); +struct scsi_device *sdev = cmd->device; +struct Scsi_Host *shost = sdev->host; +struct ufs_hba *hba =shost_priv (shost); + + *ret =ufshcd_try_to_abort_task (hba, tag); +dev_err (hba->dev,"Aborting tag %d / CDB %#02x %s\n" , tag, + hba->lrb[tag].cmd ? hba->lrb[tag].cmd->cmnd[0 ] :-1 , + *ret ?"failed" :"succeeded" ); +return *ret ==0 ; +} +/** * ufshcd_abort_all - Abort all pending commands. * @hba: Host bus adapter pointer.
drivers/ufs/core/ufshcd.c +4
-11@@ -6395,34 +6411,12 @@ static boolufshcd_is_pwr_mode_restore_needed(struct ufs_hba *hba) */ static bool ufshcd_abort_all (struct ufs_hba *hba) { -int tag, ret; +int tag, ret =0 ; -if (is_mcq_enabled (hba)) { -struct ufshcd_lrb *lrbp; -int tag; +blk_mq_tagset_busy_iter (&hba->host->tag_set, ufshcd_abort_one, &ret); +if (ret) + goto out; -for (tag =0 ; tag < hba->nutrs; tag++) { - lrbp = &hba->lrb[tag]; -if (!ufshcd_cmd_inflight (lrbp->cmd)) -continue ; - ret =ufshcd_try_to_abort_task (hba, tag); - dev_err(hba->dev, "Aborting tag %d / CDB %#02x %s\n", tag, - hba->lrb[tag].cmd ? hba->lrb[tag].cmd-Quoted 1 line
cmnd[0] : -1,
drivers/ufs/core/ufshcd.c +0
-7- ret ? "failed" : "succeeded"); -if (ret) - goto out; - } - }else { -/* Clear pending transfer requests */ - for_each_set_bit(tag, &hba->outstanding_reqs, hba-Quoted 1 line
nutrs) {
drivers/ufs/core/ufshcd.c +0
-2- ret =ufshcd_try_to_abort_task (hba, tag); - dev_err(hba->dev, "Aborting tag %d / CDB %#02x%s\n", tag,
drivers/ufs/core/ufshcd.c +0
-1- hba->lrb[tag].cmd ? hba->lrb[tag].cmd-Quoted 1 line
cmnd[0] : -1,
drivers/ufs/core/ufshcd.c static bool ufshcd_is_pwr_mode_restore_needed(struct ufs_hba *hba) · line 6422
Quoted 8 lines
drivers/ufs/core/ufshcd.c +0
-5- ret ? "failed" : "succeeded"); -if (ret) - goto out; - } - }/* Clear pending task management requests */ for_each_set_bit (tag, &hba->outstanding_tasks, hba->nutmrs) { ret =ufshcd_clear_tm_cmd (hba, tag);
Hi Bart,
Previous ufshcd_try_to_abort_task retrun fail will break tag iterate and return true to tell caller need reset.
But this patch only return last tag ufshcd_try_to_abort_task return value, if some tag abort fail and last tag abort success, will not retrun true to tell caller need reset, am I right?
Thanks.
Peter
Bart Van Assche
reviewerRe: [PATCH v2 09/12] scsi: ufs: Simplify ufshcd_abort_all()
Quoted 90 lines · Peter Wang (王信友)
Quoted 78 lines · Bart Van Assche
Unify the MCQ and legacy code paths. This patch reworks code introduced by
commitab248643d3d6("scsi: ufs: core: Add error handling for MCQ mode").Cc Bao D. Nguyen <[email protected]>Signed-off-by Bart Van Assche <[email protected]>--- drivers/ufs/core/ufshcd.c | 46 +++++++++++++++++------------------ ---- 1 file changed, 20 insertions(+), 26 deletions(-)drivers/ufs/core/ufshcd.c +16
-0@@ -6387,6 +6387,22 @@ static bool ufshcd_is_pwr_mode_restore_needed(struct ufs_hba *hba) return false; } +static bool ufshcd_abort_one (struct request *rq,void *priv) +{ +int *ret = priv; +u32 tag = rq->tag; +struct scsi_cmnd *cmd =blk_mq_rq_to_pdu (rq); +struct scsi_device *sdev = cmd->device; +struct Scsi_Host *shost = sdev->host; +struct ufs_hba *hba =shost_priv (shost); + + *ret =ufshcd_try_to_abort_task (hba, tag); +dev_err (hba->dev,"Aborting tag %d / CDB %#02x %s\n" , tag, + hba->lrb[tag].cmd ? hba->lrb[tag].cmd->cmnd[0 ] :-1 , + *ret ?"failed" :"succeeded" ); +return *ret ==0 ; +} +/** * ufshcd_abort_all - Abort all pending commands. * @hba: Host bus adapter pointer.
drivers/ufs/core/ufshcd.c +4
-11@@ -6395,34 +6411,12 @@ static boolufshcd_is_pwr_mode_restore_needed(struct ufs_hba *hba) */ static bool ufshcd_abort_all (struct ufs_hba *hba) { -int tag, ret; +int tag, ret =0 ; -if (is_mcq_enabled (hba)) { -struct ufshcd_lrb *lrbp; -int tag; +blk_mq_tagset_busy_iter (&hba->host->tag_set, ufshcd_abort_one, &ret); +if (ret) + goto out; -for (tag =0 ; tag < hba->nutrs; tag++) { - lrbp = &hba->lrb[tag]; -if (!ufshcd_cmd_inflight (lrbp->cmd)) -continue ; - ret =ufshcd_try_to_abort_task (hba, tag); - dev_err(hba->dev, "Aborting tag %d / CDB %#02x %s\n", tag, - hba->lrb[tag].cmd ? hba->lrb[tag].cmd-Quoted 1 line
cmnd[0] : -1,
drivers/ufs/core/ufshcd.c +0
-7- ret ? "failed" : "succeeded"); -if (ret) - goto out; - } - }else { -/* Clear pending transfer requests */ - for_each_set_bit(tag, &hba->outstanding_reqs, hba-Quoted 1 line
nutrs) {
drivers/ufs/core/ufshcd.c +0
-2- ret =ufshcd_try_to_abort_task (hba, tag); - dev_err(hba->dev, "Aborting tag %d / CDB %#02x%s\n", tag,
drivers/ufs/core/ufshcd.c +0
-1- hba->lrb[tag].cmd ? hba->lrb[tag].cmd-Quoted 1 line
cmnd[0] : -1,
drivers/ufs/core/ufshcd.c static bool ufshcd_is_pwr_mode_restore_needed(struct ufs_hba *hba) · line 6422
Quoted 8 lines
drivers/ufs/core/ufshcd.c +0
-5- ret ? "failed" : "succeeded"); -if (ret) - goto out; - } - }/* Clear pending task management requests */ for_each_set_bit (tag, &hba->outstanding_tasks, hba->nutmrs) { ret =ufshcd_clear_tm_cmd (hba, tag);Hi Bart,
Quoted 5 lines
Previous
ufshcd_try_to_abort_taskretrun fail will break tag iterate and return true to tell caller need reset.
But this patch only return last tagufshcd_try_to_abort_taskreturn value, if some tag abort fail and last tag abort success, will not retrun true to tell caller need reset, am I right?
Hi Peter,
blk_mq_tagset_busy_iter() keeps iterating as long as the callback function that has been passed as the second argument returns true. ufshcd_abort_one() returns false if ufshcd_try_to_abort_task() fails.
The behavior that a host reset is triggered if ufshcd_try_to_abort_task() fails has been preserved.
Bart.
Bart Van Assche
reviewerPATCH v2 10/12 scsi: ufs: Remove a member variable
In reply to Bart Van AsscheRemove the 'response' member variable because no code reads its value. Additionally, move the ufs_query_req and ufs_query_res data structure definitions into include/ufs/ufshcd.h because these data structures are related to the UFS host controller driver.
--- drivers/ufs/core/ufshcd.c | 6 +----- include/ufs/ufs.h | 20 -------------------- include/ufs/ufshcd.h | 19 +++++++++++++++++++ 3 files changed, 20 insertions(+), 25 deletions(-)
drivers/ufs/core/ufshcd.c +1 -5
@@ -3014,12 +3014,8 @@ static int ufshcd_clear_cmd(struct ufs_hba *hba, u32 task_tag)static int ufshcd_check_query_response (struct ufs_hba *hba,struct ufshcd_lrb *lrbp) { -struct ufs_query_res *query_res = &hba->dev_cmd.query.response; - -/* Get the UPIU response */ - query_res->response =ufshcd_get_rsp_upiu_result (lrbp->ucd_rsp_ptr) >> +return ufshcd_get_rsp_upiu_result (lrbp->ucd_rsp_ptr) >>UPIU_RSP_CODE_OFFSET ; -return query_res->response; }/**
include/ufs/ufs.h +0 -20
@@ -537,26 +537,6 @@ struct utp_upiu_rsp { }; }; -/** -* struct ufs_query_req - parameters for building a query request -* @query_func: UPIU header query function -* @upiu_req: the query request data -*/ -struct ufs_query_req { -u8 query_func; -struct utp_upiu_query upiu_req; -}; - -/** -* struct ufs_query_resp - UPIU QUERY -* @response: device response code -* @upiu_res: query response data -*/ -struct ufs_query_res { -u8 response; -struct utp_upiu_query upiu_res; -}; -/* * VCCQ & VCCQ2 current requirement when UFS device is in sleep state * and link is in Hibern8 state.
include/ufs/ufshcd.h +19 -0
@@ -202,6 +202,25 @@ struct ufshcd_lrb {bool req_abort_skip; }; +/** +* struct ufs_query_req - parameters for building a query request +* @query_func: UPIU header query function +* @upiu_req: the query request data +*/ +struct ufs_query_req { +u8 query_func; +struct utp_upiu_query upiu_req; +}; + +/** +* struct ufs_query_resp - UPIU QUERY +* @response: device response code +* @upiu_res: query response data +*/ +struct ufs_query_res { +struct utp_upiu_query upiu_res; +}; +/** * struct ufs_query - holds relevant data structures for query request * @request: request upiu and function
Bart Van Assche
reviewerPATCH v2 11/12 scsi: ufs: Simplify transfer request header initialization
In reply to Bart Van AsscheMake the code that initializes UTP transfer request headers easier to read by using bitfields instead of __le32 where appropriate.
--- drivers/ufs/core/ufs-mcq.c | 7 +-- drivers/ufs/core/ufshcd-crypto.h | 20 ++++----- drivers/ufs/core/ufshcd.c | 77 ++++++++++++++++++++++---------- include/ufs/ufs.h | 3 -- include/ufs/ufshci.h | 50 ++++++++++++++------- 5 files changed, 99 insertions(+), 58 deletions(-)
drivers/ufs/core/ufs-mcq.c +1 -6
@@ -558,12 +558,7 @@ int ufshcd_mcq_sq_cleanup(struct ufs_hba *hba, int task_tag)*/ static void ufshcd_mcq_nullify_sqe (struct utp_transfer_req_desc *utrd) { -u32 dword_0; - - dword_0 =le32_to_cpu (utrd->header.dword_0); - dword_0 &= ~UPIU_COMMAND_TYPE_MASK ; - dword_0 |=FIELD_PREP (UPIU_COMMAND_TYPE_MASK ,0xF ); - utrd->header.dword_0 =cpu_to_le32 (dword_0); + utrd->header.command_type =0xf ; }/**
drivers/ufs/core/ufshcd-crypto.h +10 -10
@@ -26,15 +26,15 @@ static inline void ufshcd_prepare_lrbp_crypto(struct request *rq, }static inline void -ufshcd_prepare_req_desc_hdr_crypto (struct ufshcd_lrb *lrbp,u32 *dword_0, -u32 *dword_1,u32 *dword_3) +ufshcd_prepare_req_desc_hdr_crypto (struct ufshcd_lrb *lrbp, +struct request_desc_header *h) { -if (lrbp->crypto_key_slot >=0 ) { - *dword_0 |=UTP_REQ_DESC_CRYPTO_ENABLE_CMD ; - *dword_0 |= lrbp->crypto_key_slot; - *dword_1 =lower_32_bits (lrbp->data_unit_num); - *dword_3 =upper_32_bits (lrbp->data_unit_num); - } +if (lrbp->crypto_key_slot <0 ) +return ; + h->enable_crypto =1 ; + h->cci = lrbp->crypto_key_slot; + h->dunl =cpu_to_le32 (lower_32_bits (lrbp->data_unit_num)); + h->dunu =cpu_to_le32 (upper_32_bits (lrbp->data_unit_num)); }bool ufshcd_crypto_enable (struct ufs_hba *hba);
@@ -51,8 +51,8 @@ static inline void ufshcd_prepare_lrbp_crypto(struct request *rq, struct ufshcd_lrb *lrbp) { }static inline void -ufshcd_prepare_req_desc_hdr_crypto (struct ufshcd_lrb *lrbp,u32 *dword_0, -u32 *dword_1,u32 *dword_3) { } +ufshcd_prepare_req_desc_hdr_crypto (struct ufshcd_lrb *lrbp, +struct request_desc_header *h) { }static inline bool ufshcd_crypto_enable (struct ufs_hba *hba) {
drivers/ufs/core/ufshcd.c +54 -23
146 lines not on this page · raw message
include/ufs/ufs.h +0 -3
@@ -473,9 +473,6 @@ enum { UPIU_COMMAND_SET_TYPE_QUERY = 0x2, }; -/* UTP Transfer Request Command Offset */ -#define UPIU_COMMAND_TYPE_OFFSET 28 -/* Offset of the response code in the UPIU header */ #define UPIU_RSP_CODE_OFFSET 8
include/ufs/ufshci.h +34 -16
73 lines not on this page · raw message
RE: [PATCH v2 11/12] scsi: ufs: Simplify transfer request header initialization
Quoted 10 lines
Make the code that initializes UTP transfer request headers easier to read by using bitfields instead of
__le32where appropriate.Cc Bao D. Nguyen <[email protected]>Cc Eric Biggers <[email protected]>Cc Avri Altman <[email protected]>Cc Bean Huo <[email protected]>Cc Adrian Hunter <[email protected]>Signed-off-by Bart Van Assche <[email protected]>
Re: [PATCH v2 11/12] scsi: ufs: Simplify transfer request header initialization
In reply to Bart Van AsscheHi Bart,
Quoted 35 lines · Bart Van Assche
Make the code that initializes UTP transfer request headers easier to read by using bitfields instead of
__le32where appropriate.Cc Bao D. Nguyen <[email protected]>Cc Eric Biggers <[email protected]>Cc Avri Altman <[email protected]>Cc Bean Huo <[email protected]>Cc Adrian Hunter <[email protected]>Signed-off-by Bart Van Assche <[email protected]>---
[...]drivers/ufs/core/ufshcd.c +23
-0+static void ufshcd_check_header_layout (void ) +{ +BUILD_BUG_ON (((u8 *)&(struct request_desc_header ){ + .cci =3 })[0 ] !=3 ); + +BUILD_BUG_ON (((u8 *)&(struct request_desc_header ){ + .ehs_length =2 })[1 ] !=2 ); + +BUILD_BUG_ON (((u8 *)&(struct request_desc_header ){ + .enable_crypto =1 })[2 ] + !=0x80 ); + +BUILD_BUG_ON ((((u8 *)&(struct request_desc_header ){ + .command_type =5 , + .data_direction =3 , + .interrupt =1 , + })[3 ]) != ((5 <<4 ) | (3 <<1 ) |1 )); + +BUILD_BUG_ON (((__le32 *)&(struct request_desc_header ){ + .dunl =cpu_to_le32 (0xdeadbeef )})[1 ] != +cpu_to_le32 (0xdeadbeef )); + + BUILD_BUG_ON(((u8 *)&(struct request_desc_header){
drivers/ufs/core/ufshcd.c static const struct dev_pm_ops ufshcd_wl_pm_ops = { · line 10598
Quoted 10 lines
drivers/ufs/core/ufshcd.c +10
-0+ .ocs = 4})[8] != 4); + +BUILD_BUG_ON (((u8 *)&(struct request_desc_header ){ + .cds =5 })[9 ] !=5 ); + +BUILD_BUG_ON (((__le32 *)&(struct request_desc_header ){ + .dunu =cpu_to_le32 (0xbadcafe )})[3 ] != +cpu_to_le32 (0xbadcafe )); +} +
While building next-20230801 for ARM64 architecture,
this patch is giving compilation error
In function ‘ufshcd_check_header_layout’,
inlined from ‘ufshcd_core_init’ at drivers/ufs/core/ufshcd.c:10629:2:././include/linux/compiler_types.h:397:38: error: call to ‘__compiletime_assert_554’ declared with attribute error: BUILD_BUG_ON failed: ((u8 *)&(struct request_desc_header){ .enable_crypto = 1})[2] != 0x80 397 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
compiler information
tar -Jxvf gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz
Build steps
make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- Image
Quoted 1 line
[...]
Bart Van Assche
reviewerRe: [PATCH v2 11/12] scsi: ufs: Simplify transfer request header initialization
Quoted 11 lines · Udit
While building next-20230801 for ARM64 architecture,
this patch is giving compilation error
In function ‘ufshcd_check_header_layout’,
inlined from ‘ufshcd_core_init’ atdrivers/ufs/core/ufshcd.c:10629:2:././include/linux/compiler_types.h:397:38: error: call to ‘__compiletime_assert_554’ declared with attribute error:BUILD_BUG_ONfailed: ((u8 *)&(struct request_desc_header){ .enable_crypto = 1})[2] !=0x80
397 | _compiletime_assert(condition, msg,__compiletime_assert_,__COUNTER__)
Quoted 3 lines
compiler information
Does this patch help: https://lore.kernel.org/linux-scsi/[email protected]/?
Thanks,
Bart.
RE: [PATCH v2 11/12] scsi: ufs: Simplify transfer request header initialization
Thanks Bart
Quoted 19 lines · Udit
Quoted 17 lines
While building next-20230801 for ARM64 architecture,
this patch is giving compilation error
In function ‘ufshcd_check_header_layout’,
inlined from ‘ufshcd_core_init’ atdrivers/ufs/core/ufshcd.c:10629:2:././include/linux/compiler_types.h:397:38: error: call to ‘__compiletime_assert_554’ declared with attribute error:BUILD_BUG_ON
failed: ((u8 *)&(struct request_desc_header){ .enable_crypto = 1})[2] !=0x80
397 | _compiletime_assert(condition, msg,__compiletime_assert_,__COUNTER__)compiler information
Quoted 7 lines
Quoted 3 lines
wget
https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/bi
nrel/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xzDoes this patch help:
https://lore.kernel.org/linux-scsi/20230801232204.1481902-1-
[email protected]/?
Yes , build works for me with this patch. You just skipped based upon compiler version but what about checks you want to do in this function.
Quoted 3 lines
Thanks,
Bart.
Bart Van Assche
reviewerRe: [PATCH v2 11/12] scsi: ufs: Simplify transfer request header initialization
Quoted 7 lines · Udit
Quoted 3 lines
Does this patch help:
https://lore.kernel.org/linux-scsi/20230801232204.1481902-1-
[email protected]/?Yes , build works for me with this patch. You just skipped based upon compiler version but what about checks you want to do in this function.
These checks verify that the layout of the structures matches the layout from the UFS standard. I want these checks to performed at compile time. I'm not sure how to let gcc 9 or older perform these checks at compile time.
Thanks,
Bart.
Bart Van Assche
reviewerPATCH v2 12/12 scsi: ufs: Simplify response header parsing
In reply to Bart Van AsscheMake the code that parses UTP transfer request headers easier to read by using u8 instead of __be32 where appropriate.
--- drivers/ufs/core/ufshcd.c | 153 ++++++++++++------------------- include/uapi/scsi/scsi_bsg_ufs.h | 52 ++++++++++- include/ufs/ufs.h | 18 ++-- 3 files changed, 115 insertions(+), 108 deletions(-)
drivers/ufs/core/ufshcd.c +60 -93
@@ -882,35 +882,7 @@ static inline u32 ufshcd_get_dme_attr_val(struct ufs_hba *hba)static inline enum upiu_response_transaction ufshcd_get_req_rsp (struct utp_upiu_rsp *ucd_rsp_ptr) { -return be32_to_cpu (ucd_rsp_ptr->header.dword_0) >>24 ; -} - -/** -* ufshcd_get_rsp_upiu_result - Get the result from response UPIU -* @ucd_rsp_ptr: pointer to response UPIU -* -* This function gets the response status and scsi_status from response UPIU -* -* Return: the response result code. -*/ -static inline int -ufshcd_get_rsp_upiu_result (struct utp_upiu_rsp *ucd_rsp_ptr) -{ -return be32_to_cpu (ucd_rsp_ptr->header.dword_1) &MASK_RSP_UPIU_RESULT ; -} - -/* -* ufshcd_get_rsp_upiu_data_seg_len - Get the data segment length -* from response UPIU -* @ucd_rsp_ptr: pointer to response UPIU -* -* Return: the data segment length. -*/ -static inline unsigned int -ufshcd_get_rsp_upiu_data_seg_len (struct utp_upiu_rsp *ucd_rsp_ptr) -{ -return be32_to_cpu (ucd_rsp_ptr->header.dword_2) & -MASK_RSP_UPIU_DATA_SEG_LEN ; +return ucd_rsp_ptr->header.transaction_code; }/**
@@ -924,8 +896,7 @@ ufshcd_get_rsp_upiu_data_seg_len(struct utp_upiu_rsp *ucd_rsp_ptr)*/ static inline bool ufshcd_is_exception_event (struct utp_upiu_rsp *ucd_rsp_ptr) { -return be32_to_cpu (ucd_rsp_ptr->header.dword_2) & -MASK_RSP_EXCEPTION_EVENT ; +return ucd_rsp_ptr->header.device_information &1 ; }/**
@@ -2224,10 +2195,11 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag,static inline void ufshcd_copy_sense_data (struct ufshcd_lrb *lrbp) {u8 *const sense_buffer = lrbp->cmd->sense_buffer; +u16 resp_len;int len; -if (sense_buffer && -ufshcd_get_rsp_upiu_data_seg_len (lrbp->ucd_rsp_ptr)) { + resp_len =be16_to_cpu (lrbp->ucd_rsp_ptr->header.data_segment_length); +if (sense_buffer && resp_len) {int len_to_copy; len =be16_to_cpu (lrbp->ucd_rsp_ptr->sr.sense_data_len);
@@ -2262,8 +2234,8 @@ int ufshcd_copy_query_response(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)u16 buf_len;/* data segment length */ - resp_len =be32_to_cpu (lrbp->ucd_rsp_ptr->header.dword_2) & -MASK_QUERY_DATA_SEG_LEN ; + resp_len =be16_to_cpu (lrbp->ucd_rsp_ptr->header + .data_segment_length); buf_len =be16_to_cpu ( hba->dev_cmd.query.request.upiu_req.length);if (likely (buf_len >= resp_len)) {
@@ -2636,15 +2608,13 @@ void ufshcd_prepare_utp_scsi_cmd_upiu(struct ufshcd_lrb *lrbp, u8 upiu_flags)struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr;unsigned short cdb_len; -/* command descriptor fields */ - ucd_req_ptr->header.dword_0 =upiu_header_dword ( -UPIU_TRANSACTION_COMMAND , upiu_flags, - lrbp->lun, lrbp->task_tag); - ucd_req_ptr->header.dword_1 =upiu_header_dword ( -UPIU_COMMAND_SET_TYPE_SCSI ,0 ,0 ,0 ); - -/* Total EHS length and Data segment length will be zero */ - ucd_req_ptr->header.dword_2 =0 ; + ucd_req_ptr->header = (struct utp_upiu_header ){ + .transaction_code =UPIU_TRANSACTION_COMMAND , + .flags = upiu_flags, + .lun = lrbp->lun, + .task_tag = lrbp->task_tag, + .command_set_type =UPIU_COMMAND_SET_TYPE_SCSI , + }; ucd_req_ptr->sc.exp_data_transfer_len =cpu_to_be32 (cmd->sdb.length);
@@ -2669,18 +2639,19 @@ static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba,u16 len =be16_to_cpu (query->request.upiu_req.length);/* Query request header */ - ucd_req_ptr->header.dword_0 =upiu_header_dword ( -UPIU_TRANSACTION_QUERY_REQ , upiu_flags, - lrbp->lun, lrbp->task_tag); - ucd_req_ptr->header.dword_1 =upiu_header_dword ( -0 , query->request.query_func,0 ,0 ); - -/* Data segment length only need for WRITE_DESC */ -if (query->request.upiu_req.opcode ==UPIU_QUERY_OPCODE_WRITE_DESC ) - ucd_req_ptr->header.dword_2 = -upiu_header_dword (0 ,0 , len >>8 , (u8 )len); -else - ucd_req_ptr->header.dword_2 =0 ; + ucd_req_ptr->header = (struct utp_upiu_header ){ + .transaction_code =UPIU_TRANSACTION_QUERY_REQ , + .flags = upiu_flags, + .lun = lrbp->lun, + .task_tag = lrbp->task_tag, + .query_function = query->request.query_func, +/* Data segment length only need for WRITE_DESC */ + .data_segment_length = + query->request.upiu_req.opcode == +UPIU_QUERY_OPCODE_WRITE_DESC ? +cpu_to_be16 (len) : +0 , + };/* Copy the Query Request buffer as is */ memcpy(&ucd_req_ptr->qr, &query->request.upiu_req,
@@ -2699,12 +2670,10 @@ static inline void ufshcd_prepare_utp_nop_upiu(struct ufshcd_lrb *lrbp)memset (ucd_req_ptr,0 ,sizeof (struct utp_upiu_req )); -/* command descriptor fields */ - ucd_req_ptr->header.dword_0 =upiu_header_dword ( -UPIU_TRANSACTION_NOP_OUT ,0 ,0 , lrbp->task_tag); -/* clear rest of the fields of basic header */ - ucd_req_ptr->header.dword_1 =0 ; - ucd_req_ptr->header.dword_2 =0 ; + ucd_req_ptr->header = (struct utp_upiu_header ){ + .transaction_code =UPIU_TRANSACTION_NOP_OUT , + .task_tag = lrbp->task_tag, + };memset (lrbp->ucd_rsp_ptr,0 ,sizeof (struct utp_upiu_rsp )); }
@@ -3008,13 +2977,6 @@ static int ufshcd_clear_cmd(struct ufs_hba *hba, u32 task_tag) mask, ~mask, 1000, 1000); } -static int -ufshcd_check_query_response (struct ufs_hba *hba,struct ufshcd_lrb *lrbp) -{ -return ufshcd_get_rsp_upiu_result (lrbp->ucd_rsp_ptr) >> -UPIU_RSP_CODE_OFFSET ; -} -/** * ufshcd_dev_cmd_completion() - handles device management command responses * @hba: per adapter instance
@@ -3039,11 +3001,13 @@ ufshcd_dev_cmd_completion(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) __func__, resp); }break ; -case UPIU_TRANSACTION_QUERY_RSP : - err =ufshcd_check_query_response (hba, lrbp); -if (!err) +case UPIU_TRANSACTION_QUERY_RSP : { +u8 response = lrbp->ucd_rsp_ptr->header.response; + +if (response ==0 ) err =ufshcd_copy_query_response (hba, lrbp);break ; + }case UPIU_TRANSACTION_REJECT_UPIU :/* TODO: handle Reject UPIU Response */ err = -EPERM ;
@@ -5244,7 +5208,7 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp,u8 upiu_flags;u32 resid; - upiu_flags =be32_to_cpu (lrbp->ucd_rsp_ptr->header.dword_0) >>16 ; + upiu_flags = lrbp->ucd_rsp_ptr->header.flags; resid =be32_to_cpu (lrbp->ucd_rsp_ptr->sr.residual_transfer_count);/* * Test !overflow instead of underflow to support UFS devices that do
@@ -5257,8 +5221,8 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, ocs =ufshcd_get_tr_ocs (lrbp, cqe);if (hba->quirks &UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR ) { -if (be32_to_cpu (lrbp->ucd_rsp_ptr->header.dword_1) & -MASK_RSP_UPIU_RESULT ) +if (lrbp->ucd_rsp_ptr->header.response || + lrbp->ucd_rsp_ptr->header.status) ocs =OCS_SUCCESS ; }
@@ -5267,17 +5231,11 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, hba->ufs_stats.last_hibern8_exit_tstamp =ktime_set (0 ,0 );switch (ufshcd_get_req_rsp (lrbp->ucd_rsp_ptr)) {case UPIU_TRANSACTION_RESPONSE : -/* -* get the response UPIU result to extract -* the SCSI command status -*/ - result =ufshcd_get_rsp_upiu_result (lrbp->ucd_rsp_ptr); -/* * get the result based on SCSI status response * to notify the SCSI midlayer of the command status */ - scsi_status = result &MASK_SCSI_STATUS ; + scsi_status = lrbp->ucd_rsp_ptr->header.status; result =ufshcd_scsi_cmd_status (lrbp, scsi_status);/*
@@ -6967,7 +6925,7 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba,WARN_ONCE (task_tag <0 || task_tag >= hba->nutmrs,"Invalid tag %d\n" , task_tag); hba->tmf_rqs[req->tag] = req; - treq->upiu_req.req_header.dword_0 |=cpu_to_be32 (task_tag); + treq->upiu_req.req_header.task_tag = task_tag;memcpy (hba->utmrdl_base_addr + task_tag, treq,sizeof (*treq));ufshcd_vops_setup_task_mgmt (hba, task_tag, tm_function);
@@ -7034,9 +6992,9 @@ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id, treq.header.ocs =OCS_INVALID_COMMAND_STATUS ;/* Configure task request UPIU */ - treq.upiu_req.req_header.dword_0 =cpu_to_be32 (lun_id <<8 ) | -cpu_to_be32 (UPIU_TRANSACTION_TASK_REQ <<24 ); - treq.upiu_req.req_header.dword_1 =cpu_to_be32 (tm_function <<16 ); + treq.upiu_req.req_header.transaction_code =UPIU_TRANSACTION_TASK_REQ ; + treq.upiu_req.req_header.lun = lun_id; + treq.upiu_req.req_header.tm_function = tm_function;/* * The host shall provide the same value for LUN field in the basic
@@ -7110,7 +7068,7 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, lrbp->command_type =UTP_CMD_TYPE_UFS_STORAGE ;/* update the task tag in the request upiu */ - req_upiu->header.dword_0 |=cpu_to_be32 (tag); + req_upiu->header.task_tag = tag;ufshcd_prepare_req_desc_hdr (lrbp, &upiu_flags,DMA_NONE ,0 );
@@ -7143,8 +7101,8 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba,memcpy (rsp_upiu, lrbp->ucd_rsp_ptr,sizeof (*rsp_upiu));if (desc_buff && desc_op ==UPIU_QUERY_OPCODE_READ_DESC ) {u8 *descp = (u8 *)lrbp->ucd_rsp_ptr +sizeof (*rsp_upiu); -u16 resp_len =be32_to_cpu (lrbp->ucd_rsp_ptr->header.dword_2) & -MASK_QUERY_DATA_SEG_LEN ; +u16 resp_len =be16_to_cpu (lrbp->ucd_rsp_ptr->header + .data_segment_length);if (*buff_len >= resp_len) {memcpy (desc_buff, descp, resp_len);
@@ -7192,7 +7150,7 @@ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba,enum dev_cmd_type cmd_type =DEV_CMD_TYPE_QUERY ;struct utp_task_req_desc treq = { };enum utp_ocs ocs_value; -u8 tm_f =be32_to_cpu (req_upiu->header.dword_1) >>16 &MASK_TM_FUNC ; +u8 tm_f = req_upiu->header.tm_function;switch (msgcode) {case UPIU_TRANSACTION_NOP_OUT :
@@ -7284,7 +7242,9 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *rufshcd_prepare_req_desc_hdr (lrbp, &upiu_flags, dir,2 );/* update the task tag and LUN in the request upiu */ - req_upiu->header.dword_0 |=cpu_to_be32 (upiu_flags <<16 |UFS_UPIU_RPMB_WLUN <<8 | tag); + req_upiu->header.flags = upiu_flags; + req_upiu->header.lun =UFS_UPIU_RPMB_WLUN ; + req_upiu->header.task_tag = tag;/* copy the UPIU(contains CDB) request as it is */ memcpy (lrbp->ucd_req_ptr, req_upiu,sizeof (*lrbp->ucd_req_ptr));
@@ -7306,9 +7266,10 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r/* Just copy the upiu response as it is */ memcpy (rsp_upiu, lrbp->ucd_rsp_ptr,sizeof (*rsp_upiu));/* Get the response UPIU result */ - result =ufshcd_get_rsp_upiu_result (lrbp->ucd_rsp_ptr); + result = (lrbp->ucd_rsp_ptr->header.response <<8 ) | + lrbp->ucd_rsp_ptr->header.status; - ehs_len =be32_to_cpu (lrbp->ucd_rsp_ptr->header.dword_2) >>24 ; + ehs_len = lrbp->ucd_rsp_ptr->header.ehs_length;/* * Since the bLength in EHS indicates the total size of the EHS Header and EHS Data * in 32 Byte units, the value of the bLength Request/Response for Advanced RPMB
@@ -10594,6 +10555,12 @@ static void ufshcd_check_header_layout(void)BUILD_BUG_ON (((__le32 *)&(struct request_desc_header ){ .dunu =cpu_to_le32 (0xbadcafe )})[3 ] !=cpu_to_le32 (0xbadcafe )); + +BUILD_BUG_ON (((u8 *)&(struct utp_upiu_header ){ + .iid =0xf })[4 ] !=0xf0 ); + +BUILD_BUG_ON (((u8 *)&(struct utp_upiu_header ){ + .command_set_type =0xf })[4 ] !=0xf ); }/*
include/uapi/scsi/scsi_bsg_ufs.h +49 -3
66 lines not on this page · raw message
include/ufs/ufs.h +6 -12
@@ -15,6 +15,12 @@#include <linux/types.h> #include <uapi/scsi/scsi_bsg_ufs.h> +/* +* Using static_assert() is not allowed in UAPI header files. Hence the check +* in this header file of the size of struct utp_upiu_header. +*/ +static_assert (sizeof (struct utp_upiu_header ) ==12 ); +#define GENERAL_UPIU_REQUEST_SIZE (sizeof(struct utp_upiu_req))#define QUERY_DESC_MAX_SIZE 255#define QUERY_DESC_MIN_SIZE 2
@@ -23,11 +29,6 @@ (sizeof(struct utp_upiu_header)))#define UFS_SENSE_SIZE 18 -static inline __be32 upiu_header_dword (u8 byte3,u8 byte2,u8 byte1,u8 byte0) -{ -return cpu_to_be32 (byte3 <<24 | byte2 <<16 | byte1 <<8 | byte0); -} -/* * UFS device may have standard LUs and LUN id could be from 0x00 to * 0x7F. Standard LUs use "Peripheral Device Addressing Format".
@@ -477,14 +478,7 @@ enum {#define UPIU_RSP_CODE_OFFSET 8enum { -MASK_SCSI_STATUS =0xFF , -MASK_TASK_RESPONSE =0xFF00 , -MASK_RSP_UPIU_RESULT =0xFFFF , -MASK_QUERY_DATA_SEG_LEN =0xFFFF , -MASK_RSP_UPIU_DATA_SEG_LEN =0xFFFF , -MASK_RSP_EXCEPTION_EVENT =0x10000 ,MASK_TM_SERVICE_RESP =0xFF , -MASK_TM_FUNC =0xFF , };/* Task management service response */
RE: [PATCH v2 12/12] scsi: ufs: Simplify response header parsing
Quoted 5 lines
Make the code that parses UTP transfer request headers easier to read by using u8 instead of
__be32where appropriate.Signed-off-by Bart Van Assche <[email protected]>
Martin K. Petersen
AppliedBart,
Quoted 7 lines
This patch includes the following changes, none of which should change the functionality of the UFS host controller driver:
- Improve the kernel-doc headers further.
- Fix multiple W=2 compiler warnings.
- Simplifyufshcd_abort_all().
- Simplify the code for creating and parsing UFS Transport Protocol (UTP) headers.
Applied to 6.6/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedQuoted 9 lines · Bart Van Assche
This patch includes the following changes, none of which should change the functionality of the UFS host controller driver:
- Improve the kernel-doc headers further.
- Fix multiple W=2 compiler warnings.
- Simplifyufshcd_abort_all().
- Simplify the code for creating and parsing UFS Transport Protocol (UTP) headers.[...]
Applied to 6.6/scsi-queue, thanks!
[01/12] scsi: ufs: Follow the kernel-doc syntax for documenting return values
https://git.kernel.org/mkp/scsi/c/3a17fefe0f19 [02/12] scsi: ufs: Document all return values https://git.kernel.org/mkp/scsi/c/fd4bffb54dc0 [03/12] scsi: ufs: Fix kernel-doc headers https://git.kernel.org/mkp/scsi/c/8d8af294ce03 [04/12] scsi: ufs: Rename a function argument https://git.kernel.org/mkp/scsi/c/f08191520614 [05/12] scsi: ufs: Minimize #include directives https://git.kernel.org/mkp/scsi/c/cce9fd602ca0 [06/12] scsi: ufs: Simplify zero-initialization https://git.kernel.org/mkp/scsi/c/f99533bd7e3d [07/12] scsi: ufs: Improve type safety https://git.kernel.org/mkp/scsi/c/08108d31129a [08/12] scsi: ufs: Remove a local variable from ufshcd_abort_all() https://git.kernel.org/mkp/scsi/c/e8b0234f8458 [09/12] scsi: ufs: Simplify ufshcd_abort_all() https://git.kernel.org/mkp/scsi/c/f9c028e7415a [10/12] scsi: ufs: Remove a member variable https://git.kernel.org/mkp/scsi/c/e2566e0b7937 [11/12] scsi: ufs: Simplify transfer request header initialization https://git.kernel.org/mkp/scsi/c/67a2a8973832 [12/12] scsi: ufs: Simplify response header parsing https://git.kernel.org/mkp/scsi/c/617bfaa8dd50
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering