All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: tidspbridge: protect dmm_map properly
@ 2010-12-20 17:12 Felipe Contreras
  2010-12-20 18:30 ` Kanigeri, Hari
  2011-03-07 18:02 ` Felipe Contreras
  0 siblings, 2 replies; 14+ messages in thread
From: Felipe Contreras @ 2010-12-20 17:12 UTC (permalink / raw)
  To: linux-main, linux-omap, Greg KH, Omar Ramirez Luna
  Cc: Ohad Ben-Cohen, Fernando Guzman Lugo, Nishanth Menon,
	Ameya Palande, Felipe Contreras

We need to protect not only the dmm_map list, but the individual
map_obj's, otherwise, we might be building the scatter-gather list with
garbage. So, use the existing proc_lock for that.

I observed race conditions which caused kernel panics while running
stress tests. This patch fixes those.

Signed-off-by: Felipe Contreras <felipe.contreras@nokia.com>
---
 drivers/staging/tidspbridge/rmgr/proc.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/tidspbridge/rmgr/proc.c b/drivers/staging/tidspbridge/rmgr/proc.c
index b47d7aa..21052e3 100644
--- a/drivers/staging/tidspbridge/rmgr/proc.c
+++ b/drivers/staging/tidspbridge/rmgr/proc.c
@@ -781,12 +781,14 @@ int proc_begin_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
 							(u32)pmpu_addr,
 							ul_size, dir);
 
+	mutex_lock(&proc_lock);
+
 	/* find requested memory are in cached mapping information */
 	map_obj = find_containing_mapping(pr_ctxt, (u32) pmpu_addr, ul_size);
 	if (!map_obj) {
 		pr_err("%s: find_containing_mapping failed\n", __func__);
 		status = -EFAULT;
-		goto err_out;
+		goto no_map;
 	}
 
 	if (memory_give_ownership(map_obj, (u32) pmpu_addr, ul_size, dir)) {
@@ -795,6 +797,8 @@ int proc_begin_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
 		status = -EFAULT;
 	}
 
+no_map:
+	mutex_unlock(&proc_lock);
 err_out:
 
 	return status;
@@ -819,12 +823,14 @@ int proc_end_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
 							(u32)pmpu_addr,
 							ul_size, dir);
 
+	mutex_lock(&proc_lock);
+
 	/* find requested memory are in cached mapping information */
 	map_obj = find_containing_mapping(pr_ctxt, (u32) pmpu_addr, ul_size);
 	if (!map_obj) {
 		pr_err("%s: find_containing_mapping failed\n", __func__);
 		status = -EFAULT;
-		goto err_out;
+		goto no_map;
 	}
 
 	if (memory_regain_ownership(map_obj, (u32) pmpu_addr, ul_size, dir)) {
@@ -834,6 +840,8 @@ int proc_end_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
 		goto err_out;
 	}
 
+no_map:
+	mutex_unlock(&proc_lock);
 err_out:
 	return status;
 }
@@ -1726,9 +1734,8 @@ int proc_un_map(void *hprocessor, void *map_addr,
 		    (p_proc_object->hbridge_context, va_align, size_align);
 	}
 
-	mutex_unlock(&proc_lock);
 	if (status)
-		goto func_end;
+		goto unmap_failed;
 
 	/*
 	 * A successful unmap should be followed by removal of map_obj
@@ -1737,6 +1744,9 @@ int proc_un_map(void *hprocessor, void *map_addr,
 	 */
 	remove_mapping_information(pr_ctxt, (u32) map_addr, size_align);
 
+unmap_failed:
+	mutex_unlock(&proc_lock);
+
 func_end:
 	dev_dbg(bridge, "%s: hprocessor: 0x%p map_addr: 0x%p status: 0x%x\n",
 		__func__, hprocessor, map_addr, status);
-- 
1.7.3.3


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH] staging: tidspbridge: protect dmm_map properly
  2010-12-20 17:12 [PATCH] staging: tidspbridge: protect dmm_map properly Felipe Contreras
