* [PATCH v3 0/3] staging: tidspbridge: bugfixes
@ 2010-11-05 16:31 Ionut Nicu
2010-11-05 16:31 ` [PATCH v3 1/3] staging: tidspbridge: fix mgr_enum_node_info Ionut Nicu
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Ionut Nicu @ 2010-11-05 16:31 UTC (permalink / raw)
To: Greg Kroah-Hartman, Omar Ramirez Luna
Cc: Fernando Guzman Lugo, Felipe Contreras, linux-omap, Ionut Nicu
Changes since v1:
* Split the mgr_enum_node_info patch into two patches:
one that fixes the issue and one that reorganizes the
code.
Ionut Nicu (3):
staging: tidspbridge: fix mgr_enum_node_info
staging: tidspbridge: mgr_enum_node_info cleanup
staging: tidspbridge: fix kernel oops in bridge_io_get_proc_load
drivers/staging/tidspbridge/core/io_sm.c | 78 +++++++++++------------------
drivers/staging/tidspbridge/rmgr/mgr.c | 50 +++++++------------
2 files changed, 48 insertions(+), 80 deletions(-)
--
1.7.2.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/3] staging: tidspbridge: fix mgr_enum_node_info
2010-11-05 16:31 [PATCH v3 0/3] staging: tidspbridge: bugfixes Ionut Nicu
@ 2010-11-05 16:31 ` Ionut Nicu
2010-11-05 16:39 ` Nishanth Menon
2010-11-05 16:31 ` [PATCH v3 2/3] staging: tidspbridge: mgr_enum_node_info cleanup Ionut Nicu
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Ionut Nicu @ 2010-11-05 16:31 UTC (permalink / raw)
To: Greg Kroah-Hartman, Omar Ramirez Luna
Cc: Fernando Guzman Lugo, Felipe Contreras, linux-omap, Ionut Nicu
The current code was always returning a non-zero status value
to userspace applications when this ioctl was called.
The error code was ENODATA, which isn't actually an error,
it's always returned by dcd_enumerate_object() when it hits the
end of list.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
drivers/staging/tidspbridge/rmgr/mgr.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/drivers/staging/tidspbridge/rmgr/mgr.c b/drivers/staging/tidspbridge/rmgr/mgr.c
index 0ea89a1..2eab6a5 100644
--- a/drivers/staging/tidspbridge/rmgr/mgr.c
+++ b/drivers/staging/tidspbridge/rmgr/mgr.c
@@ -169,6 +169,11 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops *pndb_props,
}
}
+
+ /* the last status is not 0, but neither an error */
+ if (status > 0)
+ status = 0;
+
if (!status) {
if (node_id > (node_index - 1)) {
status = -EINVAL;
--
1.7.2.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 2/3] staging: tidspbridge: mgr_enum_node_info cleanup
2010-11-05 16:31 [PATCH v3 0/3] staging: tidspbridge: bugfixes Ionut Nicu
2010-11-05 16:31 ` [PATCH v3 1/3] staging: tidspbridge: fix mgr_enum_node_info Ionut Nicu
@ 2010-11-05 16:31 ` Ionut Nicu
2010-11-05 16:31 ` [PATCH v3 3/3] staging: tidspbridge: fix kernel oops in bridge_io_get_proc_load Ionut Nicu
2010-12-06 8:56 ` [PATCH v3 0/3] staging: tidspbridge: bugfixes Ramirez Luna, Omar
3 siblings, 0 replies; 6+ messages in thread
From: Ionut Nicu @ 2010-11-05 16:31 UTC (permalink / raw)
To: Greg Kroah-Hartman, Omar Ramirez Luna
Cc: Fernando Guzman Lugo, Felipe Contreras, linux-omap, Ionut Nicu
Reorganized mgr_enum_node_info code to increase its
readability.
Signed-off-by: Ionut Nicu <ionut.nicu@mindbit.ro>
---
drivers/staging/tidspbridge/rmgr/mgr.c | 51 ++++++++++----------------------
1 files changed, 16 insertions(+), 35 deletions(-)
diff --git a/drivers/staging/tidspbridge/rmgr/mgr.c b/drivers/staging/tidspbridge/rmgr/mgr.c
index 2eab6a5..16410a5 100644
--- a/drivers/staging/tidspbridge/rmgr/mgr.c
+++ b/drivers/staging/tidspbridge/rmgr/mgr.c
@@ -134,8 +134,7 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops *pndb_props,
u32 undb_props_size, u32 *pu_num_nodes)
{
int status = 0;
- struct dsp_uuid node_uuid, temp_uuid;
- u32 temp_index = 0;
+ struct dsp_uuid node_uuid;
u32 node_index = 0;
struct dcd_genericobj gen_obj;
struct mgr_object *pmgr_obj = NULL;
@@ -149,24 +148,27 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops *pndb_props,
*pu_num_nodes = 0;
/* Get the Manager Object from the driver data */
if (!drv_datap || !drv_datap->mgr_object) {
- status = -ENODATA;
pr_err("%s: Failed to retrieve the object handle\n", __func__);
- goto func_cont;
- } else {
- pmgr_obj = drv_datap->mgr_object;
+ return -ENODATA;
}
+ pmgr_obj = drv_datap->mgr_object;
DBC_ASSERT(pmgr_obj);
/* Forever loop till we hit failed or no more items in the
* Enumeration. We will exit the loop other than 0; */
- while (status == 0) {
- status = dcd_enumerate_object(temp_index++, DSP_DCDNODETYPE,
- &temp_uuid);
- if (status == 0) {
- node_index++;
- if (node_id == (node_index - 1))
- node_uuid = temp_uuid;
-
+ while (!status) {
+ status = dcd_enumerate_object(node_index++, DSP_DCDNODETYPE,
+ &node_uuid);
+ if (status)
+ break;
+ *pu_num_nodes = node_index;
+ if (node_id == (node_index - 1)) {
+ status = dcd_get_object_def(pmgr_obj->hdcd_mgr,
+ &node_uuid, DSP_DCDNODETYPE, &gen_obj);
+ if (status)
+ break;
+ /* Get the Obj def */
+ *pndb_props = gen_obj.obj_data.node_obj.ndb_props;
}
}
@@ -174,27 +176,6 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops *pndb_props,
if (status > 0)
status = 0;
- if (!status) {
- if (node_id > (node_index - 1)) {
- status = -EINVAL;
- } else {
- status = dcd_get_object_def(pmgr_obj->hdcd_mgr,
- (struct dsp_uuid *)
- &node_uuid, DSP_DCDNODETYPE,
- &gen_obj);
- if (!status) {
- /* Get the Obj def */
- *pndb_props =
- gen_obj.obj_data.node_obj.ndb_props;
- *pu_num_nodes = node_index;
- }
- }
- }
-
-func_cont:
- DBC_ENSURE((!status && *pu_num_nodes > 0) ||
- (status && *pu_num_nodes == 0));
-
return status;
}
--
1.7.2.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 3/3] staging: tidspbridge: fix kernel oops in bridge_io_get_proc_load
2010-11-05 16:31 [PATCH v3 0/3] staging: tidspbridge: bugfixes Ionut Nicu
2010-11-05 16:31 ` [PATCH v3 1/3] staging: tidspbridge: fix mgr_enum_node_info Ionut Nicu
2010-11-05 16:31 ` [PATCH v3 2/3] staging: tidspbridge: mgr_enum_node_info cleanup Ionut Nicu
@ 2010-11-05 16:31 ` Ionut Nicu
2010-12-06 8:56 ` [PATCH v3 0/3] staging: tidspbridge: bugfixes Ramirez Luna, Omar
3 siblings, 0 replies; 6+ messages in thread
From: Ionut Nicu @ 2010-11-05 16:31 UTC (permalink / raw)
To: Greg Kroah-Hartman, Omar Ramirez Luna
Cc: Fernando Guzman Lugo, Felipe Contreras, linux-omap, Ionut Nicu
The DSP shared memory area gets initialized only when
a COFF file is loaded.
If bridge_io_get_proc_load is called before loading a base
image into the DSP, the shared_mem member of the io manager
will be NULL, resulting in a kernel oops when it's dereferenced.
Also made some coding style changes to bridge_io_create.
Signed-off-by: Ionut Nicu <ionut.nicu@mindbit.ro>
---
drivers/staging/tidspbridge/core/io_sm.c | 78 +++++++++++------------------
1 files changed, 30 insertions(+), 48 deletions(-)
diff --git a/drivers/staging/tidspbridge/core/io_sm.c b/drivers/staging/tidspbridge/core/io_sm.c
index de2cc3b..bd407b6 100644
--- a/drivers/staging/tidspbridge/core/io_sm.c
+++ b/drivers/staging/tidspbridge/core/io_sm.c
@@ -164,57 +164,41 @@ int bridge_io_create(struct io_mgr **io_man,
struct dev_object *hdev_obj,
const struct io_attrs *mgr_attrts)
{
- int status = 0;
struct io_mgr *pio_mgr = NULL;
- struct shm *shared_mem = NULL;
struct bridge_dev_context *hbridge_context = NULL;
struct cfg_devnode *dev_node_obj;
struct chnl_mgr *hchnl_mgr;
u8 dev_type;
/* Check requirements */
- if (!io_man || !mgr_attrts || mgr_attrts->word_size == 0) {
- status = -EFAULT;
- goto func_end;
- }
+ if (!io_man || !mgr_attrts || mgr_attrts->word_size == 0)
+ return -EFAULT;
+
+ *io_man = NULL;
+
dev_get_chnl_mgr(hdev_obj, &hchnl_mgr);
- if (!hchnl_mgr || hchnl_mgr->hio_mgr) {
- status = -EFAULT;
- goto func_end;
- }
+ if (!hchnl_mgr || hchnl_mgr->hio_mgr)
+ return -EFAULT;
+
/*
* Message manager will be created when a file is loaded, since
* size of message buffer in shared memory is configurable in
* the base image.
*/
dev_get_bridge_context(hdev_obj, &hbridge_context);
- if (!hbridge_context) {
- status = -EFAULT;
- goto func_end;
- }
+ if (!hbridge_context)
+ return -EFAULT;
+
dev_get_dev_type(hdev_obj, &dev_type);
- /*
- * DSP shared memory area will get set properly when
- * a program is loaded. They are unknown until a COFF file is
- * loaded. I chose the value -1 because it was less likely to be
- * a valid address than 0.
- */
- shared_mem = (struct shm *)-1;
/* Allocate IO manager object */
pio_mgr = kzalloc(sizeof(struct io_mgr), GFP_KERNEL);
- if (pio_mgr == NULL) {
- status = -ENOMEM;
- goto func_end;
- }
+ if (!pio_mgr)
+ return -ENOMEM;
/* Initialize chnl_mgr object */
-#if defined(CONFIG_TIDSPBRIDGE_BACKTRACE) || defined(CONFIG_TIDSPBRIDGE_DEBUG)
- pio_mgr->pmsg = NULL;
-#endif
pio_mgr->hchnl_mgr = hchnl_mgr;
pio_mgr->word_size = mgr_attrts->word_size;
- pio_mgr->shared_mem = shared_mem;
if (dev_type == DSP_UNIT) {
/* Create an IO DPC */
@@ -226,29 +210,24 @@ int bridge_io_create(struct io_mgr **io_man,
spin_lock_init(&pio_mgr->dpc_lock);
- status = dev_get_dev_node(hdev_obj, &dev_node_obj);
+ if (dev_get_dev_node(hdev_obj, &dev_node_obj)) {
+ bridge_io_destroy(pio_mgr);
+ return -EIO;
+ }
}
- if (!status) {
- pio_mgr->hbridge_context = hbridge_context;
- pio_mgr->shared_irq = mgr_attrts->irq_shared;
- if (dsp_wdt_init())
- status = -EPERM;
- } else {
- status = -EIO;
- }
-func_end:
- if (status) {
- /* Cleanup */
+ pio_mgr->hbridge_context = hbridge_context;
+ pio_mgr->shared_irq = mgr_attrts->irq_shared;
+ if (dsp_wdt_init()) {
bridge_io_destroy(pio_mgr);
- if (io_man)
- *io_man = NULL;
- } else {
- /* Return IO manager object to caller... */
- hchnl_mgr->hio_mgr = pio_mgr;
- *io_man = pio_mgr;
+ return -EPERM;
}
- return status;
+
+ /* Return IO manager object to caller... */
+ hchnl_mgr->hio_mgr = pio_mgr;
+ *io_man = pio_mgr;
+
+ return 0;
}
/*
@@ -1532,6 +1511,9 @@ int io_sh_msetting(struct io_mgr *hio_mgr, u8 desc, void *pargs)
int bridge_io_get_proc_load(struct io_mgr *hio_mgr,
struct dsp_procloadstat *proc_lstat)
{
+ if (!hio_mgr->shared_mem)
+ return -EFAULT;
+
proc_lstat->curr_load =
hio_mgr->shared_mem->load_mon_info.curr_dsp_load;
proc_lstat->predicted_load =
--
1.7.2.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/3] staging: tidspbridge: fix mgr_enum_node_info
2010-11-05 16:31 ` [PATCH v3 1/3] staging: tidspbridge: fix mgr_enum_node_info Ionut Nicu
@ 2010-11-05 16:39 ` Nishanth Menon
0 siblings, 0 replies; 6+ messages in thread
From: Nishanth Menon @ 2010-11-05 16:39 UTC (permalink / raw)
To: Ionut Nicu
Cc: Greg Kroah-Hartman, Omar Ramirez Luna, Fernando Guzman Lugo,
Felipe Contreras, linux-omap, Ionut Nicu
Ionut Nicu wrote, on 11/05/2010 12:31 PM:
> The current code was always returning a non-zero status value
> to userspace applications when this ioctl was called.
>
> The error code was ENODATA, which isn't actually an error,
> it's always returned by dcd_enumerate_object() when it hits the
> end of list.
>
> Signed-off-by: Felipe Contreras<felipe.contreras@gmail.com>
please try this as well:
a) git rebase -i master (to rebase from master if your branch is off that)
b) change this commit to edit
c) git commit --amend --author "Felipe Contreras
<felipe.contreras@gmail.com>"
to change the authorship
d) git rebase --continue
OR
edit the patch Manually and change:
From: Ionut Nicu <ionut.nicu@gmail.com>
to
From: Felipe Contreras <felipe.contreras@gmail.com>
The From shows the authorship, that way, when you do a git send email,
the proper acknowledgements are done :)
--
Regards,
Nishanth Menon
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/3] staging: tidspbridge: bugfixes
2010-11-05 16:31 [PATCH v3 0/3] staging: tidspbridge: bugfixes Ionut Nicu
` (2 preceding siblings ...)
2010-11-05 16:31 ` [PATCH v3 3/3] staging: tidspbridge: fix kernel oops in bridge_io_get_proc_load Ionut Nicu
@ 2010-12-06 8:56 ` Ramirez Luna, Omar
3 siblings, 0 replies; 6+ messages in thread
From: Ramirez Luna, Omar @ 2010-12-06 8:56 UTC (permalink / raw)
To: Ionut Nicu
Cc: Greg Kroah-Hartman, Fernando Guzman Lugo, Felipe Contreras,
linux-omap, Ionut Nicu
On Fri, Nov 5, 2010 at 11:31 AM, Ionut Nicu <ionut.nicu@gmail.com> wrote:
> Changes since v1:
>
> * Split the mgr_enum_node_info patch into two patches:
> one that fixes the issue and one that reorganizes the
> code.
>
> Ionut Nicu (3):
> staging: tidspbridge: fix mgr_enum_node_info
> staging: tidspbridge: mgr_enum_node_info cleanup
> staging: tidspbridge: fix kernel oops in bridge_io_get_proc_load
Pushed to dspbridge.
Regards,
Omar
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-12-06 8:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-05 16:31 [PATCH v3 0/3] staging: tidspbridge: bugfixes Ionut Nicu
2010-11-05 16:31 ` [PATCH v3 1/3] staging: tidspbridge: fix mgr_enum_node_info Ionut Nicu
2010-11-05 16:39 ` Nishanth Menon
2010-11-05 16:31 ` [PATCH v3 2/3] staging: tidspbridge: mgr_enum_node_info cleanup Ionut Nicu
2010-11-05 16:31 ` [PATCH v3 3/3] staging: tidspbridge: fix kernel oops in bridge_io_get_proc_load Ionut Nicu
2010-12-06 8:56 ` [PATCH v3 0/3] staging: tidspbridge: bugfixes Ramirez Luna, Omar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox