All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Airlie <airlied@redhat.com>
To: marcin.slusarz@gmail.com
Cc: LKML <linux-kernel@vger.kernel.org>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	nouveau@lists.freedesktop.org, linux-fbdev@vger.kernel.org,
	Peter Jones <pjones@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 1/3] fbmem: fix aperture overlapping check
Date: Mon, 12 Apr 2010 09:54:28 +1000	[thread overview]
Message-ID: <1271030068.3554.1.camel@localhost> (raw)
In-Reply-To: <1270929334-3742-1-git-send-email-marcin.slusarz@gmail.com>

On Sat, 2010-04-10 at 21:55 +0200, marcin.slusarz@gmail.com wrote:
> fb_do_apertures_overlap is returning wrong value when one aperture
> is completely whithin the other. Add generic ranges_overlap macro
> (probably kernel.h candidate) and use it here.
> 

That doesn't seem right.

The rules are:

the generic aperture has to be equal or smaller than the hw aperture,
otherwise the generic driver will be trashing random hw pieces on the
machine.

So with that in mind, the check makes sure the generic aperture starts
somewhere inside the hw aperture, which the test clearly gets right.

Have you got a pointer to a machine where it fails?

Dave.


> Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Peter Jones <pjones@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> ---
>  drivers/video/fbmem.c |   24 +++++++++++++++++-------
>  1 files changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
> index a15b44e..41f2e5e 100644
> --- a/drivers/video/fbmem.c
> +++ b/drivers/video/fbmem.c
> @@ -1468,15 +1468,25 @@ static int fb_check_foreignness(struct fb_info *fi)
>  	return 0;
>  }
>  
> +/**
> + * ranges_overlap - check whether two ranges overlap (their intersection is not empty)
> + * @start1: start of the first range
> + * @size1:  length of the first range
> + * @start2: start of the second range
> + * @size2:  length of the second range
> + */
> +#define ranges_overlap(start1, size1, start2, size2) ({	\
> +	typeof(start1) __start1 = (start1);		\
> +	typeof(size1)  __size1  = (size1);		\
> +	typeof(start2) __start2 = (start2);		\
> +	typeof(size2)  __size2  = (size2);		\
> +	__start1 < __start2 + __size2 && __start1 + __size1 > __start2; \
> +})
> +
>  static bool fb_do_apertures_overlap(struct fb_info *gen, struct fb_info *hw)
>  {
> -	/* is the generic aperture base the same as the HW one */
> -	if (gen->aperture_base == hw->aperture_base)
> -		return true;
> -	/* is the generic aperture base inside the hw base->hw base+size */
> -	if (gen->aperture_base > hw->aperture_base && gen->aperture_base <= hw->aperture_base + hw->aperture_size)
> -		return true;
> -	return false;
> +	return ranges_overlap(gen->aperture_base, gen->aperture_size,
> +				hw->aperture_base, hw->aperture_size);
>  }
>  /**
>   *	register_framebuffer - registers a frame buffer device



WARNING: multiple messages have this Message-ID (diff)
From: Dave Airlie <airlied@redhat.com>
To: marcin.slusarz@gmail.com
Cc: LKML <linux-kernel@vger.kernel.org>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	nouveau@lists.freedesktop.org, linux-fbdev@vger.kernel.org,
	Peter Jones <pjones@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 1/3] fbmem: fix aperture overlapping check
Date: Sun, 11 Apr 2010 23:54:28 +0000	[thread overview]
Message-ID: <1271030068.3554.1.camel@localhost> (raw)
In-Reply-To: <1270929334-3742-1-git-send-email-marcin.slusarz@gmail.com>

On Sat, 2010-04-10 at 21:55 +0200, marcin.slusarz@gmail.com wrote:
> fb_do_apertures_overlap is returning wrong value when one aperture
> is completely whithin the other. Add generic ranges_overlap macro
> (probably kernel.h candidate) and use it here.
> 

That doesn't seem right.

The rules are:

the generic aperture has to be equal or smaller than the hw aperture,
otherwise the generic driver will be trashing random hw pieces on the
machine.

So with that in mind, the check makes sure the generic aperture starts
somewhere inside the hw aperture, which the test clearly gets right.

Have you got a pointer to a machine where it fails?

Dave.


> Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Peter Jones <pjones@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> ---
>  drivers/video/fbmem.c |   24 +++++++++++++++++-------
>  1 files changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
> index a15b44e..41f2e5e 100644
> --- a/drivers/video/fbmem.c
> +++ b/drivers/video/fbmem.c
> @@ -1468,15 +1468,25 @@ static int fb_check_foreignness(struct fb_info *fi)
>  	return 0;
>  }
>  
> +/**
> + * ranges_overlap - check whether two ranges overlap (their intersection is not empty)
> + * @start1: start of the first range
> + * @size1:  length of the first range
> + * @start2: start of the second range
> + * @size2:  length of the second range
> + */
> +#define ranges_overlap(start1, size1, start2, size2) ({	\
> +	typeof(start1) __start1 = (start1);		\
> +	typeof(size1)  __size1  = (size1);		\
> +	typeof(start2) __start2 = (start2);		\
> +	typeof(size2)  __size2  = (size2);		\
> +	__start1 < __start2 + __size2 && __start1 + __size1 > __start2; \
> +})
> +
>  static bool fb_do_apertures_overlap(struct fb_info *gen, struct fb_info *hw)
>  {
> -	/* is the generic aperture base the same as the HW one */
> -	if (gen->aperture_base = hw->aperture_base)
> -		return true;
> -	/* is the generic aperture base inside the hw base->hw base+size */
> -	if (gen->aperture_base > hw->aperture_base && gen->aperture_base <= hw->aperture_base + hw->aperture_size)
> -		return true;
> -	return false;
> +	return ranges_overlap(gen->aperture_base, gen->aperture_size,
> +				hw->aperture_base, hw->aperture_size);
>  }
>  /**
>   *	register_framebuffer - registers a frame buffer device



  parent reply	other threads:[~2010-04-11 23:55 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-10 19:55 [PATCH 1/3] fbmem: fix aperture overlapping check marcin.slusarz
2010-04-10 19:55 ` marcin.slusarz
2010-04-10 19:55 ` marcin.slusarz
2010-04-10 19:55 ` [PATCH 2/3] fbdev: allow passing more than one aperture for handoff marcin.slusarz
2010-04-10 19:55 ` marcin.slusarz
2010-04-10 19:55   ` marcin.slusarz
2010-04-10 19:55 ` [PATCH 3/3] fbmem, drm/nouveau: kick firmware framebuffers as soon as possible marcin.slusarz
2010-04-10 19:55 ` marcin.slusarz
2010-04-10 19:55   ` marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w
2010-04-10 19:55   ` marcin.slusarz
2010-04-11 17:09   ` Marcin Slusarz
2010-04-11 17:09     ` Marcin Slusarz
2010-04-11 17:09     ` [PATCH 3/3] fbmem, drm/nouveau: kick firmware framebuffers as Marcin Slusarz
2010-04-11 23:54 ` Dave Airlie [this message]
2010-04-11 23:54   ` [PATCH 1/3] fbmem: fix aperture overlapping check Dave Airlie
2010-04-12 11:34   ` Marcin Slusarz
2010-04-12 11:34   ` Marcin Slusarz
2010-04-12 11:34     ` Marcin Slusarz
2010-04-12 11:34     ` Marcin Slusarz
2010-04-12 20:28     ` Dave Airlie
2010-04-12 20:28       ` Dave Airlie
2010-04-12 21:33       ` Marcin Slusarz
2010-04-12 21:33         ` Marcin Slusarz
2010-04-12 22:32         ` Dave Airlie
2010-04-12 22:32         ` Dave Airlie
2010-04-12 22:32           ` Dave Airlie
2010-04-12 22:32           ` Dave Airlie
2010-04-13 19:50         ` [PATCH] vga16fb, drm/nouveau: vga16fb->nouveau handoff Marcin Slusarz
2010-04-13 19:50           ` Marcin Slusarz
2010-04-18 21:57           ` [PATCH] vga16fb, drm: vga16fb->drm handoff Marcin Slusarz
2010-04-18 21:57             ` Marcin Slusarz
2010-04-19 16:20             ` James Simmons
2010-04-19 16:20               ` James Simmons
2010-04-19 16:20               ` James Simmons
2010-04-20 19:54               ` Marcin Slusarz
2010-04-20 19:54                 ` Marcin Slusarz
2010-04-20 19:54                 ` Marcin Slusarz
2010-04-12 11:34   ` [PATCH 1/3] fbmem: fix aperture overlapping check Marcin Slusarz
2010-04-11 23:54 ` Dave Airlie

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=1271030068.3554.1.camel@localhost \
    --to=airlied@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcin.slusarz@gmail.com \
    --cc=nouveau@lists.freedesktop.org \
    --cc=pjones@redhat.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.