# Debug

This section describes the different errors from the storage driver and provides guidance to resolve such errors.

## Debug UFS device issue

The kernel log records <cite>cmd pending in the device</cite> or <cite>no response from device</cite> when a UFS device issue occurs. For more information, reach out to the UFS vendor.

Example 1:

> 
> 
> [ 82.928056][01-01 00:02:05] ufshcd-qcom 1d84000.ufshc: ufshcd\_abort: Device abort task at tag 1
> [ 82.928059][01-01 00:02:05] sd 0:0:0:4: [sde] tag#1 CDB: Read(10) 28 00 00 00 44 49 00 00 20 00
> [ 82.936477][01-01 00:02:05] ufshcd-qcom 1d84000.ufshc: UPIU[1] - issue time 50955434 us
> [ 82.936479][01-01 00:02:05] ufshcd-qcom 1d84000.ufshc: UPIU[1] - complete time 0 us
> [ 82.936567][01-01 00:02:05] ufshcd-qcom 1d84000.ufshc: ufshcd\_abort: cmd pending in the device. tag = 1

Example 2 :

> 
> 
> [ 1036.008147] [1230\_22:00:49]@0 ufshcd-qcom 1d84000.ufshc: ufshcd\_abort: Device abort task at tag 2
> [ 1036.008510] [1230\_22:00:49]@0 sd 0:0:0:0: tag#2 CDB: opcode=0xfa (vendor) fa 02 01 48 07 79 ae 03 50 00
> [ 1036.120287] [1230\_22:00:50]@1 ufshcd-qcom 1d84000.ufshc: ufshcd\_abort: no response from device. tag = 2, err -110.

### Physical adapter or data link error

In the kernel log, `pa_err_cnt_total` and `dl_err_cnt_total` with non-zero values indicate a physical adapter or data link (PA/DL) error issue.
This issue occurs when the signal quality between the AP and the UFS device is not strong, and requires modification in all three components, such as hardware, software, and the UFS vendor to resolve.

To view the PA/DL error count, use the `debugfs` path `/sys/kernel/debug/ufshcd/1d84000.ufs/stats`.

Mount `debugfs` using the following command. This command ensures that the `debugfs` file system remains accessible for the debug nodes.

> 
> 
> mount -t debugfs none /sys/kernel/debug
>     Copy to clipboard

Example:

> 
> 
> [31709.438001] ufshcd-qcom 1d84000.ufshc: pa\_err\_cnt\_total=5086, pa\_lane\_0\_err\_cnt=3250, pa\_lane\_1\_err\_cnt=1405, pa\_line\_reset\_err\_cnt=431
> [31709.438008] ufshcd-qcom 1d84000.ufshc: dl\_err\_cnt\_total=4488, dl\_nac\_received\_err\_cnt=289, dl\_tcx\_replay\_timer\_expired\_err\_cnt=258
> [31709.438015] ufshcd-qcom 1d84000.ufshc: dl\_afcx\_request\_timer\_expired\_err\_cnt=0, dl\_fcx\_protection\_timer\_expired\_err\_cnt=0, dl\_crc\_err\_cnt=18

## UFS power consumptions issue

Excess power consumption could be due to active or sleep power states.

### Active state

> 
> 
> Use the following steps to debug UFS high power consumption during active state.
> 
> 
> 1. Check how often the issue occurs. Use the following SSH command to check current clock frequency.
> 
> 
> 
> 
> > 
> > 
> > cat /sys/devices/platform/soc@0/1d84000.ufs/devfreq/1d84000.ufs/cur_freq
> >     Copy to clipboard
> > 
> > 
> > Note
> > 
> > 
> > If the frequency is maximum, skip to Step 3.
> 
> 
> 2. Check whether any UFS-related feature (such as WriteBooster) has been enabled.
> 3. Check whether clock scale is disabled.
> 
> 
> 
> 
> > 
> > 
> > cat /sys/devices/platform/soc@0/1d84000.ufs/clkscale_enable
> >     Copy to clipboard
> 
> 
> 4. Monitor the UFS clocks frequency and UFS rails.
> 
> 
>     The issue may occur due to the initial setting or due to an unexpected devfreq event.

### Sleep state

> 
> 
> During sleep state, if UFS power consumption is high, use the following steps to debug UFS suspend-related issues.
> 
> 1. Check the power management state using sysfs nodes `link_state`, `curr_freq`, and `runtime_status` and PM level (`PM_LVL` 3 has higher power consumption than 5).
> 2. Check the UFS state using sysfs node `dev_pm` to determine whether UFS is in sleep mode.
> 3. Check whether the HPB and write booster features are enabled because they cause high power consumption.
> 4. Check the UFS VCC/VCCQ/VCCQ2 timing from the hardware side if an issue occurs.

## Disable UFS SMMU

System memory management Unit (SMMU) is a memory management unit (MMU) that connects a direct-memory-access-capable (DMA-capable) I/O bus to the physical memory.

Each device is assigned a unique stream ID (SID). The UFS controller SID value is 0x80.

For unhandled SMMU fault from UFS SMMU, disable the UFS SMMU.