@ 2010-12-20 18:30 ` Kanigeri, Hari
  2010-12-20 18:43   ` Felipe Contreras
  2011-03-07 18:02 ` Felipe Contreras
  1 sibling, 1 reply; 14+ messages in thread
From: Kanigeri, Hari @ 2010-12-20 18:30 UTC (permalink / raw)
  To: Felipe Contreras
  Cc: linux-main, linux-omap, Greg KH, Omar Ramirez Luna,
	Ohad Ben-Cohen, Fernando Guzman Lugo, Nishanth Menon,
	Ameya Palande

Felipe,

On Mon, Dec 20, 2010 at 11:12 AM, Felipe Contreras
<felipe.contreras@nokia.com> wrote:
> We need to protect not only the dmm_map list, but the individual
> map_obj's, otherwise, we might be building the scatter-gather list with
> garbage. So, use the existing proc_lock for that.
>
> I observed race conditions which caused kernel panics while running
> stress tests. This patch fixes those.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@nokia.com>
> ---
>  drivers/staging/tidspbridge/rmgr/proc.c |   18 ++++++++++++++----
>  1 files changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/tidspbridge/rmgr/proc.c b/drivers/staging/tidspbridge/rmgr/proc.c
> index b47d7aa..21052e3 100644
> --- a/drivers/staging/tidspbridge/rmgr/proc.c
> +++ b/drivers/staging/tidspbridge/rmgr/proc.c
> @@ -781,12 +781,14 @@ int proc_begin_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
>                                                        (u32)pmpu_addr,
>                                                        ul_size, dir);
>
> +       mutex_lock(&proc_lock);

May be you should use mutex_lock_interruptable instead of  mutex_lock.

> +
>        /* find requested memory are in cached mapping information */
>        map_obj = find_containing_mapping(pr_ctxt, (u32) pmpu_addr, ul_size);
>        if (!map_obj) {
>                pr_err("%s: find_containing_mapping failed\n", __func__);
>                status = -EFAULT;
> -               goto err_out;
> +               goto no_map;
>        }
>
>        if (memory_give_ownership(map_obj, (u32) pmpu_addr, ul_size, dir)) {
> @@ -795,6 +797,8 @@ int proc_begin_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
>                status = -EFAULT;
>        }
>
> +no_map:
> +       mutex_unlock(&proc_lock);
>  err_out:
>
>        return status;
> @@ -819,12 +823,14 @@ int proc_end_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
>                                                        (u32)pmpu_addr,
>                                                        ul_size, dir);
>
> +       mutex_lock(&proc_lock);
> +
>        /* find requested memory are in cached mapping information */
>        map_obj = find_containing_mapping(pr_ctxt, (u32) pmpu_addr, ul_size);
>        if (!map_obj) {
>                pr_err("%s: find_containing_mapping failed\n", __func__);
>                status = -EFAULT;
> -               goto err_out;
> +               goto no_map;
>        }
>
>        if (memory_regain_ownership(map_obj, (u32) pmpu_addr, ul_size, dir)) {
> @@ -834,6 +840,8 @@ int proc_end_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
>                goto err_out;

Mutex is not released in this case as it is released only at no_map.


>        }
>
> +no_map:
> +       mutex_unlock(&proc_lock);
>  err_out:
>        return status;
>  }
> @@ -1726,9 +1734,8 @@ int proc_un_map(void *hprocessor, void *map_addr,
>                    (p_proc_object->hbridge_context, va_align, size_align);
>        }
>
> -       mutex_unlock(&proc_lock);
>        if (status)
> -               goto func_end;
> +               goto unmap_failed;
>
>        /*
>         * A successful unmap should be followed by removal of map_obj
> @@ -1737,6 +1744,9 @@ int proc_un_map(void *hprocessor, void *map_addr,
>         */
>        remove_mapping_information(pr_ctxt, (u32) map_addr, size_align);
>
> +unmap_failed:
> +       mutex_unlock(&proc_lock);
> +
>  func_end:
>        dev_dbg(bridge, "%s: hprocessor: 0x%p map_addr: 0x%p status: 0x%x\n",
>                __func__, hprocessor, map_addr, status);
> --
> 1.7.3.3
>
> --
> 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
>



-- 
Thank you,
Best regards,
Hari Kanigeri

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] staging: tidspbridge: protect dmm_map properly
  2010-12-20 18:30 ` Kanigeri, Hari
