]> git.karo-electronics.de Git - karo-tx-linux.git/log
karo-tx-linux.git
7 years agodrm: nouveau: fix build when LEDS_CLASS=m
Randy Dunlap [Mon, 2 Jan 2017 00:20:53 +0000 (16:20 -0800)]
drm: nouveau: fix build when LEDS_CLASS=m

Fix build errors in nouveau driver when CONFIG_LEDS_CLASS=m and
CONFIG_DRM_NOUVEAU=y.
If LEDS_CLASS is enabled, DRM_NOUVEAU is restricted to the same
kconfig value as LEDS_CLASS.

drivers/built-in.o: In function `nouveau_do_suspend':
nouveau_drm.c:(.text+0x2030b1): undefined reference to `nouveau_led_suspend'
drivers/built-in.o: In function `nouveau_do_resume':
nouveau_drm.c:(.text+0x2034ca): undefined reference to `nouveau_led_resume'
drivers/built-in.o: In function `nouveau_drm_unload':
nouveau_drm.c:(.text+0x203a15): undefined reference to `nouveau_led_fini'
drivers/built-in.o: In function `nouveau_drm_load':
nouveau_drm.c:(.text+0x204423): undefined reference to `nouveau_led_init'

BTW, this line in Kbuild:
nouveau-$(CONFIG_LEDS_CLASS) += nouveau_led.o
does nothing when CONFIG_LEDS_CLASS=m and CONFIG_DRM_NOUVEAU=y.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Cc: Martin Peres <martin.peres@free.fr>
Cc: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/029a1ec5-48ac-a3ce-3106-430e0f2584bb@infradead.org
7 years agodrm/edid: constify edid quirk list
Jani Nikula [Wed, 28 Dec 2016 11:06:26 +0000 (13:06 +0200)]
drm/edid: constify edid quirk list

No reason not to be const.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1482923186-22430-1-git-send-email-jani.nikula@intel.com
7 years agodrm/bridge: Use recommened kerneldoc for struct member refs
Daniel Vetter [Mon, 2 Jan 2017 08:17:26 +0000 (09:17 +0100)]
drm/bridge: Use recommened kerneldoc for struct member refs

I just learned that &struct_name.member_name works and looks pretty
even. It doesn't (yet) link to the member directly though, which would
be really good for big structures or vfunc tables (where the
per-member kerneldoc tends to be long).

Also some minor drive-by polish where it makes sense, I read a lot
of docs ...

Cc: Archit Taneja <architt@codeaurora.org>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Archit Taneja <architt@codeaurora.org>
[danvet: Remove spurious hunk that Archit spotted.]
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1483044517-5770-13-git-send-email-daniel.vetter@ffwll.ch
7 years agodrm/cma-helpers: Use recommened kerneldoc for struct member refs
Daniel Vetter [Thu, 29 Dec 2016 20:48:34 +0000 (21:48 +0100)]
drm/cma-helpers: Use recommened kerneldoc for struct member refs

I just learned that &struct_name.member_name works and looks pretty
even. It doesn't (yet) link to the member directly though, which would
be really good for big structures or vfunc tables (where the
per-member kerneldoc tends to be long).

Also some minor drive-by polish where it makes sense, I read a lot
of docs ...

v2: Review from Laurent:
- Move misplaced doc change to the right patch.
- Remove "DRM driver's", it's redundant.
- Spotted 3 more places where where we could add prose reference with
  a real one.

Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1483044517-5770-14-git-send-email-daniel.vetter@ffwll.ch
7 years agodrm/cma-helper: simplify setup for drivers with ->dirty callbacks
Daniel Vetter [Thu, 29 Dec 2016 20:48:31 +0000 (21:48 +0100)]
drm/cma-helper: simplify setup for drivers with ->dirty callbacks

If we store the fb funcs pointer, we can remove a bit of boilerplate.
Also remove the _fbdev_ in the example code, since the fb_funcs->dirty
callback has nothing to do with fbdev. It's a KMS feature, only
used by the fbdev deferred_io support to implement flushing/upload.

Cc: Noralf Trønnes <noralf@tronnes.org>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[danvet: Move the misplaced kerneldoc change from a later patch to
this one here.]
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1483044517-5770-11-git-send-email-daniel.vetter@ffwll.ch
7 years agodrm/armada: Fix compile fail
Daniel Vetter [Fri, 30 Dec 2016 16:38:52 +0000 (17:38 +0100)]
drm/armada: Fix compile fail

I reported the include issue for tracepoints a while ago, but nothing
seems to have happened. Now it bit us, since the drm_mm_print
conversion was broken for armada. Fix it, so I can re-enable armada
in the drm-misc build configs.

v2: Rebase just the compile fix on top of Chris' build fix.

Cc: Russell King <rmk+kernel@armlinux.org.uk>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Acked: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1483115932-19584-1-git-send-email-daniel.vetter@ffwll.ch
7 years agodrm/armada: s/drm_mm_dump_table/drm_mm_print/
Chris Wilson [Fri, 30 Dec 2016 14:55:10 +0000 (14:55 +0000)]
drm/armada: s/drm_mm_dump_table/drm_mm_print/

