Re: [PATCH 01/14] memory: ti-emif-sram: Add resume function to recopy sram code

From: Keerthy
Date: Mon Apr 16 2018 - 06:29:52 EST




On Thursday 12 April 2018 10:14 PM, santosh.shilimkar@xxxxxxxxxx wrote:
> On 4/11/18 9:53 PM, Keerthy wrote:
>> From: Dave Gerlach <d-gerlach@xxxxxx>
>>
>> After an RTC+DDR cycle we lose sram context so emif pm functions present
>> in sram are lost. We can check if the first byte of the original
>> code in DDR contains the same first byte as the code in sram, and if
>> they do not match we know we have lost context and must recopy the
>> functions to the previous address to maintain PM functionality.
>>
>> Signed-off-by: Dave Gerlach <d-gerlach@xxxxxx>
>> Signed-off-by: Keerthy <j-keerthy@xxxxxx>
>> ---
>> Â drivers/memory/ti-emif-pm.c | 24 ++++++++++++++++++++++++
>> Â 1 file changed, 24 insertions(+)
>>
>> diff --git a/drivers/memory/ti-emif-pm.c b/drivers/memory/ti-emif-pm.c
>> index 632651f..ec4a62c 100644
>> --- a/drivers/memory/ti-emif-pm.c
>> +++ b/drivers/memory/ti-emif-pm.c
>> @@ -249,6 +249,25 @@ int ti_emif_get_mem_type(void)
>> Â };
>> Â MODULE_DEVICE_TABLE(of, ti_emif_of_match);
>> Â +#ifdef CONFIG_PM_SLEEP
>> +static int ti_emif_resume(struct device *dev)
>> +{
>> +ÂÂÂ unsigned long tmp =
>> +ÂÂÂÂÂÂÂÂÂÂÂ __raw_readl((void *)emif_instance->ti_emif_sram_virt);
>> +
>> +ÂÂÂ /*
>> +ÂÂÂÂ * Check to see if what we are copying is already present in the
>> +ÂÂÂÂ * first byte at the destination, only copy if it is not which
>> +ÂÂÂÂ * indicates we have lost context and sram no longer contains
>> +ÂÂÂÂ * the PM code
>> +ÂÂÂÂ */
>
>> +ÂÂÂ if (tmp != ti_emif_sram)
>> +ÂÂÂÂÂÂÂ ti_emif_push_sram(dev, emif_instance);
>> +
>> +ÂÂÂ return 0;
>> +}
>> +#endif /* CONFIG_PM_SLEEP */
> Instead of this indirect method , why can't just check the previous
> deep sleep mode and based on that do copy or not. EMIF power status
> register should have something like that ?

I will check if we have a register that tells the previous state of sram.

>
> Another minor point is even though there is nothing to do in suspend,
> might be good to have a callback with comment that nothing to do with
> some explanation why not. Don't have strong preference but may for
> better readability.

Okay. Thanks a lot for the quick feedback!

>
> Regards,
> Santosh
>
>