@ 2010-12-20 18:43   ` Felipe Contreras
  0 siblings, 0 replies; 14+ messages in thread
From: Felipe Contreras @ 2010-12-20 18:43 UTC (permalink / raw)
  To: Kanigeri, Hari
  Cc: Felipe Contreras, linux-main, linux-omap, Greg KH,
	Omar Ramirez Luna, Ohad Ben-Cohen, Fernando Guzman Lugo,
	Nishanth Menon, Ameya Palande

Hi,

On Mon, Dec 20, 2010 at 8:30 PM, Kanigeri, Hari <h-kanigeri2@ti.com> wrote:
> On Mon, Dec 20, 2010 at 11:12 AM, Felipe Contreras
> <felipe.contreras@nokia.com> wrote:
>> We need to protect not only the dmm_map list, but the individual
>> map_obj's, otherwise, we might be building the scatter-gather list with
>> garbage. So, use the existing proc_lock for that.
>>
>> I observed race conditions which caused kernel panics while running
>> stress tests. This patch fixes those.
>>
>> Signed-off-by: Felipe Contreras <felipe.contreras@nokia.com>
>> ---
>>  drivers/staging/tidspbridge/rmgr/proc.c |   18 ++++++++++++++----
>>  1 files changed, 14 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/staging/tidspbridge/rmgr/proc.c b/drivers/staging/tidspbridge/rmgr/proc.c
>> index b47d7aa..21052e3 100644
>> --- a/drivers/staging/tidspbridge/rmgr/proc.c
>> +++ b/drivers/staging/tidspbridge/rmgr/proc.c
>> @@ -781,12 +781,14 @@ int proc_begin_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
>>                                                        (u32)pmpu_addr,
>>                                                        ul_size, dir);
>>
>> +       mutex_lock(&proc_lock);
>
> May be you should use mutex_lock_interruptable instead of  mutex_lock.

Right, but I think that should be a separate patch since
mutex_lock(&proc_lock) is already being used.

>> @@ -819,12 +823,14 @@ int proc_end_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
>>                                                        (u32)pmpu_addr,
>>                                                        ul_size, dir);
>>
>> +       mutex_lock(&proc_lock);
>> +
>>        /* find requested memory are in cached mapping information */
>>        map_obj = find_containing_mapping(pr_ctxt, (u32) pmpu_addr, ul_size);
>>        if (!map_obj) {
>>                pr_err("%s: find_containing_mapping failed\n", __func__);
>>                status = -EFAULT;
>> -               goto err_out;
>> +               goto no_map;
>>        }
>>
>>        if (memory_regain_ownership(map_obj, (u32) pmpu_addr, ul_size, dir)) {
>> @@ -834,6 +840,8 @@ int proc_end_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
>>                goto err_out;
>
> Mutex is not released in this case as it is released only at no_map.

Oops! I didn't test proc_end_dma() and quickly added those locks after
I noticed it. I'll resend with the fix.

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] staging: tidspbridge: protect dmm_map properly
  2010-12-20 17:12 [PATCH] staging: tidspbridge: protect dmm_map properly Felipe Contreras
  2010-12-20 18:30 ` Kanigeri, Hari
@ 2011-03-07 18:02 ` Felipe Contreras
  2011-03-07 18:14   ` Ohad Ben-Cohen
                     ` (2 more replies)
  1 sibling, 3 replies; 14+ messages in thread
From: Felipe Contreras @ 2011-03-07 18:02 UTC (permalink / raw)
  To: Felipe Contreras
  Cc: linux-main, linux-omap, Greg KH, Omar Ramirez Luna,
	Ohad Ben-Cohen, Fernando Guzman Lugo, Nishanth Menon,
	Ameya Palande

On Mon, Dec 20, 2010 at 7:12 PM, Felipe Contreras
<felipe.contreras@nokia.com> wrote:
> We need to protect not only the dmm_map list, but the individual
> map_obj's, otherwise, we might be building the scatter-gather list with
> garbage. So, use the existing proc_lock for that.
>
> I observed race conditions which caused kernel panics while running
> stress tests. This patch fixes those.

I just heard that Tuomas Kulve is getting a lot of panics on Gumstix
Overo. I propose we apply this patch on the stable tree ASAP, and if
there's no better proposals, also on .38.

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] staging: tidspbridge: protect dmm_map properly
  2011-03-07 18:02 ` Felipe Contreras
@ 2011-03-07 18:14   ` Ohad Ben-Cohen
  2011-03-07 18:48   ` Greg KH
  2011-03-07 19:29   ` Ramirez Luna, Omar
  2 siblings, 0 replies; 14+ messages in thread
From: Ohad Ben-Cohen @ 2011-03-07 18:14 UTC (permalink / raw)
  To: Felipe Contreras
  Cc: Felipe Contreras, linux-main, linux-omap, Greg KH,
	Omar Ramirez Luna, Fernando Guzman Lugo, Nishanth Menon,
	Ameya Palande

On Mon, Mar 7, 2011 at 8:02 PM, Felipe Contreras
<felipe.contreras@gmail.com> wrote:
> On Mon, Dec 20, 2010 at 7:12 PM, Felipe Contreras
> <felipe.contreras@nokia.com> wrote:
>> We need to protect not only the dmm_map list, but the individual
>> map_obj's, otherwise, we might be building the scatter-gather list with
>> garbage. So, use the existing proc_lock for that.
>>
>> I observed race conditions which caused kernel panics while running
>> stress tests. This patch fixes those.
>
> I just heard that Tuomas Kulve is getting a lot of panics on Gumstix
> Overo. I propose we apply this patch on the stable tree ASAP, and if
> there's no better proposals, also on .38.

Agree that a fix should be merged asap, and I don't mind which.
Especially since things have changed lately and chances that we will
use this code for OMAP4 too are really small now.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] staging: tidspbridge: protect dmm_map properly
  2011-03-07 18:02 ` Felipe Contreras
  2011-03-07 18:14   ` Ohad Ben-Cohen
@ 2011-03-07 18:48   ` Greg KH
  2011-03-07 19:29   ` Ramirez Luna, Omar
  2 siblings, 0 replies; 14+ messages in thread
From: Greg KH @ 2011-03-07 18:48 UTC (permalink / raw)
  To: Felipe Contreras
  Cc: Felipe Contreras, linux-main, linux-omap, Omar Ramirez Luna,
	Ohad Ben-Cohen, Fernando Guzman Lugo, Nishanth Menon,
	Ameya Palande

On Mon, Mar 07, 2011 at 08:02:44PM +0200, Felipe Contreras wrote:
> On Mon, Dec 20, 2010 at 7:12 PM, Felipe Contreras
> <felipe.contreras@nokia.com> wrote:
> > We need to protect not only the dmm_map list, but the individual
> > map_obj's, otherwise, we might be building the scatter-gather list with
> > garbage. So, use the existing proc_lock for that.
> >
> > I observed race conditions which caused kernel panics while running
> > stress tests. This patch fixes those.
> 
> I just heard that Tuomas Kulve is getting a lot of panics on Gumstix
> Overo. I propose we apply this patch on the stable tree ASAP, and if
> there's no better proposals, also on .38.

Um, I don't think you realize _how_ stable trees work, please go read
Documentation/stable_kernel_rules.txt to see how it is not possible to
take something into the stable releases before it goes to Linus's tree.

Sorry,

greg k-h

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] staging: tidspbridge: protect dmm_map properly
  2011-03-07 18:02 ` Felipe Contreras
  2011-03-07 18:14   ` Ohad Ben-Cohen
  2011-03-07 18:48   ` Greg KH
@ 2011-03-07 19:29   ` Ramirez Luna, Omar
  2011-03-07 21:48     ` Felipe Contreras
  2 siblings, 1 reply; 14+ messages in thread
From: Ramirez Luna, Omar @ 2011-03-07 19:29 UTC (permalink / raw)
  To: Felipe Contreras
  Cc: Felipe Contreras, linux-main, linux-omap, Greg KH,
	Ohad Ben-Cohen, Fernando Guzman Lugo, Nishanth Menon,
	Ameya Palande

Hi Felipe,

On Mon, Mar 7, 2011 at 12:02 PM, Felipe Contreras
<felipe.contreras@gmail.com> wrote:
> On Mon, Dec 20, 2010 at 7:12 PM, Felipe Contreras
> <felipe.contreras@nokia.com> wrote:
>> We need to protect not only the dmm_map list, but the individual
>> map_obj's, otherwise, we might be building the scatter-gather list with
>> garbage. So, use the existing proc_lock for that.
>>
>> I observed race conditions which caused kernel panics while running
>> stress tests. This patch fixes those.
>
> I just heard that Tuomas Kulve is getting a lot of panics on Gumstix
> Overo. I propose we apply this patch on the stable tree ASAP, and if
> there's no better proposals, also on .38.

