hi Mathieu,

On 4/30/20 9:57 PM, Mathieu Poirier wrote:
> On Tue, Apr 28, 2020 at 07:27:27PM +0200, Arnaud POULIQUEN wrote:
>>
>>
>> On 4/24/20 10:01 PM, Mathieu Poirier wrote:
>>> Call the right core function based on whether we should synchronise
>>> with a remote processor or boot it from scratch.
>>>
>>> Signed-off-by: Mathieu Poirier <[email protected]>
>>> ---
>>>  drivers/remoteproc/remoteproc_internal.h | 50 ++++++++++++++++++++++++
>>>  1 file changed, 50 insertions(+)
>>>
>>> diff --git a/drivers/remoteproc/remoteproc_internal.h 
>>> b/drivers/remoteproc/remoteproc_internal.h
>>> index dda7044c4b3e..3985c084b184 100644
>>> --- a/drivers/remoteproc/remoteproc_internal.h
>>> +++ b/drivers/remoteproc/remoteproc_internal.h
>>> @@ -72,6 +72,12 @@ static inline bool rproc_needs_syncing(struct rproc 
>>> *rproc)
>>>  static inline
>>>  int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw)
>>>  {
>>> +   if (rproc_needs_syncing(rproc)) {
>>> +           if (rproc->sync_ops && rproc->sync_ops->sanity_check)
>>> +                   return rproc->sync_ops->sanity_check(rproc, fw);
>>> +           return 0;
>>> +   }
>>> +
>>>     if (rproc->ops && rproc->ops->sanity_check)
>>>             return rproc->ops->sanity_check(rproc, fw);
>>
>> Regarding this patch I'm trying to determine whether it makes sense to have 
>> ops or
>> sync_ops set to null. Your[v3 01/14]  patch commit explains that ops can be 
>> null in case of
>> synchronisation.
>> But it seems deprecated with the sync_ops introduction...
> 
> Your comment made me go over the logic again...  If rproc_needs_syncing() is
> true then we necessarily have a sync_ops.  If rproc_needs_syncing() is false,
> there too we automatically have an ops.  As such and as you point out, 
> checking
> for rproc->sync_ops and rproc-ops is probably useless.
An Additional test in rproc_set_state_machine should be sufficient, something 
like that: 
 /* rproc->ops struct is mandatory if at least one sync flag is false */
 if (!rproc->ops && !(sync_flags.on_init &&
            sync_flags.after_stop && sync_flags.after_crash))
                return -EINVAL;

> 
>>
>> And if sync_ops is null, is it still necessary to define a remoteproc device?
> 
> Not sure I understand your point here but with the reasonning from above it
> is probably moot anyway. 
Just to mention that a platform device with ops and ops_sync null seems like 
nonsense 

Regards,
Arnaud
> 
>>
>> Regards
>> Arnad
>>
>>>  
>>> @@ -81,6 +87,12 @@ int rproc_fw_sanity_check(struct rproc *rproc, const 
>>> struct firmware *fw)
>>>  static inline
>>>  u64 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw)
>>>  {
>>> +   if (rproc_needs_syncing(rproc)) {
>>> +           if (rproc->sync_ops && rproc->sync_ops->get_boot_addr)
>>> +                   return rproc->sync_ops->get_boot_addr(rproc, fw);
>>> +           return 0;
>>> +   }
>>> +
>>>     if (rproc->ops && rproc->ops->get_boot_addr)
>>>             return rproc->ops->get_boot_addr(rproc, fw);
>>>  
>>> @@ -90,6 +102,12 @@ u64 rproc_get_boot_addr(struct rproc *rproc, const 
>>> struct firmware *fw)
>>>  static inline
>>>  int rproc_load_segments(struct rproc *rproc, const struct firmware *fw)
>>>  {
>>> +   if (rproc_needs_syncing(rproc)) {
>>> +           if (rproc->sync_ops && rproc->sync_ops->load)
>>> +                   return rproc->sync_ops->load(rproc, fw);
>>> +           return 0;
>>> +   }
>>> +
>>>     if (rproc->ops && rproc->ops->load)
>>>             return rproc->ops->load(rproc, fw);
>>>  
>>> @@ -98,6 +116,12 @@ int rproc_load_segments(struct rproc *rproc, const 
>>> struct firmware *fw)
>>>  
>>>  static inline int rproc_parse_fw(struct rproc *rproc, const struct 
>>> firmware *fw)
>>>  {
>>> +   if (rproc_needs_syncing(rproc)) {
>>> +           if (rproc->sync_ops && rproc->sync_ops->parse_fw)
>>> +                   return rproc->sync_ops->parse_fw(rproc, fw);
>>> +           return 0;
>>> +   }
>>> +
>>>     if (rproc->ops && rproc->ops->parse_fw)
>>>             return rproc->ops->parse_fw(rproc, fw);
>>>  
>>> @@ -108,6 +132,13 @@ static inline
>>>  int rproc_handle_rsc(struct rproc *rproc, u32 rsc_type, void *rsc, int 
>>> offset,
>>>                  int avail)
>>>  {
>>> +   if (rproc_needs_syncing(rproc)) {
>>> +           if (rproc->sync_ops && rproc->sync_ops->handle_rsc)
>>> +                   return rproc->sync_ops->handle_rsc(rproc, rsc_type,
>>> +                                                      rsc, offset, avail);
>>> +           return 0;
>>> +   }
>>> +
>>>     if (rproc->ops && rproc->ops->handle_rsc)
>>>             return rproc->ops->handle_rsc(rproc, rsc_type, rsc, offset,
>>>                                           avail);
>>> @@ -119,6 +150,13 @@ static inline
>>>  struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc,
>>>                                                const struct firmware *fw)
>>>  {
>>> +   if (rproc_needs_syncing(rproc)) {
>>> +           if (rproc->sync_ops && rproc->sync_ops->find_loaded_rsc_table)
>>> +                   return rproc->sync_ops->find_loaded_rsc_table(rproc,
>>> +                                                                 fw);
>>> +           return NULL;
>>> +   }
>>> +
>>>     if (rproc->ops && rproc->ops->find_loaded_rsc_table)
>>>             return rproc->ops->find_loaded_rsc_table(rproc, fw);
>>>  
>>> @@ -127,6 +165,12 @@ struct resource_table 
>>> *rproc_find_loaded_rsc_table(struct rproc *rproc,
>>>  
>>>  static inline int rproc_start_device(struct rproc *rproc)
>>>  {
>>> +   if (rproc_needs_syncing(rproc)) {
>>> +           if (rproc->sync_ops && rproc->sync_ops->start)
>>> +                   return rproc->sync_ops->start(rproc);
>>> +           return 0;
>>> +   }
>>> +
>>>     if (rproc->ops && rproc->ops->start)
>>>             return rproc->ops->start(rproc);
>>>  
>>> @@ -135,6 +179,12 @@ static inline int rproc_start_device(struct rproc 
>>> *rproc)
>>>  
>>>  static inline int rproc_stop_device(struct rproc *rproc)
>>>  {
>>> +   if (rproc_needs_syncing(rproc)) {
>>> +           if (rproc->sync_ops && rproc->sync_ops->stop)
>>> +                   return rproc->sync_ops->stop(rproc);
>>> +           return 0;
>>> +   }
>>> +
>>>     if (rproc->ops && rproc->ops->stop)
>>>             return rproc->ops->stop(rproc);
>>>  
>>>

Reply via email to