summaryrefslogtreecommitdiff
path: root/shared-core
AgeCommit message (Expand)Author
2004-08-30Fix copy_from_user return value ignored warning at via_dma.c:168.Erdi Chen
2004-08-27run i915 through lindentDave Airlie
2004-08-27__NO_VERSION__ hasn't been needed since 2.3 days ditch it...Dave Airlie
2004-08-26Rearrange things so that via_dma.c will compile with inline via_check_dmaJon Smirl
2004-08-24Merged drmfntbl-0-0-2Dave Airlie
2004-08-24This patch adds three new ioctl's to the VIA Unichrome/Pro DRM driver:Erdi Chen
2004-08-23set pointers to NULL after freeing, remove some extra debuggingDave Airlie
2004-08-17Merged drmfntbl-0-0-1Dave Airlie
2004-08-17preparation patch for radeon permanent mapping registers/framebuffer makesDave Airlie
2004-08-14Add a "dev" argument to DRIVER_CTX_[CD]TOR. This will be used in anEric Anholt
2004-08-13Fix apparent copy'n'paste-o of the card attributes commit that broke theEric Anholt
2004-08-10Patch from Jon Smirl to add attribute field to the pciids, and use this forDave Airlie
2004-08-02forgot to check these in.. thanks to Jon for reminding me ..Dave Airlie
2004-07-31patch from RH xorg-x11 tree ported to drm.hDave Airlie
2004-07-31fixes for using userspace pointers found by sparse utilityDave Airlie
2004-07-29initial port of i915 to BSD, not finished doesn't work.. no idea why...Dave Airlie
2004-07-25check for __user if not there define itDave Airlie
2004-07-25sync up with current 2.6 kernel bk tree - mostly __user annotationsDave Airlie
2004-07-23Correct a couple of packet length calculations.Keith Whitwell
2004-07-20Add NULLs instead of 0 for i915Dave Airlie
2004-07-15sparse cleanups from kernel: Al ViroDave Airlie
2004-07-05whitespace align with kernelDave Airlie
2004-06-10i915.o drm driverKeith Whitwell
2004-06-02Added some comments copied from xf86drm.h.Ian Romanick
2004-06-01Replace size_t with an ugly, ugly hack. This was done so that code in theIan Romanick
2004-05-18fix whitespace issue in previous patchRoland Scheidegger
2004-05-18add R200_EMIT_RB3D_BLENDCOLOR state packet to support GL_EXT_blend_color,Roland Scheidegger
2004-05-14Add PCI id entry for VIA CN400 (UnichromePro) chip. XFree86 bug: ReportedErdi Chen
2004-05-11Merge from FreeBSD-current. Mostly 64-bit cleanliness fixes, but a fewEric Anholt
2004-05-11Add missing DRM_ERR()s.Eric Anholt
2004-04-26add another tdfxDave Airlie
2004-04-21add new files to generate pci idsDave Airlie
2004-04-21centralise pci ids into one place and use scripts to generate files forDave Airlie
2004-04-121. Added a PCI ID.Thomas Hellstrom
2004-04-12Add mach64 to the trunkDave Airlie
2004-04-10white space changes to align with kernelDave Airlie
2004-04-08fix build problemAlan Hourihane
2004-04-08fixes from Linux kernelDave Airlie
2004-03-23Merged via-1-2-0Thomas Hellstrom
2004-03-12Fixes need to clean up the mess I made with the mesa merge. This codeJon Smirl
2004-02-18Fix sisfb header location for 2.6 kernelsMichel Daenzer
2004-01-10Make sure that all state packets are handled inMichel Daenzer
2004-01-10R200_PP_CUBIC_OFFSET_F1_[0-6] state packets only contain 5 offsets, not 6Michel Daenzer
2003-12-16Don't ioremap the framebuffer area. The ioremapped area wasn't used byEric Anholt
2003-11-05- Tie the DRM to a specific device: setunique no longer succeeds when givenEric Anholt
2003-11-05__linux__ is spelled with a lowercase 'l'Eric Anholt
2003-11-05Repo-copy linux/drm/kernel/drm.h to shared/drm/kernel/drm.h and use it onEric Anholt
2003-11-04Memory layout transition:Michel Daenzer
2003-10-23- Introduce a new ioctl, DRM_IOCTL_SET_VERSION. This ioctl allows theEric Anholt
2003-10-17- Move IRQ functions from drm_dma.h to new drm_irq.h and disentangle themEric Anholt
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898
/**************************************************************************
 *
 * Copyright (c) 2006-2007 Tungsten Graphics, Inc., Cedar Park, TX., USA
 * All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sub license, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial portions
 * of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
 * USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 **************************************************************************/