arm-smmu 15000000.apps-smmu: Unhandled arm-smmu context fault from 1d84000.ufshc!
    Copy to clipboard

To disable UFS SMMU, modify the `ufshc_mem` node in `<workspace_root_path>/sources/kernel/kernel_platform/kernel/arch/arm64/boot/dts/qcom/sc7280.dtsi` file.

-   qcom,iommu-dma = "fastmap";
    +   qcom,iommu-dma = "bypass";
    Copy to clipboard

## Debug with sysfs or debugfs nodes

To identify the status or update the state, use the <cite>sysfs</cite> and <cite>debugfs</cite> nodes.

Mount <cite>debugfs</cite> to ensure that the <cite>debugfs</cite> file system is accessible for the debug nodes.

> 
> 
> mount -t debugfs none /sys/kernel/debug
>     Copy to clipboard

UFS state information

| Required UFS state information | Command |
| --- | --- |
| Check PA/DL error count | `cat /sys/kernel/debug/ufshcd/1d84000.ufs/stats` |
| Read UFS gating delay, in ms | `cat /sys/devices/platform/soc@0/1d84000.ufs/clkgate_delay_ms` |
| Read UFS clocks current frequency at given point | `cat /sys/devices/platform/soc@0/1d84000.ufs/devfreq/1d84000.ufs/cur_freq` |
| Read UFS I/O scheduler details | `cat /sys/devices/platform/soc@0/1d84000.ufs/devfreq/1d84000.ufs/governor` |
| Read UFS min frequency during clock scale down | `cat /sys/devices/platform/soc@0/1d84000.ufs/devfreq/1d84000.ufs/min_freq` |
| Read UFS max frequency during clock scale up | `cat /sys/devices/platform/soc@0/1d84000.ufs/devfreq/1d84000.ufs/max_freq` |
| Read UFS device state active or sleep | `cat /sys/devices/platform/soc@0/1d84000.ufs/power_info/dev_pm` |
| Read UFS gear information such as HS\_G3, HS\_G4 | `cat /sys/devices/platform/soc@0/1d84000.ufs/power_info/gear` |
| Read UFS number of lanes | `cat /sys/devices/platform/soc@0/1d84000.ufs/power_info/lane` |
| Read UFS link state, ACTIVE or HIBERN8 | `cat /sys/devices/platform/soc@0/1d84000.ufs/power_info/link_state` |
| Read UFS rate information such as Rate A or B | `cat /sys/devices/platform/soc@0/1d84000.ufs/power_info/rate` |
| Read UFS device descriptor information | `ls /sys/devices/platform/soc@0/1d84000.ufs/device_descriptor` |
| Read UFS health descriptor information | `ls /sys/devices/platform/soc@0/1d84000.ufs/health_descriptor` |
| Read UFS runtime status information active or suspended | `cat /sys/devices/platform/soc@0/1d84000.ufs/power/runtime_status` |
| Find and/or modify the SPM/RPM level | `cat /sys/devices/platform/soc@0/1d84000.ufs/rpm_lvl`<br><br><br>`cat /sys/devices/platform/soc@0/1d84000.ufs/spm_lvl` |

SD card state information

| Required SD card state information | Command |
| --- | --- |
| Read SD card error stats information | `cat /sys/kernel/debug/mmc1/err_stats` |
| Read SD card latest error state details | `cat /sys/kernel/debug/mmc1/err_state` |
| Check the current running clock details | `cat /sys/kernel/debug/mmc1/clock` |
| Read the SD card runtime status information (active or suspended) | `cat /sys/devices/platform/soc@0/8804000.mmc/power/runtime_status` |
| Read SD card auto suspend delay time | `cat /sys/devices/platform/soc@0/8804000.mmc/power/autosuspend_delay_ms` |
| Read SD card runtime active time | `cat /sys/devices/platform/soc@0/8804000.mmc/power/runtime_active_time` |
| Read SD card runtime suspend time | `cat /sys/devices/platform/soc@0/8804000.mmc/power/runtime_suspended_time` |
| Read SD card uevent details | `cat /sys/devices/platform/soc@0/8804000.mmc/uevent` |

## Debug NVMe issues

| Required NVME card state information | Command |
| --- | --- |
| View device model name | `cat /sys/class/nvme/nvme0/model` |
| View device serial number | `cat /sys/class/nvme/nvme0/serial` |
| View current firmware version | `cat /sys/class/nvme/nvme0/firmware_rev` |
| View namespace identifier | `cat /sys/class/nvme/nvme0/nvme0n1/nsid` |
| View namespace size | `cat /sys/class/nvme/nvme0/nvme0n1/size` |
| View the offset in bytes to align the start of the NVMe namespace to the optimal I/O boundary | `cat /sys/class/nvme/nvme0/nvme0n1/alignment_offset` |
| View queue depth | `cat /sys/class/nvme/nvme0/queue_count` |

Last Published: Dec 30, 2024

[Previous Topic
Customize](https://docs.qualcomm.com/bundle/publicresource/80-70017-6/topics/customize.md) [Next Topic
References](https://docs.qualcomm.com/bundle/publicresource/80-70017-6/topics/references.md)