diff mbox series

[5/6] bus: mhi: check for RDDM cookie set by device to indicate readiness

Message ID 20240718061344.575653-6-quic_gokulsri@quicinc.com (mailing list archive)
State Not Applicable
Headers show
Series add improvements to mhi driver | expand

Commit Message

Gokul Sriram Palanisamy July 18, 2024, 6:13 a.m. UTC
From: Rajkumar Ayyasamy <quic_arajkuma@quicinc.com>

If the device is unable to send the mission mode execution
environment change event but has already entered mission mode
with the ability to allow ramdump collection, it can set a unique
cookie pattern to indicate the availability of ramdumps. Allow
the controller to query for this unique pattern upon any bootup
failure or timeout.

Signed-off-by: Rajkumar Ayyasamy <quic_arajkuma@quicinc.com>
Signed-off-by: Gokul Sriram Palanisamy <quic_gokulsri@quicinc.com>
---
 drivers/bus/mhi/host/main.c | 44 +++++++++++++++++++++++++++++++++++++
 include/linux/mhi.h         |  8 +++++++
 2 files changed, 52 insertions(+)

Comments

Jeffrey Hugo July 18, 2024, 4:25 p.m. UTC | #1
On 7/18/2024 12:13 AM, Gokul Sriram Palanisamy wrote:
> diff --git a/include/linux/mhi.h b/include/linux/mhi.h
> index c0c9bfc28e4a..2f90de8616f3 100644
> --- a/include/linux/mhi.h
> +++ b/include/linux/mhi.h
> @@ -839,4 +839,12 @@ int mhi_get_channel_doorbell_offset(struct mhi_controller *mhi_cntrl, u32 *chdb_
>    * @mhi_cntrl: MHI controller
>    */
>   void mhi_debug_reg_dump(struct mhi_controller *mhi_cntrl);
> +
> +/**
> + * mhi_scan_rddm_cookie - Look for supplied cookie value in the BHI debug
> + * registers set by device to indicate rddm readiness for debugging purposes.
> + * @mhi_cntrl: MHI controller
> + * @cookie: cookie/pattern value to match
> + */
> +bool mhi_scan_rddm_cookie(struct mhi_controller *mhi_cntrl, u32 cookie);
>   #endif /* _MHI_H_ */

NACK.  This is not used.
Gokul Sriram Palanisamy July 28, 2024, 1:41 p.m. UTC | #2
On 7/18/2024 9:55 PM, Jeffrey Hugo wrote:
> On 7/18/2024 12:13 AM, Gokul Sriram Palanisamy wrote:
>> diff --git a/include/linux/mhi.h b/include/linux/mhi.h
>> index c0c9bfc28e4a..2f90de8616f3 100644
>> --- a/include/linux/mhi.h
>> +++ b/include/linux/mhi.h
>> @@ -839,4 +839,12 @@ int mhi_get_channel_doorbell_offset(struct 
>> mhi_controller *mhi_cntrl, u32 *chdb_
>>    * @mhi_cntrl: MHI controller
>>    */
>>   void mhi_debug_reg_dump(struct mhi_controller *mhi_cntrl);
>> +
>> +/**
>> + * mhi_scan_rddm_cookie - Look for supplied cookie value in the BHI 
>> debug
>> + * registers set by device to indicate rddm readiness for debugging 
>> purposes.
>> + * @mhi_cntrl: MHI controller
>> + * @cookie: cookie/pattern value to match
>> + */
>> +bool mhi_scan_rddm_cookie(struct mhi_controller *mhi_cntrl, u32 
>> cookie);
>>   #endif /* _MHI_H_ */
>
> NACK.  This is not used.

mhi_debug_reg_dump - this is added in 3 places, mhi_fw_load_bhi( ), 
mhi_fw_load_bhie( ) and mhi_download_rddm_image( ) to print error codes 
on failure scenarios.

What do you mean by not used?

Regards,

Gokul
Jeffrey Hugo July 28, 2024, 8:27 p.m. UTC | #3
On 7/28/2024 7:41 AM, Gokul Sriram P wrote:
> 
> On 7/18/2024 9:55 PM, Jeffrey Hugo wrote:
>> On 7/18/2024 12:13 AM, Gokul Sriram Palanisamy wrote:
>>> diff --git a/include/linux/mhi.h b/include/linux/mhi.h
>>> index c0c9bfc28e4a..2f90de8616f3 100644
>>> --- a/include/linux/mhi.h
>>> +++ b/include/linux/mhi.h
>>> @@ -839,4 +839,12 @@ int mhi_get_channel_doorbell_offset(struct 
>>> mhi_controller *mhi_cntrl, u32 *chdb_
>>>    * @mhi_cntrl: MHI controller
>>>    */
>>>   void mhi_debug_reg_dump(struct mhi_controller *mhi_cntrl);
>>> +
>>> +/**
>>> + * mhi_scan_rddm_cookie - Look for supplied cookie value in the BHI 
>>> debug
>>> + * registers set by device to indicate rddm readiness for debugging 
>>> purposes.
>>> + * @mhi_cntrl: MHI controller
>>> + * @cookie: cookie/pattern value to match
>>> + */
>>> +bool mhi_scan_rddm_cookie(struct mhi_controller *mhi_cntrl, u32 
>>> cookie);
>>>   #endif /* _MHI_H_ */
>>
>> NACK.  This is not used.
> 
> mhi_debug_reg_dump - this is added in 3 places, mhi_fw_load_bhi( ), 
> mhi_fw_load_bhie( ) and mhi_download_rddm_image( ) to print error codes 
> on failure scenarios.
> 
> What do you mean by not used?

You add an API to other drivers, mhi_scan_rddm_cookie(), but no code 
ever calls it.  This entire patch is useless as all it does is add dead 
code.
diff mbox series

Patch

diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c
index 26baa04badf4..de804a701b85 100644
--- a/drivers/bus/mhi/host/main.c
+++ b/drivers/bus/mhi/host/main.c
@@ -1772,3 +1772,47 @@  void mhi_debug_reg_dump(struct mhi_controller *mhi_cntrl)
 	}
 }
 EXPORT_SYMBOL_GPL(mhi_debug_reg_dump);
+
+bool mhi_scan_rddm_cookie(struct mhi_controller *mhi_cntrl, u32 cookie)
+{
+	struct device *dev = &mhi_cntrl->mhi_dev->dev;
+	int ret;
+	int i;
+	u32 val;
+	bool result = false;
+	struct {
+		char *name;
+		u32 offset;
+	} error_reg[] = {
+		{ "ERROR_DBG1", BHI_ERRDBG1 },
+		{ "ERROR_DBG2", BHI_ERRDBG2 },
+		{ "ERROR_DBG3", BHI_ERRDBG3 },
+		{ NULL },
+	};
+
+	if (!mhi_cntrl->rddm_size || !cookie)
+		return false;
+
+	dev_dbg(dev, "Checking BHI debug register for 0x%x\n", cookie);
+
+	if (!MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state))
+		return false;
+
+	/* look for an RDDM cookie match in any of the error debug registers */
+	for (i = 0; error_reg[i].name; i++) {
+		ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi,
+				   error_reg[i].offset, &val);
+		if (ret)
+			break;
+		dev_dbg(dev, "reg:%s value:0x%x\n", error_reg[i].name, val);
+
+		if (!(val ^ cookie)) {
+			dev_err(dev, "RDDM cookie found in %s\n",
+				error_reg[i].name);
+			return true;
+		}
+	}
+	dev_dbg(dev, "RDDM cookie not found\n");
+	return result;
+}
+EXPORT_SYMBOL_GPL(mhi_scan_rddm_cookie);
diff --git a/include/linux/mhi.h b/include/linux/mhi.h
index c0c9bfc28e4a..2f90de8616f3 100644
--- a/include/linux/mhi.h
+++ b/include/linux/mhi.h
@@ -839,4 +839,12 @@  int mhi_get_channel_doorbell_offset(struct mhi_controller *mhi_cntrl, u32 *chdb_
  * @mhi_cntrl: MHI controller
  */
 void mhi_debug_reg_dump(struct mhi_controller *mhi_cntrl);
+
+/**
+ * mhi_scan_rddm_cookie - Look for supplied cookie value in the BHI debug
+ * registers set by device to indicate rddm readiness for debugging purposes.
+ * @mhi_cntrl: MHI controller
+ * @cookie: cookie/pattern value to match
+ */
+bool mhi_scan_rddm_cookie(struct mhi_controller *mhi_cntrl, u32 cookie);
 #endif /* _MHI_H_ */