All of lore.kernel.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@nokia.com>
To: "Syrjala Ville (Nokia-D/Helsinki)" <ville.syrjala@nokia.com>
Cc: "Valkeinen Tomi (Nokia-D/Helsinki)" <Tomi.Valkeinen@nokia.com>,
	"linux-fbdev@vger.kernel.org" <linux-fbdev@vger.kernel.org>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>
Subject: Re: [PATCH v3 1/4] DSS2: OMAPFB: Add support for switching memory
Date: Thu, 18 Mar 2010 08:52:39 +0000	[thread overview]
Message-ID: <20100318085239.GE30422@localhost> (raw)
In-Reply-To: <20100317201425.GI18243@nokia.com>

On Wed, Mar 17, 2010 at 09:14:25PM +0100, Syrjala Ville (Nokia-D/Helsinki) wrote:
> On Wed, Mar 17, 2010 at 06:34:07PM +0100, Deak Imre (Nokia-D/Helsinki) wrote:
> > Hi,
> > 
> > couple of minor comments inlined.
> > 
> > On Fri, Mar 05, 2010 at 02:26:19PM +0100, Syrjala Ville (Nokia-D/Helsinki) wrote:
> > [...]
> > > @@ -115,30 +184,57 @@ static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi)
> > >         struct omapfb_info *ofbi = FB2OFB(fbi);
> > >         struct omapfb2_device *fbdev = ofbi->fbdev;
> > >         struct omapfb2_mem_region *rg;
> > > -       int r, i;
> > > +       int r = 0;
> > >         size_t size;
> > > +       int i;
> > > 
> > >         if (mi->type > OMAPFB_MEMTYPE_MAX)
> > >                 return -EINVAL;
> > > 
> > >         size = PAGE_ALIGN(mi->size);
> > > 
> > > -       rg = &ofbi->region;
> > > +       rg = ofbi->region;
> > > 
> > > -       for (i = 0; i < ofbi->num_overlays; i++) {
> > > -               if (ofbi->overlays[i]->info.enabled)
> > > -                       return -EBUSY;
> > > +       /* FIXME probably should be a rwsem ... */
> > > +       mutex_lock(&rg->mtx);
> > > +       while (rg->ref) {
> > > +               mutex_unlock(&rg->mtx);
> > > +               schedule();
> > > +               mutex_lock(&rg->mtx);
> > > +       }
> > 
> > Yes, rwsem would mean no unnecessary scheduling and also make things
> > clearer.
> 
> Just tried it and seems to be mostly OK. We get lockdep checking as a
> bonus. It didn't like setup_plane taking the same rwsem twice so I
> added a check to see if the old and new regions are the same and just
> lock once in that case. I thought rwsem was supposed to be OK with
> read recursion but perhaps I was mitaken, or perhaps it's just lockdep
> that's misbehaving.

Ah ok, so it's not so obvious change. Nested read locks could really lead
to a deadlock I think. A read lock will block if there is a write waiter
in the queue to avoid write starvation..

--Imre


WARNING: multiple messages have this Message-ID (diff)
From: Imre Deak <imre.deak@nokia.com>
To: "Syrjala Ville (Nokia-D/Helsinki)" <ville.syrjala@nokia.com>
Cc: "Valkeinen Tomi (Nokia-D/Helsinki)" <Tomi.Valkeinen@nokia.com>,
	"linux-fbdev@vger.kernel.org" <linux-fbdev@vger.kernel.org>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>
Subject: Re: [PATCH v3 1/4] DSS2: OMAPFB: Add support for switching memory regions
Date: Thu, 18 Mar 2010 10:52:39 +0200	[thread overview]
Message-ID: <20100318085239.GE30422@localhost> (raw)
In-Reply-To: <20100317201425.GI18243@nokia.com>

On Wed, Mar 17, 2010 at 09:14:25PM +0100, Syrjala Ville (Nokia-D/Helsinki) wrote:
> On Wed, Mar 17, 2010 at 06:34:07PM +0100, Deak Imre (Nokia-D/Helsinki) wrote:
> > Hi,
> > 
> > couple of minor comments inlined.
> > 
> > On Fri, Mar 05, 2010 at 02:26:19PM +0100, Syrjala Ville (Nokia-D/Helsinki) wrote:
> > [...]
> > > @@ -115,30 +184,57 @@ static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi)
> > >         struct omapfb_info *ofbi = FB2OFB(fbi);
> > >         struct omapfb2_device *fbdev = ofbi->fbdev;
> > >         struct omapfb2_mem_region *rg;
> > > -       int r, i;
> > > +       int r = 0;
> > >         size_t size;
> > > +       int i;
> > > 
> > >         if (mi->type > OMAPFB_MEMTYPE_MAX)
> > >                 return -EINVAL;
> > > 
> > >         size = PAGE_ALIGN(mi->size);
> > > 
> > > -       rg = &ofbi->region;
> > > +       rg = ofbi->region;
> > > 
> > > -       for (i = 0; i < ofbi->num_overlays; i++) {
> > > -               if (ofbi->overlays[i]->info.enabled)
> > > -                       return -EBUSY;
> > > +       /* FIXME probably should be a rwsem ... */
> > > +       mutex_lock(&rg->mtx);
> > > +       while (rg->ref) {
> > > +               mutex_unlock(&rg->mtx);
> > > +               schedule();
> > > +               mutex_lock(&rg->mtx);
> > > +       }
> > 
> > Yes, rwsem would mean no unnecessary scheduling and also make things
> > clearer.
> 
> Just tried it and seems to be mostly OK. We get lockdep checking as a
> bonus. It didn't like setup_plane taking the same rwsem twice so I
> added a check to see if the old and new regions are the same and just
> lock once in that case. I thought rwsem was supposed to be OK with
> read recursion but perhaps I was mitaken, or perhaps it's just lockdep
> that's misbehaving.

Ah ok, so it's not so obvious change. Nested read locks could really lead
to a deadlock I think. A read lock will block if there is a write waiter
in the queue to avoid write starvation..

--Imre


  reply	other threads:[~2010-03-18  8:52 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-05 13:26 [PATCH v3 1/4] DSS2: OMAPFB: Add support for switching memory regions ville.syrjala
2010-03-05 13:26 ` ville.syrjala
2010-03-05 13:26 ` [PATCH 2/4] DSS2: Check if display supports update mode changes ville.syrjala
2010-03-05 13:26   ` ville.syrjala
2010-03-05 13:26 ` [PATCH 3/4] DSS2: Make wait_for_go() succeed for disabled displays ville.syrjala
2010-03-05 13:26   ` ville.syrjala
2010-03-05 13:26 ` [PATCH 4/4] DSS2: clear spurious SYNC_LOST_DIGIT interrupts ville.syrjala
2010-03-05 13:26   ` ville.syrjala
2010-03-05 15:19   ` Aguirre, Sergio
2010-03-05 15:19     ` Aguirre, Sergio
2010-03-05 15:25     ` Tomi Valkeinen
2010-03-05 15:25       ` Tomi Valkeinen
2010-03-05 15:28       ` Aguirre, Sergio
2010-03-05 15:28         ` Aguirre, Sergio
2010-03-17 13:50 ` [PATCH v3 1/4] DSS2: OMAPFB: Add support for switching memory Tomi Valkeinen
2010-03-17 13:50   ` [PATCH v3 1/4] DSS2: OMAPFB: Add support for switching memory regions Tomi Valkeinen
2010-03-17 15:51   ` [PATCH v3 1/4] DSS2: OMAPFB: Add support for switching memory Ville Syrjälä
2010-03-17 15:51     ` [PATCH v3 1/4] DSS2: OMAPFB: Add support for switching memory regions Ville Syrjälä
2010-03-17 17:34 ` [PATCH v3 1/4] DSS2: OMAPFB: Add support for switching memory Imre Deak
2010-03-17 17:34   ` [PATCH v3 1/4] DSS2: OMAPFB: Add support for switching memory regions Imre Deak
2010-03-17 20:14   ` [PATCH v3 1/4] DSS2: OMAPFB: Add support for switching memory Ville Syrjälä
2010-03-17 20:14     ` [PATCH v3 1/4] DSS2: OMAPFB: Add support for switching memory regions Ville Syrjälä
2010-03-18  8:52     ` Imre Deak [this message]
2010-03-18  8:52       ` Imre Deak
2010-03-18 15:26       ` [PATCH v3 1/4] DSS2: OMAPFB: Add support for switching memory Ville Syrjälä
2010-03-18 15:26         ` [PATCH v3 1/4] DSS2: OMAPFB: Add support for switching memory regions Ville Syrjälä
2010-03-19  7:46         ` [PATCH v3 1/4] DSS2: OMAPFB: Add support for switching memory Imre Deak
2010-03-19  7:46           ` [PATCH v3 1/4] DSS2: OMAPFB: Add support for switching memory regions Imre Deak
2010-03-19 12:23           ` [PATCH v3 1/4] DSS2: OMAPFB: Add support for switching memory Ville Syrjälä
2010-03-19 12:23             ` [PATCH v3 1/4] DSS2: OMAPFB: Add support for switching memory regions Ville Syrjälä

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100318085239.GE30422@localhost \
    --to=imre.deak@nokia.com \
    --cc=Tomi.Valkeinen@nokia.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=ville.syrjala@nokia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.