Can you or Tuomas share the bug report data (panic log, test case
maybe)? I would like to discard issues affected by timing that could
be hidden with this patch.

I agree that for the time being this needs to be sent upstream, even
if in paper Ohad's patch solves the issue without side effects of
locking.

Thanks,

Omar

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] staging: tidspbridge: protect dmm_map properly
  2011-03-07 19:29   ` Ramirez Luna, Omar
@ 2011-03-07 21:48     ` Felipe Contreras
  0 siblings, 0 replies; 14+ messages in thread
From: Felipe Contreras @ 2011-03-07 21:48 UTC (permalink / raw)
  To: Ramirez Luna, Omar
  Cc: Felipe Contreras, linux-main, linux-omap, Greg KH,
	Ohad Ben-Cohen, Fernando Guzman Lugo, Nishanth Menon,
	Ameya Palande

On Mon, Mar 7, 2011 at 9:29 PM, Ramirez Luna, Omar <omar.ramirez@ti.com> wrote:
> On Mon, Mar 7, 2011 at 12:02 PM, Felipe Contreras
> <felipe.contreras@gmail.com> wrote:
>> On Mon, Dec 20, 2010 at 7:12 PM, Felipe Contreras
>> <felipe.contreras@nokia.com> wrote:
>>> We need to protect not only the dmm_map list, but the individual
>>> map_obj's, otherwise, we might be building the scatter-gather list with
>>> garbage. So, use the existing proc_lock for that.
>>>
>>> I observed race conditions which caused kernel panics while running
>>> stress tests. This patch fixes those.
>>
>> I just heard that Tuomas Kulve is getting a lot of panics on Gumstix
>> Overo. I propose we apply this patch on the stable tree ASAP, and if
>> there's no better proposals, also on .38.
>
> Can you or Tuomas share the bug report data (panic log, test case
> maybe)? I would like to discard issues affected by timing that could
> be hidden with this patch.

I got this from Tuomas:
http://pastie.org/1643677

It seems it's very easy to reproduce on Gumstix Overo with a
gst-launch command. The way I reproduced it was very tedious; running
a full blown Maemo test suite with GBs of clips.

I think the issue is very clear; if you build a sg list with garbage
memory, problems are expected =/

> I agree that for the time being this needs to be sent upstream, even
> if in paper Ohad's patch solves the issue without side effects of
> locking.

Perhaps. I don't remember if I ack'ed Ohad's patch, but even if it's
ok, I think it can be applied on top of my patch.

Cheers.

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] staging: tidspbridge: protect dmm_map properly
  2011-03-14 15:33       ` Felipe Contreras
@ 2011-03-14 15:53         ` Greg KH
  0 siblings, 0 replies; 14+ messages in thread
From: Greg KH @ 2011-03-14 15:53 UTC (permalink / raw)
  To: Felipe Contreras
  Cc: omar.ramirez, linux-kernel, linux-omap, ohad, fernando.lugo, tuomas

On Mon, Mar 14, 2011 at 05:33:09PM +0200, Felipe Contreras wrote:
> greg@kroah.com wrote:
> > On Sun, Mar 13, 2011 at 01:42:35AM +0200, Felipe Contreras wrote:
> > > On Sat, Mar 12, 2011 at 7:36 PM, Greg KH <greg@kroah.com> wrote:
> > > > How about I send it to Linus for .39 and then add it to the .38-stable
> > > > tree when it comes out?
> > > 
> > > That was the plan for .38/.37-stable. I'd say that's fine, but it
> > > would be even better to avoid people getting bit by this on plain .38.
> > 
> > What is one more week, when you all waited months to get this to me?  In
> > other words, why should I suddenly now rush when no one else did?
> 
> The reason is because it didn't seem like it was happening often, but
> in Tuomas' case, it does so much it's basically unusable. So _now_ we
> know this could have possibly been affecting many people we didn't know
> about.
> 
> You have to remember that this driver only started to work on .37, so
> people might have tried it, seen it crashing and said "oh well, it's on
> 'staging' for a reason", having no point of reference that would be a
> valid conclusion, while in fact this is a regression from pre-staging
> (the issue wasn't there).

I understand you feeling like there is a rush here, but again, please
recognize that we all have different priorities.  The number of users
out there using this driver is very small and again, this patch can
safely wait until the first .38-stable release comes out.

> Anyway, I don't think .38.1 is going to be released in one week,

Is that a challenge?  :)

