drivers/gpu/drm/mgag200/mgag200_cursor.c:134:57: sparse: incorrect type in argument 1 (different address spaces)
Hey Dave, Do we care about these warnings? I'm not sure how to get around them. thanks, Chris P.S, this is my last day at Matrox, but I'll maintain it from another email. On Fri, Jun 21 2013, kbuild test robot wrote: > tree: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next master > head: 849aa58856855ae73d9654b2e675f2c7a6ad4c9b > commit: a080db9fdda77ffaa43679d21b4bd78ead0cf9e1 drm/mgag200: Hardware cursor > support > date: 4 days ago > > > sparse warnings: (new ones prefixed by >>) > >>> drivers/gpu/drm/mgag200/mgag200_cursor.c:134:57: sparse: incorrect type in >>> argument 1 (different address spaces) >drivers/gpu/drm/mgag200/mgag200_cursor.c:134:57:expected void > [noderef] * >drivers/gpu/drm/mgag200/mgag200_cursor.c:134:57:got void * >>> drivers/gpu/drm/mgag200/mgag200_cursor.c:200:65: sparse: incorrect type in >>> argument 1 (different address spaces) >drivers/gpu/drm/mgag200/mgag200_cursor.c:200:65:expected void > [noderef] * >drivers/gpu/drm/mgag200/mgag200_cursor.c:200:65:got void * >>> drivers/gpu/drm/mgag200/mgag200_cursor.c:218:55: sparse: incorrect type in >>> argument 1 (different address spaces) >drivers/gpu/drm/mgag200/mgag200_cursor.c:218:55:expected void volatile > [noderef] *dst >drivers/gpu/drm/mgag200/mgag200_cursor.c:218:55:got void * > > vim +134 drivers/gpu/drm/mgag200/mgag200_cursor.c > >128} >129} >130 >131memset(_set[0], 0, sizeof(uint32_t)*16); >132/* width*height*4 = 16384 */ >133for (i = 0; i < 16384; i += 4) { > > 134this_colour = ioread32(bo->kmap.virtual + i); >135/* No transparency */ >136if (this_colour>>24 != 0xff && >137this_colour>>24 != 0x0) { >138if (warn_transparent) { >139dev_info(>pdev->dev, > "Video card doesn't support cursors with partial transparency.\n"); >140dev_info(>pdev->dev, "Not > enabling hardware cursor.\n"); >141warn_transparent = false; /* > Only tell the user once. */ >142} >143ret = -EINVAL; >144goto out3; >145} >146/* Don't need to store transparent pixels as > colours */ >147if (this_colour>>24 == 0x0) >148continue; >149found = false; >150for (palette_iter = _set[0]; > palette_iter != next_space; palette_iter++) { >151if (*palette_iter == this_colour) { >152found = true; >153break; >154} >155} >156if (found) >157continue; >158/* We only support 4bit paletted cursors */ >159if (colour_count >= 16) { >160if (warn_palette) { >161dev_info(>pdev->dev, > "Video card only supports cursors with up to 16 colours.\n"); >162dev_info(>pdev->dev, "Not > enabling hardware cursor.\n"); >163warn_palette = false; /* Only > tell the user once. */ >164} >165ret = -EINVAL; >166goto out3; >167} >168*next_space = this_colour; >169next_space++; >170colour_count++; >171} >172 >173/* Program colours from cursor icon into palette */ >174for (i = 0; i < colour_count; i++) { >175if (i <= 2) >176reg_index = 0x8 + i*0x4; >177else >178reg_index = 0x60 + i*0x3; >179WREG_DAC(reg_index, colour_set[i] & 0xff); >180WREG_DAC(reg_index+1, colour_set[i]>>8 & 0xff); >181WREG_DAC(reg_index+2, colour_set[i]>>16 & 0xff); >182BUG_ON((colour_set[i]>>24 & 0xff) != 0xff); >183} >184 >185/* Map up-coming buffer to write colour indices */ >186if
Re: drivers/gpu/drm/mgag200/mgag200_cursor.c:134:57: sparse: incorrect type in argument 1 (different address spaces)
Hey Dave, Do we care about these warnings? I'm not sure how to get around them. thanks, Chris P.S, this is my last day at Matrox, but I'll maintain it from another email. On Fri, Jun 21 2013, kbuild test robot fengguang...@intel.com wrote: tree: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next master head: 849aa58856855ae73d9654b2e675f2c7a6ad4c9b commit: a080db9fdda77ffaa43679d21b4bd78ead0cf9e1 drm/mgag200: Hardware cursor support date: 4 days ago sparse warnings: (new ones prefixed by ) drivers/gpu/drm/mgag200/mgag200_cursor.c:134:57: sparse: incorrect type in argument 1 (different address spaces) drivers/gpu/drm/mgag200/mgag200_cursor.c:134:57:expected void [noderef] asn:2*noident drivers/gpu/drm/mgag200/mgag200_cursor.c:134:57:got void * drivers/gpu/drm/mgag200/mgag200_cursor.c:200:65: sparse: incorrect type in argument 1 (different address spaces) drivers/gpu/drm/mgag200/mgag200_cursor.c:200:65:expected void [noderef] asn:2*noident drivers/gpu/drm/mgag200/mgag200_cursor.c:200:65:got void * drivers/gpu/drm/mgag200/mgag200_cursor.c:218:55: sparse: incorrect type in argument 1 (different address spaces) drivers/gpu/drm/mgag200/mgag200_cursor.c:218:55:expected void volatile [noderef] asn:2*dst drivers/gpu/drm/mgag200/mgag200_cursor.c:218:55:got void * vim +134 drivers/gpu/drm/mgag200/mgag200_cursor.c 128} 129} 130 131memset(colour_set[0], 0, sizeof(uint32_t)*16); 132/* width*height*4 = 16384 */ 133for (i = 0; i 16384; i += 4) { 134this_colour = ioread32(bo-kmap.virtual + i); 135/* No transparency */ 136if (this_colour24 != 0xff 137this_colour24 != 0x0) { 138if (warn_transparent) { 139dev_info(dev-pdev-dev, Video card doesn't support cursors with partial transparency.\n); 140dev_info(dev-pdev-dev, Not enabling hardware cursor.\n); 141warn_transparent = false; /* Only tell the user once. */ 142} 143ret = -EINVAL; 144goto out3; 145} 146/* Don't need to store transparent pixels as colours */ 147if (this_colour24 == 0x0) 148continue; 149found = false; 150for (palette_iter = colour_set[0]; palette_iter != next_space; palette_iter++) { 151if (*palette_iter == this_colour) { 152found = true; 153break; 154} 155} 156if (found) 157continue; 158/* We only support 4bit paletted cursors */ 159if (colour_count = 16) { 160if (warn_palette) { 161dev_info(dev-pdev-dev, Video card only supports cursors with up to 16 colours.\n); 162dev_info(dev-pdev-dev, Not enabling hardware cursor.\n); 163warn_palette = false; /* Only tell the user once. */ 164} 165ret = -EINVAL; 166goto out3; 167} 168*next_space = this_colour; 169next_space++; 170colour_count++; 171} 172 173/* Program colours from cursor icon into palette */ 174for (i = 0; i colour_count; i++) { 175if (i = 2) 176reg_index = 0x8 + i*0x4; 177else 178reg_index = 0x60 + i*0x3; 179WREG_DAC(reg_index, colour_set[i] 0xff); 180WREG_DAC(reg_index+1, colour_set[i]8 0xff); 181WREG_DAC(reg_index+2, colour_set[i]16 0xff); 182BUG_ON((colour_set[i]24 0xff) != 0xff); 183} 184 185/* Map up-coming buffer to write colour indices */ 186if (!pixels_prev-kmap.virtual) { 187ret = ttm_bo_kmap(pixels_prev-bo,
[PATCH] drm/mgag200: Hardware cursor support
On Wed, Jun 05 2013, Christopher Harvey wrote: > G200 cards support, at best, 16 colour palleted images for the cursor > so we do a conversion in the cursor_set function, and reject cursors > with more than 16 colours, or cursors with partial transparency. Xorg > falls back gracefully to software cursors in this case. > > We can't disable/enable the cursor hardware without causing momentary > corruption around the cursor. Instead, once the cursor is on we leave > it on, and simulate turning the cursor off by moving it > offscreen. This works well. > > Since we can't disable -> update -> enable the cursors, we double > buffer cursor icons, then just move the base address that points to > the old cursor, to the new. This also works well, but uses an extra > page of memory. > > The cursor buffers are lazily-allocated on first cursor_set. This is > to make sure they don't take priority over any framebuffers in case of > limited memory. > > Here is a representation of how the bitmap for the cursor is mapped in G200 > memory : > > Each line of color cursor use 6 Slices of 8 bytes. Slices 0 to 3 > are used for the 4bpp bitmap, slice 4 for XOR mask and slice 5 for > AND mask. Each line has the following format: > > // Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7 > // > // S0: P00-01 P02-03 P04-05 P06-07 P08-09 P10-11 P12-13 P14-15 > // S1: P16-17 P18-19 P20-21 P22-23 P24-25 P26-27 P28-29 P30-31 > // S2: P32-33 P34-35 P36-37 P38-39 P40-41 P42-43 P44-45 P46-47 > // S3: P48-49 P50-51 P52-53 P54-55 P56-57 P58-59 P60-61 P62-63 > // S4: X63-56 X55-48 X47-40 X39-32 X31-24 X23-16 X15-08 X07-00 > // S5: A63-56 A55-48 A47-40 A39-32 A31-24 A23-16 A15-08 A07-00 > // > // S0 to S5 = Slices 0 to 5 > // P00 to P63= Bitmap - pixels 0 to 63 > // X00 to X63= always 0 - pixels 0 to 63 > // A00 to A63= transparent markers - pixels 0 to 63 > // 1 means colour, 0 means transparent > > Signed-off-by: Christopher Harvey > Signed-off-by: Mathieu Larouche > Acked-by: Julia Lemire > Tested-by: Julia Lemire ping.
[PATCH] drm/mgag200: Don't do full cleanup if mgag200_device_init fails
On Wed, Jun 05 2013, Christopher Harvey wrote: > Running mgag200_driver_unload when the driver init fails early on > causes functions like drm_mode_config_cleanup to be called. The > problem is, drm_mode_config_cleanup crashes because the corresponding > init hasn't happend yet. There really isn't anything to cleanup after > mgag200_device_init, so we can just pass the error code upwards. > > Acked-by: Julia Lemire > Signed-off-by: Christopher Harvey > --- > drivers/gpu/drm/mgag200/mgag200_main.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c > b/drivers/gpu/drm/mgag200/mgag200_main.c > index 5189675..6d6b598 100644 > --- a/drivers/gpu/drm/mgag200/mgag200_main.c > +++ b/drivers/gpu/drm/mgag200/mgag200_main.c > @@ -209,7 +209,7 @@ int mgag200_driver_load(struct drm_device *dev, unsigned > long flags) > r = mgag200_device_init(dev, flags); > if (r) { > dev_err(>pdev->dev, "Fatal error during GPU init: %d\n", > r); > - goto out; > + return r; > } > r = mgag200_mm_init(mdev); > if (r) ping.
Re: [PATCH] drm/mgag200: Don't do full cleanup if mgag200_device_init fails
On Wed, Jun 05 2013, Christopher Harvey char...@matrox.com wrote: Running mgag200_driver_unload when the driver init fails early on causes functions like drm_mode_config_cleanup to be called. The problem is, drm_mode_config_cleanup crashes because the corresponding init hasn't happend yet. There really isn't anything to cleanup after mgag200_device_init, so we can just pass the error code upwards. Acked-by: Julia Lemire jlem...@matrox.com Signed-off-by: Christopher Harvey char...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c index 5189675..6d6b598 100644 --- a/drivers/gpu/drm/mgag200/mgag200_main.c +++ b/drivers/gpu/drm/mgag200/mgag200_main.c @@ -209,7 +209,7 @@ int mgag200_driver_load(struct drm_device *dev, unsigned long flags) r = mgag200_device_init(dev, flags); if (r) { dev_err(dev-pdev-dev, Fatal error during GPU init: %d\n, r); - goto out; + return r; } r = mgag200_mm_init(mdev); if (r) ping. ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm/mgag200: Hardware cursor support
On Wed, Jun 05 2013, Christopher Harvey char...@matrox.com wrote: G200 cards support, at best, 16 colour palleted images for the cursor so we do a conversion in the cursor_set function, and reject cursors with more than 16 colours, or cursors with partial transparency. Xorg falls back gracefully to software cursors in this case. We can't disable/enable the cursor hardware without causing momentary corruption around the cursor. Instead, once the cursor is on we leave it on, and simulate turning the cursor off by moving it offscreen. This works well. Since we can't disable - update - enable the cursors, we double buffer cursor icons, then just move the base address that points to the old cursor, to the new. This also works well, but uses an extra page of memory. The cursor buffers are lazily-allocated on first cursor_set. This is to make sure they don't take priority over any framebuffers in case of limited memory. Here is a representation of how the bitmap for the cursor is mapped in G200 memory : Each line of color cursor use 6 Slices of 8 bytes. Slices 0 to 3 are used for the 4bpp bitmap, slice 4 for XOR mask and slice 5 for AND mask. Each line has the following format: // Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7 // // S0: P00-01 P02-03 P04-05 P06-07 P08-09 P10-11 P12-13 P14-15 // S1: P16-17 P18-19 P20-21 P22-23 P24-25 P26-27 P28-29 P30-31 // S2: P32-33 P34-35 P36-37 P38-39 P40-41 P42-43 P44-45 P46-47 // S3: P48-49 P50-51 P52-53 P54-55 P56-57 P58-59 P60-61 P62-63 // S4: X63-56 X55-48 X47-40 X39-32 X31-24 X23-16 X15-08 X07-00 // S5: A63-56 A55-48 A47-40 A39-32 A31-24 A23-16 A15-08 A07-00 // // S0 to S5 = Slices 0 to 5 // P00 to P63= Bitmap - pixels 0 to 63 // X00 to X63= always 0 - pixels 0 to 63 // A00 to A63= transparent markers - pixels 0 to 63 // 1 means colour, 0 means transparent Signed-off-by: Christopher Harvey char...@matrox.com Signed-off-by: Mathieu Larouche mathieu.larou...@matrox.com Acked-by: Julia Lemire jlem...@matrox.com Tested-by: Julia Lemire jlem...@matrox.com ping. ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] drm/mgag200: Hardware cursor support
G200 cards support, at best, 16 colour palleted images for the cursor so we do a conversion in the cursor_set function, and reject cursors with more than 16 colours, or cursors with partial transparency. Xorg falls back gracefully to software cursors in this case. We can't disable/enable the cursor hardware without causing momentary corruption around the cursor. Instead, once the cursor is on we leave it on, and simulate turning the cursor off by moving it offscreen. This works well. Since we can't disable -> update -> enable the cursors, we double buffer cursor icons, then just move the base address that points to the old cursor, to the new. This also works well, but uses an extra page of memory. The cursor buffers are lazily-allocated on first cursor_set. This is to make sure they don't take priority over any framebuffers in case of limited memory. Here is a representation of how the bitmap for the cursor is mapped in G200 memory : Each line of color cursor use 6 Slices of 8 bytes. Slices 0 to 3 are used for the 4bpp bitmap, slice 4 for XOR mask and slice 5 for AND mask. Each line has the following format: // Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7 // // S0: P00-01 P02-03 P04-05 P06-07 P08-09 P10-11 P12-13 P14-15 // S1: P16-17 P18-19 P20-21 P22-23 P24-25 P26-27 P28-29 P30-31 // S2: P32-33 P34-35 P36-37 P38-39 P40-41 P42-43 P44-45 P46-47 // S3: P48-49 P50-51 P52-53 P54-55 P56-57 P58-59 P60-61 P62-63 // S4: X63-56 X55-48 X47-40 X39-32 X31-24 X23-16 X15-08 X07-00 // S5: A63-56 A55-48 A47-40 A39-32 A31-24 A23-16 A15-08 A07-00 // // S0 to S5 = Slices 0 to 5 // P00 to P63= Bitmap - pixels 0 to 63 // X00 to X63= always 0 - pixels 0 to 63 // A00 to A63= transparent markers - pixels 0 to 63 // 1 means colour, 0 means transparent Signed-off-by: Christopher Harvey Signed-off-by: Mathieu Larouche Acked-by: Julia Lemire Tested-by: Julia Lemire --- drivers/gpu/drm/mgag200/Makefile | 2 +- drivers/gpu/drm/mgag200/mgag200_cursor.c | 275 +++ drivers/gpu/drm/mgag200/mgag200_drv.h| 21 +++ drivers/gpu/drm/mgag200/mgag200_main.c | 21 ++- drivers/gpu/drm/mgag200/mgag200_mode.c | 2 + drivers/gpu/drm/mgag200/mgag200_reg.h| 6 +- 6 files changed, 324 insertions(+), 3 deletions(-) create mode 100644 drivers/gpu/drm/mgag200/mgag200_cursor.c diff --git a/drivers/gpu/drm/mgag200/Makefile b/drivers/gpu/drm/mgag200/Makefile index 7db592e..a9a0300 100644 --- a/drivers/gpu/drm/mgag200/Makefile +++ b/drivers/gpu/drm/mgag200/Makefile @@ -1,5 +1,5 @@ ccflags-y := -Iinclude/drm -mgag200-y := mgag200_main.o mgag200_mode.o \ +mgag200-y := mgag200_main.o mgag200_mode.o mgag200_cursor.o \ mgag200_drv.o mgag200_fb.o mgag200_i2c.o mgag200_ttm.o obj-$(CONFIG_DRM_MGAG200) += mgag200.o diff --git a/drivers/gpu/drm/mgag200/mgag200_cursor.c b/drivers/gpu/drm/mgag200/mgag200_cursor.c new file mode 100644 index 000..801731a --- /dev/null +++ b/drivers/gpu/drm/mgag200/mgag200_cursor.c @@ -0,0 +1,275 @@ +/* + * Copyright 2013 Matrox Graphics + * + * This file is subject to the terms and conditions of the GNU General + * Public License version 2. See the file COPYING in the main + * directory of this archive for more details. + * + * Author: Christopher Harvey + */ + +#include +#include "mgag200_drv.h" + +static bool warn_transparent = true; +static bool warn_palette = true; + +/* + Hide the cursor off screen. We can't disable the cursor hardware because it + takes too long to re-activate and causes momentary corruption +*/ +static void mga_hide_cursor(struct mga_device *mdev) +{ + WREG8(MGA_CURPOSXL, 0); + WREG8(MGA_CURPOSXH, 0); + mgag200_bo_unpin(mdev->cursor.pixels_1); + mgag200_bo_unpin(mdev->cursor.pixels_2); +} + +int mga_crtc_cursor_set(struct drm_crtc *crtc, + struct drm_file *file_priv, + uint32_t handle, + uint32_t width, + uint32_t height) +{ + struct drm_device *dev = (struct drm_device *)file_priv->minor->dev; + struct mga_device *mdev = (struct mga_device *)dev->dev_private; + struct mgag200_bo *pixels_1 = mdev->cursor.pixels_1; + struct mgag200_bo *pixels_2 = mdev->cursor.pixels_2; + struct mgag200_bo *pixels_current = mdev->cursor.pixels_current; + struct mgag200_bo *pixels_prev = mdev->cursor.pixels_prev; + struct drm_gem_object *obj; + struct mgag200_bo *bo = NULL; + int ret = 0; + unsigned int i, row, col; + uint32_t colour_set[16]; + uint32_t *next_space = _set[0]; + uint32_t *palette_iter; + uint32_t this_colour; + bool found = false; + int colour_count = 0; + u64
[PATCH] drm/mgag200: Don't do full cleanup if mgag200_device_init fails
Running mgag200_driver_unload when the driver init fails early on causes functions like drm_mode_config_cleanup to be called. The problem is, drm_mode_config_cleanup crashes because the corresponding init hasn't happend yet. There really isn't anything to cleanup after mgag200_device_init, so we can just pass the error code upwards. Acked-by: Julia Lemire Signed-off-by: Christopher Harvey --- drivers/gpu/drm/mgag200/mgag200_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c index 5189675..6d6b598 100644 --- a/drivers/gpu/drm/mgag200/mgag200_main.c +++ b/drivers/gpu/drm/mgag200/mgag200_main.c @@ -209,7 +209,7 @@ int mgag200_driver_load(struct drm_device *dev, unsigned long flags) r = mgag200_device_init(dev, flags); if (r) { dev_err(>pdev->dev, "Fatal error during GPU init: %d\n", r); - goto out; + return r; } r = mgag200_mm_init(mdev); if (r) -- 1.8.1.5
[PATCH] drm/mgag200: Hardware cursor support
G200 cards support, at best, 16 colour palleted images for the cursor so we do a conversion in the cursor_set function, and reject cursors with more than 16 colours, or cursors with partial transparency. Xorg falls back gracefully to software cursors in this case. We can't disable/enable the cursor hardware without causing momentary corruption around the cursor. Instead, once the cursor is on we leave it on, and simulate turning the cursor off by moving it offscreen. This works well. Since we can't disable - update - enable the cursors, we double buffer cursor icons, then just move the base address that points to the old cursor, to the new. This also works well, but uses an extra page of memory. The cursor buffers are lazily-allocated on first cursor_set. This is to make sure they don't take priority over any framebuffers in case of limited memory. Here is a representation of how the bitmap for the cursor is mapped in G200 memory : Each line of color cursor use 6 Slices of 8 bytes. Slices 0 to 3 are used for the 4bpp bitmap, slice 4 for XOR mask and slice 5 for AND mask. Each line has the following format: // Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7 // // S0: P00-01 P02-03 P04-05 P06-07 P08-09 P10-11 P12-13 P14-15 // S1: P16-17 P18-19 P20-21 P22-23 P24-25 P26-27 P28-29 P30-31 // S2: P32-33 P34-35 P36-37 P38-39 P40-41 P42-43 P44-45 P46-47 // S3: P48-49 P50-51 P52-53 P54-55 P56-57 P58-59 P60-61 P62-63 // S4: X63-56 X55-48 X47-40 X39-32 X31-24 X23-16 X15-08 X07-00 // S5: A63-56 A55-48 A47-40 A39-32 A31-24 A23-16 A15-08 A07-00 // // S0 to S5 = Slices 0 to 5 // P00 to P63= Bitmap - pixels 0 to 63 // X00 to X63= always 0 - pixels 0 to 63 // A00 to A63= transparent markers - pixels 0 to 63 // 1 means colour, 0 means transparent Signed-off-by: Christopher Harvey char...@matrox.com Signed-off-by: Mathieu Larouche mathieu.larou...@matrox.com Acked-by: Julia Lemire jlem...@matrox.com Tested-by: Julia Lemire jlem...@matrox.com --- drivers/gpu/drm/mgag200/Makefile | 2 +- drivers/gpu/drm/mgag200/mgag200_cursor.c | 275 +++ drivers/gpu/drm/mgag200/mgag200_drv.h| 21 +++ drivers/gpu/drm/mgag200/mgag200_main.c | 21 ++- drivers/gpu/drm/mgag200/mgag200_mode.c | 2 + drivers/gpu/drm/mgag200/mgag200_reg.h| 6 +- 6 files changed, 324 insertions(+), 3 deletions(-) create mode 100644 drivers/gpu/drm/mgag200/mgag200_cursor.c diff --git a/drivers/gpu/drm/mgag200/Makefile b/drivers/gpu/drm/mgag200/Makefile index 7db592e..a9a0300 100644 --- a/drivers/gpu/drm/mgag200/Makefile +++ b/drivers/gpu/drm/mgag200/Makefile @@ -1,5 +1,5 @@ ccflags-y := -Iinclude/drm -mgag200-y := mgag200_main.o mgag200_mode.o \ +mgag200-y := mgag200_main.o mgag200_mode.o mgag200_cursor.o \ mgag200_drv.o mgag200_fb.o mgag200_i2c.o mgag200_ttm.o obj-$(CONFIG_DRM_MGAG200) += mgag200.o diff --git a/drivers/gpu/drm/mgag200/mgag200_cursor.c b/drivers/gpu/drm/mgag200/mgag200_cursor.c new file mode 100644 index 000..801731a --- /dev/null +++ b/drivers/gpu/drm/mgag200/mgag200_cursor.c @@ -0,0 +1,275 @@ +/* + * Copyright 2013 Matrox Graphics + * + * This file is subject to the terms and conditions of the GNU General + * Public License version 2. See the file COPYING in the main + * directory of this archive for more details. + * + * Author: Christopher Harvey char...@matrox.com + */ + +#include drm/drmP.h +#include mgag200_drv.h + +static bool warn_transparent = true; +static bool warn_palette = true; + +/* + Hide the cursor off screen. We can't disable the cursor hardware because it + takes too long to re-activate and causes momentary corruption +*/ +static void mga_hide_cursor(struct mga_device *mdev) +{ + WREG8(MGA_CURPOSXL, 0); + WREG8(MGA_CURPOSXH, 0); + mgag200_bo_unpin(mdev-cursor.pixels_1); + mgag200_bo_unpin(mdev-cursor.pixels_2); +} + +int mga_crtc_cursor_set(struct drm_crtc *crtc, + struct drm_file *file_priv, + uint32_t handle, + uint32_t width, + uint32_t height) +{ + struct drm_device *dev = (struct drm_device *)file_priv-minor-dev; + struct mga_device *mdev = (struct mga_device *)dev-dev_private; + struct mgag200_bo *pixels_1 = mdev-cursor.pixels_1; + struct mgag200_bo *pixels_2 = mdev-cursor.pixels_2; + struct mgag200_bo *pixels_current = mdev-cursor.pixels_current; + struct mgag200_bo *pixels_prev = mdev-cursor.pixels_prev; + struct drm_gem_object *obj; + struct mgag200_bo *bo = NULL; + int ret = 0; + unsigned int i, row, col; + uint32_t colour_set[16]; + uint32_t *next_space = colour_set[0]; + uint32_t *palette_iter; + uint32_t this_colour; + bool
[PATCH] drm/mgag200: Add missing write to index before accessing data register
On Fri, May 31 2013, Christopher Harvey wrote: > This is a bug fix for some versions of g200se cards while doing > mode-setting. > > Signed-off-by: Christopher Harvey > Tested-by: Julia Lemire > Acked-by: Julia Lemire Julia Lemire matrox.com> hmmm, feel free to delete the extra "Julia Lemire " before applying. (or I could just re-send) thanks
[PATCH] drm/mgag200: Add missing write to index before accessing data register
This is a bug fix for some versions of g200se cards while doing mode-setting. Signed-off-by: Christopher Harvey Tested-by: Julia Lemire Acked-by: Julia Lemire Julia Lemire --- drivers/gpu/drm/mgag200/mgag200_mode.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index deed0bd..5b1a9e7 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -1034,13 +1034,14 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc, else hi_pri_lvl = 5; - WREG8(0x1fde, 0x06); - WREG8(0x1fdf, hi_pri_lvl); + WREG8(MGAREG_CRTCEXT_INDEX, 0x06); + WREG8(MGAREG_CRTCEXT_DATA, hi_pri_lvl); } else { + WREG8(MGAREG_CRTCEXT_INDEX, 0x06); if (mdev->reg_1e24 >= 0x01) - WREG8(0x1fdf, 0x03); + WREG8(MGAREG_CRTCEXT_DATA, 0x03); else - WREG8(0x1fdf, 0x04); + WREG8(MGAREG_CRTCEXT_DATA, 0x04); } } return 0; -- 1.8.1.5
[PATCH] drm/mgag200: Add missing write to index before accessing data register
This is a bug fix for some versions of g200se cards while doing mode-setting. Signed-off-by: Christopher Harvey char...@matrox.com Tested-by: Julia Lemire jlem...@matrox.com Acked-by: Julia Lemire jlem...@matrox.comJulia Lemire jlem...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_mode.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index deed0bd..5b1a9e7 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -1034,13 +1034,14 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc, else hi_pri_lvl = 5; - WREG8(0x1fde, 0x06); - WREG8(0x1fdf, hi_pri_lvl); + WREG8(MGAREG_CRTCEXT_INDEX, 0x06); + WREG8(MGAREG_CRTCEXT_DATA, hi_pri_lvl); } else { + WREG8(MGAREG_CRTCEXT_INDEX, 0x06); if (mdev-reg_1e24 = 0x01) - WREG8(0x1fdf, 0x03); + WREG8(MGAREG_CRTCEXT_DATA, 0x03); else - WREG8(0x1fdf, 0x04); + WREG8(MGAREG_CRTCEXT_DATA, 0x04); } } return 0; -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm/mgag200: Add missing write to index before accessing data register
On Fri, May 31 2013, Christopher Harvey char...@matrox.com wrote: This is a bug fix for some versions of g200se cards while doing mode-setting. Signed-off-by: Christopher Harvey char...@matrox.com Tested-by: Julia Lemire jlem...@matrox.com Acked-by: Julia Lemire jlem...@matrox.comJulia Lemire jlem...@matrox.com hmmm, feel free to delete the extra Julia Lemire jlem...@matrox.com before applying. (or I could just re-send) thanks ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
picking efifb driver over dri driver
I'm looking for the mechanism in the kernel that makes the decision to load the efifb driver over a dri one. Any tips? I've got a machine here that loads efifb and prevents dri drivers from loading. thanks, Chris
picking efifb driver over dri driver
I'm looking for the mechanism in the kernel that makes the decision to load the efifb driver over a dri one. Any tips? I've got a machine here that loads efifb and prevents dri drivers from loading. thanks, Chris ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 2/4] drm/mgag200: Fix writes into MGA1064_PIX_CLK_CTL register
The original line, WREG_DAC(MGA1064_PIX_CLK_CTL_CLK_DIS, tmp); wrote tmp into MGA1064_PIX_CLK_CTL_CLK_DIS, where MGA1064_PIX_CLK_CTL_CLK_DIS is an offset into MGA1064_PIX_CLK_CTL. Change the line to write properly into MGA1064_PIX_CLK_CTL. There were other chunks of code nearby that use the same pattern (but work correctly), so this patch updates them all to use this new (slightly more efficient) write pattern. The WREG_DAC macro was causing the DAC_INDEX register to be set to the same value twice. WREG8(DAC_DATA, foo) takes advantage of the fact that DAC_INDEX is already at the value we want. Signed-off-by: Christopher Harvey Acked-by: Julia Lemire Tested-by: Julia Lemire Acked-by: Mathieu Larouche --- drivers/gpu/drm/mgag200/mgag200_mode.c | 42 +- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 2d9333d..6f3b9db 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -189,12 +189,12 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp |= MGA1064_PIX_CLK_CTL_CLK_DIS; - WREG_DAC(MGA1064_PIX_CLK_CTL_CLK_DIS, tmp); + WREG8(DAC_DATA, tmp); WREG8(DAC_INDEX, MGA1064_REMHEADCTL); tmp = RREG8(DAC_DATA); tmp |= MGA1064_REMHEADCTL_CLKDIS; - WREG_DAC(MGA1064_REMHEADCTL, tmp); + WREG8(DAC_DATA, tmp); /* select PLL Set C */ tmp = RREG8(MGAREG_MEM_MISC_READ); @@ -204,7 +204,7 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp |= MGA1064_PIX_CLK_CTL_CLK_POW_DOWN | 0x80; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); udelay(500); @@ -212,7 +212,7 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_VREF_CTL); tmp = RREG8(DAC_DATA); tmp &= ~0x04; - WREG_DAC(MGA1064_VREF_CTL, tmp); + WREG8(DAC_DATA, tmp); udelay(50); @@ -236,13 +236,13 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) tmp = RREG8(DAC_DATA); tmp &= ~MGA1064_PIX_CLK_CTL_SEL_MSK; tmp |= MGA1064_PIX_CLK_CTL_SEL_PLL; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); WREG8(DAC_INDEX, MGA1064_REMHEADCTL); tmp = RREG8(DAC_DATA); tmp &= ~MGA1064_REMHEADCTL_CLKSL_MSK; tmp |= MGA1064_REMHEADCTL_CLKSL_PLL; - WREG_DAC(MGA1064_REMHEADCTL, tmp); + WREG8(DAC_DATA, tmp); /* reset dotclock rate bit */ WREG8(MGAREG_SEQ_INDEX, 1); @@ -253,7 +253,7 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp &= ~MGA1064_PIX_CLK_CTL_CLK_DIS; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); vcount = RREG8(MGAREG_VCOUNT); @@ -318,7 +318,7 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp |= MGA1064_PIX_CLK_CTL_CLK_DIS; - WREG_DAC(MGA1064_PIX_CLK_CTL_CLK_DIS, tmp); + WREG8(DAC_DATA, tmp); tmp = RREG8(MGAREG_MEM_MISC_READ); tmp |= 0x3 << 2; @@ -326,12 +326,12 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_PLL_STAT); tmp = RREG8(DAC_DATA); - WREG_DAC(MGA1064_PIX_PLL_STAT, tmp & ~0x40); + WREG8(DAC_DATA, tmp & ~0x40); WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp |= MGA1064_PIX_CLK_CTL_CLK_POW_DOWN; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); WREG_DAC(MGA1064_EV_PIX_PLLC_M, m); WREG_DAC(MGA1064_EV_PIX_PLLC_N, n); @@ -342,7 +342,7 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp &= ~MGA1064_PIX_CLK_CTL_CLK_POW_DOWN; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); udelay(500); @@ -350,11 +350,11 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock) tmp = RREG8(DAC_DATA); tmp &= ~MGA1064_PIX_CLK_CTL_SEL_MSK; tmp |= MGA1064_PIX_CLK_CTL_SEL_PLL; - WREG_DAC(MG
[PATCH v2 1/4] drm/mgag200: Don't change unrelated registers during modeset
Registers in indices below 0x18 are totally unrelated to modesetting, so don't write 0's, or anything else into them on modeset. Most of these registers are hardware cursor related, so this existing code interferes with hardware cursor development. Signed-off-by: Christopher Harvey Tested-by: Julia Lemire Acked-by: Julia Lemire Acked-by: Mathieu Larouche --- drivers/gpu/drm/mgag200/mgag200_mode.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index f988965..2d9333d 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -829,11 +829,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc, for (i = 0; i < sizeof(dacvalue); i++) { - if ((i <= 0x03) || - (i == 0x07) || - (i == 0x0b) || - (i == 0x0f) || - ((i >= 0x13) && (i <= 0x17)) || + if ((i <= 0x17) || (i == 0x1b) || (i == 0x1c) || ((i >= 0x1f) && (i <= 0x29)) || -- 1.8.1.5
[PATCH 2/4] drm/mgag200: Fix writes into MGA1064_PIX_CLK_CTL register
The original line, WREG_DAC(MGA1064_PIX_CLK_CTL_CLK_DIS, tmp); wrote tmp into MGA1064_PIX_CLK_CTL_CLK_DIS, where MGA1064_PIX_CLK_CTL_CLK_DIS is an offset into MGA1064_PIX_CLK_CTL. Change the line to write properly into MGA1064_PIX_CLK_CTL. There were other chunks of code nearby that use the same pattern (but work correctly), so this patch updates them all to use this new (slightly more efficient) write pattern. The WREG_DAC macro was causing the DAC_INDEX register to be set to the same value twice. WREG8(DAC_DATA, foo) takes advantage of the fact that DAC_INDEX is already at the value we want. Signed-off-by: Christopher Harvey --- drivers/gpu/drm/mgag200/mgag200_mode.c | 42 +- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 2d9333d..6f3b9db 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -189,12 +189,12 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp |= MGA1064_PIX_CLK_CTL_CLK_DIS; - WREG_DAC(MGA1064_PIX_CLK_CTL_CLK_DIS, tmp); + WREG8(DAC_DATA, tmp); WREG8(DAC_INDEX, MGA1064_REMHEADCTL); tmp = RREG8(DAC_DATA); tmp |= MGA1064_REMHEADCTL_CLKDIS; - WREG_DAC(MGA1064_REMHEADCTL, tmp); + WREG8(DAC_DATA, tmp); /* select PLL Set C */ tmp = RREG8(MGAREG_MEM_MISC_READ); @@ -204,7 +204,7 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp |= MGA1064_PIX_CLK_CTL_CLK_POW_DOWN | 0x80; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); udelay(500); @@ -212,7 +212,7 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_VREF_CTL); tmp = RREG8(DAC_DATA); tmp &= ~0x04; - WREG_DAC(MGA1064_VREF_CTL, tmp); + WREG8(DAC_DATA, tmp); udelay(50); @@ -236,13 +236,13 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) tmp = RREG8(DAC_DATA); tmp &= ~MGA1064_PIX_CLK_CTL_SEL_MSK; tmp |= MGA1064_PIX_CLK_CTL_SEL_PLL; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); WREG8(DAC_INDEX, MGA1064_REMHEADCTL); tmp = RREG8(DAC_DATA); tmp &= ~MGA1064_REMHEADCTL_CLKSL_MSK; tmp |= MGA1064_REMHEADCTL_CLKSL_PLL; - WREG_DAC(MGA1064_REMHEADCTL, tmp); + WREG8(DAC_DATA, tmp); /* reset dotclock rate bit */ WREG8(MGAREG_SEQ_INDEX, 1); @@ -253,7 +253,7 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp &= ~MGA1064_PIX_CLK_CTL_CLK_DIS; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); vcount = RREG8(MGAREG_VCOUNT); @@ -318,7 +318,7 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp |= MGA1064_PIX_CLK_CTL_CLK_DIS; - WREG_DAC(MGA1064_PIX_CLK_CTL_CLK_DIS, tmp); + WREG8(DAC_DATA, tmp); tmp = RREG8(MGAREG_MEM_MISC_READ); tmp |= 0x3 << 2; @@ -326,12 +326,12 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_PLL_STAT); tmp = RREG8(DAC_DATA); - WREG_DAC(MGA1064_PIX_PLL_STAT, tmp & ~0x40); + WREG8(DAC_DATA, tmp & ~0x40); WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp |= MGA1064_PIX_CLK_CTL_CLK_POW_DOWN; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); WREG_DAC(MGA1064_EV_PIX_PLLC_M, m); WREG_DAC(MGA1064_EV_PIX_PLLC_N, n); @@ -342,7 +342,7 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp &= ~MGA1064_PIX_CLK_CTL_CLK_POW_DOWN; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); udelay(500); @@ -350,11 +350,11 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock) tmp = RREG8(DAC_DATA); tmp &= ~MGA1064_PIX_CLK_CTL_SEL_MSK; tmp |= MGA1064_PIX_CLK_CTL_SEL_PLL; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); WREG8(DAC_IND
[PATCH 1/4] drm/mgag200: Don't change unrelated registers during modeset
Registers in indices below 0x18 are totally unrelated to modesetting, so don't write 0's, or anything else into them on modeset. Most of these registers are hardware cursor related, so this existing code interferes with hardware cursor development. Signed-off-by: Christopher Harvey --- drivers/gpu/drm/mgag200/mgag200_mode.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index f988965..2d9333d 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -829,11 +829,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc, for (i = 0; i < sizeof(dacvalue); i++) { - if ((i <= 0x03) || - (i == 0x07) || - (i == 0x0b) || - (i == 0x0f) || - ((i >= 0x13) && (i <= 0x17)) || + if ((i <= 0x17) || (i == 0x1b) || (i == 0x1c) || ((i >= 0x1f) && (i <= 0x29)) || -- 1.8.1.5
[PATCH 0/4] mgag200 fixes
Christopher Harvey writes: > The Following should be CC'd to stable: > * drm/mgag200: Fix writes into MGA1064_PIX_CLK_CTL register > * drm/mgag200: Fix framebuffer base address programming > > The others are bug fixes, but aren't critical. I'm sitting on some > hardware cursor code that depends on all of these patches before it > can go in. I'm aiming for 3.11 for the hardware cursor support. > > thanks, > Christopher Harvey (4): > drm/mgag200: Don't change unrelated registers during modeset > drm/mgag200: Fix writes into MGA1064_PIX_CLK_CTL register > drm/mgag200: Convert counter delays to jiffies > drm/mgag200: Fix framebuffer base address programming > > drivers/gpu/drm/mgag200/mgag200_mode.c | 90 > -- > 1 file changed, 52 insertions(+), 38 deletions(-) please ignore this, version 2 has been posted. -C
[PATCH v2 0/4] *** SUBJECT HERE ***
I forgot to include some acked and tested-by lines in v1 of this series. No code changes in v2. thanks, Christopher Harvey (4): drm/mgag200: Don't change unrelated registers during modeset drm/mgag200: Fix writes into MGA1064_PIX_CLK_CTL register drm/mgag200: Convert counter delays to jiffies drm/mgag200: Fix framebuffer base address programming drivers/gpu/drm/mgag200/mgag200_mode.c | 90 -- 1 file changed, 52 insertions(+), 38 deletions(-) -- 1.8.1.5
[PATCH 0/4] mgag200 fixes
The Following should be CC'd to stable: * drm/mgag200: Fix writes into MGA1064_PIX_CLK_CTL register * drm/mgag200: Fix framebuffer base address programming The others are bug fixes, but aren't critical. I'm sitting on some hardware cursor code that depends on all of these patches before it can go in. I'm aiming for 3.11 for the hardware cursor support. thanks, Christopher Harvey (4): drm/mgag200: Don't change unrelated registers during modeset drm/mgag200: Fix writes into MGA1064_PIX_CLK_CTL register drm/mgag200: Convert counter delays to jiffies drm/mgag200: Fix framebuffer base address programming drivers/gpu/drm/mgag200/mgag200_mode.c | 90 -- 1 file changed, 52 insertions(+), 38 deletions(-) -- 1.8.1.5
[PATCH 0/4] mgag200 fixes
The Following should be CC'd to stable: * drm/mgag200: Fix writes into MGA1064_PIX_CLK_CTL register * drm/mgag200: Fix framebuffer base address programming The others are bug fixes, but aren't critical. I'm sitting on some hardware cursor code that depends on all of these patches before it can go in. I'm aiming for 3.11 for the hardware cursor support. thanks, Christopher Harvey (4): drm/mgag200: Don't change unrelated registers during modeset drm/mgag200: Fix writes into MGA1064_PIX_CLK_CTL register drm/mgag200: Convert counter delays to jiffies drm/mgag200: Fix framebuffer base address programming drivers/gpu/drm/mgag200/mgag200_mode.c | 90 -- 1 file changed, 52 insertions(+), 38 deletions(-) -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 1/4] drm/mgag200: Don't change unrelated registers during modeset
Registers in indices below 0x18 are totally unrelated to modesetting, so don't write 0's, or anything else into them on modeset. Most of these registers are hardware cursor related, so this existing code interferes with hardware cursor development. Signed-off-by: Christopher Harvey char...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_mode.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index f988965..2d9333d 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -829,11 +829,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc, for (i = 0; i sizeof(dacvalue); i++) { - if ((i = 0x03) || - (i == 0x07) || - (i == 0x0b) || - (i == 0x0f) || - ((i = 0x13) (i = 0x17)) || + if ((i = 0x17) || (i == 0x1b) || (i == 0x1c) || ((i = 0x1f) (i = 0x29)) || -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 2/4] drm/mgag200: Fix writes into MGA1064_PIX_CLK_CTL register
The original line, WREG_DAC(MGA1064_PIX_CLK_CTL_CLK_DIS, tmp); wrote tmp into MGA1064_PIX_CLK_CTL_CLK_DIS, where MGA1064_PIX_CLK_CTL_CLK_DIS is an offset into MGA1064_PIX_CLK_CTL. Change the line to write properly into MGA1064_PIX_CLK_CTL. There were other chunks of code nearby that use the same pattern (but work correctly), so this patch updates them all to use this new (slightly more efficient) write pattern. The WREG_DAC macro was causing the DAC_INDEX register to be set to the same value twice. WREG8(DAC_DATA, foo) takes advantage of the fact that DAC_INDEX is already at the value we want. Signed-off-by: Christopher Harvey char...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_mode.c | 42 +- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 2d9333d..6f3b9db 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -189,12 +189,12 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp |= MGA1064_PIX_CLK_CTL_CLK_DIS; - WREG_DAC(MGA1064_PIX_CLK_CTL_CLK_DIS, tmp); + WREG8(DAC_DATA, tmp); WREG8(DAC_INDEX, MGA1064_REMHEADCTL); tmp = RREG8(DAC_DATA); tmp |= MGA1064_REMHEADCTL_CLKDIS; - WREG_DAC(MGA1064_REMHEADCTL, tmp); + WREG8(DAC_DATA, tmp); /* select PLL Set C */ tmp = RREG8(MGAREG_MEM_MISC_READ); @@ -204,7 +204,7 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp |= MGA1064_PIX_CLK_CTL_CLK_POW_DOWN | 0x80; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); udelay(500); @@ -212,7 +212,7 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_VREF_CTL); tmp = RREG8(DAC_DATA); tmp = ~0x04; - WREG_DAC(MGA1064_VREF_CTL, tmp); + WREG8(DAC_DATA, tmp); udelay(50); @@ -236,13 +236,13 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) tmp = RREG8(DAC_DATA); tmp = ~MGA1064_PIX_CLK_CTL_SEL_MSK; tmp |= MGA1064_PIX_CLK_CTL_SEL_PLL; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); WREG8(DAC_INDEX, MGA1064_REMHEADCTL); tmp = RREG8(DAC_DATA); tmp = ~MGA1064_REMHEADCTL_CLKSL_MSK; tmp |= MGA1064_REMHEADCTL_CLKSL_PLL; - WREG_DAC(MGA1064_REMHEADCTL, tmp); + WREG8(DAC_DATA, tmp); /* reset dotclock rate bit */ WREG8(MGAREG_SEQ_INDEX, 1); @@ -253,7 +253,7 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp = ~MGA1064_PIX_CLK_CTL_CLK_DIS; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); vcount = RREG8(MGAREG_VCOUNT); @@ -318,7 +318,7 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp |= MGA1064_PIX_CLK_CTL_CLK_DIS; - WREG_DAC(MGA1064_PIX_CLK_CTL_CLK_DIS, tmp); + WREG8(DAC_DATA, tmp); tmp = RREG8(MGAREG_MEM_MISC_READ); tmp |= 0x3 2; @@ -326,12 +326,12 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_PLL_STAT); tmp = RREG8(DAC_DATA); - WREG_DAC(MGA1064_PIX_PLL_STAT, tmp ~0x40); + WREG8(DAC_DATA, tmp ~0x40); WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp |= MGA1064_PIX_CLK_CTL_CLK_POW_DOWN; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); WREG_DAC(MGA1064_EV_PIX_PLLC_M, m); WREG_DAC(MGA1064_EV_PIX_PLLC_N, n); @@ -342,7 +342,7 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp = ~MGA1064_PIX_CLK_CTL_CLK_POW_DOWN; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); udelay(500); @@ -350,11 +350,11 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock) tmp = RREG8(DAC_DATA); tmp = ~MGA1064_PIX_CLK_CTL_SEL_MSK; tmp |= MGA1064_PIX_CLK_CTL_SEL_PLL; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); WREG8(DAC_INDEX
[PATCH 3/4] drm/mgag200: Convert counter delays to jiffies
Signed-off-by: Christopher Harvey char...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_mode.c | 15 ++- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 6f3b9db..6dbf6de 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -46,29 +46,26 @@ static void mga_crtc_load_lut(struct drm_crtc *crtc) static inline void mga_wait_vsync(struct mga_device *mdev) { - unsigned int count = 0; + unsigned long timeout = jiffies + HZ/10; unsigned int status = 0; do { status = RREG32(MGAREG_Status); - count++; - } while ((status 0x08) (count 25)); - count = 0; + } while ((status 0x08) time_before(jiffies, timeout)); + timeout = jiffies + HZ/10; status = 0; do { status = RREG32(MGAREG_Status); - count++; - } while (!(status 0x08) (count 25)); + } while (!(status 0x08) time_before(jiffies, timeout)); } static inline void mga_wait_busy(struct mga_device *mdev) { - unsigned int count = 0; + unsigned long timeout = jiffies + HZ; unsigned int status = 0; do { status = RREG8(MGAREG_Status + 2); - count++; - } while ((status 0x01) (count 50)); + } while ((status 0x01) time_before(jiffies, timeout)); } /* -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 4/4] drm/mgag200: Fix framebuffer base address programming
Higher bits of the base address of framebuffers weren't being programmed properly. This caused framebuffers that didn't happen to be allocated at a low enough address to not be displayed properly. Signed-off-by: Christopher Harvey char...@matrox.com Signed-off-by: Mathieu Larouche mathieu.larou...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_mode.c | 27 --- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 6dbf6de..77b8a45 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -654,12 +654,26 @@ static void mga_g200wb_commit(struct drm_crtc *crtc) WREG_DAC(MGA1064_GEN_IO_DATA, tmp); } - +/* + This is how the framebuffer base address is stored in g200 cards: + * Assume @offset is the gpu_addr variable of the framebuffer object + * Then addr is the number of _pixels_ (not bytes) from the start of + VRAM to the first pixel we want to display. (divided by 2 for 32bit + framebuffers) + * addr is stored in the CRTCEXT0, CRTCC and CRTCD registers + addr20 - CRTCEXT06 + addr19-16 - CRTCEXT03-0 + addr15-8 - CRTCC7-0 + addr7-0 - CRTCD7-0 + CRTCEXT0 has to be programmed last to trigger an update and make the + new addr variable take effect. + */ void mga_set_start_address(struct drm_crtc *crtc, unsigned offset) { struct mga_device *mdev = crtc-dev-dev_private; u32 addr; int count; + u8 crtcext0; while (RREG8(0x1fda) 0x08); while (!(RREG8(0x1fda) 0x08)); @@ -667,10 +681,17 @@ void mga_set_start_address(struct drm_crtc *crtc, unsigned offset) count = RREG8(MGAREG_VCOUNT) + 2; while (RREG8(MGAREG_VCOUNT) count); - addr = offset 2; + WREG8(MGAREG_CRTCEXT_INDEX, 0); + crtcext0 = RREG8(MGAREG_CRTCEXT_DATA); + crtcext0 = 0xB0; + addr = offset / 8; + /* Can't store addresses any higher than that... + but we also don't have more than 16MB of memory, so it should be fine. */ + WARN_ON(addr 0x1f); + crtcext0 |= (!!(addr (120)))6; WREG_CRT(0x0d, (u8)(addr 0xff)); WREG_CRT(0x0c, (u8)(addr 8) 0xff); - WREG_CRT(0xaf, (u8)(addr 16) 0xf); + WREG_ECRT(0x0, ((u8)(addr 16) 0xf) | crtcext0); } -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 0/4] *** SUBJECT HERE ***
I forgot to include some acked and tested-by lines in v1 of this series. No code changes in v2. thanks, Christopher Harvey (4): drm/mgag200: Don't change unrelated registers during modeset drm/mgag200: Fix writes into MGA1064_PIX_CLK_CTL register drm/mgag200: Convert counter delays to jiffies drm/mgag200: Fix framebuffer base address programming drivers/gpu/drm/mgag200/mgag200_mode.c | 90 -- 1 file changed, 52 insertions(+), 38 deletions(-) -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 1/4] drm/mgag200: Don't change unrelated registers during modeset
Registers in indices below 0x18 are totally unrelated to modesetting, so don't write 0's, or anything else into them on modeset. Most of these registers are hardware cursor related, so this existing code interferes with hardware cursor development. Signed-off-by: Christopher Harvey char...@matrox.com Tested-by: Julia Lemire jlem...@matrox.com Acked-by: Julia Lemire jlem...@matrox.com Acked-by: Mathieu Larouche mathieu.larou...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_mode.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index f988965..2d9333d 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -829,11 +829,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc, for (i = 0; i sizeof(dacvalue); i++) { - if ((i = 0x03) || - (i == 0x07) || - (i == 0x0b) || - (i == 0x0f) || - ((i = 0x13) (i = 0x17)) || + if ((i = 0x17) || (i == 0x1b) || (i == 0x1c) || ((i = 0x1f) (i = 0x29)) || -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 2/4] drm/mgag200: Fix writes into MGA1064_PIX_CLK_CTL register
The original line, WREG_DAC(MGA1064_PIX_CLK_CTL_CLK_DIS, tmp); wrote tmp into MGA1064_PIX_CLK_CTL_CLK_DIS, where MGA1064_PIX_CLK_CTL_CLK_DIS is an offset into MGA1064_PIX_CLK_CTL. Change the line to write properly into MGA1064_PIX_CLK_CTL. There were other chunks of code nearby that use the same pattern (but work correctly), so this patch updates them all to use this new (slightly more efficient) write pattern. The WREG_DAC macro was causing the DAC_INDEX register to be set to the same value twice. WREG8(DAC_DATA, foo) takes advantage of the fact that DAC_INDEX is already at the value we want. Signed-off-by: Christopher Harvey char...@matrox.com Acked-by: Julia Lemire jlem...@matrox.com Tested-by: Julia Lemire jlem...@matrox.com Acked-by: Mathieu Larouche mathieu.larou...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_mode.c | 42 +- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 2d9333d..6f3b9db 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -189,12 +189,12 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp |= MGA1064_PIX_CLK_CTL_CLK_DIS; - WREG_DAC(MGA1064_PIX_CLK_CTL_CLK_DIS, tmp); + WREG8(DAC_DATA, tmp); WREG8(DAC_INDEX, MGA1064_REMHEADCTL); tmp = RREG8(DAC_DATA); tmp |= MGA1064_REMHEADCTL_CLKDIS; - WREG_DAC(MGA1064_REMHEADCTL, tmp); + WREG8(DAC_DATA, tmp); /* select PLL Set C */ tmp = RREG8(MGAREG_MEM_MISC_READ); @@ -204,7 +204,7 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp |= MGA1064_PIX_CLK_CTL_CLK_POW_DOWN | 0x80; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); udelay(500); @@ -212,7 +212,7 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_VREF_CTL); tmp = RREG8(DAC_DATA); tmp = ~0x04; - WREG_DAC(MGA1064_VREF_CTL, tmp); + WREG8(DAC_DATA, tmp); udelay(50); @@ -236,13 +236,13 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) tmp = RREG8(DAC_DATA); tmp = ~MGA1064_PIX_CLK_CTL_SEL_MSK; tmp |= MGA1064_PIX_CLK_CTL_SEL_PLL; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); WREG8(DAC_INDEX, MGA1064_REMHEADCTL); tmp = RREG8(DAC_DATA); tmp = ~MGA1064_REMHEADCTL_CLKSL_MSK; tmp |= MGA1064_REMHEADCTL_CLKSL_PLL; - WREG_DAC(MGA1064_REMHEADCTL, tmp); + WREG8(DAC_DATA, tmp); /* reset dotclock rate bit */ WREG8(MGAREG_SEQ_INDEX, 1); @@ -253,7 +253,7 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp = ~MGA1064_PIX_CLK_CTL_CLK_DIS; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); vcount = RREG8(MGAREG_VCOUNT); @@ -318,7 +318,7 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp |= MGA1064_PIX_CLK_CTL_CLK_DIS; - WREG_DAC(MGA1064_PIX_CLK_CTL_CLK_DIS, tmp); + WREG8(DAC_DATA, tmp); tmp = RREG8(MGAREG_MEM_MISC_READ); tmp |= 0x3 2; @@ -326,12 +326,12 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_PLL_STAT); tmp = RREG8(DAC_DATA); - WREG_DAC(MGA1064_PIX_PLL_STAT, tmp ~0x40); + WREG8(DAC_DATA, tmp ~0x40); WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp |= MGA1064_PIX_CLK_CTL_CLK_POW_DOWN; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); WREG_DAC(MGA1064_EV_PIX_PLLC_M, m); WREG_DAC(MGA1064_EV_PIX_PLLC_N, n); @@ -342,7 +342,7 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock) WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); tmp = RREG8(DAC_DATA); tmp = ~MGA1064_PIX_CLK_CTL_CLK_POW_DOWN; - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); + WREG8(DAC_DATA, tmp); udelay(500); @@ -350,11 +350,11 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock) tmp = RREG8(DAC_DATA); tmp = ~MGA1064_PIX_CLK_CTL_SEL_MSK; tmp
[PATCH v2 3/4] drm/mgag200: Convert counter delays to jiffies
Signed-off-by: Christopher Harvey char...@matrox.com Acked-by: Julia Lemire jlem...@matrox.com Tested-by: Julia Lemire jlem...@matrox.com Acked-by: Mathieu Larouche mathieu.larou...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_mode.c | 15 ++- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 6f3b9db..6dbf6de 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -46,29 +46,26 @@ static void mga_crtc_load_lut(struct drm_crtc *crtc) static inline void mga_wait_vsync(struct mga_device *mdev) { - unsigned int count = 0; + unsigned long timeout = jiffies + HZ/10; unsigned int status = 0; do { status = RREG32(MGAREG_Status); - count++; - } while ((status 0x08) (count 25)); - count = 0; + } while ((status 0x08) time_before(jiffies, timeout)); + timeout = jiffies + HZ/10; status = 0; do { status = RREG32(MGAREG_Status); - count++; - } while (!(status 0x08) (count 25)); + } while (!(status 0x08) time_before(jiffies, timeout)); } static inline void mga_wait_busy(struct mga_device *mdev) { - unsigned int count = 0; + unsigned long timeout = jiffies + HZ; unsigned int status = 0; do { status = RREG8(MGAREG_Status + 2); - count++; - } while ((status 0x01) (count 50)); + } while ((status 0x01) time_before(jiffies, timeout)); } /* -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 4/4] drm/mgag200: Fix framebuffer base address programming
Higher bits of the base address of framebuffers weren't being programmed properly. This caused framebuffers that didn't happen to be allocated at a low enough address to not be displayed properly. Signed-off-by: Christopher Harvey char...@matrox.com Signed-off-by: Mathieu Larouche mathieu.larou...@matrox.com Acked-by: Julia Lemire jlem...@matrox.com Tested-by: Julia Lemire jlem...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_mode.c | 27 --- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 6dbf6de..77b8a45 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -654,12 +654,26 @@ static void mga_g200wb_commit(struct drm_crtc *crtc) WREG_DAC(MGA1064_GEN_IO_DATA, tmp); } - +/* + This is how the framebuffer base address is stored in g200 cards: + * Assume @offset is the gpu_addr variable of the framebuffer object + * Then addr is the number of _pixels_ (not bytes) from the start of + VRAM to the first pixel we want to display. (divided by 2 for 32bit + framebuffers) + * addr is stored in the CRTCEXT0, CRTCC and CRTCD registers + addr20 - CRTCEXT06 + addr19-16 - CRTCEXT03-0 + addr15-8 - CRTCC7-0 + addr7-0 - CRTCD7-0 + CRTCEXT0 has to be programmed last to trigger an update and make the + new addr variable take effect. + */ void mga_set_start_address(struct drm_crtc *crtc, unsigned offset) { struct mga_device *mdev = crtc-dev-dev_private; u32 addr; int count; + u8 crtcext0; while (RREG8(0x1fda) 0x08); while (!(RREG8(0x1fda) 0x08)); @@ -667,10 +681,17 @@ void mga_set_start_address(struct drm_crtc *crtc, unsigned offset) count = RREG8(MGAREG_VCOUNT) + 2; while (RREG8(MGAREG_VCOUNT) count); - addr = offset 2; + WREG8(MGAREG_CRTCEXT_INDEX, 0); + crtcext0 = RREG8(MGAREG_CRTCEXT_DATA); + crtcext0 = 0xB0; + addr = offset / 8; + /* Can't store addresses any higher than that... + but we also don't have more than 16MB of memory, so it should be fine. */ + WARN_ON(addr 0x1f); + crtcext0 |= (!!(addr (120)))6; WREG_CRT(0x0d, (u8)(addr 0xff)); WREG_CRT(0x0c, (u8)(addr 8) 0xff); - WREG_CRT(0xaf, (u8)(addr 16) 0xf); + WREG_ECRT(0x0, ((u8)(addr 16) 0xf) | crtcext0); } -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 0/4] mgag200 fixes
Christopher Harvey char...@matrox.com writes: The Following should be CC'd to stable: * drm/mgag200: Fix writes into MGA1064_PIX_CLK_CTL register * drm/mgag200: Fix framebuffer base address programming The others are bug fixes, but aren't critical. I'm sitting on some hardware cursor code that depends on all of these patches before it can go in. I'm aiming for 3.11 for the hardware cursor support. thanks, Christopher Harvey (4): drm/mgag200: Don't change unrelated registers during modeset drm/mgag200: Fix writes into MGA1064_PIX_CLK_CTL register drm/mgag200: Convert counter delays to jiffies drm/mgag200: Fix framebuffer base address programming drivers/gpu/drm/mgag200/mgag200_mode.c | 90 -- 1 file changed, 52 insertions(+), 38 deletions(-) please ignore this, version 2 has been posted. -C ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 4/4] drm/mgag200: Fix framebuffer base address programming
Higher bits of the base address of framebuffers weren't being programmed properly. This caused framebuffers that didn't happen to be allocated at a low enough address to not be displayed properly. Signed-off-by: Christopher Harvey Signed-off-by: Mathieu Larouche --- drivers/gpu/drm/mgag200/mgag200_mode.c | 27 --- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 6dbf6de..77b8a45 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -654,12 +654,26 @@ static void mga_g200wb_commit(struct drm_crtc *crtc) WREG_DAC(MGA1064_GEN_IO_DATA, tmp); } - +/* + This is how the framebuffer base address is stored in g200 cards: + * Assume @offset is the gpu_addr variable of the framebuffer object + * Then addr is the number of _pixels_ (not bytes) from the start of + VRAM to the first pixel we want to display. (divided by 2 for 32bit + framebuffers) + * addr is stored in the CRTCEXT0, CRTCC and CRTCD registers + addr<20> -> CRTCEXT0<6> + addr<19-16> -> CRTCEXT0<3-0> + addr<15-8> -> CRTCC<7-0> + addr<7-0> -> CRTCD<7-0> + CRTCEXT0 has to be programmed last to trigger an update and make the + new addr variable take effect. + */ void mga_set_start_address(struct drm_crtc *crtc, unsigned offset) { struct mga_device *mdev = crtc->dev->dev_private; u32 addr; int count; + u8 crtcext0; while (RREG8(0x1fda) & 0x08); while (!(RREG8(0x1fda) & 0x08)); @@ -667,10 +681,17 @@ void mga_set_start_address(struct drm_crtc *crtc, unsigned offset) count = RREG8(MGAREG_VCOUNT) + 2; while (RREG8(MGAREG_VCOUNT) < count); - addr = offset >> 2; + WREG8(MGAREG_CRTCEXT_INDEX, 0); + crtcext0 = RREG8(MGAREG_CRTCEXT_DATA); + crtcext0 &= 0xB0; + addr = offset / 8; + /* Can't store addresses any higher than that... + but we also don't have more than 16MB of memory, so it should be fine. */ + WARN_ON(addr > 0x1f); + crtcext0 |= (!!(addr & (1<<20)))<<6; WREG_CRT(0x0d, (u8)(addr & 0xff)); WREG_CRT(0x0c, (u8)(addr >> 8) & 0xff); - WREG_CRT(0xaf, (u8)(addr >> 16) & 0xf); + WREG_ECRT(0x0, ((u8)(addr >> 16) & 0xf) | crtcext0); } -- 1.8.1.5
[PATCH v2 4/4] drm/mgag200: Fix framebuffer base address programming
Higher bits of the base address of framebuffers weren't being programmed properly. This caused framebuffers that didn't happen to be allocated at a low enough address to not be displayed properly. Signed-off-by: Christopher Harvey Signed-off-by: Mathieu Larouche Acked-by: Julia Lemire Tested-by: Julia Lemire --- drivers/gpu/drm/mgag200/mgag200_mode.c | 27 --- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 6dbf6de..77b8a45 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -654,12 +654,26 @@ static void mga_g200wb_commit(struct drm_crtc *crtc) WREG_DAC(MGA1064_GEN_IO_DATA, tmp); } - +/* + This is how the framebuffer base address is stored in g200 cards: + * Assume @offset is the gpu_addr variable of the framebuffer object + * Then addr is the number of _pixels_ (not bytes) from the start of + VRAM to the first pixel we want to display. (divided by 2 for 32bit + framebuffers) + * addr is stored in the CRTCEXT0, CRTCC and CRTCD registers + addr<20> -> CRTCEXT0<6> + addr<19-16> -> CRTCEXT0<3-0> + addr<15-8> -> CRTCC<7-0> + addr<7-0> -> CRTCD<7-0> + CRTCEXT0 has to be programmed last to trigger an update and make the + new addr variable take effect. + */ void mga_set_start_address(struct drm_crtc *crtc, unsigned offset) { struct mga_device *mdev = crtc->dev->dev_private; u32 addr; int count; + u8 crtcext0; while (RREG8(0x1fda) & 0x08); while (!(RREG8(0x1fda) & 0x08)); @@ -667,10 +681,17 @@ void mga_set_start_address(struct drm_crtc *crtc, unsigned offset) count = RREG8(MGAREG_VCOUNT) + 2; while (RREG8(MGAREG_VCOUNT) < count); - addr = offset >> 2; + WREG8(MGAREG_CRTCEXT_INDEX, 0); + crtcext0 = RREG8(MGAREG_CRTCEXT_DATA); + crtcext0 &= 0xB0; + addr = offset / 8; + /* Can't store addresses any higher than that... + but we also don't have more than 16MB of memory, so it should be fine. */ + WARN_ON(addr > 0x1f); + crtcext0 |= (!!(addr & (1<<20)))<<6; WREG_CRT(0x0d, (u8)(addr & 0xff)); WREG_CRT(0x0c, (u8)(addr >> 8) & 0xff); - WREG_CRT(0xaf, (u8)(addr >> 16) & 0xf); + WREG_ECRT(0x0, ((u8)(addr >> 16) & 0xf) | crtcext0); } -- 1.8.1.5
[PATCH 3/4] drm/mgag200: Convert counter delays to jiffies
Signed-off-by: Christopher Harvey --- drivers/gpu/drm/mgag200/mgag200_mode.c | 15 ++- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 6f3b9db..6dbf6de 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -46,29 +46,26 @@ static void mga_crtc_load_lut(struct drm_crtc *crtc) static inline void mga_wait_vsync(struct mga_device *mdev) { - unsigned int count = 0; + unsigned long timeout = jiffies + HZ/10; unsigned int status = 0; do { status = RREG32(MGAREG_Status); - count++; - } while ((status & 0x08) && (count < 25)); - count = 0; + } while ((status & 0x08) && time_before(jiffies, timeout)); + timeout = jiffies + HZ/10; status = 0; do { status = RREG32(MGAREG_Status); - count++; - } while (!(status & 0x08) && (count < 25)); + } while (!(status & 0x08) && time_before(jiffies, timeout)); } static inline void mga_wait_busy(struct mga_device *mdev) { - unsigned int count = 0; + unsigned long timeout = jiffies + HZ; unsigned int status = 0; do { status = RREG8(MGAREG_Status + 2); - count++; - } while ((status & 0x01) && (count < 50)); + } while ((status & 0x01) && time_before(jiffies, timeout)); } /* -- 1.8.1.5
[PATCH v2 3/4] drm/mgag200: Convert counter delays to jiffies
Signed-off-by: Christopher Harvey Acked-by: Julia Lemire Tested-by: Julia Lemire Acked-by: Mathieu Larouche --- drivers/gpu/drm/mgag200/mgag200_mode.c | 15 ++- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 6f3b9db..6dbf6de 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -46,29 +46,26 @@ static void mga_crtc_load_lut(struct drm_crtc *crtc) static inline void mga_wait_vsync(struct mga_device *mdev) { - unsigned int count = 0; + unsigned long timeout = jiffies + HZ/10; unsigned int status = 0; do { status = RREG32(MGAREG_Status); - count++; - } while ((status & 0x08) && (count < 25)); - count = 0; + } while ((status & 0x08) && time_before(jiffies, timeout)); + timeout = jiffies + HZ/10; status = 0; do { status = RREG32(MGAREG_Status); - count++; - } while (!(status & 0x08) && (count < 25)); + } while (!(status & 0x08) && time_before(jiffies, timeout)); } static inline void mga_wait_busy(struct mga_device *mdev) { - unsigned int count = 0; + unsigned long timeout = jiffies + HZ; unsigned int status = 0; do { status = RREG8(MGAREG_Status + 2); - count++; - } while ((status & 0x01) && (count < 50)); + } while ((status & 0x01) && time_before(jiffies, timeout)); } /* -- 1.8.1.5
[PATCH] drm/mgag200: Pass driver specific mga_device in driver functions
Signed-off-by: Christopher Harvey --- drivers/gpu/drm/mgag200/mgag200_mode.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 78d8e91..f988965 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -1254,9 +1254,8 @@ static const struct drm_crtc_helper_funcs mga_helper_funcs = { }; /* CRTC setup */ -static void mga_crtc_init(struct drm_device *dev) +static void mga_crtc_init(struct mga_device *mdev) { - struct mga_device *mdev = dev->dev_private; struct mga_crtc *mga_crtc; int i; @@ -1267,7 +1266,7 @@ static void mga_crtc_init(struct drm_device *dev) if (mga_crtc == NULL) return; - drm_crtc_init(dev, _crtc->base, _crtc_funcs); + drm_crtc_init(mdev->dev, _crtc->base, _crtc_funcs); drm_mode_crtc_set_gamma_size(_crtc->base, MGAG200_LUT_SIZE); mdev->mode_info.crtc = mga_crtc; @@ -1522,7 +1521,7 @@ int mgag200_modeset_init(struct mga_device *mdev) mdev->dev->mode_config.fb_base = mdev->mc.vram_base; - mga_crtc_init(mdev->dev); + mga_crtc_init(mdev); encoder = mga_encoder_init(mdev->dev); if (!encoder) { -- 1.8.1.5
[PATCH] drm/mgag200: Remove pointless call to drm_fb_get_bpp_depth
Signed-off-by: Christopher Harvey --- drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c index d2253f6..a5a1f34 100644 --- a/drivers/gpu/drm/mgag200/mgag200_fb.c +++ b/drivers/gpu/drm/mgag200/mgag200_fb.c @@ -105,12 +105,9 @@ static int mgag200fb_create_object(struct mga_fbdev *afbdev, struct drm_gem_object **gobj_p) { struct drm_device *dev = afbdev->helper.dev; - u32 bpp, depth; u32 size; struct drm_gem_object *gobj; - int ret = 0; - drm_fb_get_bpp_depth(mode_cmd->pixel_format, , ); size = mode_cmd->pitches[0] * mode_cmd->height; ret = mgag200_gem_create(dev, size, true, ); -- 1.8.1.5
[PATCH] mgag200 code cleanup patches
Christopher Harvey writes: > I submitted these a while ago, but I think they got lost in the > mailing list. Just wanted to make sure they get a shot at the merge > window. > > thanks, > > Christopher Harvey (3): > drm/mgag200: Remove pointless call to drm_fb_get_bpp_depth > drm/mgag200: Pass driver specific mga_device in driver functions > drm/mgag200: Remove extra variable assigns > > drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- > drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- > drivers/gpu/drm/mgag200/mgag200_mode.c | 7 +++ > 3 files changed, 3 insertions(+), 9 deletions(-) the drm-next branch is what gets merged into merge windows, right? http://cgit.freedesktop.org/~airlied/linux/ --
[PATCH] mgag200 code cleanup patches
I submitted these a while ago, but I think they got lost in the mailing list. Just wanted to make sure they get a shot at the merge window. thanks, Christopher Harvey (3): drm/mgag200: Remove pointless call to drm_fb_get_bpp_depth drm/mgag200: Pass driver specific mga_device in driver functions drm/mgag200: Remove extra variable assigns drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- drivers/gpu/drm/mgag200/mgag200_mode.c | 7 +++ 3 files changed, 3 insertions(+), 9 deletions(-) -- 1.8.1.5
[PATCH] mgag200 code cleanup patches
I submitted these a while ago, but I think they got lost in the mailing list. Just wanted to make sure they get a shot at the merge window. thanks, Christopher Harvey (3): drm/mgag200: Remove pointless call to drm_fb_get_bpp_depth drm/mgag200: Pass driver specific mga_device in driver functions drm/mgag200: Remove extra variable assigns drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- drivers/gpu/drm/mgag200/mgag200_mode.c | 7 +++ 3 files changed, 3 insertions(+), 9 deletions(-) -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] drm/mgag200: Remove pointless call to drm_fb_get_bpp_depth
Signed-off-by: Christopher Harvey char...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c index d2253f6..a5a1f34 100644 --- a/drivers/gpu/drm/mgag200/mgag200_fb.c +++ b/drivers/gpu/drm/mgag200/mgag200_fb.c @@ -105,12 +105,9 @@ static int mgag200fb_create_object(struct mga_fbdev *afbdev, struct drm_gem_object **gobj_p) { struct drm_device *dev = afbdev-helper.dev; - u32 bpp, depth; u32 size; struct drm_gem_object *gobj; - int ret = 0; - drm_fb_get_bpp_depth(mode_cmd-pixel_format, depth, bpp); size = mode_cmd-pitches[0] * mode_cmd-height; ret = mgag200_gem_create(dev, size, true, gobj); -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] drm/mgag200: Pass driver specific mga_device in driver functions
Signed-off-by: Christopher Harvey char...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_mode.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 78d8e91..f988965 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -1254,9 +1254,8 @@ static const struct drm_crtc_helper_funcs mga_helper_funcs = { }; /* CRTC setup */ -static void mga_crtc_init(struct drm_device *dev) +static void mga_crtc_init(struct mga_device *mdev) { - struct mga_device *mdev = dev-dev_private; struct mga_crtc *mga_crtc; int i; @@ -1267,7 +1266,7 @@ static void mga_crtc_init(struct drm_device *dev) if (mga_crtc == NULL) return; - drm_crtc_init(dev, mga_crtc-base, mga_crtc_funcs); + drm_crtc_init(mdev-dev, mga_crtc-base, mga_crtc_funcs); drm_mode_crtc_set_gamma_size(mga_crtc-base, MGAG200_LUT_SIZE); mdev-mode_info.crtc = mga_crtc; @@ -1522,7 +1521,7 @@ int mgag200_modeset_init(struct mga_device *mdev) mdev-dev-mode_config.fb_base = mdev-mc.vram_base; - mga_crtc_init(mdev-dev); + mga_crtc_init(mdev); encoder = mga_encoder_init(mdev-dev); if (!encoder) { -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] drm/mgag200: Remove extra variable assigns
These two variables are set again immediately in 'mgag200_modeset_init' Signed-off-by: Christopher Harvey char...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c index 64297c7..b762bfb 100644 --- a/drivers/gpu/drm/mgag200/mgag200_main.c +++ b/drivers/gpu/drm/mgag200/mgag200_main.c @@ -234,8 +234,6 @@ int mgag200_driver_load(struct drm_device *dev, unsigned long flags) drm_mode_config_init(dev); dev-mode_config.funcs = (void *)mga_mode_funcs; - dev-mode_config.min_width = 0; - dev-mode_config.min_height = 0; dev-mode_config.preferred_depth = 24; dev-mode_config.prefer_shadow = 1; -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] mgag200 code cleanup patches
Christopher Harvey char...@matrox.com writes: I submitted these a while ago, but I think they got lost in the mailing list. Just wanted to make sure they get a shot at the merge window. thanks, Christopher Harvey (3): drm/mgag200: Remove pointless call to drm_fb_get_bpp_depth drm/mgag200: Pass driver specific mga_device in driver functions drm/mgag200: Remove extra variable assigns drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- drivers/gpu/drm/mgag200/mgag200_mode.c | 7 +++ 3 files changed, 3 insertions(+), 9 deletions(-) the drm-next branch is what gets merged into merge windows, right? http://cgit.freedesktop.org/~airlied/linux/ -- ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
confused about a BUG_ON in drm_mm_dump_table
I've been trying to wrap my head around ttm and gem these last couple of weeks. I found the nice 'drm_mm_dump_table' function and ran it on the mgag200 drm_mm struct. Instant BUG in include/drm/drm_mm.h line 100. static inline unsigned long drm_mm_hole_node_start(struct drm_mm_node *hole_node) { BUG_ON(!hole_node->hole_follows); return __drm_mm_hole_node_start(hole_node); } where drm_mm_hole_node_start is called from drm_mm_dump_table like so: int drm_mm_dump_table(struct seq_file *m, struct drm_mm *mm) { struct drm_mm_node *entry; unsigned long total_used = 0, total_free = 0, total = 0; unsigned long hole_start, hole_end, hole_size; hole_start = drm_mm_hole_node_start(>head_node); ... ... ... as far as I can tell the head_node is a list of page offsets that point to free memory chunks. It seems drm_mm_dump_table expects a free chunk at the beginning of the list. What if all the memory is used? How can we ALWAYS expect a free chunk at the first element? Is this a bug in drm_mm_dump_table? Can't we just remove the first print and let the loop do all the work that comes right after? They look the same to me. This all started from me trying to figure out where ttm/gem is putting buffer objects in VRAM. All the variables in a ttm_buffer_object that looks like they hold variables either have address outside of the total VRAM size, or 0. When I removed the first print in drm_mm_dump_table I get the following output: 0x0010-0x001007e9: 0x07e9: used 0x001007e9-0x1010: 0x0817: free total: 268435456, used 2025 free 268433431 The board only has 16M of VRAM. thanks, Chris
confused about a BUG_ON in drm_mm_dump_table
I've been trying to wrap my head around ttm and gem these last couple of weeks. I found the nice 'drm_mm_dump_table' function and ran it on the mgag200 drm_mm struct. Instant BUG in include/drm/drm_mm.h line 100. static inline unsigned long drm_mm_hole_node_start(struct drm_mm_node *hole_node) { BUG_ON(!hole_node-hole_follows); return __drm_mm_hole_node_start(hole_node); } where drm_mm_hole_node_start is called from drm_mm_dump_table like so: int drm_mm_dump_table(struct seq_file *m, struct drm_mm *mm) { struct drm_mm_node *entry; unsigned long total_used = 0, total_free = 0, total = 0; unsigned long hole_start, hole_end, hole_size; hole_start = drm_mm_hole_node_start(mm-head_node); ... ... ... as far as I can tell the head_node is a list of page offsets that point to free memory chunks. It seems drm_mm_dump_table expects a free chunk at the beginning of the list. What if all the memory is used? How can we ALWAYS expect a free chunk at the first element? Is this a bug in drm_mm_dump_table? Can't we just remove the first print and let the loop do all the work that comes right after? They look the same to me. This all started from me trying to figure out where ttm/gem is putting buffer objects in VRAM. All the variables in a ttm_buffer_object that looks like they hold variables either have address outside of the total VRAM size, or 0. When I removed the first print in drm_mm_dump_table I get the following output: 0x0010-0x001007e9: 0x07e9: used 0x001007e9-0x1010: 0x0817: free total: 268435456, used 2025 free 268433431 The board only has 16M of VRAM. thanks, Chris ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 0/3] mgag200: bug fix, cleanup and managed devices
Patch one is a simple bug fix for G200ER cards. Patch two doesn't change any code Patch three makes the mgag200 driver use managed devices where possible. I'm not too sure how to test this one properly, other than to just boot a bunch of boards and stare at the code changes for a long while. Any testing hints are appreciated. Christopher Harvey (3): drm/mgag200: Index 24 in extended CRTC registers is 24 in hex, not decimal. drm: Misc comment cleanup drm/mgag200: Convert to managed device resources where possible drivers/gpu/drm/mgag200/mgag200_drv.h | 6 +++--- drivers/gpu/drm/mgag200/mgag200_fb.c | 9 +++-- drivers/gpu/drm/mgag200/mgag200_main.c | 29 + drivers/gpu/drm/mgag200/mgag200_mode.c | 13 +++-- include/drm/drm_crtc.h | 2 +- include/uapi/drm/drm_mode.h| 6 +++--- 6 files changed, 18 insertions(+), 47 deletions(-) -- 1.7.12.4
[PATCH 3/3] drm/mgag200: Convert to managed device resources where possible
Signed-off-by: Christopher Harvey --- drivers/gpu/drm/mgag200/mgag200_fb.c | 9 +++-- drivers/gpu/drm/mgag200/mgag200_main.c | 29 + 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c index a5a1f34..421beab 100644 --- a/drivers/gpu/drm/mgag200/mgag200_fb.c +++ b/drivers/gpu/drm/mgag200/mgag200_fb.c @@ -246,7 +246,7 @@ int mgag200_fbdev_init(struct mga_device *mdev) struct mga_fbdev *mfbdev; int ret; - mfbdev = kzalloc(sizeof(struct mga_fbdev), GFP_KERNEL); + mfbdev = devm_kzalloc(mdev->dev->dev, sizeof(struct mga_fbdev), GFP_KERNEL); if (!mfbdev) return -ENOMEM; @@ -255,10 +255,9 @@ int mgag200_fbdev_init(struct mga_device *mdev) ret = drm_fb_helper_init(mdev->dev, >helper, mdev->num_crtc, MGAG200FB_CONN_LIMIT); - if (ret) { - kfree(mfbdev); + if (ret) return ret; - } + drm_fb_helper_single_add_all_connectors(>helper); /* disable all the possible outputs/crtcs before entering KMS mode */ @@ -275,6 +274,4 @@ void mgag200_fbdev_fini(struct mga_device *mdev) return; mga_fbdev_destroy(mdev->dev, mdev->mfbdev); - kfree(mdev->mfbdev); - mdev->mfbdev = NULL; } diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c index baf54d9..19db16d 100644 --- a/drivers/gpu/drm/mgag200/mgag200_main.c +++ b/drivers/gpu/drm/mgag200/mgag200_main.c @@ -80,15 +80,6 @@ static const struct drm_mode_config_funcs mga_mode_funcs = { .fb_create = mgag200_user_framebuffer_create, }; -/* Unmap the framebuffer from the core and release the memory */ -static void mga_vram_fini(struct mga_device *mdev) -{ - pci_iounmap(mdev->dev->pdev, mdev->rmmio); - mdev->rmmio = NULL; - if (mdev->mc.vram_base) - release_mem_region(mdev->mc.vram_base, mdev->mc.vram_window); -} - static int mga_probe_vram(struct mga_device *mdev, void __iomem *mem) { int offset; @@ -144,7 +135,7 @@ static int mga_vram_init(struct mga_device *mdev) remove_conflicting_framebuffers(aper, "mgafb", true); kfree(aper); - if (!request_mem_region(mdev->mc.vram_base, mdev->mc.vram_window, + if (!devm_request_mem_region(mdev->dev->dev, mdev->mc.vram_base, mdev->mc.vram_window, "mgadrmfb_vram")) { DRM_ERROR("can't reserve VRAM\n"); return -ENXIO; @@ -177,13 +168,13 @@ static int mgag200_device_init(struct drm_device *dev, mdev->rmmio_base = pci_resource_start(mdev->dev->pdev, 1); mdev->rmmio_size = pci_resource_len(mdev->dev->pdev, 1); - if (!request_mem_region(mdev->rmmio_base, mdev->rmmio_size, + if (!devm_request_mem_region(mdev->dev->dev, mdev->rmmio_base, mdev->rmmio_size, "mgadrmfb_mmio")) { DRM_ERROR("can't reserve mmio registers\n"); return -ENOMEM; } - mdev->rmmio = pci_iomap(dev->pdev, 1, 0); + mdev->rmmio = pcim_iomap(dev->pdev, 1, 0); if (mdev->rmmio == NULL) return -ENOMEM; @@ -192,10 +183,8 @@ static int mgag200_device_init(struct drm_device *dev, mdev->reg_1e24 = RREG32(0x1e24); ret = mga_vram_init(mdev); - if (ret) { - release_mem_region(mdev->rmmio_base, mdev->rmmio_size); + if (ret) return ret; - } mdev->bpp_shifts[0] = 0; mdev->bpp_shifts[1] = 1; @@ -204,12 +193,6 @@ static int mgag200_device_init(struct drm_device *dev, return 0; } -void mgag200_device_fini(struct mga_device *mdev) -{ - release_mem_region(mdev->rmmio_base, mdev->rmmio_size); - mga_vram_fini(mdev); -} - /* * Functions here will be called by the core once it's bound the driver to * a PCI device @@ -221,7 +204,7 @@ int mgag200_driver_load(struct drm_device *dev, unsigned long flags) struct mga_device *mdev; int r; - mdev = kzalloc(sizeof(struct mga_device), GFP_KERNEL); + mdev = devm_kzalloc(dev->dev, sizeof(struct mga_device), GFP_KERNEL); if (mdev == NULL) return -ENOMEM; dev->dev_private = (void *)mdev; @@ -265,8 +248,6 @@ int mgag200_driver_unload(struct drm_device *dev) mgag200_fbdev_fini(mdev); drm_mode_config_cleanup(dev); mgag200_mm_fini(mdev); - mgag200_device_fini(mdev); - kfree(mdev); dev->dev_private = NULL; return 0; } -- 1.7.12.4
[PATCH 2/3] drm: Misc comment cleanup
Signed-off-by: Christopher Harvey --- drivers/gpu/drm/mgag200/mgag200_drv.h | 6 +++--- include/drm/drm_crtc.h| 2 +- include/uapi/drm/drm_mode.h | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h index 4d932c4..dcfc973 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.h +++ b/drivers/gpu/drm/mgag200/mgag200_drv.h @@ -215,7 +215,7 @@ mgag200_bo(struct ttm_buffer_object *bo) { return container_of(bo, struct mgag200_bo, bo); } - /* mga_crtc.c */ + /* mgag200_crtc.c */ void mga_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green, u16 blue, int regno); void mga_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green, @@ -225,7 +225,7 @@ void mga_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green, int mgag200_modeset_init(struct mga_device *mdev); void mgag200_modeset_fini(struct mga_device *mdev); - /* mga_fbdev.c */ + /* mgag200_fb.c */ int mgag200_fbdev_init(struct mga_device *mdev); void mgag200_fbdev_fini(struct mga_device *mdev); @@ -254,7 +254,7 @@ mgag200_dumb_mmap_offset(struct drm_file *file, struct drm_device *dev, uint32_t handle, uint64_t *offset); - /* mga_i2c.c */ + /* mgag200_i2c.c */ struct mga_i2c_chan *mgag200_i2c_create(struct drm_device *dev); void mgag200_i2c_destroy(struct mga_i2c_chan *i2c); diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index e3e0d65..8c7846b 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -310,7 +310,7 @@ struct drm_plane; * drm_crtc_funcs - control CRTCs for a given device * @save: save CRTC state * @restore: restore CRTC state - * @reset: reset CRTC after state has been invalidate (e.g. resume) + * @reset: reset CRTC after state has been invalidated (e.g. resume) * @cursor_set: setup the cursor * @cursor_move: move the cursor * @gamma_set: specify color ramp for CRTC diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 3d6301b..090e533 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -367,13 +367,13 @@ struct drm_mode_mode_cmd { * depending on the value in flags different members are used. * * CURSOR_BO uses - *crtc + *crtc_id *width *height - *handle - if 0 turns the cursor of + *handle - if 0 turns the cursor off * * CURSOR_MOVE uses - *crtc + *crtc_id *x *y */ -- 1.7.12.4
[PATCH 1/3] drm/mgag200: Index 24 in extended CRTC registers is 24 in hex, not decimal.
This change properly enables the "requester" in G200ER cards that is responsible for getting pixels out of memory and clocking them out to the screen. Signed-off-by: Christopher Harvey --- drivers/gpu/drm/mgag200/mgag200_mode.c | 13 +++-- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 7337013..f988965 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -751,8 +751,6 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc, int i; unsigned char misc = 0; unsigned char ext_vga[6]; - unsigned char ext_vga_index24; - unsigned char dac_index90 = 0; u8 bppshift; static unsigned char dacvalue[] = { @@ -803,7 +801,6 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc, option2 = 0xb000; break; case G200_ER: - dac_index90 = 0; break; } @@ -852,10 +849,8 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc, WREG_DAC(i, dacvalue[i]); } - if (mdev->type == G200_ER) { - WREG_DAC(0x90, dac_index90); - } - + if (mdev->type == G200_ER) + WREG_DAC(0x90, 0); if (option) pci_write_config_dword(dev->pdev, PCI_MGA_OPTION, option); @@ -952,8 +947,6 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc, if (mdev->type == G200_WB) ext_vga[1] |= 0x88; - ext_vga_index24 = 0x05; - /* Set pixel clocks */ misc = 0x2d; WREG8(MGA_MISC_OUT, misc); @@ -965,7 +958,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc, } if (mdev->type == G200_ER) - WREG_ECRT(24, ext_vga_index24); + WREG_ECRT(0x24, 0x5); if (mdev->type == G200_EV) { WREG_ECRT(6, 0); -- 1.7.12.4
[PATCH 0/3] mgag200: bug fix, cleanup and managed devices
Patch one is a simple bug fix for G200ER cards. Patch two doesn't change any code Patch three makes the mgag200 driver use managed devices where possible. I'm not too sure how to test this one properly, other than to just boot a bunch of boards and stare at the code changes for a long while. Any testing hints are appreciated. Christopher Harvey (3): drm/mgag200: Index 24 in extended CRTC registers is 24 in hex, not decimal. drm: Misc comment cleanup drm/mgag200: Convert to managed device resources where possible drivers/gpu/drm/mgag200/mgag200_drv.h | 6 +++--- drivers/gpu/drm/mgag200/mgag200_fb.c | 9 +++-- drivers/gpu/drm/mgag200/mgag200_main.c | 29 + drivers/gpu/drm/mgag200/mgag200_mode.c | 13 +++-- include/drm/drm_crtc.h | 2 +- include/uapi/drm/drm_mode.h| 6 +++--- 6 files changed, 18 insertions(+), 47 deletions(-) -- 1.7.12.4 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 1/3] drm/mgag200: Index 24 in extended CRTC registers is 24 in hex, not decimal.
This change properly enables the requester in G200ER cards that is responsible for getting pixels out of memory and clocking them out to the screen. Signed-off-by: Christopher Harvey char...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_mode.c | 13 +++-- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 7337013..f988965 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -751,8 +751,6 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc, int i; unsigned char misc = 0; unsigned char ext_vga[6]; - unsigned char ext_vga_index24; - unsigned char dac_index90 = 0; u8 bppshift; static unsigned char dacvalue[] = { @@ -803,7 +801,6 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc, option2 = 0xb000; break; case G200_ER: - dac_index90 = 0; break; } @@ -852,10 +849,8 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc, WREG_DAC(i, dacvalue[i]); } - if (mdev-type == G200_ER) { - WREG_DAC(0x90, dac_index90); - } - + if (mdev-type == G200_ER) + WREG_DAC(0x90, 0); if (option) pci_write_config_dword(dev-pdev, PCI_MGA_OPTION, option); @@ -952,8 +947,6 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc, if (mdev-type == G200_WB) ext_vga[1] |= 0x88; - ext_vga_index24 = 0x05; - /* Set pixel clocks */ misc = 0x2d; WREG8(MGA_MISC_OUT, misc); @@ -965,7 +958,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc, } if (mdev-type == G200_ER) - WREG_ECRT(24, ext_vga_index24); + WREG_ECRT(0x24, 0x5); if (mdev-type == G200_EV) { WREG_ECRT(6, 0); -- 1.7.12.4 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 2/3] drm: Misc comment cleanup
Signed-off-by: Christopher Harvey char...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_drv.h | 6 +++--- include/drm/drm_crtc.h| 2 +- include/uapi/drm/drm_mode.h | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h index 4d932c4..dcfc973 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.h +++ b/drivers/gpu/drm/mgag200/mgag200_drv.h @@ -215,7 +215,7 @@ mgag200_bo(struct ttm_buffer_object *bo) { return container_of(bo, struct mgag200_bo, bo); } - /* mga_crtc.c */ + /* mgag200_crtc.c */ void mga_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green, u16 blue, int regno); void mga_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green, @@ -225,7 +225,7 @@ void mga_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green, int mgag200_modeset_init(struct mga_device *mdev); void mgag200_modeset_fini(struct mga_device *mdev); - /* mga_fbdev.c */ + /* mgag200_fb.c */ int mgag200_fbdev_init(struct mga_device *mdev); void mgag200_fbdev_fini(struct mga_device *mdev); @@ -254,7 +254,7 @@ mgag200_dumb_mmap_offset(struct drm_file *file, struct drm_device *dev, uint32_t handle, uint64_t *offset); - /* mga_i2c.c */ + /* mgag200_i2c.c */ struct mga_i2c_chan *mgag200_i2c_create(struct drm_device *dev); void mgag200_i2c_destroy(struct mga_i2c_chan *i2c); diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index e3e0d65..8c7846b 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -310,7 +310,7 @@ struct drm_plane; * drm_crtc_funcs - control CRTCs for a given device * @save: save CRTC state * @restore: restore CRTC state - * @reset: reset CRTC after state has been invalidate (e.g. resume) + * @reset: reset CRTC after state has been invalidated (e.g. resume) * @cursor_set: setup the cursor * @cursor_move: move the cursor * @gamma_set: specify color ramp for CRTC diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 3d6301b..090e533 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -367,13 +367,13 @@ struct drm_mode_mode_cmd { * depending on the value in flags different members are used. * * CURSOR_BO uses - *crtc + *crtc_id *width *height - *handle - if 0 turns the cursor of + *handle - if 0 turns the cursor off * * CURSOR_MOVE uses - *crtc + *crtc_id *x *y */ -- 1.7.12.4 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 3/3] drm/mgag200: Convert to managed device resources where possible
Signed-off-by: Christopher Harvey char...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_fb.c | 9 +++-- drivers/gpu/drm/mgag200/mgag200_main.c | 29 + 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c index a5a1f34..421beab 100644 --- a/drivers/gpu/drm/mgag200/mgag200_fb.c +++ b/drivers/gpu/drm/mgag200/mgag200_fb.c @@ -246,7 +246,7 @@ int mgag200_fbdev_init(struct mga_device *mdev) struct mga_fbdev *mfbdev; int ret; - mfbdev = kzalloc(sizeof(struct mga_fbdev), GFP_KERNEL); + mfbdev = devm_kzalloc(mdev-dev-dev, sizeof(struct mga_fbdev), GFP_KERNEL); if (!mfbdev) return -ENOMEM; @@ -255,10 +255,9 @@ int mgag200_fbdev_init(struct mga_device *mdev) ret = drm_fb_helper_init(mdev-dev, mfbdev-helper, mdev-num_crtc, MGAG200FB_CONN_LIMIT); - if (ret) { - kfree(mfbdev); + if (ret) return ret; - } + drm_fb_helper_single_add_all_connectors(mfbdev-helper); /* disable all the possible outputs/crtcs before entering KMS mode */ @@ -275,6 +274,4 @@ void mgag200_fbdev_fini(struct mga_device *mdev) return; mga_fbdev_destroy(mdev-dev, mdev-mfbdev); - kfree(mdev-mfbdev); - mdev-mfbdev = NULL; } diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c index baf54d9..19db16d 100644 --- a/drivers/gpu/drm/mgag200/mgag200_main.c +++ b/drivers/gpu/drm/mgag200/mgag200_main.c @@ -80,15 +80,6 @@ static const struct drm_mode_config_funcs mga_mode_funcs = { .fb_create = mgag200_user_framebuffer_create, }; -/* Unmap the framebuffer from the core and release the memory */ -static void mga_vram_fini(struct mga_device *mdev) -{ - pci_iounmap(mdev-dev-pdev, mdev-rmmio); - mdev-rmmio = NULL; - if (mdev-mc.vram_base) - release_mem_region(mdev-mc.vram_base, mdev-mc.vram_window); -} - static int mga_probe_vram(struct mga_device *mdev, void __iomem *mem) { int offset; @@ -144,7 +135,7 @@ static int mga_vram_init(struct mga_device *mdev) remove_conflicting_framebuffers(aper, mgafb, true); kfree(aper); - if (!request_mem_region(mdev-mc.vram_base, mdev-mc.vram_window, + if (!devm_request_mem_region(mdev-dev-dev, mdev-mc.vram_base, mdev-mc.vram_window, mgadrmfb_vram)) { DRM_ERROR(can't reserve VRAM\n); return -ENXIO; @@ -177,13 +168,13 @@ static int mgag200_device_init(struct drm_device *dev, mdev-rmmio_base = pci_resource_start(mdev-dev-pdev, 1); mdev-rmmio_size = pci_resource_len(mdev-dev-pdev, 1); - if (!request_mem_region(mdev-rmmio_base, mdev-rmmio_size, + if (!devm_request_mem_region(mdev-dev-dev, mdev-rmmio_base, mdev-rmmio_size, mgadrmfb_mmio)) { DRM_ERROR(can't reserve mmio registers\n); return -ENOMEM; } - mdev-rmmio = pci_iomap(dev-pdev, 1, 0); + mdev-rmmio = pcim_iomap(dev-pdev, 1, 0); if (mdev-rmmio == NULL) return -ENOMEM; @@ -192,10 +183,8 @@ static int mgag200_device_init(struct drm_device *dev, mdev-reg_1e24 = RREG32(0x1e24); ret = mga_vram_init(mdev); - if (ret) { - release_mem_region(mdev-rmmio_base, mdev-rmmio_size); + if (ret) return ret; - } mdev-bpp_shifts[0] = 0; mdev-bpp_shifts[1] = 1; @@ -204,12 +193,6 @@ static int mgag200_device_init(struct drm_device *dev, return 0; } -void mgag200_device_fini(struct mga_device *mdev) -{ - release_mem_region(mdev-rmmio_base, mdev-rmmio_size); - mga_vram_fini(mdev); -} - /* * Functions here will be called by the core once it's bound the driver to * a PCI device @@ -221,7 +204,7 @@ int mgag200_driver_load(struct drm_device *dev, unsigned long flags) struct mga_device *mdev; int r; - mdev = kzalloc(sizeof(struct mga_device), GFP_KERNEL); + mdev = devm_kzalloc(dev-dev, sizeof(struct mga_device), GFP_KERNEL); if (mdev == NULL) return -ENOMEM; dev-dev_private = (void *)mdev; @@ -265,8 +248,6 @@ int mgag200_driver_unload(struct drm_device *dev) mgag200_fbdev_fini(mdev); drm_mode_config_cleanup(dev); mgag200_mm_fini(mdev); - mgag200_device_fini(mdev); - kfree(mdev); dev-dev_private = NULL; return 0; } -- 1.7.12.4 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
colour pallete utilities
On Tue, Mar 19, 2013 at 03:15:14PM -0400, Christopher Harvey wrote: > Does the Linux kernel have functions to convert images to palleted > images? I want to display a 4bit palleted cursor, not too sure how to > handle that in DRM. Some ideas I have: > > * change DRM to handle palleted cursors > * convert 32bit images in drivers > * write library functions do convert > * require the conversion to be done in userspace > > thanks, > Chris s/pallete/palette/ :S
colour pallete utilities
Does the Linux kernel have functions to convert images to palleted images? I want to display a 4bit palleted cursor, not too sure how to handle that in DRM. Some ideas I have: * change DRM to handle palleted cursors * convert 32bit images in drivers * write library functions do convert * require the conversion to be done in userspace thanks, Chris
colour pallete utilities
Does the Linux kernel have functions to convert images to palleted images? I want to display a 4bit palleted cursor, not too sure how to handle that in DRM. Some ideas I have: * change DRM to handle palleted cursors * convert 32bit images in drivers * write library functions do convert * require the conversion to be done in userspace thanks, Chris ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: colour pallete utilities
On Tue, Mar 19, 2013 at 03:15:14PM -0400, Christopher Harvey wrote: Does the Linux kernel have functions to convert images to palleted images? I want to display a 4bit palleted cursor, not too sure how to handle that in DRM. Some ideas I have: * change DRM to handle palleted cursors * convert 32bit images in drivers * write library functions do convert * require the conversion to be done in userspace thanks, Chris s/pallete/palette/ :S ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 3/4] drm/mgag200: Remove extra variable assigns
These two variables are set again immediately in 'mgag200_modeset_init' Signed-off-by: Christopher Harvey --- drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c index 64297c7..b762bfb 100644 --- a/drivers/gpu/drm/mgag200/mgag200_main.c +++ b/drivers/gpu/drm/mgag200/mgag200_main.c @@ -234,8 +234,6 @@ int mgag200_driver_load(struct drm_device *dev, unsigned long flags) drm_mode_config_init(dev); dev->mode_config.funcs = (void *)_mode_funcs; - dev->mode_config.min_width = 0; - dev->mode_config.min_height = 0; dev->mode_config.preferred_depth = 24; dev->mode_config.prefer_shadow = 1; -- 1.7.12.4
[PATCH 2/4] drm/mgag200: Pass driver specific mga_device in driver functions
Signed-off-by: Christopher Harvey --- drivers/gpu/drm/mgag200/mgag200_mode.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index a274b99..6b5db83 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -1261,9 +1261,8 @@ static const struct drm_crtc_helper_funcs mga_helper_funcs = { }; /* CRTC setup */ -static void mga_crtc_init(struct drm_device *dev) +static void mga_crtc_init(struct mga_device *mdev) { - struct mga_device *mdev = dev->dev_private; struct mga_crtc *mga_crtc; int i; @@ -1274,7 +1273,7 @@ static void mga_crtc_init(struct drm_device *dev) if (mga_crtc == NULL) return; - drm_crtc_init(dev, _crtc->base, _crtc_funcs); + drm_crtc_init(mdev->dev, _crtc->base, _crtc_funcs); drm_mode_crtc_set_gamma_size(_crtc->base, MGAG200_LUT_SIZE); mdev->mode_info.crtc = mga_crtc; @@ -1529,7 +1528,7 @@ int mgag200_modeset_init(struct mga_device *mdev) mdev->dev->mode_config.fb_base = mdev->mc.vram_base; - mga_crtc_init(mdev->dev); + mga_crtc_init(mdev); encoder = mga_encoder_init(mdev->dev); if (!encoder) { -- 1.7.12.4
[PATCH 1/4] drm/mgag200: Remove pointless call to drm_fb_get_bpp_depth
Signed-off-by: Christopher Harvey --- drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c index d2253f6..a5a1f34 100644 --- a/drivers/gpu/drm/mgag200/mgag200_fb.c +++ b/drivers/gpu/drm/mgag200/mgag200_fb.c @@ -105,12 +105,9 @@ static int mgag200fb_create_object(struct mga_fbdev *afbdev, struct drm_gem_object **gobj_p) { struct drm_device *dev = afbdev->helper.dev; - u32 bpp, depth; u32 size; struct drm_gem_object *gobj; - int ret = 0; - drm_fb_get_bpp_depth(mode_cmd->pixel_format, , ); size = mode_cmd->pitches[0] * mode_cmd->height; ret = mgag200_gem_create(dev, size, true, ); -- 1.7.12.4
[PATCH 0/4] mgag200 fix and cleanup
Just a bit of cleanup from me (resubmitted). The important patch comes from Julia. Julia's patch conflicts with the following: 1363594270-22137-1-git-send-email-airlied at gmail.com it fixes https://bugzilla.kernel.org/show_bug.cgi?id=46591 Christopher Harvey (3): drm/mgag200: Remove pointless call to drm_fb_get_bpp_depth drm/mgag200: Pass driver specific mga_device in driver functions drm/mgag200: Remove extra variable assigns Julia Lemire (1): drm/mgag200: Bug fix: Modified pll algorithm for EH project drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- drivers/gpu/drm/mgag200/mgag200_mode.c | 17 - 3 files changed, 8 insertions(+), 14 deletions(-) -- 1.7.12.4
[PATCH 0/4] mgag200 fix and cleanup
Just a bit of cleanup from me (resubmitted). The important patch comes from Julia. Julia's patch conflicts with the following: 1363594270-22137-1-git-send-email-airl...@gmail.com it fixes https://bugzilla.kernel.org/show_bug.cgi?id=46591 Christopher Harvey (3): drm/mgag200: Remove pointless call to drm_fb_get_bpp_depth drm/mgag200: Pass driver specific mga_device in driver functions drm/mgag200: Remove extra variable assigns Julia Lemire (1): drm/mgag200: Bug fix: Modified pll algorithm for EH project drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- drivers/gpu/drm/mgag200/mgag200_mode.c | 17 - 3 files changed, 8 insertions(+), 14 deletions(-) -- 1.7.12.4 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 1/4] drm/mgag200: Remove pointless call to drm_fb_get_bpp_depth
Signed-off-by: Christopher Harvey char...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c index d2253f6..a5a1f34 100644 --- a/drivers/gpu/drm/mgag200/mgag200_fb.c +++ b/drivers/gpu/drm/mgag200/mgag200_fb.c @@ -105,12 +105,9 @@ static int mgag200fb_create_object(struct mga_fbdev *afbdev, struct drm_gem_object **gobj_p) { struct drm_device *dev = afbdev-helper.dev; - u32 bpp, depth; u32 size; struct drm_gem_object *gobj; - int ret = 0; - drm_fb_get_bpp_depth(mode_cmd-pixel_format, depth, bpp); size = mode_cmd-pitches[0] * mode_cmd-height; ret = mgag200_gem_create(dev, size, true, gobj); -- 1.7.12.4 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 2/4] drm/mgag200: Pass driver specific mga_device in driver functions
Signed-off-by: Christopher Harvey char...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_mode.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index a274b99..6b5db83 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -1261,9 +1261,8 @@ static const struct drm_crtc_helper_funcs mga_helper_funcs = { }; /* CRTC setup */ -static void mga_crtc_init(struct drm_device *dev) +static void mga_crtc_init(struct mga_device *mdev) { - struct mga_device *mdev = dev-dev_private; struct mga_crtc *mga_crtc; int i; @@ -1274,7 +1273,7 @@ static void mga_crtc_init(struct drm_device *dev) if (mga_crtc == NULL) return; - drm_crtc_init(dev, mga_crtc-base, mga_crtc_funcs); + drm_crtc_init(mdev-dev, mga_crtc-base, mga_crtc_funcs); drm_mode_crtc_set_gamma_size(mga_crtc-base, MGAG200_LUT_SIZE); mdev-mode_info.crtc = mga_crtc; @@ -1529,7 +1528,7 @@ int mgag200_modeset_init(struct mga_device *mdev) mdev-dev-mode_config.fb_base = mdev-mc.vram_base; - mga_crtc_init(mdev-dev); + mga_crtc_init(mdev); encoder = mga_encoder_init(mdev-dev); if (!encoder) { -- 1.7.12.4 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 3/4] drm/mgag200: Remove extra variable assigns
These two variables are set again immediately in 'mgag200_modeset_init' Signed-off-by: Christopher Harvey char...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c index 64297c7..b762bfb 100644 --- a/drivers/gpu/drm/mgag200/mgag200_main.c +++ b/drivers/gpu/drm/mgag200/mgag200_main.c @@ -234,8 +234,6 @@ int mgag200_driver_load(struct drm_device *dev, unsigned long flags) drm_mode_config_init(dev); dev-mode_config.funcs = (void *)mga_mode_funcs; - dev-mode_config.min_width = 0; - dev-mode_config.min_height = 0; dev-mode_config.preferred_depth = 24; dev-mode_config.prefer_shadow = 1; -- 1.7.12.4 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 2/2] drm: Documentation typo fixes
Signed-off-by: Christopher Harvey --- include/drm/drm_crtc.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 00d78b5..7294403 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -429,12 +429,12 @@ struct drm_crtc { * @dpms: set power state (see drm_crtc_funcs above) * @save: save connector state * @restore: restore connector state - * @reset: reset connector after state has been invalidate (e.g. resume) + * @reset: reset connector after state has been invalidated (e.g. resume) * @detect: is this connector active? * @fill_modes: fill mode list for this connector - * @set_property: property for this connector may need update + * @set_property: property for this connector may need an update * @destroy: make object go away - * @force: notify the driver the connector is forced on + * @force: notify the driver that the connector is forced on * * Each CRTC may have one or more connectors attached to it. The functions * below allow the core DRM code to control connectors, enumerate available modes, -- 1.7.12.4
[PATCH 0/2] mgag200 fix plus documentation typo fixes
This is a fix for mgag200 cards that is well documented in the commit message. Also includes some typo fixes that were bugging me. Christopher Harvey (1): drm: Documentation typo fixes Julia Lemire (1): drm/mgag200: Bug fix: Renesas board now selects native resolution. drivers/gpu/drm/mgag200/mgag200_i2c.c | 1 + include/drm/drm_crtc.h| 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) -- 1.7.12.4
[PATCH 0/2] mgag200 fix plus documentation typo fixes
This is a fix for mgag200 cards that is well documented in the commit message. Also includes some typo fixes that were bugging me. Christopher Harvey (1): drm: Documentation typo fixes Julia Lemire (1): drm/mgag200: Bug fix: Renesas board now selects native resolution. drivers/gpu/drm/mgag200/mgag200_i2c.c | 1 + include/drm/drm_crtc.h| 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) -- 1.7.12.4 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 2/2] drm: Documentation typo fixes
Signed-off-by: Christopher Harvey char...@matrox.com --- include/drm/drm_crtc.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 00d78b5..7294403 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -429,12 +429,12 @@ struct drm_crtc { * @dpms: set power state (see drm_crtc_funcs above) * @save: save connector state * @restore: restore connector state - * @reset: reset connector after state has been invalidate (e.g. resume) + * @reset: reset connector after state has been invalidated (e.g. resume) * @detect: is this connector active? * @fill_modes: fill mode list for this connector - * @set_property: property for this connector may need update + * @set_property: property for this connector may need an update * @destroy: make object go away - * @force: notify the driver the connector is forced on + * @force: notify the driver that the connector is forced on * * Each CRTC may have one or more connectors attached to it. The functions * below allow the core DRM code to control connectors, enumerate available modes, -- 1.7.12.4 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] mgag200: some cleanup and a fix for corrupted output
On Tue, Feb 26, 2013 at 10:52:55AM -0500, Christopher Harvey wrote: > Patches 1 to 4 are just cleanup. Maybe these should should be rolled > into one patch? > > Patch 5 is a bit more complicated. > On cards with very little video memory, (e.g 8MB) higher resolutions > at 32bit framebuffer depths will get corrupted because the required > memory is larger than what the framebuffer has. DRM has "max_height" > and "max_width" but no "max_bytes" for limiting resolutions, so the > patch is a little hacky. The first for loop tries to associate a > connector with the mode being tested. From the connector I can get the > bpp if the user specified one on the video= commandline. After that I > do 2 things: > 1) Invalidate the requested mode from the video= parameter > 2) Return MODE_BAD if the framebuffer would be too large > I feel this patch plays with structures it shouldn't have to touch to > get the bpp. An alternative fix would be to include a "max_bytes" in > the DRM core and then do these checks there. > > I'm also wondering, did I miss the 3.9.0 merge window? > > Thanks, > > Christopher Harvey (5): > drm/mgag200: Cleanup: Remove pointless call to drm_fb_get_bpp_depth > drm/mgag200: Cleanup: 'fbdev_list' in 'struct mga_fbdev' is not used > drm/mgag200: Cleanup: Pass driver specific mga_device in driver > functions > drm/mgag200: Cleanup: Remove extra variable assigns > drm/mgag200: Reject modes that are too big for VRAM > > drivers/gpu/drm/mgag200/mgag200_drv.h | 1 - > drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- > drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- > drivers/gpu/drm/mgag200/mgag200_mode.c | 34 > ++ > 4 files changed, 30 insertions(+), 10 deletions(-) > > -- > 1.7.12.4 > Ping. I've got more patches queuing up. Should I re-submit these along with the new ones? So far I've only gotten commit message feedback. -Chris
Re: [PATCH] mgag200: some cleanup and a fix for corrupted output
On Tue, Feb 26, 2013 at 10:52:55AM -0500, Christopher Harvey wrote: Patches 1 to 4 are just cleanup. Maybe these should should be rolled into one patch? Patch 5 is a bit more complicated. On cards with very little video memory, (e.g 8MB) higher resolutions at 32bit framebuffer depths will get corrupted because the required memory is larger than what the framebuffer has. DRM has max_height and max_width but no max_bytes for limiting resolutions, so the patch is a little hacky. The first for loop tries to associate a connector with the mode being tested. From the connector I can get the bpp if the user specified one on the video= commandline. After that I do 2 things: 1) Invalidate the requested mode from the video= parameter 2) Return MODE_BAD if the framebuffer would be too large I feel this patch plays with structures it shouldn't have to touch to get the bpp. An alternative fix would be to include a max_bytes in the DRM core and then do these checks there. I'm also wondering, did I miss the 3.9.0 merge window? Thanks, Christopher Harvey (5): drm/mgag200: Cleanup: Remove pointless call to drm_fb_get_bpp_depth drm/mgag200: Cleanup: 'fbdev_list' in 'struct mga_fbdev' is not used drm/mgag200: Cleanup: Pass driver specific mga_device in driver functions drm/mgag200: Cleanup: Remove extra variable assigns drm/mgag200: Reject modes that are too big for VRAM drivers/gpu/drm/mgag200/mgag200_drv.h | 1 - drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- drivers/gpu/drm/mgag200/mgag200_mode.c | 34 ++ 4 files changed, 30 insertions(+), 10 deletions(-) -- 1.7.12.4 Ping. I've got more patches queuing up. Should I re-submit these along with the new ones? So far I've only gotten commit message feedback. -Chris ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] drm/mgag200: Reject modes that are too big for VRAM
A monitor or a user could request a resolution greater than the available VRAM for the backing framebuffer. This change checks the required framebuffer size against the max VRAM size and rejects modes if they are too big. This change can also remove a mode request passed in via the video= parameter. Signed-off-by: Christopher Harvey --- drivers/gpu/drm/mgag200/mgag200_mode.c | 27 +++ 1 file changed, 27 insertions(+) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 3abf197..6b5db83 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -1405,6 +1405,14 @@ static int mga_vga_get_modes(struct drm_connector *connector) static int mga_vga_mode_valid(struct drm_connector *connector, struct drm_display_mode *mode) { + struct drm_device *dev = connector->dev; + struct mga_device *mdev = (struct mga_device*)dev->dev_private; + struct mga_fbdev *mfbdev = mdev->mfbdev; + struct drm_fb_helper *fb_helper = >helper; + struct drm_fb_helper_connector *fb_helper_conn = NULL; + int bpp = 32; + int i = 0; + /* FIXME: Add bandwidth and g200se limitations */ if (mode->crtc_hdisplay > 2048 || mode->crtc_hsync_start > 4096 || @@ -1414,6 +1422,25 @@ static int mga_vga_mode_valid(struct drm_connector *connector, return MODE_BAD; } + /* Validate the mode input by the user */ + for (i = 0; i < fb_helper->connector_count; i++) { + if (fb_helper->connector_info[i]->connector == connector) { + /* Found the helper for this connector */ + fb_helper_conn = fb_helper->connector_info[i]; + if (fb_helper_conn->cmdline_mode.specified) { + if (fb_helper_conn->cmdline_mode.bpp_specified) { + bpp = fb_helper_conn->cmdline_mode.bpp; + } + } + } + } + + if ((mode->hdisplay * mode->vdisplay * (bpp/8)) > mdev->mc.vram_size) { + if (fb_helper_conn) + fb_helper_conn->cmdline_mode.specified = false; + return MODE_BAD; + } + return MODE_OK; } -- 1.7.12.4
[PATCH] drm/mgag200: Cleanup: Remove extra variable assigns
These two variables are set again immediately in 'mgag200_modeset_init' Signed-off-by: Christopher Harvey --- drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c index 70dd3c5..aad280a 100644 --- a/drivers/gpu/drm/mgag200/mgag200_main.c +++ b/drivers/gpu/drm/mgag200/mgag200_main.c @@ -240,8 +240,6 @@ int mgag200_driver_load(struct drm_device *dev, unsigned long flags) drm_mode_config_init(dev); dev->mode_config.funcs = (void *)_mode_funcs; - dev->mode_config.min_width = 0; - dev->mode_config.min_height = 0; dev->mode_config.preferred_depth = 24; dev->mode_config.prefer_shadow = 1; -- 1.7.12.4
[PATCH] drm/mgag200: Cleanup: Pass driver specific mga_device in driver functions
Signed-off-by: Christopher Harvey --- drivers/gpu/drm/mgag200/mgag200_mode.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index d3d99a2..3abf197 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -1261,9 +1261,8 @@ static const struct drm_crtc_helper_funcs mga_helper_funcs = { }; /* CRTC setup */ -static void mga_crtc_init(struct drm_device *dev) +static void mga_crtc_init(struct mga_device *mdev) { - struct mga_device *mdev = dev->dev_private; struct mga_crtc *mga_crtc; int i; @@ -1274,7 +1273,7 @@ static void mga_crtc_init(struct drm_device *dev) if (mga_crtc == NULL) return; - drm_crtc_init(dev, _crtc->base, _crtc_funcs); + drm_crtc_init(mdev->dev, _crtc->base, _crtc_funcs); drm_mode_crtc_set_gamma_size(_crtc->base, MGAG200_LUT_SIZE); mdev->mode_info.crtc = mga_crtc; @@ -1502,7 +1501,7 @@ int mgag200_modeset_init(struct mga_device *mdev) mdev->dev->mode_config.fb_base = mdev->mc.vram_base; - mga_crtc_init(mdev->dev); + mga_crtc_init(mdev); encoder = mga_encoder_init(mdev->dev); if (!encoder) { -- 1.7.12.4
[PATCH] drm/mgag200: Cleanup: 'fbdev_list' in 'struct mga_fbdev' is not used
Signed-off-by: Christopher Harvey --- drivers/gpu/drm/mgag200/mgag200_drv.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h index 5ea5033..4d932c4 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.h +++ b/drivers/gpu/drm/mgag200/mgag200_drv.h @@ -112,7 +112,6 @@ struct mga_framebuffer { struct mga_fbdev { struct drm_fb_helper helper; struct mga_framebuffer mfb; - struct list_head fbdev_list; void *sysram; int size; struct ttm_bo_kmap_obj mapping; -- 1.7.12.4
[PATCH] drm/mgag200: Cleanup: Remove pointless call to drm_fb_get_bpp_depth
Signed-off-by: Christopher Harvey --- drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c index 2f48648..d46bd2c 100644 --- a/drivers/gpu/drm/mgag200/mgag200_fb.c +++ b/drivers/gpu/drm/mgag200/mgag200_fb.c @@ -104,12 +104,9 @@ static int mgag200fb_create_object(struct mga_fbdev *afbdev, struct drm_gem_object **gobj_p) { struct drm_device *dev = afbdev->helper.dev; - u32 bpp, depth; u32 size; struct drm_gem_object *gobj; - int ret = 0; - drm_fb_get_bpp_depth(mode_cmd->pixel_format, , ); size = mode_cmd->pitches[0] * mode_cmd->height; ret = mgag200_gem_create(dev, size, true, ); -- 1.7.12.4
[PATCH] mgag200: some cleanup and a fix for corrupted output
Patches 1 to 4 are just cleanup. Maybe these should should be rolled into one patch? Patch 5 is a bit more complicated. On cards with very little video memory, (e.g 8MB) higher resolutions at 32bit framebuffer depths will get corrupted because the required memory is larger than what the framebuffer has. DRM has "max_height" and "max_width" but no "max_bytes" for limiting resolutions, so the patch is a little hacky. The first for loop tries to associate a connector with the mode being tested. From the connector I can get the bpp if the user specified one on the video= commandline. After that I do 2 things: 1) Invalidate the requested mode from the video= parameter 2) Return MODE_BAD if the framebuffer would be too large I feel this patch plays with structures it shouldn't have to touch to get the bpp. An alternative fix would be to include a "max_bytes" in the DRM core and then do these checks there. I'm also wondering, did I miss the 3.9.0 merge window? Thanks, Christopher Harvey (5): drm/mgag200: Cleanup: Remove pointless call to drm_fb_get_bpp_depth drm/mgag200: Cleanup: 'fbdev_list' in 'struct mga_fbdev' is not used drm/mgag200: Cleanup: Pass driver specific mga_device in driver functions drm/mgag200: Cleanup: Remove extra variable assigns drm/mgag200: Reject modes that are too big for VRAM drivers/gpu/drm/mgag200/mgag200_drv.h | 1 - drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- drivers/gpu/drm/mgag200/mgag200_mode.c | 34 ++ 4 files changed, 30 insertions(+), 10 deletions(-) -- 1.7.12.4
[PATCH] drm/mgag200: Cleanup: Remove pointless call to drm_fb_get_bpp_depth
Signed-off-by: Christopher Harvey char...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c index 2f48648..d46bd2c 100644 --- a/drivers/gpu/drm/mgag200/mgag200_fb.c +++ b/drivers/gpu/drm/mgag200/mgag200_fb.c @@ -104,12 +104,9 @@ static int mgag200fb_create_object(struct mga_fbdev *afbdev, struct drm_gem_object **gobj_p) { struct drm_device *dev = afbdev-helper.dev; - u32 bpp, depth; u32 size; struct drm_gem_object *gobj; - int ret = 0; - drm_fb_get_bpp_depth(mode_cmd-pixel_format, depth, bpp); size = mode_cmd-pitches[0] * mode_cmd-height; ret = mgag200_gem_create(dev, size, true, gobj); -- 1.7.12.4 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] drm/mgag200: Cleanup: Remove extra variable assigns
These two variables are set again immediately in 'mgag200_modeset_init' Signed-off-by: Christopher Harvey char...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c index 70dd3c5..aad280a 100644 --- a/drivers/gpu/drm/mgag200/mgag200_main.c +++ b/drivers/gpu/drm/mgag200/mgag200_main.c @@ -240,8 +240,6 @@ int mgag200_driver_load(struct drm_device *dev, unsigned long flags) drm_mode_config_init(dev); dev-mode_config.funcs = (void *)mga_mode_funcs; - dev-mode_config.min_width = 0; - dev-mode_config.min_height = 0; dev-mode_config.preferred_depth = 24; dev-mode_config.prefer_shadow = 1; -- 1.7.12.4 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] drm/mgag200: Cleanup: 'fbdev_list' in 'struct mga_fbdev' is not used
Signed-off-by: Christopher Harvey char...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_drv.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h index 5ea5033..4d932c4 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.h +++ b/drivers/gpu/drm/mgag200/mgag200_drv.h @@ -112,7 +112,6 @@ struct mga_framebuffer { struct mga_fbdev { struct drm_fb_helper helper; struct mga_framebuffer mfb; - struct list_head fbdev_list; void *sysram; int size; struct ttm_bo_kmap_obj mapping; -- 1.7.12.4 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] mgag200: some cleanup and a fix for corrupted output
Patches 1 to 4 are just cleanup. Maybe these should should be rolled into one patch? Patch 5 is a bit more complicated. On cards with very little video memory, (e.g 8MB) higher resolutions at 32bit framebuffer depths will get corrupted because the required memory is larger than what the framebuffer has. DRM has max_height and max_width but no max_bytes for limiting resolutions, so the patch is a little hacky. The first for loop tries to associate a connector with the mode being tested. From the connector I can get the bpp if the user specified one on the video= commandline. After that I do 2 things: 1) Invalidate the requested mode from the video= parameter 2) Return MODE_BAD if the framebuffer would be too large I feel this patch plays with structures it shouldn't have to touch to get the bpp. An alternative fix would be to include a max_bytes in the DRM core and then do these checks there. I'm also wondering, did I miss the 3.9.0 merge window? Thanks, Christopher Harvey (5): drm/mgag200: Cleanup: Remove pointless call to drm_fb_get_bpp_depth drm/mgag200: Cleanup: 'fbdev_list' in 'struct mga_fbdev' is not used drm/mgag200: Cleanup: Pass driver specific mga_device in driver functions drm/mgag200: Cleanup: Remove extra variable assigns drm/mgag200: Reject modes that are too big for VRAM drivers/gpu/drm/mgag200/mgag200_drv.h | 1 - drivers/gpu/drm/mgag200/mgag200_fb.c | 3 --- drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- drivers/gpu/drm/mgag200/mgag200_mode.c | 34 ++ 4 files changed, 30 insertions(+), 10 deletions(-) -- 1.7.12.4 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] drm/mgag200: Cleanup: Pass driver specific mga_device in driver functions
Signed-off-by: Christopher Harvey char...@matrox.com --- drivers/gpu/drm/mgag200/mgag200_mode.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index d3d99a2..3abf197 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -1261,9 +1261,8 @@ static const struct drm_crtc_helper_funcs mga_helper_funcs = { }; /* CRTC setup */ -static void mga_crtc_init(struct drm_device *dev) +static void mga_crtc_init(struct mga_device *mdev) { - struct mga_device *mdev = dev-dev_private; struct mga_crtc *mga_crtc; int i; @@ -1274,7 +1273,7 @@ static void mga_crtc_init(struct drm_device *dev) if (mga_crtc == NULL) return; - drm_crtc_init(dev, mga_crtc-base, mga_crtc_funcs); + drm_crtc_init(mdev-dev, mga_crtc-base, mga_crtc_funcs); drm_mode_crtc_set_gamma_size(mga_crtc-base, MGAG200_LUT_SIZE); mdev-mode_info.crtc = mga_crtc; @@ -1502,7 +1501,7 @@ int mgag200_modeset_init(struct mga_device *mdev) mdev-dev-mode_config.fb_base = mdev-mc.vram_base; - mga_crtc_init(mdev-dev); + mga_crtc_init(mdev); encoder = mga_encoder_init(mdev-dev); if (!encoder) { -- 1.7.12.4 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel