Re: [Mesa3d-dev] [PATCH] Provide dri shared library building and SDK installation.

2010-04-10 Thread Keith Whitwell
I haven't been following this very closely, so apologies if I'm going
over established ground.

This patch appears to create new libraries from some subset of Mesa's
internals.  At a guess you're selecting some internal interface(s)
within mesa to become the public API of those libraries?  I'm pretty
sure that's not something we're trying to achieve in this project.

We have public APIs which we respect and implement, and which are
maintained and evolved under the Khronos umbrella.

We have a strong driver-level interface (ie gallium) which we benefit
greatly from being rev as fast and as hard as we can, to adapt to our
evolving understanding of the problem space.  We really don't want to
subject that interface to the strictures that come with becoming a
public API or ABI.

We have a third interface, the Mesa driver interface, which may appear
relatively stable, but which is more accurately described as
neglected, veering towards deprecated.  The shortcomings of this
interface, in particular its porous nature and inappropriate
abstraction level, were major catalysts provoking the development of
gallium.  Those shortcomings would also make it less than appropriate
as a public API.  At some point in the future, that interface will
either roar back into rapid evolution or truly be deprecated in favour
of either gallium or a low-level, legacy-free GL3/4 subset from
Khronos.

I can't easily tell from your patch what interfaces these new
libraries have, or what expectations there would be for maintaining
compatibility on those interfaces going forward.  I'd like to see that
spelled out explicitly.  Without investigating further, I can say I'm
not aware of any interface within Mesa which we'd be happy to promote
to a public interface, nor one which we'd be happy to accept extra
restrictions on in terms of compatibility.

Keith

On Fri, Apr 9, 2010 at 11:59 PM, Luc Verhaegen  wrote:
> Patch cherry-picked from my dri-sdk-7.8 branch against current head
> (edb5253dfa). An earlier full build through of all drivers (except
> nouveau, i will play with its expansive libdrm dependencies later)
> showed it to be an exact match still.
>
> This patch, while not harming or hampering anything or anyone, gives us
> the ability to maintain and build DRI drivers out of tree for those so
> inclined. Build system additions only. No adverse effects. Everybody
> wins.
>
> I intend to provide changes as needed, I hope to at least manage to
> maintain released versions in the long term.
>
> For those wanting a test run, please check out the 7.8 version of the
> SDK and the drivers in my cgit.freedesktop.org repos.
>
> Luc Verhaegen.
>
> --
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> ___
> Mesa3d-dev mailing list
> mesa3d-...@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mesa3d-dev
>
>
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/3] fbmem: fix aperture overlapping check

2010-04-10 Thread marcin . slusarz
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.

Signed-off-by: Marcin Slusarz 
Cc: Dave Airlie 
Cc: Peter Jones 
Cc: Andrew Morton 
---
 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
-- 
1.7.0.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/3] fbmem, drm/nouveau: kick firmware framebuffers as soon as possible

2010-04-10 Thread marcin . slusarz
Currently vesafb/efifb/... is kicked when hardware driver is registering
framebuffer. To do it hardware must be fully functional, so there's a short
window between start of initialisation and framebuffer registration when
two drivers touch the hardware. Unfortunately sometimes it breaks nouveau
initialisation.

Fix it by kicking firmware driver(s) before we start touching the hardware.

Reported-by: Didier Spaier 
Signed-off-by: Marcin Slusarz 
Cc: Ben Skeggs 
Cc: Dave Airlie 
Cc: Peter Jones 
Cc: Andrew Morton 
---
 drivers/gpu/drm/nouveau/nouveau_drv.h   |2 +
 drivers/gpu/drm/nouveau/nouveau_fbcon.c |   19 +-
 drivers/gpu/drm/nouveau/nouveau_state.c |   43 +++
 drivers/video/fbmem.c   |   43 ++-
 include/linux/fb.h  |1 +
 5 files changed, 72 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h 
b/drivers/gpu/drm/nouveau/nouveau_drv.h
index cb16a1b..a1f61f7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -621,6 +621,8 @@ struct drm_nouveau_private {
struct {
struct dentry *channel_root;
} debugfs;
+
+   struct apertures_struct *apertures;
 };
 
 static inline struct drm_nouveau_private *
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c 
b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 206368b..5e4367b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -195,7 +195,6 @@ nouveau_fbcon_create(struct drm_device *dev, uint32_t 
fb_width,
struct drm_mode_fb_cmd mode_cmd;
struct pci_dev *pdev = dev->pdev;
struct device *device = &pdev->dev;
-   struct apertures_struct *aper;
int size, ret;
 
mode_cmd.width = surface_width;
@@ -282,28 +281,12 @@ nouveau_fbcon_create(struct drm_device *dev, uint32_t 
fb_width,
info->fix.mmio_len = pci_resource_len(pdev, 1);
 
/* Set aperture base/size for vesafb takeover */
-   aper = info->apertures = alloc_apertures(3);
+   info->apertures = dev_priv->apertures;
if (!info->apertures) {
ret = -ENOMEM;
goto out_unref;
}
 
-   aper->ranges[0].base = pci_resource_start(pdev, 1);
-   aper->ranges[0].size = pci_resource_len(pdev, 1);
-   aper->count = 1;
-
-   if (pci_resource_len(pdev, 2)) {
-   aper->ranges[aper->count].base = pci_resource_start(pdev, 2);
-   aper->ranges[aper->count].size = pci_resource_len(pdev, 2);
-   aper->count++;
-   }
-
-   if (pci_resource_len(pdev, 3)) {
-   aper->ranges[aper->count].base = pci_resource_start(pdev, 3);
-   aper->ranges[aper->count].size = pci_resource_len(pdev, 3);
-   aper->count++;
-   }
-
info->pixmap.size = 64*1024;
info->pixmap.buf_align = 8;
info->pixmap.access_align = 32;
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c 
b/drivers/gpu/drm/nouveau/nouveau_state.c
index a9e9cf3..cfa3239 100644
--- a/drivers/gpu/drm/nouveau/nouveau_state.c
+++ b/drivers/gpu/drm/nouveau/nouveau_state.c
@@ -636,6 +636,43 @@ static void nouveau_OF_copy_vbios_to_ramin(struct 
drm_device *dev)
 #endif
 }
 
+static struct apertures_struct *nouveau_get_apertures(struct drm_device *dev)
+{
+   struct pci_dev *pdev = dev->pdev;
+   struct apertures_struct *aper = alloc_apertures(3);
+   if (!aper)
+   return NULL;
+
+   aper->ranges[0].base = pci_resource_start(pdev, 1);
+   aper->ranges[0].size = pci_resource_len(pdev, 1);
+   aper->count = 1;
+
+   if (pci_resource_len(pdev, 2)) {
+   aper->ranges[aper->count].base = pci_resource_start(pdev, 2);
+   aper->ranges[aper->count].size = pci_resource_len(pdev, 2);
+   aper->count++;
+   }
+
+   if (pci_resource_len(pdev, 3)) {
+   aper->ranges[aper->count].base = pci_resource_start(pdev, 3);
+   aper->ranges[aper->count].size = pci_resource_len(pdev, 3);
+   aper->count++;
+   }
+
+   return aper;
+}
+
+static int nouveau_remove_conflicting_drivers(struct drm_device *dev)
+{
+   struct drm_nouveau_private *dev_priv = dev->dev_private;
+   dev_priv->apertures = nouveau_get_apertures(dev);
+   if (!dev_priv->apertures)
+   return -ENOMEM;
+   
+   remove_conflicting_framebuffers(dev_priv->apertures, "nouveaufb");
+   return 0;
+}
+
 int nouveau_load(struct drm_device *dev, unsigned long flags)
 {
struct drm_nouveau_private *dev_priv;
@@ -723,6 +760,12 @@ int nouveau_load(struct drm_device *dev, unsigned long 
flags)
NV_INFO(dev, "Detected an NV%2x generation card (0x%08x)\n",
dev_priv->card_type, reg0);
 
+   if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+   int ret = nouveau_remove_confli

[PATCH 0/2] drm/radeon/kms: tex3D mipmap fix & R500 VAP regs

2010-04-10 Thread Marek Olšák
Hi devs,

The first attached patch fixes the calculation of mipmapped 3D texture sizes
in the CS checker, the 3rd dimension (depth) should be minified too. This
should probably go to 2.6.34.

The second patch adds 2 new regs:
- VAP_ALT_NUM_VERTICES, along with an update to the CS checker.
- VAP_INDEX_OFFSET, I don't think this one needs to be tracked, because we
have min/max vertex index clamping, but I might be wrong.

Both probably need a DRM version bump so that I can detect them in
userspace.

Please review.

-Marek
From 183a7e6cdff9f1ff379af114efc8c12f1f47d8a0 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Marek=20Ol=C5=A1=C3=A1k?= 
Date: Sun, 11 Apr 2010 03:18:52 +0200
Subject: [PATCH 1/2] drm/radeon/kms: fix calculation of mipmapped 3D texture sizes
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

The 3rd dimension should be minified too.

Signed-off-by: Marek Olšák 
---
 drivers/gpu/drm/radeon/r100.c |   15 ++-
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 3ae51ad..e40dbdc 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -2890,7 +2890,7 @@ static int r100_cs_track_texture_check(struct radeon_device *rdev,
 {
 	struct radeon_bo *robj;
 	unsigned long size;
-	unsigned u, i, w, h;
+	unsigned u, i, w, h, d;
 	int ret;
 
 	for (u = 0; u < track->num_texture; u++) {
@@ -2922,20 +2922,25 @@ static int r100_cs_track_texture_check(struct radeon_device *rdev,
 			h = h / (1 << i);
 			if (track->textures[u].roundup_h)
 h = roundup_pow_of_two(h);
+			if (track->textures[u].tex_coord_type == 1) {
+d = (1 << track->textures[u].txdepth) / (1 << i);
+if (!d)
+	d = 1;
+			} else {
+d = 1;
+			}
 			if (track->textures[u].compress_format) {
 
-size += r100_track_compress_size(track->textures[u].compress_format, w, h);
+size += r100_track_compress_size(track->textures[u].compress_format, w, h) * d;
 /* compressed textures are block based */
 			} else
-size += w * h;
+size += w * h * d;
 		}
 		size *= track->textures[u].cpp;
 
 		switch (track->textures[u].tex_coord_type) {
 		case 0:
-			break;
 		case 1:
-			size *= (1 << track->textures[u].txdepth);
 			break;
 		case 2:
 			if (track->separate_cube) {
-- 
1.6.3.3

From f12cc20b1bc29edb948559ae3369b69f00b44e66 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Marek=20Ol=C5=A1=C3=A1k?= 
Date: Sun, 21 Feb 2010 21:24:15 +0100
Subject: [PATCH 2/2] drm/radeon/kms: allow R500 regs VAP_ALT_NUM_VERTICES and VAP_INDEX_OFFSET
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Marek Olšák 
---
 drivers/gpu/drm/radeon/r100.c |6 +-
 drivers/gpu/drm/radeon/r100_track.h   |1 +
 drivers/gpu/drm/radeon/r300.c |5 -
 drivers/gpu/drm/radeon/reg_srcs/rv515 |2 ++
 4 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index e40dbdc..c06207e 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -3011,7 +3011,11 @@ int r100_cs_track_check(struct radeon_device *rdev, struct r100_cs_track *track)
 		}
 	}
 	prim_walk = (track->vap_vf_cntl >> 4) & 0x3;
-	nverts = (track->vap_vf_cntl >> 16) & 0x;
+	if (track->vap_vf_cntl & (1 << 14)) {
+		nverts = track->vap_alt_nverts;
+	} else {
+		nverts = (track->vap_vf_cntl >> 16) & 0x;
+	}
 	switch (prim_walk) {
 	case 1:
 		for (i = 0; i < track->num_arrays; i++) {
diff --git a/drivers/gpu/drm/radeon/r100_track.h b/drivers/gpu/drm/radeon/r100_track.h
index b27a699..fadfe68 100644
--- a/drivers/gpu/drm/radeon/r100_track.h
+++ b/drivers/gpu/drm/radeon/r100_track.h
@@ -64,6 +64,7 @@ struct r100_cs_track {
 	unsigned			maxy;
 	unsigned			vtx_size;
 	unsigned			vap_vf_cntl;
+	unsigned			vap_alt_nverts;
 	unsigned			immd_dwords;
 	unsigned			num_arrays;
 	unsigned			max_indx;
diff --git a/drivers/gpu/drm/radeon/r300.c b/drivers/gpu/drm/radeon/r300.c
index 0e9eb76..a47568a 100644
--- a/drivers/gpu/drm/radeon/r300.c
+++ b/drivers/gpu/drm/radeon/r300.c
@@ -729,6 +729,10 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
 		/* VAP_VF_MAX_VTX_INDX */
 		track->max_indx = idx_value & 0x00FFUL;
 		break;
+	case 0x2088:
+		/* VAP_ALT_NUM_VERTICES */
+		track->vap_alt_nverts = idx_value & 0xFF;
+		break;
 	case 0x43E4:
 		/* SC_SCISSOR1 */
 		track->maxy = ((idx_value >> 13) & 0x1FFF) + 1;
@@ -766,7 +770,6 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
 		tmp = idx_value & ~(0x7 << 16);
 		tmp |= tile_flags;
 		ib[idx] = tmp;
-
 		i = (reg - 0x4E38) >> 2;
 		track->cb[i].pitch = idx_value & 0x3FFE;
 		switch (((idx_value >> 21) & 0xF)) {
diff --git a/drivers/gpu/drm/radeon/reg_srcs/rv515 b/drivers/gpu/drm/radeon/reg_srcs/rv515
index 38abf63..a9e6f4c 100644
--- a/drivers/gpu/drm/radeon/reg_srcs/rv515
+++ b/drivers/gpu/drm/radeon/reg_srcs/rv

[PATCH] Provide dri shared library building and SDK installation.

2010-04-10 Thread Luc Verhaegen
Patch cherry-picked from my dri-sdk-7.8 branch against current head 
(edb5253dfa). An earlier full build through of all drivers (except 
nouveau, i will play with its expansive libdrm dependencies later) 
showed it to be an exact match still.

This patch, while not harming or hampering anything or anyone, gives us 
the ability to maintain and build DRI drivers out of tree for those so 
inclined. Build system additions only. No adverse effects. Everybody 
wins.

I intend to provide changes as needed, I hope to at least manage to 
maintain released versions in the long term.

For those wanting a test run, please check out the 7.8 version of the 
SDK and the drivers in my cgit.freedesktop.org repos.

Luc Verhaegen.


[Mesa3d-dev] [PATCH] Provide dri shared library building and SDK installation.

2010-04-10 Thread Keith Whitwell
I haven't been following this very closely, so apologies if I'm going
over established ground.

This patch appears to create new libraries from some subset of Mesa's
internals.  At a guess you're selecting some internal interface(s)
within mesa to become the public API of those libraries?  I'm pretty
sure that's not something we're trying to achieve in this project.

We have public APIs which we respect and implement, and which are
maintained and evolved under the Khronos umbrella.

We have a strong driver-level interface (ie gallium) which we benefit
greatly from being rev as fast and as hard as we can, to adapt to our
evolving understanding of the problem space.  We really don't want to
subject that interface to the strictures that come with becoming a
public API or ABI.

We have a third interface, the Mesa driver interface, which may appear
relatively stable, but which is more accurately described as
neglected, veering towards deprecated.  The shortcomings of this
interface, in particular its porous nature and inappropriate
abstraction level, were major catalysts provoking the development of
gallium.  Those shortcomings would also make it less than appropriate
as a public API.  At some point in the future, that interface will
either roar back into rapid evolution or truly be deprecated in favour
of either gallium or a low-level, legacy-free GL3/4 subset from
Khronos.

I can't easily tell from your patch what interfaces these new
libraries have, or what expectations there would be for maintaining
compatibility on those interfaces going forward.  I'd like to see that
spelled out explicitly.  Without investigating further, I can say I'm
not aware of any interface within Mesa which we'd be happy to promote
to a public interface, nor one which we'd be happy to accept extra
restrictions on in terms of compatibility.

Keith

On Fri, Apr 9, 2010 at 11:59 PM, Luc Verhaegen  wrote:
> Patch cherry-picked from my dri-sdk-7.8 branch against current head
> (edb5253dfa). An earlier full build through of all drivers (except
> nouveau, i will play with its expansive libdrm dependencies later)
> showed it to be an exact match still.
>
> This patch, while not harming or hampering anything or anyone, gives us
> the ability to maintain and build DRI drivers out of tree for those so
> inclined. Build system additions only. No adverse effects. Everybody
> wins.
>
> I intend to provide changes as needed, I hope to at least manage to
> maintain released versions in the long term.
>
> For those wanting a test run, please check out the 7.8 version of the
> SDK and the drivers in my cgit.freedesktop.org repos.
>
> Luc Verhaegen.
>
> --
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> ___
> Mesa3d-dev mailing list
> Mesa3d-dev at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mesa3d-dev
>
>


[PATCH 1/3] fbmem: fix aperture overlapping check

2010-04-10 Thread marcin.slus...@gmail.com
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.

Signed-off-by: Marcin Slusarz 
Cc: Dave Airlie 
Cc: Peter Jones 
Cc: Andrew Morton 
---
 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
-- 
1.7.0.4



[PATCH 3/3] fbmem, drm/nouveau: kick firmware framebuffers as soon as possible

2010-04-10 Thread marcin.slus...@gmail.com
Currently vesafb/efifb/... is kicked when hardware driver is registering
framebuffer. To do it hardware must be fully functional, so there's a short
window between start of initialisation and framebuffer registration when
two drivers touch the hardware. Unfortunately sometimes it breaks nouveau
initialisation.

Fix it by kicking firmware driver(s) before we start touching the hardware.

Reported-by: Didier Spaier 
Signed-off-by: Marcin Slusarz 
Cc: Ben Skeggs 
Cc: Dave Airlie 
Cc: Peter Jones 
Cc: Andrew Morton 
---
 drivers/gpu/drm/nouveau/nouveau_drv.h   |2 +
 drivers/gpu/drm/nouveau/nouveau_fbcon.c |   19 +-
 drivers/gpu/drm/nouveau/nouveau_state.c |   43 +++
 drivers/video/fbmem.c   |   43 ++-
 include/linux/fb.h  |1 +
 5 files changed, 72 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h 
b/drivers/gpu/drm/nouveau/nouveau_drv.h
index cb16a1b..a1f61f7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -621,6 +621,8 @@ struct drm_nouveau_private {
struct {
struct dentry *channel_root;
} debugfs;
+
+   struct apertures_struct *apertures;
 };

 static inline struct drm_nouveau_private *
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c 
b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 206368b..5e4367b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -195,7 +195,6 @@ nouveau_fbcon_create(struct drm_device *dev, uint32_t 
fb_width,
struct drm_mode_fb_cmd mode_cmd;
struct pci_dev *pdev = dev->pdev;
struct device *device = &pdev->dev;
-   struct apertures_struct *aper;
int size, ret;

mode_cmd.width = surface_width;
@@ -282,28 +281,12 @@ nouveau_fbcon_create(struct drm_device *dev, uint32_t 
fb_width,
info->fix.mmio_len = pci_resource_len(pdev, 1);

/* Set aperture base/size for vesafb takeover */
-   aper = info->apertures = alloc_apertures(3);
+   info->apertures = dev_priv->apertures;
if (!info->apertures) {
ret = -ENOMEM;
goto out_unref;
}

-   aper->ranges[0].base = pci_resource_start(pdev, 1);
-   aper->ranges[0].size = pci_resource_len(pdev, 1);
-   aper->count = 1;
-
-   if (pci_resource_len(pdev, 2)) {
-   aper->ranges[aper->count].base = pci_resource_start(pdev, 2);
-   aper->ranges[aper->count].size = pci_resource_len(pdev, 2);
-   aper->count++;
-   }
-
-   if (pci_resource_len(pdev, 3)) {
-   aper->ranges[aper->count].base = pci_resource_start(pdev, 3);
-   aper->ranges[aper->count].size = pci_resource_len(pdev, 3);
-   aper->count++;
-   }
-
info->pixmap.size = 64*1024;
info->pixmap.buf_align = 8;
info->pixmap.access_align = 32;
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c 
b/drivers/gpu/drm/nouveau/nouveau_state.c
index a9e9cf3..cfa3239 100644
--- a/drivers/gpu/drm/nouveau/nouveau_state.c
+++ b/drivers/gpu/drm/nouveau/nouveau_state.c
@@ -636,6 +636,43 @@ static void nouveau_OF_copy_vbios_to_ramin(struct 
drm_device *dev)
 #endif
 }

+static struct apertures_struct *nouveau_get_apertures(struct drm_device *dev)
+{
+   struct pci_dev *pdev = dev->pdev;
+   struct apertures_struct *aper = alloc_apertures(3);
+   if (!aper)
+   return NULL;
+
+   aper->ranges[0].base = pci_resource_start(pdev, 1);
+   aper->ranges[0].size = pci_resource_len(pdev, 1);
+   aper->count = 1;
+
+   if (pci_resource_len(pdev, 2)) {
+   aper->ranges[aper->count].base = pci_resource_start(pdev, 2);
+   aper->ranges[aper->count].size = pci_resource_len(pdev, 2);
+   aper->count++;
+   }
+
+   if (pci_resource_len(pdev, 3)) {
+   aper->ranges[aper->count].base = pci_resource_start(pdev, 3);
+   aper->ranges[aper->count].size = pci_resource_len(pdev, 3);
+   aper->count++;
+   }
+
+   return aper;
+}
+
+static int nouveau_remove_conflicting_drivers(struct drm_device *dev)
+{
+   struct drm_nouveau_private *dev_priv = dev->dev_private;
+   dev_priv->apertures = nouveau_get_apertures(dev);
+   if (!dev_priv->apertures)
+   return -ENOMEM;
+   
+   remove_conflicting_framebuffers(dev_priv->apertures, "nouveaufb");
+   return 0;
+}
+
 int nouveau_load(struct drm_device *dev, unsigned long flags)
 {
struct drm_nouveau_private *dev_priv;
@@ -723,6 +760,12 @@ int nouveau_load(struct drm_device *dev, unsigned long 
flags)
NV_INFO(dev, "Detected an NV%2x generation card (0x%08x)\n",
dev_priv->card_type, reg0);

+   if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+   int ret = nouveau_remove_conflicting_

[PATCH 2/3] fbdev: allow passing more than one aperture for handoff

2010-04-10 Thread marcin.slus...@gmail.com
It simplifies nouveau code by removal of detection which
region to pass to kick vesafb/efifb.

Signed-off-by: Marcin Slusarz 
Cc: Eric Anholt 
Cc: Ben Skeggs 
Cc: Thomas Hellstrom 
Cc: Dave Airlie 
Cc: Peter Jones 
Cc: Andrew Morton 
Cc: Benjamin Herrenschmidt 
---
 drivers/gpu/drm/i915/intel_fb.c |   11 +++-
 drivers/gpu/drm/nouveau/nouveau_fbcon.c |   84 +-
 drivers/gpu/drm/radeon/radeon_fb.c  |9 +++-
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c  |   10 +++-
 drivers/video/efifb.c   |   11 +++-
 drivers/video/fbmem.c   |   20 +++-
 drivers/video/fbsysfs.c |1 +
 drivers/video/offb.c|   28 ++
 drivers/video/vesafb.c  |   11 +++-
 include/linux/fb.h  |   16 +-
 10 files changed, 114 insertions(+), 87 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_fb.c b/drivers/gpu/drm/i915/intel_fb.c
index 8cd791d..a9192ab 100644
--- a/drivers/gpu/drm/i915/intel_fb.c
+++ b/drivers/gpu/drm/i915/intel_fb.c
@@ -192,11 +192,16 @@ static int intelfb_create(struct drm_device *dev, 
uint32_t fb_width,


/* setup aperture base/size for vesafb takeover */
-   info->aperture_base = dev->mode_config.fb_base;
+   info->apertures = alloc_apertures(1);
+   if (!info->apertures) {
+   ret = -ENOMEM;
+   goto out_unpin;
+   }
+   info->apertures->ranges[0].base = dev->mode_config.fb_base;
if (IS_I9XX(dev))
-   info->aperture_size = pci_resource_len(dev->pdev, 2);
+   info->apertures->ranges[0].size = pci_resource_len(dev->pdev, 
2);
else
-   info->aperture_size = pci_resource_len(dev->pdev, 0);
+   info->apertures->ranges[0].size = pci_resource_len(dev->pdev, 
0);

info->fix.smem_start = dev->mode_config.fb_base + obj_priv->gtt_offset;
info->fix.smem_len = size;
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c 
b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 68cedd9..206368b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -161,44 +161,6 @@ static struct drm_fb_helper_funcs 
nouveau_fbcon_helper_funcs = {
.gamma_get = nouveau_fbcon_gamma_get
 };

-#if defined(__i386__) || defined(__x86_64__)
-static bool
-nouveau_fbcon_has_vesafb_or_efifb(struct drm_device *dev)
-{
-   struct pci_dev *pdev = dev->pdev;
-   int ramin;
-
-   if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB &&
-   screen_info.orig_video_isVGA != VIDEO_TYPE_EFI)
-   return false;
-
-   if (screen_info.lfb_base < pci_resource_start(pdev, 1))
-   goto not_fb;
-
-   if (screen_info.lfb_base + screen_info.lfb_size >=
-   pci_resource_start(pdev, 1) + pci_resource_len(pdev, 1))
-   goto not_fb;
-
-   return true;
-not_fb:
-   ramin = 2;
-   if (pci_resource_len(pdev, ramin) == 0) {
-   ramin = 3;
-   if (pci_resource_len(pdev, ramin) == 0)
-   return false;
-   }
-
-   if (screen_info.lfb_base < pci_resource_start(pdev, ramin))
-   return false;
-
-   if (screen_info.lfb_base + screen_info.lfb_size >=
-   pci_resource_start(pdev, ramin) + pci_resource_len(pdev, ramin))
-   return false;
-
-   return true;
-}
-#endif
-
 void
 nouveau_fbcon_zfill(struct drm_device *dev)
 {
@@ -231,7 +193,9 @@ nouveau_fbcon_create(struct drm_device *dev, uint32_t 
fb_width,
struct nouveau_framebuffer *nouveau_fb;
struct nouveau_bo *nvbo;
struct drm_mode_fb_cmd mode_cmd;
-   struct device *device = &dev->pdev->dev;
+   struct pci_dev *pdev = dev->pdev;
+   struct device *device = &pdev->dev;
+   struct apertures_struct *aper;
int size, ret;

mode_cmd.width = surface_width;
@@ -314,28 +278,30 @@ nouveau_fbcon_create(struct drm_device *dev, uint32_t 
fb_width,
drm_fb_helper_fill_var(info, fb, fb_width, fb_height);

/* FIXME: we really shouldn't expose mmio space at all */
-   info->fix.mmio_start = pci_resource_start(dev->pdev, 1);
-   info->fix.mmio_len = pci_resource_len(dev->pdev, 1);
+   info->fix.mmio_start = pci_resource_start(pdev, 1);
+   info->fix.mmio_len = pci_resource_len(pdev, 1);

/* Set aperture base/size for vesafb takeover */
-#if defined(__i386__) || defined(__x86_64__)
-   if (nouveau_fbcon_has_vesafb_or_efifb(dev)) {
-   /* Some NVIDIA VBIOS' are stupid and decide to put the
-* framebuffer in the middle of the PRAMIN BAR for
-* whatever reason.  We need to know the exact lfb_base
-* to get vesafb kicked off, and the only reliable way
-* we have left is to find out lfb_base the same way
-* vesafb did.
-*/
-   info->aperture_base = sc