> but I guess if people are having issues and not reporting them, they
> can wait more.

Thanks, I think they can.

greg k-h

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] staging: tidspbridge: protect dmm_map properly
  2011-03-13  1:06     ` Greg KH
@ 2011-03-14 15:33       ` Felipe Contreras
  2011-03-14 15:53         ` Greg KH
  0 siblings, 1 reply; 14+ messages in thread
From: Felipe Contreras @ 2011-03-14 15:33 UTC (permalink / raw)
  To: greg; +Cc: omar.ramirez, linux-kernel, linux-omap, ohad, fernando.lugo, tuomas

greg@kroah.com wrote:
> On Sun, Mar 13, 2011 at 01:42:35AM +0200, Felipe Contreras wrote:
> > On Sat, Mar 12, 2011 at 7:36 PM, Greg KH <greg@kroah.com> wrote:
> > > How about I send it to Linus for .39 and then add it to the .38-stable
> > > tree when it comes out?
> > 
> > That was the plan for .38/.37-stable. I'd say that's fine, but it
> > would be even better to avoid people getting bit by this on plain .38.
> 
> What is one more week, when you all waited months to get this to me?  In
> other words, why should I suddenly now rush when no one else did?

The reason is because it didn't seem like it was happening often, but
in Tuomas' case, it does so much it's basically unusable. So _now_ we
know this could have possibly been affecting many people we didn't know
about.

You have to remember that this driver only started to work on .37, so
people might have tried it, seen it crashing and said "oh well, it's on
'staging' for a reason", having no point of reference that would be a
valid conclusion, while in fact this is a regression from pre-staging
(the issue wasn't there).

Anyway, I don't think .38.1 is going to be released in one week, but I
guess if people are having issues and not reporting them, they can wait
more.

Cheers.

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] staging: tidspbridge: protect dmm_map properly
  2011-03-12 23:42   ` Felipe Contreras
@ 2011-03-13  1:06     ` Greg KH
  2011-03-14 15:33       ` Felipe Contreras
  0 siblings, 1 reply; 14+ messages in thread
From: Greg KH @ 2011-03-13  1:06 UTC (permalink / raw)
  To: Felipe Contreras
  Cc: Omar Ramirez Luna, l-m, Felipe Contreras, l-o, Ohad Ben-Cohen,
	Fernando Guzman Lugo, Tuomas Kulve

On Sun, Mar 13, 2011 at 01:42:35AM +0200, Felipe Contreras wrote:
> On Sat, Mar 12, 2011 at 7:36 PM, Greg KH <greg@kroah.com> wrote:
> > On Fri, Mar 11, 2011 at 06:29:06PM -0600, Omar Ramirez Luna wrote:
> >> Please consider to apply this patch in the staging tree, as the
> >> description says it fixes a crash in tidspbridge driver, this bug
> >> was already present but it seems to have surfaced by recent tests
> >> made by Felipe and Tuomas.
> >>
> >> It is an urgent fix for 2.6.38.
> >
> > Heh, it's funny to see such a "urgent" fix take so long to get to me :)
> 
> Well, depending on your hardware and use-case this might or might not
> be urgent. At least for some people the driver is unusable without
> this.

Urgency is all relative :)

> > Is it also applicable for .37?
> 
> Yes.

In the future, always say this so I don't have to ask please.

> > How about I send it to Linus for .39 and then add it to the .38-stable
> > tree when it comes out?
> 
> That was the plan for .38/.37-stable. I'd say that's fine, but it
> would be even better to avoid people getting bit by this on plain .38.

What is one more week, when you all waited months to get this to me?  In
other words, why should I suddenly now rush when no one else did?

I'll queue this up for .39 and mark it for stable inclusion.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] staging: tidspbridge: protect dmm_map properly
  2011-03-12 17:36 ` Greg KH
@ 2011-03-12 23:42   ` Felipe Contreras
  2011-03-13  1:06     ` Greg KH
  0 siblings, 1 reply; 14+ messages in thread
From: Felipe Contreras @ 2011-03-12 23:42 UTC (permalink / raw)
  To: Greg KH
  Cc: Omar Ramirez Luna, l-m, Felipe Contreras, l-o, Ohad Ben-Cohen,
	Fernando Guzman Lugo, Tuomas Kulve

On Sat, Mar 12, 2011 at 7:36 PM, Greg KH <greg@kroah.com> wrote:
> On Fri, Mar 11, 2011 at 06:29:06PM -0600, Omar Ramirez Luna wrote:
>> Please consider to apply this patch in the staging tree, as the
>> description says it fixes a crash in tidspbridge driver, this bug
>> was already present but it seems to have surfaced by recent tests
>> made by Felipe and Tuomas.
>>
>> It is an urgent fix for 2.6.38.
>
> Heh, it's funny to see such a "urgent" fix take so long to get to me :)

Well, depending on your hardware and use-case this might or might not
be urgent. At least for some people the driver is unusable without
this.

> Is it also applicable for .37?

Yes.

> How about I send it to Linus for .39 and then add it to the .38-stable
> tree when it comes out?

That was the plan for .38/.37-stable. I'd say that's fine, but it
would be even better to avoid people getting bit by this on plain .38.

Cheers.

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] staging: tidspbridge: protect dmm_map properly
  2011-03-12  0:29 Omar Ramirez Luna
@ 2011-03-12 17:36 ` Greg KH
  2011-03-12 23:42   ` Felipe Contreras
  0 siblings, 1 reply; 14+ messages in thread
From: Greg KH @ 2011-03-12 17:36 UTC (permalink / raw)
  To: Omar Ramirez Luna
  Cc: l-m, Felipe Contreras, l-o, Ohad Ben-Cohen, Fernando Guzman Lugo,
	Tuomas Kulve

On Fri, Mar 11, 2011 at 06:29:06PM -0600, Omar Ramirez Luna wrote:
> Hi Greg,
> 
> Please consider to apply this patch in the staging tree, as the
> description says it fixes a crash in tidspbridge driver, this bug
> was already present but it seems to have surfaced by recent tests
> made by Felipe and Tuomas.
> 
> It is an urgent fix for 2.6.38.

Heh, it's funny to see such a "urgent" fix take so long to get to me :)

Is it also applicable for .37?

> More on this discussion:
> http://www.gossamer-threads.com/lists/linux/kernel/1351446
> 
> Thanks,
> - omar
> 
> From: Felipe Contreras <felipe.contreras@nokia.com>
> 
> We need to protect not only the dmm_map list, but the individual
> map_obj's, otherwise, we might be building the scatter-gather list with
> garbage. So, use the existing proc_lock for that.
> 
> I observed race conditions which caused kernel panics while running
> stress tests, also, Tuomas Kulve found it happening quite often in
> Gumstix Over. This patch fixes those.
> 
> Cc: Tuomas Kulve <tuomas@kulve.fi>
> Signed-off-by: Felipe Contreras <felipe.contreras@nokia.com>
> Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>

How about I send it to Linus for .39 and then add it to the .38-stable
tree when it comes out?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH] staging: tidspbridge: protect dmm_map properly
@ 2011-03-12  0:29 Omar Ramirez Luna
  2011-03-12 17:36 ` Greg KH
  0 siblings, 1 reply; 14+ messages in thread
From: Omar Ramirez Luna @ 2011-03-12  0:29 UTC (permalink / raw)
  To: Greg KH, l-m
  Cc: Felipe Contreras, l-o, Ohad Ben-Cohen, Fernando Guzman Lugo,
	Tuomas Kulve, Omar Ramirez Luna

Hi Greg,

Please consider to apply this patch in the staging tree, as the
description says it fixes a crash in tidspbridge driver, this bug
was already present but it seems to have surfaced by recent tests
made by Felipe and Tuomas.

It is an urgent fix for 2.6.38.

More on this discussion:
http://www.gossamer-threads.com/lists/linux/kernel/1351446

Thanks,
- omar

From: Felipe Contreras <felipe.contreras@nokia.com>

We need to protect not only the dmm_map list, but the individual
map_obj's, otherwise, we might be building the scatter-gather list with
garbage. So, use the existing proc_lock for that.

I observed race conditions which caused kernel panics while running
stress tests, also, Tuomas Kulve found it happening quite often in
Gumstix Over. This patch fixes those.

Cc: Tuomas Kulve <tuomas@kulve.fi>
Signed-off-by: Felipe Contreras <felipe.contreras@nokia.com>
Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 drivers/staging/tidspbridge/rmgr/proc.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/tidspbridge/rmgr/proc.c b/drivers/staging/tidspbridge/rmgr/proc.c
index b47d7aa..e2fe165 100644
--- a/drivers/staging/tidspbridge/rmgr/proc.c
+++ b/drivers/staging/tidspbridge/rmgr/proc.c
@@ -781,12 +781,14 @@ int proc_begin_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
 							(u32)pmpu_addr,
 							ul_size, dir);
 
+	mutex_lock(&proc_lock);
+
 	/* find requested memory are in cached mapping information */
 	map_obj = find_containing_mapping(pr_ctxt, (u32) pmpu_addr, ul_size);
 	if (!map_obj) {
 		pr_err("%s: find_containing_mapping failed\n", __func__);
 		status = -EFAULT;
-		goto err_out;
+		goto no_map;
 	}
 
 	if (memory_give_ownership(map_obj, (u32) pmpu_addr, ul_size, dir)) {
@@ -795,6 +797,8 @@ int proc_begin_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
 		status = -EFAULT;
 	}
 
+no_map:
+	mutex_unlock(&proc_lock);
 err_out:
 
 	return status;
@@ -819,21 +823,24 @@ int proc_end_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
 							(u32)pmpu_addr,
 							ul_size, dir);
 
+	mutex_lock(&proc_lock);
+
 	/* find requested memory are in cached mapping information */
 	map_obj = find_containing_mapping(pr_ctxt, (u32) pmpu_addr, ul_size);
 	if (!map_obj) {
 		pr_err("%s: find_containing_mapping failed\n", __func__);
 		status = -EFAULT;
-		goto err_out;
+		goto no_map;
 	}
 
 	if (memory_regain_ownership(map_obj, (u32) pmpu_addr, ul_size, dir)) {
 		pr_err("%s: InValid address parameters %p %x\n",
 		       __func__, pmpu_addr, ul_size);
 		status = -EFAULT;
-		goto err_out;
 	}
 
+no_map:
+	mutex_unlock(&proc_lock);
 err_out:
 	return status;
 }
@@ -1726,9 +1733,8 @@ int proc_un_map(void *hprocessor, void *map_addr,
 		    (p_proc_object->hbridge_context, va_align, size_align);
 	}
 
-	mutex_unlock(&proc_lock);
 	if (status)
-		goto func_end;
+		goto unmap_failed;
 
 	/*
 	 * A successful unmap should be followed by removal of map_obj
@@ -1737,6 +1743,9 @@ int proc_un_map(void *hprocessor, void *map_addr,
 	 */
 	remove_mapping_information(pr_ctxt, (u32) map_addr, size_align);
 
+unmap_failed:
+	mutex_unlock(&proc_lock);
+
 func_end:
 	dev_dbg(bridge, "%s: hprocessor: 0x%p map_addr: 0x%p status: 0x%x\n",
 		__func__, hprocessor, map_addr, status);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-03-14 15:54 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-20 17:12 [PATCH] staging: tidspbridge: protect dmm_map properly Felipe Contreras
2010-12-20 18:30 ` Kanigeri, Hari
2010-12-20 18:43   ` Felipe Contreras
2011-03-07 18:02 ` Felipe Contreras
2011-03-07 18:14   ` Ohad Ben-Cohen
2011-03-07 18:48   ` Greg KH
2011-03-07 19:29   ` Ramirez Luna, Omar
2011-03-07 21:48     ` Felipe Contreras
2011-03-12  0:29 Omar Ramirez Luna
2011-03-12 17:36 ` Greg KH
2011-03-12 23:42   ` Felipe Contreras
2011-03-13  1:06     ` Greg KH
2011-03-14 15:33       ` Felipe Contreras
2011-03-14 15:53         ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.