Re: [PATCH] platform/x86/amd/pmf: Fix TEE enact command failure after suspend and resume

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Hans,

On 2/12/2024 15:17, Hans de Goede wrote:
> Hi,
> 
> Thank you for your patch.
> 
> On 2/12/24 10:24, Shyam Sundar S K wrote:
>> TEE enact command failures are seen after each suspend/resume cycle;
>> fix this by cancelling the policy builder workqueue before going into
>> suspend and reschedule the workqueue after resume.
>>
>> [  629.516792] ccp 0000:c2:00.2: tee: command 0x5 timed out, disabling PSP
>> [  629.516835] amd-pmf AMDI0102:00: TEE enact cmd failed. err: ffff000e, ret:0
>> [  630.550464] amd-pmf AMDI0102:00: AMD_PMF_REGISTER_RESPONSE:1
>> [  630.550511] amd-pmf AMDI0102:00: AMD_PMF_REGISTER_ARGUMENT:7
>> [  630.550548] amd-pmf AMDI0102:00: AMD_PMF_REGISTER_MESSAGE:16
>>
>> Fixes: ae82cef7d9c5 ("platform/x86/amd/pmf: Add support for PMF-TA interaction")
>> Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@xxxxxxx>
>> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@xxxxxxx>
>> ---
>>  drivers/platform/x86/amd/pmf/core.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c
>> index feaa09f5b35a..be9edb849006 100644
>> --- a/drivers/platform/x86/amd/pmf/core.c
>> +++ b/drivers/platform/x86/amd/pmf/core.c
>> @@ -296,6 +296,9 @@ static int amd_pmf_suspend_handler(struct device *dev)
>>  {
>>  	struct amd_pmf_dev *pdev = dev_get_drvdata(dev);
>>  
>> +	if (!pdev->smart_pc_enabled)
>> +		cancel_delayed_work_sync(&pdev->pb_work);
>> +
> 
> These inverted checks are very confusing and this is all caused by this
> enum which causes the smart_pc_enabled enabled bool to be inverted:
> 
> enum smart_pc_status {
>         PMF_SMART_PC_ENABLED,
>         PMF_SMART_PC_DISABLED,
> };
> 
> Please do a preparation patch for this fix which:
> 
> 1. Drops this broken enum, there is no need to have an enum for what
> is simply a true/false case.
> 
> 2. Replace PMF_SMART_PC_ENABLED with true, PMF_SMART_PC_DISABLED with false,
> so that the contents of pdev->smart_pc_enabled actually matches its name
> instead of being inverted.
> 
> 3. Change the single existing smart_pc_enabled check from:
> 
>         if (!dev->smart_pc_enabled) {
>                 amd_pmf_deinit_smart_pc(dev);
> 
> Which is nonsensical code, if not enabled clean it up? Into
> the much more sensible version of:
> 
>         if (dev->smart_pc_enabled) {
>                 amd_pmf_deinit_smart_pc(dev);
> 
> And then redo this patch on top of this preparation patch,
> also replacing the "if (!dev->smart_pc_enabled)" checks
> in this patch with "if (dev->smart_pc_enabled)" so that
> the code actually makes sense to a casual reader.

Thank you. I agree with your remarks. Have sent out a new revision now.

Thanks,
Shyam

> 
> Regards,
> 
> Hans
> 
> 
> 
> 
> 
> 
>>  	kfree(pdev->buf);
>>  
>>  	return 0;
>> @@ -312,6 +315,9 @@ static int amd_pmf_resume_handler(struct device *dev)
>>  			return ret;
>>  	}
>>  
>> +	if (!pdev->smart_pc_enabled)
>> +		schedule_delayed_work(&pdev->pb_work, msecs_to_jiffies(2000));
>> +
>>  	return 0;
>>  }
>>  
> 




[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux