.gitignore | 2 bsd-core/drm_mode.h | 1 configure.ac | 4 libdrm/Makefile.am | 5 libdrm/intel/intel_bufmgr.h | 14 libdrm/intel/intel_bufmgr_gem.c | 281 +++- libdrm/xf86drm.c | 44 libdrm/xf86drm.h | 6 libdrm/xf86drmMode.c | 686 ++++++++++ libdrm/xf86drmMode.h | 258 ++++ linux-core/Makefile | 9 linux-core/Makefile.kernel | 6 linux-core/drm_mode.h | 1 shared-core/Makefile.am | 1 shared-core/drm.h | 30 shared-core/drm_mode.h | 273 ++++ shared-core/i915_drm.h | 68 - shared-core/nv50_graph.c | 6 shared-core/nv50_grctx.h | 2542 +++++++++++++++++++++++++++++++++++++--- shared-core/radeon_irq.c | 6 tests/Makefile.am | 4 tests/dristat.c | 2 tests/modeprint/Makefile.am | 13 tests/modeprint/modeprint.c | 402 ++++++ tests/modetest/Makefile.am | 13 tests/modetest/modetest.c | 470 +++++++ 26 files changed, 4906 insertions(+), 241 deletions(-)
New commits: commit a8c548034e38d7fb8afeca100230818b3cfcb9d9 Author: Jesse Barnes <jbar...@virtuousgeek.org> Date: Mon Dec 29 09:21:58 2008 -0800 Remove executable from modeprint test dir Accidentally committed it with the mode setting changes. diff --git a/tests/modeprint/app b/tests/modeprint/app deleted file mode 100755 index 82085c8..0000000 Binary files a/tests/modeprint/app and /dev/null differ commit 58d557c73b9e4ad1964fd083abeec74875c141cb Author: Robert Noland <rnol...@2hip.net> Date: Tue Dec 23 13:56:23 2008 -0500 [FreeBSD] Fix build on FreeBSD after modesetting import. diff --git a/bsd-core/drm_mode.h b/bsd-core/drm_mode.h new file mode 120000 index 0000000..a43f138 --- /dev/null +++ b/bsd-core/drm_mode.h @@ -0,0 +1 @@ +../shared-core/drm_mode.h \ No newline at end of file diff --git a/shared-core/drm_mode.h b/shared-core/drm_mode.h index 601d2bd..9b92733 100644 --- a/shared-core/drm_mode.h +++ b/shared-core/drm_mode.h @@ -27,11 +27,13 @@ #ifndef _DRM_MODE_H #define _DRM_MODE_H +#ifdef __linux__ #if !defined(__KERNEL__) && !defined(_KERNEL) #include <stdint.h> #else #include <linux/kernel.h> #endif +#endif #define DRM_DISPLAY_INFO_LEN 32 #define DRM_CONNECTOR_NAME_LEN 32 commit b48bd3a036efa3c3aa759759a5be4f80f1c3ac72 Author: Dave Airlie <airl...@redhat.com> Date: Tue Dec 23 11:22:44 2008 +1000 radeon: only write irq regs if irq is enabled diff --git a/shared-core/radeon_irq.c b/shared-core/radeon_irq.c index 6956996..836f384 100644 --- a/shared-core/radeon_irq.c +++ b/shared-core/radeon_irq.c @@ -44,7 +44,8 @@ void radeon_irq_set_state(struct drm_device *dev, u32 mask, int state) else dev_priv->irq_enable_reg &= ~mask; - RADEON_WRITE(RADEON_GEN_INT_CNTL, dev_priv->irq_enable_reg); + if (dev->irq_enabled) + RADEON_WRITE(RADEON_GEN_INT_CNTL, dev_priv->irq_enable_reg); } static void r500_vbl_irq_set_state(struct drm_device *dev, u32 mask, int state) @@ -56,7 +57,8 @@ static void r500_vbl_irq_set_state(struct drm_device *dev, u32 mask, int state) else dev_priv->r500_disp_irq_reg &= ~mask; - RADEON_WRITE(R500_DxMODE_INT_MASK, dev_priv->r500_disp_irq_reg); + if (dev->irq_enabled) + RADEON_WRITE(R500_DxMODE_INT_MASK, dev_priv->r500_disp_irq_reg); } int radeon_enable_vblank(struct drm_device *dev, int crtc) commit dfd7fdafd8a2bad0d63ced4a969b6278c221c000 Author: Eric Anholt <e...@anholt.net> Date: Wed Dec 17 13:55:53 2008 -0800 intel: Rename plane[AB]* back to pipe[AB]*. The values are really going to continue meaning pipe, not plane, and that's what they're called in the kernel copy of the header. Userland hasn't ever made the switch to pipe!=plane, since userland checks are based on DRM version, which is still stuck at 1.6. However, Mesa did start using plane[AB] names, so provide a compat define. diff --git a/shared-core/i915_drm.h b/shared-core/i915_drm.h index 628f7f8..04ab4cf 100644 --- a/shared-core/i915_drm.h +++ b/shared-core/i915_drm.h @@ -111,14 +111,25 @@ typedef struct drm_i915_sarea { unsigned int rotated_tiled; unsigned int rotated2_tiled; - int planeA_x; - int planeA_y; - int planeA_w; - int planeA_h; - int planeB_x; - int planeB_y; - int planeB_w; - int planeB_h; + /* compat defines for the period of time when pipeA_* got renamed + * to planeA_*. They mean pipe, really. + */ +#define planeA_x pipeA_x +#define planeA_y pipeA_y +#define planeA_w pipeA_w +#define planeA_h pipeA_h +#define planeB_x pipeB_x +#define planeB_y pipeB_y +#define planeB_w pipeB_w +#define planeB_h pipeB_h + int pipeA_x; + int pipeA_y; + int pipeA_w; + int pipeA_h; + int pipeB_x; + int pipeB_y; + int pipeB_w; + int pipeB_h; /* Triple buffering */ drm_handle_t third_handle; commit 28771e06dfe45027be6618f87335c19e8e88e3f6 Author: Eric Anholt <e...@anholt.net> Date: Wed Dec 17 13:47:59 2008 -0800 intel: Remove linux build of i915 DRM, as it's unmaintained and a user trap. The code's in the linux kernel. diff --git a/linux-core/Makefile b/linux-core/Makefile index 157664e..5235721 100644 --- a/linux-core/Makefile +++ b/linux-core/Makefile @@ -63,7 +63,7 @@ MODULE_LIST := drm.o tdfx.o r128.o radeon.o mga.o sis.o savage.o via.o \ # Modules only for ix86 architectures ifneq (,$(findstring 86,$(MACHINE))) ARCHX86 := 1 -MODULE_LIST += i810.o i915.o +MODULE_LIST += i810.o endif ifneq (,$(findstring sparc64,$(MACHINE))) @@ -281,7 +281,6 @@ CONFIG_DRM_MGA := n CONFIG_DRM_I810 := n CONFIG_DRM_R128 := n CONFIG_DRM_RADEON := n -CONFIG_DRM_I915 := n CONFIG_DRM_SIS := n CONFIG_DRM_FFB := n CONFIG_DRM_SAVAGE := n @@ -335,11 +334,6 @@ endif ifneq (,$(findstring i810,$(DRM_MODULES))) CONFIG_DRM_I810 := m endif -ifneq (,$(findstring i915,$(DRM_MODULES))) -ifeq ($(OS_HAS_GEM), 1) -CONFIG_DRM_I915 := m -endif -endif GIT_REVISION := $(shell cd "$(DRMSRCDIR)" && git describe --abbrev=17) ifneq ($(GIT_REVISION),) @@ -354,7 +348,6 @@ $(tdfx-objs): $(TDFXHEADERS) $(r128-objs): $(R128HEADERS) $(mga-objs): $(MGAHEADERS) $(i810-objs): $(I810HEADERS) -$(i915-objs): $(I915HEADERS) $(radeon-objs): $(RADEONHEADERS) $(sis-objs): $(SISHEADERS) $(ffb-objs): $(FFBHEADERS) diff --git a/linux-core/Makefile.kernel b/linux-core/Makefile.kernel index e5af2ec..1d577a7 100644 --- a/linux-core/Makefile.kernel +++ b/linux-core/Makefile.kernel @@ -19,10 +19,6 @@ tdfx-objs := tdfx_drv.o r128-objs := r128_drv.o r128_cce.o r128_state.o r128_irq.o mga-objs := mga_drv.o mga_dma.o mga_state.o mga_warp.o mga_irq.o i810-objs := i810_drv.o i810_dma.o -i915-objs := i915_drv.o i915_dma.o i915_irq.o i915_mem.o i915_fence.o \ - i915_buffer.o i915_compat.o i915_execbuf.o i915_suspend.o \ - i915_opregion.o \ - i915_gem.o i915_gem_debug.o i915_gem_proc.o i915_gem_tiling.o nouveau-objs := nouveau_drv.o nouveau_state.o nouveau_fifo.o nouveau_mem.o \ nouveau_object.o nouveau_irq.o nouveau_notifier.o nouveau_swmthd.o \ nouveau_sgdma.o nouveau_dma.o nouveau_bo.o nouveau_fence.o \ @@ -49,7 +45,6 @@ drm-objs += drm_ioc32.o radeon-objs += radeon_ioc32.o mga-objs += mga_ioc32.o r128-objs += r128_ioc32.o -i915-objs += i915_ioc32.o nouveau-objs += nouveau_ioc32.o xgi-objs += xgi_ioc32.o endif @@ -60,7 +55,6 @@ obj-$(CONFIG_DRM_R128) += r128.o obj-$(CONFIG_DRM_RADEON)+= radeon.o obj-$(CONFIG_DRM_MGA) += mga.o obj-$(CONFIG_DRM_I810) += i810.o -obj-$(CONFIG_DRM_I915) += i915.o obj-$(CONFIG_DRM_SIS) += sis.o obj-$(CONFIG_DRM_FFB) += ffb.o obj-$(CONFIG_DRM_SAVAGE)+= savage.o commit d221e00105477be824ff8878ba3c06b77efff84f Author: Eric Anholt <e...@anholt.net> Date: Wed Dec 17 13:45:01 2008 -0800 intel: Sync GEM ioctl comments for easier diffing against the kernel. diff --git a/shared-core/i915_drm.h b/shared-core/i915_drm.h index 976ff18..628f7f8 100644 --- a/shared-core/i915_drm.h +++ b/shared-core/i915_drm.h @@ -469,8 +469,12 @@ struct drm_i915_gem_pread { uint64_t offset; /** Length of data to read */ uint64_t size; - /** Pointer to write the data into. */ - uint64_t data_ptr; /* void *, but pointers are not 32/64 compatible */ + /** + * Pointer to write the data into. + * + * This is a fixed-size type for 32/64 compatibility. + */ + uint64_t data_ptr; }; struct drm_i915_gem_pwrite { @@ -481,8 +485,12 @@ struct drm_i915_gem_pwrite { uint64_t offset; /** Length of data to write */ uint64_t size; - /** Pointer to read the data from. */ - uint64_t data_ptr; /* void *, but pointers are not 32/64 compatible */ + /** + * Pointer to read the data from. + * + * This is a fixed-size type for 32/64 compatibility. + */ + uint64_t data_ptr; }; struct drm_i915_gem_mmap { @@ -497,8 +505,12 @@ struct drm_i915_gem_mmap { * The value will be page-aligned. */ uint64_t size; - /** Returned pointer the data was mapped at */ - uint64_t addr_ptr; /* void *, but pointers are not 32/64 compatible */ + /** + * Returned pointer the data was mapped at. + * + * This is a fixed-size type for 32/64 compatibility. + */ + uint64_t addr_ptr; }; struct drm_i915_gem_mmap_gtt { @@ -643,7 +655,8 @@ struct drm_i915_gem_execbuffer { uint32_t DR1; uint32_t DR4; uint32_t num_cliprects; - uint64_t cliprects_ptr; /* struct drm_clip_rect *cliprects */ + /** This is a struct drm_clip_rect *cliprects */ + uint64_t cliprects_ptr; }; struct drm_i915_gem_pin { commit 0243c9f801a35de3465a0321c02f18a4d07ce5b8 Author: Kristian Høgsberg <k...@redhat.com> Date: Thu Dec 18 00:02:43 2008 -0500 modetest: Print more stuff. Prettier. diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index e5a16e1..193057c 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -128,6 +128,22 @@ void dump_encoders(void) encoder->possible_clones); drmModeFreeEncoder(encoder); } + printf("\n"); +} + +void dump_mode(struct drm_mode_modeinfo *mode) +{ + printf(" %s %.02f %d %d %d %d %d %d %d %d\n", + mode->name, + (float)mode->vrefresh / 1000, + mode->hdisplay, + mode->hsync_start, + mode->hsync_end, + mode->htotal, + mode->vdisplay, + mode->vsync_start, + mode->vsync_end, + mode->vtotal); } void dump_connectors(void) @@ -160,24 +176,12 @@ void dump_connectors(void) printf(" modes:\n"); printf(" name refresh (Hz) hdisp hss hse htot vdisp " "vss vse vtot)\n"); - for (j = 0; j < connector->count_modes; j++) { - struct drm_mode_modeinfo *mode; + for (j = 0; j < connector->count_modes; j++) + dump_mode(&connector->modes[j]); - mode = &connector->modes[j]; - printf(" %s %.02f %d %d %d %d %d %d %d %d\n", - mode->name, - (float)mode->vrefresh / 1000, - mode->hdisplay, - mode->hsync_start, - mode->hsync_end, - mode->htotal, - mode->vdisplay, - mode->vsync_start, - mode->vsync_end, - mode->vtotal); - } drmModeFreeConnector(connector); } + printf("\n"); } void dump_crtcs(void) @@ -185,6 +189,8 @@ void dump_crtcs(void) drmModeCrtc *crtc; int i; + printf("CRTCs:\n"); + printf("id\tfb\tpos\tsize\n"); for (i = 0; i < resources->count_crtcs; i++) { crtc = drmModeGetCrtc(fd, resources->crtcs[i]); @@ -193,8 +199,16 @@ void dump_crtcs(void) resources->crtcs[i], strerror(errno)); continue; } + printf("%d\t%d\t(%d,%d)\t(%dx%d)\n", + crtc->crtc_id, + crtc->buffer_id, + crtc->x, crtc->y, + crtc->width, crtc->height); + dump_mode(&crtc->mode); + drmModeFreeCrtc(crtc); } + printf("\n"); } void dump_framebuffers(void) @@ -202,6 +216,8 @@ void dump_framebuffers(void) drmModeFB *fb; int i; + printf("Frame buffers:\n"); + printf("id\tsize\tpitch\n"); for (i = 0; i < resources->count_fbs; i++) { fb = drmModeGetFB(fd, resources->fbs[i]); @@ -210,8 +226,13 @@ void dump_framebuffers(void) resources->fbs[i], strerror(errno)); continue; } + printf("%d\t(%dx%d)\t%d\n", + fb->fb_id, + fb->width, fb->height); + drmModeFreeFB(fb); } + printf("\n"); } /* commit 06ab2f6436e26f77292d53e3ce2fe547d4a79fe3 Author: Eric Anholt <e...@anholt.net> Date: Wed Dec 17 10:41:21 2008 -0800 libdrm: Fix modetest/modeprint to use automake stuff. diff --git a/.gitignore b/.gitignore index 796e74c..bd78034 100644 --- a/.gitignore +++ b/.gitignore @@ -65,4 +65,5 @@ tests/gem_readwrite tests/openclose tests/setversion tests/updatedraw -tests/modetest +tests/modeprint/modeprint +tests/modetest/modetest diff --git a/configure.ac b/configure.ac index f4179fa..ccc58ef 100644 --- a/configure.ac +++ b/configure.ac @@ -119,4 +119,6 @@ AC_OUTPUT([ libdrm/intel/Makefile shared-core/Makefile tests/Makefile + tests/modeprint/Makefile + tests/modetest/Makefile libdrm.pc]) diff --git a/tests/Makefile.am b/tests/Makefile.am index 02b2ef0..e66d1c8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -15,7 +15,7 @@ libdrmtest_la_LIBADD = \ LDADD = libdrmtest.la -noinst_SUBDIRS = \ +SUBDIRS = \ modeprint \ modetest diff --git a/tests/modeprint/Makefile b/tests/modeprint/Makefile deleted file mode 100644 index 70788dc..0000000 --- a/tests/modeprint/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -all: app - -#CFLAGS = -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \ -# -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \ - -app: modeprint.c - @gcc $(CFLAGS) -o app -Wall -I../../libdrm -I../../shared-core -L../../libdrm/.libs -ldrm modeprint.c - -clean: - @rm -f app - -run: app - @sudo ./test diff --git a/tests/modeprint/Makefile.am b/tests/modeprint/Makefile.am new file mode 100644 index 0000000..77f8ec7 --- /dev/null +++ b/tests/modeprint/Makefile.am @@ -0,0 +1,13 @@ +AM_CFLAGS = \ + -I$(top_srcdir)/shared-core \ + -I$(top_srcdir)/libdrm/intel/ \ + -I$(top_srcdir)/libdrm + +noinst_PROGRAMS = \ + modeprint + +modeprint_SOURCES = \ + modeprint.c +modeprint_LDADD = \ + $(top_builddir)/libdrm/libdrm.la \ + $(top_builddir)/libdrm/intel/libdrm_intel.la diff --git a/tests/modeprint/test b/tests/modeprint/test deleted file mode 100644 index bd1952c..0000000 --- a/tests/modeprint/test +++ /dev/null @@ -1 +0,0 @@ -LD_PRELOAD=../../libdrm/.libs/libdrm.so ./app $@ diff --git a/tests/modetest/Makefile b/tests/modetest/Makefile deleted file mode 100644 index 8583ae8..0000000 --- a/tests/modetest/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -all: app - -#CFLAGS = -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \ -# -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \ - -app: modetest.c - gcc $(CFLAGS) -o app -Wall -I../../libdrm -I../../libdrm/intel -I../../shared-core -L../../libdrm/.libs -L../../libdrm/intel/.libs -ldrm -ldrm_intel modetest.c - -clean: - @rm -f app - -run: app - sudo ./test diff --git a/tests/modetest/Makefile.am b/tests/modetest/Makefile.am new file mode 100644 index 0000000..b89c489 --- /dev/null +++ b/tests/modetest/Makefile.am @@ -0,0 +1,13 @@ +AM_CFLAGS = \ + -I$(top_srcdir)/shared-core \ + -I$(top_srcdir)/libdrm/intel/ \ + -I$(top_srcdir)/libdrm + +noinst_PROGRAMS = \ + modetest + +modetest_SOURCES = \ + modetest.c +modetest_LDADD = \ + $(top_builddir)/libdrm/libdrm.la \ + $(top_builddir)/libdrm/intel/libdrm_intel.la diff --git a/tests/modetest/test b/tests/modetest/test deleted file mode 100644 index 5bb552e..0000000 --- a/tests/modetest/test +++ /dev/null @@ -1,2 +0,0 @@ -export LD_LIBRARY_PATH=../../libdrm/.libs:../../libdrm/intel/.libs -LD_PRELOAD=../../libdrm/.libs/libdrm.so ./app $@ commit 18f091d136cd44ab397817f8a3e89c21e9561a31 Author: Keith Packard <kei...@keithp.com> Date: Mon Dec 15 15:08:12 2008 -0800 intel: Cache tiling/swizzle state in user mode. Reset tiling on reuse. Remember tiling mode values provided by appplications, and record tiling mode when creating a buffer from another application. This eliminates any need to ask the kernel for tiling values and also makes reused buffers get the right tiling. Signed-off-by: Keith Packard <kei...@keithp.com> diff --git a/libdrm/intel/intel_bufmgr_gem.c b/libdrm/intel/intel_bufmgr_gem.c index 5e9350f..c510e5e 100644 --- a/libdrm/intel/intel_bufmgr_gem.c +++ b/libdrm/intel/intel_bufmgr_gem.c @@ -127,6 +127,12 @@ struct _drm_intel_bo_gem { */ int swrast; + /** + * Current tiling mode + */ + uint32_t tiling_mode; + uint32_t swizzle_mode; + /** Array passed to the DRM containing relocation information. */ struct drm_i915_gem_relocation_entry *relocs; /** Array of bos corresponding to relocs[i].target_handle */ @@ -170,6 +176,17 @@ static unsigned int drm_intel_gem_compute_batch_space(drm_intel_bo **bo_array, int count); static int +drm_intel_gem_bo_get_tiling(drm_intel_bo *bo, uint32_t *tiling_mode, + uint32_t *swizzle_mode); + +static int +drm_intel_gem_bo_set_tiling(drm_intel_bo *bo, uint32_t *tiling_mode, + uint32_t stride); + +static void +drm_intel_gem_bo_unreference(drm_intel_bo *bo); + +static int logbase2(int n) { int i = 1; @@ -370,6 +387,8 @@ drm_intel_gem_bo_alloc(drm_intel_bufmgr *bufmgr, const char *name, bo_gem->validate_index = -1; bo_gem->reloc_tree_size = bo_gem->bo.size; bo_gem->used_as_reloc_target = 0; + bo_gem->tiling_mode = I915_TILING_NONE; + bo_gem->swizzle_mode = I915_BIT_6_SWIZZLE_NONE; DBG("bo_create: buf %d (%s) %ldb\n", bo_gem->gem_handle, bo_gem->name, size); @@ -391,6 +410,7 @@ drm_intel_bo_gem_create_from_name(drm_intel_bufmgr *bufmgr, const char *name, drm_intel_bo_gem *bo_gem; int ret; struct drm_gem_open open_arg; + struct drm_i915_gem_get_tiling get_tiling; bo_gem = calloc(1, sizeof(*bo_gem)); if (!bo_gem) @@ -415,6 +435,15 @@ drm_intel_bo_gem_create_from_name(drm_intel_bufmgr *bufmgr, const char *name, bo_gem->gem_handle = open_arg.handle; bo_gem->global_name = handle; + get_tiling.handle = bo_gem->gem_handle; + ret = ioctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling); + if (ret != 0) { + drm_intel_gem_bo_unreference(&bo_gem->bo); + return NULL; + } + bo_gem->tiling_mode = get_tiling.tiling_mode; + bo_gem->swizzle_mode = get_tiling.swizzle_mode; + DBG("bo_create_from_handle: %d (%s)\n", handle, bo_gem->name); return &bo_gem->bo; @@ -469,6 +498,7 @@ drm_intel_gem_bo_unreference_locked(drm_intel_bo *bo) if (--bo_gem->refcount == 0) { struct drm_intel_gem_bo_bucket *bucket; + uint32_t tiling_mode; if (bo_gem->relocs != NULL) { int i; @@ -485,11 +515,13 @@ drm_intel_gem_bo_unreference_locked(drm_intel_bo *bo) bucket = drm_intel_gem_bo_bucket_for_size(bufmgr_gem, bo->size); /* Put the buffer into our internal cache for reuse if we can. */ + tiling_mode = I915_TILING_NONE; if (bo_gem->global_name == 0 && bucket != NULL && (bucket->max_entries == -1 || (bucket->max_entries > 0 && - bucket->num_entries < bucket->max_entries))) + bucket->num_entries < bucket->max_entries)) && + drm_intel_gem_bo_set_tiling(bo, &tiling_mode, 0) == 0) { bo_gem->name = NULL; bo_gem->validate_index = -1; @@ -1001,17 +1033,22 @@ drm_intel_gem_bo_set_tiling(drm_intel_bo *bo, uint32_t *tiling_mode, struct drm_i915_gem_set_tiling set_tiling; int ret; + if (bo_gem->global_name == 0 && *tiling_mode == bo_gem->tiling_mode) + return 0; + set_tiling.handle = bo_gem->gem_handle; set_tiling.tiling_mode = *tiling_mode; set_tiling.stride = stride; ret = ioctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_SET_TILING, &set_tiling); if (ret != 0) { - *tiling_mode = I915_TILING_NONE; + *tiling_mode = bo_gem->tiling_mode; return -errno; } + bo_gem->tiling_mode = set_tiling.tiling_mode; + bo_gem->swizzle_mode = set_tiling.swizzle_mode; - *tiling_mode = set_tiling.tiling_mode; + *tiling_mode = bo_gem->tiling_mode; return 0; } @@ -1019,22 +1056,10 @@ static int drm_intel_gem_bo_get_tiling(drm_intel_bo *bo, uint32_t *tiling_mode, uint32_t *swizzle_mode) { - drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bo->bufmgr; drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *)bo; - struct drm_i915_gem_get_tiling get_tiling; - int ret; - - get_tiling.handle = bo_gem->gem_handle; - - ret = ioctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling); - if (ret != 0) { - *tiling_mode = I915_TILING_NONE; - *swizzle_mode = I915_BIT_6_SWIZZLE_NONE; - return -errno; - } - *tiling_mode = get_tiling.tiling_mode; - *swizzle_mode = get_tiling.swizzle_mode; + *tiling_mode = bo_gem->tiling_mode; + *swizzle_mode = bo_gem->swizzle_mode; return 0; } commit 40334c64107a2938c41af6e34bda9f2094d1c6ec Author: Keith Packard <kei...@keithp.com> Date: Mon Dec 15 15:08:17 2008 -0800 intel: Debug output %u vs uint64_t warning fix Signed-off-by: Keith Packard <kei...@keithp.com> diff --git a/libdrm/intel/intel_bufmgr_gem.c b/libdrm/intel/intel_bufmgr_gem.c index dbce938..5e9350f 100644 --- a/libdrm/intel/intel_bufmgr_gem.c +++ b/libdrm/intel/intel_bufmgr_gem.c @@ -931,7 +931,7 @@ drm_intel_gem_bo_exec(drm_intel_bo *bo, int used, bufmgr_gem->exec_count), drm_intel_gem_compute_batch_space(bufmgr_gem->exec_bos, bufmgr_gem->exec_count), - bufmgr_gem->gtt_size); + (unsigned int) bufmgr_gem->gtt_size); } drm_intel_update_buffer_offsets (bufmgr_gem); commit bd14b2cf7551826c6437bbf1d8409cebd45615a5 Author: Keith Packard <kei...@keithp.com> Date: Sat Dec 13 11:06:11 2008 -0800 intel: return error status from drm_intel_gem_bo_map Applications may actually care if the mapping operation failed, so when it happens, return an error indication. errno is probably trashed by fprintf though. Signed-off-by: Keith Packard <kei...@keithp.com> diff --git a/libdrm/intel/intel_bufmgr_gem.c b/libdrm/intel/intel_bufmgr_gem.c index c94f82e..dbce938 100644 --- a/libdrm/intel/intel_bufmgr_gem.c +++ b/libdrm/intel/intel_bufmgr_gem.c @@ -544,6 +544,8 @@ drm_intel_gem_bo_map(drm_intel_bo *bo, int write_enable) fprintf(stderr, "%s:%d: Error mapping buffer %d (%s): %s .\n", __FILE__, __LINE__, bo_gem->gem_handle, bo_gem->name, strerror(errno)); + pthread_mutex_unlock(&bufmgr_gem->lock); + return ret; } bo_gem->virtual = (void *)(uintptr_t)mmap_arg.addr_ptr; bo_gem->swrast = 0; @@ -566,6 +568,8 @@ drm_intel_gem_bo_map(drm_intel_bo *bo, int write_enable) if (ret != 0) { fprintf (stderr, "%s:%d: Error setting swrast %d: %s\n", __FILE__, __LINE__, bo_gem->gem_handle, strerror (errno)); + pthread_mutex_unlock(&bufmgr_gem->lock); + return ret; } bo_gem->swrast = 1; } commit b13f4e1a32ab98fa719a3233cad59ff4d49cfb38 Author: Keith Packard <kei...@keithp.com> Date: Fri Nov 21 01:49:39 2008 -0800 intel: Dump out memory usage information when the kernel fails to pin The execbuffer ioctl returns ENOMEM when it fails to pin all of the buffers in the GTT. This is usually caused by the DRM client attempting to use too much memory in a single request. Dumping out the requested and available memory values should help point out failures in the DRM code to catch over commitments of this form. Signed-off-by: Keith Packard <kei...@keithp.com> diff --git a/libdrm/intel/intel_bufmgr_gem.c b/libdrm/intel/intel_bufmgr_gem.c index 9605cc7..c94f82e 100644 --- a/libdrm/intel/intel_bufmgr_gem.c +++ b/libdrm/intel/intel_bufmgr_gem.c @@ -163,6 +163,12 @@ struct _drm_intel_bo_gem { static void drm_intel_gem_bo_reference_locked(drm_intel_bo *bo); +static unsigned int +drm_intel_gem_estimate_batch_space(drm_intel_bo **bo_array, int count); + +static unsigned int +drm_intel_gem_compute_batch_space(drm_intel_bo **bo_array, int count); + static int logbase2(int n) { @@ -915,6 +921,14 @@ drm_intel_gem_bo_exec(drm_intel_bo *bo, int used, ret = ioctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_EXECBUFFER, &execbuf); } while (ret != 0 && errno == EAGAIN); + if (ret != 0 && errno == ENOMEM) { + fprintf(stderr, "Execbuffer fails to pin. Estimate: %u. Actual: %u. Available: %u\n", + drm_intel_gem_estimate_batch_space(bufmgr_gem->exec_bos, + bufmgr_gem->exec_count), + drm_intel_gem_compute_batch_space(bufmgr_gem->exec_bos, + bufmgr_gem->exec_count), + bufmgr_gem->gtt_size); + } drm_intel_update_buffer_offsets (bufmgr_gem); if (bufmgr_gem->bufmgr.debug) @@ -1102,6 +1116,43 @@ drm_intel_gem_bo_clear_aperture_space_flag(drm_intel_bo *bo) } /** + * Return a conservative estimate for the amount of aperture required + * for a collection of buffers. This may double-count some buffers. + */ +static unsigned int +drm_intel_gem_estimate_batch_space(drm_intel_bo **bo_array, int count) +{ + int i; + unsigned int total = 0; + + for (i = 0; i < count; i++) { + drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *)bo_array[i]; + if (bo_gem != NULL) + total += bo_gem->reloc_tree_size; + } + return total; +} + +/** + * Return the amount of aperture needed for a collection of buffers. + * This avoids double counting any buffers, at the cost of looking + * at every buffer in the set. + */ +static unsigned int +drm_intel_gem_compute_batch_space(drm_intel_bo **bo_array, int count) +{ + int i; + unsigned int total = 0; + + for (i = 0; i < count; i++) + total += drm_intel_gem_bo_get_aperture_space(bo_array[i]); + + for (i = 0; i < count; i++) + drm_intel_gem_bo_clear_aperture_space_flag(bo_array[i]); + return total; +} + +/** * Return -1 if the batchbuffer should be flushed before attempting to * emit rendering referencing the buffers pointed to by bo_array. * @@ -1123,24 +1174,13 @@ drm_intel_gem_check_aperture_space(drm_intel_bo **bo_array, int count) drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bo_array[0]->bufmgr; unsigned int total = 0; unsigned int threshold = bufmgr_gem->gtt_size * 3 / 4; - int i; - for (i = 0; i < count; i++) { - drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *)bo_array[i]; - if (bo_gem != NULL) - total += bo_gem->reloc_tree_size; - } + total = drm_intel_gem_estimate_batch_space(bo_array, count); + + if (total > threshold) + total = drm_intel_gem_compute_batch_space(bo_array, count); if (total > threshold) { - total = 0; - for (i = 0; i < count; i++) - total += drm_intel_gem_bo_get_aperture_space(bo_array[i]); - - for (i = 0; i < count; i++) - drm_intel_gem_bo_clear_aperture_space_flag(bo_array[i]); - } - - if (total > bufmgr_gem->gtt_size * 3 / 4) { DBG("check_space: overflowed available aperture, %dkb vs %dkb\n", total / 1024, (int)bufmgr_gem->gtt_size / 1024); return -1; commit 731cd5526e5c732d51307b26e784f454a724a699 Author: Jesse Barnes <jbar...@virtuousgeek.org> Date: Wed Dec 17 10:09:49 2008 -0800 libdrm: add mode setting files Add mode setting files to libdrm, including xf86drmMode.* and the new drm_mode.h header. Also add a couple of tests to sanity check the kernel interfaces and update code to support them. diff --git a/libdrm/Makefile.am b/libdrm/Makefile.am index a5be36e..eb63abe 100644 --- a/libdrm/Makefile.am +++ b/libdrm/Makefile.am @@ -26,9 +26,10 @@ libdrm_la_LDFLAGS = -version-number 2:4:0 -no-undefined AM_CFLAGS = -I$(top_srcdir)/shared-core libdrm_la_SOURCES = xf86drm.c xf86drmHash.c xf86drmRandom.c xf86drmSL.c \ + xf86drmMode.c libdrm_lists.h libdrm_lists.h libdrmincludedir = ${includedir} -libdrminclude_HEADERS = xf86drm.h +libdrminclude_HEADERS = xf86drm.h xf86drmMode.h EXTRA_DIST = ChangeLog TODO diff --git a/libdrm/intel/intel_bufmgr.h b/libdrm/intel/intel_bufmgr.h index f134f16..e8c2e06 100644 --- a/libdrm/intel/intel_bufmgr.h +++ b/libdrm/intel/intel_bufmgr.h @@ -66,6 +66,11 @@ struct _drm_intel_bo { /** Buffer manager context associated with this buffer object */ drm_intel_bufmgr *bufmgr; + + /** + * MM-specific handle for accessing object + */ + int handle; }; drm_intel_bo *drm_intel_bo_alloc(drm_intel_bufmgr *bufmgr, const char *name, diff --git a/libdrm/intel/intel_bufmgr_gem.c b/libdrm/intel/intel_bufmgr_gem.c index e5a1375..9605cc7 100644 --- a/libdrm/intel/intel_bufmgr_gem.c +++ b/libdrm/intel/intel_bufmgr_gem.c @@ -351,6 +351,7 @@ drm_intel_gem_bo_alloc(drm_intel_bufmgr *bufmgr, const char *name, ret = ioctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_CREATE, &create); bo_gem->gem_handle = create.handle; + bo_gem->bo.handle = bo_gem->gem_handle; if (ret != 0) { free(bo_gem); return NULL; diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c index c36f196..0b5d31f 100644 --- a/libdrm/xf86drm.c +++ b/libdrm/xf86drm.c @@ -87,6 +87,9 @@ #define DRM_MSG_VERBOSITY 3 +#define DRM_NODE_CONTROL 0 +#define DRM_NODE_RENDER 1 + static drmServerInfoPtr drm_server_info; void drmSetServerInfo(drmServerInfoPtr info) @@ -174,7 +177,7 @@ static char *drmStrdup(const char *s) /** * Call ioctl, restarting if it is interupted */ -static int +int drmIoctl(int fd, unsigned long request, void *arg) { int ret; @@ -277,7 +280,7 @@ static int drmMatchBusID(const char *id1, const char *id2) * special file node with the major and minor numbers specified by \p dev and * parent directory if necessary and was called by root. */ -static int drmOpenDevice(long dev, int minor) +static int drmOpenDevice(long dev, int minor, int type) { stat_t st; char buf[64]; @@ -287,7 +290,7 @@ static int drmOpenDevice(long dev, int minor) uid_t user = DRM_DEV_UID; gid_t group = DRM_DEV_GID, serv_group; - sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, minor); + sprintf(buf, type ? DRM_DEV_NAME : DRM_CONTROL_DEV_NAME, DRM_DIR_NAME, minor); drmMsg("drmOpenDevice: node name is %s\n", buf); if (drm_server_info) { @@ -386,15 +389,15 @@ wait_for_udev: * Calls drmOpenDevice() if \p create is set, otherwise assembles the device * name from \p minor and opens it. */ -static int drmOpenMinor(int minor, int create) +static int drmOpenMinor(int minor, int create, int type) { int fd; char buf[64]; if (create) - return drmOpenDevice(makedev(DRM_MAJOR, minor), minor); + return drmOpenDevice(makedev(DRM_MAJOR, minor), minor, type); - sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, minor); + sprintf(buf, type ? DRM_DEV_NAME : DRM_CONTROL_DEV_NAME, DRM_DIR_NAME, minor); if ((fd = open(buf, O_RDWR, 0)) >= 0) return fd; return -errno; @@ -417,7 +420,7 @@ int drmAvailable(void) int retval = 0; int fd; -- To UNSUBSCRIBE, email to debian-x-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org