Message ID | 20200424200135.28825-2-mathieu.poirier@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | remoteproc: Add support for synchronisaton with rproc | expand |
Hi Mathieu, On 4/24/20 10:01 PM, Mathieu Poirier wrote: > When synchronizing with a remote processor, it is entirely possible that > the remoteproc core is not the life cycle manager. In such a case core > operations don't exist and should not be called. What about ops in remote_core.c? Applying the series, seems that at least rproc->ops->panic rproc->ops->da_to_va can be called tested with undefined ops structure. Regards, Arnaud > > Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> > --- > drivers/remoteproc/remoteproc_internal.h | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h > index b389dc79da81..59fc871743c7 100644 > --- a/drivers/remoteproc/remoteproc_internal.h > +++ b/drivers/remoteproc/remoteproc_internal.h > @@ -67,7 +67,7 @@ rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...); > static inline > int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) > { > - if (rproc->ops->sanity_check) > + if (rproc->ops && rproc->ops->sanity_check) > return rproc->ops->sanity_check(rproc, fw); > > return 0; > @@ -76,7 +76,7 @@ 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->ops->get_boot_addr) > + if (rproc->ops && rproc->ops->get_boot_addr) > return rproc->ops->get_boot_addr(rproc, fw); > > return 0; > @@ -85,7 +85,7 @@ 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->ops->load) > + if (rproc->ops && rproc->ops->load) > return rproc->ops->load(rproc, fw); > > return -EINVAL; > @@ -93,7 +93,7 @@ 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->ops->parse_fw) > + if (rproc->ops && rproc->ops->parse_fw) > return rproc->ops->parse_fw(rproc, fw); > > return 0; > @@ -103,7 +103,7 @@ static inline > int rproc_handle_rsc(struct rproc *rproc, u32 rsc_type, void *rsc, int offset, > int avail) > { > - if (rproc->ops->handle_rsc) > + if (rproc->ops && rproc->ops->handle_rsc) > return rproc->ops->handle_rsc(rproc, rsc_type, rsc, offset, > avail); > > @@ -114,7 +114,7 @@ static inline > struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, > const struct firmware *fw) > { > - if (rproc->ops->find_loaded_rsc_table) > + if (rproc->ops && rproc->ops->find_loaded_rsc_table) > return rproc->ops->find_loaded_rsc_table(rproc, fw); > > return NULL; >
On Tue, Apr 28, 2020 at 06:18:59PM +0200, Arnaud POULIQUEN wrote: > Hi Mathieu, > > On 4/24/20 10:01 PM, Mathieu Poirier wrote: > > When synchronizing with a remote processor, it is entirely possible that > > the remoteproc core is not the life cycle manager. In such a case core > > operations don't exist and should not be called. > > What about ops in remote_core.c? > Applying the series, seems that at least rproc->ops->panic rproc->ops->da_to_va > can be called tested with undefined ops structure. Very true - good catch! > > Regards, > > Arnaud > > > > > Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> > > --- > > drivers/remoteproc/remoteproc_internal.h | 12 ++++++------ > > 1 file changed, 6 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h > > index b389dc79da81..59fc871743c7 100644 > > --- a/drivers/remoteproc/remoteproc_internal.h > > +++ b/drivers/remoteproc/remoteproc_internal.h > > @@ -67,7 +67,7 @@ rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...); > > static inline > > int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) > > { > > - if (rproc->ops->sanity_check) > > + if (rproc->ops && rproc->ops->sanity_check) > > return rproc->ops->sanity_check(rproc, fw); > > > > return 0; > > @@ -76,7 +76,7 @@ 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->ops->get_boot_addr) > > + if (rproc->ops && rproc->ops->get_boot_addr) > > return rproc->ops->get_boot_addr(rproc, fw); > > > > return 0; > > @@ -85,7 +85,7 @@ 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->ops->load) > > + if (rproc->ops && rproc->ops->load) > > return rproc->ops->load(rproc, fw); > > > > return -EINVAL; > > @@ -93,7 +93,7 @@ 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->ops->parse_fw) > > + if (rproc->ops && rproc->ops->parse_fw) > > return rproc->ops->parse_fw(rproc, fw); > > > > return 0; > > @@ -103,7 +103,7 @@ static inline > > int rproc_handle_rsc(struct rproc *rproc, u32 rsc_type, void *rsc, int offset, > > int avail) > > { > > - if (rproc->ops->handle_rsc) > > + if (rproc->ops && rproc->ops->handle_rsc) > > return rproc->ops->handle_rsc(rproc, rsc_type, rsc, offset, > > avail); > > > > @@ -114,7 +114,7 @@ static inline > > struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, > > const struct firmware *fw) > > { > > - if (rproc->ops->find_loaded_rsc_table) > > + if (rproc->ops && rproc->ops->find_loaded_rsc_table) > > return rproc->ops->find_loaded_rsc_table(rproc, fw); > > > > return NULL; > >
On Fri 24 Apr 13:01 PDT 2020, Mathieu Poirier wrote: > When synchronizing with a remote processor, it is entirely possible that > the remoteproc core is not the life cycle manager. In such a case core > operations don't exist and should not be called. > Why would the core call these functions if it knows the remote is in a state where it doesn't need these? Regards, Bjorn > Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> > --- > drivers/remoteproc/remoteproc_internal.h | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h > index b389dc79da81..59fc871743c7 100644 > --- a/drivers/remoteproc/remoteproc_internal.h > +++ b/drivers/remoteproc/remoteproc_internal.h > @@ -67,7 +67,7 @@ rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...); > static inline > int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) > { > - if (rproc->ops->sanity_check) > + if (rproc->ops && rproc->ops->sanity_check) > return rproc->ops->sanity_check(rproc, fw); > > return 0; > @@ -76,7 +76,7 @@ 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->ops->get_boot_addr) > + if (rproc->ops && rproc->ops->get_boot_addr) > return rproc->ops->get_boot_addr(rproc, fw); > > return 0; > @@ -85,7 +85,7 @@ 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->ops->load) > + if (rproc->ops && rproc->ops->load) > return rproc->ops->load(rproc, fw); > > return -EINVAL; > @@ -93,7 +93,7 @@ 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->ops->parse_fw) > + if (rproc->ops && rproc->ops->parse_fw) > return rproc->ops->parse_fw(rproc, fw); > > return 0; > @@ -103,7 +103,7 @@ static inline > int rproc_handle_rsc(struct rproc *rproc, u32 rsc_type, void *rsc, int offset, > int avail) > { > - if (rproc->ops->handle_rsc) > + if (rproc->ops && rproc->ops->handle_rsc) > return rproc->ops->handle_rsc(rproc, rsc_type, rsc, offset, > avail); > > @@ -114,7 +114,7 @@ static inline > struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, > const struct firmware *fw) > { > - if (rproc->ops->find_loaded_rsc_table) > + if (rproc->ops && rproc->ops->find_loaded_rsc_table) > return rproc->ops->find_loaded_rsc_table(rproc, fw); > > return NULL; > -- > 2.20.1 >
Hi Bjorn, On Tue, May 05, 2020 at 03:16:08PM -0700, Bjorn Andersson wrote: > On Fri 24 Apr 13:01 PDT 2020, Mathieu Poirier wrote: > > > When synchronizing with a remote processor, it is entirely possible that > > the remoteproc core is not the life cycle manager. In such a case core > > operations don't exist and should not be called. > > > > Why would the core call these functions if it knows the remote is in a > state where it doesn't need these? This is the reasoning that came out of a conversation Arnaud and I had. We are all on the same page. > > Regards, > Bjorn > > > Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> > > --- > > drivers/remoteproc/remoteproc_internal.h | 12 ++++++------ > > 1 file changed, 6 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h > > index b389dc79da81..59fc871743c7 100644 > > --- a/drivers/remoteproc/remoteproc_internal.h > > +++ b/drivers/remoteproc/remoteproc_internal.h > > @@ -67,7 +67,7 @@ rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...); > > static inline > > int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) > > { > > - if (rproc->ops->sanity_check) > > + if (rproc->ops && rproc->ops->sanity_check) > > return rproc->ops->sanity_check(rproc, fw); > > > > return 0; > > @@ -76,7 +76,7 @@ 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->ops->get_boot_addr) > > + if (rproc->ops && rproc->ops->get_boot_addr) > > return rproc->ops->get_boot_addr(rproc, fw); > > > > return 0; > > @@ -85,7 +85,7 @@ 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->ops->load) > > + if (rproc->ops && rproc->ops->load) > > return rproc->ops->load(rproc, fw); > > > > return -EINVAL; > > @@ -93,7 +93,7 @@ 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->ops->parse_fw) > > + if (rproc->ops && rproc->ops->parse_fw) > > return rproc->ops->parse_fw(rproc, fw); > > > > return 0; > > @@ -103,7 +103,7 @@ static inline > > int rproc_handle_rsc(struct rproc *rproc, u32 rsc_type, void *rsc, int offset, > > int avail) > > { > > - if (rproc->ops->handle_rsc) > > + if (rproc->ops && rproc->ops->handle_rsc) > > return rproc->ops->handle_rsc(rproc, rsc_type, rsc, offset, > > avail); > > > > @@ -114,7 +114,7 @@ static inline > > struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, > > const struct firmware *fw) > > { > > - if (rproc->ops->find_loaded_rsc_table) > > + if (rproc->ops && rproc->ops->find_loaded_rsc_table) > > return rproc->ops->find_loaded_rsc_table(rproc, fw); > > > > return NULL; > > -- > > 2.20.1 > >
diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index b389dc79da81..59fc871743c7 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -67,7 +67,7 @@ rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...); static inline int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) { - if (rproc->ops->sanity_check) + if (rproc->ops && rproc->ops->sanity_check) return rproc->ops->sanity_check(rproc, fw); return 0; @@ -76,7 +76,7 @@ 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->ops->get_boot_addr) + if (rproc->ops && rproc->ops->get_boot_addr) return rproc->ops->get_boot_addr(rproc, fw); return 0; @@ -85,7 +85,7 @@ 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->ops->load) + if (rproc->ops && rproc->ops->load) return rproc->ops->load(rproc, fw); return -EINVAL; @@ -93,7 +93,7 @@ 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->ops->parse_fw) + if (rproc->ops && rproc->ops->parse_fw) return rproc->ops->parse_fw(rproc, fw); return 0; @@ -103,7 +103,7 @@ static inline int rproc_handle_rsc(struct rproc *rproc, u32 rsc_type, void *rsc, int offset, int avail) { - if (rproc->ops->handle_rsc) + if (rproc->ops && rproc->ops->handle_rsc) return rproc->ops->handle_rsc(rproc, rsc_type, rsc, offset, avail); @@ -114,7 +114,7 @@ static inline struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *fw) { - if (rproc->ops->find_loaded_rsc_table) + if (rproc->ops && rproc->ops->find_loaded_rsc_table) return rproc->ops->find_loaded_rsc_table(rproc, fw); return NULL;
When synchronizing with a remote processor, it is entirely possible that the remoteproc core is not the life cycle manager. In such a case core operations don't exist and should not be called. Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> --- drivers/remoteproc/remoteproc_internal.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)