Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 08244c00 authored by Dave Airlie's avatar Dave Airlie
Browse files

Merge tag 'topic/drm-misc-2016-02-18' of git://anongit.freedesktop.org/drm-intel into drm-next

Misc stuff all over:
- more mode_fixup removal from Carlos, there's another final pile still
  left.
- final bits of vgaswitcheroo from Lukas for apple gmux, we're still
  discussing an api cleanup patch to make it a bit more abuse-safe as a
  follow-up
- dp aux interface for userspace for tools&tests from Rafael Antognolli
- actual interface parts for dma-buf flushing for userspace mmap
- few small bits all over

- vgaswitcheroo support for apple gmux from Lukas Wunner
- checks for ->mode_fixup in non-atomic helpers from Carlos Palminha, plus
  removing dummy funcs from drivers. Carlos promised to follow up with
  more, since there's lots more silly dummy functions around.
- dma-buf patches from Tiago, except the ioctl itself (that needed a
  respin to address review from David Herrmann)
- encoder mask for atomic from Maarten
- bunch of random things all over.

* tag 'topic/drm-misc-2016-02-18' of git://anongit.freedesktop.org/drm-intel: (57 commits)
  drm/udl: Use module_usb_driver
  drm: fixes crct set_mode when crtc mode_fixup is null.
  drm/tilcdc: removed optional dummy encoder mode_fixup function.
  drm/sti: removed optional dummy encoder mode_fixup function.
  drm/rockchip: removed optional dummy encoder mode_fixup function.
  drm/qxl: removed optional dummy encoder mode_fixup function.
  drm/mgag200: removed optional dummy encoder mode_fixup function.
  drm/msm/mdp: removed optional dummy encoder mode_fixup function.
  drm/imx: removed optional dummy encoder mode_fixup function.
  drm/gma500: removed optional dummy encoder mode_fixup function.
  drm/radeon: removed optional dummy encoder mode_fixup function.
  drm/cirrus: removed optional dummy encoder mode_fixup function.
  drm/bochs: removed optional dummy encoder mode_fixup function.
  drm/ast: removed optional dummy encoder mode_fixup function.
  drm/amdgpu: removed optional dummy encoder mode_fixup function.
  drm/exynos: removed optional dummy encoder mode_fixup function.
  drm/udl: removed optional dummy encoder mode_fixup function.
  drm/virtio: removed optional dummy encoder mode_fixup function.
  drm/fb_helper: Use add_one_connector in add_all_connectors.
  drm/fb_helper: Use correct allocation count for arrays.
  ...
parents 5443ce86 a6ddd2f1
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -3422,6 +3422,7 @@ int num_ioctls;</synopsis>
    </sect1>
    <sect1>
      <title>Public constants</title>
!Finclude/linux/vga_switcheroo.h vga_switcheroo_handler_flags_t
!Finclude/linux/vga_switcheroo.h vga_switcheroo_client_id
!Finclude/linux/vga_switcheroo.h vga_switcheroo_state
    </sect1>
@@ -3450,6 +3451,10 @@ int num_ioctls;</synopsis>
        <title>Backlight control</title>
!Pdrivers/platform/x86/apple-gmux.c Backlight control
      </sect2>
      <sect2>
        <title>Public functions</title>
!Iinclude/linux/apple-gmux.h
      </sect2>
    </sect1>
  </chapter>

+28 −12
Original line number Diff line number Diff line
@@ -257,17 +257,15 @@ Access to a dma_buf from the kernel context involves three steps:

   Interface:
      int dma_buf_begin_cpu_access(struct dma_buf *dmabuf,
				   size_t start, size_t len,
				   enum dma_data_direction direction)

   This allows the exporter to ensure that the memory is actually available for
   cpu access - the exporter might need to allocate or swap-in and pin the
   backing storage. The exporter also needs to ensure that cpu access is
   coherent for the given range and access direction. The range and access
   direction can be used by the exporter to optimize the cache flushing, i.e.
   access outside of the range or with a different direction (read instead of
   write) might return stale or even bogus data (e.g. when the exporter needs to
   copy the data to temporary storage).
   coherent for the access direction. The direction can be used by the exporter
   to optimize the cache flushing, i.e. access with a different direction (read
   instead of write) might return stale or even bogus data (e.g. when the
   exporter needs to copy the data to temporary storage).

   This step might fail, e.g. in oom conditions.

