[PATCH v3 5/6] drm: atmel-hlcdc: add sam9x60 LCD controller

2019-04-26 Thread Claudiu.Beznea
From: Sandeep Sheriker Mallikarjun 

Add the LCD controller for SAM9X60.

Signed-off-by: Sandeep Sheriker Mallikarjun 

[claudiu.bez...@microchip.com: add fixed_clksrc option to
 atmel_hlcdc_dc_sam9x60]
Signed-off-by: Claudiu Beznea 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 101 +++
 1 file changed, 101 insertions(+)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 8bf51f853721..fb2e7646daeb 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -364,6 +364,103 @@ static const struct atmel_hlcdc_dc_desc 
atmel_hlcdc_dc_sama5d4 = {
.nlayers = ARRAY_SIZE(atmel_hlcdc_sama5d4_layers),
.layers = atmel_hlcdc_sama5d4_layers,
 };
+
+static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sam9x60_layers[] = {
+   {
+   .name = "base",
+   .formats = &atmel_hlcdc_plane_rgb_formats,
+   .regs_offset = 0x60,
+   .id = 0,
+   .type = ATMEL_HLCDC_BASE_LAYER,
+   .cfgs_offset = 0x2c,
+   .layout = {
+   .xstride = { 2 },
+   .default_color = 3,
+   .general_config = 4,
+   .disc_pos = 5,
+   .disc_size = 6,
+   },
+   .clut_offset = 0x600,
+   },
+   {
+   .name = "overlay1",
+   .formats = &atmel_hlcdc_plane_rgb_formats,
+   .regs_offset = 0x160,
+   .id = 1,
+   .type = ATMEL_HLCDC_OVERLAY_LAYER,
+   .cfgs_offset = 0x2c,
+   .layout = {
+   .pos = 2,
+   .size = 3,
+   .xstride = { 4 },
+   .pstride = { 5 },
+   .default_color = 6,
+   .chroma_key = 7,
+   .chroma_key_mask = 8,
+   .general_config = 9,
+   },
+   .clut_offset = 0xa00,
+   },
+   {
+   .name = "overlay2",
+   .formats = &atmel_hlcdc_plane_rgb_formats,
+   .regs_offset = 0x260,
+   .id = 2,
+   .type = ATMEL_HLCDC_OVERLAY_LAYER,
+   .cfgs_offset = 0x2c,
+   .layout = {
+   .pos = 2,
+   .size = 3,
+   .xstride = { 4 },
+   .pstride = { 5 },
+   .default_color = 6,
+   .chroma_key = 7,
+   .chroma_key_mask = 8,
+   .general_config = 9,
+   },
+   .clut_offset = 0xe00,
+   },
+   {
+   .name = "high-end-overlay",
+   .formats = &atmel_hlcdc_plane_rgb_and_yuv_formats,
+   .regs_offset = 0x360,
+   .id = 3,
+   .type = ATMEL_HLCDC_OVERLAY_LAYER,
+   .cfgs_offset = 0x4c,
+   .layout = {
+   .pos = 2,
+   .size = 3,
+   .memsize = 4,
+   .xstride = { 5, 7 },
+   .pstride = { 6, 8 },
+   .default_color = 9,
+   .chroma_key = 10,
+   .chroma_key_mask = 11,
+   .general_config = 12,
+   .scaler_config = 13,
+   .phicoeffs = {
+   .x = 17,
+   .y = 33,
+   },
+   .csc = 14,
+   },
+   .clut_offset = 0x1200,
+   },
+};
+
+static const struct atmel_hlcdc_dc_desc atmel_hlcdc_dc_sam9x60 = {
+   .min_width = 0,
+   .min_height = 0,
+   .max_width = 2048,
+   .max_height = 2048,
+   .max_spw = 0xff,
+   .max_vpw = 0xff,
+   .max_hpw = 0x3ff,
+   .fixed_clksrc = true,
+   .nlayers = ARRAY_SIZE(atmel_hlcdc_sam9x60_layers),
+   .layers = atmel_hlcdc_sam9x60_layers,
+};
+
 static const struct of_device_id atmel_hlcdc_of_match[] = {
{
.compatible = "atmel,at91sam9n12-hlcdc",
@@ -385,6 +482,10 @@ static const struct of_device_id atmel_hlcdc_of_match[] = {
.compatible = "atmel,sama5d4-hlcdc",
.data = &atmel_hlcdc_dc_sama5d4,
},
+   {
+   .compatible = "microchip,sam9x60-hlcdc",
+   .data = &atmel_hlcdc_dc_sam9x60,
+   },
{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, atmel_hlcdc_of_match);
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 28/29] stacktrace: Provide common infrastructure

2019-04-26 Thread Thomas Gleixner
All architectures which support stacktrace carry duplicated code and
do the stack storage and filtering at the architecture side.

Provide a consolidated interface with a callback function for consuming the
stack entries provided by the architecture specific stack walker. This
removes lots of duplicated code and allows to implement better filtering
than 'skip number of entries' in the future without touching any
architecture specific code.

Signed-off-by: Thomas Gleixner 
Cc: linux-a...@vger.kernel.org
---
V3: Fix kernel doc
---
 include/linux/stacktrace.h |   39 ++
 kernel/stacktrace.c|  173 +
 lib/Kconfig|4 +
 3 files changed, 216 insertions(+)

--- a/include/linux/stacktrace.h
+++ b/include/linux/stacktrace.h
@@ -23,6 +23,44 @@ unsigned int stack_trace_save_regs(struc
 unsigned int stack_trace_save_user(unsigned long *store, unsigned int size);
 
 /* Internal interfaces. Do not use in generic code */
+#ifdef CONFIG_ARCH_STACKWALK
+
+/**
+ * stack_trace_consume_fn - Callback for arch_stack_walk()
+ * @cookie:Caller supplied pointer handed back by arch_stack_walk()
+ * @addr:  The stack entry address to consume
+ * @reliable:  True when the stack entry is reliable. Required by
+ * some printk based consumers.
+ *
+ * Return: True, if the entry was consumed or skipped
+ * False, if there is no space left to store
+ */
+typedef bool (*stack_trace_consume_fn)(void *cookie, unsigned long addr,
+  bool reliable);
+/**
+ * arch_stack_walk - Architecture specific function to walk the stack
+ * @consume_entry: Callback which is invoked by the architecture code for
+ * each entry.
+ * @cookie:Caller supplied pointer which is handed back to
+ * @consume_entry
+ * @task:  Pointer to a task struct, can be NULL
+ * @regs:  Pointer to registers, can be NULL
+ *
+ *  === 
+ * taskregs
+ *  === 
+ * taskNULLStack trace from task (can be current)
+ * current regsStack trace starting on regs->stackpointer
+ *  === 
+ */
+void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie,
+struct task_struct *task, struct pt_regs *regs);
+int arch_stack_walk_reliable(stack_trace_consume_fn consume_entry, void 
*cookie,
+struct task_struct *task);
+void arch_stack_walk_user(stack_trace_consume_fn consume_entry, void *cookie,
+ const struct pt_regs *regs);
+
+#else /* CONFIG_ARCH_STACKWALK */
 struct stack_trace {
unsigned int nr_entries, max_entries;
unsigned long *entries;
@@ -37,6 +75,7 @@ extern void save_stack_trace_tsk(struct
 extern int save_stack_trace_tsk_reliable(struct task_struct *tsk,
 struct stack_trace *trace);
 extern void save_stack_trace_user(struct stack_trace *trace);
+#endif /* !CONFIG_ARCH_STACKWALK */
 #endif /* CONFIG_STACKTRACE */
 
 #if defined(CONFIG_STACKTRACE) && defined(CONFIG_HAVE_RELIABLE_STACKTRACE)
--- a/kernel/stacktrace.c
+++ b/kernel/stacktrace.c
@@ -5,6 +5,8 @@
  *
  *  Copyright (C) 2006 Red Hat, Inc., Ingo Molnar 
  */
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -66,6 +68,175 @@ int stack_trace_snprint(char *buf, size_
 }
 EXPORT_SYMBOL_GPL(stack_trace_snprint);
 
+#ifdef CONFIG_ARCH_STACKWALK
+
+struct stacktrace_cookie {
+   unsigned long   *store;
+   unsigned intsize;
+   unsigned intskip;
+   unsigned intlen;
+};
+
+static bool stack_trace_consume_entry(void *cookie, unsigned long addr,
+ bool reliable)
+{
+   struct stacktrace_cookie *c = cookie;
+
+   if (c->len >= c->size)
+   return false;
+
+   if (c->skip > 0) {
+   c->skip--;
+   return true;
+   }
+   c->store[c->len++] = addr;
+   return c->len < c->size;
+}
+
+static bool stack_trace_consume_entry_nosched(void *cookie, unsigned long addr,
+ bool reliable)
+{
+   if (in_sched_functions(addr))
+   return true;
+   return stack_trace_consume_entry(cookie, addr, reliable);
+}
+
+/**
+ * stack_trace_save - Save a stack trace into a storage array
+ * @store: Pointer to storage array
+ * @size:  Size of the storage array
+ * @skipnr:Number of entries to skip at the start of the stack trace
+ *
+ * Return: Number of trace entries stored.
+ */
+unsigned int stack_trace_save(unsigned long *store, unsigned int size,
+ unsigned int skipnr)
+{
+   stack_trace_consume_fn consume_entry = stack_trace_consume_entry;
+  

[RESEND][PATCH v3 6/6] drm/atmel-hclcdc: revert shift by 8

2019-04-26 Thread Claudiu.Beznea
From: Claudiu Beznea 

Revert shift by 8 of state->base.alpha. This introduced regresion
on planes.

Fixes: 7f73c10b256b ("drm/atmel-hclcdc: Convert to the new generic alpha 
property")
Cc: Maxime Ripard 
Signed-off-by: Claudiu Beznea 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
index e836e2de35ce..cc8301352384 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
@@ -382,7 +382,7 @@ atmel_hlcdc_plane_update_general_settings(struct 
atmel_hlcdc_plane *plane,
cfg |= ATMEL_HLCDC_LAYER_LAEN;
else
cfg |= ATMEL_HLCDC_LAYER_GAEN |
-  ATMEL_HLCDC_LAYER_GA(state->base.alpha >> 8);
+  ATMEL_HLCDC_LAYER_GA(state->base.alpha);
}
 
if (state->disc_h && state->disc_w)
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 22/29] tracing: Make ftrace_trace_userstack() static and conditional

2019-04-26 Thread Thomas Gleixner
It's only used in trace.c and there is absolutely no point in compiling it
in when user space stack traces are not supported.

Signed-off-by: Thomas Gleixner 
Reviewed-by: Steven Rostedt 
---
 kernel/trace/trace.c |   14 --
 kernel/trace/trace.h |8 
 2 files changed, 8 insertions(+), 14 deletions(-)

--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -159,6 +159,8 @@ static union trace_eval_map_item *trace_
 #endif /* CONFIG_TRACE_EVAL_MAP_FILE */
 
 static int tracing_set_tracer(struct trace_array *tr, const char *buf);
+static void ftrace_trace_userstack(struct ring_buffer *buffer,
+  unsigned long flags, int pc);
 
 #define MAX_TRACER_SIZE100
 static char bootup_tracer_buf[MAX_TRACER_SIZE] __initdata;
@@ -2905,9 +2907,10 @@ void trace_dump_stack(int skip)
 }
 EXPORT_SYMBOL_GPL(trace_dump_stack);
 
+#ifdef CONFIG_USER_STACKTRACE_SUPPORT
 static DEFINE_PER_CPU(int, user_stack_count);
 
-void
+static void
 ftrace_trace_userstack(struct ring_buffer *buffer, unsigned long flags, int pc)
 {
struct trace_event_call *call = &event_user_stack;
@@ -2958,13 +2961,12 @@ ftrace_trace_userstack(struct ring_buffe
  out:
preempt_enable();
 }
-
-#ifdef UNUSED
-static void __trace_userstack(struct trace_array *tr, unsigned long flags)
+#else /* CONFIG_USER_STACKTRACE_SUPPORT */
+static void ftrace_trace_userstack(struct ring_buffer *buffer,
+  unsigned long flags, int pc)
 {
-   ftrace_trace_userstack(tr, flags, preempt_count());
 }
-#endif /* UNUSED */
+#endif /* !CONFIG_USER_STACKTRACE_SUPPORT */
 
 #endif /* CONFIG_STACKTRACE */
 
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -782,17 +782,9 @@ void update_max_tr_single(struct trace_a
 #endif /* CONFIG_TRACER_MAX_TRACE */
 
 #ifdef CONFIG_STACKTRACE
-void ftrace_trace_userstack(struct ring_buffer *buffer, unsigned long flags,
-   int pc);
-
 void __trace_stack(struct trace_array *tr, unsigned long flags, int skip,
   int pc);
 #else
-static inline void ftrace_trace_userstack(struct ring_buffer *buffer,
- unsigned long flags, int pc)
-{
-}
-
 static inline void __trace_stack(struct trace_array *tr, unsigned long flags,
 int skip, int pc)
 {


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 16/29] drm: Simplify stacktrace handling

2019-04-26 Thread Thomas Gleixner
Replace the indirection through struct stack_trace by using the storage
array based interfaces.

The original code in all printing functions is really wrong. It allocates a
storage array on stack which is unused because depot_fetch_stack() does not
store anything in it. It overwrites the entries pointer in the stack_trace
struct so it points to the depot storage.

Signed-off-by: Thomas Gleixner 
Acked-by: Daniel Vetter 
Cc: intel-...@lists.freedesktop.org
Cc: Joonas Lahtinen 
Cc: Maarten Lankhorst 
Cc: dri-devel@lists.freedesktop.org
Cc: David Airlie 
Cc: Jani Nikula 
Cc: Rodrigo Vivi 
---
 drivers/gpu/drm/drm_mm.c|   22 +++---
 drivers/gpu/drm/i915/i915_vma.c |   11 ---
 drivers/gpu/drm/i915/intel_runtime_pm.c |   21 +++--
 3 files changed, 18 insertions(+), 36 deletions(-)

--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -106,22 +106,19 @@
 static noinline void save_stack(struct drm_mm_node *node)
 {
unsigned long entries[STACKDEPTH];
-   struct stack_trace trace = {
-   .entries = entries,
-   .max_entries = STACKDEPTH,
-   .skip = 1
-   };
+   unsigned int n;
 
-   save_stack_trace(&trace);
+   n = stack_trace_save(entries, ARRAY_SIZE(entries), 1);
 
/* May be called under spinlock, so avoid sleeping */
-   node->stack = depot_save_stack(&trace, GFP_NOWAIT);
+   node->stack = stack_depot_save(entries, n, GFP_NOWAIT);
 }
 
 static void show_leaks(struct drm_mm *mm)
 {
struct drm_mm_node *node;
-   unsigned long entries[STACKDEPTH];
+   unsigned long *entries;
+   unsigned int nr_entries;
char *buf;
 
buf = kmalloc(BUFSZ, GFP_KERNEL);
@@ -129,19 +126,14 @@ static void show_leaks(struct drm_mm *mm
return;
 
list_for_each_entry(node, drm_mm_nodes(mm), node_list) {
-   struct stack_trace trace = {
-   .entries = entries,
-   .max_entries = STACKDEPTH
-   };
-
if (!node->stack) {
DRM_ERROR("node [%08llx + %08llx]: unknown owner\n",
  node->start, node->size);
continue;
}
 
-   depot_fetch_stack(node->stack, &trace);
-   snprint_stack_trace(buf, BUFSZ, &trace, 0);
+   nr_entries = stack_depot_fetch(node->stack, &entries);
+   stack_trace_snprint(buf, BUFSZ, entries, nr_entries, 0);
DRM_ERROR("node [%08llx + %08llx]: inserted at\n%s",
  node->start, node->size, buf);
}
--- a/drivers/gpu/drm/i915/i915_vma.c
+++ b/drivers/gpu/drm/i915/i915_vma.c
@@ -36,11 +36,8 @@
 
 static void vma_print_allocator(struct i915_vma *vma, const char *reason)
 {
-   unsigned long entries[12];
-   struct stack_trace trace = {
-   .entries = entries,
-   .max_entries = ARRAY_SIZE(entries),
-   };
+   unsigned long *entries;
+   unsigned int nr_entries;
char buf[512];
 
if (!vma->node.stack) {
@@ -49,8 +46,8 @@ static void vma_print_allocator(struct i
return;
}
 
-   depot_fetch_stack(vma->node.stack, &trace);
-   snprint_stack_trace(buf, sizeof(buf), &trace, 0);
+   nr_entries = stack_depot_fetch(vma->node.stack, &entries);
+   stack_trace_snprint(buf, sizeof(buf), entries, nr_entries, 0);
DRM_DEBUG_DRIVER("vma.node [%08llx + %08llx] %s: inserted at %s\n",
 vma->node.start, vma->node.size, reason, buf);
 }
--- a/drivers/gpu/drm/i915/intel_runtime_pm.c
+++ b/drivers/gpu/drm/i915/intel_runtime_pm.c
@@ -60,27 +60,20 @@
 static noinline depot_stack_handle_t __save_depot_stack(void)
 {
unsigned long entries[STACKDEPTH];
-   struct stack_trace trace = {
-   .entries = entries,
-   .max_entries = ARRAY_SIZE(entries),
-   .skip = 1,
-   };
+   unsigned int n;
 
-   save_stack_trace(&trace);
-   return depot_save_stack(&trace, GFP_NOWAIT | __GFP_NOWARN);
+   n = stack_trace_save(entries, ARRAY_SIZE(entries), 1);
+   return stack_depot_save(entries, n, GFP_NOWAIT | __GFP_NOWARN);
 }
 
 static void __print_depot_stack(depot_stack_handle_t stack,
char *buf, int sz, int indent)
 {
-   unsigned long entries[STACKDEPTH];
-   struct stack_trace trace = {
-   .entries = entries,
-   .max_entries = ARRAY_SIZE(entries),
-   };
+   unsigned long *entries;
+   unsigned int nr_entries;
 
-   depot_fetch_stack(stack, &trace);
-   snprint_stack_trace(buf, sz, &trace, indent);
+   nr_entries = stack_depot_fetch(stack, &entries);
+   stack_trace_snprint(buf, sz, entries, nr_entries, indent);
 }
 
 static void init_intel_runtime_pm_wakeref(struct drm_i915_private *i915)


__

[PATCH v3 1/6] drm: atmel-hlcdc: add config option for clock selection

2019-04-26 Thread Claudiu.Beznea
From: Claudiu Beznea 

SAM9x60 LCD Controller has no option to select clock source as previous
controllers have. To be able to use the same driver even for this LCD
controller add a config option to know if controller supports this.

Signed-off-by: Claudiu Beznea 
Reviewed-by: Sam Ravnborg 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 12 +++-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h   |  2 ++
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index 8070a558d7b1..957e6d2fb00f 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -78,7 +78,8 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c)
unsigned long mode_rate;
struct videomode vm;
unsigned long prate;
-   unsigned int cfg;
+   unsigned int mask = ATMEL_HLCDC_CLKDIV_MASK | ATMEL_HLCDC_CLKPOL;
+   unsigned int cfg = 0;
int div;
 
vm.vfront_porch = adj->crtc_vsync_start - adj->crtc_vdisplay;
@@ -101,7 +102,10 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc 
*c)
 (adj->crtc_hdisplay - 1) |
 ((adj->crtc_vdisplay - 1) << 16));
 
-   cfg = ATMEL_HLCDC_CLKSEL;
+   if (!crtc->dc->desc->fixed_clksrc) {
+   cfg |= ATMEL_HLCDC_CLKSEL;
+   mask |= ATMEL_HLCDC_CLKSEL;
+   }
 
prate = 2 * clk_get_rate(crtc->dc->hlcdc->sys_clk);
mode_rate = adj->crtc_clock * 1000;
@@ -132,9 +136,7 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc 
*c)
 
cfg |= ATMEL_HLCDC_CLKDIV(div);
 
-   regmap_update_bits(regmap, ATMEL_HLCDC_CFG(0),
-  ATMEL_HLCDC_CLKSEL | ATMEL_HLCDC_CLKDIV_MASK |
-  ATMEL_HLCDC_CLKPOL, cfg);
+   regmap_update_bits(regmap, ATMEL_HLCDC_CFG(0), mask, cfg);
 
cfg = 0;
 
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
index 70bd540d644e..0155efb9c443 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
@@ -328,6 +328,7 @@ atmel_hlcdc_layer_to_plane(struct atmel_hlcdc_layer *layer)
  * @max_hpw: maximum horizontal back/front porch width
  * @conflicting_output_formats: true if RGBXXX output formats conflict with
  * each other.
+ * @fixed_clksrc: true if clock source is fixed
  * @layers: a layer description table describing available layers
  * @nlayers: layer description table size
  */
@@ -340,6 +341,7 @@ struct atmel_hlcdc_dc_desc {
int max_vpw;
int max_hpw;
bool conflicting_output_formats;
+   bool fixed_clksrc;
const struct atmel_hlcdc_layer_desc *layers;
int nlayers;
 };
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 01/29] tracing: Cleanup stack trace code

2019-04-26 Thread Thomas Gleixner
- Remove the extra array member of stack_dump_trace[] along with the
  ARRAY_SIZE - 1 initialization for struct stack_trace :: max_entries.

  Both are historical leftovers of no value. The stack tracer never exceeds
  the array and there is no extra storage requirement either.

- Make variables which are only used in trace_stack.c static.

- Simplify the enable/disable logic.

- Rename stack_trace_print() as it's using the stack_trace_ namespace. Free
  the name up for stack trace related functions.

Signed-off-by: Thomas Gleixner 
Reviewed-by: Steven Rostedt 
---
V3: Remove the -1 init and split the variable declaration as requested by 
Steven.
V2: Add more cleanups and use print_max_stack() as requested by Steven.
---
 include/linux/ftrace.h |   18 --
 kernel/trace/trace_stack.c |   42 +-
 2 files changed, 17 insertions(+), 43 deletions(-)

--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -241,21 +241,11 @@ static inline void ftrace_free_mem(struc
 
 #ifdef CONFIG_STACK_TRACER
 
-#define STACK_TRACE_ENTRIES 500
-
-struct stack_trace;
-
-extern unsigned stack_trace_index[];
-extern struct stack_trace stack_trace_max;
-extern unsigned long stack_trace_max_size;
-extern arch_spinlock_t stack_trace_max_lock;
-
 extern int stack_tracer_enabled;
-void stack_trace_print(void);
-int
-stack_trace_sysctl(struct ctl_table *table, int write,
-  void __user *buffer, size_t *lenp,
-  loff_t *ppos);
+
+int stack_trace_sysctl(struct ctl_table *table, int write,
+  void __user *buffer, size_t *lenp,
+  loff_t *ppos);
 
 /* DO NOT MODIFY THIS VARIABLE DIRECTLY! */
 DECLARE_PER_CPU(int, disable_stack_tracer);
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -18,30 +18,26 @@
 
 #include "trace.h"
 
-static unsigned long stack_dump_trace[STACK_TRACE_ENTRIES + 1];
-unsigned stack_trace_index[STACK_TRACE_ENTRIES];
+#define STACK_TRACE_ENTRIES 500
+
+static unsigned long stack_dump_trace[STACK_TRACE_ENTRIES];
+static unsigned stack_trace_index[STACK_TRACE_ENTRIES];
 
-/*
- * Reserve one entry for the passed in ip. This will allow
- * us to remove most or all of the stack size overhead
- * added by the stack tracer itself.
- */
 struct stack_trace stack_trace_max = {
-   .max_entries= STACK_TRACE_ENTRIES - 1,
+   .max_entries= STACK_TRACE_ENTRIES,
.entries= &stack_dump_trace[0],
 };
 
-unsigned long stack_trace_max_size;
-arch_spinlock_t stack_trace_max_lock =
+static unsigned long stack_trace_max_size;
+static arch_spinlock_t stack_trace_max_lock =
(arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
 
 DEFINE_PER_CPU(int, disable_stack_tracer);
 static DEFINE_MUTEX(stack_sysctl_mutex);
 
 int stack_tracer_enabled;
-static int last_stack_tracer_enabled;
 
-void stack_trace_print(void)
+static void print_max_stack(void)
 {
long i;
int size;
@@ -61,16 +57,7 @@ void stack_trace_print(void)
}
 }
 
-/*
- * When arch-specific code overrides this function, the following
- * data should be filled up, assuming stack_trace_max_lock is held to
- * prevent concurrent updates.
- * stack_trace_index[]
- * stack_trace_max
- * stack_trace_max_size
- */
-void __weak
-check_stack(unsigned long ip, unsigned long *stack)
+static void check_stack(unsigned long ip, unsigned long *stack)
 {
unsigned long this_size, flags; unsigned long *p, *top, *start;
static int tracer_frame;
@@ -179,7 +166,7 @@ check_stack(unsigned long ip, unsigned l
stack_trace_max.nr_entries = x;
 
if (task_stack_end_corrupted(current)) {
-   stack_trace_print();
+   print_max_stack();
BUG();
}
 
@@ -412,23 +399,21 @@ stack_trace_sysctl(struct ctl_table *tab
   void __user *buffer, size_t *lenp,
   loff_t *ppos)
 {
+   int was_enabled;
int ret;
 
mutex_lock(&stack_sysctl_mutex);
+   was_enabled = !!stack_tracer_enabled;
 
ret = proc_dointvec(table, write, buffer, lenp, ppos);
 
-   if (ret || !write ||
-   (last_stack_tracer_enabled == !!stack_tracer_enabled))
+   if (ret || !write || (was_enabled == !!stack_tracer_enabled))
goto out;
 
-   last_stack_tracer_enabled = !!stack_tracer_enabled;
-
if (stack_tracer_enabled)
register_ftrace_function(&trace_ops);
else
unregister_ftrace_function(&trace_ops);
-
  out:
mutex_unlock(&stack_sysctl_mutex);
return ret;
@@ -444,7 +429,6 @@ static __init int enable_stacktrace(char
strncpy(stack_trace_filter_buf, str + len, COMMAND_LINE_SIZE);
 
stack_tracer_enabled = 1;
-   last_stack_tracer_enabled = 1;
return 1;
 }
 __setup("stacktrace", enable_stacktrace);


___
dri-devel

[patch V3 15/29] dm persistent data: Simplify stack trace handling

2019-04-26 Thread Thomas Gleixner
Replace the indirection through struct stack_trace with an invocation of
the storage array based interface. This results in less storage space and
indirection.

Signed-off-by: Thomas Gleixner 
Cc: dm-de...@redhat.com
Cc: Mike Snitzer 
Cc: Alasdair Kergon 
---
 drivers/md/persistent-data/dm-block-manager.c |   19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

--- a/drivers/md/persistent-data/dm-block-manager.c
+++ b/drivers/md/persistent-data/dm-block-manager.c
@@ -35,7 +35,10 @@
 #define MAX_HOLDERS 4
 #define MAX_STACK 10
 
-typedef unsigned long stack_entries[MAX_STACK];
+struct stack_store {
+   unsigned intnr_entries;
+   unsigned long   entries[MAX_STACK];
+};
 
 struct block_lock {
spinlock_t lock;
@@ -44,8 +47,7 @@ struct block_lock {
struct task_struct *holders[MAX_HOLDERS];
 
 #ifdef CONFIG_DM_DEBUG_BLOCK_STACK_TRACING
-   struct stack_trace traces[MAX_HOLDERS];
-   stack_entries entries[MAX_HOLDERS];
+   struct stack_store traces[MAX_HOLDERS];
 #endif
 };
 
@@ -73,7 +75,7 @@ static void __add_holder(struct block_lo
 {
unsigned h = __find_holder(lock, NULL);
 #ifdef CONFIG_DM_DEBUG_BLOCK_STACK_TRACING
-   struct stack_trace *t;
+   struct stack_store *t;
 #endif
 
get_task_struct(task);
@@ -81,11 +83,7 @@ static void __add_holder(struct block_lo
 
 #ifdef CONFIG_DM_DEBUG_BLOCK_STACK_TRACING
t = lock->traces + h;
-   t->nr_entries = 0;
-   t->max_entries = MAX_STACK;
-   t->entries = lock->entries[h];
-   t->skip = 2;
-   save_stack_trace(t);
+   t->nr_entries = stack_trace_save(t->entries, MAX_STACK, 2);
 #endif
 }
 
@@ -106,7 +104,8 @@ static int __check_holder(struct block_l
DMERR("recursive lock detected in metadata");
 #ifdef CONFIG_DM_DEBUG_BLOCK_STACK_TRACING
DMERR("previously held here:");
-   print_stack_trace(lock->traces + i, 4);
+   stack_trace_print(lock->traces[i].entries,
+ lock->traces[i].nr_entries, 4);
 
DMERR("subsequent acquisition attempted here:");
dump_stack();


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v3 4/6] drm: atmel-hlcdc: enable sys_clk during initalization.

2019-04-26 Thread Claudiu.Beznea
From: Sandeep Sheriker Mallikarjun 

For SAM9X60 SoC, sys_clk is through lcd_gclk clock source and this
needs to be enabled before enabling lcd_clk.

Signed-off-by: Sandeep Sheriker Mallikarjun 

[claudiu.bez...@microchip.com: add fixed_clksrc checks]
Signed-off-by: Claudiu Beznea 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 0be13eceedba..8bf51f853721 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -625,10 +625,18 @@ static int atmel_hlcdc_dc_load(struct drm_device *dev)
dc->hlcdc = dev_get_drvdata(dev->dev->parent);
dev->dev_private = dc;
 
+   if (dc->desc->fixed_clksrc) {
+   ret = clk_prepare_enable(dc->hlcdc->sys_clk);
+   if (ret) {
+   dev_err(dev->dev, "failed to enable sys_clk\n");
+   goto err_destroy_wq;
+   }
+   }
+
ret = clk_prepare_enable(dc->hlcdc->periph_clk);
if (ret) {
dev_err(dev->dev, "failed to enable periph_clk\n");
-   goto err_destroy_wq;
+   goto err_sys_clk_disable;
}
 
pm_runtime_enable(dev->dev);
@@ -664,6 +672,9 @@ static int atmel_hlcdc_dc_load(struct drm_device *dev)
 err_periph_clk_disable:
pm_runtime_disable(dev->dev);
clk_disable_unprepare(dc->hlcdc->periph_clk);
+err_sys_clk_disable:
+   if (dc->desc->fixed_clksrc)
+   clk_disable_unprepare(dc->hlcdc->sys_clk);
 
 err_destroy_wq:
destroy_workqueue(dc->wq);
@@ -688,6 +699,8 @@ static void atmel_hlcdc_dc_unload(struct drm_device *dev)
 
pm_runtime_disable(dev->dev);
clk_disable_unprepare(dc->hlcdc->periph_clk);
+   if (dc->desc->fixed_clksrc)
+   clk_disable_unprepare(dc->hlcdc->sys_clk);
destroy_workqueue(dc->wq);
 }
 
@@ -805,6 +818,8 @@ static int atmel_hlcdc_dc_drm_suspend(struct device *dev)
regmap_read(regmap, ATMEL_HLCDC_IMR, &dc->suspend.imr);
regmap_write(regmap, ATMEL_HLCDC_IDR, dc->suspend.imr);
clk_disable_unprepare(dc->hlcdc->periph_clk);
+   if (dc->desc->fixed_clksrc)
+   clk_disable_unprepare(dc->hlcdc->sys_clk);
 
return 0;
 }
@@ -814,6 +829,8 @@ static int atmel_hlcdc_dc_drm_resume(struct device *dev)
struct drm_device *drm_dev = dev_get_drvdata(dev);
struct atmel_hlcdc_dc *dc = drm_dev->dev_private;
 
+   if (dc->desc->fixed_clksrc)
+   clk_prepare_enable(dc->hlcdc->sys_clk);
clk_prepare_enable(dc->hlcdc->periph_clk);
regmap_write(dc->hlcdc->regmap, ATMEL_HLCDC_IER, dc->suspend.imr);
 
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 21/29] tracing: Use percpu stack trace buffer more intelligently

2019-04-26 Thread Thomas Gleixner
The per cpu stack trace buffer usage pattern is odd at best. The buffer has
place for 512 stack trace entries on 64-bit and 1024 on 32-bit. When
interrupts or exceptions nest after the per cpu buffer was acquired the
stacktrace length is hardcoded to 8 entries. 512/1024 stack trace entries
in kernel stacks are unrealistic so the buffer is a complete waste.

Split the buffer into 4 nest levels, which are 128/256 entries per
level. This allows nesting contexts (interrupts, exceptions) to utilize the
cpu buffer for stack retrieval and avoids the fixed length allocation along
with the conditional execution pathes.

Signed-off-by: Thomas Gleixner 
Cc: Steven Rostedt 
---
V3: Limit to 4 nest levels and increase size per level.
---
 kernel/trace/trace.c |   77 +--
 1 file changed, 39 insertions(+), 38 deletions(-)

--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2749,12 +2749,21 @@ trace_function(struct trace_array *tr,
 
 #ifdef CONFIG_STACKTRACE
 
-#define FTRACE_STACK_MAX_ENTRIES (PAGE_SIZE / sizeof(unsigned long))
+/* Allow 4 levels of nesting: normal, softirq, irq, NMI */
+#define FTRACE_KSTACK_NESTING  4
+
+#define FTRACE_KSTACK_ENTRIES  (PAGE_SIZE / FTRACE_KSTACK_NESTING)
+
 struct ftrace_stack {
-   unsigned long   calls[FTRACE_STACK_MAX_ENTRIES];
+   unsigned long   calls[FTRACE_KSTACK_ENTRIES];
+};
+
+
+struct ftrace_stacks {
+   struct ftrace_stack stacks[FTRACE_KSTACK_NESTING];
 };
 
-static DEFINE_PER_CPU(struct ftrace_stack, ftrace_stack);
+static DEFINE_PER_CPU(struct ftrace_stacks, ftrace_stacks);
 static DEFINE_PER_CPU(int, ftrace_stack_reserve);
 
 static void __ftrace_trace_stack(struct ring_buffer *buffer,
@@ -2763,10 +2772,11 @@ static void __ftrace_trace_stack(struct
 {
struct trace_event_call *call = &event_kernel_stack;
struct ring_buffer_event *event;
+   struct ftrace_stack *fstack;
struct stack_entry *entry;
struct stack_trace trace;
-   int use_stack;
-   int size = FTRACE_STACK_ENTRIES;
+   int size = FTRACE_KSTACK_ENTRIES;
+   int stackidx;
 
trace.nr_entries= 0;
trace.skip  = skip;
@@ -2788,29 +2798,32 @@ static void __ftrace_trace_stack(struct
 */
preempt_disable_notrace();
 
-   use_stack = __this_cpu_inc_return(ftrace_stack_reserve);
+   stackidx = __this_cpu_inc_return(ftrace_stack_reserve);
+
+   /* This should never happen. If it does, yell once and skip */
+   if (WARN_ON_ONCE(stackidx >= FTRACE_KSTACK_NESTING))
+   goto out;
+
/*
-* We don't need any atomic variables, just a barrier.
-* If an interrupt comes in, we don't care, because it would
-* have exited and put the counter back to what we want.
-* We just need a barrier to keep gcc from moving things
-* around.
+* The above __this_cpu_inc_return() is 'atomic' cpu local. An
+* interrupt will either see the value pre increment or post
+* increment. If the interrupt happens pre increment it will have
+* restored the counter when it returns.  We just need a barrier to
+* keep gcc from moving things around.
 */
barrier();
-   if (use_stack == 1) {
-   trace.entries   = this_cpu_ptr(ftrace_stack.calls);
-   trace.max_entries   = FTRACE_STACK_MAX_ENTRIES;
-
-   if (regs)
-   save_stack_trace_regs(regs, &trace);
-   else
-   save_stack_trace(&trace);
-
-   if (trace.nr_entries > size)
-   size = trace.nr_entries;
-   } else
-   /* From now on, use_stack is a boolean */
-   use_stack = 0;
+
+   fstack = this_cpu_ptr(ftrace_stacks.stacks) + (stackidx - 1);
+   trace.entries   = fstack->calls;
+   trace.max_entries   = FTRACE_KSTACK_ENTRIES;
+
+   if (regs)
+   save_stack_trace_regs(regs, &trace);
+   else
+   save_stack_trace(&trace);
+
+   if (trace.nr_entries > size)
+   size = trace.nr_entries;
 
size *= sizeof(unsigned long);
 
@@ -2820,19 +2833,7 @@ static void __ftrace_trace_stack(struct
goto out;
entry = ring_buffer_event_data(event);
 
-   memset(&entry->caller, 0, size);
-
-   if (use_stack)
-   memcpy(&entry->caller, trace.entries,
-  trace.nr_entries * sizeof(unsigned long));
-   else {
-   trace.max_entries   = FTRACE_STACK_ENTRIES;
-   trace.entries   = entry->caller;
-   if (regs)
-   save_stack_trace_regs(regs, &trace);
-   else
-   save_stack_trace(&trace);
-   }
+   memcpy(&entry->caller, trace.entries, size);
 
entry->size = trace.nr_entries;
 


__

[RESEND][PATCH v3 1/6] drm: atmel-hlcdc: add config option for clock selection

2019-04-26 Thread Claudiu.Beznea
From: Claudiu Beznea 

SAM9x60 LCD Controller has no option to select clock source as previous
controllers have. To be able to use the same driver even for this LCD
controller add a config option to know if controller supports this.

Signed-off-by: Claudiu Beznea 
Reviewed-by: Sam Ravnborg 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 12 +++-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h   |  2 ++
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index 8070a558d7b1..957e6d2fb00f 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -78,7 +78,8 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c)
unsigned long mode_rate;
struct videomode vm;
unsigned long prate;
-   unsigned int cfg;
+   unsigned int mask = ATMEL_HLCDC_CLKDIV_MASK | ATMEL_HLCDC_CLKPOL;
+   unsigned int cfg = 0;
int div;
 
vm.vfront_porch = adj->crtc_vsync_start - adj->crtc_vdisplay;
@@ -101,7 +102,10 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc 
*c)
 (adj->crtc_hdisplay - 1) |
 ((adj->crtc_vdisplay - 1) << 16));
 
-   cfg = ATMEL_HLCDC_CLKSEL;
+   if (!crtc->dc->desc->fixed_clksrc) {
+   cfg |= ATMEL_HLCDC_CLKSEL;
+   mask |= ATMEL_HLCDC_CLKSEL;
+   }
 
prate = 2 * clk_get_rate(crtc->dc->hlcdc->sys_clk);
mode_rate = adj->crtc_clock * 1000;
@@ -132,9 +136,7 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc 
*c)
 
cfg |= ATMEL_HLCDC_CLKDIV(div);
 
-   regmap_update_bits(regmap, ATMEL_HLCDC_CFG(0),
-  ATMEL_HLCDC_CLKSEL | ATMEL_HLCDC_CLKDIV_MASK |
-  ATMEL_HLCDC_CLKPOL, cfg);
+   regmap_update_bits(regmap, ATMEL_HLCDC_CFG(0), mask, cfg);
 
cfg = 0;
 
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
index 70bd540d644e..0155efb9c443 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
@@ -328,6 +328,7 @@ atmel_hlcdc_layer_to_plane(struct atmel_hlcdc_layer *layer)
  * @max_hpw: maximum horizontal back/front porch width
  * @conflicting_output_formats: true if RGBXXX output formats conflict with
  * each other.
+ * @fixed_clksrc: true if clock source is fixed
  * @layers: a layer description table describing available layers
  * @nlayers: layer description table size
  */
@@ -340,6 +341,7 @@ struct atmel_hlcdc_dc_desc {
int max_vpw;
int max_hpw;
bool conflicting_output_formats;
+   bool fixed_clksrc;
const struct atmel_hlcdc_layer_desc *layers;
int nlayers;
 };
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RESEND][PATCH v3 3/6] pwm: atmel-hlcdc: add compatible for SAM9X60 HLCDC's PWM

2019-04-26 Thread Claudiu.Beznea
From: Claudiu Beznea 

Add compatible string for SAM9X60 HLCDC's PWM.

Signed-off-by: Claudiu Beznea 
Acked-by: Thierry Reding 
---
 drivers/pwm/pwm-atmel-hlcdc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pwm/pwm-atmel-hlcdc.c b/drivers/pwm/pwm-atmel-hlcdc.c
index 54c6633d9b5d..6bfbe1a902fc 100644
--- a/drivers/pwm/pwm-atmel-hlcdc.c
+++ b/drivers/pwm/pwm-atmel-hlcdc.c
@@ -246,6 +246,7 @@ static const struct of_device_id atmel_hlcdc_dt_ids[] = {
.compatible = "atmel,sama5d4-hlcdc",
.data = &atmel_hlcdc_pwm_sama5d3_errata,
},
+   {   .compatible = "microchip,sam9x60-hlcdc", },
{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, atmel_hlcdc_dt_ids);
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 08/29] mm/kmemleak: Simplify stacktrace handling

2019-04-26 Thread Thomas Gleixner
Replace the indirection through struct stack_trace by using the storage
array based interfaces.

Signed-off-by: Thomas Gleixner 
Acked-by: Catalin Marinas 
Cc: linux...@kvack.org
---
 mm/kmemleak.c |   24 +++-
 1 file changed, 3 insertions(+), 21 deletions(-)

--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -410,11 +410,6 @@ static void print_unreferenced(struct se
  */
 static void dump_object_info(struct kmemleak_object *object)
 {
-   struct stack_trace trace;
-
-   trace.nr_entries = object->trace_len;
-   trace.entries = object->trace;
-
pr_notice("Object 0x%08lx (size %zu):\n",
  object->pointer, object->size);
pr_notice("  comm \"%s\", pid %d, jiffies %lu\n",
@@ -424,7 +419,7 @@ static void dump_object_info(struct kmem
pr_notice("  flags = 0x%x\n", object->flags);
pr_notice("  checksum = %u\n", object->checksum);
pr_notice("  backtrace:\n");
-   print_stack_trace(&trace, 4);
+   stack_trace_print(object->trace, object->trace_len, 4);
 }
 
 /*
@@ -553,15 +548,7 @@ static struct kmemleak_object *find_and_
  */
 static int __save_stack_trace(unsigned long *trace)
 {
-   struct stack_trace stack_trace;
-
-   stack_trace.max_entries = MAX_TRACE;
-   stack_trace.nr_entries = 0;
-   stack_trace.entries = trace;
-   stack_trace.skip = 2;
-   save_stack_trace(&stack_trace);
-
-   return stack_trace.nr_entries;
+   return stack_trace_save(trace, MAX_TRACE, 2);
 }
 
 /*
@@ -2019,13 +2006,8 @@ early_param("kmemleak", kmemleak_boot_co
 
 static void __init print_log_trace(struct early_log *log)
 {
-   struct stack_trace trace;
-
-   trace.nr_entries = log->trace_len;
-   trace.entries = log->trace;
-
pr_notice("Early log backtrace:\n");
-   print_stack_trace(&trace, 2);
+   stack_trace_print(log->trace, log->trace_len, 2);
 }
 
 /*


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 12/29] dma/debug: Simplify stracktrace retrieval

2019-04-26 Thread Thomas Gleixner
Replace the indirection through struct stack_trace with an invocation of
the storage array based interface.

Signed-off-by: Thomas Gleixner 
Reviewed-by: Christoph Hellwig 
Cc: io...@lists.linux-foundation.org
Cc: Robin Murphy 
Cc: Marek Szyprowski 
---
 kernel/dma/debug.c |   14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

--- a/kernel/dma/debug.c
+++ b/kernel/dma/debug.c
@@ -89,8 +89,8 @@ struct dma_debug_entry {
int  sg_mapped_ents;
enum map_err_types  map_err_type;
 #ifdef CONFIG_STACKTRACE
-   struct   stack_trace stacktrace;
-   unsigned longst_entries[DMA_DEBUG_STACKTRACE_ENTRIES];
+   unsigned intstack_len;
+   unsigned long   stack_entries[DMA_DEBUG_STACKTRACE_ENTRIES];
 #endif
 };
 
@@ -174,7 +174,7 @@ static inline void dump_entry_trace(stru
 #ifdef CONFIG_STACKTRACE
if (entry) {
pr_warning("Mapped at:\n");
-   print_stack_trace(&entry->stacktrace, 0);
+   stack_trace_print(entry->stack_entries, entry->stack_len, 0);
}
 #endif
 }
@@ -704,12 +704,10 @@ static struct dma_debug_entry *dma_entry
spin_unlock_irqrestore(&free_entries_lock, flags);
 
 #ifdef CONFIG_STACKTRACE
-   entry->stacktrace.max_entries = DMA_DEBUG_STACKTRACE_ENTRIES;
-   entry->stacktrace.entries = entry->st_entries;
-   entry->stacktrace.skip = 1;
-   save_stack_trace(&entry->stacktrace);
+   entry->stack_len = stack_trace_save(entry->stack_entries,
+   ARRAY_SIZE(entry->stack_entries),
+   1);
 #endif
-
return entry;
 }
 


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v3 3/6] pwm: atmel-hlcdc: add compatible for SAM9X60 HLCDC's PWM

2019-04-26 Thread Claudiu.Beznea
From: Claudiu Beznea 

Add compatible string for SAM9X60 HLCDC's PWM.

Signed-off-by: Claudiu Beznea 
Acked-by: Thierry Reding 
---
 drivers/pwm/pwm-atmel-hlcdc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pwm/pwm-atmel-hlcdc.c b/drivers/pwm/pwm-atmel-hlcdc.c
index 54c6633d9b5d..6bfbe1a902fc 100644
--- a/drivers/pwm/pwm-atmel-hlcdc.c
+++ b/drivers/pwm/pwm-atmel-hlcdc.c
@@ -246,6 +246,7 @@ static const struct of_device_id atmel_hlcdc_dt_ids[] = {
.compatible = "atmel,sama5d4-hlcdc",
.data = &atmel_hlcdc_pwm_sama5d3_errata,
},
+   {   .compatible = "microchip,sam9x60-hlcdc", },
{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, atmel_hlcdc_dt_ids);
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RESEND][PATCH v3 2/6] drm: atmel-hlcdc: avoid initializing cfg with zero

2019-04-26 Thread Claudiu.Beznea
From: Claudiu Beznea 

Remove cfg initialization with zero and read state with
drm_crtc_state_to_atmel_hlcdc_crtc_state() so that cfg to be initialized
with state's output_mode.

Signed-off-by: Claudiu Beznea 
Reviewed-by: Sam Ravnborg 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index 957e6d2fb00f..81c50772df05 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -138,7 +138,8 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc 
*c)
 
regmap_update_bits(regmap, ATMEL_HLCDC_CFG(0), mask, cfg);
 
-   cfg = 0;
+   state = drm_crtc_state_to_atmel_hlcdc_crtc_state(c->state);
+   cfg = state->output_mode << 8;
 
if (adj->flags & DRM_MODE_FLAG_NVSYNC)
cfg |= ATMEL_HLCDC_VSPOL;
@@ -146,9 +147,6 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc 
*c)
if (adj->flags & DRM_MODE_FLAG_NHSYNC)
cfg |= ATMEL_HLCDC_HSPOL;
 
-   state = drm_crtc_state_to_atmel_hlcdc_crtc_state(c->state);
-   cfg |= state->output_mode << 8;
-
regmap_update_bits(regmap, ATMEL_HLCDC_CFG(5),
   ATMEL_HLCDC_HSPOL | ATMEL_HLCDC_VSPOL |
   ATMEL_HLCDC_VSPDLYS | ATMEL_HLCDC_VSPDLYE |
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH v2 4/9] powerpc/powernv/npu: use helper pci_dev_id

2019-04-26 Thread Alexey Kardashevskiy


On 25/04/2019 05:14, Heiner Kallweit wrote:
> Use new helper pci_dev_id() to simplify the code.
> 
> Signed-off-by: Heiner Kallweit 



Reviewed-by: Alexey Kardashevskiy 


> ---
>  arch/powerpc/platforms/powernv/npu-dma.c | 14 ++
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/powernv/npu-dma.c 
> b/arch/powerpc/platforms/powernv/npu-dma.c
> index dc23d9d2a..495550432 100644
> --- a/arch/powerpc/platforms/powernv/npu-dma.c
> +++ b/arch/powerpc/platforms/powernv/npu-dma.c
> @@ -1213,9 +1213,8 @@ int pnv_npu2_map_lpar_dev(struct pci_dev *gpdev, 
> unsigned int lparid,
>* Currently we only support radix and non-zero LPCR only makes sense
>* for hash tables so skiboot expects the LPCR parameter to be a zero.
>*/
> - ret = opal_npu_map_lpar(nphb->opal_id,
> - PCI_DEVID(gpdev->bus->number, gpdev->devfn), lparid,
> - 0 /* LPCR bits */);
> + ret = opal_npu_map_lpar(nphb->opal_id, pci_dev_id(gpdev), lparid,
> + 0 /* LPCR bits */);
>   if (ret) {
>   dev_err(&gpdev->dev, "Error %d mapping device to LPAR\n", ret);
>   return ret;
> @@ -1224,7 +1223,7 @@ int pnv_npu2_map_lpar_dev(struct pci_dev *gpdev, 
> unsigned int lparid,
>   dev_dbg(&gpdev->dev, "init context opalid=%llu msr=%lx\n",
>   nphb->opal_id, msr);
>   ret = opal_npu_init_context(nphb->opal_id, 0/*__unused*/, msr,
> - PCI_DEVID(gpdev->bus->number, gpdev->devfn));
> + pci_dev_id(gpdev));
>   if (ret < 0)
>   dev_err(&gpdev->dev, "Failed to init context: %d\n", ret);
>   else
> @@ -1258,7 +1257,7 @@ int pnv_npu2_unmap_lpar_dev(struct pci_dev *gpdev)
>   dev_dbg(&gpdev->dev, "destroy context opalid=%llu\n",
>   nphb->opal_id);
>   ret = opal_npu_destroy_context(nphb->opal_id, 0/*__unused*/,
> - PCI_DEVID(gpdev->bus->number, gpdev->devfn));
> +pci_dev_id(gpdev));
>   if (ret < 0) {
>   dev_err(&gpdev->dev, "Failed to destroy context: %d\n", ret);
>   return ret;
> @@ -1266,9 +1265,8 @@ int pnv_npu2_unmap_lpar_dev(struct pci_dev *gpdev)
>  
>   /* Set LPID to 0 anyway, just to be safe */
>   dev_dbg(&gpdev->dev, "Map LPAR opalid=%llu lparid=0\n", nphb->opal_id);
> - ret = opal_npu_map_lpar(nphb->opal_id,
> - PCI_DEVID(gpdev->bus->number, gpdev->devfn), 0 /*LPID*/,
> - 0 /* LPCR bits */);
> + ret = opal_npu_map_lpar(nphb->opal_id, pci_dev_id(gpdev), 0 /*LPID*/,
> + 0 /* LPCR bits */);
>   if (ret)
>   dev_err(&gpdev->dev, "Error %d mapping device to LPAR\n", ret);
>  
> 

-- 
Alexey
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 24/29] tracing: Remove the last struct stack_trace usage

2019-04-26 Thread Thomas Gleixner
Simplify the stack retrieval code by using the storage array based
interface.

Signed-off-by: Thomas Gleixner 
Reviewed-by: Steven Rostedt (VMware) 
---
 kernel/trace/trace_stack.c |   37 -
 1 file changed, 16 insertions(+), 21 deletions(-)

--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -23,11 +23,7 @@
 static unsigned long stack_dump_trace[STACK_TRACE_ENTRIES];
 static unsigned stack_trace_index[STACK_TRACE_ENTRIES];
 
-struct stack_trace stack_trace_max = {
-   .max_entries= STACK_TRACE_ENTRIES,
-   .entries= &stack_dump_trace[0],
-};
-
+static unsigned int stack_trace_entries;
 static unsigned long stack_trace_max_size;
 static arch_spinlock_t stack_trace_max_lock =
(arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
@@ -44,10 +40,10 @@ static void print_max_stack(void)
 
pr_emerg("DepthSize   Location(%d entries)\n"
   "-   \n",
-  stack_trace_max.nr_entries);
+  stack_trace_entries);
 
-   for (i = 0; i < stack_trace_max.nr_entries; i++) {
-   if (i + 1 == stack_trace_max.nr_entries)
+   for (i = 0; i < stack_trace_entries; i++) {
+   if (i + 1 == stack_trace_entries)
size = stack_trace_index[i];
else
size = stack_trace_index[i] - stack_trace_index[i+1];
@@ -93,13 +89,12 @@ static void check_stack(unsigned long ip
 
stack_trace_max_size = this_size;
 
-   stack_trace_max.nr_entries = 0;
-   stack_trace_max.skip = 0;
-
-   save_stack_trace(&stack_trace_max);
+   stack_trace_entries = stack_trace_save(stack_dump_trace,
+  ARRAY_SIZE(stack_dump_trace) - 1,
+  0);
 
/* Skip over the overhead of the stack tracer itself */
-   for (i = 0; i < stack_trace_max.nr_entries; i++) {
+   for (i = 0; i < stack_trace_entries; i++) {
if (stack_dump_trace[i] == ip)
break;
}
@@ -108,7 +103,7 @@ static void check_stack(unsigned long ip
 * Some archs may not have the passed in ip in the dump.
 * If that happens, we need to show everything.
 */
-   if (i == stack_trace_max.nr_entries)
+   if (i == stack_trace_entries)
i = 0;
 
/*
@@ -126,13 +121,13 @@ static void check_stack(unsigned long ip
 * loop will only happen once. This code only takes place
 * on a new max, so it is far from a fast path.
 */
-   while (i < stack_trace_max.nr_entries) {
+   while (i < stack_trace_entries) {
int found = 0;
 
stack_trace_index[x] = this_size;
p = start;
 
-   for (; p < top && i < stack_trace_max.nr_entries; p++) {
+   for (; p < top && i < stack_trace_entries; p++) {
/*
 * The READ_ONCE_NOCHECK is used to let KASAN know that
 * this is not a stack-out-of-bounds error.
@@ -163,7 +158,7 @@ static void check_stack(unsigned long ip
i++;
}
 
-   stack_trace_max.nr_entries = x;
+   stack_trace_entries = x;
 
if (task_stack_end_corrupted(current)) {
print_max_stack();
@@ -265,7 +260,7 @@ static void *
 {
long n = *pos - 1;
 
-   if (n >= stack_trace_max.nr_entries)
+   if (n >= stack_trace_entries)
return NULL;
 
m->private = (void *)n;
@@ -329,7 +324,7 @@ static int t_show(struct seq_file *m, vo
seq_printf(m, "DepthSize   Location"
   "(%d entries)\n"
   "-   \n",
-  stack_trace_max.nr_entries);
+  stack_trace_entries);
 
if (!stack_tracer_enabled && !stack_trace_max_size)
print_disabled(m);
@@ -339,10 +334,10 @@ static int t_show(struct seq_file *m, vo
 
i = *(long *)v;
 
-   if (i >= stack_trace_max.nr_entries)
+   if (i >= stack_trace_entries)
return 0;
 
-   if (i + 1 == stack_trace_max.nr_entries)
+   if (i + 1 == stack_trace_entries)
size = stack_trace_index[i];
else
size = stack_trace_index[i] - stack_trace_index[i+1];


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 04/29] backtrace-test: Simplify stack trace handling

2019-04-26 Thread Thomas Gleixner
Replace the indirection through struct stack_trace by using the storage
array based interfaces.

Signed-off-by: Thomas Gleixner 
---
 kernel/backtracetest.c |   11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

--- a/kernel/backtracetest.c
+++ b/kernel/backtracetest.c
@@ -48,19 +48,14 @@ static void backtrace_test_irq(void)
 #ifdef CONFIG_STACKTRACE
 static void backtrace_test_saved(void)
 {
-   struct stack_trace trace;
unsigned long entries[8];
+   unsigned int nr_entries;
 
pr_info("Testing a saved backtrace.\n");
pr_info("The following trace is a kernel self test and not a bug!\n");
 
-   trace.nr_entries = 0;
-   trace.max_entries = ARRAY_SIZE(entries);
-   trace.entries = entries;
-   trace.skip = 0;
-
-   save_stack_trace(&trace);
-   print_stack_trace(&trace, 0);
+   nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 0);
+   stack_trace_print(entries, nr_entries, 0);
 }
 #else
 static void backtrace_test_saved(void)


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RESEND][PATCH v3 0/6] add LCD support for SAM9X60

2019-04-26 Thread Claudiu.Beznea
From: Claudiu Beznea 

Hi,

These patches adds support for SAM9X60's LCD controller.

First patches add option to specify if controller clock source is fixed.
Second patch avoid a variable initialization in 
atmel_hlcdc_crtc_mode_set_nofb().
The 3rd add compatibles in pwm-atmel-hlcdc driver.
The 4th patch enables sys_clk in probe since SAM9X60 needs this.
Specific support was added also in suspend/resume hooks.
The 5th patch adds SAM9X60's LCD configuration and enabled it.

I took the changes of this series and introduced also a fix
(this is the 6th patch in this series) - if you want to send it separately
I would gladly do it.

I resend this to also include Lee Jones for pwm-atmel-hlcdc changes.

Thank you,
Claudiu Beznea

Changes in v3:
- keep compatible string on patch 3/6 on a single line (I keep here a tab
  in front of ".compatible" to be aligned with the rest of the code in
  atmel_hlcdc_dt_ids[])
- patches 4/7 and 3/7 from v2 were applied so remove them from this version
- add a fix for atmel_hlcdc (patch 6/6)

Changes in v2:
- use "|" operator in patch 1/7 to set ATMEL_HLCDC_CLKSEL on cfg
- collect Acked-by, Reviewed-by tags

Claudiu Beznea (4):
  drm: atmel-hlcdc: add config option for clock selection
  drm: atmel-hlcdc: avoid initializing cfg with zero
  pwm: atmel-hlcdc: add compatible for SAM9X60 HLCDC's PWM
  drm/atmel-hclcdc: revert shift by 8

Sandeep Sheriker Mallikarjun (2):
  drm: atmel-hlcdc: enable sys_clk during initalization.
  drm: atmel-hlcdc: add sam9x60 LCD controller

 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c  |  18 ++--
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c| 120 +++-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h|   2 +
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c |   2 +-
 drivers/pwm/pwm-atmel-hlcdc.c   |   1 +
 5 files changed, 132 insertions(+), 11 deletions(-)

-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v3 1/3] dt-bindings: display: Add Sharp LS020B1DD01D panel documentation

2019-04-26 Thread Paul Cercueil
The LS020B1DD01D is a 2.0" 240x160 16-bit TFT LCD panel.

Signed-off-by: Paul Cercueil 
Reviewed-by: Rob Herring 
---

Notes:
v2: New patch

v3: Add Rob's Reviewed-by

 .../bindings/display/panel/sharp,ls020b1dd01d.txt| 12 
 1 file changed, 12 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/sharp,ls020b1dd01d.txt

diff --git 
a/Documentation/devicetree/bindings/display/panel/sharp,ls020b1dd01d.txt 
b/Documentation/devicetree/bindings/display/panel/sharp,ls020b1dd01d.txt
new file mode 100644
index ..e45edbc565a3
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/sharp,ls020b1dd01d.txt
@@ -0,0 +1,12 @@
+Sharp 2.0" (240x160 pixels) 16-bit TFT LCD panel
+
+Required properties:
+- compatible: should be "sharp,ls020b1dd01d"
+- power-supply: as specified in the base binding
+
+Optional properties:
+- backlight: as specified in the base binding
+- enable-gpios: as specified in the base binding
+
+This binding is compatible with the simple-panel binding, which is specified
+in simple-panel.txt in this directory.
-- 
2.21.0.593.g511ec345e18

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v3 2/3] drm: Add bus flag for Sharp-specific signals

2019-04-26 Thread Paul Cercueil
Add the DRM_BUS_FLAG_SHARP_SIGNALS to the drm_bus_flags enum.

This flags can be used when the display must be driven with the
Sharp-specific signals SPL, CLS, REV, PS.

Signed-off-by: Paul Cercueil 
---

Notes:
v3: New patch

 include/drm/drm_connector.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 02a131202add..ac7d58fd1e03 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -323,6 +323,8 @@ enum drm_panel_orientation {
  * edge of the pixel clock
  * @DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE:  Sync signals are sampled on the falling
  * edge of the pixel clock
+ * @DRM_BUS_FLAG_SHARP_SIGNALS:Set if the Sharp-specific 
signals
+ * (SPL, CLS, PS, REV) must be used
  */
 enum drm_bus_flags {
DRM_BUS_FLAG_DE_LOW = BIT(0),
@@ -341,6 +343,7 @@ enum drm_bus_flags {
DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE = DRM_BUS_FLAG_SYNC_NEGEDGE,
DRM_BUS_FLAG_SYNC_SAMPLE_POSEDGE = DRM_BUS_FLAG_SYNC_NEGEDGE,
DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE = DRM_BUS_FLAG_SYNC_POSEDGE,
+   DRM_BUS_FLAG_SHARP_SIGNALS = BIT(8),
 };
 
 /**
-- 
2.21.0.593.g511ec345e18

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 18/29] lockdep: Remove save argument from check_prev_add()

2019-04-26 Thread Thomas Gleixner
There is only one caller which hands in save_trace as function pointer.

Signed-off-by: Thomas Gleixner 
---
 kernel/locking/lockdep.c |   16 
 1 file changed, 8 insertions(+), 8 deletions(-)

--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -2158,8 +2158,7 @@ check_deadlock(struct task_struct *curr,
  */
 static int
 check_prev_add(struct task_struct *curr, struct held_lock *prev,
-  struct held_lock *next, int distance, struct stack_trace *trace,
-  int (*save)(struct stack_trace *trace))
+  struct held_lock *next, int distance, struct stack_trace *trace)
 {
struct lock_list *uninitialized_var(target_entry);
struct lock_list *entry;
@@ -2199,11 +2198,11 @@ check_prev_add(struct task_struct *curr,
if (unlikely(!ret)) {
if (!trace->entries) {
/*
-* If @save fails here, the printing might trigger
-* a WARN but because of the !nr_entries it should
-* not do bad things.
+* If save_trace fails here, the printing might
+* trigger a WARN but because of the !nr_entries it
+* should not do bad things.
 */
-   save(trace);
+   save_trace(trace);
}
return print_circular_bug(&this, target_entry, next, prev);
}
@@ -2253,7 +2252,7 @@ check_prev_add(struct task_struct *curr,
return print_bfs_bug(ret);
 
 
-   if (!trace->entries && !save(trace))
+   if (!trace->entries && !save_trace(trace))
return 0;
 
/*
@@ -2318,7 +2317,8 @@ check_prevs_add(struct task_struct *curr
 * added:
 */
if (hlock->read != 2 && hlock->check) {
-   int ret = check_prev_add(curr, hlock, next, distance, 
&trace, save_trace);
+   int ret = check_prev_add(curr, hlock, next, distance,
+&trace);
if (!ret)
return 0;
 


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v4 1/2] dt-bindings: Add doc for the Ingenic JZ47xx LCD controller driver

2019-04-26 Thread Paul Cercueil
Add documentation for the devicetree bindings of the LCD controller present in
the JZ47xx family of SoCs from Ingenic.

Signed-off-by: Paul Cercueil 
Tested-by: Artur Rojek 
---

Notes:
v2: Remove ingenic,panel property.

v3: - Rename compatible strings from ingenic,jz47XX-drm to 
ingenic,jz47XX-lcd
- The ingenic,lcd-mode property is now read from the panel node instead
  of from the driver node

v4: Remove ingenic,lcd-mode property completely.

 .../bindings/display/ingenic,lcd.txt  | 44 +++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/ingenic,lcd.txt

diff --git a/Documentation/devicetree/bindings/display/ingenic,lcd.txt 
b/Documentation/devicetree/bindings/display/ingenic,lcd.txt
new file mode 100644
index ..7b536c8c6dde
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/ingenic,lcd.txt
@@ -0,0 +1,44 @@
+Ingenic JZ47xx LCD driver
+
+Required properties:
+- compatible: one of:
+  * ingenic,jz4740-lcd
+  * ingenic,jz4725b-lcd
+- reg: LCD registers location and length
+- clocks: LCD pixclock and device clock specifiers.
+  The device clock is only required on the JZ4740.
+- clock-names: "lcd_pclk" and "lcd"
+- interrupts: Specifies the interrupt line the LCD controller is connected to.
+
+Example:
+
+panel {
+   compatible = "sharp,ls020b1dd01d";
+
+   backlight = <&backlight>;
+   power-supply = <&vcc>;
+
+   port {
+   panel_input: endpoint {
+   remote-endpoint = <&panel_output>;
+   };
+   };
+};
+
+
+lcd: lcd-controller@1305 {
+   compatible = "ingenic,jz4725b-lcd";
+   reg = <0x1305 0x1000>;
+
+   interrupt-parent = <&intc>;
+   interrupts = <31>;
+
+   clocks = <&cgu JZ4725B_CLK_LCD>;
+   clock-names = "lcd";
+
+   port {
+   panel_output: endpoint {
+   remote-endpoint = <&panel_input>;
+   };
+   };
+};
-- 
2.21.0.593.g511ec345e18

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 27/29] lib/stackdepot: Remove obsolete functions

2019-04-26 Thread Thomas Gleixner
No more users of the struct stack_trace based interfaces.

Signed-off-by: Thomas Gleixner 
Acked-by: Alexander Potapenko 
---
 include/linux/stackdepot.h |4 
 lib/stackdepot.c   |   20 
 2 files changed, 24 deletions(-)

--- a/include/linux/stackdepot.h
+++ b/include/linux/stackdepot.h
@@ -23,13 +23,9 @@
 
 typedef u32 depot_stack_handle_t;
 
-struct stack_trace;
-
-depot_stack_handle_t depot_save_stack(struct stack_trace *trace, gfp_t flags);
 depot_stack_handle_t stack_depot_save(unsigned long *entries,
  unsigned int nr_entries, gfp_t gfp_flags);
 
-void depot_fetch_stack(depot_stack_handle_t handle, struct stack_trace *trace);
 unsigned int stack_depot_fetch(depot_stack_handle_t handle,
   unsigned long **entries);
 
--- a/lib/stackdepot.c
+++ b/lib/stackdepot.c
@@ -216,14 +216,6 @@ unsigned int stack_depot_fetch(depot_sta
 }
 EXPORT_SYMBOL_GPL(stack_depot_fetch);
 
-void depot_fetch_stack(depot_stack_handle_t handle, struct stack_trace *trace)
-{
-   unsigned int nent = stack_depot_fetch(handle, &trace->entries);
-
-   trace->max_entries = trace->nr_entries = nent;
-}
-EXPORT_SYMBOL_GPL(depot_fetch_stack);
-
 /**
  * stack_depot_save - Save a stack trace from an array
  *
@@ -318,15 +310,3 @@ depot_stack_handle_t stack_depot_save(un
return retval;
 }
 EXPORT_SYMBOL_GPL(stack_depot_save);
-
-/**
- * depot_save_stack - save stack in a stack depot.
- * @trace - the stacktrace to save.
- * @alloc_flags - flags for allocating additional memory if required.
- */
-depot_stack_handle_t depot_save_stack(struct stack_trace *trace,
- gfp_t alloc_flags)
-{
-   return stack_depot_save(trace->entries, trace->nr_entries, alloc_flags);
-}
-EXPORT_SYMBOL_GPL(depot_save_stack);


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 23/29] tracing: Simplify stack trace retrieval

2019-04-26 Thread Thomas Gleixner
Replace the indirection through struct stack_trace by using the storage
array based interfaces.

Signed-off-by: Thomas Gleixner 
Reviewed-by: Steven Rostedt (VMware) 
---
 kernel/trace/trace.c |   40 +---
 1 file changed, 13 insertions(+), 27 deletions(-)

--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2774,22 +2774,18 @@ static void __ftrace_trace_stack(struct
 {
struct trace_event_call *call = &event_kernel_stack;
struct ring_buffer_event *event;
+   unsigned int size, nr_entries;
struct ftrace_stack *fstack;
struct stack_entry *entry;
-   struct stack_trace trace;
-   int size = FTRACE_KSTACK_ENTRIES;
int stackidx;
 
-   trace.nr_entries= 0;
-   trace.skip  = skip;
-
/*
 * Add one, for this function and the call to save_stack_trace()
 * If regs is set, then these functions will not be in the way.
 */
 #ifndef CONFIG_UNWINDER_ORC
if (!regs)
-   trace.skip++;
+   skip++;
 #endif
 
/*
@@ -2816,28 +2812,24 @@ static void __ftrace_trace_stack(struct
barrier();
 
fstack = this_cpu_ptr(ftrace_stacks.stacks) + (stackidx - 1);
-   trace.entries   = fstack->calls;
-   trace.max_entries   = FTRACE_KSTACK_ENTRIES;
-
-   if (regs)
-   save_stack_trace_regs(regs, &trace);
-   else
-   save_stack_trace(&trace);
-
-   if (trace.nr_entries > size)
-   size = trace.nr_entries;
+   size = ARRAY_SIZE(fstack->calls);
 
-   size *= sizeof(unsigned long);
+   if (regs) {
+   nr_entries = stack_trace_save_regs(regs, fstack->calls,
+  size, skip);
+   } else {
+   nr_entries = stack_trace_save(fstack->calls, size, skip);
+   }
 
+   size = nr_entries * sizeof(unsigned long);
event = __trace_buffer_lock_reserve(buffer, TRACE_STACK,
sizeof(*entry) + size, flags, pc);
if (!event)
goto out;
entry = ring_buffer_event_data(event);
 
-   memcpy(&entry->caller, trace.entries, size);
-
-   entry->size = trace.nr_entries;
+   memcpy(&entry->caller, fstack->calls, size);
+   entry->size = nr_entries;
 
if (!call_filter_check_discard(call, entry, buffer, event))
__buffer_unlock_commit(buffer, event);
@@ -2916,7 +2908,6 @@ ftrace_trace_userstack(struct ring_buffe
struct trace_event_call *call = &event_user_stack;
struct ring_buffer_event *event;
struct userstack_entry *entry;
-   struct stack_trace trace;
 
if (!(global_trace.trace_flags & TRACE_ITER_USERSTACKTRACE))
return;
@@ -2947,12 +2938,7 @@ ftrace_trace_userstack(struct ring_buffe
entry->tgid = current->tgid;
memset(&entry->caller, 0, sizeof(entry->caller));
 
-   trace.nr_entries= 0;
-   trace.max_entries   = FTRACE_STACK_ENTRIES;
-   trace.skip  = 0;
-   trace.entries   = entry->caller;
-
-   save_stack_trace_user(&trace);
+   stack_trace_save_user(entry->caller, FTRACE_STACK_ENTRIES);
if (!call_filter_check_discard(call, entry, buffer, event))
__buffer_unlock_commit(buffer, event);
 


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 11/29] fault-inject: Simplify stacktrace retrieval

2019-04-26 Thread Thomas Gleixner
Replace the indirection through struct stack_trace with an invocation of
the storage array based interface.

Signed-off-by: Thomas Gleixner 
Cc: Akinobu Mita 
---
 lib/fault-inject.c |   12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

--- a/lib/fault-inject.c
+++ b/lib/fault-inject.c
@@ -65,22 +65,16 @@ static bool fail_task(struct fault_attr
 
 static bool fail_stacktrace(struct fault_attr *attr)
 {
-   struct stack_trace trace;
int depth = attr->stacktrace_depth;
unsigned long entries[MAX_STACK_TRACE_DEPTH];
-   int n;
+   int n, nr_entries;
bool found = (attr->require_start == 0 && attr->require_end == 
ULONG_MAX);
 
if (depth == 0)
return found;
 
-   trace.nr_entries = 0;
-   trace.entries = entries;
-   trace.max_entries = depth;
-   trace.skip = 1;
-
-   save_stack_trace(&trace);
-   for (n = 0; n < trace.nr_entries; n++) {
+   nr_entries = stack_trace_save(entries, depth, 1);
+   for (n = 0; n < nr_entries; n++) {
if (attr->reject_start <= entries[n] &&
   entries[n] < attr->reject_end)
return false;


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 09/29] mm/kasan: Simplify stacktrace handling

2019-04-26 Thread Thomas Gleixner
Replace the indirection through struct stack_trace by using the storage
array based interfaces.

Signed-off-by: Thomas Gleixner 
Acked-by: Dmitry Vyukov 
Acked-by: Andrey Ryabinin 
Cc: Alexander Potapenko 
Cc: kasan-...@googlegroups.com
Cc: linux...@kvack.org
---
 mm/kasan/common.c |   30 --
 mm/kasan/report.c |7 ---
 2 files changed, 16 insertions(+), 21 deletions(-)

--- a/mm/kasan/common.c
+++ b/mm/kasan/common.c
@@ -48,34 +48,28 @@ static inline int in_irqentry_text(unsig
 ptr < (unsigned long)&__softirqentry_text_end);
 }
 
-static inline void filter_irq_stacks(struct stack_trace *trace)
+static inline unsigned int filter_irq_stacks(unsigned long *entries,
+unsigned int nr_entries)
 {
-   int i;
+   unsigned int i;
 
-   if (!trace->nr_entries)
-   return;
-   for (i = 0; i < trace->nr_entries; i++)
-   if (in_irqentry_text(trace->entries[i])) {
+   for (i = 0; i < nr_entries; i++) {
+   if (in_irqentry_text(entries[i])) {
/* Include the irqentry function into the stack. */
-   trace->nr_entries = i + 1;
-   break;
+   return i + 1;
}
+   }
+   return nr_entries;
 }
 
 static inline depot_stack_handle_t save_stack(gfp_t flags)
 {
unsigned long entries[KASAN_STACK_DEPTH];
-   struct stack_trace trace = {
-   .nr_entries = 0,
-   .entries = entries,
-   .max_entries = KASAN_STACK_DEPTH,
-   .skip = 0
-   };
+   unsigned int nr_entries;
 
-   save_stack_trace(&trace);
-   filter_irq_stacks(&trace);
-
-   return depot_save_stack(&trace, flags);
+   nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 0);
+   nr_entries = filter_irq_stacks(entries, nr_entries);
+   return stack_depot_save(entries, nr_entries, flags);
 }
 
 static inline void set_track(struct kasan_track *track, gfp_t flags)
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -100,10 +100,11 @@ static void print_track(struct kasan_tra
 {
pr_err("%s by task %u:\n", prefix, track->pid);
if (track->stack) {
-   struct stack_trace trace;
+   unsigned long *entries;
+   unsigned int nr_entries;
 
-   depot_fetch_stack(track->stack, &trace);
-   print_stack_trace(&trace, 0);
+   nr_entries = stack_depot_fetch(track->stack, &entries);
+   stack_trace_print(entries, nr_entries, 0);
} else {
pr_err("(stack is not available)\n");
}


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 20/29] tracing: Simplify stacktrace retrieval in histograms

2019-04-26 Thread Thomas Gleixner
The indirection through struct stack_trace is not necessary at all. Use the
storage array based interface.

Signed-off-by: Thomas Gleixner 
Tested-by: Tom Zanussi 
Reviewed-by: Tom Zanussi 
Acked-by: Steven Rostedt (VMware) 
---
 kernel/trace/trace_events_hist.c |   12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -5186,7 +5186,6 @@ static void event_hist_trigger(struct ev
u64 var_ref_vals[TRACING_MAP_VARS_MAX];
char compound_key[HIST_KEY_SIZE_MAX];
struct tracing_map_elt *elt = NULL;
-   struct stack_trace stacktrace;
struct hist_field *key_field;
u64 field_contents;
void *key = NULL;
@@ -5198,14 +5197,9 @@ static void event_hist_trigger(struct ev
key_field = hist_data->fields[i];
 
if (key_field->flags & HIST_FIELD_FL_STACKTRACE) {
-   stacktrace.max_entries = HIST_STACKTRACE_DEPTH;
-   stacktrace.entries = entries;
-   stacktrace.nr_entries = 0;
-   stacktrace.skip = HIST_STACKTRACE_SKIP;
-
-   memset(stacktrace.entries, 0, HIST_STACKTRACE_SIZE);
-   save_stack_trace(&stacktrace);
-
+   memset(entries, 0, HIST_STACKTRACE_SIZE);
+   stack_trace_save(entries, HIST_STACKTRACE_DEPTH,
+HIST_STACKTRACE_SKIP);
key = entries;
} else {
field_contents = key_field->fn(key_field, elt, rbe, 
rec);


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 19/29] lockdep: Simplify stack trace handling

2019-04-26 Thread Thomas Gleixner
Replace the indirection through struct stack_trace by using the storage
array based interfaces and storing the information is a small lockdep
specific data structure.

Signed-off-by: Thomas Gleixner 
Acked-by: Peter Zijlstra (Intel) 
---
 include/linux/lockdep.h  |9 +--
 kernel/locking/lockdep.c |   55 +++
 2 files changed, 35 insertions(+), 29 deletions(-)

--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -66,6 +66,11 @@ struct lock_class_key {
 
 extern struct lock_class_key __lockdep_no_validate__;
 
+struct lock_trace {
+   unsigned intnr_entries;
+   unsigned intoffset;
+};
+
 #define LOCKSTAT_POINTS4
 
 /*
@@ -100,7 +105,7 @@ struct lock_class {
 * IRQ/softirq usage tracking bits:
 */
unsigned long   usage_mask;
-   struct stack_trace  usage_traces[XXX_LOCK_USAGE_STATES];
+   struct lock_trace   usage_traces[XXX_LOCK_USAGE_STATES];
 
/*
 * Generation counter, when doing certain classes of graph walking,
@@ -188,7 +193,7 @@ struct lock_list {
struct list_headentry;
struct lock_class   *class;
struct lock_class   *links_to;
-   struct stack_trace  trace;
+   struct lock_trace   trace;
int distance;
 
/*
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -434,18 +434,14 @@ static void print_lockdep_off(const char
 #endif
 }
 
-static int save_trace(struct stack_trace *trace)
+static int save_trace(struct lock_trace *trace)
 {
-   trace->nr_entries = 0;
-   trace->max_entries = MAX_STACK_TRACE_ENTRIES - nr_stack_trace_entries;
-   trace->entries = stack_trace + nr_stack_trace_entries;
-
-   trace->skip = 3;
-
-   save_stack_trace(trace);
-
-   trace->max_entries = trace->nr_entries;
+   unsigned long *entries = stack_trace + nr_stack_trace_entries;
+   unsigned int max_entries;
 
+   trace->offset = nr_stack_trace_entries;
+   max_entries = MAX_STACK_TRACE_ENTRIES - nr_stack_trace_entries;
+   trace->nr_entries = stack_trace_save(entries, max_entries, 3);
nr_stack_trace_entries += trace->nr_entries;
 
if (nr_stack_trace_entries >= MAX_STACK_TRACE_ENTRIES-1) {
@@ -1196,7 +1192,7 @@ static struct lock_list *alloc_list_entr
 static int add_lock_to_list(struct lock_class *this,
struct lock_class *links_to, struct list_head *head,
unsigned long ip, int distance,
-   struct stack_trace *trace)
+   struct lock_trace *trace)
 {
struct lock_list *entry;
/*
@@ -1415,6 +1411,13 @@ static inline int __bfs_backwards(struct
  * checking.
  */
 
+static void print_lock_trace(struct lock_trace *trace, unsigned int spaces)
+{
+   unsigned long *entries = stack_trace + trace->offset;
+
+   stack_trace_print(entries, trace->nr_entries, spaces);
+}
+
 /*
  * Print a dependency chain entry (this is only done when a deadlock
  * has been detected):
@@ -1427,8 +1430,7 @@ print_circular_bug_entry(struct lock_lis
printk("\n-> #%u", depth);
print_lock_name(target->class);
printk(KERN_CONT ":\n");
-   print_stack_trace(&target->trace, 6);
-
+   print_lock_trace(&target->trace, 6);
return 0;
 }
 
@@ -1740,7 +1742,7 @@ static void print_lock_class_header(stru
 
len += printk("%*s   %s", depth, "", usage_str[bit]);
len += printk(KERN_CONT " at:\n");
-   print_stack_trace(class->usage_traces + bit, len);
+   print_lock_trace(class->usage_traces + bit, len);
}
}
printk("%*s }\n", depth, "");
@@ -1765,7 +1767,7 @@ print_shortest_lock_dependencies(struct
do {
print_lock_class_header(entry->class, depth);
printk("%*s ... acquired at:\n", depth, "");
-   print_stack_trace(&entry->trace, 2);
+   print_lock_trace(&entry->trace, 2);
printk("\n");
 
if (depth == 0 && (entry != root)) {
@@ -1878,14 +1880,14 @@ print_bad_irq_dependency(struct task_str
print_lock_name(backwards_entry->class);
pr_warn("\n... which became %s-irq-safe at:\n", irqclass);
 
-   print_stack_trace(backwards_entry->class->usage_traces + bit1, 1);
+   print_lock_trace(backwards_entry->class->usage_traces + bit1, 1);
 
pr_warn("\nto a %s-irq-unsafe lock:\n", irqclass);
print_lock_name(forwards_entry->class);
pr_warn("\n... which became %s-irq-unsafe at:\n", irqclass);
pr_warn("...");
 
-   print_stack_trace(forwards_entry->class->usage_traces + bit2, 1);
+   print_lock_trace(forwards_entry->class->usage_traces + bit2, 1);
 
 

[patch V3 05/29] proc: Simplify task stack retrieval

2019-04-26 Thread Thomas Gleixner
Replace the indirection through struct stack_trace with an invocation of
the storage array based interface.

Signed-off-by: Thomas Gleixner 
Reviewed-by: Alexey Dobriyan 
Cc: Andrew Morton 
---
 fs/proc/base.c |   14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -407,7 +407,6 @@ static void unlock_trace(struct task_str
 static int proc_pid_stack(struct seq_file *m, struct pid_namespace *ns,
  struct pid *pid, struct task_struct *task)
 {
-   struct stack_trace trace;
unsigned long *entries;
int err;
 
@@ -430,20 +429,17 @@ static int proc_pid_stack(struct seq_fil
if (!entries)
return -ENOMEM;
 
-   trace.nr_entries= 0;
-   trace.max_entries   = MAX_STACK_TRACE_DEPTH;
-   trace.entries   = entries;
-   trace.skip  = 0;
-
err = lock_trace(task);
if (!err) {
-   unsigned int i;
+   unsigned int i, nr_entries;
 
-   save_stack_trace_tsk(task, &trace);
+   nr_entries = stack_trace_save_tsk(task, entries,
+ MAX_STACK_TRACE_DEPTH, 0);
 
-   for (i = 0; i < trace.nr_entries; i++) {
+   for (i = 0; i < nr_entries; i++) {
seq_printf(m, "[<0>] %pB\n", (void *)entries[i]);
}
+
unlock_trace(task);
}
kfree(entries);


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 17/29] lockdep: Remove unused trace argument from print_circular_bug()

2019-04-26 Thread Thomas Gleixner
Signed-off-by: Thomas Gleixner 
---
 kernel/locking/lockdep.c |9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -1522,10 +1522,9 @@ static inline int class_equal(struct loc
 }
 
 static noinline int print_circular_bug(struct lock_list *this,
-   struct lock_list *target,
-   struct held_lock *check_src,
-   struct held_lock *check_tgt,
-   struct stack_trace *trace)
+  struct lock_list *target,
+  struct held_lock *check_src,
+  struct held_lock *check_tgt)
 {
struct task_struct *curr = current;
struct lock_list *parent;
@@ -2206,7 +2205,7 @@ check_prev_add(struct task_struct *curr,
 */
save(trace);
}
-   return print_circular_bug(&this, target_entry, next, prev, 
trace);
+   return print_circular_bug(&this, target_entry, next, prev);
}
else if (unlikely(ret < 0))
return print_bfs_bug(ret);


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v3 6/6] drm/atmel-hclcdc: revert shift by 8

2019-04-26 Thread Claudiu.Beznea
From: Claudiu Beznea 

Revert shift by 8 of state->base.alpha. This introduced regresion
on planes.

Fixes: 7f73c10b256b ("drm/atmel-hclcdc: Convert to the new generic alpha 
property")
Cc: Maxime Ripard 
Signed-off-by: Claudiu Beznea 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
index e836e2de35ce..cc8301352384 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
@@ -382,7 +382,7 @@ atmel_hlcdc_plane_update_general_settings(struct 
atmel_hlcdc_plane *plane,
cfg |= ATMEL_HLCDC_LAYER_LAEN;
else
cfg |= ATMEL_HLCDC_LAYER_GAEN |
-  ATMEL_HLCDC_LAYER_GA(state->base.alpha >> 8);
+  ATMEL_HLCDC_LAYER_GA(state->base.alpha);
}
 
if (state->disc_h && state->disc_w)
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 02/29] stacktrace: Provide helpers for common stack trace operations

2019-04-26 Thread Thomas Gleixner
All operations with stack traces are based on struct stack_trace. That's a
horrible construct as the struct is a kitchen sink for input and
output. Quite some usage sites embed it into their own data structures
which creates weird indirections.

There is absolutely no point in doing so. For all use cases a storage array
and the number of valid stack trace entries in the array is sufficient.

Provide helper functions which avoid the struct stack_trace indirection so
the usage sites can be cleaned up.

Signed-off-by: Thomas Gleixner 
---
V3: Fix kernel doc.
---
 include/linux/stacktrace.h |   27 +++
 kernel/stacktrace.c|  170 +
 2 files changed, 182 insertions(+), 15 deletions(-)

--- a/include/linux/stacktrace.h
+++ b/include/linux/stacktrace.h
@@ -3,11 +3,26 @@
 #define __LINUX_STACKTRACE_H
 
 #include 
+#include 
 
 struct task_struct;
 struct pt_regs;
 
 #ifdef CONFIG_STACKTRACE
+void stack_trace_print(unsigned long *trace, unsigned int nr_entries,
+  int spaces);
+int stack_trace_snprint(char *buf, size_t size, unsigned long *entries,
+   unsigned int nr_entries, int spaces);
+unsigned int stack_trace_save(unsigned long *store, unsigned int size,
+ unsigned int skipnr);
+unsigned int stack_trace_save_tsk(struct task_struct *task,
+ unsigned long *store, unsigned int size,
+ unsigned int skipnr);
+unsigned int stack_trace_save_regs(struct pt_regs *regs, unsigned long *store,
+  unsigned int size, unsigned int skipnr);
+unsigned int stack_trace_save_user(unsigned long *store, unsigned int size);
+
+/* Internal interfaces. Do not use in generic code */
 struct stack_trace {
unsigned int nr_entries, max_entries;
unsigned long *entries;
@@ -41,4 +56,16 @@ extern void save_stack_trace_user(struct
 # define save_stack_trace_tsk_reliable(tsk, trace) ({ -ENOSYS; })
 #endif /* CONFIG_STACKTRACE */
 
+#if defined(CONFIG_STACKTRACE) && defined(CONFIG_HAVE_RELIABLE_STACKTRACE)
+int stack_trace_save_tsk_reliable(struct task_struct *tsk, unsigned long 
*store,
+ unsigned int size);
+#else
+static inline int stack_trace_save_tsk_reliable(struct task_struct *tsk,
+   unsigned long *store,
+   unsigned int size)
+{
+   return -ENOSYS;
+}
+#endif
+
 #endif /* __LINUX_STACKTRACE_H */
--- a/kernel/stacktrace.c
+++ b/kernel/stacktrace.c
@@ -11,35 +11,54 @@
 #include 
 #include 
 
-void print_stack_trace(struct stack_trace *trace, int spaces)
+/**
+ * stack_trace_print - Print the entries in the stack trace
+ * @entries:   Pointer to storage array
+ * @nr_entries:Number of entries in the storage array
+ * @spaces:Number of leading spaces to print
+ */
+void stack_trace_print(unsigned long *entries, unsigned int nr_entries,
+  int spaces)
 {
-   int i;
+   unsigned int i;
 
-   if (WARN_ON(!trace->entries))
+   if (WARN_ON(!entries))
return;
 
-   for (i = 0; i < trace->nr_entries; i++)
-   printk("%*c%pS\n", 1 + spaces, ' ', (void *)trace->entries[i]);
+   for (i = 0; i < nr_entries; i++)
+   printk("%*c%pS\n", 1 + spaces, ' ', (void *)entries[i]);
+}
+EXPORT_SYMBOL_GPL(stack_trace_print);
+
+void print_stack_trace(struct stack_trace *trace, int spaces)
+{
+   stack_trace_print(trace->entries, trace->nr_entries, spaces);
 }
 EXPORT_SYMBOL_GPL(print_stack_trace);
 
-int snprint_stack_trace(char *buf, size_t size,
-   struct stack_trace *trace, int spaces)
+/**
+ * stack_trace_snprint - Print the entries in the stack trace into a buffer
+ * @buf:   Pointer to the print buffer
+ * @size:  Size of the print buffer
+ * @entries:   Pointer to storage array
+ * @nr_entries:Number of entries in the storage array
+ * @spaces:Number of leading spaces to print
+ *
+ * Return: Number of bytes printed.
+ */
+int stack_trace_snprint(char *buf, size_t size, unsigned long *entries,
+   unsigned int nr_entries, int spaces)
 {
-   int i;
-   int generated;
-   int total = 0;
+   unsigned int generated, i, total = 0;
 
-   if (WARN_ON(!trace->entries))
+   if (WARN_ON(!entries))
return 0;
 
-   for (i = 0; i < trace->nr_entries; i++) {
+   for (i = 0; i < nr_entries && size; i++) {
generated = snprintf(buf, size, "%*c%pS\n", 1 + spaces, ' ',
-(void *)trace->entries[i]);
+(void *)entries[i]);
 
total += generated;
-
-   /* Assume that generated isn't a negative number */
if (generated >= size) {
buf += size;
   

[patch V3 29/29] x86/stacktrace: Use common infrastructure

2019-04-26 Thread Thomas Gleixner
Replace the stack_trace_save*() functions with the new arch_stack_walk()
interfaces.

Signed-off-by: Thomas Gleixner 
Cc: linux-a...@vger.kernel.org
---
 arch/x86/Kconfig |1 
 arch/x86/kernel/stacktrace.c |  116 +++
 2 files changed, 20 insertions(+), 97 deletions(-)

--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -74,6 +74,7 @@ config X86
select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI
select ARCH_MIGHT_HAVE_PC_PARPORT
select ARCH_MIGHT_HAVE_PC_SERIO
+   select ARCH_STACKWALK
select ARCH_SUPPORTS_ACPI
select ARCH_SUPPORTS_ATOMIC_RMW
select ARCH_SUPPORTS_NUMA_BALANCING if X86_64
--- a/arch/x86/kernel/stacktrace.c
+++ b/arch/x86/kernel/stacktrace.c
@@ -12,75 +12,31 @@
 #include 
 #include 
 
-static int save_stack_address(struct stack_trace *trace, unsigned long addr,
- bool nosched)
-{
-   if (nosched && in_sched_functions(addr))
-   return 0;
-
-   if (trace->skip > 0) {
-   trace->skip--;
-   return 0;
-   }
-
-   if (trace->nr_entries >= trace->max_entries)
-   return -1;
-
-   trace->entries[trace->nr_entries++] = addr;
-   return 0;
-}
-
-static void noinline __save_stack_trace(struct stack_trace *trace,
-  struct task_struct *task, struct pt_regs *regs,
-  bool nosched)
+void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie,
+struct task_struct *task, struct pt_regs *regs)
 {
struct unwind_state state;
unsigned long addr;
 
-   if (regs)
-   save_stack_address(trace, regs->ip, nosched);
+   if (regs && !consume_entry(cookie, regs->ip, false))
+   return;
 
for (unwind_start(&state, task, regs, NULL); !unwind_done(&state);
 unwind_next_frame(&state)) {
addr = unwind_get_return_address(&state);
-   if (!addr || save_stack_address(trace, addr, nosched))
+   if (!addr || !consume_entry(cookie, addr, false))
break;
}
 }
 
 /*
- * Save stack-backtrace addresses into a stack_trace buffer.
+ * This function returns an error if it detects any unreliable features of the
+ * stack.  Otherwise it guarantees that the stack trace is reliable.
+ *
+ * If the task is not 'current', the caller *must* ensure the task is inactive.
  */
-void save_stack_trace(struct stack_trace *trace)
-{
-   trace->skip++;
-   __save_stack_trace(trace, current, NULL, false);
-}
-EXPORT_SYMBOL_GPL(save_stack_trace);
-
-void save_stack_trace_regs(struct pt_regs *regs, struct stack_trace *trace)
-{
-   __save_stack_trace(trace, current, regs, false);
-}
-
-void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
-{
-   if (!try_get_task_stack(tsk))
-   return;
-
-   if (tsk == current)
-   trace->skip++;
-   __save_stack_trace(trace, tsk, NULL, true);
-
-   put_task_stack(tsk);
-}
-EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
-
-#ifdef CONFIG_HAVE_RELIABLE_STACKTRACE
-
-static int __always_inline
-__save_stack_trace_reliable(struct stack_trace *trace,
-   struct task_struct *task)
+int arch_stack_walk_reliable(stack_trace_consume_fn consume_entry,
+void *cookie, struct task_struct *task)
 {
struct unwind_state state;
struct pt_regs *regs;
@@ -117,7 +73,7 @@ static int __always_inline
if (!addr)
return -EINVAL;
 
-   if (save_stack_address(trace, addr, false))
+   if (!consume_entry(cookie, addr, false))
return -EINVAL;
}
 
@@ -132,32 +88,6 @@ static int __always_inline
return 0;
 }
 
-/*
- * This function returns an error if it detects any unreliable features of the
- * stack.  Otherwise it guarantees that the stack trace is reliable.
- *
- * If the task is not 'current', the caller *must* ensure the task is inactive.
- */
-int save_stack_trace_tsk_reliable(struct task_struct *tsk,
- struct stack_trace *trace)
-{
-   int ret;
-
-   /*
-* If the task doesn't have a stack (e.g., a zombie), the stack is
-* "reliably" empty.
-*/
-   if (!try_get_task_stack(tsk))
-   return 0;
-
-   ret = __save_stack_trace_reliable(trace, tsk);
-
-   put_task_stack(tsk);
-
-   return ret;
-}
-#endif /* CONFIG_HAVE_RELIABLE_STACKTRACE */
-
 /* Userspace stacktrace - based on kernel/trace/trace_sysprof.c */
 
 struct stack_frame_user {
@@ -182,15 +112,15 @@ copy_stack_frame(const void __user *fp,
return ret;
 }
 
-static inline void __save_stack_trace_user(struct stack_trace *trace)
+void arch_stack_walk_user(stack_trace_consume_fn consume_entry, void *cookie,
+ c

[patch V3 25/29] livepatch: Simplify stack trace retrieval

2019-04-26 Thread Thomas Gleixner
Replace the indirection through struct stack_trace by using the storage
array based interfaces.

Signed-off-by: Thomas Gleixner 
Acked-by: Miroslav Benes 
---
 kernel/livepatch/transition.c |   22 +-
 1 file changed, 9 insertions(+), 13 deletions(-)

--- a/kernel/livepatch/transition.c
+++ b/kernel/livepatch/transition.c
@@ -202,15 +202,15 @@ void klp_update_patch_state(struct task_
  * Determine whether the given stack trace includes any references to a
  * to-be-patched or to-be-unpatched function.
  */
-static int klp_check_stack_func(struct klp_func *func,
-   struct stack_trace *trace)
+static int klp_check_stack_func(struct klp_func *func, unsigned long *entries,
+   unsigned int nr_entries)
 {
unsigned long func_addr, func_size, address;
struct klp_ops *ops;
int i;
 
-   for (i = 0; i < trace->nr_entries; i++) {
-   address = trace->entries[i];
+   for (i = 0; i < nr_entries; i++) {
+   address = entries[i];
 
if (klp_target_state == KLP_UNPATCHED) {
 /*
@@ -254,29 +254,25 @@ static int klp_check_stack_func(struct k
 static int klp_check_stack(struct task_struct *task, char *err_buf)
 {
static unsigned long entries[MAX_STACK_ENTRIES];
-   struct stack_trace trace;
struct klp_object *obj;
struct klp_func *func;
-   int ret;
+   int ret, nr_entries;
 
-   trace.skip = 0;
-   trace.nr_entries = 0;
-   trace.max_entries = MAX_STACK_ENTRIES;
-   trace.entries = entries;
-   ret = save_stack_trace_tsk_reliable(task, &trace);
+   ret = stack_trace_save_tsk_reliable(task, entries, ARRAY_SIZE(entries));
WARN_ON_ONCE(ret == -ENOSYS);
-   if (ret) {
+   if (ret < 0) {
snprintf(err_buf, STACK_ERR_BUF_SIZE,
 "%s: %s:%d has an unreliable stack\n",
 __func__, task->comm, task->pid);
return ret;
}
+   nr_entries = ret;
 
klp_for_each_object(klp_transition_patch, obj) {
if (!obj->patched)
continue;
klp_for_each_func(obj, func) {
-   ret = klp_check_stack_func(func, &trace);
+   ret = klp_check_stack_func(func, entries, nr_entries);
if (ret) {
snprintf(err_buf, STACK_ERR_BUF_SIZE,
 "%s: %s:%d is sleeping on function 
%s\n",


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 00/29] stacktrace: Consolidate stack trace usage

2019-04-26 Thread Thomas Gleixner
This is an update to V2 which can be found here:

  https://lkml.kernel.org/r/20190418084119.056416...@linutronix.de

Changes vs. V2:

  - Fixed the kernel-doc issue pointed out by Mike

  - Removed the '-1' oddity from the tracer

  - Restricted the tracer nesting to 4

  - Restored the lockdep magic to prevent redundant stack traces

  - Addressed the small nitpicks here and there

  - Picked up Acked/Reviewed tags

The series is based on:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core/stacktrace

which contains the removal of the inconsistent and pointless ULONG_MAX
termination of stacktraces.

It's also available from git:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git WIP.core/stacktrace

   up to 5160eb663575 ("x86/stacktrace: Use common infrastructure")

Delta patch vs. v2 below.

Thanks,

tglx

8<-
diff --git a/include/linux/stacktrace.h b/include/linux/stacktrace.h
index 654949dc1c16..f0cfd12cb45e 100644
--- a/include/linux/stacktrace.h
+++ b/include/linux/stacktrace.h
@@ -32,14 +32,13 @@ unsigned int stack_trace_save_user(unsigned long *store, 
unsigned int size);
  * @reliable:  True when the stack entry is reliable. Required by
  * some printk based consumers.
  *
- * Returns:True, if the entry was consumed or skipped
+ * Return: True, if the entry was consumed or skipped
  * False, if there is no space left to store
  */
 typedef bool (*stack_trace_consume_fn)(void *cookie, unsigned long addr,
   bool reliable);
 /**
  * arch_stack_walk - Architecture specific function to walk the stack
-
  * @consume_entry: Callback which is invoked by the architecture code for
  * each entry.
  * @cookie:Caller supplied pointer which is handed back to
@@ -47,10 +46,12 @@ typedef bool (*stack_trace_consume_fn)(void *cookie, 
unsigned long addr,
  * @task:  Pointer to a task struct, can be NULL
  * @regs:  Pointer to registers, can be NULL
  *
- * @task   @regs:
- * NULLNULLStack trace from current
+ *  === 
+ * taskregs
+ *  === 
  * taskNULLStack trace from task (can be current)
- * NULLregsStack trace starting on regs->stackpointer
+ * current regsStack trace starting on regs->stackpointer
+ *  === 
  */
 void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie,
 struct task_struct *task, struct pt_regs *regs);
diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c
index 1e8e246edaad..badd77670d00 100644
--- a/kernel/dma/debug.c
+++ b/kernel/dma/debug.c
@@ -705,7 +705,8 @@ static struct dma_debug_entry *dma_entry_alloc(void)
 
 #ifdef CONFIG_STACKTRACE
entry->stack_len = stack_trace_save(entry->stack_entries,
-   ARRAY_SIZE(entry->stack_entries), 
1);
+   ARRAY_SIZE(entry->stack_entries),
+   1);
 #endif
return entry;
 }
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 84423f0bb0b0..45bcaf2e4cb6 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -2160,12 +2160,11 @@ check_deadlock(struct task_struct *curr, struct 
held_lock *next,
  */
 static int
 check_prev_add(struct task_struct *curr, struct held_lock *prev,
-  struct held_lock *next, int distance)
+  struct held_lock *next, int distance, struct lock_trace *trace)
 {
struct lock_list *uninitialized_var(target_entry);
struct lock_list *entry;
struct lock_list this;
-   struct lock_trace trace;
int ret;
 
if (!hlock_class(prev)->key || !hlock_class(next)->key) {
@@ -2198,8 +2197,17 @@ check_prev_add(struct task_struct *curr, struct 
held_lock *prev,
this.class = hlock_class(next);
this.parent = NULL;
ret = check_noncircular(&this, hlock_class(prev), &target_entry);
-   if (unlikely(!ret))
+   if (unlikely(!ret)) {
+   if (!trace->nr_entries) {
+   /*
+* If save_trace fails here, the printing might
+* trigger a WARN but because of the !nr_entries it
+* should not do bad things.
+*/
+   save_trace(trace);
+   }
return print_circular_bug(&this, target_entry, next, prev);
+   }
else if (unlikely(ret < 0))
return print_bfs_bug(ret);
 
@@ -2246,7 +2254,7 @@ check_prev_add(struct task_struct *curr, struct held_lock 
*prev,
return print_bfs_bug(ret);
 
 
-   if (!save_trace(&trace))
+   if (

[patch V3 26/29] stacktrace: Remove obsolete functions

2019-04-26 Thread Thomas Gleixner
No more users of the struct stack_trace based interfaces. Remove them.

Remove the macro stubs for !CONFIG_STACKTRACE as well as they are pointless
because the storage on the call sites is conditional on CONFIG_STACKTRACE
already. No point to be 'smart'.

Signed-off-by: Thomas Gleixner 
---
 include/linux/stacktrace.h |   17 -
 kernel/stacktrace.c|   14 --
 2 files changed, 31 deletions(-)

--- a/include/linux/stacktrace.h
+++ b/include/linux/stacktrace.h
@@ -36,24 +36,7 @@ extern void save_stack_trace_tsk(struct
struct stack_trace *trace);
 extern int save_stack_trace_tsk_reliable(struct task_struct *tsk,
 struct stack_trace *trace);
-
-extern void print_stack_trace(struct stack_trace *trace, int spaces);
-extern int snprint_stack_trace(char *buf, size_t size,
-   struct stack_trace *trace, int spaces);
-
-#ifdef CONFIG_USER_STACKTRACE_SUPPORT
 extern void save_stack_trace_user(struct stack_trace *trace);
-#else
-# define save_stack_trace_user(trace)  do { } while (0)
-#endif
-
-#else /* !CONFIG_STACKTRACE */
-# define save_stack_trace(trace)   do { } while (0)
-# define save_stack_trace_tsk(tsk, trace)  do { } while (0)
-# define save_stack_trace_user(trace)  do { } while (0)
-# define print_stack_trace(trace, spaces)  do { } while (0)
-# define snprint_stack_trace(buf, size, trace, spaces) do { } while (0)
-# define save_stack_trace_tsk_reliable(tsk, trace) ({ -ENOSYS; })
 #endif /* CONFIG_STACKTRACE */
 
 #if defined(CONFIG_STACKTRACE) && defined(CONFIG_HAVE_RELIABLE_STACKTRACE)
--- a/kernel/stacktrace.c
+++ b/kernel/stacktrace.c
@@ -30,12 +30,6 @@ void stack_trace_print(unsigned long *en
 }
 EXPORT_SYMBOL_GPL(stack_trace_print);
 
-void print_stack_trace(struct stack_trace *trace, int spaces)
-{
-   stack_trace_print(trace->entries, trace->nr_entries, spaces);
-}
-EXPORT_SYMBOL_GPL(print_stack_trace);
-
 /**
  * stack_trace_snprint - Print the entries in the stack trace into a buffer
  * @buf:   Pointer to the print buffer
@@ -72,14 +66,6 @@ int stack_trace_snprint(char *buf, size_
 }
 EXPORT_SYMBOL_GPL(stack_trace_snprint);
 
-int snprint_stack_trace(char *buf, size_t size,
-   struct stack_trace *trace, int spaces)
-{
-   return stack_trace_snprint(buf, size, trace->entries,
-  trace->nr_entries, spaces);
-}
-EXPORT_SYMBOL_GPL(snprint_stack_trace);
-
 /*
  * Architectures that do not implement save_stack_trace_*()
  * get these weak aliases and once-per-bootup warnings


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH] drm/komeda: Use memset to initialize config_id

2019-04-26 Thread Nick Desaulniers
On Wed, Apr 24, 2019 at 11:27 PM Nathan Chancellor
 wrote:
>
> Clang warns:
>
> drivers/gpu/drm/arm/display/komeda/komeda_dev.c:76:38: warning: suggest
> braces around initialization of subobject [-Wmissing-braces]
> union komeda_config_id config_id = {0,};
> ^
> {}
> 1 warning generated.
>
> One way to fix these warnings is to add additional braces like Clang
> suggests; however, there has been a bit of push back from some
> maintainers, who just prefer memset as it is unambiguous, doesn't
> depend on a particular compiler version, and properly initializes all
> subobjects [1][2]. Do that here so there are no more warnings.
>
> [1]: 
> https://lore.kernel.org/lkml/022e41c0-8465-dc7a-a45c-64187ecd9...@amd.com/
> [2]: 
> https://lore.kernel.org/lkml/20181128.215241.702406654469517539.da...@davemloft.net/
>
> Fixes: 4cc734cb79a8 ("drm/komeda: Add sysfs attribute: core_id and config_id")
> Link: https://github.com/ClangBuiltLinux/linux/issues/457
> Signed-off-by: Nathan Chancellor 
> ---
>  drivers/gpu/drm/arm/display/komeda/komeda_dev.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c 
> b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> index 9d6c31cca875..e605a518f59a 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> @@ -73,9 +73,10 @@ config_id_show(struct device *dev, struct device_attribute 
> *attr, char *buf)
>  {
> struct komeda_dev *mdev = dev_to_mdev(dev);
> struct komeda_pipeline *pipe = mdev->pipelines[0];
> -   union komeda_config_id config_id = {0,};

Haven't seen a trailing comma too often.  Thanks for the patch.
Reviewed-by: Nick Desaulniers 

> +   union komeda_config_id config_id;
> int i;
>
> +   memset(&config_id, 0, sizeof(config_id));
> config_id.max_line_sz = pipe->layers[0]->hsize_in.end;
> config_id.n_pipelines = mdev->n_pipelines;
> config_id.n_scalers = pipe->n_scalers;
> --
> 2.21.0
>


-- 
Thanks,
~Nick Desaulniers
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH v3 12/26] compat_ioctl: move more drivers to compat_ptr_ioctl

2019-04-26 Thread Al Viro
On Thu, Apr 25, 2019 at 12:21:53PM -0300, Mauro Carvalho Chehab wrote:

> If I understand your patch description well, using compat_ptr_ioctl
> only works if the driver is not for s390, right?

No; s390 is where "oh, just set ->compat_ioctl same as ->unlocked_ioctl
and be done with that; compat_ptr() is a no-op anyway" breaks.  IOW,
s390 is the reason for having compat_ptr_ioctl() in the first place;
that thing works on all biarch architectures, as long as all stuff
handled by ->ioctl() takes pointer to arch-independent object as
argument.  IOW,
argument ignored => OK
any arithmetical type => no go, compat_ptr() would bugger it
pointer to int => OK
pointer to string => OK
pointer to u64 => OK
pointer to struct {u64 addr; char s[11];} => OK
pointer to long => needs explicit handler
pointer to struct {void *addr; char s[11];} => needs explicit handler
pointer to struct {int x; u64 y;} => needs explicit handler on amd64
For "just use ->unlocked_ioctl for ->ioctl" we have
argument ignored => OK
any arithmetical type => OK
any pointer => instant breakage on s390, in addtion to cases that break
with compat_ptr_ioctl().

Probably some form of that ought to go into commit message for 
compat_ptr_ioctl()
introduction...
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v3 2/6] drm: atmel-hlcdc: avoid initializing cfg with zero

2019-04-26 Thread Claudiu.Beznea
From: Claudiu Beznea 

Remove cfg initialization with zero and read state with
drm_crtc_state_to_atmel_hlcdc_crtc_state() so that cfg to be initialized
with state's output_mode.

Signed-off-by: Claudiu Beznea 
Reviewed-by: Sam Ravnborg 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index 957e6d2fb00f..81c50772df05 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -138,7 +138,8 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc 
*c)
 
regmap_update_bits(regmap, ATMEL_HLCDC_CFG(0), mask, cfg);
 
-   cfg = 0;
+   state = drm_crtc_state_to_atmel_hlcdc_crtc_state(c->state);
+   cfg = state->output_mode << 8;
 
if (adj->flags & DRM_MODE_FLAG_NVSYNC)
cfg |= ATMEL_HLCDC_VSPOL;
@@ -146,9 +147,6 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc 
*c)
if (adj->flags & DRM_MODE_FLAG_NHSYNC)
cfg |= ATMEL_HLCDC_HSPOL;
 
-   state = drm_crtc_state_to_atmel_hlcdc_crtc_state(c->state);
-   cfg |= state->output_mode << 8;
-
regmap_update_bits(regmap, ATMEL_HLCDC_CFG(5),
   ATMEL_HLCDC_HSPOL | ATMEL_HLCDC_VSPOL |
   ATMEL_HLCDC_VSPDLYS | ATMEL_HLCDC_VSPDLYE |
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH v2] drm: prefix header search paths with $(srctree)/

2019-04-26 Thread Masahiro Yamada
Hi.


On Fri, Mar 29, 2019 at 8:37 PM Masahiro Yamada
 wrote:
>
> Currently, the Kbuild core manipulates header search paths in a crazy
> way [1].
>
> To fix this mess, I want all Makefiles to add explicit $(srctree)/ to
> the search paths in the srctree. Some Makefiles are already written in
> that way, but not all. The goal of this work is to make the notation
> consistent, and finally get rid of the gross hacks.
>
> Having whitespaces after -I does not matter since commit 48f6e3cf5bc6
> ("kbuild: do not drop -I without parameter").
>
> [1]: https://patchwork.kernel.org/patch/9632347/
>
> Signed-off-by: Masahiro Yamada 
> Reviewed-by: Sam Ravnborg 
> ---
>
> I put all gpu/drm changes into a single patch because
> they are trivial conversion.
>
> If you are interested in the big picture of this work,
> the full patch set is available at the following URL.
>
> git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git 
> build-test


Is somebody taking care of this?



>
> Changes in v2:
>   - fix up the new driver komeda
>   - Add Sam's Reviewed-by
>
>  drivers/gpu/drm/amd/amdgpu/Makefile | 2 +-
>  drivers/gpu/drm/amd/lib/Makefile| 2 +-
>  drivers/gpu/drm/arm/display/komeda/Makefile | 4 ++--
>  drivers/gpu/drm/i915/gvt/Makefile   | 2 +-
>  drivers/gpu/drm/msm/Makefile| 6 +++---
>  drivers/gpu/drm/nouveau/Kbuild  | 8 
>  6 files changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
> b/drivers/gpu/drm/amd/amdgpu/Makefile
> index 466da59..62bf9da 100644
> --- a/drivers/gpu/drm/amd/amdgpu/Makefile
> +++ b/drivers/gpu/drm/amd/amdgpu/Makefile
> @@ -23,7 +23,7 @@
>  # Makefile for the drm device driver.  This driver provides support for the
>  # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
>
> -FULL_AMD_PATH=$(src)/..
> +FULL_AMD_PATH=$(srctree)/$(src)/..
>  DISPLAY_FOLDER_NAME=display
>  FULL_AMD_DISPLAY_PATH = $(FULL_AMD_PATH)/$(DISPLAY_FOLDER_NAME)
>
> diff --git a/drivers/gpu/drm/amd/lib/Makefile 
> b/drivers/gpu/drm/amd/lib/Makefile
> index 6902430..d534992 100644
> --- a/drivers/gpu/drm/amd/lib/Makefile
> +++ b/drivers/gpu/drm/amd/lib/Makefile
> @@ -27,6 +27,6 @@
>  # driver components or later moved to kernel/lib for sharing with
>  # other drivers.
>
> -ccflags-y := -I$(src)/../include
> +ccflags-y := -I $(srctree)/$(src)/../include
>
>  obj-$(CONFIG_CHASH) += chash.o
> diff --git a/drivers/gpu/drm/arm/display/komeda/Makefile 
> b/drivers/gpu/drm/arm/display/komeda/Makefile
> index 1b875e5..a72e30c 100644
> --- a/drivers/gpu/drm/arm/display/komeda/Makefile
> +++ b/drivers/gpu/drm/arm/display/komeda/Makefile
> @@ -1,8 +1,8 @@
>  # SPDX-License-Identifier: GPL-2.0
>
>  ccflags-y := \
> -   -I$(src)/../include \
> -   -I$(src)
> +   -I $(srctree)/$(src)/../include \
> +   -I $(srctree)/$(src)
>
>  komeda-y := \
> komeda_drv.o \
> diff --git a/drivers/gpu/drm/i915/gvt/Makefile 
> b/drivers/gpu/drm/i915/gvt/Makefile
> index 271fb46..ea8324a 100644
> --- a/drivers/gpu/drm/i915/gvt/Makefile
> +++ b/drivers/gpu/drm/i915/gvt/Makefile
> @@ -5,5 +5,5 @@ GVT_SOURCE := gvt.o aperture_gm.o handlers.o vgpu.o 
> trace_points.o firmware.o \
> execlist.o scheduler.o sched_policy.o mmio_context.o cmd_parser.o 
> debugfs.o \
> fb_decoder.o dmabuf.o page_track.o
>
> -ccflags-y  += -I$(src) -I$(src)/$(GVT_DIR)
> +ccflags-y  += -I $(srctree)/$(src) -I 
> $(srctree)/$(src)/$(GVT_DIR)/
>  i915-y += $(addprefix $(GVT_DIR)/, 
> $(GVT_SOURCE))
> diff --git a/drivers/gpu/drm/msm/Makefile b/drivers/gpu/drm/msm/Makefile
> index 56a70c7..b7b1ebd 100644
> --- a/drivers/gpu/drm/msm/Makefile
> +++ b/drivers/gpu/drm/msm/Makefile
> @@ -1,7 +1,7 @@
>  # SPDX-License-Identifier: GPL-2.0
> -ccflags-y := -Idrivers/gpu/drm/msm
> -ccflags-y += -Idrivers/gpu/drm/msm/disp/dpu1
> -ccflags-$(CONFIG_DRM_MSM_DSI) += -Idrivers/gpu/drm/msm/dsi
> +ccflags-y := -I $(srctree)/$(src)
> +ccflags-y += -I $(srctree)/$(src)/disp/dpu1
> +ccflags-$(CONFIG_DRM_MSM_DSI) += -I $(srctree)/$(src)/dsi
>
>  msm-y := \
> adreno/adreno_device.o \
> diff --git a/drivers/gpu/drm/nouveau/Kbuild b/drivers/gpu/drm/nouveau/Kbuild
> index ea3035e..4fae728 100644
> --- a/drivers/gpu/drm/nouveau/Kbuild
> +++ b/drivers/gpu/drm/nouveau/Kbuild
> @@ -1,7 +1,7 @@
> -ccflags-y += -I$(src)/include
> -ccflags-y += -I$(src)/include/nvkm
> -ccflags-y += -I$(src)/nvkm
> -ccflags-y += -I$(src)
> +ccflags-y += -I $(srctree)/$(src)/include
> +ccflags-y += -I $(srctree)/$(src)/include/nvkm
> +ccflags-y += -I $(srctree)/$(src)/nvkm
> +ccflags-y += -I $(srctree)/$(src)
>
>  # NVKM - HW resource manager
>  #- code also used by various userspace tools/tests
> --
> 2.7.4
>


-- 
Best Regards
Masahiro Yamada
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.free

[patch V3 06/29] latency_top: Simplify stack trace handling

2019-04-26 Thread Thomas Gleixner
Replace the indirection through struct stack_trace with an invocation of
the storage array based interface.

Signed-off-by: Thomas Gleixner 
---
 kernel/latencytop.c |   17 ++---
 1 file changed, 2 insertions(+), 15 deletions(-)

--- a/kernel/latencytop.c
+++ b/kernel/latencytop.c
@@ -141,20 +141,6 @@ account_global_scheduler_latency(struct
memcpy(&latency_record[i], lat, sizeof(struct latency_record));
 }
 
-/*
- * Iterator to store a backtrace into a latency record entry
- */
-static inline void store_stacktrace(struct task_struct *tsk,
-   struct latency_record *lat)
-{
-   struct stack_trace trace;
-
-   memset(&trace, 0, sizeof(trace));
-   trace.max_entries = LT_BACKTRACEDEPTH;
-   trace.entries = &lat->backtrace[0];
-   save_stack_trace_tsk(tsk, &trace);
-}
-
 /**
  * __account_scheduler_latency - record an occurred latency
  * @tsk - the task struct of the task hitting the latency
@@ -191,7 +177,8 @@ void __sched
lat.count = 1;
lat.time = usecs;
lat.max = usecs;
-   store_stacktrace(tsk, &lat);
+
+   stack_trace_save_tsk(tsk, lat.backtrace, LT_BACKTRACEDEPTH, 0);
 
raw_spin_lock_irqsave(&latency_lock, flags);
 


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v3 0/6] add LCD support for SAM9X60

2019-04-26 Thread Claudiu.Beznea
From: Claudiu Beznea 

Hi,

These patches adds support for SAM9X60's LCD controller.

First patches add option to specify if controller clock source is fixed.
Second patch avoid a variable initialization in 
atmel_hlcdc_crtc_mode_set_nofb().
The 3rd add compatibles in pwm-atmel-hlcdc driver.
The 4th patch enables sys_clk in probe since SAM9X60 needs this.
Specific support was added also in suspend/resume hooks.
The 5th patch adds SAM9X60's LCD configuration and enabled it.

I took the changes of this series and introduced also a fix
(this is the 6th patch in this series) - if you want to send it separately
I would gladly do it.

Thank you,
Claudiu Beznea

Changes in v3:
- keep compatible string on patch 3/6 on a single line (I keep here a tab
  in front of ".compatible" to be aligned with the rest of the code in
  atmel_hlcdc_dt_ids[])
- patches 4/7 and 3/7 from v2 were applied so remove them from this version
- add a fix for atmel_hlcdc (patch 6/6)

Changes in v2:
- use "|" operator in patch 1/7 to set ATMEL_HLCDC_CLKSEL on cfg
- collect Acked-by, Reviewed-by tags

Claudiu Beznea (4):
  drm: atmel-hlcdc: add config option for clock selection
  drm: atmel-hlcdc: avoid initializing cfg with zero
  pwm: atmel-hlcdc: add compatible for SAM9X60 HLCDC's PWM
  drm/atmel-hclcdc: revert shift by 8

Sandeep Sheriker Mallikarjun (2):
  drm: atmel-hlcdc: enable sys_clk during initalization.
  drm: atmel-hlcdc: add sam9x60 LCD controller

 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c  |  18 ++--
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c| 120 +++-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h|   2 +
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c |   2 +-
 drivers/pwm/pwm-atmel-hlcdc.c   |   1 +
 5 files changed, 132 insertions(+), 11 deletions(-)

-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v4 2/2] DRM: Add KMS driver for the Ingenic JZ47xx SoCs

2019-04-26 Thread Paul Cercueil
Add a KMS driver for the Ingenic JZ47xx family of SoCs.
This driver is meant to replace the aging jz4740-fb driver.

This driver does not make use of the simple pipe helper, for the reason
that it will soon be updated to support more advanced features like
multiple planes, IPU integration for colorspace conversion and up/down
scaling, support for DSI displays, and TV-out and HDMI outputs.

Signed-off-by: Paul Cercueil 
Tested-by: Artur Rojek 
---

Notes:
v2: - Remove custom handling of panel. The panel is now discovered using
  the standard API.
- Lots of small tweaks suggested by upstream

v3: - Use devm_drm_dev_init()
- Update compatible strings to -lcd instead of -drm
- Add destroy() callbacks to plane and crtc
- The ingenic,lcd-mode is now read from the bridge's DT node

v4: Remove ingenic,lcd-mode property completely. The various modes are now
deduced from the connector type, the pixel format or the bus flags.

 drivers/gpu/drm/Kconfig   |   2 +
 drivers/gpu/drm/Makefile  |   1 +
 drivers/gpu/drm/ingenic/Kconfig   |  16 +
 drivers/gpu/drm/ingenic/Makefile  |   1 +
 drivers/gpu/drm/ingenic/ingenic-drm.c | 835 ++
 5 files changed, 855 insertions(+)
 create mode 100644 drivers/gpu/drm/ingenic/Kconfig
 create mode 100644 drivers/gpu/drm/ingenic/Makefile
 create mode 100644 drivers/gpu/drm/ingenic/ingenic-drm.c

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 39d5f7562f1c..6863223c61d5 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -307,6 +307,8 @@ source "drivers/gpu/drm/sti/Kconfig"
 
 source "drivers/gpu/drm/imx/Kconfig"
 
+source "drivers/gpu/drm/ingenic/Kconfig"
+
 source "drivers/gpu/drm/v3d/Kconfig"
 
 source "drivers/gpu/drm/vc4/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 3d0c75cd687c..1c2aca7965bd 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -95,6 +95,7 @@ obj-$(CONFIG_DRM_TEGRA) += tegra/
 obj-$(CONFIG_DRM_STM) += stm/
 obj-$(CONFIG_DRM_STI) += sti/
 obj-$(CONFIG_DRM_IMX) += imx/
+obj-$(CONFIG_DRM_INGENIC) += ingenic/
 obj-$(CONFIG_DRM_MEDIATEK) += mediatek/
 obj-$(CONFIG_DRM_MESON)+= meson/
 obj-y  += i2c/
diff --git a/drivers/gpu/drm/ingenic/Kconfig b/drivers/gpu/drm/ingenic/Kconfig
new file mode 100644
index ..d82c3d37ec9c
--- /dev/null
+++ b/drivers/gpu/drm/ingenic/Kconfig
@@ -0,0 +1,16 @@
+config DRM_INGENIC
+   tristate "DRM Support for Ingenic SoCs"
+   depends on MIPS || COMPILE_TEST
+   depends on DRM
+   depends on CMA
+   depends on OF
+   select DRM_BRIDGE
+   select DRM_PANEL_BRIDGE
+   select DRM_KMS_HELPER
+   select DRM_KMS_CMA_HELPER
+   select DRM_GEM_CMA_HELPER
+   select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
+   help
+ Choose this option for DRM support for the Ingenic SoCs.
+
+ If M is selected the module will be called ingenic-drm.
diff --git a/drivers/gpu/drm/ingenic/Makefile b/drivers/gpu/drm/ingenic/Makefile
new file mode 100644
index ..11cac42ce0bb
--- /dev/null
+++ b/drivers/gpu/drm/ingenic/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_DRM_INGENIC) += ingenic-drm.o
diff --git a/drivers/gpu/drm/ingenic/ingenic-drm.c 
b/drivers/gpu/drm/ingenic/ingenic-drm.c
new file mode 100644
index ..b000a910d480
--- /dev/null
+++ b/drivers/gpu/drm/ingenic/ingenic-drm.c
@@ -0,0 +1,835 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// Ingenic JZ47xx KMS driver
+//
+// Copyright (C) 2019, Paul Cercueil 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define JZ_REG_LCD_CFG 0x00
+#define JZ_REG_LCD_VSYNC   0x04
+#define JZ_REG_LCD_HSYNC   0x08
+#define JZ_REG_LCD_VAT 0x0C
+#define JZ_REG_LCD_DAH 0x10
+#define JZ_REG_LCD_DAV 0x14
+#define JZ_REG_LCD_PS  0x18
+#define JZ_REG_LCD_CLS 0x1C
+#define JZ_REG_LCD_SPL 0x20
+#define JZ_REG_LCD_REV 0x24
+#define JZ_REG_LCD_CTRL0x30
+#define JZ_REG_LCD_STATE   0x34
+#define JZ_REG_LCD_IID 0x38
+#define JZ_REG_LCD_DA0 0x40
+#define JZ_REG_LCD_SA0 0x44
+#define JZ_REG_LCD_FID00x48
+#define JZ_REG_LCD_CMD00x4C
+#define JZ_REG_LCD_DA1 0x50
+#define JZ_REG_LCD_SA1 0x54
+#define JZ_REG_LCD_FID10x58
+#define JZ_REG_

[patch V3 13/29] btrfs: ref-verify: Simplify stack trace retrieval

2019-04-26 Thread Thomas Gleixner
Replace the indirection through struct stack_trace with an invocation of
the storage array based interface.

Signed-off-by: Thomas Gleixner 
Reviewed-by: Johannes Thumshirn 
Acked-by: David Sterba 
Cc: Chris Mason 
Cc: Josef Bacik 
Cc: linux-bt...@vger.kernel.org
---
 fs/btrfs/ref-verify.c |   15 ++-
 1 file changed, 2 insertions(+), 13 deletions(-)

--- a/fs/btrfs/ref-verify.c
+++ b/fs/btrfs/ref-verify.c
@@ -205,28 +205,17 @@ static struct root_entry *lookup_root_en
 #ifdef CONFIG_STACKTRACE
 static void __save_stack_trace(struct ref_action *ra)
 {
-   struct stack_trace stack_trace;
-
-   stack_trace.max_entries = MAX_TRACE;
-   stack_trace.nr_entries = 0;
-   stack_trace.entries = ra->trace;
-   stack_trace.skip = 2;
-   save_stack_trace(&stack_trace);
-   ra->trace_len = stack_trace.nr_entries;
+   ra->trace_len = stack_trace_save(ra->trace, MAX_TRACE, 2);
 }
 
 static void __print_stack_trace(struct btrfs_fs_info *fs_info,
struct ref_action *ra)
 {
-   struct stack_trace trace;
-
if (ra->trace_len == 0) {
btrfs_err(fs_info, "  ref-verify: no stacktrace");
return;
}
-   trace.nr_entries = ra->trace_len;
-   trace.entries = ra->trace;
-   print_stack_trace(&trace, 2);
+   stack_trace_print(ra->trace, ra->trace_len, 2);
 }
 #else
 static void inline __save_stack_trace(struct ref_action *ra)


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 03/29] lib/stackdepot: Provide functions which operate on plain storage arrays

2019-04-26 Thread Thomas Gleixner
The struct stack_trace indirection in the stack depot functions is a truly
pointless excercise which requires horrible code at the callsites.

Provide interfaces based on plain storage arrays.

Signed-off-by: Thomas Gleixner 
Acked-by: Alexander Potapenko 
---
V3: Fix kernel-doc
---
 include/linux/stackdepot.h |4 ++
 lib/stackdepot.c   |   70 -
 2 files changed, 55 insertions(+), 19 deletions(-)

--- a/include/linux/stackdepot.h
+++ b/include/linux/stackdepot.h
@@ -26,7 +26,11 @@ typedef u32 depot_stack_handle_t;
 struct stack_trace;
 
 depot_stack_handle_t depot_save_stack(struct stack_trace *trace, gfp_t flags);
+depot_stack_handle_t stack_depot_save(unsigned long *entries,
+ unsigned int nr_entries, gfp_t gfp_flags);
 
 void depot_fetch_stack(depot_stack_handle_t handle, struct stack_trace *trace);
+unsigned int stack_depot_fetch(depot_stack_handle_t handle,
+  unsigned long **entries);
 
 #endif
--- a/lib/stackdepot.c
+++ b/lib/stackdepot.c
@@ -194,40 +194,60 @@ static inline struct stack_record *find_
return NULL;
 }
 
-void depot_fetch_stack(depot_stack_handle_t handle, struct stack_trace *trace)
+/**
+ * stack_depot_fetch - Fetch stack entries from a depot
+ *
+ * @handle:Stack depot handle which was returned from
+ * stack_depot_save().
+ * @entries:   Pointer to store the entries address
+ *
+ * Return: The number of trace entries for this depot.
+ */
+unsigned int stack_depot_fetch(depot_stack_handle_t handle,
+  unsigned long **entries)
 {
union handle_parts parts = { .handle = handle };
void *slab = stack_slabs[parts.slabindex];
size_t offset = parts.offset << STACK_ALLOC_ALIGN;
struct stack_record *stack = slab + offset;
 
-   trace->nr_entries = trace->max_entries = stack->size;
-   trace->entries = stack->entries;
-   trace->skip = 0;
+   *entries = stack->entries;
+   return stack->size;
+}
+EXPORT_SYMBOL_GPL(stack_depot_fetch);
+
+void depot_fetch_stack(depot_stack_handle_t handle, struct stack_trace *trace)
+{
+   unsigned int nent = stack_depot_fetch(handle, &trace->entries);
+
+   trace->max_entries = trace->nr_entries = nent;
 }
 EXPORT_SYMBOL_GPL(depot_fetch_stack);
 
 /**
- * depot_save_stack - save stack in a stack depot.
- * @trace - the stacktrace to save.
- * @alloc_flags - flags for allocating additional memory if required.
+ * stack_depot_save - Save a stack trace from an array
+ *
+ * @entries:   Pointer to storage array
+ * @nr_entries:Size of the storage array
+ * @alloc_flags:   Allocation gfp flags
  *
- * Returns the handle of the stack struct stored in depot.
+ * Return: The handle of the stack struct stored in depot
  */
-depot_stack_handle_t depot_save_stack(struct stack_trace *trace,
-   gfp_t alloc_flags)
+depot_stack_handle_t stack_depot_save(unsigned long *entries,
+ unsigned int nr_entries,
+ gfp_t alloc_flags)
 {
-   u32 hash;
-   depot_stack_handle_t retval = 0;
struct stack_record *found = NULL, **bucket;
-   unsigned long flags;
+   depot_stack_handle_t retval = 0;
struct page *page = NULL;
void *prealloc = NULL;
+   unsigned long flags;
+   u32 hash;
 
-   if (unlikely(trace->nr_entries == 0))
+   if (unlikely(nr_entries == 0))
goto fast_exit;
 
-   hash = hash_stack(trace->entries, trace->nr_entries);
+   hash = hash_stack(entries, nr_entries);
bucket = &stack_table[hash & STACK_HASH_MASK];
 
/*
@@ -235,8 +255,8 @@ depot_stack_handle_t depot_save_stack(st
 * The smp_load_acquire() here pairs with smp_store_release() to
 * |bucket| below.
 */
-   found = find_stack(smp_load_acquire(bucket), trace->entries,
-  trace->nr_entries, hash);
+   found = find_stack(smp_load_acquire(bucket), entries,
+  nr_entries, hash);
if (found)
goto exit;
 
@@ -264,10 +284,10 @@ depot_stack_handle_t depot_save_stack(st
 
spin_lock_irqsave(&depot_lock, flags);
 
-   found = find_stack(*bucket, trace->entries, trace->nr_entries, hash);
+   found = find_stack(*bucket, entries, nr_entries, hash);
if (!found) {
struct stack_record *new =
-   depot_alloc_stack(trace->entries, trace->nr_entries,
+   depot_alloc_stack(entries, nr_entries,
  hash, &prealloc, alloc_flags);
if (new) {
new->next = *bucket;
@@ -297,4 +317,16 @@ depot_stack_handle_t depot_save_stack(st
 fast_exit:
return retval;
 }
+EXPORT_SYMBOL_GPL(stack_depot_save);
+
+/**
+ * depot

[PATCH v3 3/3] drm/panel: simple: Add Sharp LS020B1DD01D panel support

2019-04-26 Thread Paul Cercueil
The Sharp LS020B1DD01D is a simple 2.0" 240x160 16-bit TFT panel.

Signed-off-by: Paul Cercueil 
Tested-by: Artur Rojek 
---

Notes:
v2: No change

v3: Add DRM_BUS_FLAG_SHARP_SIGNALS to the bus flags

 drivers/gpu/drm/panel/panel-simple.c | 30 
 1 file changed, 30 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index f5fb9fec88e3..803b91f18248 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -2381,6 +2381,33 @@ static const struct panel_desc sharp_lq150x1lg11 = {
.bus_format = MEDIA_BUS_FMT_RGB565_1X16,
 };
 
+static const struct display_timing sharp_ls020b1dd01d_timing = {
+   .pixelclock = { 200, 420, 500 },
+   .hactive = { 240, 240, 240 },
+   .hfront_porch = { 66, 66, 66 },
+   .hback_porch = { 1, 1, 1 },
+   .hsync_len = { 1, 1, 1 },
+   .vactive = { 160, 160, 160 },
+   .vfront_porch = { 52, 52, 52 },
+   .vback_porch = { 6, 6, 6 },
+   .vsync_len = { 10, 10, 10 },
+   .flags = DISPLAY_FLAGS_HSYNC_HIGH | DISPLAY_FLAGS_VSYNC_LOW,
+};
+
+static const struct panel_desc sharp_ls020b1dd01d = {
+   .timings = &sharp_ls020b1dd01d_timing,
+   .num_timings = 1,
+   .bpc = 6,
+   .size = {
+   .width = 42,
+   .height = 28,
+   },
+   .bus_format = MEDIA_BUS_FMT_RGB565_1X16,
+   .bus_flags = DRM_BUS_FLAG_DE_HIGH
+  | DRM_BUS_FLAG_PIXDATA_NEGEDGE
+  | DRM_BUS_FLAG_SHARP_SIGNALS,
+};
+
 static const struct drm_display_mode shelly_sca07010_bfn_lnn_mode = {
.clock = 33300,
.hdisplay = 800,
@@ -2932,6 +2959,9 @@ static const struct of_device_id platform_of_match[] = {
}, {
.compatible = "sharp,lq150x1lg11",
.data = &sharp_lq150x1lg11,
+   }, {
+   .compatible = "sharp,ls020b1dd01d",
+   .data = &sharp_ls020b1dd01d,
}, {
.compatible = "shelly,sca07010-bfn-lnn",
.data = &shelly_sca07010_bfn_lnn,
-- 
2.21.0.593.g511ec345e18

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RESEND][PATCH v3 5/6] drm: atmel-hlcdc: add sam9x60 LCD controller

2019-04-26 Thread Claudiu.Beznea
From: Sandeep Sheriker Mallikarjun 

Add the LCD controller for SAM9X60.

Signed-off-by: Sandeep Sheriker Mallikarjun 

[claudiu.bez...@microchip.com: add fixed_clksrc option to
 atmel_hlcdc_dc_sam9x60]
Signed-off-by: Claudiu Beznea 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 101 +++
 1 file changed, 101 insertions(+)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 8bf51f853721..fb2e7646daeb 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -364,6 +364,103 @@ static const struct atmel_hlcdc_dc_desc 
atmel_hlcdc_dc_sama5d4 = {
.nlayers = ARRAY_SIZE(atmel_hlcdc_sama5d4_layers),
.layers = atmel_hlcdc_sama5d4_layers,
 };
+
+static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sam9x60_layers[] = {
+   {
+   .name = "base",
+   .formats = &atmel_hlcdc_plane_rgb_formats,
+   .regs_offset = 0x60,
+   .id = 0,
+   .type = ATMEL_HLCDC_BASE_LAYER,
+   .cfgs_offset = 0x2c,
+   .layout = {
+   .xstride = { 2 },
+   .default_color = 3,
+   .general_config = 4,
+   .disc_pos = 5,
+   .disc_size = 6,
+   },
+   .clut_offset = 0x600,
+   },
+   {
+   .name = "overlay1",
+   .formats = &atmel_hlcdc_plane_rgb_formats,
+   .regs_offset = 0x160,
+   .id = 1,
+   .type = ATMEL_HLCDC_OVERLAY_LAYER,
+   .cfgs_offset = 0x2c,
+   .layout = {
+   .pos = 2,
+   .size = 3,
+   .xstride = { 4 },
+   .pstride = { 5 },
+   .default_color = 6,
+   .chroma_key = 7,
+   .chroma_key_mask = 8,
+   .general_config = 9,
+   },
+   .clut_offset = 0xa00,
+   },
+   {
+   .name = "overlay2",
+   .formats = &atmel_hlcdc_plane_rgb_formats,
+   .regs_offset = 0x260,
+   .id = 2,
+   .type = ATMEL_HLCDC_OVERLAY_LAYER,
+   .cfgs_offset = 0x2c,
+   .layout = {
+   .pos = 2,
+   .size = 3,
+   .xstride = { 4 },
+   .pstride = { 5 },
+   .default_color = 6,
+   .chroma_key = 7,
+   .chroma_key_mask = 8,
+   .general_config = 9,
+   },
+   .clut_offset = 0xe00,
+   },
+   {
+   .name = "high-end-overlay",
+   .formats = &atmel_hlcdc_plane_rgb_and_yuv_formats,
+   .regs_offset = 0x360,
+   .id = 3,
+   .type = ATMEL_HLCDC_OVERLAY_LAYER,
+   .cfgs_offset = 0x4c,
+   .layout = {
+   .pos = 2,
+   .size = 3,
+   .memsize = 4,
+   .xstride = { 5, 7 },
+   .pstride = { 6, 8 },
+   .default_color = 9,
+   .chroma_key = 10,
+   .chroma_key_mask = 11,
+   .general_config = 12,
+   .scaler_config = 13,
+   .phicoeffs = {
+   .x = 17,
+   .y = 33,
+   },
+   .csc = 14,
+   },
+   .clut_offset = 0x1200,
+   },
+};
+
+static const struct atmel_hlcdc_dc_desc atmel_hlcdc_dc_sam9x60 = {
+   .min_width = 0,
+   .min_height = 0,
+   .max_width = 2048,
+   .max_height = 2048,
+   .max_spw = 0xff,
+   .max_vpw = 0xff,
+   .max_hpw = 0x3ff,
+   .fixed_clksrc = true,
+   .nlayers = ARRAY_SIZE(atmel_hlcdc_sam9x60_layers),
+   .layers = atmel_hlcdc_sam9x60_layers,
+};
+
 static const struct of_device_id atmel_hlcdc_of_match[] = {
{
.compatible = "atmel,at91sam9n12-hlcdc",
@@ -385,6 +482,10 @@ static const struct of_device_id atmel_hlcdc_of_match[] = {
.compatible = "atmel,sama5d4-hlcdc",
.data = &atmel_hlcdc_dc_sama5d4,
},
+   {
+   .compatible = "microchip,sam9x60-hlcdc",
+   .data = &atmel_hlcdc_dc_sam9x60,
+   },
{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, atmel_hlcdc_of_match);
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH v3 12/26] compat_ioctl: move more drivers to compat_ptr_ioctl

2019-04-26 Thread Al Viro
On Thu, Apr 25, 2019 at 05:55:23PM +0200, Arnd Bergmann wrote:
> On Thu, Apr 25, 2019 at 5:35 PM Al Viro  wrote:
> >
> > On Thu, Apr 25, 2019 at 12:21:53PM -0300, Mauro Carvalho Chehab wrote:
> >
> > > If I understand your patch description well, using compat_ptr_ioctl
> > > only works if the driver is not for s390, right?
> >
> > No; s390 is where "oh, just set ->compat_ioctl same as ->unlocked_ioctl
> > and be done with that; compat_ptr() is a no-op anyway" breaks.  IOW,
> > s390 is the reason for having compat_ptr_ioctl() in the first place;
> > that thing works on all biarch architectures, as long as all stuff
> > handled by ->ioctl() takes pointer to arch-independent object as
> > argument.  IOW,
> > argument ignored => OK
> > any arithmetical type => no go, compat_ptr() would bugger it
> > pointer to int => OK
> > pointer to string => OK
> > pointer to u64 => OK
> > pointer to struct {u64 addr; char s[11];} => OK
> 
> To be extra pedantic, the 'struct {u64 addr; char s[11];} '
> case is also broken on x86, because sizeof (obj) is smaller
> on i386, even though the location of the members are
> the same. i.e. you can copy_from_user() this, but not
> copy_to_user(), which overwrites 4 bytes after the end of
> the 20-byte user structure.

D'oh!  FWIW, it might be worth putting into Documentation/ somewhere;
basically, what is and what isn't biarch-neutral.

Or arch-neutral, for that matter - it's very close.  The only real
exception, IIRC, is an extra twist on m68k, where int behaves
like x86 long long - its alignment is only half its size, so
sizeof(struct {char c; int x;}) is 6, not 8 as everywhere
else.  Irrelevant for biarch, thankfully (until somebody gets insane
enough to implement 64bit coldfire, kernel port for it *and* biarch
support for m68k binaries on that thing, that is)...
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[RESEND][PATCH v3 4/6] drm: atmel-hlcdc: enable sys_clk during initalization.

2019-04-26 Thread Claudiu.Beznea
From: Sandeep Sheriker Mallikarjun 

For SAM9X60 SoC, sys_clk is through lcd_gclk clock source and this
needs to be enabled before enabling lcd_clk.

Signed-off-by: Sandeep Sheriker Mallikarjun 

[claudiu.bez...@microchip.com: add fixed_clksrc checks]
Signed-off-by: Claudiu Beznea 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 0be13eceedba..8bf51f853721 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -625,10 +625,18 @@ static int atmel_hlcdc_dc_load(struct drm_device *dev)
dc->hlcdc = dev_get_drvdata(dev->dev->parent);
dev->dev_private = dc;
 
+   if (dc->desc->fixed_clksrc) {
+   ret = clk_prepare_enable(dc->hlcdc->sys_clk);
+   if (ret) {
+   dev_err(dev->dev, "failed to enable sys_clk\n");
+   goto err_destroy_wq;
+   }
+   }
+
ret = clk_prepare_enable(dc->hlcdc->periph_clk);
if (ret) {
dev_err(dev->dev, "failed to enable periph_clk\n");
-   goto err_destroy_wq;
+   goto err_sys_clk_disable;
}
 
pm_runtime_enable(dev->dev);
@@ -664,6 +672,9 @@ static int atmel_hlcdc_dc_load(struct drm_device *dev)
 err_periph_clk_disable:
pm_runtime_disable(dev->dev);
clk_disable_unprepare(dc->hlcdc->periph_clk);
+err_sys_clk_disable:
+   if (dc->desc->fixed_clksrc)
+   clk_disable_unprepare(dc->hlcdc->sys_clk);
 
 err_destroy_wq:
destroy_workqueue(dc->wq);
@@ -688,6 +699,8 @@ static void atmel_hlcdc_dc_unload(struct drm_device *dev)
 
pm_runtime_disable(dev->dev);
clk_disable_unprepare(dc->hlcdc->periph_clk);
+   if (dc->desc->fixed_clksrc)
+   clk_disable_unprepare(dc->hlcdc->sys_clk);
destroy_workqueue(dc->wq);
 }
 
@@ -805,6 +818,8 @@ static int atmel_hlcdc_dc_drm_suspend(struct device *dev)
regmap_read(regmap, ATMEL_HLCDC_IMR, &dc->suspend.imr);
regmap_write(regmap, ATMEL_HLCDC_IDR, dc->suspend.imr);
clk_disable_unprepare(dc->hlcdc->periph_clk);
+   if (dc->desc->fixed_clksrc)
+   clk_disable_unprepare(dc->hlcdc->sys_clk);
 
return 0;
 }
@@ -814,6 +829,8 @@ static int atmel_hlcdc_dc_drm_resume(struct device *dev)
struct drm_device *drm_dev = dev_get_drvdata(dev);
struct atmel_hlcdc_dc *dc = drm_dev->dev_private;
 
+   if (dc->desc->fixed_clksrc)
+   clk_prepare_enable(dc->hlcdc->sys_clk);
clk_prepare_enable(dc->hlcdc->periph_clk);
regmap_write(dc->hlcdc->regmap, ATMEL_HLCDC_IER, dc->suspend.imr);
 
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

RE: [Intel-gfx] [PATCH v2] drm: prefix header search paths with $(srctree)/

2019-04-26 Thread yamada.masahiro
Hi Dave,

> -Original Message-
> From: Dave Airlie [mailto:airl...@gmail.com]
> Sent: Friday, April 26, 2019 11:19 AM
> To: Yamada, Masahiro/山田 真弘 
> Cc: David Airlie ; Daniel Vetter ;
> dri-devel ; nouveau
> ; Sam Ravnborg ; David
> (ChunMing) Zhou ; amd-gfx mailing list
> ; James (Qian) Wang
> ; Ben Skeggs ;
> linux-arm-msm ; Intel Graphics
> Development ;
> intel-gvt-...@lists.freedesktop.org; Linux Kernel Mailing List
> ; Christian König
> ; Alex Deucher ;
> freedr...@lists.freedesktop.org
> Subject: Re: [Intel-gfx] [PATCH v2] drm: prefix header search paths with
> $(srctree)/
> 
> On Fri, 26 Apr 2019 at 11:46, Masahiro Yamada
>  wrote:
> >
> > Hi.
> >
> >
> > On Fri, Mar 29, 2019 at 8:37 PM Masahiro Yamada
> >  wrote:
> > >
> > > Currently, the Kbuild core manipulates header search paths in a crazy
> > > way [1].
> > >
> > > To fix this mess, I want all Makefiles to add explicit $(srctree)/ to
> > > the search paths in the srctree. Some Makefiles are already written
> in
> > > that way, but not all. The goal of this work is to make the notation
> > > consistent, and finally get rid of the gross hacks.
> > >
> > > Having whitespaces after -I does not matter since commit 48f6e3cf5bc6
> > > ("kbuild: do not drop -I without parameter").
> > >
> > > [1]: https://patchwork.kernel.org/patch/9632347/
> > >
> > > Signed-off-by: Masahiro Yamada 
> > > Reviewed-by: Sam Ravnborg 
> > > ---
> > >
> > > I put all gpu/drm changes into a single patch because
> > > they are trivial conversion.
> > >
> > > If you are interested in the big picture of this work,
> > > the full patch set is available at the following URL.
> > >
> > >
> git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.g
> it build-test
> >
> >
> > Is somebody taking care of this?
> >
> 
> Are you expecting this to be merged in the drm tree? if so please
> indicate that when posting.


Sorry for unclearness.

Could you apply this to your drm tree?

Thanks.




> I'd assumed this would go via kbuild tree.
> 
> If the later,
> Acked-by: Dave Airlie 
> Dave.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 14/29] dm bufio: Simplify stack trace retrieval

2019-04-26 Thread Thomas Gleixner
Replace the indirection through struct stack_trace with an invocation of
the storage array based interface.

Signed-off-by: Thomas Gleixner 
Cc: dm-de...@redhat.com
Cc: Mike Snitzer 
Cc: Alasdair Kergon 
---
 drivers/md/dm-bufio.c |   15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -150,7 +150,7 @@ struct dm_buffer {
void (*end_io)(struct dm_buffer *, blk_status_t);
 #ifdef CONFIG_DM_DEBUG_BLOCK_STACK_TRACING
 #define MAX_STACK 10
-   struct stack_trace stack_trace;
+   unsigned int stack_len;
unsigned long stack_entries[MAX_STACK];
 #endif
 };
@@ -232,11 +232,7 @@ static DEFINE_MUTEX(dm_bufio_clients_loc
 #ifdef CONFIG_DM_DEBUG_BLOCK_STACK_TRACING
 static void buffer_record_stack(struct dm_buffer *b)
 {
-   b->stack_trace.nr_entries = 0;
-   b->stack_trace.max_entries = MAX_STACK;
-   b->stack_trace.entries = b->stack_entries;
-   b->stack_trace.skip = 2;
-   save_stack_trace(&b->stack_trace);
+   b->stack_len = stack_trace_save(b->stack_entries, MAX_STACK, 2);
 }
 #endif
 
@@ -438,7 +434,7 @@ static struct dm_buffer *alloc_buffer(st
adjust_total_allocated(b->data_mode, (long)c->block_size);
 
 #ifdef CONFIG_DM_DEBUG_BLOCK_STACK_TRACING
-   memset(&b->stack_trace, 0, sizeof(b->stack_trace));
+   b->stack_len = 0;
 #endif
return b;
 }
@@ -1520,8 +1516,9 @@ static void drop_buffers(struct dm_bufio
DMERR("leaked buffer %llx, hold count %u, list %d",
  (unsigned long long)b->block, b->hold_count, i);
 #ifdef CONFIG_DM_DEBUG_BLOCK_STACK_TRACING
-   print_stack_trace(&b->stack_trace, 1);
-   b->hold_count = 0; /* mark unclaimed to avoid BUG_ON 
below */
+   stack_trace_print(b->stack_entries, b->stack_len, 1);
+   /* mark unclaimed to avoid BUG_ON below */
+   b->hold_count = 0;
 #endif
}
 


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[patch V3 10/29] mm/page_owner: Simplify stack trace handling

2019-04-26 Thread Thomas Gleixner
Replace the indirection through struct stack_trace by using the storage
array based interfaces.

The original code in all printing functions is really wrong. It allocates a
storage array on stack which is unused because depot_fetch_stack() does not
store anything in it. It overwrites the entries pointer in the stack_trace
struct so it points to the depot storage.

Signed-off-by: Thomas Gleixner 
Cc: linux...@kvack.org
Cc: Mike Rapoport 
Cc: David Rientjes 
Cc: Andrew Morton 
---
 mm/page_owner.c |   79 +++-
 1 file changed, 28 insertions(+), 51 deletions(-)

--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -58,15 +58,10 @@ static bool need_page_owner(void)
 static __always_inline depot_stack_handle_t create_dummy_stack(void)
 {
unsigned long entries[4];
-   struct stack_trace dummy;
+   unsigned int nr_entries;
 
-   dummy.nr_entries = 0;
-   dummy.max_entries = ARRAY_SIZE(entries);
-   dummy.entries = &entries[0];
-   dummy.skip = 0;
-
-   save_stack_trace(&dummy);
-   return depot_save_stack(&dummy, GFP_KERNEL);
+   nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 0);
+   return stack_depot_save(entries, nr_entries, GFP_KERNEL);
 }
 
 static noinline void register_dummy_stack(void)
@@ -120,46 +115,39 @@ void __reset_page_owner(struct page *pag
}
 }
 
-static inline bool check_recursive_alloc(struct stack_trace *trace,
-   unsigned long ip)
+static inline bool check_recursive_alloc(unsigned long *entries,
+unsigned int nr_entries,
+unsigned long ip)
 {
-   int i;
+   unsigned int i;
 
-   if (!trace->nr_entries)
-   return false;
-
-   for (i = 0; i < trace->nr_entries; i++) {
-   if (trace->entries[i] == ip)
+   for (i = 0; i < nr_entries; i++) {
+   if (entries[i] == ip)
return true;
}
-
return false;
 }
 
 static noinline depot_stack_handle_t save_stack(gfp_t flags)
 {
unsigned long entries[PAGE_OWNER_STACK_DEPTH];
-   struct stack_trace trace = {
-   .nr_entries = 0,
-   .entries = entries,
-   .max_entries = PAGE_OWNER_STACK_DEPTH,
-   .skip = 2
-   };
depot_stack_handle_t handle;
+   unsigned int nr_entries;
 
-   save_stack_trace(&trace);
+   nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 2);
 
/*
-* We need to check recursion here because our request to stackdepot
-* could trigger memory allocation to save new entry. New memory
-* allocation would reach here and call depot_save_stack() again
-* if we don't catch it. There is still not enough memory in stackdepot
-* so it would try to allocate memory again and loop forever.
+* We need to check recursion here because our request to
+* stackdepot could trigger memory allocation to save new
+* entry. New memory allocation would reach here and call
+* stack_depot_save_entries() again if we don't catch it. There is
+* still not enough memory in stackdepot so it would try to
+* allocate memory again and loop forever.
 */
-   if (check_recursive_alloc(&trace, _RET_IP_))
+   if (check_recursive_alloc(entries, nr_entries, _RET_IP_))
return dummy_handle;
 
-   handle = depot_save_stack(&trace, flags);
+   handle = stack_depot_save(entries, nr_entries, flags);
if (!handle)
handle = failure_handle;
 
@@ -337,16 +325,10 @@ print_page_owner(char __user *buf, size_
struct page *page, struct page_owner *page_owner,
depot_stack_handle_t handle)
 {
-   int ret;
-   int pageblock_mt, page_mt;
+   int ret, pageblock_mt, page_mt;
+   unsigned long *entries;
+   unsigned int nr_entries;
char *kbuf;
-   unsigned long entries[PAGE_OWNER_STACK_DEPTH];
-   struct stack_trace trace = {
-   .nr_entries = 0,
-   .entries = entries,
-   .max_entries = PAGE_OWNER_STACK_DEPTH,
-   .skip = 0
-   };
 
count = min_t(size_t, count, PAGE_SIZE);
kbuf = kmalloc(count, GFP_KERNEL);
@@ -375,8 +357,8 @@ print_page_owner(char __user *buf, size_
if (ret >= count)
goto err;
 
-   depot_fetch_stack(handle, &trace);
-   ret += snprint_stack_trace(kbuf + ret, count - ret, &trace, 0);
+   nr_entries = stack_depot_fetch(handle, &entries);
+   ret += stack_trace_snprint(kbuf + ret, count - ret, entries, 
nr_entries, 0);
if (ret >= count)
goto err;
 
@@ -407,14 +389,9 @@ void __dump_page_owner(struct page *page
 {
struct page_ext *page_ext = lookup_page_ext(page);
struct page_owner *page_owner;
-   unsigned l

[patch V3 07/29] mm/slub: Simplify stack trace retrieval

2019-04-26 Thread Thomas Gleixner
Replace the indirection through struct stack_trace with an invocation of
the storage array based interface.

Signed-off-by: Thomas Gleixner 
Acked-by: Christoph Lameter 
Cc: Andrew Morton 
Cc: Pekka Enberg 
Cc: linux...@kvack.org
Cc: David Rientjes 
---
 mm/slub.c |   12 
 1 file changed, 4 insertions(+), 8 deletions(-)

--- a/mm/slub.c
+++ b/mm/slub.c
@@ -552,18 +552,14 @@ static void set_track(struct kmem_cache
 
if (addr) {
 #ifdef CONFIG_STACKTRACE
-   struct stack_trace trace;
+   unsigned int nr_entries;
 
-   trace.nr_entries = 0;
-   trace.max_entries = TRACK_ADDRS_COUNT;
-   trace.entries = p->addrs;
-   trace.skip = 3;
metadata_access_enable();
-   save_stack_trace(&trace);
+   nr_entries = stack_trace_save(p->addrs, TRACK_ADDRS_COUNT, 3);
metadata_access_disable();
 
-   if (trace.nr_entries < TRACK_ADDRS_COUNT)
-   p->addrs[trace.nr_entries] = 0;
+   if (nr_entries < TRACK_ADDRS_COUNT)
+   p->addrs[nr_entries] = 0;
 #endif
p->addr = addr;
p->cpu = smp_processor_id();


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 110514] [CI][BAT] igt@* - skip - Test requirement: is_i915_device(fd) && has_known_intel_chipset(fd), Skip

2019-04-26 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110514

--- Comment #7 from CI Bug Log  ---
A CI Bug Log filter associated to this bug has been updated:

{- CML: igt@kms_addfb_basic@* - skip - Test requirement: gen >= 9, SKIP -}
{+ CML: all tests - skip - Test requirement: .* gen >= .*, SKIP +}

New failures caught by the filter:

  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_rotation_...@bad-pixel-format.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_flip_til...@flip-to-yf-tiled.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_rotation_...@primary-rotation-270.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_rotation_...@primary-yf-tiled-reflect-x-0.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_rotation_...@sprite-rotation-90-pos-100-0.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_rotation_...@primary-y-tiled-reflect-x-180.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_rotation_...@multiplane-rotation-cropping-top.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_flip_til...@flip-changes-tiling-yf.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_flip_til...@flip-to-y-tiled.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_rotation_...@primary-x-tiled-reflect-x-0.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_flip_til...@flip-changes-tiling-y.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_rotation_...@multiplane-rotation.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_rotation_...@exhaust-fences.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_rotation_...@primary-x-tiled-reflect-x-180.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_rotation_...@primary-yf-tiled-reflect-x-270.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_rotation_...@primary-rotation-90.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_rotation_...@sprite-rotation-270.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_rotation_...@primary-yf-tiled-reflect-x-180.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_rotation_...@primary-y-tiled-reflect-x-0.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_flip_til...@flip-yf-tiled.html

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH v3 12/26] compat_ioctl: move more drivers to compat_ptr_ioctl

2019-04-26 Thread Arnd Bergmann
On Thu, Apr 25, 2019 at 11:25 PM Johannes Berg
 wrote:
> On Thu, 2019-04-25 at 17:55 +0200, Arnd Bergmann wrote:
> > On Thu, Apr 25, 2019 at 5:35 PM Al Viro  wrote:
> > >
> > > On Thu, Apr 25, 2019 at 12:21:53PM -0300, Mauro Carvalho Chehab wrote:
> > >
> > > > If I understand your patch description well, using compat_ptr_ioctl
> > > > only works if the driver is not for s390, right?
> > >
> > > No; s390 is where "oh, just set ->compat_ioctl same as ->unlocked_ioctl
> > > and be done with that; compat_ptr() is a no-op anyway" breaks.  IOW,
> > > s390 is the reason for having compat_ptr_ioctl() in the first place;
> > > that thing works on all biarch architectures, as long as all stuff
> > > handled by ->ioctl() takes pointer to arch-independent object as
> > > argument.  IOW,
> > > argument ignored => OK
> > > any arithmetical type => no go, compat_ptr() would bugger it
> > > pointer to int => OK
> > > pointer to string => OK
> > > pointer to u64 => OK
> > > pointer to struct {u64 addr; char s[11];} => OK
> >
> > To be extra pedantic, the 'struct {u64 addr; char s[11];} '
> > case is also broken on x86, because sizeof (obj) is smaller
> > on i386, even though the location of the members are
> > the same. i.e. you can copy_from_user() this
>
> Actually, you can't even do that because the struct might sit at the end
> of a page and then you'd erroneously fault in this case.
>
> We had this a while ago with struct ifreq, see commit 98406133dd and its
> parents.

Yes, you are right. Very rare to hit with real-life code, but easily
reproduced by intentionally hitting it and clearly a bug.

As the saying goes

  | the difference between "always works" and "almost always works"
  | is called data corruption

here the difference is an -EFAULT.

  Arnd
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 109239] Polaris10: Periodic random black screens for 1-2 seconds

2019-04-26 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=109239

--- Comment #12 from Samuel Pitoiset  ---
Actually, the problem happens with that new 4K screen too, lees frequently but
still.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH] drm/ttm: fix busy memory to fail other user v3

2019-04-26 Thread Christian König

Am 25.04.19 um 09:39 schrieb Chunming Zhou:

heavy gpu job could occupy memory long time, which lead other user fail to get 
memory.

basically pick up Christian idea:

1. Reserve the BO in DC using a ww_mutex ticket (trivial).


Any reason you don't want to split this into a separate patch?


2. If we then run into this EBUSY condition in TTM check if the BO we need 
memory for (or rather the ww_mutex of its reservation object) has a ticket 
assigned.
3. If we have a ticket we grab a reference to the first BO on the LRU, drop the 
LRU lock and try to grab the reservation lock with the ticket.
4. If getting the reservation lock with the ticket succeeded we check if the BO 
is still the first one on the LRU in question (the BO could have moved).
5. If the BO is still the first one on the LRU in question we try to evict it 
as we would evict any other BO.
6. If any of the "If's" above fail we just back off and return -EBUSY.

v2: fix some minor check
v3: address Christian v2 comments.

Change-Id: I21423fb922f885465f13833c41df1e134364a8e7
Signed-off-by: Chunming Zhou 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c|  7 ++-
  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 21 ++--
  drivers/gpu/drm/ttm/ttm_bo.c  | 48 +--
  3 files changed, 67 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index affde72b44db..015bf62277d0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -811,7 +811,12 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 
domain,
 u64 min_offset, u64 max_offset)
  {
struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
-   struct ttm_operation_ctx ctx = { false, false };
+   struct ttm_operation_ctx ctx = {
+   .interruptible = false,
+   .no_wait_gpu = false,
+   .resv = bo->tbo.resv,
+   .flags = TTM_OPT_FLAG_ALLOW_RES_EVICT
+   };


Please completely drop this chunk.

If we allow evicting BOs from the same process during pinning it could 
lead to some unforeseen side effects.



int r, i;
  
  	if (amdgpu_ttm_tt_get_usermm(bo->tbo.ttm))

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index a5cacf846e1b..2957ac38dcb0 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4101,6 +4101,9 @@ static int dm_plane_helper_prepare_fb(struct drm_plane 
*plane,
struct amdgpu_device *adev;
struct amdgpu_bo *rbo;
struct dm_plane_state *dm_plane_state_new, *dm_plane_state_old;
+   struct list_head list, duplicates;
+   struct ttm_validate_buffer tv;
+   struct ww_acquire_ctx ticket;
uint64_t tiling_flags;
uint32_t domain;
int r;
@@ -4120,6 +4123,18 @@ static int dm_plane_helper_prepare_fb(struct drm_plane 
*plane,
r = amdgpu_bo_reserve(rbo, false);
if (unlikely(r != 0))
return r;
+   INIT_LIST_HEAD(&list);
+   INIT_LIST_HEAD(&duplicates);
+
+   tv.bo = &rbo->tbo;
+   tv.num_shared = 1;
+   list_add(&tv.head, &list);
+
+   r = ttm_eu_reserve_buffers(&ticket, &list, false, &duplicates);
+   if (r) {
+   dev_err(adev->dev, "fail to reserve bo (%d)\n", r);
+   return r;
+   }
  
  	if (plane->type != DRM_PLANE_TYPE_CURSOR)

domain = amdgpu_display_supported_domains(adev);
@@ -4130,21 +4145,21 @@ static int dm_plane_helper_prepare_fb(struct drm_plane 
*plane,
if (unlikely(r != 0)) {
if (r != -ERESTARTSYS)
DRM_ERROR("Failed to pin framebuffer with error %d\n", 
r);
-   amdgpu_bo_unreserve(rbo);
+   ttm_eu_backoff_reservation(&ticket, &list);
return r;
}
  
  	r = amdgpu_ttm_alloc_gart(&rbo->tbo);

if (unlikely(r != 0)) {
amdgpu_bo_unpin(rbo);
-   amdgpu_bo_unreserve(rbo);
+   ttm_eu_backoff_reservation(&ticket, &list);
DRM_ERROR("%p bind failed\n", rbo);
return r;
}
  
  	amdgpu_bo_get_tiling_flags(rbo, &tiling_flags);
  
-	amdgpu_bo_unreserve(rbo);

+   ttm_eu_backoff_reservation(&ticket, &list);


This part looks good to me, but as noted above should probably be in a 
separate patch.


  
  	afb->address = amdgpu_bo_gpu_offset(rbo);
  
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c

index 8502b3ed2d88..dbcf958d1b43 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -766,11 +766,12 @@ EXPORT_SYMBOL(ttm_bo_eviction_valuable);
   * b. Otherwise, trylock it.
   */
  static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo,
-   struct ttm_operation_ct

Re: [PATCH 4/4] drm/amd/display: Compensate for pre-DCE12 BTR-VRR hw limitations.

2019-04-26 Thread Mario Kleiner
On Wed, Apr 24, 2019 at 4:34 PM Kazlauskas, Nicholas
 wrote:
>
> On 4/17/19 11:51 PM, Mario Kleiner wrote:
> > Pre-DCE12 needs special treatment for BTR / low framerate
> > compensation for more stable behaviour:
> >
> > According to comments in the code and some testing on DCE-8
> > and DCE-11, DCE-11 and earlier only apply VTOTAL_MIN/MAX
> > programming with a lag of one frame, so the special BTR hw
> > programming for intermediate fixed duration frames must be
> > done inside the current frame at flip submission in atomic
> > commit tail, ie. one vblank earlier, and the fixed refresh
> > intermediate frame mode must be also terminated one vblank
> > earlier on pre-DCE12 display engines.
> >
> > To achieve proper termination on < DCE-12 shift the point
> > when the switch-back from fixed vblank duration to variable
> > vblank duration happens from the start of VBLANK (vblank irq,
> > as done on DCE-12+) to back-porch or end of VBLANK (handled
> > by vupdate irq handler). We must leave the switch-back code
> > inside VBLANK irq for DCE12+, as before.
> >
> > Doing this, we get much better behaviour of BTR for up-sweeps,
> > ie. going from short to long frame durations (~high to low fps)
> > and for constant framerate flips, as tested on DCE-8 and
> > DCE-11. Behaviour is still not quite as good as on DCN-1
> > though.
> >
> > On down-sweeps, going from long to short frame durations
> > (low fps to high fps) < DCE-12 is a little bit improved,
> > although by far not as much as for up-sweeps and constant
> > fps.
> >
> > Signed-off-by: Mario Kleiner 
> > ---
>
> I did some debugging/testing with this patch and it certainly does
> improve things quite a bit for pre DCE12 (since this really should have
> been handled in VUPDATE before).
>

Do you know at which exact point in the frame cycle or vblank the new
VTOTAL_MIN/MAX gets latched by the hw?

Btw. for reference i made a little git repo with a cleaned up version
my test script VRRTest.m and some pdf's with some plots from my
testing with a slightly earlier version of that script:

https://github.com/kleinerm/VRRTestPlots

Easy to use on a Debian/Ubuntu based system as you can get GNU/Octave
+ psychtoolbox-3 from the distro repo. Explanations in the Readme.md

> I have one comment inline below:
>
>
> >   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 ++-
> >   1 file changed, 31 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
> > b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > index 76b6e621793f..9c8c94f82b35 100644
> > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > @@ -364,6 +364,7 @@ static void dm_vupdate_high_irq(void *interrupt_params)
> >   struct amdgpu_device *adev = irq_params->adev;
> >   struct amdgpu_crtc *acrtc;
> >   struct dm_crtc_state *acrtc_state;
> > + unsigned long flags;
> >
> >   acrtc = get_crtc_by_otg_inst(adev, irq_params->irq_src - 
> > IRQ_TYPE_VUPDATE);
> >
> > @@ -381,6 +382,22 @@ static void dm_vupdate_high_irq(void *interrupt_params)
> >*/
> >   if (amdgpu_dm_vrr_active(acrtc_state))
> >   drm_crtc_handle_vblank(&acrtc->base);
> > +
> > + if (acrtc_state->stream && adev->family < AMDGPU_FAMILY_AI &&
> > + acrtc_state->vrr_params.supported &&
> > + acrtc_state->freesync_config.state == 
> > VRR_STATE_ACTIVE_VARIABLE) {
> > + spin_lock_irqsave(&adev->ddev->event_lock, flags);
> > + mod_freesync_handle_v_update(
> > + adev->dm.freesync_module,
> > + acrtc_state->stream,
> > + &acrtc_state->vrr_params);
> > +
> > + dc_stream_adjust_vmin_vmax(
> > + adev->dm.dc,
> > + acrtc_state->stream,
> > + &acrtc_state->vrr_params.adjust);
> > + spin_unlock_irqrestore(&adev->ddev->event_lock, 
> > flags);
> > + }
> >   }
> >   }
> >
> > @@ -390,6 +407,7 @@ static void dm_crtc_high_irq(void *interrupt_params)
> >   struct amdgpu_device *adev = irq_params->adev;
> >   struct amdgpu_crtc *acrtc;
> >   struct dm_crtc_state *acrtc_state;
> > + unsigned long flags;
> >
> >   acrtc = get_crtc_by_otg_inst(adev, irq_params->irq_src - 
> > IRQ_TYPE_VBLANK);
> >
> > @@ -412,9 +430,10 @@ static void dm_crtc_high_irq(void *interrupt_params)
> >*/
> >   amdgpu_dm_crtc_handle_crc_irq(&acrtc->base);
> >
> > - if (acrtc_state->stream &&
> > + if (acrtc_state->stream && adev->family >= AMDGPU_FAMILY_AI &&
> >   acrtc_state->vrr_params.supported &&
> >   acrtc_state->freesync_config.state == 
> > VRR_STATE_ACTIVE_VARIABLE) {
> > + spin_lock_ir

[Bug 110514] [CI][BAT] igt@* - skip - Test requirement: is_i915_device(fd) && has_known_intel_chipset(fd), Skip

2019-04-26 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110514

--- Comment #8 from CI Bug Log  ---
The CI Bug Log issue associated to this bug has been updated.

### New filters associated

* CML: igt@*stolen* - skip - Test requirement:
gem_create__has_stolen_support(fd) && (gem_total_stolen_size(fd) >
0), SKIP
  -
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@gem_sto...@stolen-pread.html
  -
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@gem_sto...@stolen-no-mmap.html
  -
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@gem_pwr...@stolen-display.html
  -
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@gem_pr...@stolen-uncached.html
  -
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@gem_sto...@large-object-alloc.html
  -
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@gem_pwr...@stolen-snoop.html
  -
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@gem_sto...@stolen-copy.html
  -
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@gem_pr...@stolen-normal.html
  -
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@gem_pr...@stolen-display.html

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 110514] [CI][BAT] igt@* - skip - Test requirement: is_i915_device(fd) && has_known_intel_chipset(fd), Skip

2019-04-26 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110514

--- Comment #9 from CI Bug Log  ---
A CI Bug Log filter associated to this bug has been updated:

{- CML: all tests - skip - Test requirement: .* gen >= .*, SKIP -}
{+ CML: all tests - skip - Test requirement: .* (gen|intel_gen(ms_data.devid))
>= .*, SKIP +}

New failures caught by the filter:

  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@i915_pm_...@debugfs-forcewake-user.html

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 110514] [CI][BAT] igt@* - skip - Test requirement: is_i915_device(fd) && has_known_intel_chipset(fd), Skip

2019-04-26 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110514

--- Comment #10 from CI Bug Log  ---
A CI Bug Log filter associated to this bug has been updated:

{- CML: all tests - skip - Test requirement: .* (gen|intel_gen(ms_data.devid))
>= .*, SKIP -}
{+ CML: all tests - skip - Test requirement: .* (gen|intel_gen(.*)) >= .*,
SKIP +}

New failures caught by the filter:

  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_...@pipe-b-bad-aux-stride.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_...@pipe-c-bad-aux-stride.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_panel_fitt...@atomic-fastset.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_...@pipe-b-bad-pixel-format.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_...@pipe-b-crc-primary-rotation-180.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_hdmi_inj...@inject-4k.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_...@pipe-b-crc-primary-basic.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_...@pipe-b-ccs-on-another-bo.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_...@pipe-a-crc-sprite-planes-basic.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_...@pipe-a-crc-primary-basic.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_...@pipe-c-crc-primary-rotation-180.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_...@pipe-c-bad-rotation-90.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@kms_...@pipe-a-bad-aux-stride.html

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH] drm/ttm: fix busy memory to fail other user v3

2019-04-26 Thread zhoucm1



On 2019年04月26日 16:31, Christian König wrote:

Am 25.04.19 um 09:39 schrieb Chunming Zhou:
heavy gpu job could occupy memory long time, which lead other user 
fail to get memory.


basically pick up Christian idea:

1. Reserve the BO in DC using a ww_mutex ticket (trivial).


Any reason you don't want to split this into a separate patch?
Will do that after locking down solution, just make the solution in one 
patch to review conveniently.




2. If we then run into this EBUSY condition in TTM check if the BO we 
need memory for (or rather the ww_mutex of its reservation object) 
has a ticket assigned.
3. If we have a ticket we grab a reference to the first BO on the 
LRU, drop the LRU lock and try to grab the reservation lock with the 
ticket.
4. If getting the reservation lock with the ticket succeeded we check 
if the BO is still the first one on the LRU in question (the BO could 
have moved).
5. If the BO is still the first one on the LRU in question we try to 
evict it as we would evict any other BO.

6. If any of the "If's" above fail we just back off and return -EBUSY.

v2: fix some minor check
v3: address Christian v2 comments.

Change-Id: I21423fb922f885465f13833c41df1e134364a8e7
Signed-off-by: Chunming Zhou 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c    |  7 ++-
  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 21 ++--
  drivers/gpu/drm/ttm/ttm_bo.c  | 48 +--
  3 files changed, 67 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

index affde72b44db..015bf62277d0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -811,7 +811,12 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo 
*bo, u32 domain,

   u64 min_offset, u64 max_offset)
  {
  struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
-    struct ttm_operation_ctx ctx = { false, false };
+    struct ttm_operation_ctx ctx = {
+    .interruptible = false,
+    .no_wait_gpu = false,
+    .resv = bo->tbo.resv,
+    .flags = TTM_OPT_FLAG_ALLOW_RES_EVICT
+    };


Please completely drop this chunk.

If we allow evicting BOs from the same process during pinning it could 
lead to some unforeseen side effects.

Will remove that flags.




  int r, i;
    if (amdgpu_ttm_tt_get_usermm(bo->tbo.ttm))
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index a5cacf846e1b..2957ac38dcb0 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4101,6 +4101,9 @@ static int dm_plane_helper_prepare_fb(struct 
drm_plane *plane,

  struct amdgpu_device *adev;
  struct amdgpu_bo *rbo;
  struct dm_plane_state *dm_plane_state_new, *dm_plane_state_old;
+    struct list_head list, duplicates;
+    struct ttm_validate_buffer tv;
+    struct ww_acquire_ctx ticket;
  uint64_t tiling_flags;
  uint32_t domain;
  int r;
@@ -4120,6 +4123,18 @@ static int dm_plane_helper_prepare_fb(struct 
drm_plane *plane,

  r = amdgpu_bo_reserve(rbo, false);
  if (unlikely(r != 0))
  return r;
+    INIT_LIST_HEAD(&list);
+    INIT_LIST_HEAD(&duplicates);
+
+    tv.bo = &rbo->tbo;
+    tv.num_shared = 1;
+    list_add(&tv.head, &list);
+
+    r = ttm_eu_reserve_buffers(&ticket, &list, false, &duplicates);
+    if (r) {
+    dev_err(adev->dev, "fail to reserve bo (%d)\n", r);
+    return r;
+    }
    if (plane->type != DRM_PLANE_TYPE_CURSOR)
  domain = amdgpu_display_supported_domains(adev);
@@ -4130,21 +4145,21 @@ static int dm_plane_helper_prepare_fb(struct 
drm_plane *plane,

  if (unlikely(r != 0)) {
  if (r != -ERESTARTSYS)
  DRM_ERROR("Failed to pin framebuffer with error %d\n", r);
-    amdgpu_bo_unreserve(rbo);
+    ttm_eu_backoff_reservation(&ticket, &list);
  return r;
  }
    r = amdgpu_ttm_alloc_gart(&rbo->tbo);
  if (unlikely(r != 0)) {
  amdgpu_bo_unpin(rbo);
-    amdgpu_bo_unreserve(rbo);
+    ttm_eu_backoff_reservation(&ticket, &list);
  DRM_ERROR("%p bind failed\n", rbo);
  return r;
  }
    amdgpu_bo_get_tiling_flags(rbo, &tiling_flags);
  -    amdgpu_bo_unreserve(rbo);
+    ttm_eu_backoff_reservation(&ticket, &list);


This part looks good to me, but as noted above should probably be in a 
separate patch.



    afb->address = amdgpu_bo_gpu_offset(rbo);
  diff --git a/drivers/gpu/drm/ttm/ttm_bo.c 
b/drivers/gpu/drm/ttm/ttm_bo.c

index 8502b3ed2d88..dbcf958d1b43 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -766,11 +766,12 @@ EXPORT_SYMBOL(ttm_bo_eviction_valuable);
   * b. Otherwise, trylock it.
   */
  static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object 
*bo,

-    struct ttm_operation_ctx *ctx, bool *lock

Re: [PATCH] drm/ttm: fix busy memory to fail other user v3

2019-04-26 Thread Koenig, Christian
Am 26.04.19 um 11:07 schrieb zhoucm1:
> [SNIP]
>>> + spin_lock(&glob->lru_lock);
>>> +    for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
>>> +    if (list_empty(&man->lru[i]))
>>> +    continue;
>>> +    bo = list_first_entry(&man->lru[i],
>>> +  struct ttm_buffer_object,
>>> +  lru);
>>
>> You now need to check all BOs on the LRU, cause the first one where a 
>> trylock failed is not necessarily the first one on the list.
> Sorry, I don't get your opinion on this, Could you detail a bit how to 
> do that?
> I though after ww_mutex_lock, cs is done, then DC can pick up any of 
> them.

The first_bo is not necessarily the first BO of the LRU, but the first 
BO which failed in the trylock.

>
>>
>>> +
>>> +    break;
>>> +    }
>>> +    /* verify if BO have been moved */
>>> +    if (first_bo != bo) {

And in this case we would abort here without a good reason.

Christian.

>>> + spin_unlock(&glob->lru_lock);
>>> +    ww_mutex_unlock(&bo->resv->lock);
>>> +    return -EBUSY;
>>> +    }
>>> +    spin_unlock(&glob->lru_lock);
>>> +    /* ok, pick up first busy BO to wait to evict */
>>>   }
>>>     kref_get(&bo->list_kref);
>>> @@ -1784,7 +1819,10 @@ int ttm_bo_swapout(struct ttm_bo_global 
>>> *glob, struct ttm_operation_ctx *ctx)
>>>   spin_lock(&glob->lru_lock);
>>>   for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
>>>   list_for_each_entry(bo, &glob->swap_lru[i], swap) {
>>> -    if (ttm_bo_evict_swapout_allowable(bo, ctx, &locked)) {
>>> +    bool busy = false;
>>
>> Better make the parameter optional.
> Will do.
>
> -David
>>
>> Christian.
>>
>>> +
>>> +    if (ttm_bo_evict_swapout_allowable(bo, ctx, &locked,
>>> +   &busy)) {
>>>   ret = 0;
>>>   break;
>>>   }
>>
>

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH] drm/ttm: fix busy memory to fail other user v3

2019-04-26 Thread zhoucm1



On 2019年04月26日 17:11, Koenig, Christian wrote:

Am 26.04.19 um 11:07 schrieb zhoucm1:

[SNIP]

+ spin_lock(&glob->lru_lock);
+    for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
+    if (list_empty(&man->lru[i]))
+    continue;
+    bo = list_first_entry(&man->lru[i],
+  struct ttm_buffer_object,
+  lru);

You now need to check all BOs on the LRU, cause the first one where a
trylock failed is not necessarily the first one on the list.

Sorry, I don't get your opinion on this, Could you detail a bit how to
do that?
I though after ww_mutex_lock, cs is done, then DC can pick up any of
them.

The first_bo is not necessarily the first BO of the LRU, but the first
BO which failed in the trylock.


+
+    break;
+    }
+    /* verify if BO have been moved */
+    if (first_bo != bo) {

And in this case we would abort here without a good reason.

I got what you said now. I will change it soon.

-David


Christian.


+ spin_unlock(&glob->lru_lock);
+    ww_mutex_unlock(&bo->resv->lock);
+    return -EBUSY;
+    }
+    spin_unlock(&glob->lru_lock);
+    /* ok, pick up first busy BO to wait to evict */
   }
     kref_get(&bo->list_kref);
@@ -1784,7 +1819,10 @@ int ttm_bo_swapout(struct ttm_bo_global
*glob, struct ttm_operation_ctx *ctx)
   spin_lock(&glob->lru_lock);
   for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
   list_for_each_entry(bo, &glob->swap_lru[i], swap) {
-    if (ttm_bo_evict_swapout_allowable(bo, ctx, &locked)) {
+    bool busy = false;

Better make the parameter optional.

Will do.

-David

Christian.


+
+    if (ttm_bo_evict_swapout_allowable(bo, ctx, &locked,
+   &busy)) {
   ret = 0;
   break;
   }


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 110514] [CI][BAT] igt@* - skip - Test requirement: is_i915_device(fd) && has_known_intel_chipset(fd), Skip

2019-04-26 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110514

--- Comment #11 from CI Bug Log  ---
The CI Bug Log issue associated to this bug has been updated.

### New filters associated

* CML: igt@gem_render_copy_redux@interruptible - skip - no render-copy function
  -
https://intel-gfx-ci.01.org/tree/drm-tip/drmtip_265/fi-cml-u/igt@gem_render_copy_re...@interruptible.html

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH] drm/ttm: fix busy memory to fail other user v4

2019-04-26 Thread Chunming Zhou
heavy gpu job could occupy memory long time, which lead other user fail to get 
memory.

basically pick up Christian idea:

1. Reserve the BO in DC using a ww_mutex ticket (trivial).
2. If we then run into this EBUSY condition in TTM check if the BO we need 
memory for (or rather the ww_mutex of its reservation object) has a ticket 
assigned.
3. If we have a ticket we grab a reference to the first BO on the LRU, drop the 
LRU lock and try to grab the reservation lock with the ticket.
4. If getting the reservation lock with the ticket succeeded we check if the BO 
is still the first one on the LRU in question (the BO could have moved).
5. If the BO is still the first one on the LRU in question we try to evict it 
as we would evict any other BO.
6. If any of the "If's" above fail we just back off and return -EBUSY.

v2: fix some minor check
v3: address Christian v2 comments.
v4: fix some missing

Change-Id: I21423fb922f885465f13833c41df1e134364a8e7
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c|  6 +-
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 21 +-
 drivers/gpu/drm/ttm/ttm_bo.c  | 70 +--
 3 files changed, 88 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index affde72b44db..032edf477827 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -811,7 +811,11 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 
domain,
 u64 min_offset, u64 max_offset)
 {
struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
-   struct ttm_operation_ctx ctx = { false, false };
+   struct ttm_operation_ctx ctx = {
+   .interruptible = false,
+   .no_wait_gpu = false,
+   .resv = bo->tbo.resv,
+   };
int r, i;
 
if (amdgpu_ttm_tt_get_usermm(bo->tbo.ttm))
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index a5cacf846e1b..2957ac38dcb0 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4101,6 +4101,9 @@ static int dm_plane_helper_prepare_fb(struct drm_plane 
*plane,
struct amdgpu_device *adev;
struct amdgpu_bo *rbo;
struct dm_plane_state *dm_plane_state_new, *dm_plane_state_old;
+   struct list_head list, duplicates;
+   struct ttm_validate_buffer tv;
+   struct ww_acquire_ctx ticket;
uint64_t tiling_flags;
uint32_t domain;
int r;
@@ -4120,6 +4123,18 @@ static int dm_plane_helper_prepare_fb(struct drm_plane 
*plane,
r = amdgpu_bo_reserve(rbo, false);
if (unlikely(r != 0))
return r;
+   INIT_LIST_HEAD(&list);
+   INIT_LIST_HEAD(&duplicates);
+
+   tv.bo = &rbo->tbo;
+   tv.num_shared = 1;
+   list_add(&tv.head, &list);
+
+   r = ttm_eu_reserve_buffers(&ticket, &list, false, &duplicates);
+   if (r) {
+   dev_err(adev->dev, "fail to reserve bo (%d)\n", r);
+   return r;
+   }
 
if (plane->type != DRM_PLANE_TYPE_CURSOR)
domain = amdgpu_display_supported_domains(adev);
@@ -4130,21 +4145,21 @@ static int dm_plane_helper_prepare_fb(struct drm_plane 
*plane,
if (unlikely(r != 0)) {
if (r != -ERESTARTSYS)
DRM_ERROR("Failed to pin framebuffer with error %d\n", 
r);
-   amdgpu_bo_unreserve(rbo);
+   ttm_eu_backoff_reservation(&ticket, &list);
return r;
}
 
r = amdgpu_ttm_alloc_gart(&rbo->tbo);
if (unlikely(r != 0)) {
amdgpu_bo_unpin(rbo);
-   amdgpu_bo_unreserve(rbo);
+   ttm_eu_backoff_reservation(&ticket, &list);
DRM_ERROR("%p bind failed\n", rbo);
return r;
}
 
amdgpu_bo_get_tiling_flags(rbo, &tiling_flags);
 
-   amdgpu_bo_unreserve(rbo);
+   ttm_eu_backoff_reservation(&ticket, &list);
 
afb->address = amdgpu_bo_gpu_offset(rbo);
 
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 8502b3ed2d88..3348ca0423a1 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -766,11 +766,12 @@ EXPORT_SYMBOL(ttm_bo_eviction_valuable);
  * b. Otherwise, trylock it.
  */
 static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo,
-   struct ttm_operation_ctx *ctx, bool *locked)
+   struct ttm_operation_ctx *ctx, bool *locked, bool *busy)
 {
bool ret = false;
 
*locked = false;
+   *busy = false;
if (bo->resv == ctx->resv) {
reservation_object_assert_held(bo->resv);
if (ctx->flags & TTM_OPT_FLAG_ALLOW_RES_EVICT
@@ -779,6 +780,8 @@ static bool ttm_bo_evi

Re: [PATCH v2 25/79] docs: convert docs to ReST and rename to *.rst

2019-04-26 Thread Mauro Carvalho Chehab
Hi Mark,

Em Thu, 25 Apr 2019 19:07:58 +0100
Mark Brown  escreveu:

> On Mon, Apr 22, 2019 at 10:27:14AM -0300, Mauro Carvalho Chehab wrote:
> > Convert the PM documents to ReST, in order to allow them to
> > build with Sphinx.  
> 
> This is massively CCed covering a large range of subsystems and is patch
> 25 of a 79 patch series so I've no context for what's going on here or
> why...  

There are two goals of this series:

1) to prepare for placing the new *.rst files under Documentation/ into an
   index file, being part of one of the books. Most of the stuff covered
   on this series either fit at the system admin guide or at the
   Kernel API documentation book;

2) to ensure that, if some edition on a file would cause warnings at
   Sphinx build, someone will notice and submit a followup patch.

You can see more details at patch 00/79:
https://lore.kernel.org/lkml/20190422115110.26443...@coco.lan/

In order to do that, this series has one patch per Documentation/*
sub-directory. This specific one is for the documents under
Documentation/power/ [1].

[1] btw, the title of this specific patch should be, instead:
docs: power: convert docs to ReST and rename to *.rst

The series is long because I'm trying to cover a significant part
of the documentation files. In any case, except if an eventual
conflict might rise on some file, this patch is independent from
all other files, and should be safe to apply directly via the
subsystem git tree.

I'm working on a follow-up patch series that should be adding the
power/index.rst file into another index file - probably at
Documentation/index.rst[1]. As such patch will be adding a lot of other
index files, the best would be to merge it via the docs tree, in
order to avoid conflicts.


[1] such patch will be removing the ":orphan:" meta-tag from it
(that basically tells the build system to not produce warnings if
the file is not directly or indirectly referenced by the main
index file).

Thanks,
Mauro
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH] drm/ttm: fix busy memory to fail other user v4

2019-04-26 Thread Chunming Zhou
heavy gpu job could occupy memory long time, which lead other user fail to get 
memory.

basically pick up Christian idea:

1. Reserve the BO in DC using a ww_mutex ticket (trivial).
2. If we then run into this EBUSY condition in TTM check if the BO we need 
memory for (or rather the ww_mutex of its reservation object) has a ticket 
assigned.
3. If we have a ticket we grab a reference to the first BO on the LRU, drop the 
LRU lock and try to grab the reservation lock with the ticket.
4. If getting the reservation lock with the ticket succeeded we check if the BO 
is still the first one on the LRU in question (the BO could have moved).
5. If the BO is still the first one on the LRU in question we try to evict it 
as we would evict any other BO.
6. If any of the "If's" above fail we just back off and return -EBUSY.

v2: fix some minor check
v3: address Christian v2 comments.
v4: fix some missing

Change-Id: I21423fb922f885465f13833c41df1e134364a8e7
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c|  6 +-
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 21 +-
 drivers/gpu/drm/ttm/ttm_bo.c  | 74 +--
 3 files changed, 92 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index affde72b44db..032edf477827 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -811,7 +811,11 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 
domain,
 u64 min_offset, u64 max_offset)
 {
struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
-   struct ttm_operation_ctx ctx = { false, false };
+   struct ttm_operation_ctx ctx = {
+   .interruptible = false,
+   .no_wait_gpu = false,
+   .resv = bo->tbo.resv,
+   };
int r, i;
 
if (amdgpu_ttm_tt_get_usermm(bo->tbo.ttm))
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index a5cacf846e1b..2957ac38dcb0 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4101,6 +4101,9 @@ static int dm_plane_helper_prepare_fb(struct drm_plane 
*plane,
struct amdgpu_device *adev;
struct amdgpu_bo *rbo;
struct dm_plane_state *dm_plane_state_new, *dm_plane_state_old;
+   struct list_head list, duplicates;
+   struct ttm_validate_buffer tv;
+   struct ww_acquire_ctx ticket;
uint64_t tiling_flags;
uint32_t domain;
int r;
@@ -4120,6 +4123,18 @@ static int dm_plane_helper_prepare_fb(struct drm_plane 
*plane,
r = amdgpu_bo_reserve(rbo, false);
if (unlikely(r != 0))
return r;
+   INIT_LIST_HEAD(&list);
+   INIT_LIST_HEAD(&duplicates);
+
+   tv.bo = &rbo->tbo;
+   tv.num_shared = 1;
+   list_add(&tv.head, &list);
+
+   r = ttm_eu_reserve_buffers(&ticket, &list, false, &duplicates);
+   if (r) {
+   dev_err(adev->dev, "fail to reserve bo (%d)\n", r);
+   return r;
+   }
 
if (plane->type != DRM_PLANE_TYPE_CURSOR)
domain = amdgpu_display_supported_domains(adev);
@@ -4130,21 +4145,21 @@ static int dm_plane_helper_prepare_fb(struct drm_plane 
*plane,
if (unlikely(r != 0)) {
if (r != -ERESTARTSYS)
DRM_ERROR("Failed to pin framebuffer with error %d\n", 
r);
-   amdgpu_bo_unreserve(rbo);
+   ttm_eu_backoff_reservation(&ticket, &list);
return r;
}
 
r = amdgpu_ttm_alloc_gart(&rbo->tbo);
if (unlikely(r != 0)) {
amdgpu_bo_unpin(rbo);
-   amdgpu_bo_unreserve(rbo);
+   ttm_eu_backoff_reservation(&ticket, &list);
DRM_ERROR("%p bind failed\n", rbo);
return r;
}
 
amdgpu_bo_get_tiling_flags(rbo, &tiling_flags);
 
-   amdgpu_bo_unreserve(rbo);
+   ttm_eu_backoff_reservation(&ticket, &list);
 
afb->address = amdgpu_bo_gpu_offset(rbo);
 
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 8502b3ed2d88..f4f506dad2b0 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -766,11 +766,12 @@ EXPORT_SYMBOL(ttm_bo_eviction_valuable);
  * b. Otherwise, trylock it.
  */
 static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo,
-   struct ttm_operation_ctx *ctx, bool *locked)
+   struct ttm_operation_ctx *ctx, bool *locked, bool *busy)
 {
bool ret = false;
 
*locked = false;
+   *busy = false;
if (bo->resv == ctx->resv) {
reservation_object_assert_held(bo->resv);
if (ctx->flags & TTM_OPT_FLAG_ALLOW_RES_EVICT
@@ -779,6 +780,8 @@ static bool ttm_bo_evi

Re: [PATCH] drm/komeda: Use memset to initialize config_id

2019-04-26 Thread Liviu Dudau
On Wed, Apr 24, 2019 at 11:27:20PM -0700, Nathan Chancellor wrote:
> Clang warns:
> 
> drivers/gpu/drm/arm/display/komeda/komeda_dev.c:76:38: warning: suggest
> braces around initialization of subobject [-Wmissing-braces]
> union komeda_config_id config_id = {0,};
> ^
> {}
> 1 warning generated.
> 
> One way to fix these warnings is to add additional braces like Clang
> suggests; however, there has been a bit of push back from some
> maintainers, who just prefer memset as it is unambiguous, doesn't
> depend on a particular compiler version, and properly initializes all
> subobjects [1][2]. Do that here so there are no more warnings.
> 
> [1]: 
> https://lore.kernel.org/lkml/022e41c0-8465-dc7a-a45c-64187ecd9...@amd.com/
> [2]: 
> https://lore.kernel.org/lkml/20181128.215241.702406654469517539.da...@davemloft.net/
> 
> Fixes: 4cc734cb79a8 ("drm/komeda: Add sysfs attribute: core_id and config_id")
> Link: https://github.com/ClangBuiltLinux/linux/issues/457
> Signed-off-by: Nathan Chancellor 

Acked-by: Liviu Dudau 

I'll pull the patch into my tree today.

Best regards,
Liviu

> ---
>  drivers/gpu/drm/arm/display/komeda/komeda_dev.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c 
> b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> index 9d6c31cca875..e605a518f59a 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> @@ -73,9 +73,10 @@ config_id_show(struct device *dev, struct device_attribute 
> *attr, char *buf)
>  {
>   struct komeda_dev *mdev = dev_to_mdev(dev);
>   struct komeda_pipeline *pipe = mdev->pipelines[0];
> - union komeda_config_id config_id = {0,};
> + union komeda_config_id config_id;
>   int i;
>  
> + memset(&config_id, 0, sizeof(config_id));
>   config_id.max_line_sz = pipe->layers[0]->hsize_in.end;
>   config_id.n_pipelines = mdev->n_pipelines;
>   config_id.n_scalers = pipe->n_scalers;
> -- 
> 2.21.0
> 

-- 

| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---
¯\_(ツ)_/¯
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH] drm/ttm: fix busy memory to fail other user v4

2019-04-26 Thread zhoucm1

please ignore v4. Will send v5 instead.


On 2019年04月26日 17:53, Chunming Zhou wrote:

heavy gpu job could occupy memory long time, which lead other user fail to get 
memory.

basically pick up Christian idea:

1. Reserve the BO in DC using a ww_mutex ticket (trivial).
2. If we then run into this EBUSY condition in TTM check if the BO we need 
memory for (or rather the ww_mutex of its reservation object) has a ticket 
assigned.
3. If we have a ticket we grab a reference to the first BO on the LRU, drop the 
LRU lock and try to grab the reservation lock with the ticket.
4. If getting the reservation lock with the ticket succeeded we check if the BO 
is still the first one on the LRU in question (the BO could have moved).
5. If the BO is still the first one on the LRU in question we try to evict it 
as we would evict any other BO.
6. If any of the "If's" above fail we just back off and return -EBUSY.

v2: fix some minor check
v3: address Christian v2 comments.
v4: fix some missing

Change-Id: I21423fb922f885465f13833c41df1e134364a8e7
Signed-off-by: Chunming Zhou 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c|  6 +-
  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 21 +-
  drivers/gpu/drm/ttm/ttm_bo.c  | 74 +--
  3 files changed, 92 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index affde72b44db..032edf477827 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -811,7 +811,11 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 
domain,
 u64 min_offset, u64 max_offset)
  {
struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
-   struct ttm_operation_ctx ctx = { false, false };
+   struct ttm_operation_ctx ctx = {
+   .interruptible = false,
+   .no_wait_gpu = false,
+   .resv = bo->tbo.resv,
+   };
int r, i;
  
  	if (amdgpu_ttm_tt_get_usermm(bo->tbo.ttm))

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index a5cacf846e1b..2957ac38dcb0 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4101,6 +4101,9 @@ static int dm_plane_helper_prepare_fb(struct drm_plane 
*plane,
struct amdgpu_device *adev;
struct amdgpu_bo *rbo;
struct dm_plane_state *dm_plane_state_new, *dm_plane_state_old;
+   struct list_head list, duplicates;
+   struct ttm_validate_buffer tv;
+   struct ww_acquire_ctx ticket;
uint64_t tiling_flags;
uint32_t domain;
int r;
@@ -4120,6 +4123,18 @@ static int dm_plane_helper_prepare_fb(struct drm_plane 
*plane,
r = amdgpu_bo_reserve(rbo, false);
if (unlikely(r != 0))
return r;
+   INIT_LIST_HEAD(&list);
+   INIT_LIST_HEAD(&duplicates);
+
+   tv.bo = &rbo->tbo;
+   tv.num_shared = 1;
+   list_add(&tv.head, &list);
+
+   r = ttm_eu_reserve_buffers(&ticket, &list, false, &duplicates);
+   if (r) {
+   dev_err(adev->dev, "fail to reserve bo (%d)\n", r);
+   return r;
+   }
  
  	if (plane->type != DRM_PLANE_TYPE_CURSOR)

domain = amdgpu_display_supported_domains(adev);
@@ -4130,21 +4145,21 @@ static int dm_plane_helper_prepare_fb(struct drm_plane 
*plane,
if (unlikely(r != 0)) {
if (r != -ERESTARTSYS)
DRM_ERROR("Failed to pin framebuffer with error %d\n", 
r);
-   amdgpu_bo_unreserve(rbo);
+   ttm_eu_backoff_reservation(&ticket, &list);
return r;
}
  
  	r = amdgpu_ttm_alloc_gart(&rbo->tbo);

if (unlikely(r != 0)) {
amdgpu_bo_unpin(rbo);
-   amdgpu_bo_unreserve(rbo);
+   ttm_eu_backoff_reservation(&ticket, &list);
DRM_ERROR("%p bind failed\n", rbo);
return r;
}
  
  	amdgpu_bo_get_tiling_flags(rbo, &tiling_flags);
  
-	amdgpu_bo_unreserve(rbo);

+   ttm_eu_backoff_reservation(&ticket, &list);
  
  	afb->address = amdgpu_bo_gpu_offset(rbo);
  
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c

index 8502b3ed2d88..f4f506dad2b0 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -766,11 +766,12 @@ EXPORT_SYMBOL(ttm_bo_eviction_valuable);
   * b. Otherwise, trylock it.
   */
  static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo,
-   struct ttm_operation_ctx *ctx, bool *locked)
+   struct ttm_operation_ctx *ctx, bool *locked, bool *busy)
  {
bool ret = false;
  
  	*locked = false;

+   *busy = false;
if (bo->resv == ctx->resv) {
reservation_object_assert_held(bo->resv);
if (ctx->flags

[Bug 110514] [CI][BAT] igt@* - skip - Test requirement: is_i915_device(fd) && has_known_intel_chipset(fd), Skip

2019-04-26 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110514

Petri Latvala  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #12 from Petri Latvala  ---
commit 2fc51d5528eda79fe1856e0b85e6b71e3fb79c47
Author: Petri Latvala 
Date:   Thu Apr 25 16:00:45 2019 +0300

lib: Add Cometlake platform definition

Commit a794f28f01f2 ("lib: sync with the newer i915_pciids.h from the
Kernel") added CML PCI IDs but did not update intel_device_info.c

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH] drm/ttm: fix busy memory to fail other user v5

2019-04-26 Thread Chunming Zhou
heavy gpu job could occupy memory long time, which lead other user fail to get 
memory.

basically pick up Christian idea:

1. Reserve the BO in DC using a ww_mutex ticket (trivial).
2. If we then run into this EBUSY condition in TTM check if the BO we need 
memory for (or rather the ww_mutex of its reservation object) has a ticket 
assigned.
3. If we have a ticket we grab a reference to the first BO on the LRU, drop the 
LRU lock and try to grab the reservation lock with the ticket.
4. If getting the reservation lock with the ticket succeeded we check if the BO 
is still the first one on the LRU in question (the BO could have moved).
5. If the BO is still the first one on the LRU in question we try to evict it 
as we would evict any other BO.
6. If any of the "If's" above fail we just back off and return -EBUSY.

v2: fix some minor check
v3: address Christian v2 comments.
v4: fix some missing
v5: handle first_bo unlock and bo_get/put

Change-Id: I21423fb922f885465f13833c41df1e134364a8e7
Signed-off-by: Chunming Zhou 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c|  6 +-
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 21 -
 drivers/gpu/drm/ttm/ttm_bo.c  | 81 +--
 3 files changed, 99 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index affde72b44db..032edf477827 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -811,7 +811,11 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 
domain,
 u64 min_offset, u64 max_offset)
 {
struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
-   struct ttm_operation_ctx ctx = { false, false };
+   struct ttm_operation_ctx ctx = {
+   .interruptible = false,
+   .no_wait_gpu = false,
+   .resv = bo->tbo.resv,
+   };
int r, i;
 
if (amdgpu_ttm_tt_get_usermm(bo->tbo.ttm))
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index a5cacf846e1b..2957ac38dcb0 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4101,6 +4101,9 @@ static int dm_plane_helper_prepare_fb(struct drm_plane 
*plane,
struct amdgpu_device *adev;
struct amdgpu_bo *rbo;
struct dm_plane_state *dm_plane_state_new, *dm_plane_state_old;
+   struct list_head list, duplicates;
+   struct ttm_validate_buffer tv;
+   struct ww_acquire_ctx ticket;
uint64_t tiling_flags;
uint32_t domain;
int r;
@@ -4120,6 +4123,18 @@ static int dm_plane_helper_prepare_fb(struct drm_plane 
*plane,
r = amdgpu_bo_reserve(rbo, false);
if (unlikely(r != 0))
return r;
+   INIT_LIST_HEAD(&list);
+   INIT_LIST_HEAD(&duplicates);
+
+   tv.bo = &rbo->tbo;
+   tv.num_shared = 1;
+   list_add(&tv.head, &list);
+
+   r = ttm_eu_reserve_buffers(&ticket, &list, false, &duplicates);
+   if (r) {
+   dev_err(adev->dev, "fail to reserve bo (%d)\n", r);
+   return r;
+   }
 
if (plane->type != DRM_PLANE_TYPE_CURSOR)
domain = amdgpu_display_supported_domains(adev);
@@ -4130,21 +4145,21 @@ static int dm_plane_helper_prepare_fb(struct drm_plane 
*plane,
if (unlikely(r != 0)) {
if (r != -ERESTARTSYS)
DRM_ERROR("Failed to pin framebuffer with error %d\n", 
r);
-   amdgpu_bo_unreserve(rbo);
+   ttm_eu_backoff_reservation(&ticket, &list);
return r;
}
 
r = amdgpu_ttm_alloc_gart(&rbo->tbo);
if (unlikely(r != 0)) {
amdgpu_bo_unpin(rbo);
-   amdgpu_bo_unreserve(rbo);
+   ttm_eu_backoff_reservation(&ticket, &list);
DRM_ERROR("%p bind failed\n", rbo);
return r;
}
 
amdgpu_bo_get_tiling_flags(rbo, &tiling_flags);
 
-   amdgpu_bo_unreserve(rbo);
+   ttm_eu_backoff_reservation(&ticket, &list);
 
afb->address = amdgpu_bo_gpu_offset(rbo);
 
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 8502b3ed2d88..2c4963e105d9 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -766,11 +766,13 @@ EXPORT_SYMBOL(ttm_bo_eviction_valuable);
  * b. Otherwise, trylock it.
  */
 static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo,
-   struct ttm_operation_ctx *ctx, bool *locked)
+   struct ttm_operation_ctx *ctx, bool *locked, bool *busy)
 {
bool ret = false;
 
*locked = false;
+   if (busy)
+   *busy = false;
if (bo->resv == ctx->resv) {
reservation_object_assert_held(bo->resv);
if (ctx->flags & TTM_

[Bug 110514] [CI][BAT] igt@* - skip - Test requirement: is_i915_device(fd) && has_known_intel_chipset(fd), Skip

2019-04-26 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110514

--- Comment #13 from Petri Latvala  ---
(In reply to CI Bug Log from comment #8)
> The CI Bug Log issue associated to this bug has been updated.
> 
> ### New filters associated
> 
> * CML: igt@*stolen* - skip - Test requirement:
> gem_create__has_stolen_support(fd) && (gem_total_stolen_size(fd)
> > 0), SKIP


This one is a different issue, isn't it?

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 110514] [CI][BAT] igt@* - skip - Test requirement: is_i915_device(fd) && has_known_intel_chipset(fd), Skip

2019-04-26 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110514

--- Comment #14 from CI Bug Log  ---
A CI Bug Log filter associated to this bug has been updated:

{- CML: igt@gem_render_copy_redux@interruptible - skip - no render-copy
function -}
{+ CML: igt@gem_render_copy_redux@interruptible - skip - no render-copy
function +}

New failures caught by the filter:

  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@gem_render_copy_re...@interruptible.html

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 110514] [CI][BAT] igt@* - skip - Test requirement: is_i915_device(fd) && has_known_intel_chipset(fd), Skip

2019-04-26 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110514

--- Comment #15 from CI Bug Log  ---
A CI Bug Log filter associated to this bug has been updated:

{- CML: all tests - skip - Test requirement: .* (gen|intel_gen(.*)) >= .*,
SKIP -}
{+ CML: all tests - skip - Test requirement: .* (gen|intel_gen(.*)) >= .*,
SKIP +}

New failures caught by the filter:

  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@i915_pm_...@debugfs-forcewake-user.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_addfb_ba...@addfb25-y-tiled-small.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-a-bad-aux-stride.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-a-bad-pixel-format.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-a-bad-rotation-90.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-a-ccs-on-another-bo.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-a-crc-primary-basic.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-a-crc-primary-rotation-180.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-a-crc-sprite-planes-basic.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-a-missing-ccs-buffer.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-b-bad-aux-stride.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-b-bad-pixel-format.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-b-bad-rotation-90.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-b-ccs-on-another-bo.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-b-crc-primary-basic.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-b-crc-primary-rotation-180.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-b-crc-sprite-planes-basic.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-b-missing-ccs-buffer.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-c-bad-aux-stride.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-c-bad-pixel-format.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-c-bad-rotation-90.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-c-ccs-on-another-bo.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-c-crc-primary-basic.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-c-crc-primary-rotation-180.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-c-crc-sprite-planes-basic.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_...@pipe-c-missing-ccs-buffer.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_draw_...@draw-method-rgb565-mmap-cpu-xtiled.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_draw_...@draw-method-rgb565-mmap-cpu-ytiled.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_draw_...@draw-method-rgb565-mmap-wc-xtiled.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_draw_...@draw-method-rgb565-mmap-wc-ytiled.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_draw_...@draw-method-rgb565-pwrite-xtiled.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_draw_...@draw-method-rgb565-pwrite-ytiled.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_draw_...@draw-method-xrgb2101010-mmap-cpu-xtiled.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_draw_...@draw-method-xrgb2101010-mmap-cpu-ytiled.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_draw_...@draw-method-xrgb2101010-mmap-wc-xtiled.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_draw_...@draw-method-xrgb2101010-mmap-wc-ytiled.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_draw_...@draw-method-xrgb2101010-pwrite-xtiled.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_draw_...@draw-method-xrgb2101010-pwrite-ytiled.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_draw_...@draw-method-xrgb-mmap-cpu-xtiled.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@kms_draw_...@draw-method-xrgb-mmap-cpu-ytiled.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-c

[Bug 110514] [CI][BAT] igt@* - skip - Test requirement: is_i915_device(fd) && has_known_intel_chipset(fd), Skip

2019-04-26 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110514

--- Comment #16 from CI Bug Log  ---
A CI Bug Log filter associated to this bug has been updated:

{- CML: igt@*stolen* - skip - Test requirement:
gem_create__has_stolen_support(fd) && (gem_total_stolen_size(fd) >
0), SKIP -}
{+ CML: igt@*stolen* - skip - Test requirement:
gem_create__has_stolen_support(fd) && (gem_total_stolen_size(fd) >
0), SKIP +}

New failures caught by the filter:

  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@gem_cre...@stolen-invalid-flag.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@gem_pr...@stolen-display.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@gem_pr...@stolen-normal.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@gem_pr...@stolen-snoop.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@gem_pr...@stolen-uncached.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@gem_pwr...@stolen-display.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@gem_pwr...@stolen-normal.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@gem_pwr...@stolen-snoop.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@gem_pwr...@stolen-uncached.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@gem_sto...@large-object-alloc.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@gem_sto...@stolen-clear.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@gem_sto...@stolen-copy.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@gem_sto...@stolen-fill-purge.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@gem_sto...@stolen-no-mmap.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@gem_sto...@stolen-pread.html
  *
https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6001/re-cml-u/igt@gem_sto...@stolen-pwrite.html

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 110514] [CI][BAT] igt@* - skip - Test requirement: is_i915_device(fd) && has_known_intel_chipset(fd), Skip

2019-04-26 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110514

--- Comment #17 from CI Bug Log  ---
A CI Bug Log filter associated to this bug has been updated:

{- CML: all tests - skip - Test requirement: intel_gen(intel_get_drm_devid(fd))
>= 5, SKIP -}
{+ CML: all tests - skip - Test requirement: intel_gen(intel_get_drm_devid(fd))
>= 5, SKIP +}


  No new failures caught with the new filter

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 1/3] drm/amd/display: Fix and simplify apply_below_the_range()

2019-04-26 Thread Mario Kleiner
The comparison of inserted_frame_duration_in_us against a
duration calculated from max_refresh_in_uhz is both wrong
in its math and not needed, as the min_duration_in_us value
is already cached in in_out_vrr for reuse. No need to
recalculate it wrongly at each invocation.

Signed-off-by: Mario Kleiner 
Reviewed-by: Nicholas Kazlauskas 
---
 drivers/gpu/drm/amd/display/modules/freesync/freesync.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c 
b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
index 71274683da04..e56543c36eba 100644
--- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
+++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
@@ -437,10 +437,8 @@ static void apply_below_the_range(struct core_freesync 
*core_freesync,
inserted_frame_duration_in_us = last_render_time_in_us /
frames_to_insert;
 
-   if (inserted_frame_duration_in_us <
-   (100 / in_out_vrr->max_refresh_in_uhz))
-   inserted_frame_duration_in_us =
-   (100 / in_out_vrr->max_refresh_in_uhz);
+   if (inserted_frame_duration_in_us < 
in_out_vrr->min_duration_in_us)
+   inserted_frame_duration_in_us = 
in_out_vrr->min_duration_in_us;
 
/* Cache the calculated variables */
in_out_vrr->btr.inserted_duration_in_us =
-- 
2.20.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

VRR BTR patches revision 2

2019-04-26 Thread Mario Kleiner
Updated series. The debug patch is dropped, a r-b by Nicholas is tacked
onto patch 1/3 and patch 3/3 has the locking fix that Nicholas proposed.
In terms of testing 3/3 didn't change anything for the better or worse,
observed behaviour on retested DCN-1 and DCE-8 is the same.
Patch 2/3 is identical.

For reference i made a little git repo with a cleaned up version
of my test script VRRTest.m and some pdf's with some plots from my
testing with a slightly earlier version of that script:

https://github.com/kleinerm/VRRTestPlots

Easy to use on a Debian/Ubuntu based system as you can get GNU/Octave
+ psychtoolbox-3 from the distro repo. Explanations in the Readm

The following plots illustrate how patch 2/3 can sometimes help to
make transition to BTR a bit smoother min VRR was 25 Hz or 40 msecs
in this test case on DCE8 and 30 Hz or 33 msecs on DCE11.

Without patch 2/3:

https://github.com/kleinerm/VRRTestPlots/blob/master/VRR_DCE8_2upstepping_VUPDATEbtr+removehysteresispatch.pdf
https://github.com/kleinerm/VRRTestPlots/blob/master/VRR_DCE11_2upstepping_VUPDATEbtr+removehysteresispatch.pdf

With patch 2/3:

https://github.com/kleinerm/VRRTestPlots/blob/master/VRR_DCE11_2upstepping_VUPDATEbtr.pdf
https://github.com/kleinerm/VRRTestPlots/blob/master/VRR_DCE8_2upstepping_VUPDATEbtr.pdf

-mario


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 2/3] drm/amd/display: Enter VRR BTR earlier.

2019-04-26 Thread Mario Kleiner
Use a 2 msecs switching headroom not only for slightly
delayed exiting of BTR mode, but now also for entering
it a bit before the max frame duration is exceeded.

With slowly changing time delay between successive flips
or with a bit of jitter in arrival of flips, this adapts
vblank early and prevents missed vblanks at the border
between non-BTR and BTR.

Testing on DCE-8, DCE-11 and DCN-1.0 shows that this more
often avoids skipped frames when moving across the BTR
boundary, especially on DCE-8 and DCE-11 with the followup
commit for dealing with pre-DCE-12 hw.

Signed-off-by: Mario Kleiner 
---
 drivers/gpu/drm/amd/display/modules/freesync/freesync.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c 
b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
index e56543c36eba..a965ab5466dc 100644
--- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
+++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
@@ -350,7 +350,7 @@ static void apply_below_the_range(struct core_freesync 
*core_freesync,
in_out_vrr->btr.frame_counter = 0;
in_out_vrr->btr.btr_active = false;
}
-   } else if (last_render_time_in_us > max_render_time_in_us) {
+   } else if (last_render_time_in_us + BTR_EXIT_MARGIN > 
max_render_time_in_us) {
/* Enter Below the Range */
in_out_vrr->btr.btr_active = true;
}
-- 
2.20.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 3/3] drm/amd/display: Compensate for pre-DCE12 BTR-VRR hw limitations. (v2)

2019-04-26 Thread Mario Kleiner
Pre-DCE12 needs special treatment for BTR / low framerate
compensation for more stable behaviour:

According to comments in the code and some testing on DCE-8
and DCE-11, DCE-11 and earlier only apply VTOTAL_MIN/MAX
programming with a lag of one frame, so the special BTR hw
programming for intermediate fixed duration frames must be
done inside the current frame at flip submission in atomic
commit tail, ie. one vblank earlier, and the fixed refresh
intermediate frame mode must be also terminated one vblank
earlier on pre-DCE12 display engines.

To achieve proper termination on < DCE-12 shift the point
when the switch-back from fixed vblank duration to variable
vblank duration happens from the start of VBLANK (vblank irq,
as done on DCE-12+) to back-porch or end of VBLANK (handled
by vupdate irq handler). We must leave the switch-back code
inside VBLANK irq for DCE12+, as before.

Doing this, we get much better behaviour of BTR for up-sweeps,
ie. going from short to long frame durations (~high to low fps)
and for constant framerate flips, as tested on DCE-8 and
DCE-11. Behaviour is still not quite as good as on DCN-1
though.

On down-sweeps, going from long to short frame durations
(low fps to high fps) < DCE-12 is a little bit improved,
although by far not as much as for up-sweeps and constant
fps.

v2: Fix some wrong locking, as pointed out by Nicholas.
Signed-off-by: Mario Kleiner 
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 45 +--
 1 file changed, 42 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 76b6e621793f..7241e1f3ebec 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -364,6 +364,7 @@ static void dm_vupdate_high_irq(void *interrupt_params)
struct amdgpu_device *adev = irq_params->adev;
struct amdgpu_crtc *acrtc;
struct dm_crtc_state *acrtc_state;
+   unsigned long flags;
 
acrtc = get_crtc_by_otg_inst(adev, irq_params->irq_src - 
IRQ_TYPE_VUPDATE);
 
@@ -381,6 +382,22 @@ static void dm_vupdate_high_irq(void *interrupt_params)
 */
if (amdgpu_dm_vrr_active(acrtc_state))
drm_crtc_handle_vblank(&acrtc->base);
+
+   if (acrtc_state->stream && adev->family < AMDGPU_FAMILY_AI &&
+   acrtc_state->vrr_params.supported &&
+   acrtc_state->freesync_config.state == 
VRR_STATE_ACTIVE_VARIABLE) {
+   spin_lock_irqsave(&adev->ddev->event_lock, flags);
+   mod_freesync_handle_v_update(
+   adev->dm.freesync_module,
+   acrtc_state->stream,
+   &acrtc_state->vrr_params);
+
+   dc_stream_adjust_vmin_vmax(
+   adev->dm.dc,
+   acrtc_state->stream,
+   &acrtc_state->vrr_params.adjust);
+   spin_unlock_irqrestore(&adev->ddev->event_lock, flags);
+   }
}
 }
 
@@ -390,6 +407,7 @@ static void dm_crtc_high_irq(void *interrupt_params)
struct amdgpu_device *adev = irq_params->adev;
struct amdgpu_crtc *acrtc;
struct dm_crtc_state *acrtc_state;
+   unsigned long flags;
 
acrtc = get_crtc_by_otg_inst(adev, irq_params->irq_src - 
IRQ_TYPE_VBLANK);
 
@@ -412,9 +430,10 @@ static void dm_crtc_high_irq(void *interrupt_params)
 */
amdgpu_dm_crtc_handle_crc_irq(&acrtc->base);
 
-   if (acrtc_state->stream &&
+   if (acrtc_state->stream && adev->family >= AMDGPU_FAMILY_AI &&
acrtc_state->vrr_params.supported &&
acrtc_state->freesync_config.state == 
VRR_STATE_ACTIVE_VARIABLE) {
+   spin_lock_irqsave(&adev->ddev->event_lock, flags);
mod_freesync_handle_v_update(
adev->dm.freesync_module,
acrtc_state->stream,
@@ -424,6 +443,7 @@ static void dm_crtc_high_irq(void *interrupt_params)
adev->dm.dc,
acrtc_state->stream,
&acrtc_state->vrr_params.adjust);
+   spin_unlock_irqrestore(&adev->ddev->event_lock, flags);
}
}
 }
@@ -4878,8 +4898,10 @@ static void update_freesync_state_on_stream(
struct dc_plane_state *surface,
u32 flip_timestamp_in_us)
 {
-   struct mod_vrr_params vrr_params = new_crtc_state->vrr_params;
+   struct mod_vrr_params vrr_params;
struct dc_info_packet vrr_infopacket = {0};
+   struct amdgpu_device *adev = dm->adev;
+   unsigned long flags;
 
if (!new_stream)
return;
@@ -4892,6 +4914,9 @@ static void update_freesync_stat

[Bug 110514] [CI][BAT] igt@* - skip - Test requirement: is_i915_device(fd) && has_known_intel_chipset(fd), Skip

2019-04-26 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110514

--- Comment #18 from Martin Peres  ---
(In reply to Petri Latvala from comment #13)
> (In reply to CI Bug Log from comment #8)
> > The CI Bug Log issue associated to this bug has been updated.
> > 
> > ### New filters associated
> > 
> > * CML: igt@*stolen* - skip - Test requirement:
> > gem_create__has_stolen_support(fd) && (gem_total_stolen_size(fd)
> > > 0), SKIP
> 
> 
> This one is a different issue, isn't it?

More info from Petri: this should be a separate bug as it uses an ioctl call to
get this information, so this bug has nothing to do with it.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 109294] [CI][SHARDS] igt@prime_vgem@basic-fence-flip - skip - Test requirement: (crtc_id = set_fb_on_crtc(i915, 0, &bo[0], fb_id[0])), SKIP

2019-04-26 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=109294

--- Comment #8 from Chris Wilson  ---
*** Bug 110531 has been marked as a duplicate of this bug. ***

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH] drm: support gpu aliases defined in DT data

2019-04-26 Thread Tomi Valkeinen
On 17/04/2019 20:42, Emil Velikov wrote:

> Have you looked at the libdrm drmDevice2 (yes use the second version) API?
> It provides various information about the different devices, yet if
> it's missing anything do send us a patch ;-)

No, I didn't notice that. At least with a quick look, looks good. I'll
give it a try. Thanks!

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Bug 201273] Fatal error during GPU init amdgpu RX560

2019-04-26 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=201273

--- Comment #44 from quirin.blae...@freenet.de ---
(In reply to Alex Deucher from comment #43)
> Does booting with any of the following options on the kernel command line in
> grub help?
> amd_iommu=off
> idle=nomwait
> iommu=pt
> pci=noats
> Can you also try different IOMMU and SVM settings in the sbios?  E.g.,
> change from "auto" to "enabled" or "disabled".

I´ll try idle=nomwait iommu=pt pci=noats for now
iommu and svm are still enabled in BIOS

-- 
You are receiving this mail because:
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH] staging: xgifb: delete the driver

2019-04-26 Thread Daniel Vetter
On Fri, Apr 26, 2019 at 2:42 AM Aaro Koskinen  wrote:
> On Fri, Jan 18, 2019 at 12:20:28PM +0100, Daniel Vetter wrote:
> > On Fri, Jan 18, 2019 at 11:08:28AM +0100, Greg Kroah-Hartman wrote:
> > > There has not been any real work done on cleaning this driver up and
> > > getting it out of the staging tree in years.  Also, no new fb drivers
> > > are being added to the tree, so it should be converted into a drm driver
> > > as well.
> > >
> > > Due to the lack of interest in this codebase, just drop it.
> > >
> > > Cc: Arnaud Patard 
> > > Cc: Mauro Carvalho Chehab 
> > > Reported-by: Daniel Vetter 
> > > Signed-off-by: Greg Kroah-Hartman 
> >
> > Acked-by: Daniel Vetter 
>
> Because of this I just lost fb/display on two of my computers...
>
> So I guess to reintroduce the support for this HW I need to write a new
> DRM driver and no staging work anymore. Which of the current DRM drivers
> would be best to be used as a template/example for a new driver?

For a simple driver pick any of the recently merged ones using the
drm_simple_display_pipe helpers, those will get rid of all the
boilerplate for you. If you have vram, you might need the in-flight
vram helpers that currently are worked on by Thomas Zimmermann (they
refactor simple vram handling from about 5 drivers into a new helper,
with the goal to make porting fbdev drivers even easier).
-Daniel




--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH 1/2] drm/stm: ltdc: manage the get_irq probe defer case

2019-04-26 Thread Philippe CORNU
Hi Fabien,
and thank you for your patch,

Acked-by: Philippe Cornu 

Philippe :-)

On 4/24/19 4:03 PM, Fabien Dessenne wrote:
> Manage the -EPROBE_DEFER error case for the ltdc IRQ.
> 
> Signed-off-by: Fabien Dessenne 
> ---
>   drivers/gpu/drm/stm/ltdc.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
> index 566b0d8..521ba83 100644
> --- a/drivers/gpu/drm/stm/ltdc.c
> +++ b/drivers/gpu/drm/stm/ltdc.c
> @@ -1174,6 +1174,9 @@ int ltdc_load(struct drm_device *ddev)
>   
>   for (i = 0; i < MAX_IRQ; i++) {
>   irq = platform_get_irq(pdev, i);
> + if (irq == -EPROBE_DEFER)
> + goto err;
> +
>   if (irq < 0)
>   continue;
>   
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH 2/2] drm/stm: ltdc: return appropriate error code during probe

2019-04-26 Thread Philippe CORNU
Hi Fabien,
and thank you for your patch,

Acked-by: Philippe Cornu 

Philippe :-)

On 4/24/19 4:03 PM, Fabien Dessenne wrote:
> During probe, return the "clk_get" error value instead of -ENODEV.
> 
> Signed-off-by: Fabien Dessenne 
> ---
>   drivers/gpu/drm/stm/ltdc.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
> index 521ba83..97912e2 100644
> --- a/drivers/gpu/drm/stm/ltdc.c
> +++ b/drivers/gpu/drm/stm/ltdc.c
> @@ -1145,8 +1145,9 @@ int ltdc_load(struct drm_device *ddev)
>   
>   ldev->pixel_clk = devm_clk_get(dev, "lcd");
>   if (IS_ERR(ldev->pixel_clk)) {
> - DRM_ERROR("Unable to get lcd clock\n");
> - return -ENODEV;
> + if (PTR_ERR(ldev->pixel_clk) != -EPROBE_DEFER)
> + DRM_ERROR("Unable to get lcd clock\n");
> + return PTR_ERR(ldev->pixel_clk);
>   }
>   
>   if (clk_prepare_enable(ldev->pixel_clk)) {
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 06/12] dma-buf: add optional invalidate_mappings callback v5

2019-04-26 Thread Christian König
Each importer can now provide an invalidate_mappings callback.

This allows the exporter to provide the mappings without the need to pin
the backing store.

v2: don't try to invalidate mappings when the callback is NULL,
lock the reservation obj while using the attachments,
add helper to set the callback
v3: move flag for invalidation support into the DMA-buf,
use new attach_info structure to set the callback
v4: use importer_priv field instead of mangling exporter priv.
v5: drop invalidation_supported flag

Signed-off-by: Christian König 
---
 drivers/dma-buf/dma-buf.c | 51 +--
 include/linux/dma-buf.h   | 30 +--
 2 files changed, 71 insertions(+), 10 deletions(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 95bcd2ed795b..1b5cdae68cd6 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -607,7 +607,9 @@ dma_buf_attach(const struct dma_buf_attach_info *info)
if (ret)
goto err_attach;
}
+   reservation_object_lock(dmabuf->resv, NULL);
list_add(&attach->node, &dmabuf->attachments);
+   reservation_object_unlock(dmabuf->resv);
 
mutex_unlock(&dmabuf->lock);
 
@@ -651,7 +653,9 @@ void dma_buf_detach(struct dma_buf *dmabuf, struct 
dma_buf_attachment *attach)
   DMA_BIDIRECTIONAL);
 
mutex_lock(&dmabuf->lock);
+   reservation_object_lock(dmabuf->resv, NULL);
list_del(&attach->node);
+   reservation_object_unlock(dmabuf->resv);
if (dmabuf->ops->detach)
dmabuf->ops->detach(dmabuf, attach);
 
@@ -672,10 +676,7 @@ EXPORT_SYMBOL_GPL(dma_buf_detach);
  * Returns sg_table containing the scatterlist to be returned; returns ERR_PTR
  * on error. May return -EINTR if it is interrupted by a signal.
  *
- * A mapping must be unmapped by using dma_buf_unmap_attachment(). Note that
- * the underlying backing storage is pinned for as long as a mapping exists,
- * therefore users/importers should not hold onto a mapping for undue amounts 
of
- * time.
+ * A mapping must be unmapped by using dma_buf_unmap_attachment().
  */
 struct sg_table *
 dma_buf_map_attachment_locked(struct dma_buf_attachment *attach,
@@ -690,11 +691,22 @@ dma_buf_map_attachment_locked(struct dma_buf_attachment 
*attach,
if (attach->sgt)
return attach->sgt;
 
-   r = dma_buf_pin(attach->dmabuf);
-   if (r)
-   return ERR_PTR(r);
+   if (attach->invalidate) {
+   /*
+* Mapping a DMA-buf can trigger its invalidation, prevent
+* sending this event to the caller by temporary removing
+* this attachment from the list.
+*/
+   list_del(&attach->node);
+   } else {
+   r = dma_buf_pin(attach->dmabuf);
+   if (r)
+   return ERR_PTR(r);
+   }
 
sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
+   if (attach->invalidate)
+   list_add(&attach->node, &attach->dmabuf->attachments);
if (!sg_table)
return ERR_PTR(-ENOMEM);
 
@@ -761,7 +773,8 @@ void dma_buf_unmap_attachment_locked(struct 
dma_buf_attachment *attach,
 
attach->dmabuf->ops->unmap_dma_buf(attach, sg_table,
direction);
-   dma_buf_unpin(attach->dmabuf);
+   if (!attach->invalidate)
+   dma_buf_unpin(attach->dmabuf);
 }
 EXPORT_SYMBOL_GPL(dma_buf_unmap_attachment_locked);
 
@@ -793,6 +806,26 @@ void dma_buf_unmap_attachment(struct dma_buf_attachment 
*attach,
 }
 EXPORT_SYMBOL_GPL(dma_buf_unmap_attachment);
 
+/**
+ * dma_buf_invalidate_mappings - invalidate all mappings of this dma_buf
+ *
+ * @dmabuf:[in]buffer which mappings should be invalidated
+ *
+ * Informs all attachmenst that they need to destroy and recreated all their
+ * mappings.
+ */
+void dma_buf_invalidate_mappings(struct dma_buf *dmabuf)
+{
+   struct dma_buf_attachment *attach;
+
+   reservation_object_assert_held(dmabuf->resv);
+
+   list_for_each_entry(attach, &dmabuf->attachments, node)
+   if (attach->invalidate)
+   attach->invalidate(attach);
+}
+EXPORT_SYMBOL_GPL(dma_buf_invalidate_mappings);
+
 /**
  * DOC: cpu access
  *
@@ -1205,10 +1238,12 @@ static int dma_buf_debug_show(struct seq_file *s, void 
*unused)
seq_puts(s, "\tAttached Devices:\n");
attach_count = 0;
 
+   reservation_object_lock(buf_obj->resv, NULL);
list_for_each_entry(attach_obj, &buf_obj->attachments, node) {
seq_printf(s, "\t%s\n", dev_name(attach_obj->dev));
attach_count++;
}
+   reservation_object_unlock(buf_obj->resv);
 
seq_printf(s, "Total %d devices attached\n\n",

[PATCH 04/12] dma-buf: lock the reservation object during (un)map_dma_buf v4

2019-04-26 Thread Christian König
This way we always call the the map/unmap callbacks with the reservation
object held if pin/unpin is also implemented.

For static dma-buf exporters we still have the fallback of using cached sgt.

v2: reordered
v3: rebased on sgt caching
v4: use the cached sgt when possible
v5: cleanup further

Signed-off-by: Christian König 
---
 drivers/dma-buf/dma-buf.c | 10 +-
 include/linux/dma-buf.h   |  3 +++
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index a18d10c4425a..0aa97bb05636 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -691,13 +691,15 @@ struct sg_table *dma_buf_map_attachment(struct 
dma_buf_attachment *attach,
 
reservation_object_lock(attach->dmabuf->resv, NULL);
r = dma_buf_pin(attach->dmabuf);
-   reservation_object_unlock(attach->dmabuf->resv);
-   if (r)
+   if (r) {
+   reservation_object_unlock(attach->dmabuf->resv);
return ERR_PTR(r);
+   }
 
sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
if (!sg_table)
sg_table = ERR_PTR(-ENOMEM);
+   reservation_object_unlock(attach->dmabuf->resv);
 
return sg_table;
 }
@@ -725,10 +727,8 @@ void dma_buf_unmap_attachment(struct dma_buf_attachment 
*attach,
if (attach->sgt == sg_table)
return;
 
-   attach->dmabuf->ops->unmap_dma_buf(attach, sg_table,
-   direction);
-
reservation_object_lock(attach->dmabuf->resv, NULL);
+   attach->dmabuf->ops->unmap_dma_buf(attach, sg_table, direction);
dma_buf_unpin(attach->dmabuf);
reservation_object_unlock(attach->dmabuf->resv);
 }
diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
index b9d0719581cd..425a771d229c 100644
--- a/include/linux/dma-buf.h
+++ b/include/linux/dma-buf.h
@@ -144,6 +144,9 @@ struct dma_buf_ops {
 * any other kind of sharing that the exporter might wish to make
 * available to buffer-users.
 *
+* This is always called with the dmabuf->resv object locked when
+* the pin/unpin callbacks are implemented.
+*
 * Returns:
 *
 * A &sg_table scatter list of or the backing storage of the DMA buffer,
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 07/12] drm: remove prime sg_table caching

2019-04-26 Thread Christian König
That is now done by the DMA-buf helpers instead.

Signed-off-by: Christian König 
---
 drivers/gpu/drm/drm_prime.c | 76 -
 1 file changed, 16 insertions(+), 60 deletions(-)

diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 1fadf5d5ed33..7e439ea3546a 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -86,11 +86,6 @@ struct drm_prime_member {
struct rb_node handle_rb;
 };
 
-struct drm_prime_attachment {
-   struct sg_table *sgt;
-   enum dma_data_direction dir;
-};
-
 static int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv,
struct dma_buf *dma_buf, uint32_t handle)
 {
@@ -188,25 +183,16 @@ static int drm_prime_lookup_buf_handle(struct 
drm_prime_file_private *prime_fpri
  * @dma_buf: buffer to attach device to
  * @attach: buffer attachment data
  *
- * Allocates &drm_prime_attachment and calls &drm_driver.gem_prime_pin for
- * device specific attachment. This can be used as the &dma_buf_ops.attach
- * callback.
+ * Calls &drm_driver.gem_prime_pin for device specific handling. This can be
+ * used as the &dma_buf_ops.attach callback.
  *
  * Returns 0 on success, negative error code on failure.
  */
 int drm_gem_map_attach(struct dma_buf *dma_buf,
   struct dma_buf_attachment *attach)
 {
-   struct drm_prime_attachment *prime_attach;
struct drm_gem_object *obj = dma_buf->priv;
 
-   prime_attach = kzalloc(sizeof(*prime_attach), GFP_KERNEL);
-   if (!prime_attach)
-   return -ENOMEM;
-
-   prime_attach->dir = DMA_NONE;
-   attach->priv = prime_attach;
-
return drm_gem_pin(obj);
 }
 EXPORT_SYMBOL(drm_gem_map_attach);
@@ -222,26 +208,8 @@ EXPORT_SYMBOL(drm_gem_map_attach);
 void drm_gem_map_detach(struct dma_buf *dma_buf,
struct dma_buf_attachment *attach)
 {
-   struct drm_prime_attachment *prime_attach = attach->priv;
struct drm_gem_object *obj = dma_buf->priv;
 
-   if (prime_attach) {
-   struct sg_table *sgt = prime_attach->sgt;
-
-   if (sgt) {
-   if (prime_attach->dir != DMA_NONE)
-   dma_unmap_sg_attrs(attach->dev, sgt->sgl,
-  sgt->nents,
-  prime_attach->dir,
-  DMA_ATTR_SKIP_CPU_SYNC);
-   sg_free_table(sgt);
-   }
-
-   kfree(sgt);
-   kfree(prime_attach);
-   attach->priv = NULL;
-   }
-
drm_gem_unpin(obj);
 }
 EXPORT_SYMBOL(drm_gem_map_detach);
@@ -286,39 +254,22 @@ void drm_prime_remove_buf_handle_locked(struct 
drm_prime_file_private *prime_fpr
 struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach,
 enum dma_data_direction dir)
 {
-   struct drm_prime_attachment *prime_attach = attach->priv;
struct drm_gem_object *obj = attach->dmabuf->priv;
struct sg_table *sgt;
 
-   if (WARN_ON(dir == DMA_NONE || !prime_attach))
+   if (WARN_ON(dir == DMA_NONE))
return ERR_PTR(-EINVAL);
 
-   /* return the cached mapping when possible */
-   if (prime_attach->dir == dir)
-   return prime_attach->sgt;
-
-   /*
-* two mappings with different directions for the same attachment are
-* not allowed
-*/
-   if (WARN_ON(prime_attach->dir != DMA_NONE))
-   return ERR_PTR(-EBUSY);
-
if (obj->funcs)
sgt = obj->funcs->get_sg_table(obj);
else
sgt = obj->dev->driver->gem_prime_get_sg_table(obj);
 
-   if (!IS_ERR(sgt)) {
-   if (!dma_map_sg_attrs(attach->dev, sgt->sgl, sgt->nents, dir,
- DMA_ATTR_SKIP_CPU_SYNC)) {
-   sg_free_table(sgt);
-   kfree(sgt);
-   sgt = ERR_PTR(-ENOMEM);
-   } else {
-   prime_attach->sgt = sgt;
-   prime_attach->dir = dir;
-   }
+   if (!dma_map_sg_attrs(attach->dev, sgt->sgl, sgt->nents, dir,
+ DMA_ATTR_SKIP_CPU_SYNC)) {
+   sg_free_table(sgt);
+   kfree(sgt);
+   sgt = ERR_PTR(-ENOMEM);
}
 
return sgt;
@@ -331,14 +282,19 @@ EXPORT_SYMBOL(drm_gem_map_dma_buf);
  * @sgt: scatterlist info of the buffer to unmap
  * @dir: direction of DMA transfer
  *
- * Not implemented. The unmap is done at drm_gem_map_detach().  This can be
- * used as the &dma_buf_ops.unmap_dma_buf callback.
+ * This can be used as the &dma_buf_ops.unmap_dma_buf callback.
  */
 void drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach,
   struct sg_table *sgt,
  

[PATCH 02/12] dma-buf: add explicit buffer pinning v2

2019-04-26 Thread Christian König
Add optional explicit pinning callbacks instead of implicitly assume the
exporter pins the buffer when a mapping is created.

v2: move in patchset and pin the dma-buf in the old mapping code paths.

Signed-off-by: Christian König 
---
 drivers/dma-buf/dma-buf.c | 49 ++-
 include/linux/dma-buf.h   | 38 +-
 2 files changed, 80 insertions(+), 7 deletions(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 50b4c6af04c7..0656dcf289be 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -529,6 +529,41 @@ void dma_buf_put(struct dma_buf *dmabuf)
 }
 EXPORT_SYMBOL_GPL(dma_buf_put);
 
+/**
+ * dma_buf_pin - Lock down the DMA-buf
+ *
+ * @dmabuf:[in]DMA-buf to lock down.
+ *
+ * Returns:
+ * 0 on success, negative error code on failure.
+ */
+int dma_buf_pin(struct dma_buf *dmabuf)
+{
+   int ret = 0;
+
+   reservation_object_assert_held(dmabuf->resv);
+
+   if (dmabuf->ops->pin)
+   ret = dmabuf->ops->pin(dmabuf);
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(dma_buf_pin);
+
+/**
+ * dma_buf_unpin - Remove lock from DMA-buf
+ *
+ * @dmabuf:[in]DMA-buf to unlock.
+ */
+void dma_buf_unpin(struct dma_buf *dmabuf)
+{
+   reservation_object_assert_held(dmabuf->resv);
+
+   if (dmabuf->ops->unpin)
+   dmabuf->ops->unpin(dmabuf);
+}
+EXPORT_SYMBOL_GPL(dma_buf_unpin);
+
 /**
  * dma_buf_attach - Add the device to dma_buf's attachments list; optionally,
  * calls attach() of dma_buf_ops to allow device-specific attach functionality
@@ -548,7 +583,8 @@ EXPORT_SYMBOL_GPL(dma_buf_put);
  * accessible to @dev, and cannot be moved to a more suitable place. This is
  * indicated with the error code -EBUSY.
  */
-struct dma_buf_attachment *dma_buf_attach(const struct dma_buf_attach_info 
*info)
+struct dma_buf_attachment *
+dma_buf_attach(const struct dma_buf_attach_info *info)
 {
struct dma_buf *dmabuf = info->dmabuf;
struct dma_buf_attachment *attach;
@@ -625,12 +661,19 @@ struct sg_table *dma_buf_map_attachment(struct 
dma_buf_attachment *attach,
enum dma_data_direction direction)
 {
struct sg_table *sg_table;
+   int r;
 
might_sleep();
 
if (WARN_ON(!attach || !attach->dmabuf))
return ERR_PTR(-EINVAL);
 
+   reservation_object_lock(attach->dmabuf->resv, NULL);
+   r = dma_buf_pin(attach->dmabuf);
+   reservation_object_unlock(attach->dmabuf->resv);
+   if (r)
+   return ERR_PTR(r);
+
sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
if (!sg_table)
sg_table = ERR_PTR(-ENOMEM);
@@ -660,6 +703,10 @@ void dma_buf_unmap_attachment(struct dma_buf_attachment 
*attach,
 
attach->dmabuf->ops->unmap_dma_buf(attach, sg_table,
direction);
+
+   reservation_object_lock(attach->dmabuf->resv, NULL);
+   dma_buf_unpin(attach->dmabuf);
+   reservation_object_unlock(attach->dmabuf->resv);
 }
 EXPORT_SYMBOL_GPL(dma_buf_unmap_attachment);
 
diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
index 2c312dfd31a1..0321939b1c3d 100644
--- a/include/linux/dma-buf.h
+++ b/include/linux/dma-buf.h
@@ -51,6 +51,34 @@ struct dma_buf_attachment;
  * @vunmap: [optional] unmaps a vmap from the buffer
  */
 struct dma_buf_ops {
+   /**
+* @pin:
+*
+* This is called by dma_buf_pin and lets the exporter know that the
+* DMA-buf can't be moved any more.
+*
+* This is called with the dmabuf->resv object locked.
+*
+* This callback is optional.
+*
+* Returns:
+*
+* 0 on success, negative error code on failure.
+*/
+   int (*pin)(struct dma_buf *);
+
+   /**
+* @unpin:
+*
+* This is called by dma_buf_unpin and lets the exporter know that the
+* DMA-buf can be moved again.
+*
+* This is called with the dmabuf->resv object locked.
+*
+* This callback is optional.
+*/
+   void (*unpin)(struct dma_buf *);
+
/**
 * @attach:
 *
@@ -95,9 +123,7 @@ struct dma_buf_ops {
 *
 * This is called by dma_buf_map_attachment() and is used to map a
 * shared &dma_buf into device address space, and it is mandatory. It
-* can only be called if @attach has been called successfully. This
-* essentially pins the DMA buffer into place, and it cannot be moved
-* any more
+* can only be called if @attach has been called successfully.
 *
 * This call may sleep, e.g. when the backing storage first needs to be
 * allocated, or moved to a location suitable for all currently attached
@@ -135,9 +161,6 @@ struct dma_buf_ops {
 *
 * This is called by dma_buf_unmap_attachment() and

[PATCH 11/12] drm/amdgpu: add independent DMA-buf import v4

2019-04-26 Thread Christian König
Instead of relying on the DRM functions just implement our own import
functions. This prepares support for taking care of unpinned DMA-buf.

v2: enable for all exporters, not just amdgpu, fix invalidation
handling, lock reservation object while setting callback
v3: change to new dma_buf attach interface
v4: split out from unpinned DMA-buf work

Signed-off-by: Christian König 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   |  1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h   |  4 ---
 drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 42 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c   | 34 +++---
 4 files changed, 56 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index f1815223a1a1..95195c427e85 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1254,7 +1254,6 @@ static struct drm_driver kms_driver = {
.gem_prime_export = amdgpu_gem_prime_export,
.gem_prime_import = amdgpu_gem_prime_import,
.gem_prime_res_obj = amdgpu_gem_prime_res_obj,
-   .gem_prime_import_sg_table = amdgpu_gem_prime_import_sg_table,
.gem_prime_vmap = amdgpu_gem_prime_vmap,
.gem_prime_vunmap = amdgpu_gem_prime_vunmap,
.gem_prime_mmap = amdgpu_gem_prime_mmap,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h
index 0c50d14a9739..01811d8aa8a9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h
@@ -39,10 +39,6 @@ int amdgpu_gem_object_open(struct drm_gem_object *obj,
 void amdgpu_gem_object_close(struct drm_gem_object *obj,
struct drm_file *file_priv);
 unsigned long amdgpu_gem_timeout(uint64_t timeout_ns);
-struct drm_gem_object *
-amdgpu_gem_prime_import_sg_table(struct drm_device *dev,
-struct dma_buf_attachment *attach,
-struct sg_table *sg);
 struct dma_buf *amdgpu_gem_prime_export(struct drm_device *dev,
struct drm_gem_object *gobj,
int flags);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
index cdc3c1e63a68..662cd99980cb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
@@ -122,31 +122,28 @@ int amdgpu_gem_prime_mmap(struct drm_gem_object *obj, 
struct vm_area_struct *vma
 }
 
 /**
- * amdgpu_gem_prime_import_sg_table - &drm_driver.gem_prime_import_sg_table
- * implementation
+ * amdgpu_gem_prime_create_obj - create BO for DMA-buf import
+ *
  * @dev: DRM device
- * @attach: DMA-buf attachment
- * @sg: Scatter/gather table
+ * @dma_buf: DMA-buf
  *
- * Imports shared DMA buffer memory exported by another device.
+ * Creates an empty SG BO for DMA-buf import.
  *
  * Returns:
  * A new GEM BO of the given DRM device, representing the memory
  * described by the given DMA-buf attachment and scatter/gather table.
  */
-struct drm_gem_object *
-amdgpu_gem_prime_import_sg_table(struct drm_device *dev,
-struct dma_buf_attachment *attach,
-struct sg_table *sg)
+static struct drm_gem_object *
+amdgpu_gem_prime_create_obj(struct drm_device *dev, struct dma_buf *dma_buf)
 {
-   struct reservation_object *resv = attach->dmabuf->resv;
+   struct reservation_object *resv = dma_buf->resv;
struct amdgpu_device *adev = dev->dev_private;
struct amdgpu_bo *bo;
struct amdgpu_bo_param bp;
int ret;
 
memset(&bp, 0, sizeof(bp));
-   bp.size = attach->dmabuf->size;
+   bp.size = dma_buf->size;
bp.byte_align = PAGE_SIZE;
bp.domain = AMDGPU_GEM_DOMAIN_CPU;
bp.flags = 0;
@@ -157,11 +154,9 @@ amdgpu_gem_prime_import_sg_table(struct drm_device *dev,
if (ret)
goto error;
 
-   bo->tbo.sg = sg;
-   bo->tbo.ttm->sg = sg;
bo->allowed_domains = AMDGPU_GEM_DOMAIN_GTT;
bo->preferred_domains = AMDGPU_GEM_DOMAIN_GTT;
-   if (attach->dmabuf->ops != &amdgpu_dmabuf_ops)
+   if (dma_buf->ops != &amdgpu_dmabuf_ops)
bo->prime_shared_count = 1;
 
ww_mutex_unlock(&resv->lock);
@@ -477,6 +472,11 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_device 
*dev,
 struct drm_gem_object *amdgpu_gem_prime_import(struct drm_device *dev,
struct dma_buf *dma_buf)
 {
+   struct dma_buf_attach_info attach_info = {
+   .dev = dev->dev,
+   .dmabuf = dma_buf,
+   };
+   struct dma_buf_attachment *attach;
struct drm_gem_object *obj;
 
if (dma_buf->ops == &amdgpu_dmabuf_ops) {
@@ -491,5 +491,17 @@ struct drm_gem_object *amdgpu_gem_prime_import(struct 
drm_device *dev,
}
}
 
- 

[PATCH 05/12] dma-buf: add dma_buf_(un)map_attachment_locked variants v4

2019-04-26 Thread Christian König
Add function variants which can be called with the reservation lock
already held.

v2: reordered, add lockdep asserts, fix kerneldoc
v3: rebased on sgt caching
v4: reorder once more

Signed-off-by: Christian König 
---
 drivers/dma-buf/dma-buf.c | 83 +--
 include/linux/dma-buf.h   |  5 +++
 2 files changed, 76 insertions(+), 12 deletions(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 0aa97bb05636..95bcd2ed795b 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -660,6 +660,48 @@ void dma_buf_detach(struct dma_buf *dmabuf, struct 
dma_buf_attachment *attach)
 }
 EXPORT_SYMBOL_GPL(dma_buf_detach);
 
+/**
+ * dma_buf_map_attachment_locked - Maps the buffer into _device_ address space
+ * with the reservation lock held. Is a wrapper for map_dma_buf() of the
+ *
+ * Returns the scatterlist table of the attachment;
+ * dma_buf_ops.
+ * @attach:[in]attachment whose scatterlist is to be returned
+ * @direction: [in]direction of DMA transfer
+ *
+ * Returns sg_table containing the scatterlist to be returned; returns ERR_PTR
+ * on error. May return -EINTR if it is interrupted by a signal.
+ *
+ * A mapping must be unmapped by using dma_buf_unmap_attachment(). Note that
+ * the underlying backing storage is pinned for as long as a mapping exists,
+ * therefore users/importers should not hold onto a mapping for undue amounts 
of
+ * time.
+ */
+struct sg_table *
+dma_buf_map_attachment_locked(struct dma_buf_attachment *attach,
+ enum dma_data_direction direction)
+{
+   struct sg_table *sg_table;
+   int r;
+
+   might_sleep();
+   reservation_object_assert_held(attach->dmabuf->resv);
+
+   if (attach->sgt)
+   return attach->sgt;
+
+   r = dma_buf_pin(attach->dmabuf);
+   if (r)
+   return ERR_PTR(r);
+
+   sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
+   if (!sg_table)
+   return ERR_PTR(-ENOMEM);
+
+   return sg_table;
+}
+EXPORT_SYMBOL_GPL(dma_buf_map_attachment_locked);
+
 /**
  * dma_buf_map_attachment - Returns the scatterlist table of the attachment;
  * mapped into _device_ address space. Is a wrapper for map_dma_buf() of the
@@ -679,7 +721,6 @@ struct sg_table *dma_buf_map_attachment(struct 
dma_buf_attachment *attach,
enum dma_data_direction direction)
 {
struct sg_table *sg_table;
-   int r;
 
might_sleep();
 
@@ -690,21 +731,40 @@ struct sg_table *dma_buf_map_attachment(struct 
dma_buf_attachment *attach,
return attach->sgt;
 
reservation_object_lock(attach->dmabuf->resv, NULL);
-   r = dma_buf_pin(attach->dmabuf);
-   if (r) {
-   reservation_object_unlock(attach->dmabuf->resv);
-   return ERR_PTR(r);
-   }
-
-   sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
-   if (!sg_table)
-   sg_table = ERR_PTR(-ENOMEM);
+   sg_table = dma_buf_map_attachment(attach, direction);
reservation_object_unlock(attach->dmabuf->resv);
 
return sg_table;
 }
 EXPORT_SYMBOL_GPL(dma_buf_map_attachment);
 
+/**
+ * dma_buf_unmap_attachment_locked - unmaps the buffer with reservation lock
+ * held, should deallocate the associated scatterlist. Is a wrapper for
+ * unmap_dma_buf() of dma_buf_ops.
+ * @attach:[in]attachment to unmap buffer from
+ * @sg_table:  [in]scatterlist info of the buffer to unmap
+ * @direction:  [in]direction of DMA transfer
+ *
+ * This unmaps a DMA mapping for @attached obtained by
+ * dma_buf_map_attachment_locked().
+ */
+void dma_buf_unmap_attachment_locked(struct dma_buf_attachment *attach,
+struct sg_table *sg_table,
+enum dma_data_direction direction)
+{
+   might_sleep();
+   reservation_object_assert_held(attach->dmabuf->resv);
+
+   if (attach->sgt == sg_table)
+   return;
+
+   attach->dmabuf->ops->unmap_dma_buf(attach, sg_table,
+   direction);
+   dma_buf_unpin(attach->dmabuf);
+}
+EXPORT_SYMBOL_GPL(dma_buf_unmap_attachment_locked);
+
 /**
  * dma_buf_unmap_attachment - unmaps and decreases usecount of the buffer;might
  * deallocate the scatterlist associated. Is a wrapper for unmap_dma_buf() of
@@ -728,8 +788,7 @@ void dma_buf_unmap_attachment(struct dma_buf_attachment 
*attach,
return;
 
reservation_object_lock(attach->dmabuf->resv, NULL);
-   attach->dmabuf->ops->unmap_dma_buf(attach, sg_table, direction);
-   dma_buf_unpin(attach->dmabuf);
+   dma_buf_unmap_attachment_locked(attach, sg_table, direction);
reservation_object_unlock(attach->dmabuf->resv);
 }
 EXPORT_SYMBOL_GPL(dma_buf_unmap_attachment);
diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
index 425a771d229c..f7d6fc049

[PATCH 09/12] drm/ttm: use the parent resv for ghost objects

2019-04-26 Thread Christian König
This way we can even pipeline imported BO evictions.

Signed-off-by: Christian König 
---
 drivers/gpu/drm/ttm/ttm_bo_util.c | 18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c 
b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 895d77d799e4..97f35c4bda35 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -486,7 +486,6 @@ static int ttm_buffer_object_transfer(struct 
ttm_buffer_object *bo,
  struct ttm_buffer_object **new_obj)
 {
struct ttm_transfer_obj *fbo;
-   int ret;
 
fbo = kmalloc(sizeof(*fbo), GFP_KERNEL);
if (!fbo)
@@ -517,10 +516,7 @@ static int ttm_buffer_object_transfer(struct 
ttm_buffer_object *bo,
kref_init(&fbo->base.kref);
fbo->base.destroy = &ttm_transfered_destroy;
fbo->base.acc_size = 0;
-   fbo->base.resv = &fbo->base.ttm_resv;
-   reservation_object_init(fbo->base.resv);
-   ret = reservation_object_trylock(fbo->base.resv);
-   WARN_ON(!ret);
+   reservation_object_init(&fbo->base.ttm_resv);
 
*new_obj = &fbo->base;
return 0;
@@ -716,8 +712,6 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
if (ret)
return ret;
 
-   reservation_object_add_excl_fence(ghost_obj->resv, fence);
-
/**
 * If we're not moving to fixed memory, the TTM object
 * needs to stay alive. Otherwhise hang it on the ghost
@@ -729,7 +723,6 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
else
bo->ttm = NULL;
 
-   ttm_bo_unreserve(ghost_obj);
ttm_bo_put(ghost_obj);
}
 
@@ -772,8 +765,6 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
if (ret)
return ret;
 
-   reservation_object_add_excl_fence(ghost_obj->resv, fence);
-
/**
 * If we're not moving to fixed memory, the TTM object
 * needs to stay alive. Otherwhise hang it on the ghost
@@ -785,7 +776,6 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
else
bo->ttm = NULL;
 
-   ttm_bo_unreserve(ghost_obj);
ttm_bo_put(ghost_obj);
 
} else if (from->flags & TTM_MEMTYPE_FLAG_FIXED) {
@@ -841,16 +831,10 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo)
if (ret)
return ret;
 
-   ret = reservation_object_copy_fences(ghost->resv, bo->resv);
-   /* Last resort, wait for the BO to be idle when we are OOM */
-   if (ret)
-   ttm_bo_wait(bo, false, false);
-
memset(&bo->mem, 0, sizeof(bo->mem));
bo->mem.mem_type = TTM_PL_SYSTEM;
bo->ttm = NULL;
 
-   ttm_bo_unreserve(ghost);
ttm_bo_put(ghost);
 
return 0;
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 01/12] dma-buf: add struct dma_buf_attach_info

2019-04-26 Thread Christian König
Add a structure for the parameters of dma_buf_attach, this makes it much easier
to add new parameters later on.

Signed-off-by: Christian König 
---
 drivers/dma-buf/dma-buf.c   | 13 +++--
 drivers/gpu/drm/armada/armada_gem.c |  6 +-
 drivers/gpu/drm/drm_prime.c |  6 +-
 drivers/gpu/drm/i915/i915_gem_dmabuf.c  |  6 +-
 drivers/gpu/drm/tegra/gem.c |  6 +-
 drivers/gpu/drm/udl/udl_dmabuf.c|  6 +-
 .../common/videobuf2/videobuf2-dma-contig.c |  6 +-
 .../media/common/videobuf2/videobuf2-dma-sg.c   |  6 +-
 drivers/staging/media/tegra-vde/tegra-vde.c |  6 +-
 include/linux/dma-buf.h | 17 +++--
 10 files changed, 62 insertions(+), 16 deletions(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 7c858020d14b..50b4c6af04c7 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -532,8 +532,9 @@ EXPORT_SYMBOL_GPL(dma_buf_put);
 /**
  * dma_buf_attach - Add the device to dma_buf's attachments list; optionally,
  * calls attach() of dma_buf_ops to allow device-specific attach functionality
- * @dmabuf:[in]buffer to attach device to.
- * @dev:   [in]device to be attached.
+ * @info:  [in]holds all the attach related information provided
+ * by the importer. see &struct dma_buf_attach_info
+ * for further details.
  *
  * Returns struct dma_buf_attachment pointer for this attachment. Attachments
  * must be cleaned up by calling dma_buf_detach().
@@ -547,20 +548,20 @@ EXPORT_SYMBOL_GPL(dma_buf_put);
  * accessible to @dev, and cannot be moved to a more suitable place. This is
  * indicated with the error code -EBUSY.
  */
-struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
- struct device *dev)
+struct dma_buf_attachment *dma_buf_attach(const struct dma_buf_attach_info 
*info)
 {
+   struct dma_buf *dmabuf = info->dmabuf;
struct dma_buf_attachment *attach;
int ret;
 
-   if (WARN_ON(!dmabuf || !dev))
+   if (WARN_ON(!dmabuf || !info->dev))
return ERR_PTR(-EINVAL);
 
attach = kzalloc(sizeof(*attach), GFP_KERNEL);
if (!attach)
return ERR_PTR(-ENOMEM);
 
-   attach->dev = dev;
+   attach->dev = info->dev;
attach->dmabuf = dmabuf;
 
mutex_lock(&dmabuf->lock);
diff --git a/drivers/gpu/drm/armada/armada_gem.c 
b/drivers/gpu/drm/armada/armada_gem.c
index 642d0e70d0f8..19c47821032f 100644
--- a/drivers/gpu/drm/armada/armada_gem.c
+++ b/drivers/gpu/drm/armada/armada_gem.c
@@ -501,6 +501,10 @@ armada_gem_prime_export(struct drm_device *dev, struct 
drm_gem_object *obj,
 struct drm_gem_object *
 armada_gem_prime_import(struct drm_device *dev, struct dma_buf *buf)
 {
+   struct dma_buf_attach_info attach_info = {
+   .dev = dev->dev,
+   .dmabuf = buf
+   };
struct dma_buf_attachment *attach;
struct armada_gem_object *dobj;
 
@@ -516,7 +520,7 @@ armada_gem_prime_import(struct drm_device *dev, struct 
dma_buf *buf)
}
}
 
-   attach = dma_buf_attach(buf, dev->dev);
+   attach = dma_buf_attach(&attach_info);
if (IS_ERR(attach))
return ERR_CAST(attach);
 
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 231e3f6d5f41..1fadf5d5ed33 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -709,6 +709,10 @@ struct drm_gem_object *drm_gem_prime_import_dev(struct 
drm_device *dev,
struct dma_buf *dma_buf,
struct device *attach_dev)
 {
+   struct dma_buf_attach_info attach_info = {
+   .dev = attach_dev,
+   .dmabuf = dma_buf
+   };
struct dma_buf_attachment *attach;
struct sg_table *sgt;
struct drm_gem_object *obj;
@@ -729,7 +733,7 @@ struct drm_gem_object *drm_gem_prime_import_dev(struct 
drm_device *dev,
if (!dev->driver->gem_prime_import_sg_table)
return ERR_PTR(-EINVAL);
 
-   attach = dma_buf_attach(dma_buf, attach_dev);
+   attach = dma_buf_attach(&attach_info);
if (IS_ERR(attach))
return ERR_CAST(attach);
 
diff --git a/drivers/gpu/drm/i915/i915_gem_dmabuf.c 
b/drivers/gpu/drm/i915/i915_gem_dmabuf.c
index 82e2ca17a441..aa7f685bd6ca 100644
--- a/drivers/gpu/drm/i915/i915_gem_dmabuf.c
+++ b/drivers/gpu/drm/i915/i915_gem_dmabuf.c
@@ -277,6 +277,10 @@ static const struct drm_i915_gem_object_ops 
i915_gem_object_dmabuf_ops = {
 struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev,
 struct dma_buf *dma_buf)
 {
+   struct dma_buf_attach_info attach_info = {
+   .dev = dev->dev,
+   

[PATCH 10/12] drm/amdgpu: add independent DMA-buf export v3

2019-04-26 Thread Christian König
The caching of SGT's is actually quite harmful and should probably removed
altogether when all drivers are audited.

Start by providing a separate DMA-buf export implementation in amdgpu. This is
also a prerequisite of unpinned DMA-buf handling.

v2: fix unintended recursion, remove debugging leftovers
v3: split out from unpinned DMA-buf work
v4: rebase on top of new no_sgt_cache flag

Signed-off-by: Christian König 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c|   1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h|   1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c |   5 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c  | 162 +
 4 files changed, 109 insertions(+), 60 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 13a68f62bcc8..f1815223a1a1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1254,7 +1254,6 @@ static struct drm_driver kms_driver = {
.gem_prime_export = amdgpu_gem_prime_export,
.gem_prime_import = amdgpu_gem_prime_import,
.gem_prime_res_obj = amdgpu_gem_prime_res_obj,
-   .gem_prime_get_sg_table = amdgpu_gem_prime_get_sg_table,
.gem_prime_import_sg_table = amdgpu_gem_prime_import_sg_table,
.gem_prime_vmap = amdgpu_gem_prime_vmap,
.gem_prime_vunmap = amdgpu_gem_prime_vunmap,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h
index f1ddfc50bcc7..0c50d14a9739 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h
@@ -39,7 +39,6 @@ int amdgpu_gem_object_open(struct drm_gem_object *obj,
 void amdgpu_gem_object_close(struct drm_gem_object *obj,
struct drm_file *file_priv);
 unsigned long amdgpu_gem_timeout(uint64_t timeout_ns);
-struct sg_table *amdgpu_gem_prime_get_sg_table(struct drm_gem_object *obj);
 struct drm_gem_object *
 amdgpu_gem_prime_import_sg_table(struct drm_device *dev,
 struct dma_buf_attachment *attach,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 93b2c5a48a71..d26e2f0b88d2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -31,6 +31,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1194,6 +1195,10 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,
 
amdgpu_bo_kunmap(abo);
 
+   if (abo->gem_base.dma_buf && !abo->gem_base.import_attach &&
+   bo->mem.mem_type != TTM_PL_SYSTEM)
+   dma_buf_invalidate_mappings(abo->gem_base.dma_buf);
+
/* remember the eviction */
if (evict)
atomic64_inc(&adev->num_evictions);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
index a38e0fb4a6fe..cdc3c1e63a68 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
@@ -40,22 +40,6 @@
 #include 
 #include 
 
-/**
- * amdgpu_gem_prime_get_sg_table - &drm_driver.gem_prime_get_sg_table
- * implementation
- * @obj: GEM buffer object (BO)
- *
- * Returns:
- * A scatter/gather table for the pinned pages of the BO's memory.
- */
-struct sg_table *amdgpu_gem_prime_get_sg_table(struct drm_gem_object *obj)
-{
-   struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
-   int npages = bo->tbo.num_pages;
-
-   return drm_prime_pages_to_sg(bo->tbo.ttm->pages, npages);
-}
-
 /**
  * amdgpu_gem_prime_vmap - &dma_buf_ops.vmap implementation
  * @obj: GEM BO
@@ -231,34 +215,84 @@ __reservation_object_make_exclusive(struct 
reservation_object *obj)
 }
 
 /**
- * amdgpu_gem_map_attach - &dma_buf_ops.attach implementation
- * @dma_buf: Shared DMA buffer
+ * amdgpu_gem_pin_dma_buf - &dma_buf_ops.pin_dma_buf implementation
+ *
+ * @dma_buf: DMA-buf to pin in memory
+ *
+ * Pin the BO which is backing the DMA-buf so that it can't move any more.
+ */
+static int amdgpu_gem_pin_dma_buf(struct dma_buf *dma_buf)
+{
+   struct drm_gem_object *obj = dma_buf->priv;
+   struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
+
+   /* pin buffer into GTT */
+   return amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_GTT);
+}
+
+/**
+ * amdgpu_gem_unpin_dma_buf - &dma_buf_ops.unpin_dma_buf implementation
+ *
+ * @dma_buf: DMA-buf to unpin
+ *
+ * Unpin a previously pinned BO to make it movable again.
+ */
+static void amdgpu_gem_unpin_dma_buf(struct dma_buf *dma_buf)
+{
+   struct drm_gem_object *obj = dma_buf->priv;
+   struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
+
+   amdgpu_bo_unpin(bo);
+}
+
+/**
+ * amdgpu_gem_dma_buf_attach - &dma_buf_ops.attach implementation
+ *
+ * @dma_buf: DMA-buf we attach to
  * @attach: DMA-buf attachment
  *
+ * Returns:
+ * Always zero for success.
+ */
+static int amdgpu_gem_dma_buf_attach(struct dma_buf *dma_buf,
+ 

[PATCH 03/12] dma-buf: start caching of sg_table objects

2019-04-26 Thread Christian König
To allow a smooth transition from pinning buffer objects to dynamic
invalidation we first start to cache the sg_table for an attachment
unless the driver has implemented the explicite pin/unpin callbacks.

Signed-off-by: Christian König 
---
 drivers/dma-buf/dma-buf.c | 24 
 include/linux/dma-buf.h   |  1 +
 2 files changed, 25 insertions(+)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 0656dcf289be..a18d10c4425a 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -610,6 +610,20 @@ dma_buf_attach(const struct dma_buf_attach_info *info)
list_add(&attach->node, &dmabuf->attachments);
 
mutex_unlock(&dmabuf->lock);
+
+   if (!dmabuf->ops->pin) {
+   struct sg_table *sgt;
+
+   sgt = dmabuf->ops->map_dma_buf(attach, DMA_BIDIRECTIONAL);
+   if (!sgt)
+   sgt = ERR_PTR(-ENOMEM);
+   if (IS_ERR(sgt)) {
+   dma_buf_detach(dmabuf, attach);
+   return ERR_CAST(sgt);
+   }
+   attach->sgt = sgt;
+   }
+
return attach;
 
 err_attach:
@@ -632,6 +646,10 @@ void dma_buf_detach(struct dma_buf *dmabuf, struct 
dma_buf_attachment *attach)
if (WARN_ON(!dmabuf || !attach))
return;
 
+   if (attach->sgt)
+   dmabuf->ops->unmap_dma_buf(attach, attach->sgt,
+  DMA_BIDIRECTIONAL);
+
mutex_lock(&dmabuf->lock);
list_del(&attach->node);
if (dmabuf->ops->detach)
@@ -668,6 +686,9 @@ struct sg_table *dma_buf_map_attachment(struct 
dma_buf_attachment *attach,
if (WARN_ON(!attach || !attach->dmabuf))
return ERR_PTR(-EINVAL);
 
+   if (attach->sgt)
+   return attach->sgt;
+
reservation_object_lock(attach->dmabuf->resv, NULL);
r = dma_buf_pin(attach->dmabuf);
reservation_object_unlock(attach->dmabuf->resv);
@@ -701,6 +722,9 @@ void dma_buf_unmap_attachment(struct dma_buf_attachment 
*attach,
if (WARN_ON(!attach || !attach->dmabuf || !sg_table))
return;
 
+   if (attach->sgt == sg_table)
+   return;
+
attach->dmabuf->ops->unmap_dma_buf(attach, sg_table,
direction);
 
diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
index 0321939b1c3d..b9d0719581cd 100644
--- a/include/linux/dma-buf.h
+++ b/include/linux/dma-buf.h
@@ -345,6 +345,7 @@ struct dma_buf_attachment {
struct dma_buf *dmabuf;
struct device *dev;
struct list_head node;
+   struct sg_table *sgt;
void *priv;
 };
 
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  1   2   >