Missed rename during v2 of b5c3714fe878 ("drm/mm: Convert to
drm_printer")

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Fixes: b5c3714fe878 ("drm/mm: Convert to drm_printer")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161230145510.12951-1-chris@chris-wilson.co.uk
7 years agodrm: Avoid NULL dereference of drm_device.dev
Chris Wilson [Fri, 30 Dec 2016 14:16:39 +0000 (14:16 +0000)]
drm: Avoid NULL dereference of drm_device.dev

For a virtual device, drm_device.dev is NULL, so becareful not to
dereference it unconditionally in core code such as drm_dev_register().

Fixes: 75f6dfe3e652 ("drm: Deduplicate driver initialization message")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161230141639.10487-1-chris@chris-wilson.co.uk
7 years agodrm/atomic-helpers: Remove outdated comment
Daniel Vetter [Thu, 29 Dec 2016 20:48:30 +0000 (21:48 +0100)]
drm/atomic-helpers: Remove outdated comment

We forgot to clean this up when adding connector refcounting.

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1483044517-5770-10-git-send-email-daniel.vetter@ffwll.ch
7 years agodrm/rect: Fix formatting of example code
Daniel Vetter [Thu, 29 Dec 2016 20:48:29 +0000 (21:48 +0100)]
drm/rect: Fix formatting of example code

Drive-by polish.

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1483044517-5770-9-git-send-email-daniel.vetter@ffwll.ch
7 years agodrm/doc: Update styleguide
Daniel Vetter [Thu, 29 Dec 2016 20:48:28 +0000 (21:48 +0100)]
drm/doc: Update styleguide

The new cool is &struct foo (kernel-doc now copes with linebreaks),
and structure members should be referenced using &foo.bar.

Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1483044517-5770-8-git-send-email-daniel.vetter@ffwll.ch
7 years agodrm: Nuke connector_list locking assert
Daniel Vetter [Thu, 29 Dec 2016 20:48:27 +0000 (21:48 +0100)]
drm: Nuke connector_list locking assert

I've forgotten to remove this when revamping the
connector_list locking.

Cc: seanpaul@chromium.org
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1483044517-5770-7-git-send-email-daniel.vetter@ffwll.ch
7 years agodrm/doc: use preferred struct reference in kernel-doc
Daniel Vetter [Thu, 29 Dec 2016 20:48:26 +0000 (21:48 +0100)]
drm/doc: use preferred struct reference in kernel-doc

sed -e 's/\( \* .*\)struct &\([_a-z]*\)/\1\&struct \2/' -i

Originally I wasnt a friend of this style because I thought a
line-break between the "&struct" and "foo" part would break it. But a
quick test shows that " * &struct \n * foo\n" works pefectly well with
current kernel-doc. So time to mass-apply these changes!

Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1483044517-5770-6-git-send-email-daniel.vetter@ffwll.ch
7 years agodma-buf: Use recommended structure member reference
Daniel Vetter [Thu, 29 Dec 2016 20:48:25 +0000 (21:48 +0100)]
dma-buf: Use recommended structure member reference

I just learned that &struct_name.member_name works and looks pretty
even. It doesn't (yet) link to the member directly though, which would
be really good for big structures or vfunc tables (where the
per-member kerneldoc tends to be long).

Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1483044517-5770-5-git-send-email-daniel.vetter@ffwll.ch
7 years agodma-buf: use preferred struct reference in kernel-doc
Daniel Vetter [Thu, 29 Dec 2016 20:48:24 +0000 (21:48 +0100)]
dma-buf: use preferred struct reference in kernel-doc

sed -e 's/\( \* .*\)struct &\([_a-z]*\)/\1\&struct \2/' -i

Originally I wasnt a friend of this style because I thought a
line-break between the "&struct" and "foo" part would break it. But a
quick test shows that " * &struct \n * foo\n" works pefectly well with
current kernel-doc. So time to mass-apply these changes!

Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1483044517-5770-4-git-send-email-daniel.vetter@ffwll.ch
7 years agodrm/mm: Some doc polish
Daniel Vetter [Thu, 29 Dec 2016 20:48:23 +0000 (21:48 +0100)]
drm/mm: Some doc polish

Added some boilerplate for the structs, documented members where they
are relevant and plenty of markup for hyperlinks all over. And a few
small wording polish.

Note that the intro needs some more love after the DRM_MM_INSERT_*
patch from Chris has landed.

v2: Spelling fixes (Chris).

v3: Use &struct foo instead of &foo structure (Chris).

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1483044517-5770-3-git-send-email-daniel.vetter@ffwll.ch
7 years agodrm/docs: Small cleanup in drm-uapi.rst
Daniel Vetter [Thu, 29 Dec 2016 20:48:21 +0000 (21:48 +0100)]
drm/docs: Small cleanup in drm-uapi.rst

- Remove the outdated hunk about driver documentation which somehow
  got misplaced here in the split-up.

- Collect all the testing&validation stuff together and give the CRC
  section a heading for prettier output.

Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1483044517-5770-1-git-send-email-daniel.vetter@ffwll.ch
7 years agodrm: Update TTM initialization documentation
Gabriel Krisman Bertazi [Fri, 30 Dec 2016 11:50:49 +0000 (12:50 +0100)]
drm: Update TTM initialization documentation

ttm_global_reference was renamed to drm_global_reference.  This updates
the documentation to reflect that.  While we are there, document the
drm_global_reference API and update the initialization interface
documentation.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
[danvet: Keep the warning, ttm docs are still massively inadequate.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161228143216.26821-7-krisman@collabora.co.uk
7 years agodrm: Export drm_ioctl_permit to kernel-doc
Gabriel Krisman Bertazi [Wed, 28 Dec 2016 14:32:14 +0000 (12:32 -0200)]
drm: Export drm_ioctl_permit to kernel-doc

drm_ioctl_permit is exported but missed a kernel-doc style
documentation.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161228143216.26821-5-krisman@collabora.co.uk
7 years agodrm: Drop unused forward declaration of drm_version
Gabriel Krisman Bertazi [Wed, 28 Dec 2016 14:32:13 +0000 (12:32 -0200)]
drm: Drop unused forward declaration of drm_version

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161228143216.26821-4-krisman@collabora.co.uk
7 years agodrm: Deduplicate driver initialization message
Gabriel Krisman Bertazi [Wed, 28 Dec 2016 14:32:11 +0000 (12:32 -0200)]
drm: Deduplicate driver initialization message

Several DRM drivers print the same initialization message right after
drm_dev_register, so move that to common code.  The exception is i915,
which uses its own register handle, so let it keep its own message.

Notice that this was tested only with Exynos, but looks simple enough
for the other drivers.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161228143216.26821-2-krisman@collabora.co.uk
7 years agodrm: Reduce verbosity level for drm_core_init() debug message
Chris Wilson [Thu, 29 Dec 2016 13:37:29 +0000 (13:37 +0000)]
drm: Reduce verbosity level for drm_core_init() debug message

Currently at the end of drm_core_init() we print

[    0.735185] [drm] Initialized

which does not provide any user information and is only a breadcrumb for
developers, so reduce it from info to debug.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161229133729.32673-1-chris@chris-wilson.co.uk
7 years agodrm: rockchip: use crtc helper drm_crtc_from_index()
Shawn Guo [Thu, 29 Dec 2016 12:41:30 +0000 (20:41 +0800)]
drm: rockchip: use crtc helper drm_crtc_from_index()

Function rockchip_crtc_from_pipe() does the exactly same thing as what
crtc helper drm_crtc_from_index() provides.  Use the helper to save
some code.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1483015290-16660-4-git-send-email-shawnguo@kernel.org
7 years agodrm: zte: use crtc helper drm_crtc_from_index()
Shawn Guo [Thu, 29 Dec 2016 12:41:29 +0000 (20:41 +0800)]
drm: zte: use crtc helper drm_crtc_from_index()

Function zx_find_crtc() does the exactly same thing as what crtc helper
drm_crtc_from_index() provides.  Use the helper to save some code.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1483015290-16660-3-git-send-email-shawnguo@kernel.org
7 years agodrm: add crtc helper drm_crtc_from_index()
Shawn Guo [Thu, 29 Dec 2016 12:41:28 +0000 (20:41 +0800)]
drm: add crtc helper drm_crtc_from_index()

It adds a crtc helper drm_crtc_from_index() to find the registered CRTC
with a given index, just like drm_plane_from_index().

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1483015290-16660-2-git-send-email-shawnguo@kernel.org
7 years agodrm/mm: Convert to drm_printer
Daniel Vetter [Thu, 29 Dec 2016 11:09:24 +0000 (12:09 +0100)]
drm/mm: Convert to drm_printer

Including all drivers. I thought about keeping small compat functions
to avoid having to change all drivers. But I really like the
drm_printer idea, so figured spreading it more widely is a good thing.

v2: Review from Chris:
- Natural argument order and better name for drm_mm_print.
- show_mm() macro in the selftest.

Cc: Rob Clark <robdclark@gmail.com>
Cc: Russell King <rmk+kernel@armlinux.org.uk>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1483009764-8281-1-git-send-email-daniel.vetter@ffwll.ch
7 years agodrm/printer: add debug printer
Daniel Vetter [Wed, 28 Dec 2016 16:42:09 +0000 (17:42 +0100)]
drm/printer: add debug printer

Useful for dumping lots of data into dmesg, e.g. drm_mm.

v2: Fixup export_symbol line, I misplaced a hunk (Chris).

Cc: Rob Clark <robdclark@gmail.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1482943330-11592-1-git-send-email-daniel.vetter@ffwll.ch
7 years agodrm/doc: link style-guide to doc-guide
Daniel Vetter [Thu, 29 Dec 2016 10:44:35 +0000 (11:44 +0100)]
drm/doc: link style-guide to doc-guide

Our style guide should only be the delta compared to the overall one.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1483008275-29383-1-git-send-email-daniel.vetter@ffwll.ch
7 years agodrm: Add kerneldoc markup for new @scan parameters in drm_mm
Chris Wilson [Wed, 28 Dec 2016 10:51:20 +0000 (10:51 +0000)]
drm: Add kerneldoc markup for new @scan parameters in drm_mm

A couple of parameters slipped through the kerneldoc net.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161228105120.14500-1-chris@chris-wilson.co.uk
7 years agodrm/mm: Document locking rules
Daniel Vetter [Tue, 27 Dec 2016 10:10:57 +0000 (11:10 +0100)]
drm/mm: Document locking rules

Drivers need to take care. Motivated by a discussion between Mark and
Rob on dri-devel.

Cc: Mark yao <mark.yao@rock-chips.com>
Cc: Rob Clark <robdclark@gmail.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
[danvet: s/alloc|freeing/modifications/ per Chris' suggestion.]
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1482833457-29592-1-git-send-email-daniel.vetter@ffwll.ch
7 years agodrm: Use drm_mm_insert_node_in_range_generic() for everyone
Chris Wilson [Thu, 22 Dec 2016 08:36:39 +0000 (08:36 +0000)]
drm: Use drm_mm_insert_node_in_range_generic() for everyone

Remove a superfluous helper as drm_mm_insert_node is equivalent to
insert_node_in_range with a range of [0, U64_MAX].

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-37-chris@chris-wilson.co.uk
7 years agodrm: Apply range restriction after color adjustment when allocation
Chris Wilson [Thu, 22 Dec 2016 08:36:38 +0000 (08:36 +0000)]
drm: Apply range restriction after color adjustment when allocation

mm->color_adjust() compares the hole with its neighbouring nodes. They
only abutt before we restrict the hole, so we have to apply color_adjust
before we apply the range restriction.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-36-chris@chris-wilson.co.uk
7 years agodrm: Wrap drm_mm_node.hole_follows
Chris Wilson [Thu, 22 Dec 2016 08:36:37 +0000 (08:36 +0000)]
drm: Wrap drm_mm_node.hole_follows

Insulate users from changes to the internal hole tracking within
struct drm_mm_node by using an accessor for hole_follows.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
[danvet: resolve conflicts in i915_vma.c]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
7 years agodrm: Apply tight eviction scanning to color_adjust
Chris Wilson [Thu, 22 Dec 2016 08:36:36 +0000 (08:36 +0000)]
drm: Apply tight eviction scanning to color_adjust

Using mm->color_adjust makes the eviction scanner much tricker since we
don't know the actual neighbours of the target hole until after it is
created (after scanning is complete). To work out whether we need to
evict the neighbours because they impact upon the hole, we have to then
check the hole afterwards - requiring an extra step in the user of the
eviction scanner when they apply color_adjust.

v2: Massage kerneldoc.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-34-chris@chris-wilson.co.uk
7 years agodrm: Simplify drm_mm scan-list manipulation
Chris Wilson [Thu, 22 Dec 2016 08:36:35 +0000 (08:36 +0000)]
drm: Simplify drm_mm scan-list manipulation

Since we mandate a strict reverse-order of drm_mm_scan_remove_block()
after drm_mm_scan_add_block() we can further simplify the list
manipulations when generating the temporary scan-hole.

v2: Highlight the games being played with the lists to track the scan
holes without allocation.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-33-chris@chris-wilson.co.uk
7 years agodrm: Optimise power-of-two alignments in drm_mm_scan_add_block()
Chris Wilson [Thu, 22 Dec 2016 08:36:34 +0000 (08:36 +0000)]
drm: Optimise power-of-two alignments in drm_mm_scan_add_block()

For power-of-two alignments, we can avoid the 64bit divide and do a
simple bitwise add instead.

v2: s/alignment_mask/remainder_mask/

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-32-chris@chris-wilson.co.uk
7 years agodrm: Compute tight evictions for drm_mm_scan
Chris Wilson [Thu, 22 Dec 2016 08:36:33 +0000 (08:36 +0000)]
drm: Compute tight evictions for drm_mm_scan

Compute the minimal required hole during scan and only evict those nodes
that overlap. This enables us to reduce the number of nodes we need to
evict to the bare minimum.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-31-chris@chris-wilson.co.uk
7 years agodrm: Fix application of color vs range restriction when scanning drm_mm
Chris Wilson [Thu, 22 Dec 2016 08:36:32 +0000 (08:36 +0000)]
drm: Fix application of color vs range restriction when scanning drm_mm

The range restriction should be applied after the color adjustment, or
else we may inadvertently apply the color adjustment to the restricted
hole (and not against its neighbours).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-30-chris@chris-wilson.co.uk
7 years agodrm: Unconditionally do the range check in drm_mm_scan_add_block()
Chris Wilson [Thu, 22 Dec 2016 08:36:31 +0000 (08:36 +0000)]
drm: Unconditionally do the range check in drm_mm_scan_add_block()

Doing the check is trivial (low cost in comparison to overall eviction)
and helps simplify the code.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-29-chris@chris-wilson.co.uk
7 years agodrm: Rename prev_node to hole in drm_mm_scan_add_block()
Chris Wilson [Thu, 22 Dec 2016 08:36:30 +0000 (08:36 +0000)]
drm: Rename prev_node to hole in drm_mm_scan_add_block()

Acknowledging that we were building up the hole was more useful to me
when reading the code, than knowing the relationship between this node
and the previous node.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-28-chris@chris-wilson.co.uk
7 years agodrm: Fix O= out-of-tree builds for selftests
Daniel Vetter [Wed, 28 Dec 2016 09:41:17 +0000 (10:41 +0100)]
drm: Fix O= out-of-tree builds for selftests

Kbuild really doesn't like non-recursive Makefiles, but they do work
as long as you build without O=

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Fixes: 50f0033d1a0f ("drm: Add some kselftests for the DRM range manager (struct drm_mm)")
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Christian König <christian.koenig@amd.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1482918077-30027-1-git-send-email-daniel.vetter@ffwll.ch
7 years agodrm: Extract struct drm_mm_scan from struct drm_mm
Chris Wilson [Thu, 22 Dec 2016 08:36:29 +0000 (08:36 +0000)]
drm: Extract struct drm_mm_scan from struct drm_mm

The scan state occupies a large proportion of the struct drm_mm and is
rarely used and only contains temporary state. That makes it suitable to
moving to its struct and onto the stack of the callers.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
[danvet: Fix up etnaviv to compile, was missing a BUG_ON.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
7 years agodrm: Add asserts to catch overflow in drm_mm_init() and drm_mm_init_scan()
Chris Wilson [Thu, 22 Dec 2016 08:36:28 +0000 (08:36 +0000)]
drm: Add asserts to catch overflow in drm_mm_init() and drm_mm_init_scan()

A simple assert to ensure that we don't overflow start + size when
initialising the drm_mm, or its scanner.

In future, we may want to switch to tracking the value of ranges (rather
than size) so that we can cover the full u64, for example like resource
tracking.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-26-chris@chris-wilson.co.uk
7 years agodrm: Simplify drm_mm_clean()
Chris Wilson [Thu, 22 Dec 2016 08:36:27 +0000 (08:36 +0000)]
drm: Simplify drm_mm_clean()

Since commit ea7b1dd44867 ("drm: mm: track free areas implicitly"),
to test whether there are any nodes allocated within the range manager,
we merely have to ask whether the node_list is empty.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-25-chris@chris-wilson.co.uk
7 years agodrm: Detect overflow in drm_mm_reserve_node()
Chris Wilson [Thu, 22 Dec 2016 08:36:26 +0000 (08:36 +0000)]
drm: Detect overflow in drm_mm_reserve_node()

Protect ourselves from a caller passing in node.start + node.size that
will overflow and trick us into reserving that node.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-24-chris@chris-wilson.co.uk
7 years agodrm: Fix kerneldoc for drm_mm_scan_remove_block()
Chris Wilson [Thu, 22 Dec 2016 08:36:25 +0000 (08:36 +0000)]
drm: Fix kerneldoc for drm_mm_scan_remove_block()

The nodes must be removed in the *reverse* order. This is correct in the
overview, but backwards in the function description. Whilst here add
Intel's copyright statement and tweak some formatting.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-23-chris@chris-wilson.co.uk
7 years agodrm: Promote drm_mm alignment to u64
Chris Wilson [Thu, 22 Dec 2016 08:36:24 +0000 (08:36 +0000)]
drm: Promote drm_mm alignment to u64

In places (e.g. i915.ko), the alignment is exported to userspace as u64
and there now exists hardware for which we can indeed utilize a u64
alignment. As such, we need to keep 64bit integers throughout when
handling alignment.

Testcase: igt/drm_mm/align64
Testcase: igt/gem_exec_alignment
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Christian König <christian.koenig@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-22-chris@chris-wilson.co.uk
7 years agodrm: kselftest for drm_mm and restricted color eviction
Chris Wilson [Thu, 22 Dec 2016 08:36:22 +0000 (08:36 +0000)]
drm: kselftest for drm_mm and restricted color eviction

Check that after applying the driver's color adjustment, restricted
eviction scanning finds a suitable hole.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-20-chris@chris-wilson.co.uk
7 years agodrm: kselftest for drm_mm and color eviction
Chris Wilson [Thu, 22 Dec 2016 08:36:21 +0000 (08:36 +0000)]
drm: kselftest for drm_mm and color eviction

Check that after applying the driver's color adjustment, eviction
scanning finds a suitable hole.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-19-chris@chris-wilson.co.uk
7 years agodrm: kselftest for drm_mm and color adjustment
Chris Wilson [Thu, 22 Dec 2016 08:36:20 +0000 (08:36 +0000)]
drm: kselftest for drm_mm and color adjustment

Check that after applying the driver's color adjustment, fitting of the
node and its alignment are still correct.

v2: s/no_color_touching/separate_adjacent_colors/

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-18-chris@chris-wilson.co.uk
7 years agodrm: kselftest for drm_mm and top-down allocation
Chris Wilson [Thu, 22 Dec 2016 08:36:19 +0000 (08:36 +0000)]
drm: kselftest for drm_mm and top-down allocation

Check that if we request top-down allocation from drm_mm_insert_node()
we receive the next available hole from the top.

v2: Flip sign on conditional assert.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-17-chris@chris-wilson.co.uk
7 years agodrm: kselftest for drm_mm and range restricted eviction
Chris Wilson [Thu, 22 Dec 2016 08:36:18 +0000 (08:36 +0000)]
drm: kselftest for drm_mm and range restricted eviction

Check that we add arbitrary blocks to a restrited eviction scanner in
order to find the first minimal hole that matches our request.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-16-chris@chris-wilson.co.uk
7 years agodrm: kselftest for drm_mm and eviction
Chris Wilson [Thu, 22 Dec 2016 08:36:17 +0000 (08:36 +0000)]
drm: kselftest for drm_mm and eviction

Check that we add arbitrary blocks to the eviction scanner in order to
find the first minimal hole that matches our request.

v2: Refactor out some common eviction code for later

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-15-chris@chris-wilson.co.uk
7 years agodrm: kselftest for drm_mm and alignment
Chris Wilson [Thu, 22 Dec 2016 08:36:16 +0000 (08:36 +0000)]
drm: kselftest for drm_mm and alignment

Check that we can request alignment to any power-of-two or prime using a
plain drm_mm_node_insert(), and also handle a reasonable selection of
primes.

v2: Exercise all allocation flags

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-14-chris@chris-wilson.co.uk
7 years agodrm: kselftest for drm_mm_insert_node_in_range()
Chris Wilson [Thu, 22 Dec 2016 08:36:15 +0000 (08:36 +0000)]
drm: kselftest for drm_mm_insert_node_in_range()

Exercise drm_mm_insert_node_in_range(), check that we only allocate from
the specified range.

v2: Use all allocation flags
v3: Don't pass in invalid ranges - these will be asserted later.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-13-chris@chris-wilson.co.uk
7 years agodrm: kselftest for drm_mm_replace_node()
Chris Wilson [Thu, 22 Dec 2016 08:36:14 +0000 (08:36 +0000)]
drm: kselftest for drm_mm_replace_node()

Reuse drm_mm_insert_node() with a temporary node to exercise
drm_mm_replace_node(). We use the previous test in order to exercise the
various lists following replacement.

v2: Check that we copy across the important (user) details of the node.
The internal details (such as lists and hole tracking) we hope to detect
errors by exercise.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-12-chris@chris-wilson.co.uk
7 years agodrm: kselftest for drm_mm_insert_node()
Chris Wilson [Thu, 22 Dec 2016 08:36:13 +0000 (08:36 +0000)]
drm: kselftest for drm_mm_insert_node()

Exercise drm_mm_insert_node(), check that we can't overfill a range and
that the lists are correct after reserving/removing.

v2: Extract helpers for the repeated tests
v3: Iterate over all allocation flags

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-11-chris@chris-wilson.co.uk
7 years agodrm: kselftest for drm_mm_reserve_node()
Chris Wilson [Thu, 22 Dec 2016 08:36:12 +0000 (08:36 +0000)]
drm: kselftest for drm_mm_reserve_node()

Exercise drm_mm_reserve_node(), check that we can't reserve an already
occupied range and that the lists are correct after reserving/removing.

v2: Check for invalid node reservation.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-10-chris@chris-wilson.co.uk
7 years agodrm: kselftest for drm_mm_debug()
Chris Wilson [Thu, 22 Dec 2016 08:36:11 +0000 (08:36 +0000)]
drm: kselftest for drm_mm_debug()

Simple test to just exercise calling the debug dumper on the drm_mm.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-9-chris@chris-wilson.co.uk
7 years agodrm: kselftest for drm_mm_init()
Chris Wilson [Thu, 22 Dec 2016 08:36:10 +0000 (08:36 +0000)]
drm: kselftest for drm_mm_init()

Simple first test to just exercise initialisation of struct drm_mm.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-8-chris@chris-wilson.co.uk
7 years agodrm: Add some kselftests for the DRM range manager (struct drm_mm)
Chris Wilson [Thu, 22 Dec 2016 08:36:09 +0000 (08:36 +0000)]
drm: Add some kselftests for the DRM range manager (struct drm_mm)

First we introduce a smattering of infrastructure for writing selftests.
The idea is that we have a test module that exercises a particular
portion of the exported API, and that module provides a set of tests
that can either be run as an ensemble via kselftest or individually via
an igt harness (in this case igt/drm_mm). To accommodate selecting
individual tests, we export a boolean parameter to control selection of
each test - that is hidden inside a bunch of reusable boilerplate macros
to keep writing the tests simple.

v2: Choose a random random_seed unless one is specified by the user.
v3: More parameters to control max_iterations and max_prime of the
tests.

Testcase: igt/drm_mm
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-7-chris@chris-wilson.co.uk
7 years agodrm: Add a simple generator of random permutations
Chris Wilson [Thu, 22 Dec 2016 08:36:08 +0000 (08:36 +0000)]
drm: Add a simple generator of random permutations

When testing, we want a random but yet reproducible order in which to
process elements. Here we create an array which is a random (using the
Tausworthe PRNG) permutation of the order in which to execute.

Note these are simple helpers intended to be merged upstream in lib/

v2: Tidier code by David Herrmann
v3: Add reminder that this code is intended to be temporary, with at
least the bulk of the prandom changes going to lib/

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-6-chris@chris-wilson.co.uk
7 years agolib: Add a simple prime number generator
Chris Wilson [Thu, 22 Dec 2016 14:45:14 +0000 (14:45 +0000)]
lib: Add a simple prime number generator

Prime numbers are interesting for testing components that use multiplies
and divides, such as testing DRM's struct drm_mm alignment computations.

v2: Move to lib/, add selftest
v3: Fix initial constants (exclude 0/1 from being primes)
v4: More RCU markup to keep 0day/sparse happy
v5: Fix RCU unwind on module exit, add to kselftests
v6: Tidy computation of bitmap size
v7: for_each_prime_number_from()
v8: Compose small-primes using BIT() for easier verification
v9: Move rcu dance entirely into callers.
v10: Improve quote for Betrand's Postulate (aka Chebyshev's theorem)

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Lukas Wunner <lukas@wunner.de>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222144514.3911-1-chris@chris-wilson.co.uk
7 years agodrm: Compile time enabling for asserts in drm_mm
Chris Wilson [Thu, 22 Dec 2016 08:36:06 +0000 (08:36 +0000)]
drm: Compile time enabling for asserts in drm_mm

Use CONFIG_DRM_DEBUG_MM to conditionally enable the internal and
validation checking using BUG_ON. Ideally these paths should all be
exercised by CI selftests (with the asserts enabled).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-4-chris@chris-wilson.co.uk
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-4-chris@chris-wilson.co.uk
7 years agodrm: Use drm_mm_nodes() as shorthand for the list of nodes under struct drm_mm
Chris Wilson [Thu, 22 Dec 2016 08:36:05 +0000 (08:36 +0000)]
drm: Use drm_mm_nodes() as shorthand for the list of nodes under struct drm_mm

Fairly commonly we want to inspect the node list on the struct drm_mm,
which is buried within an embedded node. Bring it to the surface with a
bit of syntatic sugar.

Note this was intended to be split from commit ad579002c8ec ("drm: Add
drm_mm_for_each_node_safe()") before being applied, but my timing sucks.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-3-chris@chris-wilson.co.uk
7 years agodrm: Get atomic property value even if DRIVER_ATOMIC is not set
Dhinakaran Pandiyan [Thu, 22 Dec 2016 08:50:43 +0000 (00:50 -0800)]
drm: Get atomic property value even if DRIVER_ATOMIC is not set

i915 does not set DRIVER_ATOMIC by default yet but uses atomic_check and
atomic_commit. drm_object_property_get_value() does not read the correct
value of atomic properties if DRIVER_ATOMIC is not set. Checking whether
the driver uses atomic modeset is a better check instead as the property
values are tracked in the state structures.

v2: Included header

Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1482396643-32456-2-git-send-email-dhinakaran.pandiyan@intel.com
7 years agodrm: Wrap the check for atomic_commit implementation
Dhinakaran Pandiyan [Thu, 22 Dec 2016 08:50:42 +0000 (00:50 -0800)]
drm: Wrap the check for atomic_commit implementation

This check is useful for drivers that do not have DRIVER_ATOMIC set but
have atomic modesetting internally implemented. Wrap the check into a
function since this is used in many places and as a bonus, the function
name helps to document what the check is for.

v2:
Change return type to bool (Ville)
Move the function drm_atomic.h (Daniel)
Fixed comment marker for documentation

Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
[danvet: Move back to drmP.h because include hell.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1482396643-32456-1-git-send-email-dhinakaran.pandiyan@intel.com
7 years agodrm/i915: Add a cursor hack to allow converting legacy page flip to atomic, v3.
Maarten Lankhorst [Mon, 12 Dec 2016 10:34:55 +0000 (11:34 +0100)]
drm/i915: Add a cursor hack to allow converting legacy page flip to atomic, v3.

Do something similar to vc4, only allow updating the cursor state
in-place through a fastpath when the watermarks are unaffected. This
will allow cursor movement to be smooth, but changing cursor size or
showing/hiding cursor will still fall back so watermarks can be updated.

Only moving and changing fb is allowed.

Changes since v1:
- Set page flip to always_unused for trybot.
- Copy fence correctly, ignore plane_state->state, should be NULL.
- Check crtc_state for !active and modeset, go to slowpath if the case.
Changes since v2:
- Make error handling work correctly. (Matthew Auld)

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/a8e4cb00-5171-14e5-bbe3-dadb654ff296@linux.intel.com
7 years agodrm/atomic: Remove drm_atomic_helper_framebuffer_changed.
Maarten Lankhorst [Thu, 8 Dec 2016 13:45:28 +0000 (14:45 +0100)]
drm/atomic: Remove drm_atomic_helper_framebuffer_changed.

This function is now completely unused, zap it.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1481204729-9058-6-git-send-email-maarten.lankhorst@linux.intel.com
7 years agodrm/atomic: Wait for vblank whenever a plane is added to state.
Maarten Lankhorst [Thu, 8 Dec 2016 13:45:27 +0000 (14:45 +0100)]
drm/atomic: Wait for vblank whenever a plane is added to state.

There's 2 reasons for doing a vblank wait:
- To fulfill uabi expectations, but the legacy ioctls are ill-defined
  enough that we really only need this when we do send out an event.
- To make sure we don't tear down mappings before the scanout engine
  stops accessing it.

The later is problematic with the current code since e.g. rotation
might need a different mapping than normal orientation. And rotation
is a plane property, and not on the fb. Hence we need to remove this
optimization.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
[danvet: Completely new commit message.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1481204729-9058-5-git-send-email-maarten.lankhorst@linux.intel.com
7 years agodrm/atomic: Clean up wait_for_vblanks, v2.
Maarten Lankhorst [Thu, 15 Dec 2016 11:51:42 +0000 (12:51 +0100)]
drm/atomic: Clean up wait_for_vblanks, v2.

Stop relying on a per crtc_state last_vblank_count, we shouldn't touch
crtc_state after commit. Move it to atomic_state->crtcs.

Also stop re-using new_crtc_state->enable, we can now simply set a
bitmask with crtc_crtc_mask.

Changes since v1:
- Keep last_vblank_count in __drm_crtc_state.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/8e4759a4-24d3-3f80-bd1a-1e7a9c83b612@linux.intel.com
7 years agodrm/atomic: Unconditionally call prepare_fb.
Maarten Lankhorst [Mon, 19 Dec 2016 11:08:16 +0000 (12:08 +0100)]
drm/atomic: Unconditionally call prepare_fb.

Atomic drivers may set properties like rotation on the same fb, which
may require a call to prepare_fb even when framebuffer stays identical.

Instead of handling all the special cases in the core, let the driver
decide when prepare_fb and cleanup_fb are noops.

This is a revert of:

commit fcc60b413d14dd06ddbd79ec50e83c4fb2a097ba
Author: Keith Packard <keithp@keithp.com>
Date:   Sat Jun 4 01:16:22 2016 -0700

    drm: Don't prepare or cleanup unchanging frame buffers [v3]

The original commit mentions that this prevents waiting in i915 on all
previous rendering during cursor updates, but there are better ways to
fix this.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/6d82f9b6-9d16-91d1-d176-4a37b09afc44@linux.intel.com
7 years agodrm/nouveau: use designated initializers
Kees Cook [Sat, 17 Dec 2016 01:04:42 +0000 (17:04 -0800)]
drm/nouveau: use designated initializers

Prepare to mark sensitive kernel structures for randomization by making
sure they're using designated initializers. These were identified during
allyesconfig builds of x86, arm, and arm64, with most initializer fixes
extracted from grsecurity.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161217010442.GA140619@beast
7 years agodrm/vmwgfx: use designated initializers
Kees Cook [Sat, 17 Dec 2016 01:04:02 +0000 (17:04 -0800)]
drm/vmwgfx: use designated initializers

Prepare to mark sensitive kernel structures for randomization by making
sure they're using designated initializers. These were identified during
allyesconfig builds of x86, arm, and arm64, with most initializer fixes
extracted from grsecurity.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161217010402.GA140546@beast
7 years agodrm/ttm: use designated initializers
Kees Cook [Sat, 17 Dec 2016 01:00:11 +0000 (17:00 -0800)]
drm/ttm: use designated initializers

Prepare to mark sensitive kernel structures for randomization by making
sure they're using designated initializers. These were identified during
allyesconfig builds of x86, arm, and arm64, with most initializer fixes
extracted from grsecurity.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161217010011.GA140300@beast
7 years agodrm/ttm: use designated initializers
Kees Cook [Sat, 17 Dec 2016 00:59:29 +0000 (16:59 -0800)]
drm/ttm: use designated initializers

Prepare to mark sensitive kernel structures for randomization by making
sure they're using designated initializers. These were identified during
allyesconfig builds of x86, arm, and arm64, with most initializer fixes
extracted from grsecurity.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161217005929.GA140260@beast
7 years agodrm/hisilicon: Fix spelling of clock in hisi-ade.txt
Peter Meerwald-Stadler [Fri, 16 Dec 2016 13:25:01 +0000 (14:25 +0100)]
drm/hisilicon: Fix spelling of clock in hisi-ade.txt

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: Xinliang Liu <xinliang.liu@linaro.org>
Cc: Xinwei Kong <kong.kongxinwei@hisilicon.com>
Cc: trivial@kernel.org
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1481894701-4613-1-git-send-email-pmeerw@pmeerw.net
7 years agodrm: Fix spelling of clock in drm_connector.h
Peter Meerwald-Stadler [Fri, 16 Dec 2016 13:24:23 +0000 (14:24 +0100)]
drm: Fix spelling of clock in drm_connector.h

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: trivial@kernel.org
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1481894663-4570-1-git-send-email-pmeerw@pmeerw.net
7 years agodrm: Tighten locking in drm_mode_getconnector
Daniel Vetter [Tue, 13 Dec 2016 23:08:10 +0000 (00:08 +0100)]
drm: Tighten locking in drm_mode_getconnector

- Modeset state needs mode_config->connection mutex, that covers
  figuring out the encoder, and reading properties (since in the
  atomic case those need to look at connector->state).

- Don't hold any locks for stuff that's invariant (i.e. possible
  connectors).

- Same for connector lookup and unref, those don't need any locks.

- And finally the probe stuff is only protected by mode_config->mutex.

While at it updated the kerneldoc for these fields in drm_connector
and add docs explaining what's protected by which locks.

Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161213230814.19598-10-daniel.vetter@ffwll.ch
7 years agodrm: prevent double-(un)registration for connectors
Daniel Vetter [Sun, 18 Dec 2016 13:35:45 +0000 (14:35 +0100)]
drm: prevent double-(un)registration for connectors

If we're unlucky then the registration from a hotplugged connector
might race with the final registration step on driver load. And since
MST topology discover is asynchronous that's even somewhat likely.

v2: Also update the kerneldoc for @registered!

v3: Review from Chris:
- Improve kerneldoc for late_register/early_unregister callbacks.
- Use mutex_destroy.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Reported-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161218133545.2106-1-daniel.vetter@ffwll.ch
7 years agodrm: Clean up connectors by unreferencing them
Daniel Vetter [Tue, 13 Dec 2016 23:08:08 +0000 (00:08 +0100)]
drm: Clean up connectors by unreferencing them

Only static connectors should be left at this point, and we should be
able to clean them out by simply dropping that last reference still
around from drm_connector_init.

If that leaves anything behind then we have a driver bug.

Doing the final cleanup this way also allows us to use
drm_connector_iter, removing the very last place where we walk
connector_list explicitly in drm core&helpers.

Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161213230814.19598-8-daniel.vetter@ffwll.ch
7 years agodrm: Convert all helpers to drm_connector_list_iter
Daniel Vetter [Thu, 15 Dec 2016 15:58:43 +0000 (16:58 +0100)]
drm: Convert all helpers to drm_connector_list_iter

Mostly nothing special (except making sure that really all error paths
and friends call iter_put).

v2: Don't forget the raw connector_list walking in
drm_helper_move_panel_connectors_to_head. That one unfortunately can't
be converted to the iterator helpers, but since it's just some list
splicing best to just wrap the entire thing up in one critical
section.

v3: Bail out after iter_put (Harry).

Cc: Harry Wentland <harry.wentland@amd.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161215155843.13408-1-daniel.vetter@ffwll.ch
7 years agodrm: locking&new iterators for connector_list
Daniel Vetter [Tue, 13 Dec 2016 23:08:06 +0000 (00:08 +0100)]
drm: locking&new iterators for connector_list

The requirements for connector_list locking are a bit tricky:
- We need to be able to jump over zombie conectors (i.e. with refcount
  == 0, but not yet removed from the list). If instead we require that
  there's no zombies on the list then the final kref_put must happen
  under the list protection lock, which means that locking context
  leaks all over the place. Not pretty - better to deal with zombies
  and wrap the locking just around the list_del in the destructor.

- When we walk the list we must _not_ hold the connector list lock. We
  walk the connector list at an absolutely massive amounts of places,
  if all those places can't ever call drm_connector_unreference the
  code would get unecessarily complicated.

- connector_list needs it own lock, again too many places that walk it
  that we could reuse e.g. mode_config.mutex without resulting in
  inversions.

- Lots of code uses these loops to look-up a connector, i.e. they want
  to be able to call drm_connector_reference. But on the other hand we
  want connectors to stay on that list until they're dead (i.e.
  connector_list can't hold a full reference), which means despite the
  "can't hold lock for the loop body" rule we need to make sure a
  connector doesn't suddenly become a zombie.

At first Dave&I discussed various horror-show approaches using srcu,
but turns out it's fairly easy:

- For the loop body we always hold an additional reference to the
  current connector. That means it can't zombify, and it also means
  it'll stay on the list, which means we can use it as our iterator to
  find the next connector.

- When we try to find the next connector we only have to jump over
  zombies. To make sure we don't chase bad pointers that entire loop
  is protected with the new connect_list_lock spinlock. And because we
  know that we're starting out with a non-zombie (need to drop our
  reference for the old connector only after we have our new one),
  we're guranteed to still be on the connector_list and either find
  the next non-zombie or complete the iteration.

- Only downside is that we need to make sure that the temporary
  reference for the loop body doesn't leak. iter_get/put() functions +
  lockdep make sure that's the case.

- To avoid a flag day the new iterator macro has an _iter postfix. We
  can rename it back once all the users of the unsafe version are gone
  (there's about 100 list walkers for the connector_list).

For now this patch only converts all the list walking in the core,
leaving helpers and drivers for later patches. The nice thing is that
we can now finally remove 2 FIXME comments from the
register/unregister functions.

v2:
- use irqsafe spinlocks, so that we can use this in drm_state_dump
  too.
- nuke drm_modeset_lock_all from drm_connector_init, now entirely
  cargo-culted nonsense.

v3:
- do {} while (!kref_get_unless_zero), makes for a tidier loop (Dave).
- pretty kerneldoc
- add EXPORT_SYMBOL, helpers&drivers are supposed to use this.

v4: Change lockdep annotations to only check whether we release the
iter fake lock again (i.e. make sure that iter_put is called), but
not check any locking dependecies itself. That seams to require a
recursive read lock in trylock mode.

Cc: Dave Airlie <airlied@gmail.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161213230814.19598-6-daniel.vetter@ffwll.ch
7 years agodrm: Drop locking cargo-cult from drm_mode_config_init
Daniel Vetter [Tue, 13 Dec 2016 23:08:05 +0000 (00:08 +0100)]
drm: Drop locking cargo-cult from drm_mode_config_init

This is single-threaded setup code, no need for locks. And anyway,
all properties need to be set up before the driver is registered
anyway, they can't be hot-added.

Reviewed-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161213230814.19598-5-daniel.vetter@ffwll.ch
7 years agodrm/radeon|amdgpu: Remove redundant num_connectors check
Daniel Vetter [Tue, 13 Dec 2016 23:08:04 +0000 (00:08 +0100)]
drm/radeon|amdgpu: Remove redundant num_connectors check

The list walk will shortcircuit anyway.

Cc: Alex Deucher <alexdeucher@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161213230814.19598-4-daniel.vetter@ffwll.ch
7 years agodrm: Move atomic debugfs functions into drm_crtc_internal.h
Daniel Vetter [Tue, 13 Dec 2016 23:08:03 +0000 (00:08 +0100)]
drm: Move atomic debugfs functions into drm_crtc_internal.h

This is not driver interface stuff.

Fixes: 6559c901cb48 ("drm/atomic: add debugfs file to dump out atomic state")
Cc: Rob Clark <robdclark@gmail.com>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161213230814.19598-3-daniel.vetter@ffwll.ch
7 years agodrm/irq: drm_legacy_ prefix for legacy ioctls
Daniel Vetter [Tue, 13 Dec 2016 23:08:02 +0000 (00:08 +0100)]
drm/irq: drm_legacy_ prefix for legacy ioctls

Spotted while auditing our ioctl table. Also nuke the
not-really-kerneldoc comments, we don't document internals and
definitely don't want to mislead people with the old dragons.

I think with this all the legacy ioctls now have proper drm_legacy_
prefixes.

Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161213230814.19598-2-daniel.vetter@ffwll.ch
7 years agodrm: bridge: Detach all bridges in a chain at encoder cleanup time
Laurent Pinchart [Tue, 29 Nov 2016 18:55:44 +0000 (20:55 +0200)]
drm: bridge: Detach all bridges in a chain at encoder cleanup time

Instead of detaching only the bridge directly connected to the encoder,
detach all bridges in the chain.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1481709550-29226-6-git-send-email-laurent.pinchart+renesas@ideasonboard.com
7 years agodrm: bridge: Detach bridge from encoder at encoder cleanup time
Laurent Pinchart [Mon, 28 Nov 2016 16:32:05 +0000 (18:32 +0200)]
drm: bridge: Detach bridge from encoder at encoder cleanup time

Most drivers that use bridges forgot to detach them at cleanup time.
Instead of fixing them one by one, detach the bridge in the core
drm_encoder_cleanup() function.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1481709550-29226-5-git-send-email-laurent.pinchart+renesas@ideasonboard.com
7 years agodrm: bridge: Link encoder and bridge in core code
Laurent Pinchart [Mon, 28 Nov 2016 15:59:08 +0000 (17:59 +0200)]
drm: bridge: Link encoder and bridge in core code

Instead of linking encoders and bridges in every driver (and getting it
wrong half of the time, as many drivers forget to set the drm_bridge
encoder pointer), do so in core code. The drm_bridge_attach() function
needs the encoder and optional previous bridge to perform that task,
update all the callers.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Stefan Agner <stefan@agner.ch> # For DCU
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com> # For atmel-hlcdc
Acked-by: Vincent Abriou <vincent.abriou@st.com> # For STI
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com> # For sun4i
Acked-by: Xinliang Liu <z.liuxinliang@hisilicon.com> # For hisilicon
Acked-by: Jyri Sarha <jsarha@ti.com> # For tilcdc
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1481709550-29226-4-git-send-email-laurent.pinchart+renesas@ideasonboard.com
7 years agodrm: Fix compilation warning caused by static inline forward declaration
Laurent Pinchart [Mon, 28 Nov 2016 19:03:49 +0000 (21:03 +0200)]
drm: Fix compilation warning caused by static inline forward declaration

The drm_crtc_mask() function used in <drm/drm_encoder.h> is a static
inline defined in <drm/drm_crtc.h>. If the first header is included in a
compilation unit without the second one, the following compilation
warning will be issued.

In file included from <linux>/drivers/gpu/drm/drm_bridge.c:29:0:
<linux>/include/drm/drm_encoder.h:192:95: warning: ‘drm_crtc_mask’ used but never defined
 static inline uint32_t drm_crtc_mask(const struct drm_crtc *crtc);

Fix this by including the header defining the function instead of using
a forward declaration.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1481709550-29226-3-git-send-email-laurent.pinchart+renesas@ideasonboard.com
7 years agodrm: Don't include <drm/drm_encoder.h> in <drm/drm_crtc.h>
Laurent Pinchart [Mon, 28 Nov 2016 18:51:09 +0000 (20:51 +0200)]
drm: Don't include <drm/drm_encoder.h> in <drm/drm_crtc.h>

<drm/drm_crtc.h> used to define most of the in-kernel KMS API. It has
now been split into separate files for each object type, but still
includes most other KMS headers to avoid breaking driver compilation.

As a step towards fixing that problem, remove the inclusion of
<drm/drm_encoder.h> from <drm/drm_crtc.h> and include it instead where
appropriate. Also remove the forward declarations of the drm_encoder and
drm_encoder_helper_funcs structures from <drm/drm_crtc.h> as they're not
needed in the header.

<drm/drm_encoder.h> now has to include <drm/drm_mode.h> and contain a
forward declaration of struct drm_encoder in order to allow including it
as the first header in a compilation unit.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Sinclair Yeh <syeh@vmware.com> # For vmwgfx
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1481709550-29226-2-git-send-email-laurent.pinchart+renesas@ideasonboard.com
7 years agodrm/i915: Simplify i915_gtt_color_adjust()
Chris Wilson [Fri, 16 Dec 2016 07:46:40 +0000 (07:46 +0000)]
drm/i915: Simplify i915_gtt_color_adjust()

If we remember that node_list is a circular list containing the fake
head_node, we can use a simple list_next_entry() and skip the NULL check
for the allocated check against the head_node.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161216074718.32500-3-chris@chris-wilson.co.uk
7 years agodrm: Constify the drm_mm API
Chris Wilson [Fri, 16 Dec 2016 07:46:42 +0000 (07:46 +0000)]
drm: Constify the drm_mm API

Mark up the pointers as constant through the API where appropriate.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161216074718.32500-5-chris@chris-wilson.co.uk
7 years agodrm: Add drm_mm_for_each_node_safe()
Chris Wilson [Fri, 16 Dec 2016 07:46:41 +0000 (07:46 +0000)]
drm: Add drm_mm_for_each_node_safe()

A complement to drm_mm_for_each_node(), wraps list_for_each_entry_safe()
for walking the list of nodes safe against removal.

Note from Joonas:

"Most of the diff is about __drm_mm_nodes(mm), which could be split into
own patch and keep the R-b's."

But I don't feel like insisting on the resend.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
[danvet: Add note.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161216074718.32500-4-chris@chris-wilson.co.uk
7 years agokref: prefer atomic_inc_not_zero to atomic_add_unless
Jason A. Donenfeld [Thu, 15 Dec 2016 05:01:10 +0000 (06:01 +0100)]
kref: prefer atomic_inc_not_zero to atomic_add_unless

On most platforms, there exists this ifdef:

 #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)

This makes this patch functionally useless. However, on PPC, there is
actually an explicit definition of atomic_inc_not_zero with its own
assembly that is slightly more optimized than atomic_add_unless. So,
this patch changes kref to use atomic_inc_not_zero instead, for PPC and
any future platforms that might provide an explicit implementation.

This also puts this usage of kref more in line with a verbatim reading
of the examples in Paul McKenney's paper [1] in the section titled "2.4
Atomic Counting With Check and Release Memory Barrier", which uses
atomic_inc_not_zero.

[1] http://open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2167.pdf

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161215050110.3241-1-Jason@zx2c4.com
7 years agodrm: Fix kernel docs for drm_helper_mode_fill_fb_struct()
Ville Syrjälä [Thu, 15 Dec 2016 17:01:28 +0000 (19:01 +0200)]
drm: Fix kernel docs for drm_helper_mode_fill_fb_struct()

drm_modeset_helper.c:74: warning: No description found for parameter 'dev'

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Fixes: a3f913ca9892 ("drm: Pass 'dev' to drm_helper_mode_fill_fb_struct()")
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161215170128.23972-1-ville.syrjala@linux.intel.com
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
7 years agodrm/atomic: Delete wrong comment.
Maarten Lankhorst [Thu, 15 Dec 2016 14:29:42 +0000 (15:29 +0100)]
drm/atomic: Delete wrong comment.

drm_atomic_state_put is called unconditionally, so TEST_ONLY is no
different from commit.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1481812185-19098-2-git-send-email-maarten.lankhorst@linux.intel.com
7 years agodrm: Fix typo in drm_event_reserve_init() kerneldoc
Thierry Reding [Thu, 15 Dec 2016 11:36:02 +0000 (12:36 +0100)]
drm: Fix typo in drm_event_reserve_init() kerneldoc

drm_event_reserve_init_locked() is the correct function to call when
already holding the dev->event_lock lock.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161215113602.27966-1-thierry.reding@gmail.com
7 years agodrm/cma: Fix compile fail due to fomat->format typo
Ville Syrjälä [Thu, 15 Dec 2016 14:29:27 +0000 (16:29 +0200)]
drm/cma: Fix compile fail due to fomat->format typo

Apparently my arm .config had reverted to CMA=n at some point, so I
failed to notice that I typoed the code. Fix it up so that the
cma helper will compile again.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Fixes: ca984a998ad3 ("drm/fb_cma_helper: Replace drm_format_info() with fb->format")
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161215142927.20761-1-ville.syrjala@linux.intel.com
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>