@@ -322,14 +320,13 @@ Access to a dma_buf from the kernel context involves three steps:

3. Finish access

   When the importer is done accessing the range specified in begin_cpu_access,
   it needs to announce this to the exporter (to facilitate cache flushing and
   unpinning of any pinned resources). The result of any dma_buf kmap calls
   after end_cpu_access is undefined.
   When the importer is done accessing the CPU, it needs to announce this to
   the exporter (to facilitate cache flushing and unpinning of any pinned
   resources). The result of any dma_buf kmap calls after end_cpu_access is
   undefined.

   Interface:
      void dma_buf_end_cpu_access(struct dma_buf *dma_buf,
				  size_t start, size_t len,
				  enum dma_data_direction dir);


@@ -353,7 +350,26 @@ Being able to mmap an export dma-buf buffer object has 2 main use-cases:
   handles, too). So it's beneficial to support this in a similar fashion on
   dma-buf to have a good transition path for existing Android userspace.

   No special interfaces, userspace simply calls mmap on the dma-buf fd.
   No special interfaces, userspace simply calls mmap on the dma-buf fd, making
   sure that the cache synchronization ioctl (DMA_BUF_IOCTL_SYNC) is *always*
   used when the access happens. This is discussed next paragraphs.

   Some systems might need some sort of cache coherency management e.g. when
   CPU and GPU domains are being accessed through dma-buf at the same time. To
   circumvent this problem there are begin/end coherency markers, that forward
   directly to existing dma-buf device drivers vfunc hooks. Userspace can make
   use of those markers through the DMA_BUF_IOCTL_SYNC ioctl. The sequence
   would be used like following:
     - mmap dma-buf fd
     - for each drawing/upload cycle in CPU 1. SYNC_START ioctl, 2. read/write
       to mmap area 3. SYNC_END ioctl. This can be repeated as often as you
       want (with the new data being consumed by the GPU or say scanout device)
     - munmap once you don't need the buffer any more

    Therefore, for correctness and optimal performance, systems with the memory
    cache shared by the GPU and CPU i.e. the "coherent" and also the
    "incoherent" are always required to use SYNC_START and SYNC_END before and
    after, respectively, when accessing the mapped address.

2. Supporting existing mmap interfaces in importers

+49 −9
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@
#include <linux/poll.h>
#include <linux/reservation.h>

#include <uapi/linux/dma-buf.h>

static inline int is_dma_buf_file(struct file *);

struct dma_buf_list {
@@ -251,11 +253,54 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll)
	return events;
}

static long dma_buf_ioctl(struct file *file,
			  unsigned int cmd, unsigned long arg)
{
	struct dma_buf *dmabuf;
	struct dma_buf_sync sync;
	enum dma_data_direction direction;

	dmabuf = file->private_data;

	switch (cmd) {
	case DMA_BUF_IOCTL_SYNC:
		if (copy_from_user(&sync, (void __user *) arg, sizeof(sync)))
			return -EFAULT;

		if (sync.flags & ~DMA_BUF_SYNC_VALID_FLAGS_MASK)
			return -EINVAL;

		switch (sync.flags & DMA_BUF_SYNC_RW) {
		case DMA_BUF_SYNC_READ:
			direction = DMA_FROM_DEVICE;
			break;
		case DMA_BUF_SYNC_WRITE:
			direction = DMA_TO_DEVICE;
			break;
		case DMA_BUF_SYNC_RW:
			direction = DMA_BIDIRECTIONAL;
			break;
		default:
			return -EINVAL;
		}

		if (sync.flags & DMA_BUF_SYNC_END)
			dma_buf_end_cpu_access(dmabuf, direction);
		else
			dma_buf_begin_cpu_access(dmabuf, direction);

		return 0;
	default:
		return -ENOTTY;
	}
}

static const struct file_operations dma_buf_fops = {
	.release	= dma_buf_release,
	.mmap		= dma_buf_mmap_internal,
	.llseek		= dma_buf_llseek,
	.poll		= dma_buf_poll,
	.unlocked_ioctl	= dma_buf_ioctl,
};

/*
@@ -539,13 +584,11 @@ EXPORT_SYMBOL_GPL(dma_buf_unmap_attachment);
 * preparations. Coherency is only guaranteed in the specified range for the
 * specified access direction.
 * @dmabuf:	[in]	buffer to prepare cpu access for.
 * @start:	[in]	start of range for cpu access.
 * @len:	[in]	length of range for cpu access.
 * @direction:	[in]	length of range for cpu access.
 *
 * Can return negative error values, returns 0 on success.
 */
int dma_buf_begin_cpu_access(struct dma_buf *dmabuf, size_t start, size_t len,
int dma_buf_begin_cpu_access(struct dma_buf *dmabuf,
			     enum dma_data_direction direction)
{
	int ret = 0;
@@ -554,8 +597,7 @@ int dma_buf_begin_cpu_access(struct dma_buf *dmabuf, size_t start, size_t len,
		return -EINVAL;

	if (dmabuf->ops->begin_cpu_access)
		ret = dmabuf->ops->begin_cpu_access(dmabuf, start,
							len, direction);
		ret = dmabuf->ops->begin_cpu_access(dmabuf, direction);

	return ret;
}
@@ -567,19 +609,17 @@ EXPORT_SYMBOL_GPL(dma_buf_begin_cpu_access);
 * actions. Coherency is only guaranteed in the specified range for the
 * specified access direction.
 * @dmabuf:	[in]	buffer to complete cpu access for.
 * @start:	[in]	start of range for cpu access.
 * @len:	[in]	length of range for cpu access.
 * @direction:	[in]	length of range for cpu access.
 *
 * This call must always succeed.
 */
void dma_buf_end_cpu_access(struct dma_buf *dmabuf, size_t start, size_t len,
void dma_buf_end_cpu_access(struct dma_buf *dmabuf,
			    enum dma_data_direction direction)
{
	WARN_ON(!dmabuf);

	if (dmabuf->ops->end_cpu_access)
		dmabuf->ops->end_cpu_access(dmabuf, start, len, direction);
		dmabuf->ops->end_cpu_access(dmabuf, direction);
}
EXPORT_SYMBOL_GPL(dma_buf_end_cpu_access);

+8 −0
Original line number Diff line number Diff line
@@ -25,6 +25,14 @@ config DRM_MIPI_DSI
	bool
	depends on DRM

config DRM_DP_AUX_CHARDEV
	bool "DRM DP AUX Interface"
	depends on DRM
	help
	  Choose this option to enable a /dev/drm_dp_auxN node that allows to
	  read and write values to arbitrary DPCD registers on the DP aux
	  channel.

config DRM_KMS_HELPER
	tristate
	depends on DRM
+4 −1
Original line number Diff line number Diff line
@@ -22,10 +22,13 @@ drm-$(CONFIG_OF) += drm_of.o
drm-$(CONFIG_AGP) += drm_agpsupport.o

drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \
		drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o
		drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o \
		drm_kms_helper_common.o

drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
drm_kms_helper-$(CONFIG_DRM_KMS_CMA_HELPER) += drm_fb_cma_helper.o
drm_kms_helper-$(CONFIG_DRM_DP_AUX_CHARDEV) += drm_dp_aux_dev.o

obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o

Loading