/*
 * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
 */

#ifndef _DRM_OBJECTS_H
#define _DRM_OBJECTS_H

struct drm_device;
struct drm_bo_mem_reg;

#define DRM_FENCE_FLAG_EMIT                0x00000001
#define DRM_FENCE_FLAG_SHAREABLE           0x00000002
/**
 * On hardware with no interrupt events for operation completion,
 * indicates that the kernel should sleep while waiting for any blocking
 * operation to complete rather than spinning.
 *
 * Has no effect otherwise.
 */
#define DRM_FENCE_FLAG_WAIT_LAZY           0x00000004
#define DRM_FENCE_FLAG_NO_USER             0x00000010

/* Reserved for driver use */
#define DRM_FENCE_MASK_DRIVER              0xFF000000

#define DRM_FENCE_TYPE_EXE                 0x00000001

struct drm_fence_arg {
	unsigned int handle;
	unsigned int fence_class;
	unsigned int type;
	unsigned int flags;
	unsigned int signaled;
	unsigned int error;
	unsigned int sequence;
	unsigned int pad64;
	uint64_t expand_pad[2]; /*Future expansion */
};

/* Buffer permissions, referring to how the GPU uses the buffers.
 * these translate to fence types used for the buffers.
 * Typically a texture buffer is read, A destination buffer is write and
 *  a command (batch-) buffer is exe. Can be or-ed together.
 */

#define DRM_BO_FLAG_READ        (1ULL << 0)
#define DRM_BO_FLAG_WRITE       (1ULL << 1)
#define DRM_BO_FLAG_EXE         (1ULL << 2)

/*
 * All of the bits related to access mode
 */
#define DRM_BO_MASK_ACCESS	(DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE | DRM_BO_FLAG_EXE)
/*
 * Status flags. Can be read to determine the actual state of a buffer.
 * Can also be set in the buffer mask before validation.
 */

/*
 * Mask: Never evict this buffer. Not even with force. This type of buffer is only
 * available to root and must be manually removed before buffer manager shutdown
 * or lock.
 * Flags: Acknowledge
 */
#define DRM_BO_FLAG_NO_EVICT    (1ULL << 4)

/*
 * Mask: Require that the buffer is placed in mappable memory when validated.
 *       If not set the buffer may or may not be in mappable memory when validated.
 * Flags: If set, the buffer is in mappable memory.
 */
#define DRM_BO_FLAG_MAPPABLE    (1ULL << 5)

/* Mask: The buffer should be shareable with other processes.
 * Flags: The buffer is shareable with other processes.
 */
#define DRM_BO_FLAG_SHAREABLE   (1ULL << 6)

/* Mask: If set, place the buffer in cache-coherent memory if available.
 *       If clear, never place the buffer in cache coherent memory if validated.
 * Flags: The buffer is currently in cache-coherent memory.
 */
#define DRM_BO_FLAG_CACHED      (1ULL << 7)

/* Mask: Make sure that every time this buffer is validated,
 *       it ends up on the same location provided that the memory mask is the same.
 *       The buffer will also not be evicted when claiming space for
 *       other buffers. Basically a pinned buffer but it may be thrown out as
 *       part of buffer manager shutdown or locking.
 * Flags: Acknowledge.
 */
#define DRM_BO_FLAG_NO_MOVE     (1ULL << 8)

/* Mask: Make sure the buffer is in cached memory when mapped.  In conjunction
 * with DRM_BO_FLAG_CACHED it also allows the buffer to be bound into the GART
 * with unsnooped PTEs instead of snooped, by using chipset-specific cache
 * flushing at bind time.  A better name might be DRM_BO_FLAG_TT_UNSNOOPED,
 * as the eviction to local memory (TTM unbind) on map is just a side effect
 * to prevent aggressive cache prefetch from the GPU disturbing the cache
 * management that the DRM is doing.
 *
 * Flags: Acknowledge.
 * Buffers allocated with this flag should not be used for suballocators
 * This type may have issues on CPUs with over-aggressive caching
 * http://marc.info/?l=linux-kernel&m=102376926732464&w=2
 */
#define DRM_BO_FLAG_CACHED_MAPPED    (1ULL << 19)


/* Mask: Force DRM_BO_FLAG_CACHED flag strictly also if it is set.
 * Flags: Acknowledge.
 */
#define DRM_BO_FLAG_FORCE_CACHING  (1ULL << 13)

/*
 * Mask: Force DRM_BO_FLAG_MAPPABLE flag strictly also if it is clear.
 * Flags: Acknowledge.
 */
#define DRM_BO_FLAG_FORCE_MAPPABLE (1ULL << 14)
#define DRM_BO_FLAG_TILE           (1ULL << 15)

/*
 * Buffer has been mapped or touched since creation
 * for VRAM we don't need to migrate, just fill with 0s for non-dirty
 */
#define DRM_BO_FLAG_CLEAN  (1ULL << 16)

/*
 * Memory type flags that can be or'ed together in the mask, but only
 * one appears in flags.
 */

/* System memory */
#define DRM_BO_FLAG_MEM_LOCAL  (1ULL << 24)
/* Translation table memory */
#define DRM_BO_FLAG_MEM_TT     (1ULL << 25)
/* Vram memory */
#define DRM_BO_FLAG_MEM_VRAM   (1ULL << 26)
/* Up to the driver to define. */
#define DRM_BO_FLAG_MEM_PRIV0  (1ULL << 27)
#define DRM_BO_FLAG_MEM_PRIV1  (1ULL << 28)
#define DRM_BO_FLAG_MEM_PRIV2  (1ULL << 29)
#define DRM_BO_FLAG_MEM_PRIV3  (1ULL << 30)
#define DRM_BO_FLAG_MEM_PRIV4  (1ULL << 31)
/* We can add more of these now with a 64-bit flag type */

/*
 * This is a mask covering all of the memory type flags; easier to just
 * use a single constant than a bunch of | values. It covers
 * DRM_BO_FLAG_MEM_LOCAL through DRM_BO_FLAG_MEM_PRIV4
 */
#define DRM_BO_MASK_MEM         0x00000000FF000000ULL
/*
 * This adds all of the CPU-mapping options in with the memory
 * type to label all bits which change how the page gets mapped
 */
#define DRM_BO_MASK_MEMTYPE     (DRM_BO_MASK_MEM | \
				 DRM_BO_FLAG_CACHED_MAPPED | \
				 DRM_BO_FLAG_CACHED | \
				 DRM_BO_FLAG_MAPPABLE)
				 
/* Driver-private flags */
#define DRM_BO_MASK_DRIVER      0xFFFF000000000000ULL

/*
 * Don't block on validate and map. Instead, return EBUSY.
 */
#define DRM_BO_HINT_DONT_BLOCK  0x00000002
/*
 * Don't place this buffer on the unfenced list. This means
 * that the buffer will not end up having a fence associated
 * with it as a result of this operation
 */
#define DRM_BO_HINT_DONT_FENCE  0x00000004
/**
 * On hardware with no interrupt events for operation completion,
 * indicates that the kernel should sleep while waiting for any blocking
 * operation to complete rather than spinning.
 *
 * Has no effect otherwise.
 */
#define DRM_BO_HINT_WAIT_LAZY   0x00000008
/*
 * The client has compute relocations refering to this buffer using the
 * offset in the presumed_offset field. If that offset ends up matching
 * where this buffer lands, the kernel is free to skip executing those
 * relocations
 */
#define DRM_BO_HINT_PRESUMED_OFFSET 0x00000010

#define DRM_BO_MEM_LOCAL 0
#define DRM_BO_MEM_TT 1
#define DRM_BO_MEM_VRAM 2
#define DRM_BO_MEM_PRIV0 3
#define DRM_BO_MEM_PRIV1 4
#define DRM_BO_MEM_PRIV2 5
#define DRM_BO_MEM_PRIV3 6
#define DRM_BO_MEM_PRIV4 7

#define DRM_BO_MEM_TYPES 8 /* For now. */

#define DRM_BO_LOCK_UNLOCK_BM       (1 << 0)
#define DRM_BO_LOCK_IGNORE_NO_EVICT (1 << 1)


/***************************************************
 * Fence objects. (drm_fence.c)
 */

struct drm_fence_object {
	struct drm_device *dev;
	atomic_t usage;

	/*
	 * The below three fields are protected by the fence manager spinlock.
	 */

	struct list_head ring;
	int fence_class;
	uint32_t native_types;
	uint32_t type;
	uint32_t signaled_types;
	uint32_t sequence;
	uint32_t waiting_types;
	uint32_t error;
};

#define _DRM_FENCE_CLASSES 8

struct drm_fence_class_manager {
	struct list_head ring;
	uint32_t pending_flush;
	uint32_t waiting_types;
	wait_queue_head_t fence_queue;
	uint32_t highest_waiting_sequence;
        uint32_t latest_queued_sequence;
};

struct drm_fence_manager {
	int initialized;
	rwlock_t lock;
	struct drm_fence_class_manager fence_class[_DRM_FENCE_CLASSES];
	uint32_t num_classes;
	atomic_t count;
};

struct drm_fence_driver {
	unsigned long *waiting_jiffies;
	uint32_t num_classes;
	uint32_t wrap_diff;
	uint32_t flush_diff;
	uint32_t sequence_mask;

	/*
	 * Driver implemented functions:
	 * has_irq() : 1 if the hardware can update the indicated type_flags using an
	 * irq handler. 0 if polling is required.
	 *
	 * emit() : Emit a sequence number to the command stream.
	 * Return the sequence number.
	 *
	 * flush() : Make sure the flags indicated in fc->pending_flush will eventually
	 * signal for fc->highest_received_sequence and all preceding sequences.
	 * Acknowledge by clearing the flags fc->pending_flush.
	 *
	 * poll() : Call drm_fence_handler with any new information.
	 *
	 * needed_flush() : Given the current state of the fence->type flags and previusly 
	 * executed or queued flushes, return the type_flags that need flushing.
	 *
	 * wait(): Wait for the "mask" flags to signal on a given fence, performing
	 * whatever's necessary to make this happen.
	 */

	int (*has_irq) (struct drm_device *dev, uint32_t fence_class,
			uint32_t flags);
	int (*emit) (struct drm_device *dev, uint32_t fence_class,
		     uint32_t flags, uint32_t *breadcrumb,
		     uint32_t *native_type);
	void (*flush) (struct drm_device *dev, uint32_t fence_class);
	void (*poll) (struct drm_device *dev, uint32_t fence_class,
		uint32_t types);
	uint32_t (*needed_flush) (struct drm_fence_object *fence);
	int (*wait) (struct drm_fence_object *fence, int lazy,
		     int interruptible, uint32_t mask);
};

extern int drm_fence_wait_polling(struct drm_fence_object *fence, int lazy,
				  int interruptible, uint32_t mask,
				  unsigned long end_jiffies);
extern void drm_fence_handler(struct drm_device *dev, uint32_t fence_class,
			      uint32_t sequence, uint32_t type,
			      uint32_t error);
extern void drm_fence_manager_init(struct drm_device *dev);
extern void drm_fence_manager_takedown(struct drm_device *dev);
extern void drm_fence_flush_old(struct drm_device *dev, uint32_t fence_class,
				uint32_t sequence);
extern int drm_fence_object_flush(struct drm_fence_object *fence,
				  uint32_t type);
extern int drm_fence_object_signaled(struct drm_fence_object *fence,
				     uint32_t type);
extern void drm_fence_usage_deref_locked(struct drm_fence_object **fence);
extern void drm_fence_usage_deref_unlocked(struct drm_fence_object **fence);
extern struct drm_fence_object *drm_fence_reference_locked(struct drm_fence_object *src);
extern void drm_fence_reference_unlocked(struct drm_fence_object **dst,
					 struct drm_fence_object *src);
extern int drm_fence_object_wait(struct drm_fence_object *fence,
				 int lazy, int ignore_signals, uint32_t mask);
extern int drm_fence_object_create(struct drm_device *dev, uint32_t type,
				   uint32_t fence_flags, uint32_t fence_class,
				   struct drm_fence_object **c_fence);
extern int drm_fence_object_emit(struct drm_fence_object *fence,
				 uint32_t fence_flags, uint32_t class,
				 uint32_t type);
extern void drm_fence_fill_arg(struct drm_fence_object *fence,
			       struct drm_fence_arg *arg);

extern int drm_fence_add_user_object(struct drm_file *priv,
				     struct drm_fence_object *fence,
				     int shareable);

extern int drm_fence_create_ioctl(struct drm_device *dev, void *data,
				  struct drm_file *file_priv);
extern int drm_fence_destroy_ioctl(struct drm_device *dev, void *data,
				   struct drm_file *file_priv);
extern int drm_fence_reference_ioctl(struct drm_device *dev, void *data,
				     struct drm_file *file_priv);
extern int drm_fence_unreference_ioctl(struct drm_device *dev, void *data,
				       struct drm_file *file_priv);
extern int drm_fence_signaled_ioctl(struct drm_device *dev, void *data,
				    struct drm_file *file_priv);