[PATCH 2/4] msm:disp:dpu1: add support for display for SC7180 target

2019-11-26 Thread Kalyan Thota
Add display hw catalog changes for SC7180 target.

Changes in v1:
 - Configure register offsets and capabilities for the
   display hw blocks.

Changes in v2:
 - mdss_irq data type has changed in the dependent
   patch, accommodate the necessary changes.
 - Add co-developed-by tags in the commit msg (Stephen Boyd).

Changes in v3:
 - fix kernel checkpatch errors in v2

Changes in v4:
 - move documentation into seperate patch (Rob Herring).

This patch has dependency on the below series

https://patchwork.kernel.org/patch/11253647/

Co-developed-by: Shubhashree Dhar 
Signed-off-by: Shubhashree Dhar 
Co-developed-by: Raviteja Tamatam 
Signed-off-by: Raviteja Tamatam 
Signed-off-by: Kalyan Thota 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c | 189 +++--
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h |   4 +
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.c  |   3 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c|   1 +
 drivers/gpu/drm/msm/msm_drv.c  |   4 +-
 5 files changed, 188 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c
index 88f2664..1cf4509 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c
@@ -11,11 +11,17 @@
 #include "dpu_hw_catalog_format.h"
 #include "dpu_kms.h"
 
-#define VIG_SDM845_MASK \
-   (BIT(DPU_SSPP_SRC) | BIT(DPU_SSPP_SCALER_QSEED3) | BIT(DPU_SSPP_QOS) |\
+#define VIG_MASK \
+   (BIT(DPU_SSPP_SRC) | BIT(DPU_SSPP_QOS) |\
BIT(DPU_SSPP_CSC_10BIT) | BIT(DPU_SSPP_CDP) | BIT(DPU_SSPP_QOS_8LVL) |\
BIT(DPU_SSPP_TS_PREFILL) | BIT(DPU_SSPP_EXCL_RECT))
 
+#define VIG_SDM845_MASK \
+   (VIG_MASK | BIT(DPU_SSPP_SCALER_QSEED3))
+
+#define VIG_SC7180_MASK \
+   (VIG_MASK | BIT(DPU_SSPP_SCALER_QSEED4))
+
 #define DMA_SDM845_MASK \
(BIT(DPU_SSPP_SRC) | BIT(DPU_SSPP_QOS) | BIT(DPU_SSPP_QOS_8LVL) |\
BIT(DPU_SSPP_TS_PREFILL) | BIT(DPU_SSPP_TS_PREFILL_REC1) |\
@@ -27,6 +33,9 @@
 #define MIXER_SDM845_MASK \
(BIT(DPU_MIXER_SOURCESPLIT) | BIT(DPU_DIM_LAYER))
 
+#define MIXER_SC7180_MASK \
+   (BIT(DPU_DIM_LAYER))
+
 #define PINGPONG_SDM845_MASK BIT(DPU_PINGPONG_DITHER)
 
 #define PINGPONG_SDM845_SPLIT_MASK \
@@ -60,6 +69,16 @@
.has_idle_pc = true,
 };
 
+static const struct dpu_caps sc7180_dpu_caps = {
+   .max_mixer_width = DEFAULT_DPU_OUTPUT_LINE_WIDTH,
+   .max_mixer_blendstages = 0x9,
+   .qseed_type = DPU_SSPP_SCALER_QSEED4,
+   .smart_dma_rev = DPU_SSPP_SMART_DMA_V2,
+   .ubwc_version = DPU_HW_UBWC_VER_20,
+   .has_dim_layer = true,
+   .has_idle_pc = true,
+};
+
 static struct dpu_mdp_cfg sdm845_mdp[] = {
{
.name = "top_0", .id = MDP_TOP,
@@ -85,6 +104,23 @@
},
 };
 
+static struct dpu_mdp_cfg sc7180_mdp[] = {
+   {
+   .name = "top_0", .id = MDP_TOP,
+   .base = 0x0, .len = 0x494,
+   .features = 0,
+   .highest_bank_bit = 0x3,
+   .clk_ctrls[DPU_CLK_CTRL_VIG0] = {
+   .reg_off = 0x2AC, .bit_off = 0},
+   .clk_ctrls[DPU_CLK_CTRL_DMA0] = {
+   .reg_off = 0x2AC, .bit_off = 8},
+   .clk_ctrls[DPU_CLK_CTRL_DMA1] = {
+   .reg_off = 0x2B4, .bit_off = 8},
+   .clk_ctrls[DPU_CLK_CTRL_CURSOR0] = {
+   .reg_off = 0x2BC, .bit_off = 8},
+   },
+};
+
 /*
  * CTL sub blocks config
  */
@@ -116,6 +152,24 @@
},
 };
 
+static struct dpu_ctl_cfg sc7180_ctl[] = {
+   {
+   .name = "ctl_0", .id = CTL_0,
+   .base = 0x1000, .len = 0xE4,
+   .features = BIT(DPU_CTL_ACTIVE_CFG)
+   },
+   {
+   .name = "ctl_1", .id = CTL_1,
+   .base = 0x1200, .len = 0xE4,
+   .features = BIT(DPU_CTL_ACTIVE_CFG)
+   },
+   {
+   .name = "ctl_2", .id = CTL_2,
+   .base = 0x1400, .len = 0xE4,
+   .features = BIT(DPU_CTL_ACTIVE_CFG)
+   },
+};
+
 /*
  * SSPP sub blocks config
  */
@@ -203,9 +257,23 @@
sdm845_dma_sblk_3, 13, SSPP_TYPE_DMA, DPU_CLK_CTRL_CURSOR1),
 };
 
+static struct dpu_sspp_cfg sc7180_sspp[] = {
+   SSPP_BLK("sspp_0", SSPP_VIG0, 0x4000, VIG_SC7180_MASK,
+   sdm845_vig_sblk_0, 0,  SSPP_TYPE_VIG, DPU_CLK_CTRL_VIG0),
+   SSPP_BLK("sspp_8", SSPP_DMA0, 0x24000,  DMA_SDM845_MASK,
+   sdm845_dma_sblk_0, 1, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA0),
+   SSPP_BLK("sspp_9", SSPP_DMA1, 0x26000,  DMA_SDM845_MASK,
+   sdm845_dma_sblk_1, 5, SSPP_TYPE_DMA, DPU_CLK_CTRL_DMA1),
+   SSPP_BLK("sspp_10", SSPP_DMA2, 0x28000,  DMA_CURSOR_SDM845_MASK,
+   sdm845_dma_sblk_2, 9, SSPP_TYPE_DMA, DPU_CLK_CTRL_CURSOR0),
+};
+
 /

[PATCH 0/4] Add support for SC7180 display

2019-11-26 Thread Kalyan Thota
SC7180 follows a newer architecture where in some flush controls have been 
re-organized to simplify programming and provide for future expandability.
Specifically:
1) The TIMING_ bits that control flush of INTF_ have been replaced with a 
common INTF flush bit which flushes the programming in the 
MDP_CTL__INTF_ACTIVE register
2) Individual flush bits for MERGE_3D, DSC and CDWN have been added which flush 
the programming in the MDP_CTL__MERGE_3D_ACTIVE, ... etc respectively
3) PERIPH flush bit has been added to flush DSP packets for DisplayPort

The complete datapath is described using the MDP_CTL__TOP and newly added 
ACTIVE registers to handle other sub blocks
such as interface (INTF) resources, PingPong buffer / Layer Mixer, Display 
Stream Compression (DSC) resources, writeback (WB) and 3D Merge
selections that are part of the datapath.

Kalyan Thota (4):
  dt-bindings: msm:disp: add sc7180 DPU variant
  msm:disp:dpu1: add support for display for SC7180 target
  msm:disp:dpu1: setup display datapath for SC7180 target
  msm:disp:dpu1: add mixer selection for display topology

 .../devicetree/bindings/display/msm/dpu.txt|   4 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c|  21 ++-
 .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c   |  21 ++-
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c | 191 +++--
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h |   6 +
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c |  84 -
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h |  24 +++
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c|  28 +++
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h|   6 +
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.c  |   3 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c|   1 +
 drivers/gpu/drm/msm/msm_drv.c  |   4 +-
 12 files changed, 370 insertions(+), 23 deletions(-)

-- 
1.9.1

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

[GIT PULL] Please pull hmm changes

2019-11-26 Thread Jason Gunthorpe
Hi Linus,

Here is this batch of hmm updates, I think we are nearing the end of this
project for now, although I suspect there will be some more patches related to
hmm_range_fault() in the next cycle.

You will probably be most interested in the patch "mm/mmu_notifier: add an
interval tree notifier". The approach here largely pre-exists in the various
drivers, but is honestly kind of complex/ugly. No better idea was found, I'm
hoping putting it all in one place will help improve this over the long
term. At least many bugs were squashed and lines of code eliminated while
consolidating.

Already i915 GPU has posted a series for the next window that also needs this
same approach.

There are two small conflicts I know of, the first is RDMA related with -rc,
the second is a one liner updating a deleted comment in GPU. Both can be
solved by using the hmm.git side of the conflict.

All the big driver changes have been acked and/or tested by their respective
maintainers.

Regards,
Jason

The following changes since commit d6d5df1db6e9d7f8f76d2911707f7d5877251b02:

  Linux 5.4-rc5 (2019-10-27 13:19:19 -0400)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git tags/for-linus-hmm

for you to fetch changes up to 93f4e735b6d98ee4b7a1252d81e815a983e359f2:

  mm/hmm: remove hmm_range_dma_map and hmm_range_dma_unmap (2019-11-23 19:56:45 
-0400)


hmm related patches for 5.5

This is another round of bug fixing and cleanup. This time the focus is on
the driver pattern to use mmu notifiers to monitor a VA range. This code
is lifted out of many drivers and hmm_mirror directly into the
mmu_notifier core and written using the best ideas from all the driver
implementations.

This removes many bugs from the drivers and has a very pleasing
diffstat. More drivers can still be converted, but that is for another
cycle.

- A shared branch with RDMA reworking the RDMA ODP implementation

- New mmu_interval_notifier API. This is focused on the use case of
  monitoring a VA and simplifies the process for drivers

- A common seq-count locking scheme built into the mmu_interval_notifier
  API usable by drivers that call get_user_pages() or hmm_range_fault()
  with the VA range

- Conversion of mlx5 ODP, hfi1, radeon, nouveau, AMD GPU, and Xen GntDev
  drivers to the new API. This deletes a lot of wonky driver code.

- Two improvements for hmm_range_fault(), from testing done by Ralph


Christoph Hellwig (1):
  mm/hmm: remove hmm_range_dma_map and hmm_range_dma_unmap

Jason Gunthorpe (30):
  RDMA/mlx5: Use SRCU properly in ODP prefetch
  RDMA/mlx5: Split sig_err MR data into its own xarray
  RDMA/mlx5: Use a dedicated mkey xarray for ODP
  RDMA/mlx5: Delete struct mlx5_priv->mkey_table
  RDMA/mlx5: Rework implicit_mr_get_data
  RDMA/mlx5: Lift implicit_mr_alloc() into the two routines that call it
  RDMA/mlx5: Set the HW IOVA of the child MRs to their place in the tree
  RDMA/mlx5: Split implicit handling from pagefault_mr
  RDMA/mlx5: Use an xarray for the children of an implicit ODP
  RDMA/mlx5: Reduce locking in implicit_mr_get_data()
  RDMA/mlx5: Avoid double lookups on the pagefault path
  RDMA/mlx5: Rework implicit ODP destroy
  RDMA/mlx5: Do not store implicit children in the odp_mkeys xarray
  RDMA/mlx5: Do not race with mlx5_ib_invalidate_range during create and 
destroy
  RDMA/odp: Remove broken debugging call to invalidate_range
  Merge branch 'odp_rework' into hmm.git
  mm/mmu_notifier: define the header pre-processor parts even if disabled
  mm/mmu_notifier: add an interval tree notifier
  mm/hmm: allow hmm_range to be used with a mmu_interval_notifier or 
hmm_mirror
  mm/hmm: define the pre-processor related parts of hmm.h even if disabled
  RDMA/odp: Use mmu_interval_notifier_insert()
  RDMA/hfi1: Use mmu_interval_notifier_insert for user_exp_rcv
  drm/radeon: use mmu_interval_notifier_insert
  nouveau: use mmu_notifier directly for invalidate_range_start
  nouveau: use mmu_interval_notifier instead of hmm_mirror
  drm/amdgpu: Call find_vma under mmap_sem
  drm/amdgpu: Use mmu_interval_insert instead of hmm_mirror
  drm/amdgpu: Use mmu_interval_notifier instead of hmm_mirror
  mm/hmm: remove hmm_mirror and related
  xen/gntdev: use mmu_interval_notifier_insert

Ralph Campbell (2):
  mm/hmm: allow snapshot of the special zero page
  mm/hmm: make full use of walk_page_range()

 Documentation/vm/hmm.rst |  105 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu.h  |2 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c |9 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c   |   14 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c   |1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c   |

[PATCH] drm/panel: Add Boe Himax8279d MIPI-DSI LCD panel

2019-11-26 Thread Jerry Han
Support Boe Himax8279d 8.0" 1200x1920 TFT LCD panel, it is a MIPI DSI
panel.

V9:
- Adjust init code, make the format more concise
- kill off default_off_cmds (Emil)
- use mipi_dsi_dcs_set_display_{on,off} in their enable/disable
callbacks. (Emil)
- Adjusting the delay function (Emil)

V8:
- modify PARENTHESIS_ALIGNMENT format (Sam)
- use gpios are required API replace optional gpio API (Emil)

V7:
- Modify communication address

V6:
- Add the information of the reviewer
- Remove unnecessary delays, The udelay_range code gracefully returns
without hitting the scheduler on a delay of 0. (Derek)
- Merge the same data structures, like display_mode and off_cmds (Derek)
- Optimize the processing of results returned by
devm_gpiod_get_optional (Derek)

V5:
- Add the information of the reviewer (Sam)
- Delete unnecessary header files #include  (Sam)
- The config DRM_PANEL_BOE_HIMAX8279D appears twice. Drop one of them (Sam)
- ADD static, set_gpios function is not used outside this module (Sam)

V4:
- Frefix all function maes with boe_ (Sam)
- Fsed "enable_gpio" replace "reset_gpio", Make it look clearer (Sam)
- Sort include lines alphabetically (Sam)
- Fixed entries in the makefile must be sorted alphabetically (Sam)
- Add send_mipi_cmds function to avoid duplicating the code (Sam)
- Add the necessary delay(reset_delay_t5) between reset and sending
the initialization command (Rock wang)

V3:
- Remove unnecessary delays in sending initialization commands (Jitao Shi)

V2:
- Use SPDX identifier (Sam)
- Use necessary header files replace drmP.h (Sam)
- Delete unnecessary header files #include  (Sam)
- Specifies a GPIOs array to control the reset timing,
instead of reading "dsi-reset-sequence" data from DTS (Sam)
- Delete backlight_disable() function when already disabled (Sam)
- Use devm_of_find_backlight() replace of_find_backlight_by_node() (Sam)
- Move the necessary data in the DTS to the current file,
like porch, display_mode and Init code etc. (Sam)
- Add compatible device "boe,himax8279d10p" (Sam)

V1:
- Support Boe Himax8279d 8.0" 1200x1920 TFT LCD panel, it is a MIPI DSI
panel.

Signed-off-by: Jerry Han 
Reviewed-by: Sam Ravnborg 
Reviewed-by: Derek Basehore 
Reviewed-by: Emil Velikov 
Cc: Jitao Shi 
Cc: Rock wang 
---
 MAINTAINERS  |   6 +
 drivers/gpu/drm/panel/Kconfig|  11 +
 drivers/gpu/drm/panel/Makefile   |   2 +
 drivers/gpu/drm/panel/panel-boe-himax8279d.c | 990 +++
 4 files changed, 1009 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-boe-himax8279d.c

diff --git a/MAINTAINERS b/MAINTAINERS
index c2b89453805f..295cb214834c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5135,6 +5135,12 @@ T:   git git://anongit.freedesktop.org/drm/drm-misc
 S: Maintained
 F: drivers/gpu/drm/bochs/
 
+DRM DRIVER FOR BOE HIMAX8279D PANELS
+M: Jerry Han 
+S: Maintained
+F: drivers/gpu/drm/panel/panel-boe-himax8279d.c
+F: Documentation/devicetree/bindings/display/panel/boe,himax8279d.txt
+
 DRM DRIVER FOR FARADAY TVE200 TV ENCODER
 M: Linus Walleij 
 T: git git://anongit.freedesktop.org/drm/drm-misc
diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index f152bc4eeb53..683ff77a3733 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -18,6 +18,17 @@ config DRM_PANEL_ARM_VERSATILE
  reference designs. The panel is detected using special registers
  in the Versatile family syscon registers.
 
+config DRM_PANEL_BOE_HIMAX8279D
+   tristate "Boe Himax8279d panel"
+   depends on OF
+   depends on DRM_MIPI_DSI
+   depends on BACKLIGHT_CLASS_DEVICE
+   help
+ Say Y here if you want to enable support for Boe Himax8279d
+ TFT-LCD modules. The panel has a 1200x1920 resolution and uses
+ 24 bit RGB per pixel. It provides a MIPI DSI interface to
+ the host and has a built-in LED backlight.
+
 config DRM_PANEL_LVDS
tristate "Generic LVDS panel driver"
depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index b6cd39fe0f20..4beae2ab427f 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_DRM_PANEL_ARM_VERSATILE) += panel-arm-versatile.o
+obj-$(CONFIG_DRM_PANEL_BOE_HIMAX8279D) += panel-boe-himax8279d.o
 obj-$(CONFIG_DRM_PANEL_LVDS) += panel-lvds.o
 obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o
 obj-$(CONFIG_DRM_PANEL_FEIYANG_FY07024DI26A30D) += 
panel-feiyang-fy07024di26a30d.o
@@ -36,5 +37,6 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += 
panel-sitronix-st7789v.o
 obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
 obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
 obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o
+obj-$(CONFIG_DRM_PANEL_BOE_HIMAX8279D) += panel-boe-himax8279d

[PATCH 4/4] msm:disp:dpu1: add mixer selection for display topology

2019-11-26 Thread Kalyan Thota
mixer selection in the display topology is based on multiple
factors
1) mixers available in the hw
2) interfaces to be enabled
3) merge capability

change will pickup mixer as per the topology need.

Signed-off-by: Kalyan Thota 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c| 21 ++---
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c |  1 +
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h |  2 ++
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
index d82ea99..067ef0b 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
@@ -58,7 +58,7 @@
 
 #define IDLE_SHORT_TIMEOUT 1
 
-#define MAX_VDISPLAY_SPLIT 1080
+#define MAX_HDISPLAY_SPLIT 1080
 
 /* timeout in frames waiting for frame done */
 #define DPU_ENCODER_FRAME_DONE_TIMEOUT_FRAMES 5
@@ -534,8 +534,23 @@ static struct msm_display_topology 
dpu_encoder_get_topology(
if (dpu_enc->phys_encs[i])
intf_count++;
 
-   /* User split topology for width > 1080 */
-   topology.num_lm = (mode->vdisplay > MAX_VDISPLAY_SPLIT) ? 2 : 1;
+   /* Datapath topology selection
+*
+* Dual display
+* 2 LM, 2 INTF ( Split display using 2 interfaces)
+*
+* Single display
+* 1 LM, 1 INTF
+* 2 LM, 1 INTF (stream merge to support high resolution interfaces)
+*
+*/
+   if (intf_count == 2)
+   topology.num_lm = 2;
+   else if (!dpu_kms->catalog->caps->has_3d_merge)
+   topology.num_lm = 1;
+   else
+   topology.num_lm = (mode->hdisplay > MAX_HDISPLAY_SPLIT) ? 2 : 1;
+
topology.num_enc = 0;
topology.num_intf = intf_count;
 
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c
index 0ee2b6c..de69f71 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c
@@ -67,6 +67,7 @@
.has_src_split = true,
.has_dim_layer = true,
.has_idle_pc = true,
+   .has_3d_merge = true,
 };
 
 static const struct dpu_caps sc7180_dpu_caps = {
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h
index 2607ef3..d0cb41c 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h
@@ -287,6 +287,7 @@ struct dpu_qos_lut_tbl {
  * @has_src_split  source split feature status
  * @has_dim_layer  dim layer feature status
  * @has_idle_pcindicate if idle power collapse feature is supported
+ * @has_3d_merge   indicate if 3D merge is supported
  */
 struct dpu_caps {
u32 max_mixer_width;
@@ -297,6 +298,7 @@ struct dpu_caps {
bool has_src_split;
bool has_dim_layer;
bool has_idle_pc;
+   bool has_3d_merge;
 };
 
 /**
-- 
1.9.1

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

Re: nouveau on NV04 calling illegal method 02fc under fbcon

2019-11-26 Thread Bruno Prémont
Hi Daniel,

On Mon, 25 Nov 2019 09:18:41 +0100 Daniel Vetter wrote:
> On Mon, Nov 25, 2019 at 9:08 AM Bruno Prémont  wrote:
> > Trying a new kernel on old [NV04] system I get tons of
> >   nouveau :01:00.0: gr: intr 0001 [NOTIFY] nsource 0040
> > [ILLEGAL_MTHD] nstatus 4000 [PROTECTION_FAULT] ch 0
> > [DRM] subc 3 class 004a mthd 02fc data 0003
> > errors when operating on console.
> >
> > As I updated from 4.3 kernel, a bisect does not feel like the best start.  
> 
> The bigger your upgrade, the more efficient bisecting actually is. The
> difference between one kernel (usually 12-13 bisects) and 20 kernels
> is just 4-5 bisects more.

Well with the time it takes to compile the kernel (and worse the Kconfig
changing quite a lot between the endpoints) it's not fun at all.

Thus I will first try with reverting below few commits.

> > What is that 02fc method which fbcon is probably triggering as
> > hardware-acceleration on nouveau side.  
> 
> Booting with nouveau.nofbaccel=0 (that should be the default, I guess
> you changed it) should help confirm that's it's indeed fbcon causing
> this stuff.

I will try out when I am back next to that machine.

If it's fbcon acceleration (which I assume as output to fbcon causes
new errors), probably one of the few commits to
drivers/gpu/drm/nouveau/nv04_fbcon.c would be the cause:

  1167c6bc51880cb74a3b1a02286fc25392684281
drm/nouveau: allocate device object for every client
  9dec9280523157da820f923e18dd6a7bf99fead7
drm/nouveau/fbcon: make use of drm_fb_helper.dev
  28668f43b8e421634e1623f72a879812288dd06b
drm/nouveau/fbcon: fix font width not divisible by 8
  f045f459d925138fe7d6193a8c86406bda7e49da
drm/nouveau/fbcon: fix out-of-bounds memory accesses
  4dc28134a8c124aa01b441e1e5b8b54312edc5dd
drm/nouveau: rename nouveau_drm.h to nouveau_drv.h

At first glance I would suspect one of:
  28668f43b8e421634e1623f72a879812288dd06b
  f045f459d925138fe7d6193a8c86406bda7e49da

Bruno


> I think at least, not a nouveau expert.
> -Daniel
> >
> > Thanks,
> > Bruno
> >
> >
> >
> > Below, a grep for nouveau on kernel log:
> >
> > Nov 24 18:27:27 zeus kernel: Kernel command line: BOOT_IMAGE=5.3.12 ro 
> > root=802 slub_debug=FZP nouveau.runpm=1 nouveau.debug=debug 
> > console=ttyS0,115200 nouveau.agpmode=0
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: NVIDIA NV04 (20044001)
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: bios: trying PRAMIN...
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: bios: 0260: NPDE 
> > signature (9b030041) unknown
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: bios: : type 00, 
> > 32768 bytes
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: bios: scored 4
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: bios: trying PROM...
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: bios: : ROM 
> > signature () unknown
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: bios: image 0 invalid
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: bios: scored 0
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: bios: trying ACPI...
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: bios: using image from 
> > PRAMIN
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: bios: 0260: NPDE 
> > signature (9b030041) unknown
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: bios: 0260: NPDE 
> > signature (9b030041) unknown
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: bios: BMP version 1.1
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: bios: version 
> > 02.04.19.00.00
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: bios: DCB table not found
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: i2c: ccb 00: type 00 
> > drive 3f sense 3e share ff auxch cb
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: bios: DCB table not found
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: i2c: ccb 01: type 00 
> > drive 37 sense 36 share ff auxch cb
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: bios: DCB table not found
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: bios: DCB table not found
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: disp: head-0: ctor
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: disp: head-1: ctor
> > Nov 24 18:27:27 zeus kernel: nouveau: DRM-master::0080: init 
> > running...
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: putting AGP V2 device 
> > into 0x mode
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: tmr: unknown input clock 
> > freq
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: tmr: input frequency : 
> > 0Hz
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: tmr: numerator   : 
> > 0001
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: tmr: denominator : 
> > 0001
> > Nov 24 18:27:27 zeus kernel: nouveau :01:00.0: tmr: timer frequency : 
> > 0Hz
> > Nov 24 18:27:27 z

[PATCH -next] drm/amd/display: remove set but not used variable 'msg_out'

2019-11-26 Thread YueHaibing
drivers/gpu/drm/amd/amdgpu/../display/modules/hdcp/hdcp_psp.c: In function 
mod_hdcp_hdcp2_enable_encryption:
drivers/gpu/drm/amd/amdgpu/../display/modules/hdcp/hdcp_psp.c:633:77: warning: 
variable msg_out set but not used [-Wunused-but-set-variable]
drivers/gpu/drm/amd/amdgpu/../display/modules/hdcp/hdcp_psp.c: In function 
mod_hdcp_hdcp2_enable_dp_stream_encryption:
drivers/gpu/drm/amd/amdgpu/../display/modules/hdcp/hdcp_psp.c:710:77: warning: 
variable msg_out set but not used [-Wunused-but-set-variable]

It is never used, so remove it.

Reported-by: Hulk Robot 
Signed-off-by: YueHaibing 
---
 drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c 
b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c
index 2dd5fee..468f5e6 100644
--- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c
+++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c
@@ -630,14 +630,12 @@ enum mod_hdcp_status 
mod_hdcp_hdcp2_enable_encryption(struct mod_hdcp *hdcp)
struct psp_context *psp = hdcp->config.psp.handle;
struct ta_hdcp_shared_memory *hdcp_cmd;
struct 
ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in;
-   struct 
ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out;
struct mod_hdcp_display *display = get_first_added_display(hdcp);
 
hdcp_cmd = (struct ta_hdcp_shared_memory 
*)psp->hdcp_context.hdcp_shared_buf;
memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));
 
msg_in = 
&hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2;
-   msg_out = 
&hdcp_cmd->out_msg.hdcp2_prepare_process_authentication_message_v2;
 
hdcp2_message_init(hdcp, msg_in);
 
@@ -707,14 +705,12 @@ enum mod_hdcp_status 
mod_hdcp_hdcp2_enable_dp_stream_encryption(struct mod_hdcp
struct psp_context *psp = hdcp->config.psp.handle;
struct ta_hdcp_shared_memory *hdcp_cmd;
struct 
ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in;
-   struct 
ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out;
uint8_t i;
 
hdcp_cmd = (struct ta_hdcp_shared_memory 
*)psp->hdcp_context.hdcp_shared_buf;
memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));
 
msg_in = 
&hdcp_cmd->in_msg.hdcp2_prepare_process_authentication_message_v2;
-   msg_out = 
&hdcp_cmd->out_msg.hdcp2_prepare_process_authentication_message_v2;
 
hdcp2_message_init(hdcp, msg_in);
 
-- 
2.7.4


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

[PATCH v1] drm/mediatek: fix up 1440x900 dp display black screen issue

2019-11-26 Thread yongqiang.niu
From: Yongqiang Niu 

This patch fix up 1440x900 dp display black screen issue
the computed result will overflow rdma1 fifo max size
when external display pixel clock bigger than 74MHZ

Signed-off-by: Yongqiang Niu 
---
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c 
b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
index c1abde3..41143f5 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
@@ -152,6 +152,10 @@ static void mtk_rdma_config(struct mtk_ddp_comp *comp, 
unsigned int width,
 * account for blanking, and with a pixel depth of 4 bytes:
 */
threshold = width * height * vrefresh * 4 * 7 / 100;
+
+   if (threshold > rdma_fifo_size)
+   threshold = rdma_fifo_size;
+
reg = RDMA_FIFO_UNDERFLOW_EN |
  RDMA_FIFO_PSEUDO_SIZE(rdma_fifo_size) |
  RDMA_OUTPUT_VALID_FIFO_THRESHOLD(threshold);
-- 
1.8.1.1.dirty
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [RFC 06/13] drm/i915/svm: Page table mirroring support

2019-11-26 Thread Jason Gunthorpe
On Sun, Nov 24, 2019 at 01:12:47PM -0800, Niranjan Vishwanathapura wrote:

> > > > Using a temporary range is the pattern from nouveau, is it really
> > > > necessary in this driver?
> > > 
> > > Yah, not required. In my local build I tried with proper default_flags
> > > and set pfn_flags_mask to 0 and it is working fine.
> > 
> > Sorry, I ment calling hmm_range_register during fault processing.
> > 
> > If your driver works around user space objects that cover a VA then
> > the range should be created when the object is created.
> > 
> 
> Oh ok. No, there is no user space object here.
> Binding the user space object to device page table is handled in
> patch 03 of this series (no HMM there).
> This is for binding a system allocated (malloc) memory. User calls
> the bind ioctl with the VA range.
> 
> > > > > + /*
> > > > > +  * No needd to dma map the host pages and later unmap it, as
> > > > > +  * GPU is not allowed to access it with SVM. Hence, no need
> > > > > +  * of any intermediate data strucutre to hold the mappings.
> > > > > +  */
> > > > > + for (i = 0; i < npages; i++) {
> > > > > + u64 addr = range->pfns[i] & ~((1UL << range->pfn_shift) 
> > > > > - 1);
> > > > > +
> > > > > + if (sg && (addr == (sg_dma_address(sg) + sg->length))) {
> > > > > + sg->length += PAGE_SIZE;
> > > > > + sg_dma_len(sg) += PAGE_SIZE;
> > > > > + continue;
> > > > > + }
> > > > > +
> > > > > + if (sg)
> > > > > + sg_page_sizes |= sg->length;
> > > > > +
> > > > > + sg =  sg ? __sg_next(sg) : st->sgl;
> > > > > + sg_dma_address(sg) = addr;
> > > > > + sg_dma_len(sg) = PAGE_SIZE;
> > > > > + sg->length = PAGE_SIZE;
> > > > > + st->nents++;
> > > >
> > > > It is odd to build the range into a sgl.
> > > >
> > > > IMHO it is not a good idea to use the sg_dma_address like this, that
> > > > should only be filled in by a dma map. Where does it end up being
> > > > used?
> > > 
> > > The sgl is used to plug into the page table update function in i915.
> > > 
> > > For the device memory in discrete card, we don't need dma map which
> > > is the case here.
> > 
> > How did we get to device memory on a card? Isn't range->pfns a CPU PFN
> > at this point?
> > 
> > I'm confused.
> 
> Device memory plugin is done through devm_memremap_pages() in patch 07 of
> this series. In that patch, we convert the CPU PFN to device PFN before
> building the sgl (this is similar to the nouveau driver).

But earlier just called hmm_range_fault(), it can return all kinds of
pages. If these are only allowed to be device pages here then that
must be checked (under lock)

And putting the cpu PFN of a ZONE_DEVICE device page into
sg_dma_address still looks very wrong to me

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

Re: [PATCH v3 8/8] MIPS: DTS: jz4780: add sgx gpu node

2019-11-26 Thread Tony Lindgren
* H. Nikolaus Schaller  [191124 18:00]:
> Hi Paul, Tony,
> 
> > Am 24.11.2019 um 18:48 schrieb Tony Lindgren :
> > 
> > * Paul Cercueil  [191124 12:58]:
> >> Le dim., nov. 24, 2019 at 12:40, H. Nikolaus Schaller  
> >> a
> >> écrit :
> >>> and add interrupt and clocks.
> > ...
> >>> --- a/arch/mips/boot/dts/ingenic/jz4780.dtsi
> >>> +++ b/arch/mips/boot/dts/ingenic/jz4780.dtsi
> >>> @@ -46,6 +46,17 @@
> >>>   #clock-cells = <1>;
> >>>   };
> >>> 
> >>> + gpu: gpu@1304 {
> >> 
> >> We try to keep the nodes ordered by address, could you move this node where
> >> it belongs?
> > ...
> 
> Yes, I have noted.
> 
> > 
> >>> + compatible = "ingenic,jz4780-sgx540-120", "img,sgx540-120",
> >>> "img,sgx540", "img,sgx5";
> >>> + reg = <0x1304 0x4000>;
> >>> +
> >>> + clocks = <&cgu JZ4780_CLK_GPU>;
> >>> + clock-names = "gpu";
> > 
> > Just checking.. Is there something else to configure here
> > potentially in addition to the clocks?
> 
> It doesn't look so. Unfortuantely there isn't much information
> except a v3.18 kernel supported by the vendor and that one also
> just has a gpu node with clock control.
> 
> > That is, do we need to do some interconnect specific
> > configuration etc in addition to the clocks to have
> > runtime PM work for enabling and disabling sgx on
> > jz4780?
> 
> I think we have to leave that open for further study.

OK for now, let's assume we just need to call
clk_enable/disable from the PM runtime functions if a
clock exists.

Regards,

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

[PATCH -next] drm/amd/powerplay: remove set but not used variable 'stretch_amount2'

2019-11-26 Thread YueHaibing
drivers/gpu/drm/amd/amdgpu/../powerplay/smumgr/vegam_smumgr.c:
 In function vegam_populate_clock_stretcher_data_table:
drivers/gpu/drm/amd/amdgpu/../powerplay/smumgr/vegam_smumgr.c:1489:29:
 warning: variable stretch_amount2 set but not used [-Wunused-but-set-variable]

It is never used, so can be removed.

Signed-off-by: YueHaibing 
---
 drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c 
b/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c
index 50896e9..b0e0d67 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c
@@ -1486,7 +1486,7 @@ static int 
vegam_populate_clock_stretcher_data_table(struct pp_hwmgr *hwmgr)
struct vegam_smumgr *smu_data =
(struct vegam_smumgr *)(hwmgr->smu_backend);
 
-   uint8_t i, stretch_amount, stretch_amount2, volt_offset = 0;
+   uint8_t i, stretch_amount, volt_offset = 0;
struct phm_ppt_v1_information *table_info =
(struct phm_ppt_v1_information *)(hwmgr->pptable);
struct phm_ppt_v1_clock_voltage_dependency_table *sclk_table =
@@ -1525,11 +1525,9 @@ static int 
vegam_populate_clock_stretcher_data_table(struct pp_hwmgr *hwmgr)
(table_info->cac_dtp_table->ucCKS_LDO_REFSEL != 0) ?
table_info->cac_dtp_table->ucCKS_LDO_REFSEL : 5;
/* Populate CKS Lookup Table */
-   if (stretch_amount == 1 || stretch_amount == 2 || stretch_amount == 5)
-   stretch_amount2 = 0;
-   else if (stretch_amount == 3 || stretch_amount == 4)
-   stretch_amount2 = 1;
-   else {
+   if (!(stretch_amount == 1 || stretch_amount == 2 ||
+ stretch_amount == 5 || stretch_amount == 3 ||
+ stretch_amount == 4)) {
phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
PHM_PlatformCaps_ClockStretcher);
PP_ASSERT_WITH_CODE(false,
-- 
2.7.4


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

[PATCH 3/4] msm:disp:dpu1: setup display datapath for SC7180 target

2019-11-26 Thread Kalyan Thota
Add changes to setup display datapath on SC7180 target.

Changes in v1:
 - Add changes to support ctl_active on SC7180 target.
 - While selecting the number of mixers in the topology
   consider the interface width.

Changes in v2:
 - Spawn topology mixer selection into separate patch (Rob Clark).
 - Add co-developed-by tags in the commit msg (Stephen Boyd).

Changes in v3:
 - Fix kernel checkpatch errors in v2.

This patch has dependency on the below series

https://patchwork.kernel.org/patch/11253747/

Co-developed-by: Shubhashree Dhar 
Signed-off-by: Shubhashree Dhar 
Co-developed-by: Raviteja Tamatam 
Signed-off-by: Raviteja Tamatam 
Signed-off-by: Kalyan Thota 
---
 .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c   | 21 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c |  1 +
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 84 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h | 24 +++
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c| 28 
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h|  6 ++
 6 files changed, 159 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
index b9c84fb..8cc8ad12 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
@@ -280,6 +280,14 @@ static void dpu_encoder_phys_vid_setup_timing_engine(
phys_enc->hw_intf->ops.setup_timing_gen(phys_enc->hw_intf,
&timing_params, fmt);
phys_enc->hw_ctl->ops.setup_intf_cfg(phys_enc->hw_ctl, &intf_cfg);
+
+   /* setup which pp blk will connect to this intf */
+   if (phys_enc->hw_intf->ops.bind_pingpong_blk)
+   phys_enc->hw_intf->ops.bind_pingpong_blk(
+   phys_enc->hw_intf,
+   true,
+   phys_enc->hw_pp->idx);
+
spin_unlock_irqrestore(phys_enc->enc_spinlock, lock_flags);
 
programmable_fetch_config(phys_enc, &timing_params);
@@ -435,6 +443,7 @@ static void dpu_encoder_phys_vid_enable(struct 
dpu_encoder_phys *phys_enc)
 {
struct dpu_hw_ctl *ctl;
u32 flush_mask = 0;
+   u32 intf_flush_mask = 0;
 
ctl = phys_enc->hw_ctl;
 
@@ -459,10 +468,18 @@ static void dpu_encoder_phys_vid_enable(struct 
dpu_encoder_phys *phys_enc)
ctl->ops.get_bitmask_intf(ctl, &flush_mask, phys_enc->hw_intf->idx);
ctl->ops.update_pending_flush(ctl, flush_mask);
 
+   if (ctl->ops.get_bitmask_active_intf)
+   ctl->ops.get_bitmask_active_intf(ctl, &intf_flush_mask,
+   phys_enc->hw_intf->idx);
+
+   if (ctl->ops.update_pending_intf_flush)
+   ctl->ops.update_pending_intf_flush(ctl, intf_flush_mask);
+
 skip_flush:
DPU_DEBUG_VIDENC(phys_enc,
-"update pending flush ctl %d flush_mask %x\n",
-ctl->idx - CTL_0, flush_mask);
+   "update pending flush ctl %d flush_mask 0%x intf_mask 0x%x\n",
+   ctl->idx - CTL_0, flush_mask, intf_flush_mask);
+
 
/* ctl_flush & timing engine enable will be triggered by framework */
if (phys_enc->enable_state == DPU_ENC_DISABLED)
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c
index 1cf4509..0ee2b6c 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c
@@ -374,6 +374,7 @@
{\
.name = _name, .id = _id, \
.base = _base, .len = 0x280, \
+   .features = BIT(DPU_CTL_ACTIVE_CFG), \
.type = _type, \
.controller_id = _ctrl_id, \
.prog_fetch_lines_worst_case = 24 \
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c
index 179e8d5..2ce4b5a 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c
@@ -22,11 +22,15 @@
 #define   CTL_PREPARE   0x0d0
 #define   CTL_SW_RESET  0x030
 #define   CTL_LAYER_EXTN_OFFSET 0x40
+#define   CTL_INTF_ACTIVE   0x0F4
+#define   CTL_INTF_FLUSH0x110
+#define   CTL_INTF_MASTER   0x134
 
 #define CTL_MIXER_BORDER_OUTBIT(24)
 #define CTL_FLUSH_MASK_CTL  BIT(17)
 
 #define DPU_REG_RESET_TIMEOUT_US2000
+#define  INTF_IDX   31
 
 static struct dpu_ctl_cfg *_ctl_offset(enum dpu_ctl ctl,
struct dpu_mdss_cfg *m,
@@ -100,11 +104,27 @@ static inline void dpu_hw_ctl_update_pending_flush(struct 
dpu_hw_ctl *ctx,
ctx->pending_flush_mask |= flushbits;
 }
 
+static inline void dpu_hw_ctl_update_pending_intf_flush(struct dpu_hw_ctl *ctx,
+   u32 flushbits)
+{
+   ctx->pending_intf_flush_mask |= flushbits;
+}
+
 static u32 dpu_hw_ctl_get_pending_flush(struc

[PATCH 1/4] dt-bindings: msm:disp: add sc7180 DPU variant

2019-11-26 Thread Kalyan Thota
Add a compatible string to support sc7180 dpu version.

Signed-off-by: Kalyan Thota 
---
 Documentation/devicetree/bindings/display/msm/dpu.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/msm/dpu.txt 
b/Documentation/devicetree/bindings/display/msm/dpu.txt
index a61dd40..551ae26 100644
--- a/Documentation/devicetree/bindings/display/msm/dpu.txt
+++ b/Documentation/devicetree/bindings/display/msm/dpu.txt
@@ -8,7 +8,7 @@ The DPU display controller is found in SDM845 SoC.
 
 MDSS:
 Required properties:
-- compatible: "qcom,sdm845-mdss"
+- compatible:  "qcom,sdm845-mdss", "qcom,sc7180-mdss"
 - reg: physical base address and length of contoller's registers.
 - reg-names: register region names. The following region is required:
   * "mdss"
@@ -41,7 +41,7 @@ Optional properties:
 
 MDP:
 Required properties:
-- compatible: "qcom,sdm845-dpu"
+- compatible: "qcom,sdm845-dpu", "qcom,sc7180-dpu"
 - reg: physical base address and length of controller's registers.
 - reg-names : register region names. The following region is required:
   * "mdp"
-- 
1.9.1

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

[PULL] drm-misc-fixes

2019-11-26 Thread Maxime Ripard
Hi Dave, Daniel,

Here are a few lates fixes for drm-misc-fixes. Obviously, it's not
going to make it into 5.4, but it'd be great if they were in the
upcoming PR.

Thanks!
Maxime

drm-misc-fixes-2019-11-25:
 - A fix for a memory leak in the dma-buf support
 - One in mcde DSI support that leads to a pointer dereference
The following changes since commit 0b8e7bbde5e7e2c419567e1ee29587dae3b78ee3:

  drm/sun4i: tcon: Set min division of TCON0_DCLK to 1. (2019-11-13 15:20:33 
+0100)

are available in the Git repository at:

  git://anongit.freedesktop.org/drm/drm-misc tags/drm-misc-fixes-2019-11-25

for you to fetch changes up to 6645d42d79d33e8a9fe262660a75d5f4556bbea9:

  dma-buf: Fix memory leak in sync_file_merge() (2019-11-25 10:21:33 +0100)


 - A fix for a memory leak in the dma-buf support
 - One in mcde DSI support that leads to a pointer dereference


Navid Emamdoost (1):
  dma-buf: Fix memory leak in sync_file_merge()

Stephan Gerhold (1):
  drm/mcde: dsi: Fix invalid pointer dereference if panel cannot be found

 drivers/dma-buf/sync_file.c | 2 +-
 drivers/gpu/drm/mcde/mcde_dsi.c | 6 --
 2 files changed, 5 insertions(+), 3 deletions(-)


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

RE: [PATCH libdrm v4] modetest: Add support for setting mode having floating vertical refresh rate

2019-11-26 Thread Devarsh Thakkar


> -Original Message-
> From: Ville Syrjälä 
> Sent: 25 November 2019 06:30
> To: Devarsh Thakkar 
> Cc: dri-devel@lists.freedesktop.org; Hyun Kwon ; vcu-
> team ; Ranganathan Sk ; Dhaval
> Rajeshbhai Shah ; Satish Kumar Nagireddy
> ; Varunkumar Allagadapa 
> Subject: Re: [PATCH libdrm v4] modetest: Add support for setting mode
> having floating vertical refresh rate
> 
> EXTERNAL EMAIL
> 
> On Mon, Nov 25, 2019 at 07:34:37AM +, Devarsh Thakkar wrote:
> > Ping. Just wanted to confirm if the patch is applied or anything still 
> > pending
> from my side ?
> 
> Seems to work -> pushed.
> 
> One thing I noticed is that we still print the modes with an integer vrefresh 
> so
> it's a bit hard to know what value to pass in. Might be nice to make it dumo 
> the
> modes with %.2f vrefresh as well.
>

Agreed, thanks for pointing out,  I am updating it and sending separate patch 
shortly.
 
> >
> > Also I tried to subscribe as per instructions at
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> > Sometime back, but still not able to receive messages from mailing list. Is
> there any other way to subscribe ?
> >
> > Regards,
> > Devarsh
> > > -Original Message-
> > > From: Devarsh Thakkar 
> > > Sent: 15 November 2019 06:31
> > > To: dri-devel@lists.freedesktop.org; ville.syrj...@linux.intel.com
> > > Cc: Hyun Kwon ; vcu-team ;
> > > Ranganathan Sk ; Dhaval Rajeshbhai Shah
> > > ; Satish Kumar Nagireddy ;
> > > Varunkumar Allagadapa ; Devarsh Thakkar
> > > 
> > > Subject: [PATCH libdrm v4] modetest: Add support for setting mode
> > > having floating vertical refresh rate
> > >
> > > For the scenario where user may require to modeset with a mode
> > > supporting a fractional value for vertical refresh-rate, appropriate
> > > mode can be selected by searching for mode having matching
> > > fractional vertical refresh rate using below equation.
> > >
> > > vrefresh = (1000 * pixel clock) / (htotal * vtotal) Hz.
> > >
> > > We do this way since driver doesn't return float value of vrefresh
> > > as it use int for vrefresh in struct drm_mode_info, but we can
> > > derive the actual value using pixel clock, horizontal total size and 
> > > vertical
> total size values.
> > >
> > > So for e.g. if user want to select mode having 59.94 Hz as refresh
> > > rate then with this patch it be can done as shown in below command,
> > > given there is an appropriate mode is available :
> > >
> > > modetest -M xlnx -s 39:1920x1080-59.94@BG24 -v
> > >
> > > NOTE: Above command was tested on xilinx DRM driver with DP monitor
> > > which was supporting mode having 59.94 Hz refresh rate.
> > >
> > > V2: Update commit message
> > > V3: Update with below changes as per review comments :
> > >   1) Use epsilon for vrefresh comparison
> > >   2) Use implicit type-casting wherever possible
> > > V4: Keep patch version history on main commit message
> > >
> > > Signed-off-by: Devarsh Thakkar 
> > > Reviewed-by: Ville Syrjälä 
> > > ---
> > >  tests/modetest/modetest.c | 20 
> > >  1 file changed, 12 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
> > > index e66be66..b4edfcb 100644
> > > --- a/tests/modetest/modetest.c
> > > +++ b/tests/modetest/modetest.c
> > > @@ -54,6 +54,7 @@
> > >  #ifdef HAVE_SYS_SELECT_H
> > >  #include 
> > >  #endif
> > > +#include 
> > >
> > >  #include "xf86drm.h"
> > >  #include "xf86drmMode.h"
> > > @@ -795,7 +796,7 @@ struct pipe_arg {
> > > uint32_t crtc_id;
> > > char mode_str[64];
> > > char format_str[5];
> > > -   unsigned int vrefresh;
> > > +   float vrefresh;
> > > unsigned int fourcc;
> > > drmModeModeInfo *mode;
> > > struct crtc *crtc;
> > > @@ -822,11 +823,12 @@ struct plane_arg {
> > >
> > >  static drmModeModeInfo *
> > >  connector_find_mode(struct device *dev, uint32_t con_id, const char
> > > *mode_str,
> > > -const unsigned int vrefresh)
> > > +   const float vrefresh)
> > >  {
> > > drmModeConnector *connector;
> > > drmModeModeInfo *mode;
> > > int i;
> > > +   float mode_vrefresh;
> > >
> > > connector = get_connector_by_id(dev, con_id);
> > > if (!connector || !connector->count_modes) @@ -839,9 +841,11 @@
> > > connector_find_mode(struct device *dev, uint32_t con_id, const char
> > > *mode_str,
> > >  * first mode that match with the name. Else,
> > > return the mode that match
> > >  * the name and the specified vertical refresh
> > > frequency.
> > >  */
> > > +   mode_vrefresh = mode->clock * 1000.00
> > > +   / (mode->htotal * mode->vtotal);
> > > if (vrefresh == 0)
> > > return mode;
> > > -   else if (mode->vrefresh == vrefresh)
> > > +   else if (fabs(mode_vrefresh - vrefresh) < 0.005)
> > > return mode;
> > 

Re: WARNING in md_ioctl

2019-11-26 Thread syzbot

syzbot has bisected this bug to:

commit 4b6ce6810a5dc0af387a238e8c852e0d3822381f
Author: Rafael Antognolli 
Date:   Mon Feb 5 23:33:30 2018 +

drm/i915/cnl: WaPipeControlBefore3DStateSamplePattern

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=13aeb522e0
start commit:   c61a56ab Merge branch 'x86-urgent-for-linus' of git://git...
git tree:   upstream
final crash:https://syzkaller.appspot.com/x/report.txt?x=106eb522e0
console output: https://syzkaller.appspot.com/x/log.txt?x=17aeb522e0
kernel config:  https://syzkaller.appspot.com/x/.config?x=4013180e7c7a9ff9
dashboard link: https://syzkaller.appspot.com/bug?extid=1e46a0864c1a6e9bd3d8
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=16bca20780
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=14819a4780

Reported-by: syzbot+1e46a0864c1a6e9bd...@syzkaller.appspotmail.com
Fixes: 4b6ce6810a5d ("drm/i915/cnl:  
WaPipeControlBefore3DStateSamplePattern")


For information about bisection process see: https://goo.gl/tpsmEJ#bisection
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

RE: [PATCH v4 12/13] [HACK] drm/bridge: lvds-codec: Enforce device specific compatible strings

2019-11-26 Thread Fabrizio Castro
Hi Geert,

> From: Geert Uytterhoeven 
> Sent: 22 November 2019 08:17
> Subject: Re: [PATCH v4 12/13] [HACK] drm/bridge: lvds-codec: Enforce device 
> specific compatible strings
> 
> Hi Fabrizio,
> 
> On Thu, Nov 21, 2019 at 5:00 PM Fabrizio Castro
>  wrote:
> > > From: devicetree-ow...@vger.kernel.org  
> > > On Behalf Of Laurent Pinchart
> > > Sent: 19 November 2019 21:52
> > > Subject: Re: [PATCH v4 12/13] [HACK] drm/bridge: lvds-codec: Enforce 
> > > device specific compatible strings
> > >
> > > On Tue, Nov 19, 2019 at 11:17:34AM +, Fabrizio Castro wrote:
> > > > On 19 November 2019 00:16 Laurent Pinchart wrote:
> > > > > On Wed, Nov 13, 2019 at 03:51:31PM +, Fabrizio Castro wrote:
> > > > > > The lvds-codec driver is a generic stub for transparent LVDS
> > > > > > encoders and decoders.
> > > > > > It's good practice to list a device specific compatible string
> > > > > > before the generic fallback (if any) in the DT node for the relevant
> > > > > > LVDS encoder/decoder, and it's also required by the dt-bindings.
> > > > > > A notable exception to the generic fallback mechanism is the case
> > > > > > of "thine,thc63lvdm83d", as documented in:
> > > > > > Documentation/devicetree/bindings/display/bridge/thine,thc63lvdm83d.txt
> > > > > > This patch enforces the adoption of a device specific compatible
> > > > > > string (as fist string in the list), by using markers for the
> > > > > > compatible string we match against and the index of the matching
> > > > > > compatible string in the list.
> > > > > >
> > > > > > Signed-off-by: Fabrizio Castro 
> > > > > >
> > > > > > ---
> > > > > > Hi Laurent,
> > > > > >
> > > > > > I don't think we need to do anything in the driver to address your
> > > > > > comment, as we can "enforce" this with the bindings (please see the
> > > > > > next patch, as it would help with the "enforcing" of the compatible
> > > > > > string for the thine device).
> > > > > > I am sending this patch only so that you can see what a possible
> > > > > > solution in the driver could look like.
> > > > > >
> > > > > > v3->v4:
> > > > > > * New patch addressing the below comment from Laurent:
> > > > > > "I think the lvds-decoder driver should error out at probe time if 
> > > > > > only
> > > > > > one compatible string is listed."
> 
> > > > > > --- a/drivers/gpu/drm/bridge/lvds-codec.c
> > > > > > +++ b/drivers/gpu/drm/bridge/lvds-codec.c
> 
> > > > > > @@ -65,7 +70,30 @@ static int lvds_codec_probe(struct 
> > > > > > platform_device *pdev)
> > > > > > if (!lvds_codec)
> > > > > > return -ENOMEM;
> > > > > >
> > > > > > -   lvds_codec->connector_type = 
> > > > > > (u32)of_device_get_match_data(&pdev->dev);
> > > > > > +   lvds_codec->data = of_device_get_match_data(&pdev->dev);
> > > > > > +   if (!lvds_codec->data)
> > > > > > +   return -EINVAL;
> > > > > > +
> > > > > > +   /*
> > > > > > +* If we haven't matched a device specific compatible 
> > > > > > string, we need
> > > > > > +* to work out if the generic compatible string we matched 
> > > > > > against was
> > > > > > +* listed first in the compatible property.
> > > > > > +*/
> > > > >
> > > > > Can't we do this unconditionally, and thus drop the lvds_codec_data
> > > > > structure ?
> > > >
> > > > I don't think so, and the reason for this is that we have a corner case 
> > > > for
> > > > thine,thc63lvdm83d. Here is what's allowed (according to the 
> > > > documentation)
> > > > from what's supported upstream (+ this series):
> > > > "ti,ds90c185", "lvds-encoder"
> > > > "ti,ds90c187", "lvds-encoder"
> > > > "ti,sn75lvds83", "lvds-encoder"
> > > > "ti,ds90cf384a", "lvds-decoder"
> > > > "thine,thc63lvdm83d"
> > > >
> > > > As you can see from the examples above, in most cases it's enough to 
> > > > say it's
> > > > all good when we match a compatible string with index > 0, but for the 
> > > > thine
> > > > device you _have_ to match the string with index 0 as that's what's 
> > > > currently
> > > > documented (please see thine,thc63lvdm83d.txt) and that's what's 
> > > > supported
> > > > by device trees already (please see 
> > > > arch/arm/boot/dts/r8a7779-marzen.dts).
> > >
> > > How about the following logic ?
> > >
> > >   if (match_index("lvds-encoder") == 0 ||
> > >   match_index("lvds-decoder") == 0)
> > >   return -EINVAL;
> > >
> > >
> >
> > Now I see what you mean
> >
> > > > This patch "classifies" compatible strings, and it considers a good 
> > > > match
> > > > device specific compatible strings, or generic compatible strings as 
> > > > long
> > > > as they are not listed first.
> > > >
> > > > These days you can leverage the yaml files to validate the device trees,
> > > > therefore we should be focusing on writing yaml files in such a way we 
> > > > only
> > > > pass the checks we mean to, and by checks I mean:
> > > > make dtbs_check
> > > >
> > > > or more specifically, for 

[PATCH] drm: radeon: replace 0 with NULL

2019-11-26 Thread Jules Irenge
Replace 0 with NULL to fix sparse tool  warning
 warning: Using plain integer as NULL pointer

Signed-off-by: Jules Irenge 
---
 drivers/gpu/drm/radeon/radeon_audio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/radeon_audio.c 
b/drivers/gpu/drm/radeon/radeon_audio.c
index b9aea5776d3d..2269cfced788 100644
--- a/drivers/gpu/drm/radeon/radeon_audio.c
+++ b/drivers/gpu/drm/radeon/radeon_audio.c
@@ -288,7 +288,7 @@ static void radeon_audio_interface_init(struct 
radeon_device *rdev)
} else {
rdev->audio.funcs = &r600_funcs;
rdev->audio.hdmi_funcs = &r600_hdmi_funcs;
-   rdev->audio.dp_funcs = 0;
+   rdev->audio.dp_funcs = NULL;
}
 }
 
-- 
2.23.0

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

Re: [PATCH 05/15] drm/armada: Delete dma_buf->k(un)map implemenation

2019-11-26 Thread Daniel Vetter
On Tue, Nov 26, 2019 at 1:35 AM Russell King - ARM Linux admin
 wrote:
> On Mon, Nov 25, 2019 at 10:44:43PM +0100, Daniel Vetter wrote:
> > On Mon, Nov 18, 2019 at 11:35:26AM +0100, Daniel Vetter wrote:
> > > It's a dummy anyway.
> > >
> > > Signed-off-by: Daniel Vetter 
> > > Cc: Russell King 
> >
> > I merged the entire series except this one and the final patch, sill
> > waiting a bit more for an ack on this perhaps.
>
> Acked-by: Russell King 

Thanks for taking a look.

> I thought drm trees closed around -rc6?

drm.git closes for pull request. But drm-misc is open all the time, so
that committers can push patches whenever the patches are ready,
instead of having to remember that there's something in the queue. The
script used for drm-misc pushes then makes sure that drm-misc-next
doesn't show up in linux-next until after -rc1. So this is all going
into 5.6.
-Daniel

>
> > -Daniel
> >
> > > ---
> > >  drivers/gpu/drm/armada/armada_gem.c | 12 
> > >  1 file changed, 12 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/armada/armada_gem.c 
> > > b/drivers/gpu/drm/armada/armada_gem.c
> > > index 93cf8b8bfcff..976685f2939e 100644
> > > --- a/drivers/gpu/drm/armada/armada_gem.c
> > > +++ b/drivers/gpu/drm/armada/armada_gem.c
> > > @@ -461,16 +461,6 @@ static void armada_gem_prime_unmap_dma_buf(struct 
> > > dma_buf_attachment *attach,
> > > kfree(sgt);
> > >  }
> > >
> > > -static void *armada_gem_dmabuf_no_kmap(struct dma_buf *buf, unsigned 
> > > long n)
> > > -{
> > > -   return NULL;
> > > -}
> > > -
> > > -static void
> > > -armada_gem_dmabuf_no_kunmap(struct dma_buf *buf, unsigned long n, void 
> > > *addr)
> > > -{
> > > -}
> > > -
> > >  static int
> > >  armada_gem_dmabuf_mmap(struct dma_buf *buf, struct vm_area_struct *vma)
> > >  {
> > > @@ -481,8 +471,6 @@ static const struct dma_buf_ops 
> > > armada_gem_prime_dmabuf_ops = {
> > > .map_dma_buf= armada_gem_prime_map_dma_buf,
> > > .unmap_dma_buf  = armada_gem_prime_unmap_dma_buf,
> > > .release= drm_gem_dmabuf_release,
> > > -   .map= armada_gem_dmabuf_no_kmap,
> > > -   .unmap  = armada_gem_dmabuf_no_kunmap,
> > > .mmap   = armada_gem_dmabuf_mmap,
> > >  };
> > >
> > > --
> > > 2.24.0
> > >
> >
> > --
> > Daniel Vetter
> > Software Engineer, Intel Corporation
> > http://blog.ffwll.ch
> >
>
> --
> RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
> FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
> According to speedtest.net: 11.9Mbps down 500kbps up



-- 
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 3/4] drm/hisilicon/hibmc: Implement hibmc_dumb_create() with generic helpers

2019-11-26 Thread Daniel Vetter
On Tue, Nov 26, 2019 at 08:40:27AM +0100, Thomas Zimmermann wrote:
> Hi
> 
> Am 25.11.19 um 10:14 schrieb Daniel Vetter:
> > On Fri, Nov 22, 2019 at 09:30:43AM +0100, Thomas Zimmermann wrote:
> >> The hibmc driver aligns scanlines to 16 bytes. Adding the pitch alignment
> >> as an argument to drm_gem_vram_fill_create_dumb() allows to use the generic
> >> implementation with hibmc. A value of 0 disables scanline pitches.
> >>
> >> Signed-off-by: Thomas Zimmermann 
> > 
> > I concur with Sam, the vram change should be split out.
> > 
> >> ---
> >>  drivers/gpu/drm/drm_gem_vram_helper.c | 10 ++--
> >>  .../gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h   |  4 --
> >>  drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c   | 48 +--
> >>  include/drm/drm_gem_vram_helper.h |  1 +
> >>  4 files changed, 10 insertions(+), 53 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c 
> >> b/drivers/gpu/drm/drm_gem_vram_helper.c
> >> index 666cb4c22bb9..f098784e7dfd 100644
> >> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> >> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> >> @@ -485,6 +485,7 @@ EXPORT_SYMBOL(drm_gem_vram_vunmap);
> >>   * @dev:  the DRM device
> >>   * @bdev: the TTM BO device managing the buffer object
> >>   * @pg_align: the buffer's alignment in multiples of the page 
> >> size
> >> + * @pitch_align:  the scanline's alignment in powers of 2
> >>   * @interruptible:sleep interruptible if waiting for memory
> > 
> > I also noticed that no one sets this to true, neither here nor in
> > drm_gem_vram_create(). Maybe remove that too? Otherwise the argument list
> > becomes very unwielding. And you're already touching the (few) callers.
> 
> OK, I'll add this as a separate patch.

Yeah makes sense.

> BTW What's the DRM interface's behavior wrt interruption? For example,
> can a ioctl call like CREATE_DUMB return EINTR to userspace?

Yup. Everyone is required to use drmIoctl() for all drm ioctls, which
auto-restarts all syscalls when userspace sees a EINTR. We also generally
test that in igt (but maybe not for all the kms ioctls, at least not for
the dumb ones).

interruptible + igts using igt_while_interruptible is a fairly effective
way to exercise error paths in all kinds of places. Only trouble is that
if we introduce a new interruptible point somewhere we might run into
userspace that gets it wrong (e.g. dumb ioctls I think aren't
interruptible on most x86 drivers right now, so there might be a surprise
and we need to audit userspaces, including plymouth and all those).
-Daniel

> 
> Best regards
> Thomas
> 
> > 
> >>   * @args: the arguments as provided to \
> >>&struct drm_driver.dumb_create
> >> @@ -502,6 +503,7 @@ int drm_gem_vram_fill_create_dumb(struct drm_file 
> >> *file,
> >>  struct drm_device *dev,
> >>  struct ttm_bo_device *bdev,
> >>  unsigned long pg_align,
> >> +unsigned long pitch_align,
> >>  bool interruptible,
> >>  struct drm_mode_create_dumb *args)
> >>  {
> >> @@ -510,7 +512,9 @@ int drm_gem_vram_fill_create_dumb(struct drm_file 
> >> *file,
> >>int ret;
> >>u32 handle;
> >>  
> >> -  pitch = args->width * ((args->bpp + 7) / 8);
> >> +  pitch = args->width * DIV_ROUND_UP(args->bpp, 8);
> >> +  if (pitch_align)
> >> +  pitch = ALIGN(pitch, pitch_align);
> > 
> > Maybe throw a WARN_IS(is_pot(align)) in here?
> > 
> > Cheers, Daniel
> > 
> >>size = pitch * args->height;
> >>  
> >>size = roundup(size, PAGE_SIZE);
> >> @@ -612,8 +616,8 @@ int drm_gem_vram_driver_dumb_create(struct drm_file 
> >> *file,
> >>if (WARN_ONCE(!dev->vram_mm, "VRAM MM not initialized"))
> >>return -EINVAL;
> >>  
> >> -  return drm_gem_vram_fill_create_dumb(file, dev, &dev->vram_mm->bdev, 0,
> >> -   false, args);
> >> +  return drm_gem_vram_fill_create_dumb(file, dev, &dev->vram_mm->bdev,
> >> +   0, 0, false, args);
> >>  }
> >>  EXPORT_SYMBOL(drm_gem_vram_driver_dumb_create);
> >>  
> >> diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h 
> >> b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
> >> index 8eb7258b236a..50a0c1f9d211 100644
> >> --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
> >> +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
> >> @@ -18,7 +18,6 @@
> >>  #include 
> >>  
> >>  struct drm_device;
> >> -struct drm_gem_object;
> >>  
> >>  struct hibmc_drm_private {
> >>/* hw */
> >> @@ -41,9 +40,6 @@ void hibmc_set_current_gate(struct hibmc_drm_private 
> >> *priv,
> >>  int hibmc_de_init(struct hibmc_drm_private *priv);
> >>  int hibmc_vdac_init(struct hibmc_drm_private *priv);
> >>  
> >> -int hibmc_gem_create(struct drm_device *dev, u32 size, bool iskernel,
> >> -   st

radeon UBSAN warning from user syscall

2019-11-26 Thread Meelis Roos

I tried latest (5.4) custom kernel (with UBSAN) on my Dell D600 laptop and 
found that it exhibits a
UBSAN warning triggered by userspace ioctl. Here is dmesg with anything 
radeon-related + the warning, and config:

[   17.659534] [drm] radeon kernel modesetting enabled.
[   17.659607] radeon :01:00.0: remove_conflicting_pci_framebuffers: bar 0: 
0xe800 -> 0xefff
[   17.659609] radeon :01:00.0: remove_conflicting_pci_framebuffers: bar 2: 
0xfcff -> 0xfcff
[   17.659613] radeon :01:00.0: vgaarb: deactivate vga console
[   17.661629] Console: switching to colour dummy device 80x25
[   17.667764] [drm] initializing kernel modesetting (RV250 0x1002:0x4C66 
0x1028:0x011D 0x01).
[   17.667822] resource sanity check: requesting [mem 0x000c-0x000d], 
which spans more than PCI Bus :00 [mem 0x000d-0x000d window]
[   17.667832] caller pci_map_rom+0x6d/0x19a mapping multiple BARs
[   17.668236] agpgart-intel :00:00.0: AGP 2.0 bridge
[   17.668246] agpgart-intel :00:00.0: putting AGP V2 device into 4x mode
[   17.668269] radeon :01:00.0: putting AGP V2 device into 4x mode
[   17.668291] radeon :01:00.0: GTT: 128M 0xE000 - 0xE7FF
[   17.668299] radeon :01:00.0: VRAM: 128M 0xE800 - 
0xEFFF (32M used)
[   17.668336] [drm] Detected VRAM RAM=128M, BAR=128M
[   17.668337] [drm] RAM width 64bits DDR
[   17.681858] [TTM] Zone  kernel: Available graphics memory: 412324 KiB
[   17.681861] [TTM] Initializing pool allocator
[   17.681868] [TTM] Initializing DMA pool allocator
[   17.681905] [drm] radeon: 32M of VRAM memory ready
[   17.681907] [drm] radeon: 128M of GTT memory ready.
[   17.681918] [drm] radeon: power management initialized
[   17.685726] radeon :01:00.0: WB disabled
[   17.685735] radeon :01:00.0: fence driver on ring 0 use gpu addr 
0xe000 and cpu addr 0x116c2780
[   17.685738] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[   17.685739] [drm] Driver supports precise vblank timestamp query.
[   17.685755] [drm] radeon: irq initialized.
[   17.685758] [drm] Loading R200 Microcode
[   17.788181] [drm] radeon: ring at 0xE0001000
[   17.788207] [drm] ring test succeeded in 1 usecs
[   17.788379] [drm] ib test succeeded in 0 usecs
[   17.788845] [drm] Panel ID String: 2K077141X13
  
[   17.788846] [drm] Panel Size 1024x768

[   17.70] [drm] No TV DAC info found in BIOS
[   17.788912] [drm] Radeon Display Connectors
[   17.788913] [drm] Connector 0:
[   17.788914] [drm]   VGA-1
[   17.788916] [drm]   DDC: 0x60 0x60 0x60 0x60 0x60 0x60 0x60 0x60
[   17.788917] [drm]   Encoders:
[   17.788918] [drm] CRT1: INTERNAL_DAC1
[   17.788920] [drm] Connector 1:
[   17.788920] [drm]   DVI-D-1
[   17.788921] [drm]   HPD1
[   17.788923] [drm]   DDC: 0x64 0x64 0x64 0x64 0x64 0x64 0x64 0x64
[   17.788923] [drm]   Encoders:
[   17.788924] [drm] DFP1: INTERNAL_TMDS1
[   17.788925] [drm] Connector 2:
[   17.788925] [drm]   LVDS-1
[   17.788926] [drm]   Encoders:
[   17.788927] [drm] LCD1: INTERNAL_LVDS
[   17.788927] [drm] Connector 3:
[   17.788928] [drm]   SVIDEO-1
[   17.788929] [drm]   Encoders:
[   17.788929] [drm] TV1: INTERNAL_DAC2
[   17.957500] [drm] fb mappable at 0xE804
[   17.957503] [drm] vram apper at 0xE800
[   17.957504] [drm] size 1572864
[   17.957505] [drm] fb depth is 16
[   17.957505] [drm]pitch is 2048
[   18.013861] fbcon: radeondrmfb (fb0) is primary device
[   18.566984] Console: switching to colour frame buffer device 128x48
[   18.576250] radeon :01:00.0: fb0: radeondrmfb frame buffer device
[   18.577844] [drm] Initialized radeon 2.50.0 20080528 for :01:00.0 on 
minor 0
[   64.194226] 

[   64.194238] UBSAN: Undefined behaviour in 
drivers/gpu/drm/radeon/r200.c:480:34
[   64.194244] shift exponent 4096 is too large for 32-bit type 'int'
[   64.194248] CPU: 0 PID: 447 Comm: Xorg Not tainted 5.4.0 #16
[   64.194249] Hardware name: Dell Computer Corporation Latitude D600   
/0X2034, BIOS A16 06/29/2005
[   64.194251] Call Trace:
[   64.194266]  dump_stack+0x16/0x19
[   64.194272]  ubsan_epilogue+0xb/0x29
[   64.194274]  __ubsan_handle_shift_out_of_bounds.cold+0x26/0x78
[   64.194368]  ? radeon_cs_packet_next_reloc+0x3c/0x170 [radeon]
[   64.194403]  ? r100_reloc_pitch_offset+0x27/0x140 [radeon]
[   64.194433]  r200_packet0_check.cold+0x5e/0x63 [radeon]
[   64.194473]  ? r200_copy_dma+0x430/0x430 [radeon]
[   64.194508]  r100_cs_parse_packet0+0x53/0xe0 [radeon]
[   64.194543]  r100_cs_parse+0x2de/0x4b0 [radeon]
[   64.194583]  ? r200_copy_dma+0x430/0x430 [radeon]
[   64.194617]  radeon_cs_ioctl+0x305/0x890 [radeon]
[   64.194626]  ? ttm_bo_init_reserved+0x2f0/0x390 [ttm]
[   64.194662]  ? radeon_cs_parser_init+0x550/0x550 [radeon]
[   64.194689]  drm_ioctl_kernel+0x8b/0xd0 [drm]
[   64.194724]  ? radeon_cs_parser_i

Re: WARNING in md_ioctl

2019-11-26 Thread Daniel Vetter
On Mon, Nov 25, 2019 at 02:37:01PM -0800, syzbot wrote:
> syzbot has bisected this bug to:
> 
> commit 4b6ce6810a5dc0af387a238e8c852e0d3822381f
> Author: Rafael Antognolli 
> Date:   Mon Feb 5 23:33:30 2018 +
> 
> drm/i915/cnl: WaPipeControlBefore3DStateSamplePattern

This seems very unlikely, the reproducer doesn't open a drm device, and
I'd be surprised if your gcd instances have an actual i915 device in them
(but I can't check because boot log isn't provided, didn't find it on the
dashboard either).

Since i915 is built-in I suspect this simply moved something else in the
kernel image around which provokes the bug.
-Daniel

> 
> bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=13aeb522e0
> start commit:   c61a56ab Merge branch 'x86-urgent-for-linus' of git://git...
> git tree:   upstream
> final crash:https://syzkaller.appspot.com/x/report.txt?x=106eb522e0
> console output: https://syzkaller.appspot.com/x/log.txt?x=17aeb522e0
> kernel config:  https://syzkaller.appspot.com/x/.config?x=4013180e7c7a9ff9
> dashboard link: https://syzkaller.appspot.com/bug?extid=1e46a0864c1a6e9bd3d8
> syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=16bca20780
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=14819a4780
> 
> Reported-by: syzbot+1e46a0864c1a6e9bd...@syzkaller.appspotmail.com
> Fixes: 4b6ce6810a5d ("drm/i915/cnl:
> WaPipeControlBefore3DStateSamplePattern")
> 
> For information about bisection process see: https://goo.gl/tpsmEJ#bisection
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH 0/5] drm/udl: Convert to GEM framebuffer helpers

2019-11-26 Thread Thomas Zimmermann


Am 25.11.19 um 19:39 schrieb Sam Ravnborg:
> Hi Thomas.
> 
> On Thu, Nov 14, 2019 at 03:10:20PM +0100, Thomas Zimmermann wrote:
>> Udl uses struct udl_framebuffer for representing its framebuffer. The
>> type can be replaced by the standard DRM framebuffer structure.
>>
>> Patches 1 to 4 prepare the driver for the conversion. Patch 5 replaces
>> the structure.
>>
>> The patchset has been tested by running the fb console, X11 and Weston
>> on a DisplayLink adapter.
> 
> Series looks good, with some nice cleanup to prepare for the
> removal of udl_framebuffer.
> 
> Whole series is:
> Acked-by: Sam Ravnborg 

Thanks!

> 
>>
>> Thomas Zimmermann (5):
>>   drm/udl: Unmap buffer object after damage update
>>   drm/udl: Remove udl implementation of GEM's free_object()
>>   drm/udl: Store active framebuffer in device structure
>>   drm/udl: Call udl_handle_damage() with DRM framebuffer
>>   drm/udl: Replace struct udl_framebuffer with generic implementation
>>
>>  drivers/gpu/drm/udl/udl_drv.h |  14 ++--
>>  drivers/gpu/drm/udl/udl_fb.c  | 131 +++---
>>  drivers/gpu/drm/udl/udl_gem.c |  18 +---
>>  drivers/gpu/drm/udl/udl_main.c|   3 +
>>  drivers/gpu/drm/udl/udl_modeset.c |  31 +++
>>  5 files changed, 70 insertions(+), 127 deletions(-)
>>
>> --
>> 2.23.0

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer



signature.asc
Description: OpenPGP digital signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH 1/7] drm/mediatek: fix atomic_state reference counting

2019-11-26 Thread Daniel Vetter
On Tue, Nov 26, 2019 at 02:29:26PM +0800, Bibby Hsieh wrote:
> The DRM core takes care of all atomic state refcounting.
> However, mediatek drm defers some work that accesses planes
> and plane_states in drm_atomic_state, and must therefore
> keep its own atomic state references until this work complete.
> 
> We take the atomic_state reference in atomic_fulsh() and ensure all the
> information in atomic_state already was updated in hardware for
> showing on screen and then schedules unreference_work to drop references
> on atomic_state.
> 
> Fixes: 119f5173628a ("drm/mediatek: Add DRM Driver for Mediatek SoC MT8173.")
> 
> Signed-off-by: Bibby Hsieh 

This looks strange. For one you implement your own reference counting - if
drivers have a need for drm_atomic_state_put_irq then I
think we should implement this in the core code.

The other bit is that atomic commits are meant to simply wait for
everything to finish - commit_tail doesn't hold locks, it's only ordered
through drm_crtc_commit events (at least with the async implementation in
the helpers), so you can just block there until your interrupt handler is
done processing the commit. Depending how you want to do this you might
want to wait before or after drm_atomic_helper_commit_hw_done().
-Daniel

> ---
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 11 +++-
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c  | 79 +
>  drivers/gpu/drm/mediatek/mtk_drm_drv.h  |  9 +++
>  3 files changed, 97 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c 
> b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index 29d0582e90e9..68b92adc96bb 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -7,7 +7,7 @@
>  #include 
>  
>  #include 
> -
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -47,6 +47,7 @@ struct mtk_drm_crtc {
>   struct mtk_disp_mutex   *mutex;
>   unsigned intddp_comp_nr;
>   struct mtk_ddp_comp **ddp_comp;
> + struct drm_crtc_state   *old_crtc_state;
>  };
>  
>  struct mtk_crtc_state {
> @@ -362,6 +363,7 @@ static void mtk_crtc_ddp_hw_fini(struct mtk_drm_crtc 
> *mtk_crtc)
>  static void mtk_crtc_ddp_config(struct drm_crtc *crtc)
>  {
>   struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
> + struct drm_atomic_state *atomic_state = mtk_crtc->old_crtc_state->state;
>   struct mtk_crtc_state *state = to_mtk_crtc_state(mtk_crtc->base.state);
>   struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0];
>   unsigned int i;
> @@ -399,6 +401,7 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc)
>   plane_state->pending.config = false;
>   }
>   mtk_crtc->pending_planes = false;
> + mtk_atomic_state_put_queue(atomic_state);
>   }
>  }
>  
> @@ -494,6 +497,7 @@ static void mtk_drm_crtc_atomic_begin(struct drm_crtc 
> *crtc,
>  static void mtk_drm_crtc_atomic_flush(struct drm_crtc *crtc,
> struct drm_crtc_state *old_crtc_state)
>  {
> + struct drm_atomic_state *old_atomic_state = old_crtc_state->state;
>   struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
>   struct mtk_drm_private *priv = crtc->dev->dev_private;
>   unsigned int pending_planes = 0;
> @@ -512,8 +516,11 @@ static void mtk_drm_crtc_atomic_flush(struct drm_crtc 
> *crtc,
>   pending_planes |= BIT(i);
>   }
>   }
> - if (pending_planes)
> + if (pending_planes) {
>   mtk_crtc->pending_planes = true;
> + drm_atomic_state_get(old_atomic_state);
> + mtk_crtc->old_crtc_state = old_crtc_state;
> + }
>   if (crtc->state->color_mgmt_changed)
>   for (i = 0; i < mtk_crtc->ddp_comp_nr; i++)
>   mtk_ddp_gamma_set(mtk_crtc->ddp_comp[i], crtc->state);
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c 
> b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index 6588dc6dd5e3..6c68283b6124 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -115,10 +115,85 @@ static int mtk_atomic_commit(struct drm_device *drm,
>   return 0;
>  }
>  
> +struct mtk_atomic_state {
> + struct drm_atomic_state base;
> + struct list_head list;
> +};
> +
> +static inline struct mtk_atomic_state *to_mtk_state(struct drm_atomic_state 
> *s)
> +{
> + return container_of(s, struct mtk_atomic_state, base);
> +}
> +
> +void mtk_atomic_state_put_queue(struct drm_atomic_state *state)
> +{
> + struct drm_device *drm = state->dev;
> + struct mtk_drm_private *mtk_drm = drm->dev_private;
> + struct mtk_atomic_state *mtk_state = to_mtk_state(state);
> + unsigned long flags;
> +
> + spin_lock_irqsave(&mtk_drm->unreference.lock, flags);
> + list_add_tail(&mtk_state->list, &mtk_drm->unreference.list);
> + spin_unlock_irqrestore(&mtk_drm->unrefer

Re: [PATCH v3 1/2] drm/sched: Avoid job cleanup if sched thread is parked.

2019-11-26 Thread Christian König

Am 25.11.19 um 17:51 schrieb Steven Price:

On 25/11/2019 14:10, Andrey Grodzovsky wrote:

When the sched thread is parked we assume ring_mirror_list is
not accessed from here.

FWIW I don't think this is necessary. kthread_park() will wait until the
thread is parked, at which point the thread is stuck in kthread_parkme()
until unparked.

So all this does is avoid waiting for any cleanup jobs before parking -
which might be a reasonable goal in itself, but if so lets at least
document that.


Now that you mention it that is indeed wrong.

The real problem is that in the main thread we mangled the call to 
kthread_parkme() into drm_sched_blocked() which can be called in atomic 
context.


I suggest to rework this so that the kthread_should_park() and 
kthread_should_stop() test in wait_event_interruptible() come first and 
then call kthread_parkme() outside of the wait_event_interruptible().


Regards,
Christian.



Steve


Signed-off-by: Andrey Grodzovsky 
Reviewed-by: Christian König 
---
  drivers/gpu/drm/scheduler/sched_main.c | 10 +++---
  1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/scheduler/sched_main.c 
b/drivers/gpu/drm/scheduler/sched_main.c
index d4cc728..6774955 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -635,9 +635,13 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
struct drm_sched_job *job;
unsigned long flags;
  
-	/* Don't destroy jobs while the timeout worker is running */

-   if (sched->timeout != MAX_SCHEDULE_TIMEOUT &&
-   !cancel_delayed_work(&sched->work_tdr))
+   /*
+   * Don't destroy jobs while the timeout worker is running  OR thread
+   * is being parked and hence assumed to not touch ring_mirror_list
+   */
+   if ((sched->timeout != MAX_SCHEDULE_TIMEOUT &&
+!cancel_delayed_work(&sched->work_tdr)) ||
+__kthread_should_park(sched->thread))
return NULL;
  
  	spin_lock_irqsave(&sched->job_list_lock, flags);



___
amd-gfx mailing list
amd-...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


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

[PATCH 1/2] drm/fourcc: Fill out all block sizes for P10/12/16

2019-11-26 Thread Daniel Vetter
0 means 1 as the default, but it's mighty confusing if the block size
for the first plane is spelled out explicitly, but not for the 2nd
plane.

No cc: stable because this is just confusion, but 0 functional issue.

Fixes: 05f8bc82fc42 ("drm/fourcc: Add new P010, P016 video format")
Cc: Daniel Stone 
Cc: Ville Syrjälä 
Cc: Randy Li 
Cc: Clint Taylor 
Cc: Ayan Kumar Halder 
Cc: Neil Armstrong 
Cc: Daniel Vetter 
Cc: Maarten Lankhorst 
Cc: Maxime Ripard 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_fourcc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
index c630064ccf41..fe79ce857c8a 100644
--- a/drivers/gpu/drm/drm_fourcc.c
+++ b/drivers/gpu/drm/drm_fourcc.c
@@ -253,13 +253,13 @@ const struct drm_format_info *__drm_format_info(u32 
format)
  .char_per_block = { 8, 0, 0 }, .block_w = { 2, 0, 0 }, 
.block_h = { 2, 0, 0 },
  .hsub = 2, .vsub = 2, .is_yuv = true },
{ .format = DRM_FORMAT_P010,.depth = 0,  
.num_planes = 2,
- .char_per_block = { 2, 4, 0 }, .block_w = { 1, 0, 0 }, 
.block_h = { 1, 0, 0 },
+ .char_per_block = { 2, 4, 0 }, .block_w = { 1, 1, 0 }, 
.block_h = { 1, 1, 0 },
  .hsub = 2, .vsub = 2, .is_yuv = true},
{ .format = DRM_FORMAT_P012,.depth = 0,  
.num_planes = 2,
- .char_per_block = { 2, 4, 0 }, .block_w = { 1, 0, 0 }, 
.block_h = { 1, 0, 0 },
+ .char_per_block = { 2, 4, 0 }, .block_w = { 1, 1, 0 }, 
.block_h = { 1, 1, 0 },
   .hsub = 2, .vsub = 2, .is_yuv = true},
{ .format = DRM_FORMAT_P016,.depth = 0,  
.num_planes = 2,
- .char_per_block = { 2, 4, 0 }, .block_w = { 1, 0, 0 }, 
.block_h = { 1, 0, 0 },
+ .char_per_block = { 2, 4, 0 }, .block_w = { 1, 1, 0 }, 
.block_h = { 1, 1, 0 },
  .hsub = 2, .vsub = 2, .is_yuv = true},
{ .format = DRM_FORMAT_P210,.depth = 0,
  .num_planes = 2, .char_per_block = { 2, 4, 0 },
-- 
2.24.0

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

[PATCH 2/2] drm/fourcc: Fill out all block sizes for P210

2019-11-26 Thread Daniel Vetter
0 means 1 as the default, but it's mighty confusing if the block size
for the first plane is spelled out explicitly, but not for the 2nd
plane.

No cc: stable because this is just confusion, but 0 functional issue.

Fixes: 7ba0fee247ee ("drm/fourcc: Add AFBC yuv fourccs for Mali")
Cc: Brian Starkey 
Cc: Ayan Kumar Halder 
Cc: Liviu Dudau 
Cc: Alyssa Rosenzweig 
Cc: Maarten Lankhorst 
Cc: Maxime Ripard 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_fourcc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
index fe79ce857c8a..b234bfaeda06 100644
--- a/drivers/gpu/drm/drm_fourcc.c
+++ b/drivers/gpu/drm/drm_fourcc.c
@@ -263,7 +263,7 @@ const struct drm_format_info *__drm_format_info(u32 format)
  .hsub = 2, .vsub = 2, .is_yuv = true},
{ .format = DRM_FORMAT_P210,.depth = 0,
  .num_planes = 2, .char_per_block = { 2, 4, 0 },
- .block_w = { 1, 0, 0 }, .block_h = { 1, 0, 0 }, .hsub = 2,
+ .block_w = { 1, 1, 0 }, .block_h = { 1, 1, 0 }, .hsub = 2,
  .vsub = 1, .is_yuv = true },
{ .format = DRM_FORMAT_VUY101010,   .depth = 0,
  .num_planes = 1, .cpp = { 0, 0, 0 }, .hsub = 1, .vsub = 1,
-- 
2.24.0

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

[PATCH v2 5/5] drm/hisilicon/hibmc: Export VRAM MM information to debugfs

2019-11-26 Thread Thomas Zimmermann
This change makes information about VRAM consumption available on
debugfs. See

  /sys/kernel/debug/dri/0/vram-mm

for an overview of how VRAM is being used.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Daniel Vetter 
Acked-by: Sam Ravnborg 
---
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
index 113d27b8a8f1..11d1b0761c9a 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
@@ -55,6 +55,7 @@ static struct drm_driver hibmc_driver = {
.desc   = "hibmc drm driver",
.major  = 1,
.minor  = 0,
+   .debugfs_init   = drm_vram_mm_debugfs_init,
.dumb_create= hibmc_dumb_create,
.dumb_map_offset= drm_gem_vram_driver_dumb_mmap_offset,
.gem_prime_mmap = drm_gem_prime_mmap,
-- 
2.23.0

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

[PATCH v2 0/5] Replace hibmc code with generic implmentation

2019-11-26 Thread Thomas Zimmermann
The patch set replaces code in hibmc with generic implementation.

Patches 1 to 4 replace fbdev emuation, framebuffer and creation of
dumb buffers with respective code from DRM helpers. Patch 5 adds an
additional interface to debugfs that displays the allocated and free
areas in video memory.

The patches have only been compile-tested. Further testing is
appreciated.

v2:
* split [3/4] into vram and hibmc changes
* verify that pitch_align is power of two

Thomas Zimmermann (5):
  drm/hisilicon/hibmc: Switch to generic fbdev emulation
  drm/hisilicon/hibmc: Replace struct hibmc_framebuffer with generic
code
  drm/vram: Support scanline alignment for dumb buffers
  drm/hisilicon/hibmc: Implement hibmc_dumb_create() with generic
helpers
  drm/hisilicon/hibmc: Export VRAM MM information to debugfs

 drivers/gpu/drm/drm_gem_vram_helper.c |  13 +-
 drivers/gpu/drm/hisilicon/hibmc/Makefile  |   2 +-
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_de.c|   4 +-
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c   |   6 +-
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h   |  26 --
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c | 240 --
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c   | 117 +
 include/drm/drm_gem_vram_helper.h |   1 +
 8 files changed, 20 insertions(+), 389 deletions(-)
 delete mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c

--
2.23.0

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

[PATCH v2 1/5] drm/hisilicon/hibmc: Switch to generic fbdev emulation

2019-11-26 Thread Thomas Zimmermann
There's nothing special about hibmc's fbdev emulation that is not
provided by the generic implementation. Switch over and remove the
driver's code.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Daniel Vetter 
Acked-by: Sam Ravnborg 
---
 drivers/gpu/drm/hisilicon/hibmc/Makefile  |   2 +-
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c   |   5 +-
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h   |  11 -
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c | 240 --
 4 files changed, 3 insertions(+), 255 deletions(-)
 delete mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c

diff --git a/drivers/gpu/drm/hisilicon/hibmc/Makefile 
b/drivers/gpu/drm/hisilicon/hibmc/Makefile
index 0c2d4296bccd..f99132715597 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/Makefile
+++ b/drivers/gpu/drm/hisilicon/hibmc/Makefile
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
-hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_de.o hibmc_drm_vdac.o 
hibmc_drm_fbdev.o hibmc_ttm.o
+hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_de.o hibmc_drm_vdac.o hibmc_ttm.o
 
 obj-$(CONFIG_DRM_HISI_HIBMC) += hibmc-drm.o
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
index 2fd4ca91a62d..113d27b8a8f1 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
@@ -17,6 +17,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -247,8 +248,6 @@ static int hibmc_unload(struct drm_device *dev)
 {
struct hibmc_drm_private *priv = dev->dev_private;
 
-   hibmc_fbdev_fini(priv);
-
drm_atomic_helper_shutdown(dev);
 
if (dev->irq_enabled)
@@ -307,7 +306,7 @@ static int hibmc_load(struct drm_device *dev)
/* reset all the states of crtc/plane/encoder/connector */
drm_mode_config_reset(dev);
 
-   ret = hibmc_fbdev_init(priv);
+   ret = drm_fbdev_generic_setup(dev, 16);
if (ret) {
DRM_ERROR("failed to initialize fbdev: %d\n", ret);
goto err;
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
index e58ecd7edcf8..b34493ead30b 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
@@ -25,12 +25,6 @@ struct hibmc_framebuffer {
struct drm_gem_object *obj;
 };
 
-struct hibmc_fbdev {
-   struct drm_fb_helper helper; /* must be first */
-   struct hibmc_framebuffer *fb;
-   int size;
-};
-
 struct hibmc_drm_private {
/* hw */
void __iomem   *mmio;
@@ -42,9 +36,6 @@ struct hibmc_drm_private {
/* drm */
struct drm_device  *dev;
bool mode_config_initialized;
-
-   /* fbdev */
-   struct hibmc_fbdev *fbdev;
 };
 
 #define to_hibmc_framebuffer(x) container_of(x, struct hibmc_framebuffer, fb)
@@ -56,8 +47,6 @@ void hibmc_set_current_gate(struct hibmc_drm_private *priv,
 
 int hibmc_de_init(struct hibmc_drm_private *priv);
 int hibmc_vdac_init(struct hibmc_drm_private *priv);
-int hibmc_fbdev_init(struct hibmc_drm_private *priv);
-void hibmc_fbdev_fini(struct hibmc_drm_private *priv);
 
 int hibmc_gem_create(struct drm_device *dev, u32 size, bool iskernel,
 struct drm_gem_object **obj);
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c
deleted file mode 100644
index b4c1cea051e8..
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c
+++ /dev/null
@@ -1,240 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/* Hisilicon Hibmc SoC drm driver
- *
- * Based on the bochs drm driver.
- *
- * Copyright (c) 2016 Huawei Limited.
- *
- * Author:
- * Rongrong Zou 
- * Rongrong Zou 
- * Jianhua Li 
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include "hibmc_drm_drv.h"
-
-static int hibmcfb_create_object(
-   struct hibmc_drm_private *priv,
-   const struct drm_mode_fb_cmd2 *mode_cmd,
-   struct drm_gem_object **gobj_p)
-{
-   struct drm_gem_object *gobj;
-   struct drm_device *dev = priv->dev;
-   u32 size;
-   int ret = 0;
-
-   size = mode_cmd->pitches[0] * mode_cmd->height;
-   ret = hibmc_gem_create(dev, size, true, &gobj);
-   if (ret)
-   return ret;
-
-   *gobj_p = gobj;
-   return ret;
-}
-
-static struct fb_ops hibmc_drm_fb_ops = {
-   .owner = THIS_MODULE,
-   .fb_check_var = drm_fb_helper_check_var,
-   .fb_set_par = drm_fb_helper_set_par,
-   .fb_fillrect = drm_fb_helper_sys_fillrect,
-   .fb_copyarea = drm_fb_helper_sys_copyarea,
-   .fb_imageblit = drm_fb_helper_sys_imageblit,
-   .fb_pan_display = drm_fb_helper_pan_display,
-   .fb_blank = drm_fb_helper_blank,
-   .fb_setcmap = drm_fb_helper_setcmap,
-};
-
-static int hibmc_drm_fb_create(struct d

[PATCH v2 4/5] drm/hisilicon/hibmc: Implement hibmc_dumb_create() with generic helpers

2019-11-26 Thread Thomas Zimmermann
The hibmc driver aligns scanlines to 16 bytes. By using the new pitch_align
argument of drm_gem_vram_fill_create_dumb(), convert hibmc over.

v2:
* move changes to VRAM helpers into separate patch

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Daniel Vetter 
Acked-by: Sam Ravnborg 
---
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h   |  4 --
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c   | 48 +--
 2 files changed, 2 insertions(+), 50 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
index 8eb7258b236a..50a0c1f9d211 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
@@ -18,7 +18,6 @@
 #include 
 
 struct drm_device;
-struct drm_gem_object;
 
 struct hibmc_drm_private {
/* hw */
@@ -41,9 +40,6 @@ void hibmc_set_current_gate(struct hibmc_drm_private *priv,
 int hibmc_de_init(struct hibmc_drm_private *priv);
 int hibmc_vdac_init(struct hibmc_drm_private *priv);
 
-int hibmc_gem_create(struct drm_device *dev, u32 size, bool iskernel,
-struct drm_gem_object **obj);
-
 int hibmc_mm_init(struct hibmc_drm_private *hibmc);
 void hibmc_mm_fini(struct hibmc_drm_private *hibmc);
 int hibmc_dumb_create(struct drm_file *file, struct drm_device *dev,
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
index f6d25b85c209..0af5d966a480 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
@@ -47,55 +47,11 @@ void hibmc_mm_fini(struct hibmc_drm_private *hibmc)
drm_vram_helper_release_mm(hibmc->dev);
 }
 
-int hibmc_gem_create(struct drm_device *dev, u32 size, bool iskernel,
-struct drm_gem_object **obj)
-{
-   struct drm_gem_vram_object *gbo;
-   int ret;
-
-   *obj = NULL;
-
-   size = roundup(size, PAGE_SIZE);
-   if (size == 0)
-   return -EINVAL;
-
-   gbo = drm_gem_vram_create(dev, &dev->vram_mm->bdev, size, 0, false);
-   if (IS_ERR(gbo)) {
-   ret = PTR_ERR(gbo);
-   if (ret != -ERESTARTSYS)
-   DRM_ERROR("failed to allocate GEM object: %d\n", ret);
-   return ret;
-   }
-   *obj = &gbo->bo.base;
-   return 0;
-}
-
 int hibmc_dumb_create(struct drm_file *file, struct drm_device *dev,
  struct drm_mode_create_dumb *args)
 {
-   struct drm_gem_object *gobj;
-   u32 handle;
-   int ret;
-
-   args->pitch = ALIGN(args->width * DIV_ROUND_UP(args->bpp, 8), 16);
-   args->size = args->pitch * args->height;
-
-   ret = hibmc_gem_create(dev, args->size, false,
-  &gobj);
-   if (ret) {
-   DRM_ERROR("failed to create GEM object: %d\n", ret);
-   return ret;
-   }
-
-   ret = drm_gem_handle_create(file, gobj, &handle);
-   drm_gem_object_put_unlocked(gobj);
-   if (ret) {
-   DRM_ERROR("failed to unreference GEM object: %d\n", ret);
-   return ret;
-   }
-
-   args->handle = handle;
-   return 0;
+   return drm_gem_vram_fill_create_dumb(file, dev, &dev->vram_mm->bdev,
+0, 16, false, args);
 }
 
 const struct drm_mode_config_funcs hibmc_mode_funcs = {
-- 
2.23.0

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

[PATCH v2 2/5] drm/hisilicon/hibmc: Replace struct hibmc_framebuffer with generic code

2019-11-26 Thread Thomas Zimmermann
The hibmc driver's struct hibmc_framebuffer stores a DRM framebuffer
with an associated GEM object. This functionality is also provided by
generic code. Switch hibmc over.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Daniel Vetter 
Acked-by: Sam Ravnborg 
---
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_de.c|  4 +-
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h   | 11 ---
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c   | 69 +--
 3 files changed, 3 insertions(+), 81 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
index 6527a97f68a3..7fa7d4933f60 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
@@ -99,14 +99,12 @@ static void hibmc_plane_atomic_update(struct drm_plane 
*plane,
s64 gpu_addr = 0;
unsigned int line_l;
struct hibmc_drm_private *priv = plane->dev->dev_private;
-   struct hibmc_framebuffer *hibmc_fb;
struct drm_gem_vram_object *gbo;
 
if (!state->fb)
return;
 
-   hibmc_fb = to_hibmc_framebuffer(state->fb);
-   gbo = drm_gem_vram_of_gem(hibmc_fb->obj);
+   gbo = drm_gem_vram_of_gem(state->fb->obj[0]);
 
gpu_addr = drm_gem_vram_offset(gbo);
if (WARN_ON_ONCE(gpu_addr < 0))
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
index b34493ead30b..8eb7258b236a 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
@@ -20,11 +20,6 @@
 struct drm_device;
 struct drm_gem_object;
 
-struct hibmc_framebuffer {
-   struct drm_framebuffer fb;
-   struct drm_gem_object *obj;
-};
-
 struct hibmc_drm_private {
/* hw */
void __iomem   *mmio;
@@ -38,8 +33,6 @@ struct hibmc_drm_private {
bool mode_config_initialized;
 };
 
-#define to_hibmc_framebuffer(x) container_of(x, struct hibmc_framebuffer, fb)
-
 void hibmc_set_power_mode(struct hibmc_drm_private *priv,
  unsigned int power_mode);
 void hibmc_set_current_gate(struct hibmc_drm_private *priv,
@@ -50,10 +43,6 @@ int hibmc_vdac_init(struct hibmc_drm_private *priv);
 
 int hibmc_gem_create(struct drm_device *dev, u32 size, bool iskernel,
 struct drm_gem_object **obj);
-struct hibmc_framebuffer *
-hibmc_framebuffer_init(struct drm_device *dev,
-  const struct drm_mode_fb_cmd2 *mode_cmd,
-  struct drm_gem_object *obj);
 
 int hibmc_mm_init(struct hibmc_drm_private *hibmc);
 void hibmc_mm_fini(struct hibmc_drm_private *hibmc);
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
index 21b684eab5c9..f6d25b85c209 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -97,74 +98,8 @@ int hibmc_dumb_create(struct drm_file *file, struct 
drm_device *dev,
return 0;
 }
 
-static void hibmc_user_framebuffer_destroy(struct drm_framebuffer *fb)
-{
-   struct hibmc_framebuffer *hibmc_fb = to_hibmc_framebuffer(fb);
-
-   drm_gem_object_put_unlocked(hibmc_fb->obj);
-   drm_framebuffer_cleanup(fb);
-   kfree(hibmc_fb);
-}
-
-static const struct drm_framebuffer_funcs hibmc_fb_funcs = {
-   .destroy = hibmc_user_framebuffer_destroy,
-};
-
-struct hibmc_framebuffer *
-hibmc_framebuffer_init(struct drm_device *dev,
-  const struct drm_mode_fb_cmd2 *mode_cmd,
-  struct drm_gem_object *obj)
-{
-   struct hibmc_framebuffer *hibmc_fb;
-   int ret;
-
-   hibmc_fb = kzalloc(sizeof(*hibmc_fb), GFP_KERNEL);
-   if (!hibmc_fb) {
-   DRM_ERROR("failed to allocate hibmc_fb\n");
-   return ERR_PTR(-ENOMEM);
-   }
-
-   drm_helper_mode_fill_fb_struct(dev, &hibmc_fb->fb, mode_cmd);
-   hibmc_fb->obj = obj;
-   ret = drm_framebuffer_init(dev, &hibmc_fb->fb, &hibmc_fb_funcs);
-   if (ret) {
-   DRM_ERROR("drm_framebuffer_init failed: %d\n", ret);
-   kfree(hibmc_fb);
-   return ERR_PTR(ret);
-   }
-
-   return hibmc_fb;
-}
-
-static struct drm_framebuffer *
-hibmc_user_framebuffer_create(struct drm_device *dev,
- struct drm_file *filp,
- const struct drm_mode_fb_cmd2 *mode_cmd)
-{
-   struct drm_gem_object *obj;
-   struct hibmc_framebuffer *hibmc_fb;
-
-   DRM_DEBUG_DRIVER("%dx%d, format %c%c%c%c\n",
-mode_cmd->width, mode_cmd->height,
-(mode_cmd->pixel_format) & 0xff,
-(mode_cmd->pixel_format >> 8)  & 0xff,
-(mode_cmd->pixel_format >> 16) & 0xff,
-(mode_cmd->pixel_format >> 24) & 0xff);
-
-   

[PATCH v2 3/5] drm/vram: Support scanline alignment for dumb buffers

2019-11-26 Thread Thomas Zimmermann
Adding the pitch alignment as an argument to drm_gem_vram_fill_create_dumb()
allows to align scanlines to certain offsets. A value of 0 disables scanline
pitches.

v2:
* split of patch from related hibmc changes
* test if scanline pitch is power of 2

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Daniel Vetter 
Acked-by: Sam Ravnborg 
---
 drivers/gpu/drm/drm_gem_vram_helper.c | 13 ++---
 include/drm/drm_gem_vram_helper.h |  1 +
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c 
b/drivers/gpu/drm/drm_gem_vram_helper.c
index 666cb4c22bb9..ee37c2629943 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -485,6 +485,7 @@ EXPORT_SYMBOL(drm_gem_vram_vunmap);
  * @dev:   the DRM device
  * @bdev:  the TTM BO device managing the buffer object
  * @pg_align:  the buffer's alignment in multiples of the page size
+ * @pitch_align:   the scanline's alignment in powers of 2
  * @interruptible: sleep interruptible if waiting for memory
  * @args:  the arguments as provided to \
&struct drm_driver.dumb_create
@@ -502,6 +503,7 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file,
  struct drm_device *dev,
  struct ttm_bo_device *bdev,
  unsigned long pg_align,
+ unsigned long pitch_align,
  bool interruptible,
  struct drm_mode_create_dumb *args)
 {
@@ -510,7 +512,12 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file,
int ret;
u32 handle;
 
-   pitch = args->width * ((args->bpp + 7) / 8);
+   if (WARN_ON_ONCE(!is_power_of_2(pitch_align)))
+   return -EINVAL;
+
+   pitch = args->width * DIV_ROUND_UP(args->bpp, 8);
+   if (pitch_align)
+   pitch = ALIGN(pitch, pitch_align);
size = pitch * args->height;
 
size = roundup(size, PAGE_SIZE);
@@ -612,8 +619,8 @@ int drm_gem_vram_driver_dumb_create(struct drm_file *file,
if (WARN_ONCE(!dev->vram_mm, "VRAM MM not initialized"))
return -EINVAL;
 
-   return drm_gem_vram_fill_create_dumb(file, dev, &dev->vram_mm->bdev, 0,
-false, args);
+   return drm_gem_vram_fill_create_dumb(file, dev, &dev->vram_mm->bdev,
+0, 0, false, args);
 }
 EXPORT_SYMBOL(drm_gem_vram_driver_dumb_create);
 
diff --git a/include/drm/drm_gem_vram_helper.h 
b/include/drm/drm_gem_vram_helper.h
index e040541a105f..c642b4cb6600 100644
--- a/include/drm/drm_gem_vram_helper.h
+++ b/include/drm/drm_gem_vram_helper.h
@@ -113,6 +113,7 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file,
  struct drm_device *dev,
  struct ttm_bo_device *bdev,
  unsigned long pg_align,
+ unsigned long pitch_align,
  bool interruptible,
  struct drm_mode_create_dumb *args);
 
-- 
2.23.0

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

Re: [PATCH 3/4] drm/mgag200: Add workaround for HW that does not support 'startadd'

2019-11-26 Thread Daniel Vetter
On Tue, Nov 26, 2019 at 08:25:44AM +0100, Thomas Zimmermann wrote:
> There's at least one system that does not interpret the value of
> the device's 'startadd' field correctly, which leads to incorrectly
> displayed scanout buffers. Always placing the active scanout buffer
> at offset 0 works around the problem.
> 
> Signed-off-by: Thomas Zimmermann 
> Reported-by: John Donnelly 
> Link: https://gitlab.freedesktop.org/drm/misc/issues/7

Tested-by: John Donnelly 

(Not quite this patch, but pretty much the logic, so counts).

Fixes: 81da87f63a1e ("drm: Replace drm_gem_vram_push_to_system() with kunmap + 
unpin")
Cc:  # v5.3+

Also you need the stable line on both prep patches too. For next time
around,

$ dim fixes 81da87f63a1e

will generate all the stuff you need, including a good set of suggested
Cc: you should have.

On the first 3 patches, with all that stuff added:

Reviewed-by: Daniel Vetter 

Please push these to drm-misc-next-fixes so they get backported as quickly
as possible.
-Daniel

> ---
>  drivers/gpu/drm/mgag200/mgag200_drv.c | 36 ++-
>  drivers/gpu/drm/mgag200/mgag200_drv.h |  3 +++
>  2 files changed, 38 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c 
> b/drivers/gpu/drm/mgag200/mgag200_drv.c
> index 397f8b0a9af8..d43951caeea0 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_drv.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
> @@ -30,6 +30,8 @@ module_param_named(modeset, mgag200_modeset, int, 0400);
>  static struct drm_driver driver;
>  
>  static const struct pci_device_id pciidlist[] = {
> + { PCI_VENDOR_ID_MATROX, 0x522, PCI_VENDOR_ID_SUN, 0x4852, 0, 0,
> + G200_SE_A | MGAG200_FLAG_HW_BUG_NO_STARTADD},
>   { PCI_VENDOR_ID_MATROX, 0x522, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_SE_A 
> },
>   { PCI_VENDOR_ID_MATROX, 0x524, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_SE_B 
> },
>   { PCI_VENDOR_ID_MATROX, 0x530, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_EV },
> @@ -60,6 +62,35 @@ static void mga_pci_remove(struct pci_dev *pdev)
>  
>  DEFINE_DRM_GEM_FOPS(mgag200_driver_fops);
>  
> +static bool mgag200_pin_bo_at_0(const struct mga_device *mdev)
> +{
> + return mdev->flags & MGAG200_FLAG_HW_BUG_NO_STARTADD;
> +}
> +
> +int mgag200_driver_dumb_create(struct drm_file *file,
> +struct drm_device *dev,
> +struct drm_mode_create_dumb *args)
> +{
> + struct mga_device *mdev = dev->dev_private;
> + unsigned long pg_align;
> +
> + if (WARN_ONCE(!dev->vram_mm, "VRAM MM not initialized"))
> + return -EINVAL;
> +
> + pg_align = 0ul;
> +
> + /*
> +  * Aligning scanout buffers to the size of the video ram forces
> +  * placement at offset 0. Works around a bug where HW does not
> +  * respect 'startadd' field.
> +  */
> + if (mgag200_pin_bo_at_0(mdev))
> + pg_align = PFN_UP(mdev->mc.vram_size);
> +
> + return drm_gem_vram_fill_create_dumb(file, dev, &dev->vram_mm->bdev,
> +  pg_align, false, args);
> +}
> +
>  static struct drm_driver driver = {
>   .driver_features = DRIVER_GEM | DRIVER_MODESET,
>   .load = mgag200_driver_load,
> @@ -71,7 +102,10 @@ static struct drm_driver driver = {
>   .major = DRIVER_MAJOR,
>   .minor = DRIVER_MINOR,
>   .patchlevel = DRIVER_PATCHLEVEL,
> - DRM_GEM_VRAM_DRIVER
> + .debugfs_init = drm_vram_mm_debugfs_init,
> + .dumb_create = mgag200_driver_dumb_create,
> + .dumb_map_offset = drm_gem_vram_driver_dumb_mmap_offset,
> + .gem_prime_mmap = drm_gem_prime_mmap,
>  };
>  
>  static struct pci_driver mgag200_pci_driver = {
> diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h 
> b/drivers/gpu/drm/mgag200/mgag200_drv.h
> index 4b4f9ce74a84..aa32aad222c2 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_drv.h
> +++ b/drivers/gpu/drm/mgag200/mgag200_drv.h
> @@ -150,6 +150,9 @@ enum mga_type {
>   G200_EW3,
>  };
>  
> +/* HW does not handle 'startadd' field correct. */
> +#define MGAG200_FLAG_HW_BUG_NO_STARTADD  (1ul << 8)
> +
>  #define MGAG200_TYPE_MASK(0x00ff)
>  #define MGAG200_FLAG_MASK(0x0000)
>  
> -- 
> 2.23.0
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH 4/4] drm/mgag200: Add module parameter to pin all buffers at offset 0

2019-11-26 Thread Daniel Vetter
On Tue, Nov 26, 2019 at 08:25:45AM +0100, Thomas Zimmermann wrote:
> For hardware that does not interpret the startadd field correctly,
> add the module parameter 'hw_bug_no_startadd', which enables the
> workaround.
> 
> Signed-off-by: Thomas Zimmermann 
> ---
>  drivers/gpu/drm/mgag200/mgag200_drv.c | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c 
> b/drivers/gpu/drm/mgag200/mgag200_drv.c
> index d43951caeea0..79836b09a54a 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_drv.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
> @@ -27,6 +27,10 @@ int mgag200_modeset = -1;
>  MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
>  module_param_named(modeset, mgag200_modeset, int, 0400);
>  
> +int mgag200_hw_bug_no_startadd = -1;
> +MODULE_PARM_DESC(modeset, "HW does not interpret scanout-buffer start 
> address correctly");
> +module_param_named(hw_bug_no_startadd, mgag200_hw_bug_no_startadd, int, 
> 0400);
> +
>  static struct drm_driver driver;
>  
>  static const struct pci_device_id pciidlist[] = {
> @@ -64,6 +68,10 @@ DEFINE_DRM_GEM_FOPS(mgag200_driver_fops);
>  
>  static bool mgag200_pin_bo_at_0(const struct mga_device *mdev)
>  {

I'd add a infor printing if the module option is non-zero that people
should submit a bug report if this fixes their issue. We don't want people
fixing bugs with module options, stuff should work by default.

With that addressed:

Reviewed-by: Daniel Vetter 

> + if (!mgag200_hw_bug_no_startadd)
> + return false;
> + else if (mgag200_hw_bug_no_startadd > 0)
> + return true;
>   return mdev->flags & MGAG200_FLAG_HW_BUG_NO_STARTADD;
>  }
>  
> -- 
> 2.23.0
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH 3/4] drm/mgag200: Add workaround for HW that does not support 'startadd'

2019-11-26 Thread Thomas Zimmermann
Hi

Am 26.11.19 um 10:37 schrieb Daniel Vetter:
> On Tue, Nov 26, 2019 at 08:25:44AM +0100, Thomas Zimmermann wrote:
>> There's at least one system that does not interpret the value of
>> the device's 'startadd' field correctly, which leads to incorrectly
>> displayed scanout buffers. Always placing the active scanout buffer
>> at offset 0 works around the problem.
>>
>> Signed-off-by: Thomas Zimmermann 
>> Reported-by: John Donnelly 
>> Link: https://gitlab.freedesktop.org/drm/misc/issues/7
> 
> Tested-by: John Donnelly 
> 
> (Not quite this patch, but pretty much the logic, so counts).
> 
> Fixes: 81da87f63a1e ("drm: Replace drm_gem_vram_push_to_system() with kunmap 
> + unpin")
> Cc:  # v5.3+
> 
> Also you need the stable line on both prep patches too. For next time
> around,
> 
> $ dim fixes 81da87f63a1e
> 
> will generate all the stuff you need, including a good set of suggested
> Cc: you should have.
> 
> On the first 3 patches, with all that stuff added:
> 
> Reviewed-by: Daniel Vetter 

Thanks for the review.

Sorry for leaving out some of the tags. I wanted to wait for feedback
before adding tested-by, fixes, stable. I'll split off patch 4 from the
series and get 1 to 3 merged ASAP.

Best regards
Thomas

> 
> Please push these to drm-misc-next-fixes so they get backported as quickly
> as possible.
> -Daniel
> 
>> ---
>>  drivers/gpu/drm/mgag200/mgag200_drv.c | 36 ++-
>>  drivers/gpu/drm/mgag200/mgag200_drv.h |  3 +++
>>  2 files changed, 38 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c 
>> b/drivers/gpu/drm/mgag200/mgag200_drv.c
>> index 397f8b0a9af8..d43951caeea0 100644
>> --- a/drivers/gpu/drm/mgag200/mgag200_drv.c
>> +++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
>> @@ -30,6 +30,8 @@ module_param_named(modeset, mgag200_modeset, int, 0400);
>>  static struct drm_driver driver;
>>  
>>  static const struct pci_device_id pciidlist[] = {
>> +{ PCI_VENDOR_ID_MATROX, 0x522, PCI_VENDOR_ID_SUN, 0x4852, 0, 0,
>> +G200_SE_A | MGAG200_FLAG_HW_BUG_NO_STARTADD},
>>  { PCI_VENDOR_ID_MATROX, 0x522, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_SE_A 
>> },
>>  { PCI_VENDOR_ID_MATROX, 0x524, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_SE_B 
>> },
>>  { PCI_VENDOR_ID_MATROX, 0x530, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_EV },
>> @@ -60,6 +62,35 @@ static void mga_pci_remove(struct pci_dev *pdev)
>>  
>>  DEFINE_DRM_GEM_FOPS(mgag200_driver_fops);
>>  
>> +static bool mgag200_pin_bo_at_0(const struct mga_device *mdev)
>> +{
>> +return mdev->flags & MGAG200_FLAG_HW_BUG_NO_STARTADD;
>> +}
>> +
>> +int mgag200_driver_dumb_create(struct drm_file *file,
>> +   struct drm_device *dev,
>> +   struct drm_mode_create_dumb *args)
>> +{
>> +struct mga_device *mdev = dev->dev_private;
>> +unsigned long pg_align;
>> +
>> +if (WARN_ONCE(!dev->vram_mm, "VRAM MM not initialized"))
>> +return -EINVAL;
>> +
>> +pg_align = 0ul;
>> +
>> +/*
>> + * Aligning scanout buffers to the size of the video ram forces
>> + * placement at offset 0. Works around a bug where HW does not
>> + * respect 'startadd' field.
>> + */
>> +if (mgag200_pin_bo_at_0(mdev))
>> +pg_align = PFN_UP(mdev->mc.vram_size);
>> +
>> +return drm_gem_vram_fill_create_dumb(file, dev, &dev->vram_mm->bdev,
>> + pg_align, false, args);
>> +}
>> +
>>  static struct drm_driver driver = {
>>  .driver_features = DRIVER_GEM | DRIVER_MODESET,
>>  .load = mgag200_driver_load,
>> @@ -71,7 +102,10 @@ static struct drm_driver driver = {
>>  .major = DRIVER_MAJOR,
>>  .minor = DRIVER_MINOR,
>>  .patchlevel = DRIVER_PATCHLEVEL,
>> -DRM_GEM_VRAM_DRIVER
>> +.debugfs_init = drm_vram_mm_debugfs_init,
>> +.dumb_create = mgag200_driver_dumb_create,
>> +.dumb_map_offset = drm_gem_vram_driver_dumb_mmap_offset,
>> +.gem_prime_mmap = drm_gem_prime_mmap,
>>  };
>>  
>>  static struct pci_driver mgag200_pci_driver = {
>> diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h 
>> b/drivers/gpu/drm/mgag200/mgag200_drv.h
>> index 4b4f9ce74a84..aa32aad222c2 100644
>> --- a/drivers/gpu/drm/mgag200/mgag200_drv.h
>> +++ b/drivers/gpu/drm/mgag200/mgag200_drv.h
>> @@ -150,6 +150,9 @@ enum mga_type {
>>  G200_EW3,
>>  };
>>  
>> +/* HW does not handle 'startadd' field correct. */
>> +#define MGAG200_FLAG_HW_BUG_NO_STARTADD (1ul << 8)
>> +
>>  #define MGAG200_TYPE_MASK   (0x00ff)
>>  #define MGAG200_FLAG_MASK   (0x0000)
>>  
>> -- 
>> 2.23.0
>>
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer



signature.asc
Description: OpenPGP digital signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-de

[PATCH 0/5] drm/tidss: New driver for TI Keystone platform Display SubSystem

2019-11-26 Thread Jyri Sarha
There was couple of attempts upstream an earlier version of this
driver about a year ago [1]. Back then I needed to stop my efforts to
implement support for next Keystone DSS version, so now the driver
supports three different Keystone DSS version on three different SoCs.

I am starting the patch series versioning from the beginning since it
has been over a year since the previous patch set and the structure of
the driver has evolved quite a bit. However, all the earlier comments
should be addressed in this series.

[1] https://patchwork.freedesktop.org/series/44947/

Jyri Sarha (5):
  dt-bindings: display: ti,k2g-dss: Add dt-schema yaml binding
  dt-bindings: display: ti,am65x-dss: Add dt-schema yaml binding
  dt-bindings: display: ti,j721e-dss: Add dt-schema yaml binding
  drm/tidss: New driver for TI Keystone platform Display SubSystem
  MAINTAINERS: add entry for tidss

 .../bindings/display/ti/ti,am65x-dss.yaml |  133 +
 .../bindings/display/ti/ti,j721e-dss.yaml |  177 ++
 .../bindings/display/ti/ti,k2g-dss.yaml   |   97 +
 MAINTAINERS   |   10 +
 drivers/gpu/drm/Kconfig   |2 +
 drivers/gpu/drm/Makefile  |1 +
 drivers/gpu/drm/tidss/Kconfig |   15 +
 drivers/gpu/drm/tidss/Makefile|   12 +
 drivers/gpu/drm/tidss/tidss_crtc.c|  373 +++
 drivers/gpu/drm/tidss/tidss_crtc.h|   45 +
 drivers/gpu/drm/tidss/tidss_dispc.c   | 2645 +
 drivers/gpu/drm/tidss/tidss_dispc.h   |  132 +
 drivers/gpu/drm/tidss/tidss_dispc_regs.h  |  243 ++
 drivers/gpu/drm/tidss/tidss_drv.c |  292 ++
 drivers/gpu/drm/tidss/tidss_drv.h |   42 +
 drivers/gpu/drm/tidss/tidss_encoder.c |   89 +
 drivers/gpu/drm/tidss/tidss_encoder.h |   17 +
 drivers/gpu/drm/tidss/tidss_irq.c |  185 ++
 drivers/gpu/drm/tidss/tidss_irq.h |   71 +
 drivers/gpu/drm/tidss/tidss_kms.c |  239 ++
 drivers/gpu/drm/tidss/tidss_kms.h |   15 +
 drivers/gpu/drm/tidss/tidss_plane.c   |  218 ++
 drivers/gpu/drm/tidss/tidss_plane.h   |   25 +
 drivers/gpu/drm/tidss/tidss_scale_coefs.c |  201 ++
 drivers/gpu/drm/tidss/tidss_scale_coefs.h |   22 +
 25 files changed, 5301 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/ti/ti,am65x-dss.yaml
 create mode 100644 
Documentation/devicetree/bindings/display/ti/ti,j721e-dss.yaml
 create mode 100644 Documentation/devicetree/bindings/display/ti/ti,k2g-dss.yaml
 create mode 100644 drivers/gpu/drm/tidss/Kconfig
 create mode 100644 drivers/gpu/drm/tidss/Makefile
 create mode 100644 drivers/gpu/drm/tidss/tidss_crtc.c
 create mode 100644 drivers/gpu/drm/tidss/tidss_crtc.h
 create mode 100644 drivers/gpu/drm/tidss/tidss_dispc.c
 create mode 100644 drivers/gpu/drm/tidss/tidss_dispc.h
 create mode 100644 drivers/gpu/drm/tidss/tidss_dispc_regs.h
 create mode 100644 drivers/gpu/drm/tidss/tidss_drv.c
 create mode 100644 drivers/gpu/drm/tidss/tidss_drv.h
 create mode 100644 drivers/gpu/drm/tidss/tidss_encoder.c
 create mode 100644 drivers/gpu/drm/tidss/tidss_encoder.h
 create mode 100644 drivers/gpu/drm/tidss/tidss_irq.c
 create mode 100644 drivers/gpu/drm/tidss/tidss_irq.h
 create mode 100644 drivers/gpu/drm/tidss/tidss_kms.c
 create mode 100644 drivers/gpu/drm/tidss/tidss_kms.h
 create mode 100644 drivers/gpu/drm/tidss/tidss_plane.c
 create mode 100644 drivers/gpu/drm/tidss/tidss_plane.h
 create mode 100644 drivers/gpu/drm/tidss/tidss_scale_coefs.c
 create mode 100644 drivers/gpu/drm/tidss/tidss_scale_coefs.h

-- 
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

[PATCH 5/5] MAINTAINERS: add entry for tidss

2019-11-26 Thread Jyri Sarha
Add entry for tidss DRM driver.

Signed-off-by: Jyri Sarha 
---
 MAINTAINERS | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index eb19fad370d7..556b7425e883 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5554,6 +5554,16 @@ F:   include/uapi/drm/v3d_drm.h
 F: Documentation/devicetree/bindings/gpu/brcm,bcm-v3d.txt
 T: git git://anongit.freedesktop.org/drm/drm-misc
 
+DRM DRIVERS FOR TI KEYSTONE
+M: Jyri Sarha 
+M: Tomi Valkeinen 
+L: dri-devel@lists.freedesktop.org
+S: Maintained
+F: drivers/gpu/drm/tidss/
+F: Documentation/devicetree/bindings/display/ti/ti,k2g-dss.txt
+F: Documentation/devicetree/bindings/display/ti/ti,am65x-dss.txt
+F: Documentation/devicetree/bindings/display/ti/ti,j721e-dss.txt
+
 DRM DRIVERS FOR VC4
 M: Eric Anholt 
 T: git git://github.com/anholt/linux
-- 
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

[PATCH 1/5] dt-bindings: display: ti, k2g-dss: Add dt-schema yaml binding

2019-11-26 Thread Jyri Sarha
Add dt-schema yaml bindig for K2G DSS, an ultra-light version of TI
Keystone Display SubSystem.

Signed-off-by: Jyri Sarha 
---
 .../bindings/display/ti/ti,k2g-dss.yaml   | 97 +++
 1 file changed, 97 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/ti/ti,k2g-dss.yaml

diff --git a/Documentation/devicetree/bindings/display/ti/ti,k2g-dss.yaml 
b/Documentation/devicetree/bindings/display/ti/ti,k2g-dss.yaml
new file mode 100644
index ..2d92dea1c411
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/ti/ti,k2g-dss.yaml
@@ -0,0 +1,97 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2019 Texas Instruments Incorporated
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/display/ti/ti,k2g-dss.yaml#";
+$schema: "http://devicetree.org/meta-schemas/core.yaml#";
+
+title: Texas Instruments K2G Display Subsystem
+
+maintainers:
+  - Jyri Sarha 
+  - Tomi Valkeinen 
+
+description: |
+  The K2G DSS is an ultra-light version of TI Keystone Display
+  SubSystem. It has only one output port and video plane. The
+  output is DPI.
+
+properties:
+  compatible:
+const: ti,k2g-dss
+
+  reg:
+maxItems: 5
+minItems: 5
+
+  reg-names:
+items:
+  - const: cfg
+  - const: common
+  - const: vid1
+  - const: ovr1
+  - const: vp1
+
+  clocks:
+maxItems: 2
+minItems: 2
+
+  clock-names:
+items:
+  - const: fck
+  - const: vp1
+
+  interrupts:
+maxItems: 1
+
+  power-domains:
+maxItems: 1
+description: phandle to the associated power domain
+
+  port@0:
+type: object
+description:
+  The DSS DPI output port node
+
+  max-memory-bandwidth:
+$ref: /schemas/types.yaml#/definitions/uint32
+description:
+  Input memory (from main memory to dispc) bandwidth limit in
+  bytes per second
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - clocks
+  - clock-names
+  - interrupts
+  - port@0
+
+additionalProperties: false
+
+examples:
+  - |
+dss: dss@0254 {
+compatible = "ti,k2g-dss";
+reg =   <0x0254 0x400>,
+<0x0255 0x1000>,
+<0x02557000 0x1000>,
+<0x0255a800 0x100>,
+<0x0255ac00 0x100>;
+reg-names = "cfg", "common", "vid1", "ovr1", "vp1";
+clocks =<&k2g_clks 0x2 0>,
+<&k2g_clks 0x2 1>;
+clock-names = "fck", "vp1";
+interrupts = ;
+
+power-domains = <&k2g_pds 0x2>;
+status = "disabled";
+
+max-memory-bandwidth = <23000>;
+port {
+dpi_out: endpoint {
+remote-endpoint = <&sii9022_in>;
+};
+};
+};
-- 
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

[PATCH 3/5] dt-bindings: display: ti, j721e-dss: Add dt-schema yaml binding

2019-11-26 Thread Jyri Sarha
Add dt-schema yaml bindig for J721E DSS, J721E version TI Keystone
Display SubSystem.

Signed-off-by: Jyri Sarha 
---
 .../bindings/display/ti/ti,j721e-dss.yaml | 177 ++
 1 file changed, 177 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/ti/ti,j721e-dss.yaml

diff --git a/Documentation/devicetree/bindings/display/ti/ti,j721e-dss.yaml 
b/Documentation/devicetree/bindings/display/ti/ti,j721e-dss.yaml
new file mode 100644
index ..cb3b64b9f04e
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/ti/ti,j721e-dss.yaml
@@ -0,0 +1,177 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2019 Texas Instruments Incorporated
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/display/ti/ti,j721e-dss.yaml#";
+$schema: "http://devicetree.org/meta-schemas/core.yaml#";
+
+title: Texas Instruments J721E Display Subsystem
+
+maintainers:
+  - Jyri Sarha 
+  - Tomi Valkeinen 
+
+description: |
+  The J721E TI Keystone Display SubSystem with four output ports and
+  four video planes. There is two full video planes and two "lite
+  planes" without scaling support. The video ports can be connected to
+  the SoC's DPI pins or to integrated display bridges on the SoC.
+
+properties:
+  compatible:
+const: ti,j721e-dss
+
+  reg:
+maxItems: 17
+minItems: 17
+
+  reg-names:
+items:
+  - const: common_m
+  - const: common_s0
+  - const: common_s1
+  - const: common_s2
+  - const: vidl1
+  - const: vidl2
+  - const: vid1
+  - const: vid2
+  - const: ovr1
+  - const: ovr2
+  - const: ovr3
+  - const: ovr4
+  - const: vp1
+  - const: vp2
+  - const: vp3
+  - const: vp4
+  - const: wp
+
+  clocks:
+maxItems: 5
+minItems: 5
+
+  clock-names:
+items:
+  - const: fck
+  - const: vp1
+  - const: vp2
+  - const: vp3
+  - const: vp4
+
+  interrupts:
+maxItems: 4
+
+  interrupt-names:
+items:
+  - const: common_m
+  - const: common_s0
+  - const: common_s1
+  - const: common_s2
+
+  power-domains:
+maxItems: 1
+description: phandle to the associated power domain
+
+  port@0:
+type: object
+description:
+  The output port node form video port 1
+
+  port@1:
+type: object
+description:
+  The output port node from video port 2
+
+  port@2:
+type: object
+description:
+  The output port node from video port 3
+
+  port@3:
+type: object
+description:
+  The output port node from video port 4
+
+  max-memory-bandwidth:
+$ref: /schemas/types.yaml#/definitions/uint32
+description:
+  Input memory (from main memory to dispc) bandwidth limit in
+  bytes per second
+
+  "#address-cells":
+const: 1
+
+  "#size-cells":
+const: 0
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - clocks
+  - clock-names
+  - interrupts
+  - interrupt-names
+  - "#address-cells"
+  - "#size-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+dss: dss@04a0 {
+compatible = "ti,j721e-dss";
+reg =
+<0x00 0x04a0 0x00 0x1>, /* common_m */
+<0x00 0x04a1 0x00 0x1>, /* common_s0*/
+<0x00 0x04b0 0x00 0x1>, /* common_s1*/
+<0x00 0x04b1 0x00 0x1>, /* common_s2*/
+
+<0x00 0x04a2 0x00 0x1>, /* vidl1 */
+<0x00 0x04a3 0x00 0x1>, /* vidl2 */
+<0x00 0x04a5 0x00 0x1>, /* vid1 */
+<0x00 0x04a6 0x00 0x1>, /* vid2 */
+
+<0x00 0x04a7 0x00 0x1>, /* ovr1 */
+<0x00 0x04a9 0x00 0x1>, /* ovr2 */
+<0x00 0x04ab 0x00 0x1>, /* ovr3 */
+<0x00 0x04ad 0x00 0x1>, /* ovr4 */
+
+<0x00 0x04a8 0x00 0x1>, /* vp1 */
+<0x00 0x04aa 0x00 0x1>, /* vp2 */
+<0x00 0x04ac 0x00 0x1>, /* vp3 */
+<0x00 0x04ae 0x00 0x1>, /* vp4 */
+
+<0x00 0x04af 0x00 0x1>; /* wb */
+  reg-names = "common_m", "common_s0",
+"common_s1", "common_s2",
+"vidl1", "vidl2","vid1","vid2",
+"ovr1", "ovr2", "ovr3", "ovr4",
+"vp1", "vp2", "vp3", "vp4",
+"wb";
+
+clocks =<&k3_clks 152 0>,
+<&k3_clks 152 1>,
+<&k3_clks 152 4>,
+<&k3_clks 152 9>,
+<&k3_clks 152 13>;
+clock-names = "fck", "vp1", "vp2", "vp3", "vp4";
+
+interrupts = ,
+   

[PATCH 2/5] dt-bindings: display: ti, am65x-dss: Add dt-schema yaml binding

2019-11-26 Thread Jyri Sarha
Add dt-schema yaml bindig for AM65x DSS, AM65x version TI Keystone
Display SubSystem.

Signed-off-by: Jyri Sarha 
---
 .../bindings/display/ti/ti,am65x-dss.yaml | 133 ++
 1 file changed, 133 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/ti/ti,am65x-dss.yaml

diff --git a/Documentation/devicetree/bindings/display/ti/ti,am65x-dss.yaml 
b/Documentation/devicetree/bindings/display/ti/ti,am65x-dss.yaml
new file mode 100644
index ..6691f5dad383
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/ti/ti,am65x-dss.yaml
@@ -0,0 +1,133 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2019 Texas Instruments Incorporated
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/display/ti/ti,am65x-dss.yaml#";
+$schema: "http://devicetree.org/meta-schemas/core.yaml#";
+
+title: Texas Instruments AM65x Display Subsystem
+
+maintainers:
+  - Jyri Sarha 
+  - Tomi Valkeinen 
+
+description: |
+  The AM65x TI Keystone Display SubSystem with two output ports and
+  two video planes. The first video port supports OLDI and the second
+  supports DPI format. The fist plane is full video plane with all
+  features and the second is a "lite plane" without scaling support.
+
+properties:
+  compatible:
+const: ti,am65x-dss
+
+  reg:
+maxItems: 7
+minItems: 7
+
+  reg-names:
+items:
+  - const: common
+  - const: vidl1
+  - const: vid
+  - const: ovr1
+  - const: ovr2
+  - const: vp1
+  - const: vp2
+
+  clocks:
+maxItems: 3
+minItems: 3
+
+  clock-names:
+items:
+  - const: fck
+  - const: vp1
+  - const: vp2
+
+  interrupts:
+maxItems: 1
+
+  power-domains:
+maxItems: 1
+description: phandle to the associated power domain
+
+  port@0:
+type: object
+description:
+  The DSS OLDI output port node form video port 1
+
+  port@1:
+type: object
+description:
+  The DSS DPI output port node from video port 2
+
+  ti,am65x-oldi-io-ctrl:
+maxItems: 1
+description:
+  $ref: "/schemas/types.yaml#/definitions/phandle-array"
+  phandle to syscon device node mapping OLDI IO_CTRL registers.
+  The mapped range should point to OLDI_DAT0_IO_CTRL, map it and
+  following OLDI_DAT1_IO_CTRL, OLDI_DAT2_IO_CTRL, OLDI_DAT3_IO_CTRL,
+  and OLDI_CLK_IO_CTRL registers. This property is needed for OLDI
+  interface to work.
+
+  max-memory-bandwidth:
+$ref: /schemas/types.yaml#/definitions/uint32
+description:
+  Input memory (from main memory to dispc) bandwidth limit in
+  bytes per second
+
+  "#address-cells":
+const: 1
+
+  "#size-cells":
+const: 0
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - clocks
+  - clock-names
+  - interrupts
+  - "#address-cells"
+  - "#size-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+   dss: dss@04a0 {
+compatible = "ti,am65x-dss";
+reg =   <0x0 0x04a0 0x0 0x1000>, /* common */
+<0x0 0x04a02000 0x0 0x1000>, /* vidl1 */
+<0x0 0x04a06000 0x0 0x1000>, /* vid */
+<0x0 0x04a07000 0x0 0x1000>, /* ovr1 */
+<0x0 0x04a08000 0x0 0x1000>, /* ovr2 */
+<0x0 0x04a0a000 0x0 0x1000>, /* vp1 */
+<0x0 0x04a0b000 0x0 0x1000>; /* vp2 */
+reg-names = "common", "vidl1", "vid",
+"ovr1", "ovr2", "vp1", "vp2";
+
+ti,am65x-oldi-io-ctrl = <&dss_oldi_io_ctrl>;
+
+power-domains = <&k3_pds 67 TI_SCI_PD_EXCLUSIVE>;
+
+clocks =<&k3_clks 67 1>,
+<&k3_clks 216 1>,
+<&k3_clks 67 2>;
+clock-names = "fck", "vp1", "vp2";
+
+interrupts = ;
+
+status = "disabled";
+
+port@0 {
+reg = <0>;
+
+oldi_out0: endpoint {
+remote-endpoint = <&lcd_in0>;
+};
+};
+};
-- 
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

Re: [PATCH] drm: radeon: replace 0 with NULL

2019-11-26 Thread Christian König

Am 26.11.19 um 01:35 schrieb Jules Irenge:

Replace 0 with NULL to fix sparse tool  warning
  warning: Using plain integer as NULL pointer

Signed-off-by: Jules Irenge 


Acked-by: Christian König 


---
  drivers/gpu/drm/radeon/radeon_audio.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/radeon_audio.c 
b/drivers/gpu/drm/radeon/radeon_audio.c
index b9aea5776d3d..2269cfced788 100644
--- a/drivers/gpu/drm/radeon/radeon_audio.c
+++ b/drivers/gpu/drm/radeon/radeon_audio.c
@@ -288,7 +288,7 @@ static void radeon_audio_interface_init(struct 
radeon_device *rdev)
} else {
rdev->audio.funcs = &r600_funcs;
rdev->audio.hdmi_funcs = &r600_hdmi_funcs;
-   rdev->audio.dp_funcs = 0;
+   rdev->audio.dp_funcs = NULL;
}
  }
  


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

[PATCH v2 1/3] drm/mgag200: Extract device type from flags

2019-11-26 Thread Thomas Zimmermann
Adds a conversion function that extracts the device type from the
PCI id-table flags. Allows for storing additional information in the
other flag bits.

Signed-off-by: Thomas Zimmermann 
Fixes: 81da87f63a1e ("drm: Replace drm_gem_vram_push_to_system() with kunmap + 
unpin")
Reviewed-by: Daniel Vetter 
Cc: John Donnelly 
Cc: Gerd Hoffmann 
Cc: Dave Airlie 
Cc: Maarten Lankhorst 
Cc: Maxime Ripard 
Cc: David Airlie 
Cc: Sam Ravnborg 
Cc: Emil Velikov 
Cc: "Y.C. Chen" 
Cc: Laurent Pinchart 
Cc: "José Roberto de Souza" 
Cc: Andrzej Pietrasiewicz 
Cc: dri-devel@lists.freedesktop.org
Cc:  # v5.3+
---
 drivers/gpu/drm/mgag200/mgag200_drv.h  | 7 +++
 drivers/gpu/drm/mgag200/mgag200_main.c | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h 
b/drivers/gpu/drm/mgag200/mgag200_drv.h
index 0ea9a525e57d..976404634092 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.h
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.h
@@ -150,6 +150,8 @@ enum mga_type {
G200_EW3,
 };
 
+#define MGAG200_TYPE_MASK  (0x00ff)
+
 #define IS_G200_SE(mdev) (mdev->type == G200_SE_A || mdev->type == G200_SE_B)
 
 struct mga_device {
@@ -181,6 +183,11 @@ struct mga_device {
u32 unique_rev_id;
 };
 
+static inline enum mga_type
+mgag200_type_from_driver_data(kernel_ulong_t driver_data)
+{
+   return (enum mga_type)(driver_data & MGAG200_TYPE_MASK);
+}
/* mgag200_mode.c */
 int mgag200_modeset_init(struct mga_device *mdev);
 void mgag200_modeset_fini(struct mga_device *mdev);
diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c 
b/drivers/gpu/drm/mgag200/mgag200_main.c
index 5f74aabcd3df..517c5693ad69 100644
--- a/drivers/gpu/drm/mgag200/mgag200_main.c
+++ b/drivers/gpu/drm/mgag200/mgag200_main.c
@@ -94,7 +94,7 @@ static int mgag200_device_init(struct drm_device *dev,
struct mga_device *mdev = dev->dev_private;
int ret, option;
 
-   mdev->type = flags;
+   mdev->type = mgag200_type_from_driver_data(flags);
 
/* Hardcode the number of CRTCs to 1 */
mdev->num_crtc = 1;
-- 
2.23.0

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

[PATCH v2 2/3] drm/mgag200: Store flags from PCI driver data in device structure

2019-11-26 Thread Thomas Zimmermann
The flags field in struct mga_device has been unused so far. We now
use it to store flag bits from the PCI driver.

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Daniel Vetter 
Fixes: 81da87f63a1e ("drm: Replace drm_gem_vram_push_to_system() with kunmap + 
unpin")
Cc: John Donnelly 
Cc: Gerd Hoffmann 
Cc: Dave Airlie 
Cc: Maarten Lankhorst 
Cc: Maxime Ripard 
Cc: David Airlie 
Cc: Sam Ravnborg 
Cc: "Y.C. Chen" 
Cc: Neil Armstrong 
Cc: Thomas Gleixner 
Cc: "José Roberto de Souza" 
Cc: Andrzej Pietrasiewicz 
Cc: dri-devel@lists.freedesktop.org
Cc:  # v5.3+
---
 drivers/gpu/drm/mgag200/mgag200_drv.h  | 8 
 drivers/gpu/drm/mgag200/mgag200_main.c | 1 +
 2 files changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h 
b/drivers/gpu/drm/mgag200/mgag200_drv.h
index 976404634092..4b4f9ce74a84 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.h
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.h
@@ -151,6 +151,7 @@ enum mga_type {
 };
 
 #define MGAG200_TYPE_MASK  (0x00ff)
+#define MGAG200_FLAG_MASK  (0x0000)
 
 #define IS_G200_SE(mdev) (mdev->type == G200_SE_A || mdev->type == G200_SE_B)
 
@@ -188,6 +189,13 @@ mgag200_type_from_driver_data(kernel_ulong_t driver_data)
 {
return (enum mga_type)(driver_data & MGAG200_TYPE_MASK);
 }
+
+static inline unsigned long
+mgag200_flags_from_driver_data(kernel_ulong_t driver_data)
+{
+   return driver_data & MGAG200_FLAG_MASK;
+}
+
/* mgag200_mode.c */
 int mgag200_modeset_init(struct mga_device *mdev);
 void mgag200_modeset_fini(struct mga_device *mdev);
diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c 
b/drivers/gpu/drm/mgag200/mgag200_main.c
index 517c5693ad69..e1bc5b0aa774 100644
--- a/drivers/gpu/drm/mgag200/mgag200_main.c
+++ b/drivers/gpu/drm/mgag200/mgag200_main.c
@@ -94,6 +94,7 @@ static int mgag200_device_init(struct drm_device *dev,
struct mga_device *mdev = dev->dev_private;
int ret, option;
 
+   mdev->flags = mgag200_flags_from_driver_data(flags);
mdev->type = mgag200_type_from_driver_data(flags);
 
/* Hardcode the number of CRTCs to 1 */
-- 
2.23.0

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

[PATCH v2 0/3] drm/mgag200: Workaround HW bug with non-0 offset

2019-11-26 Thread Thomas Zimmermann
We found an MGA chip that does not interpret the scanout offset
correctly. This patchset works around the problem by placing all
buffer objects at offset 0 on this system.

v2:
* serarate [4/4] from the rest of the series
* add missing tags to patch files

Thomas Zimmermann (3):
  drm/mgag200: Extract device type from flags
  drm/mgag200: Store flags from PCI driver data in device structure
  drm/mgag200: Add workaround for HW that does not support 'startadd'

 drivers/gpu/drm/mgag200/mgag200_drv.c  | 36 +-
 drivers/gpu/drm/mgag200/mgag200_drv.h  | 18 +
 drivers/gpu/drm/mgag200/mgag200_main.c |  3 ++-
 3 files changed, 55 insertions(+), 2 deletions(-)

--
2.23.0

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

[PATCH v2 3/3] drm/mgag200: Add workaround for HW that does not support 'startadd'

2019-11-26 Thread Thomas Zimmermann
There's at least one system that does not interpret the value of
the device's 'startadd' field correctly, which leads to incorrectly
displayed scanout buffers. Always placing the active scanout buffer
at offset 0 works around the problem.

Signed-off-by: Thomas Zimmermann 
Reported-by: John Donnelly 
Tested-by: John Donnelly 
Reviewed-by: Daniel Vetter 
Fixes: 81da87f63a1e ("drm: Replace drm_gem_vram_push_to_system() with kunmap + 
unpin")
Cc: Gerd Hoffmann 
Cc: Dave Airlie 
Cc: Maarten Lankhorst 
Cc: Maxime Ripard 
Cc: David Airlie 
Cc: Sam Ravnborg 
Cc: "Y.C. Chen" 
Cc: Neil Armstrong 
Cc: Thomas Gleixner 
Cc: "José Roberto de Souza" 
Cc: Andrzej Pietrasiewicz 
Cc: dri-devel@lists.freedesktop.org
Cc:  # v5.3+
Link: https://gitlab.freedesktop.org/drm/misc/issues/7
---
 drivers/gpu/drm/mgag200/mgag200_drv.c | 36 ++-
 drivers/gpu/drm/mgag200/mgag200_drv.h |  3 +++
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c 
b/drivers/gpu/drm/mgag200/mgag200_drv.c
index 397f8b0a9af8..d43951caeea0 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -30,6 +30,8 @@ module_param_named(modeset, mgag200_modeset, int, 0400);
 static struct drm_driver driver;
 
 static const struct pci_device_id pciidlist[] = {
+   { PCI_VENDOR_ID_MATROX, 0x522, PCI_VENDOR_ID_SUN, 0x4852, 0, 0,
+   G200_SE_A | MGAG200_FLAG_HW_BUG_NO_STARTADD},
{ PCI_VENDOR_ID_MATROX, 0x522, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_SE_A 
},
{ PCI_VENDOR_ID_MATROX, 0x524, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_SE_B 
},
{ PCI_VENDOR_ID_MATROX, 0x530, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_EV },
@@ -60,6 +62,35 @@ static void mga_pci_remove(struct pci_dev *pdev)
 
 DEFINE_DRM_GEM_FOPS(mgag200_driver_fops);
 
+static bool mgag200_pin_bo_at_0(const struct mga_device *mdev)
+{
+   return mdev->flags & MGAG200_FLAG_HW_BUG_NO_STARTADD;
+}
+
+int mgag200_driver_dumb_create(struct drm_file *file,
+  struct drm_device *dev,
+  struct drm_mode_create_dumb *args)
+{
+   struct mga_device *mdev = dev->dev_private;
+   unsigned long pg_align;
+
+   if (WARN_ONCE(!dev->vram_mm, "VRAM MM not initialized"))
+   return -EINVAL;
+
+   pg_align = 0ul;
+
+   /*
+* Aligning scanout buffers to the size of the video ram forces
+* placement at offset 0. Works around a bug where HW does not
+* respect 'startadd' field.
+*/
+   if (mgag200_pin_bo_at_0(mdev))
+   pg_align = PFN_UP(mdev->mc.vram_size);
+
+   return drm_gem_vram_fill_create_dumb(file, dev, &dev->vram_mm->bdev,
+pg_align, false, args);
+}
+
 static struct drm_driver driver = {
.driver_features = DRIVER_GEM | DRIVER_MODESET,
.load = mgag200_driver_load,
@@ -71,7 +102,10 @@ static struct drm_driver driver = {
.major = DRIVER_MAJOR,
.minor = DRIVER_MINOR,
.patchlevel = DRIVER_PATCHLEVEL,
-   DRM_GEM_VRAM_DRIVER
+   .debugfs_init = drm_vram_mm_debugfs_init,
+   .dumb_create = mgag200_driver_dumb_create,
+   .dumb_map_offset = drm_gem_vram_driver_dumb_mmap_offset,
+   .gem_prime_mmap = drm_gem_prime_mmap,
 };
 
 static struct pci_driver mgag200_pci_driver = {
diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h 
b/drivers/gpu/drm/mgag200/mgag200_drv.h
index 4b4f9ce74a84..aa32aad222c2 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.h
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.h
@@ -150,6 +150,9 @@ enum mga_type {
G200_EW3,
 };
 
+/* HW does not handle 'startadd' field correct. */
+#define MGAG200_FLAG_HW_BUG_NO_STARTADD(1ul << 8)
+
 #define MGAG200_TYPE_MASK  (0x00ff)
 #define MGAG200_FLAG_MASK  (0x0000)
 
-- 
2.23.0

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

[PATCH v2] drm/mgag200: Add module parameter to pin all buffers at offset 0

2019-11-26 Thread Thomas Zimmermann
For hardware that does not interpret the startadd field correctly,
add the module parameter 'hw_bug_no_startadd', which enables the
workaround.

v2:
* ask user for feedback if the option is active

Signed-off-by: Thomas Zimmermann 
Reviewed-by: Daniel Vetter 
Cc: John Donnelly 
---
 drivers/gpu/drm/mgag200/mgag200_drv.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c 
b/drivers/gpu/drm/mgag200/mgag200_drv.c
index d43951caeea0..284d58af8d45 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -27,6 +27,10 @@ int mgag200_modeset = -1;
 MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
 module_param_named(modeset, mgag200_modeset, int, 0400);
 
+int mgag200_hw_bug_no_startadd = -1;
+MODULE_PARM_DESC(modeset, "HW does not interpret scanout-buffer start address 
correctly");
+module_param_named(hw_bug_no_startadd, mgag200_hw_bug_no_startadd, int, 0400);
+
 static struct drm_driver driver;
 
 static const struct pci_device_id pciidlist[] = {
@@ -64,6 +68,15 @@ DEFINE_DRM_GEM_FOPS(mgag200_driver_fops);
 
 static bool mgag200_pin_bo_at_0(const struct mga_device *mdev)
 {
+   if (mgag200_hw_bug_no_startadd > 0) {
+   DRM_WARN_ONCE("Option hw_bug_no_startedd is enabled. Please "
+ "report the output of 'lspci -vvnn' to "
+ " if this "
+ "option is required to make mgag200 work "
+ "correctly on your system.\n");
+   return true;
+   } else if (!mgag200_hw_bug_no_startadd)
+   return false;
return mdev->flags & MGAG200_FLAG_HW_BUG_NO_STARTADD;
 }
 
-- 
2.23.0

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

[PATCH v1 1/2] drm/komeda: Add a new file komeda_sysfs.c

2019-11-26 Thread james qian wang (Arm Technology China)
From: "James Qian Wang (Arm Technology China)" 

Add a new file komeda_sysfs.c and move all sysfs related code to it.

Signed-off-by: James Qian Wang (Arm Technology China) 
---
 drivers/gpu/drm/arm/display/komeda/Makefile   |  1 +
 .../gpu/drm/arm/display/komeda/komeda_dev.c   | 61 +-
 .../gpu/drm/arm/display/komeda/komeda_dev.h   |  3 +
 .../gpu/drm/arm/display/komeda/komeda_sysfs.c | 81 +++
 4 files changed, 88 insertions(+), 58 deletions(-)
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_sysfs.c

diff --git a/drivers/gpu/drm/arm/display/komeda/Makefile 
b/drivers/gpu/drm/arm/display/komeda/Makefile
index 1931a7fa1a14..706674ca5928 100644
--- a/drivers/gpu/drm/arm/display/komeda/Makefile
+++ b/drivers/gpu/drm/arm/display/komeda/Makefile
@@ -7,6 +7,7 @@ ccflags-y := \
 komeda-y := \
komeda_drv.o \
komeda_dev.o \
+   komeda_sysfs.o \
komeda_format_caps.o \
komeda_color_mgmt.o \
komeda_pipeline.o \
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c 
b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
index 8e0bce46555b..734b88b88d94 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
@@ -63,59 +63,6 @@ static void komeda_debugfs_init(struct komeda_dev *mdev)
 }
 #endif
 
-static ssize_t
-core_id_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
-   struct komeda_dev *mdev = dev_to_mdev(dev);
-
-   return snprintf(buf, PAGE_SIZE, "0x%08x\n", mdev->chip.core_id);
-}
-static DEVICE_ATTR_RO(core_id);
-
-static ssize_t
-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;
-   int i;
-
-   memset(&config_id, 0, sizeof(config_id));
-
-   config_id.max_line_sz = pipe->layers[0]->hsize_in.end;
-   config_id.side_by_side = mdev->side_by_side;
-   config_id.n_pipelines = mdev->n_pipelines;
-   config_id.n_scalers = pipe->n_scalers;
-   config_id.n_layers = pipe->n_layers;
-   config_id.n_richs = 0;
-   for (i = 0; i < pipe->n_layers; i++) {
-   if (pipe->layers[i]->layer_type == KOMEDA_FMT_RICH_LAYER)
-   config_id.n_richs++;
-   }
-   return snprintf(buf, PAGE_SIZE, "0x%08x\n", config_id.value);
-}
-static DEVICE_ATTR_RO(config_id);
-
-static ssize_t
-aclk_hz_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
-   struct komeda_dev *mdev = dev_to_mdev(dev);
-
-   return snprintf(buf, PAGE_SIZE, "%lu\n", clk_get_rate(mdev->aclk));
-}
-static DEVICE_ATTR_RO(aclk_hz);
-
-static struct attribute *komeda_sysfs_entries[] = {
-   &dev_attr_core_id.attr,
-   &dev_attr_config_id.attr,
-   &dev_attr_aclk_hz.attr,
-   NULL,
-};
-
-static struct attribute_group komeda_sysfs_attr_group = {
-   .attrs = komeda_sysfs_entries,
-};
-
 static int komeda_parse_pipe_dt(struct komeda_pipeline *pipe)
 {
struct device_node *np = pipe->of_node;
@@ -277,11 +224,9 @@ struct komeda_dev *komeda_dev_create(struct device *dev)
 
clk_disable_unprepare(mdev->aclk);
 
-   err = sysfs_create_group(&dev->kobj, &komeda_sysfs_attr_group);
-   if (err) {
-   DRM_ERROR("create sysfs group failed.\n");
+   err = komeda_dev_sysfs_init(mdev);
+   if (err)
goto err_cleanup;
-   }
 
mdev->err_verbosity = KOMEDA_DEV_PRINT_ERR_EVENTS;
 
@@ -304,7 +249,7 @@ void komeda_dev_destroy(struct komeda_dev *mdev)
const struct komeda_dev_funcs *funcs = mdev->funcs;
int i;
 
-   sysfs_remove_group(&dev->kobj, &komeda_sysfs_attr_group);
+   komeda_dev_sysfs_destroy(mdev);
 
 #ifdef CONFIG_DEBUG_FS
debugfs_remove_recursive(mdev->debugfs_root);
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.h 
b/drivers/gpu/drm/arm/display/komeda/komeda_dev.h
index dacdb00153e9..6183e0f394f0 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.h
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.h
@@ -248,4 +248,7 @@ void komeda_print_events(struct komeda_events *evts, struct 
drm_device *dev);
 int komeda_dev_resume(struct komeda_dev *mdev);
 int komeda_dev_suspend(struct komeda_dev *mdev);
 
+int komeda_dev_sysfs_init(struct komeda_dev *mdev);
+void komeda_dev_sysfs_destroy(struct komeda_dev *mdev);
+
 #endif /*_KOMEDA_DEV_H_*/
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_sysfs.c 
b/drivers/gpu/drm/arm/display/komeda/komeda_sysfs.c
new file mode 100644
index ..740f095b4ca5
--- /dev/null
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_sysfs.c
@@ -0,0 +1,81 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * (C) COPYRIGHT 2019 ARM Limited. All rights reserved.
+ * Author: James.Qian.Wang 
+ *
+ */
+#include 
+
+#include "komeda_dev.h"
+
+static ssize_t
+core_id_show(struct de

Re: [PATCH 15/15] dma-buf: Remove kernel map/unmap hooks

2019-11-26 Thread Daniel Vetter
On Mon, Nov 18, 2019 at 11:35:36AM +0100, Daniel Vetter wrote:
> All implementations are gone now.
> 
> Signed-off-by: Daniel Vetter 
> Cc: Sumit Semwal 
> Cc: linux-me...@vger.kernel.org
> Cc: linaro-mm-...@lists.linaro.org

Applied the final two patches of this series now too.
-Daniel

> ---
>  include/linux/dma-buf.h | 25 -
>  1 file changed, 25 deletions(-)
> 
> diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
> index 7feb9c3805ae..abf5459a5b9d 100644
> --- a/include/linux/dma-buf.h
> +++ b/include/linux/dma-buf.h
> @@ -249,31 +249,6 @@ struct dma_buf_ops {
>*/
>   int (*mmap)(struct dma_buf *, struct vm_area_struct *vma);
>  
> - /**
> -  * @map:
> -  *
> -  * Maps a page from the buffer into kernel address space. The page is
> -  * specified by offset into the buffer in PAGE_SIZE units.
> -  *
> -  * This callback is optional.
> -  *
> -  * Returns:
> -  *
> -  * Virtual address pointer where requested page can be accessed. NULL
> -  * on error or when this function is unimplemented by the exporter.
> -  */
> - void *(*map)(struct dma_buf *, unsigned long);
> -
> - /**
> -  * @unmap:
> -  *
> -  * Unmaps a page from the buffer. Page offset and address pointer should
> -  * be the same as the one passed to and returned by matching call to 
> map.
> -  *
> -  * This callback is optional.
> -  */
> - void (*unmap)(struct dma_buf *, unsigned long, void *);
> -
>   void *(*vmap)(struct dma_buf *);
>   void (*vunmap)(struct dma_buf *, void *vaddr);
>  };
> -- 
> 2.24.0
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v1 0/2] drm/komeda: refactor sysfs node "config_id"

2019-11-26 Thread james qian wang (Arm Technology China)
Split sysfs node "config_id" to multiple files.

James Qian Wang (Arm Technology China) (2):
  drm/komeda: Add a new file komeda_sysfs.c
  drm/komeda: Refactor sysfs node "config_id"

 .../drm/arm/display/include/malidp_product.h  |  13 --
 drivers/gpu/drm/arm/display/komeda/Makefile   |   1 +
 .../gpu/drm/arm/display/komeda/komeda_dev.c   |  61 +
 .../gpu/drm/arm/display/komeda/komeda_dev.h   |   3 +
 .../gpu/drm/arm/display/komeda/komeda_sysfs.c | 125 ++
 5 files changed, 132 insertions(+), 71 deletions(-)
 create mode 100644 drivers/gpu/drm/arm/display/komeda/komeda_sysfs.c

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

[PATCH v1 2/2] drm/komeda: Refactor sysfs node "config_id"

2019-11-26 Thread james qian wang (Arm Technology China)
From: "James Qian Wang (Arm Technology China)" 

Split sysfs config_id bitfiles to multiple separated sysfs files.

Signed-off-by: James Qian Wang (Arm Technology China) 
---
 .../drm/arm/display/include/malidp_product.h  | 13 ---
 .../gpu/drm/arm/display/komeda/komeda_sysfs.c | 80 ++-
 2 files changed, 62 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/arm/display/include/malidp_product.h 
b/drivers/gpu/drm/arm/display/include/malidp_product.h
index dbd3d4765065..b21f4aa15c95 100644
--- a/drivers/gpu/drm/arm/display/include/malidp_product.h
+++ b/drivers/gpu/drm/arm/display/include/malidp_product.h
@@ -21,17 +21,4 @@
 #define MALIDP_D71_PRODUCT_ID  0x0071
 #define MALIDP_D32_PRODUCT_ID  0x0032
 
-union komeda_config_id {
-   struct {
-   __u32   max_line_sz:16,
-   n_pipelines:2,
-   n_scalers:2, /* number of scalers per pipeline */
-   n_layers:3, /* number of layers per pipeline */
-   n_richs:3, /* number of rich layers per pipeline */
-   side_by_side:1, /* if HW works on side_by_side mode */
-   reserved_bits:5;
-   };
-   __u32 value;
-};
-
 #endif /* _MALIDP_PRODUCT_H_ */
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_sysfs.c 
b/drivers/gpu/drm/arm/display/komeda/komeda_sysfs.c
index 740f095b4ca5..5effab795dc1 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_sysfs.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_sysfs.c
@@ -18,28 +18,67 @@ core_id_show(struct device *dev, struct device_attribute 
*attr, char *buf)
 static DEVICE_ATTR_RO(core_id);
 
 static ssize_t
-config_id_show(struct device *dev, struct device_attribute *attr, char *buf)
+line_size_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;
-   int i;
-
-   memset(&config_id, 0, sizeof(config_id));
-
-   config_id.max_line_sz = pipe->layers[0]->hsize_in.end;
-   config_id.side_by_side = mdev->side_by_side;
-   config_id.n_pipelines = mdev->n_pipelines;
-   config_id.n_scalers = pipe->n_scalers;
-   config_id.n_layers = pipe->n_layers;
-   config_id.n_richs = 0;
-   for (i = 0; i < pipe->n_layers; i++) {
+
+   return snprintf(buf, PAGE_SIZE, "%d\n", pipe->layers[0]->hsize_in.end);
+}
+static DEVICE_ATTR_RO(line_size);
+
+static ssize_t
+n_pipelines_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+   struct komeda_dev *mdev = dev_to_mdev(dev);
+
+   return snprintf(buf, PAGE_SIZE, "%d\n", mdev->n_pipelines);
+}
+static DEVICE_ATTR_RO(n_pipelines);
+
+static ssize_t
+n_layers_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];
+
+   return snprintf(buf, PAGE_SIZE, "%d\n", pipe->n_layers);
+}
+static DEVICE_ATTR_RO(n_layers);
+
+static ssize_t
+n_rich_layers_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];
+   int i, n_richs = 0;
+
+   for (i = 0; i < pipe->n_layers; i++)
if (pipe->layers[i]->layer_type == KOMEDA_FMT_RICH_LAYER)
-   config_id.n_richs++;
-   }
-   return snprintf(buf, PAGE_SIZE, "0x%08x\n", config_id.value);
+   n_richs++;
+
+   return snprintf(buf, PAGE_SIZE, "%d\n", n_richs);
+}
+static DEVICE_ATTR_RO(n_rich_layers);
+
+static ssize_t
+n_scalers_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];
+
+   return snprintf(buf, PAGE_SIZE, "%d\n", pipe->n_scalers);
+}
+static DEVICE_ATTR_RO(n_scalers);
+
+static ssize_t
+side_by_side_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+   struct komeda_dev *mdev = dev_to_mdev(dev);
+
+   return snprintf(buf, PAGE_SIZE, "%d\n", mdev->side_by_side);
 }
-static DEVICE_ATTR_RO(config_id);
+static DEVICE_ATTR_RO(side_by_side);
 
 static ssize_t
 aclk_hz_show(struct device *dev, struct device_attribute *attr, char *buf)
@@ -52,7 +91,12 @@ static DEVICE_ATTR_RO(aclk_hz);
 
 static struct attribute *komeda_sysfs_entries[] = {
&dev_attr_core_id.attr,
-   &dev_attr_config_id.attr,
+   &dev_attr_line_size.attr,
+   &dev_attr_n_pipelines.attr,
+   &dev_attr_n_layers.attr,
+   &dev_attr_n_rich_layers.attr,
+   &dev_attr_n_scalers.attr,
+   &dev_attr_side_by_side.attr,
&dev_attr_aclk_hz.attr,
NULL,
 };
-- 
2.20.1

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

Re: [PATCH v2 2/2] drm: share address space for dma bufs

2019-11-26 Thread Christian König

Am 22.11.19 um 19:21 schrieb Alex Deucher:

On Fri, Nov 22, 2019 at 4:17 AM Daniel Vetter  wrote:

On Fri, Nov 22, 2019 at 7:37 AM Gerd Hoffmann  wrote:

Use the shared address space of the drm device (see drm_open() in
drm_file.c) for dma-bufs too.  That removes a difference betweem drm
device mmap vmas and dma-buf mmap vmas and fixes corner cases like
dropping ptes (using madvise(DONTNEED) for example) not working
properly.

Also remove amdgpu driver's private dmabuf update.  It is not needed
any more now that we are doing this for everybody.

Signed-off-by: Gerd Hoffmann 

Reviewed-by: Daniel Vetter 

But I think you want at least an ack from amd guys for double checking here.
-Daniel

Looks correct to me.

Reviewed-by: Alex Deucher 


Reviewed-by: Christian König 





---
  drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 4 +---
  drivers/gpu/drm/drm_prime.c | 4 +++-
  2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
index d5bcdfefbad6..586db4fb46bd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
@@ -361,10 +361,8 @@ struct dma_buf *amdgpu_gem_prime_export(struct 
drm_gem_object *gobj,
 return ERR_PTR(-EPERM);

 buf = drm_gem_prime_export(gobj, flags);
-   if (!IS_ERR(buf)) {
-   buf->file->f_mapping = gobj->dev->anon_inode->i_mapping;
+   if (!IS_ERR(buf))
 buf->ops = &amdgpu_dmabuf_ops;
-   }

 return buf;
  }
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index a9633bd241bb..c3fc341453c0 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -240,6 +240,7 @@ void drm_prime_destroy_file_private(struct 
drm_prime_file_private *prime_fpriv)
  struct dma_buf *drm_gem_dmabuf_export(struct drm_device *dev,
   struct dma_buf_export_info *exp_info)
  {
+   struct drm_gem_object *obj = exp_info->priv;
 struct dma_buf *dma_buf;

 dma_buf = dma_buf_export(exp_info);
@@ -247,7 +248,8 @@ struct dma_buf *drm_gem_dmabuf_export(struct drm_device 
*dev,
 return dma_buf;

 drm_dev_get(dev);
-   drm_gem_object_get(exp_info->priv);
+   drm_gem_object_get(obj);
+   dma_buf->file->f_mapping = obj->dev->anon_inode->i_mapping;

 return dma_buf;
  }
--
2.18.1



--
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

___
amd-gfx mailing list
amd-...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


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

Re: [PATCH 2/2] drm/fourcc: Fill out all block sizes for P210

2019-11-26 Thread Liviu Dudau
On Tue, Nov 26, 2019 at 10:14:14AM +0100, Daniel Vetter wrote:
> 0 means 1 as the default, but it's mighty confusing if the block size
> for the first plane is spelled out explicitly, but not for the 2nd
> plane.
> 
> No cc: stable because this is just confusion, but 0 functional issue.

Agree!

> 
> Fixes: 7ba0fee247ee ("drm/fourcc: Add AFBC yuv fourccs for Mali")
> Cc: Brian Starkey 
> Cc: Ayan Kumar Halder 
> Cc: Liviu Dudau 

Acked-by: Liviu Dudau 

Best regards,

> Cc: Alyssa Rosenzweig 
> Cc: Maarten Lankhorst 
> Cc: Maxime Ripard 
> Signed-off-by: Daniel Vetter 
> ---
>  drivers/gpu/drm/drm_fourcc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> index fe79ce857c8a..b234bfaeda06 100644
> --- a/drivers/gpu/drm/drm_fourcc.c
> +++ b/drivers/gpu/drm/drm_fourcc.c
> @@ -263,7 +263,7 @@ const struct drm_format_info *__drm_format_info(u32 
> format)
> .hsub = 2, .vsub = 2, .is_yuv = true},
>   { .format = DRM_FORMAT_P210,.depth = 0,
> .num_planes = 2, .char_per_block = { 2, 4, 0 },
> -   .block_w = { 1, 0, 0 }, .block_h = { 1, 0, 0 }, .hsub = 2,
> +   .block_w = { 1, 1, 0 }, .block_h = { 1, 1, 0 }, .hsub = 2,
> .vsub = 1, .is_yuv = true },
>   { .format = DRM_FORMAT_VUY101010,   .depth = 0,
> .num_planes = 1, .cpp = { 0, 0, 0 }, .hsub = 1, .vsub = 1,
> -- 
> 2.24.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

[Bug 110674] Crashes / Resets From AMDGPU / Radeon VII

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

--- Comment #171 from line...@xcpp.org ---
Created attachment 146026
  --> https://bugs.freedesktop.org/attachment.cgi?id=146026&action=edit
5.4.0-arch1-1 GPU initialization fails

With kernel version 5.4.0-arch1-1 the GPU can flat out no longer be
initialized.

My system is now completely unusable with the current kernel.

Does this specifically mean anything?
[   15.575361] amdgpu: [powerplay] smu driver if version = 0x0013, smu fw
if version = 0x0012, smu fw version = 0x00282d00 (40.45.0)
[   15.575362] amdgpu: [powerplay] SMU driver if version not matched

-- 
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] MAINTAINERS: Drop Rex Zhu for amdgpu powerplay

2019-11-26 Thread Christian König

Reviewed-by: Christian König 

Am 25.11.19 um 06:30 schrieb Quan, Evan:

Reviewed-by: Evan Quan 


-Original Message-
From: amd-gfx  On Behalf Of Alex
Deucher
Sent: Saturday, November 23, 2019 3:19 AM
To: amd-...@lists.freedesktop.org; dri-devel@lists.freedesktop.org
Cc: Deucher, Alexander 
Subject: [PATCH] MAINTAINERS: Drop Rex Zhu for amdgpu powerplay

No longer works on the driver.

Signed-off-by: Alex Deucher 
---
  MAINTAINERS | 1 -
  1 file changed, 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index b63c291ad029..d518588b9879 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -856,7 +856,6 @@ S:  Maintained
  F:drivers/i2c/busses/i2c-amd-mp2*

  AMD POWERPLAY
-M: Rex Zhu 
  M:Evan Quan 
  L:amd-...@lists.freedesktop.org
  S:Supported
--
2.23.0

___
amd-gfx mailing list
amd-...@lists.freedesktop.org
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.free
desktop.org%2Fmailman%2Flistinfo%2Famd-
gfx&data=02%7C01%7Cevan.quan%40amd.com%7Ca64ca85a7c4a41c2d5
2408d76f80d191%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637
100471424667152&sdata=IlnGhFH1jHLTFk6NfLsZNGI%2FC7QNcYrER7TGG
uMbVE4%3D&reserved=0

___
amd-gfx mailing list
amd-...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


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

Re: [PATCH v1 2/2] drm/komeda: Refactor sysfs node "config_id"

2019-11-26 Thread Daniel Vetter
On Tue, Nov 26, 2019 at 10:54:47AM +, james qian wang (Arm Technology 
China) wrote:
> From: "James Qian Wang (Arm Technology China)" 
> 
> Split sysfs config_id bitfiles to multiple separated sysfs files.
> 
> Signed-off-by: James Qian Wang (Arm Technology China) 
> 

I guess Dave&my questions werent quite clear, this looks like uapi that's
consumed by hwc, so the userspace needs to be open source. Plus it needs
to be discussed/reviewed like any other kms uapi extensions, with a
critical eye whether this makes sense to add to a supposedly cross-vendor
interface.

I suspect the right thing to do here is to push the revert. From a quick
look at git history this landed together with the other kms properties in
komeda which we reverted already.
-Daniel

> ---
>  .../drm/arm/display/include/malidp_product.h  | 13 ---
>  .../gpu/drm/arm/display/komeda/komeda_sysfs.c | 80 ++-
>  2 files changed, 62 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/display/include/malidp_product.h 
> b/drivers/gpu/drm/arm/display/include/malidp_product.h
> index dbd3d4765065..b21f4aa15c95 100644
> --- a/drivers/gpu/drm/arm/display/include/malidp_product.h
> +++ b/drivers/gpu/drm/arm/display/include/malidp_product.h
> @@ -21,17 +21,4 @@
>  #define MALIDP_D71_PRODUCT_ID0x0071
>  #define MALIDP_D32_PRODUCT_ID0x0032
>  
> -union komeda_config_id {
> - struct {
> - __u32   max_line_sz:16,
> - n_pipelines:2,
> - n_scalers:2, /* number of scalers per pipeline */
> - n_layers:3, /* number of layers per pipeline */
> - n_richs:3, /* number of rich layers per pipeline */
> - side_by_side:1, /* if HW works on side_by_side mode */
> - reserved_bits:5;
> - };
> - __u32 value;
> -};
> -
>  #endif /* _MALIDP_PRODUCT_H_ */
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_sysfs.c 
> b/drivers/gpu/drm/arm/display/komeda/komeda_sysfs.c
> index 740f095b4ca5..5effab795dc1 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_sysfs.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_sysfs.c
> @@ -18,28 +18,67 @@ core_id_show(struct device *dev, struct device_attribute 
> *attr, char *buf)
>  static DEVICE_ATTR_RO(core_id);
>  
>  static ssize_t
> -config_id_show(struct device *dev, struct device_attribute *attr, char *buf)
> +line_size_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;
> - int i;
> -
> - memset(&config_id, 0, sizeof(config_id));
> -
> - config_id.max_line_sz = pipe->layers[0]->hsize_in.end;
> - config_id.side_by_side = mdev->side_by_side;
> - config_id.n_pipelines = mdev->n_pipelines;
> - config_id.n_scalers = pipe->n_scalers;
> - config_id.n_layers = pipe->n_layers;
> - config_id.n_richs = 0;
> - for (i = 0; i < pipe->n_layers; i++) {
> +
> + return snprintf(buf, PAGE_SIZE, "%d\n", pipe->layers[0]->hsize_in.end);
> +}
> +static DEVICE_ATTR_RO(line_size);
> +
> +static ssize_t
> +n_pipelines_show(struct device *dev, struct device_attribute *attr, char 
> *buf)
> +{
> + struct komeda_dev *mdev = dev_to_mdev(dev);
> +
> + return snprintf(buf, PAGE_SIZE, "%d\n", mdev->n_pipelines);
> +}
> +static DEVICE_ATTR_RO(n_pipelines);
> +
> +static ssize_t
> +n_layers_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];
> +
> + return snprintf(buf, PAGE_SIZE, "%d\n", pipe->n_layers);
> +}
> +static DEVICE_ATTR_RO(n_layers);
> +
> +static ssize_t
> +n_rich_layers_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];
> + int i, n_richs = 0;
> +
> + for (i = 0; i < pipe->n_layers; i++)
>   if (pipe->layers[i]->layer_type == KOMEDA_FMT_RICH_LAYER)
> - config_id.n_richs++;
> - }
> - return snprintf(buf, PAGE_SIZE, "0x%08x\n", config_id.value);
> + n_richs++;
> +
> + return snprintf(buf, PAGE_SIZE, "%d\n", n_richs);
> +}
> +static DEVICE_ATTR_RO(n_rich_layers);
> +
> +static ssize_t
> +n_scalers_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];
> +
> + return snprintf(buf, PAGE_SIZE, "%d\n", pipe->n_scalers);
> +}
> +static DEVICE_ATTR_RO(n_scalers);
> +
> +static ssize_t
> +side_by_side_show(struct device *dev, struct device_attribute *attr, char 
> *buf)
> +{
> + struct komeda_dev *mdev = dev_to_mdev(dev);
> +
> + return snprintf(buf, PAGE_SIZE, "%d\n", 

[PATCH] drm/amdgpu: Fix a bug in jpeg_v1_0_start()

2019-11-26 Thread Dan Carpenter
Originally the last WREG32_SOC15() was a part of the if statement block
but the curly braces are on the wrong line.

Fixes: bb0db70f3f75 ("drm/amdgpu: separate JPEG1.0 code out from VCN1.0")
Signed-off-by: Dan Carpenter 
---
From static analysis (Smatch).  Not tested.

 drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c 
b/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c
index 553506df077d..a141408dfb23 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c
@@ -522,7 +522,8 @@ void jpeg_v1_0_start(struct amdgpu_device *adev, int mode)
WREG32_SOC15(JPEG, 0, mmUVD_LMI_JRBC_RB_64BIT_BAR_HIGH, 
upper_32_bits(ring->gpu_addr));
WREG32_SOC15(JPEG, 0, mmUVD_JRBC_RB_RPTR, 0);
WREG32_SOC15(JPEG, 0, mmUVD_JRBC_RB_WPTR, 0);
-   }   WREG32_SOC15(JPEG, 0, mmUVD_JRBC_RB_CNTL, 
UVD_JRBC_RB_CNTL__RB_RPTR_WR_EN_MASK);
+   WREG32_SOC15(JPEG, 0, mmUVD_JRBC_RB_CNTL, 
UVD_JRBC_RB_CNTL__RB_RPTR_WR_EN_MASK);
+   }
 
/* initialize wptr */
ring->wptr = RREG32_SOC15(JPEG, 0, mmUVD_JRBC_RB_WPTR);
-- 
2.11.0

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

[PATCH] drm/i915: unmap the correct pointer in i915_error_object_create()

2019-11-26 Thread Dan Carpenter
We should be unmapping "page" instead of "s".  This code originally used
kmap_atomic() before it was changed to kmap().  The two mapping
functions are different which leads to this common mistake.

Fixes: 3e749f5199e1 ("drm/i915: Avoid atomic context for error capture")
Signed-off-by: Dan Carpenter 
---
 drivers/gpu/drm/i915/i915_gpu_error.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c 
b/drivers/gpu/drm/i915/i915_gpu_error.c
index 3c85cb0ee99f..6fe23446303b 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -1045,7 +1045,7 @@ i915_error_object_create(struct drm_i915_private *i915,
 
s = kmap(page);
ret = compress_page(compress, s, dst);
-   kunmap(s);
+   kunmap(page);
 
drm_clflush_pages(&page, 1);
 
-- 
2.11.0

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

Re: [Intel-gfx] [PATCH] drm/i915: unmap the correct pointer in i915_error_object_create()

2019-11-26 Thread Chris Wilson
Quoting Dan Carpenter (2019-11-26 12:50:03)
> We should be unmapping "page" instead of "s".  This code originally used
> kmap_atomic() before it was changed to kmap().  The two mapping
> functions are different which leads to this common mistake.
> 
> Fixes: 3e749f5199e1 ("drm/i915: Avoid atomic context for error capture")
> Signed-off-by: Dan Carpenter 

Caught by bae21dacd7b7 ("drm/i915: Switch kunmap() to take the page not
vaddr")

Thanks for smatch!
-Chris
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 04/30] drm/bridge: anx78xx: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c 
b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
index 41867be03751..e37892cdc9cf 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
@@ -1214,10 +1214,6 @@ static int anx78xx_i2c_probe(struct i2c_client *client,
 
mutex_init(&anx78xx->lock);
 
-#if IS_ENABLED(CONFIG_OF)
-   anx78xx->bridge.of_node = client->dev.of_node;
-#endif
-
anx78xx->client = client;
i2c_set_clientdata(client, anx78xx);
 
@@ -1321,8 +1317,8 @@ static int anx78xx_i2c_probe(struct i2c_client *client,
goto err_poweroff;
}
 
-   anx78xx->bridge.funcs = &anx78xx_bridge_funcs;
-
+   drm_bridge_init(&anx78xx->bridge, &client->dev, &anx78xx_bridge_funcs,
+   NULL, NULL);
drm_bridge_add(&anx78xx->bridge);
 
/* If cable is pulled out, just poweroff and wait for HPD event */
-- 
2.23.0

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

[PATCH 07/30] drm/bridge: lvds-encoder: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/lvds-encoder.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/bridge/lvds-encoder.c 
b/drivers/gpu/drm/bridge/lvds-encoder.c
index e2132a8d5106..155406510416 100644
--- a/drivers/gpu/drm/bridge/lvds-encoder.c
+++ b/drivers/gpu/drm/bridge/lvds-encoder.c
@@ -112,11 +112,10 @@ static int lvds_encoder_probe(struct platform_device 
*pdev)
return PTR_ERR(lvds_encoder->panel_bridge);
 
/* The panel_bridge bridge is attached to the panel's of_node,
-* but we need a bridge attached to our of_node for our user
-* to look up.
+* but we need a bridge attached to our of_node (in dev->of_node)
+* for our user to look up.
 */
-   lvds_encoder->bridge.of_node = dev->of_node;
-   lvds_encoder->bridge.funcs = &funcs;
+   drm_bridge_init(&lvds_encoder->bridge, dev, &funcs, NULL, NULL);
drm_bridge_add(&lvds_encoder->bridge);
 
platform_set_drvdata(pdev, lvds_encoder);
-- 
2.23.0

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

[PATCH 10/30] drm/bridge: panel: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/panel.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c
index f4e293e7cf64..91d68d0337cc 100644
--- a/drivers/gpu/drm/bridge/panel.c
+++ b/drivers/gpu/drm/bridge/panel.c
@@ -192,11 +192,8 @@ struct drm_bridge *drm_panel_bridge_add_typed(struct 
drm_panel *panel,
panel_bridge->connector_type = connector_type;
panel_bridge->panel = panel;
 
-   panel_bridge->bridge.funcs = &panel_bridge_bridge_funcs;
-#ifdef CONFIG_OF
-   panel_bridge->bridge.of_node = panel->dev->of_node;
-#endif
-
+   drm_bridge_init(&panel_bridge->bridge, panel->dev,
+   &panel_bridge_bridge_funcs, NULL, NULL);
drm_bridge_add(&panel_bridge->bridge);
 
return &panel_bridge->bridge;
-- 
2.23.0

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

[PATCH 02/30] drm/bridge: adv7511: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c 
b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
index 9e13e466e72c..73600d8766f8 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -1216,9 +1216,8 @@ static int adv7511_probe(struct i2c_client *i2c, const 
struct i2c_device_id *id)
if (ret)
goto err_unregister_cec;
 
-   adv7511->bridge.funcs = &adv7511_bridge_funcs;
-   adv7511->bridge.of_node = dev->of_node;
-
+   drm_bridge_init(&adv7511->bridge, dev, &adv7511_bridge_funcs,
+   NULL, NULL);
drm_bridge_add(&adv7511->bridge);
 
adv7511_audio_init(dev, adv7511);
-- 
2.23.0

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

[PATCH 14/30] drm/bridge: sil_sii8620: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/sil-sii8620.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c 
b/drivers/gpu/drm/bridge/sil-sii8620.c
index 4c0eef406eb1..482dc2291350 100644
--- a/drivers/gpu/drm/bridge/sil-sii8620.c
+++ b/drivers/gpu/drm/bridge/sil-sii8620.c
@@ -2337,8 +2337,7 @@ static int sii8620_probe(struct i2c_client *client,
 
i2c_set_clientdata(client, ctx);
 
-   ctx->bridge.funcs = &sii8620_bridge_funcs;
-   ctx->bridge.of_node = dev->of_node;
+   drm_bridge_init(&ctx->bridge, dev, &sii8620_bridge_funcs, NULL, NULL);
drm_bridge_add(&ctx->bridge);
 
if (!ctx->extcon)
-- 
2.23.0

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

[PATCH 12/30] drm/bridge: sii902x: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/sii902x.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index b70e8c5cf2e1..2a9db621484d 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -1017,9 +1017,8 @@ static int sii902x_probe(struct i2c_client *client,
return ret;
}
 
-   sii902x->bridge.funcs = &sii902x_bridge_funcs;
-   sii902x->bridge.of_node = dev->of_node;
-   sii902x->bridge.timings = &default_sii902x_timings;
+   drm_bridge_init(&sii902x->bridge, dev, &sii902x_bridge_funcs,
+   &default_sii902x_timings, NULL);
drm_bridge_add(&sii902x->bridge);
 
sii902x_audio_codec_init(sii902x, dev);
-- 
2.23.0

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

[PATCH 01/30] drm: Introduce drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
A simple convenience function to initialize the struct drm_bridge.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/drm_bridge.c | 29 +
 include/drm/drm_bridge.h |  4 
 2 files changed, 33 insertions(+)

diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index cba537c99e43..cbe680aa6eac 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -89,6 +89,35 @@ void drm_bridge_remove(struct drm_bridge *bridge)
 }
 EXPORT_SYMBOL(drm_bridge_remove);
 
+/**
+ * drm_bridge_init - initialise a drm_bridge structure
+ *
+ * @bridge: bridge control structure
+ * @funcs: control functions
+ * @dev: device
+ * @timings: timing specification for the bridge; optional (may be NULL)
+ * @driver_private: pointer to the bridge driver internal context (may be NULL)
+ */
+void drm_bridge_init(struct drm_bridge *bridge, struct device *dev,
+const struct drm_bridge_funcs *funcs,
+const struct drm_bridge_timings *timings,
+void *driver_private)
+{
+   WARN_ON(!funcs);
+
+   bridge->dev = NULL;
+   bridge->encoder = NULL;
+   bridge->next = NULL;
+
+#ifdef CONFIG_OF
+   bridge->of_node = dev->of_node;
+#endif
+   bridge->timings = timings;
+   bridge->funcs = funcs;
+   bridge->driver_private = driver_private;
+}
+EXPORT_SYMBOL(drm_bridge_init);
+
 /**
  * drm_bridge_attach - attach the bridge to an encoder's chain
  *
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index c0a2286a81e9..d6d9d5301551 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -402,6 +402,10 @@ struct drm_bridge {
 
 void drm_bridge_add(struct drm_bridge *bridge);
 void drm_bridge_remove(struct drm_bridge *bridge);
+void drm_bridge_init(struct drm_bridge *bridge, struct device *dev,
+const struct drm_bridge_funcs *funcs,
+const struct drm_bridge_timings *timings,
+void *driver_private);
 struct drm_bridge *of_drm_find_bridge(struct device_node *np);
 int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
  struct drm_bridge *previous);
-- 
2.23.0

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

[PATCH 11/30] drm/bridge: ps8622: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/parade-ps8622.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/parade-ps8622.c 
b/drivers/gpu/drm/bridge/parade-ps8622.c
index b7a72dfdcac3..8454dbb238bb 100644
--- a/drivers/gpu/drm/bridge/parade-ps8622.c
+++ b/drivers/gpu/drm/bridge/parade-ps8622.c
@@ -588,8 +588,7 @@ static int ps8622_probe(struct i2c_client *client,
ps8622->bl->props.brightness = PS8622_MAX_BRIGHTNESS;
}
 
-   ps8622->bridge.funcs = &ps8622_bridge_funcs;
-   ps8622->bridge.of_node = dev->of_node;
+   drm_bridge_init(&ps8622->bridge, dev, &ps8622_bridge_funcs, NULL, NULL);
drm_bridge_add(&ps8622->bridge);
 
i2c_set_clientdata(client, ps8622);
-- 
2.23.0

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

[PATCH 25/30] drm/mediatek: hdmi: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/mediatek/mtk_hdmi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c 
b/drivers/gpu/drm/mediatek/mtk_hdmi.c
index f684947c5243..9761a80674d9 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -1708,8 +1708,8 @@ static int mtk_drm_hdmi_probe(struct platform_device 
*pdev)
 
mtk_hdmi_register_audio_driver(dev);
 
-   hdmi->bridge.funcs = &mtk_hdmi_bridge_funcs;
-   hdmi->bridge.of_node = pdev->dev.of_node;
+   drm_bridge_init(&hdmi->bridge, &pdev->dev, &mtk_hdmi_bridge_funcs,
+   NULL, NULL);
drm_bridge_add(&hdmi->bridge);
 
ret = mtk_hdmi_clk_enable_audio(hdmi);
-- 
2.23.0

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

[PATCH 03/30] drm/bridge: anx6345: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c 
b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
index b4f3a923a52a..130d5c3a07ef 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
@@ -696,8 +696,6 @@ static int anx6345_i2c_probe(struct i2c_client *client,
 
mutex_init(&anx6345->lock);
 
-   anx6345->bridge.of_node = client->dev.of_node;
-
anx6345->client = client;
i2c_set_clientdata(client, anx6345);
 
@@ -760,7 +758,8 @@ static int anx6345_i2c_probe(struct i2c_client *client,
/* Look for supported chip ID */
anx6345_poweron(anx6345);
if (anx6345_get_chip_id(anx6345)) {
-   anx6345->bridge.funcs = &anx6345_bridge_funcs;
+   drm_bridge_init(&anx6345->bridge, &client->dev,
+   &anx6345_bridge_funcs, NULL, NULL);
drm_bridge_add(&anx6345->bridge);
 
return 0;
-- 
2.23.0

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

[PATCH 29/30] drm/bridge: add support for device links to bridge

2019-11-26 Thread Mihail Atanassov
From: Russell King 

Bridge devices have been a potential for kernel oops as their lifetime
is independent of the DRM device that they are bound to.  Hence, if a
bridge device is unbound while the parent DRM device is using them, the
parent happily continues to use the bridge device, calling the driver
and accessing its objects that have been freed.

This can cause kernel memory corruption and kernel oops.

To control this, use device links to ensure that the parent DRM device
is unbound when the bridge device is unbound, and when the bridge
device is re-bound, automatically rebind the parent DRM device.

Signed-off-by: Russell King 
Tested-by: Mihail Atanassov 
[reworked to use drm_bridge_init() for setting bridge->device]
Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/drm_bridge.c | 49 ++--
 include/drm/drm_bridge.h |  4 +++
 2 files changed, 40 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index cbe680aa6eac..e1f8db84651a 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -26,6 +26,7 @@
 #include 
 
 #include 
+#include 
 #include 
 
 #include "drm_crtc_internal.h"
@@ -109,6 +110,7 @@ void drm_bridge_init(struct drm_bridge *bridge, struct 
device *dev,
bridge->encoder = NULL;
bridge->next = NULL;
 
+   bridge->device = dev;
 #ifdef CONFIG_OF
bridge->of_node = dev->of_node;
 #endif
@@ -492,6 +494,32 @@ void drm_atomic_bridge_enable(struct drm_bridge *bridge,
 EXPORT_SYMBOL(drm_atomic_bridge_enable);
 
 #ifdef CONFIG_OF
+static struct drm_bridge *drm_bridge_find(struct drm_device *dev,
+ struct device_node *np, bool link)
+{
+   struct drm_bridge *bridge, *found = NULL;
+   struct device_link *dl;
+
+   mutex_lock(&bridge_lock);
+
+   list_for_each_entry(bridge, &bridge_list, list)
+   if (bridge->of_node == np) {
+   found = bridge;
+   break;
+   }
+
+   if (found && link) {
+   dl = device_link_add(dev->dev, found->device,
+DL_FLAG_AUTOPROBE_CONSUMER);
+   if (!dl)
+   found = NULL;
+   }
+
+   mutex_unlock(&bridge_lock);
+
+   return found;
+}
+
 /**
  * of_drm_find_bridge - find the bridge corresponding to the device node in
  * the global bridge list
@@ -503,21 +531,16 @@ EXPORT_SYMBOL(drm_atomic_bridge_enable);
  */
 struct drm_bridge *of_drm_find_bridge(struct device_node *np)
 {
-   struct drm_bridge *bridge;
-
-   mutex_lock(&bridge_lock);
-
-   list_for_each_entry(bridge, &bridge_list, list) {
-   if (bridge->of_node == np) {
-   mutex_unlock(&bridge_lock);
-   return bridge;
-   }
-   }
-
-   mutex_unlock(&bridge_lock);
-   return NULL;
+   return drm_bridge_find(NULL, np, false);
 }
 EXPORT_SYMBOL(of_drm_find_bridge);
+
+struct drm_bridge *of_drm_find_bridge_devlink(struct drm_device *dev,
+ struct device_node *np)
+{
+   return drm_bridge_find(dev, np, true);
+}
+EXPORT_SYMBOL(of_drm_find_bridge_devlink);
 #endif
 
 MODULE_AUTHOR("Ajay Kumar ");
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index d6d9d5301551..68b27c69cc3d 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -382,6 +382,8 @@ struct drm_bridge {
struct drm_encoder *encoder;
/** @next: the next bridge in the encoder chain */
struct drm_bridge *next;
+   /** @device: Linux driver model device */
+   struct device *device;
 #ifdef CONFIG_OF
/** @of_node: device node pointer to the bridge */
struct device_node *of_node;
@@ -407,6 +409,8 @@ void drm_bridge_init(struct drm_bridge *bridge, struct 
device *dev,
 const struct drm_bridge_timings *timings,
 void *driver_private);
 struct drm_bridge *of_drm_find_bridge(struct device_node *np);
+struct drm_bridge *of_drm_find_bridge_devlink(struct drm_device *dev,
+ struct device_node *np);
 int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
  struct drm_bridge *previous);
 
-- 
2.23.0

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

[PATCH 19/30] drm/bridge: thc63: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/thc63lvd1024.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/bridge/thc63lvd1024.c 
b/drivers/gpu/drm/bridge/thc63lvd1024.c
index 3d74129b2995..abe806db5f4d 100644
--- a/drivers/gpu/drm/bridge/thc63lvd1024.c
+++ b/drivers/gpu/drm/bridge/thc63lvd1024.c
@@ -218,11 +218,8 @@ static int thc63_probe(struct platform_device *pdev)
if (ret)
return ret;
 
-   thc63->bridge.driver_private = thc63;
-   thc63->bridge.of_node = pdev->dev.of_node;
-   thc63->bridge.funcs = &thc63_bridge_func;
-   thc63->bridge.timings = &thc63->timings;
-
+   drm_bridge_init(&thc63->bridge, &pdev->dev, &thc63_bridge_func,
+   &thc63->timings, thc63);
drm_bridge_add(&thc63->bridge);
 
return 0;
-- 
2.23.0

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

[PATCH 22/30] drm/exynos: mic: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change: no logic depends on driver_private being NULL, so
it's safe to set it earlier in exynos_mic_probe.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/exynos/exynos_drm_mic.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_mic.c 
b/drivers/gpu/drm/exynos/exynos_drm_mic.c
index f41d75923557..caad348a5646 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_mic.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_mic.c
@@ -309,10 +309,6 @@ static const struct drm_bridge_funcs mic_bridge_funcs = {
 static int exynos_mic_bind(struct device *dev, struct device *master,
   void *data)
 {
-   struct exynos_mic *mic = dev_get_drvdata(dev);
-
-   mic->bridge.driver_private = mic;
-
return 0;
 }
 
@@ -422,9 +418,7 @@ static int exynos_mic_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, mic);
 
-   mic->bridge.funcs = &mic_bridge_funcs;
-   mic->bridge.of_node = dev->of_node;
-
+   drm_bridge_init(&mic->bridge, dev, &mic_bridge_funcs, NULL, mic);
drm_bridge_add(&mic->bridge);
 
pm_runtime_enable(dev);
-- 
2.23.0

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

[PATCH 26/30] drm: rcar-du: lvds: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/rcar-du/rcar_lvds.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.c 
b/drivers/gpu/drm/rcar-du/rcar_lvds.c
index 8c6c172bbf2e..ac1f29bacfcb 100644
--- a/drivers/gpu/drm/rcar-du/rcar_lvds.c
+++ b/drivers/gpu/drm/rcar-du/rcar_lvds.c
@@ -881,9 +881,8 @@ static int rcar_lvds_probe(struct platform_device *pdev)
if (ret < 0)
return ret;
 
-   lvds->bridge.driver_private = lvds;
-   lvds->bridge.funcs = &rcar_lvds_bridge_ops;
-   lvds->bridge.of_node = pdev->dev.of_node;
+   drm_bridge_init(&lvds->bridge, &pdev->dev, &rcar_lvds_bridge_ops,
+   NULL, lvds);
 
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
lvds->mmio = devm_ioremap_resource(&pdev->dev, mem);
-- 
2.23.0

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

[PATCH 06/30] drm/bridge: dumb-vga-dac: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/dumb-vga-dac.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/bridge/dumb-vga-dac.c 
b/drivers/gpu/drm/bridge/dumb-vga-dac.c
index cc33dc411b9e..896f27272e38 100644
--- a/drivers/gpu/drm/bridge/dumb-vga-dac.c
+++ b/drivers/gpu/drm/bridge/dumb-vga-dac.c
@@ -205,10 +205,8 @@ static int dumb_vga_probe(struct platform_device *pdev)
}
}
 
-   vga->bridge.funcs = &dumb_vga_bridge_funcs;
-   vga->bridge.of_node = pdev->dev.of_node;
-   vga->bridge.timings = of_device_get_match_data(&pdev->dev);
-
+   drm_bridge_init(&vga->bridge, &pdev->dev, &dumb_vga_bridge_funcs,
+   of_device_get_match_data(&pdev->dev), NULL);
drm_bridge_add(&vga->bridge);
 
return 0;
-- 
2.23.0

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

[PATCH 21/30] drm/bridge: ti-tfp410: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/ti-tfp410.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c 
b/drivers/gpu/drm/bridge/ti-tfp410.c
index aa3198dc9903..377eca989ff3 100644
--- a/drivers/gpu/drm/bridge/ti-tfp410.c
+++ b/drivers/gpu/drm/bridge/ti-tfp410.c
@@ -328,9 +328,8 @@ static int tfp410_init(struct device *dev, bool i2c)
return -ENOMEM;
dev_set_drvdata(dev, dvi);
 
-   dvi->bridge.funcs = &tfp410_bridge_funcs;
-   dvi->bridge.of_node = dev->of_node;
-   dvi->bridge.timings = &dvi->timings;
+   drm_bridge_init(&dvi->bridge, dev, &tfp410_bridge_funcs, &dvi->timings,
+   NULL);
dvi->dev = dev;
 
ret = tfp410_parse_timings(dvi, i2c);
-- 
2.23.0

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

[PATCH 16/30] drm/bridge/synopsys: dsi: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c 
b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
index b6e793bb653c..051f9aaf5867 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
@@ -1052,11 +1052,8 @@ __dw_mipi_dsi_probe(struct platform_device *pdev,
return ERR_PTR(ret);
}
 
-   dsi->bridge.driver_private = dsi;
-   dsi->bridge.funcs = &dw_mipi_dsi_bridge_funcs;
-#ifdef CONFIG_OF
-   dsi->bridge.of_node = pdev->dev.of_node;
-#endif
+   drm_bridge_init(&dsi->bridge, &pdev->dev, &dw_mipi_dsi_bridge_funcs,
+   NULL, dsi);
 
return dsi;
 }
-- 
2.23.0

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

[PATCH 15/30] drm/bridge: dw-hdmi: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c 
b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
index dbe38a54870b..6c71ffc9df5a 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
@@ -2898,11 +2898,8 @@ __dw_hdmi_probe(struct platform_device *pdev,
hdmi->ddc = NULL;
}
 
-   hdmi->bridge.driver_private = hdmi;
-   hdmi->bridge.funcs = &dw_hdmi_bridge_funcs;
-#ifdef CONFIG_OF
-   hdmi->bridge.of_node = pdev->dev.of_node;
-#endif
+   drm_bridge_init(&hdmi->bridge, &pdev->dev, &dw_hdmi_bridge_funcs,
+   NULL, hdmi);
 
memset(&pdevinfo, 0, sizeof(pdevinfo));
pdevinfo.parent = dev;
-- 
2.23.0

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

[PATCH 13/30] gpu: drm: bridge: sii9234: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/sii9234.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/sii9234.c b/drivers/gpu/drm/bridge/sii9234.c
index f81f81b7051f..bfd3832baa1a 100644
--- a/drivers/gpu/drm/bridge/sii9234.c
+++ b/drivers/gpu/drm/bridge/sii9234.c
@@ -925,8 +925,7 @@ static int sii9234_probe(struct i2c_client *client,
 
i2c_set_clientdata(client, ctx);
 
-   ctx->bridge.funcs = &sii9234_bridge_funcs;
-   ctx->bridge.of_node = dev->of_node;
+   drm_bridge_init(&ctx->bridge, dev, &sii9234_bridge_funcs, NULL, NULL);
drm_bridge_add(&ctx->bridge);
 
sii9234_cable_in(ctx);
-- 
2.23.0

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

[PATCH 05/30] drm/bridge: cdns: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/cdns-dsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/cdns-dsi.c 
b/drivers/gpu/drm/bridge/cdns-dsi.c
index 3a5bd4e7fd1e..58b2aa8b6c24 100644
--- a/drivers/gpu/drm/bridge/cdns-dsi.c
+++ b/drivers/gpu/drm/bridge/cdns-dsi.c
@@ -1233,8 +1233,8 @@ static int cdns_dsi_drm_probe(struct platform_device 
*pdev)
 * CDNS_DPI_INPUT.
 */
input->id = CDNS_DPI_INPUT;
-   input->bridge.funcs = &cdns_dsi_bridge_funcs;
-   input->bridge.of_node = pdev->dev.of_node;
+   drm_bridge_init(&input->bridge, &pdev->dev, &cdns_dsi_bridge_funcs,
+   NULL, NULL);
 
/* Mask all interrupts before registering the IRQ handler. */
writel(0, dsi->regs + MCTL_MAIN_STS_CTL);
-- 
2.23.0

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

[PATCH 09/30] drm/bridge: nxp-ptn3460: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/nxp-ptn3460.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/nxp-ptn3460.c 
b/drivers/gpu/drm/bridge/nxp-ptn3460.c
index 57ff01339559..2656a188b434 100644
--- a/drivers/gpu/drm/bridge/nxp-ptn3460.c
+++ b/drivers/gpu/drm/bridge/nxp-ptn3460.c
@@ -320,8 +320,8 @@ static int ptn3460_probe(struct i2c_client *client,
return ret;
}
 
-   ptn_bridge->bridge.funcs = &ptn3460_bridge_funcs;
-   ptn_bridge->bridge.of_node = dev->of_node;
+   drm_bridge_init(&ptn_bridge->bridge, dev, &ptn3460_bridge_funcs,
+   NULL, NULL);
drm_bridge_add(&ptn_bridge->bridge);
 
i2c_set_clientdata(client, ptn_bridge);
-- 
2.23.0

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

[PATCH 18/30] drm/bridge: tc358767: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/tc358767.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/tc358767.c 
b/drivers/gpu/drm/bridge/tc358767.c
index 8029478ffebb..7846c1925cbb 100644
--- a/drivers/gpu/drm/bridge/tc358767.c
+++ b/drivers/gpu/drm/bridge/tc358767.c
@@ -1671,8 +1671,7 @@ static int tc_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
if (ret)
return ret;
 
-   tc->bridge.funcs = &tc_bridge_funcs;
-   tc->bridge.of_node = dev->of_node;
+   drm_bridge_init(&tc->bridge, dev, &tc_bridge_funcs, NULL, NULL);
drm_bridge_add(&tc->bridge);
 
i2c_set_clientdata(client, tc);
-- 
2.23.0

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

[PATCH 24/30] drm/mcde: dsi: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/mcde/mcde_dsi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/mcde/mcde_dsi.c b/drivers/gpu/drm/mcde/mcde_dsi.c
index 42fff811653e..d9b9253acccf 100644
--- a/drivers/gpu/drm/mcde/mcde_dsi.c
+++ b/drivers/gpu/drm/mcde/mcde_dsi.c
@@ -955,8 +955,7 @@ static int mcde_dsi_bind(struct device *dev, struct device 
*master,
d->bridge_out = bridge;
 
/* Create a bridge for this DSI channel */
-   d->bridge.funcs = &mcde_dsi_bridge_funcs;
-   d->bridge.of_node = dev->of_node;
+   drm_bridge_init(&d->bridge, dev, &mcde_dsi_bridge_funcs, NULL, NULL);
drm_bridge_add(&d->bridge);
 
/* TODO: first come first serve, use a list */
-- 
2.23.0

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

[PATCH 23/30] drm/i2c: tda998x: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/i2c/tda998x_drv.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c 
b/drivers/gpu/drm/i2c/tda998x_drv.c
index a63790d32d75..f7dfa694aff7 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -1974,11 +1974,7 @@ static int tda998x_create(struct device *dev)
goto fail;
}
 
-   priv->bridge.funcs = &tda998x_bridge_funcs;
-#ifdef CONFIG_OF
-   priv->bridge.of_node = dev->of_node;
-#endif
-
+   drm_bridge_init(&priv->bridge, dev, &tda998x_bridge_funcs, NULL, NULL);
drm_bridge_add(&priv->bridge);
 
return 0;
-- 
2.23.0

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

[PATCH 20/30] drm/bridge: ti-sn65dsi86: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/ti-sn65dsi86.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c 
b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
index 43abf01ebd4c..4e236b46f913 100644
--- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c
+++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
@@ -765,9 +765,8 @@ static int ti_sn_bridge_probe(struct i2c_client *client,
pdata->aux.transfer = ti_sn_aux_transfer;
drm_dp_aux_register(&pdata->aux);
 
-   pdata->bridge.funcs = &ti_sn_bridge_funcs;
-   pdata->bridge.of_node = client->dev.of_node;
-
+   drm_bridge_init(&pdata->bridge, &client->dev, &ti_sn_bridge_funcs,
+   NULL, NULL);
drm_bridge_add(&pdata->bridge);
 
ti_sn_debugfs_init(pdata);
-- 
2.23.0

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

[PATCH 08/30] drm/bridge: megachips-stdpxxxx-ge-b850v3-fw: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c 
b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
index e8a49f6146c6..d567cd63810f 100644
--- a/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
+++ b/drivers/gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c
@@ -303,8 +303,8 @@ static int stdp4028_ge_b850v3_fw_probe(struct i2c_client 
*stdp4028_i2c,
i2c_set_clientdata(stdp4028_i2c, ge_b850v3_lvds_ptr);
 
/* drm bridge initialization */
-   ge_b850v3_lvds_ptr->bridge.funcs = &ge_b850v3_lvds_funcs;
-   ge_b850v3_lvds_ptr->bridge.of_node = dev->of_node;
+   drm_bridge_init(&ge_b850v3_lvds_ptr->bridge, dev, &ge_b850v3_lvds_funcs,
+   NULL, NULL);
drm_bridge_add(&ge_b850v3_lvds_ptr->bridge);
 
/* Clear pending interrupts since power up. */
-- 
2.23.0

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

[PATCH 27/30] drm: rcar-du: lvds: Don't set drm_bridge private pointer

2019-11-26 Thread Mihail Atanassov
No functional change: it's not used anywhere.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/rcar-du/rcar_lvds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.c 
b/drivers/gpu/drm/rcar-du/rcar_lvds.c
index ac1f29bacfcb..168a718cbcbd 100644
--- a/drivers/gpu/drm/rcar-du/rcar_lvds.c
+++ b/drivers/gpu/drm/rcar-du/rcar_lvds.c
@@ -882,7 +882,7 @@ static int rcar_lvds_probe(struct platform_device *pdev)
return ret;
 
drm_bridge_init(&lvds->bridge, &pdev->dev, &rcar_lvds_bridge_ops,
-   NULL, lvds);
+   NULL, NULL);
 
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
lvds->mmio = devm_ioremap_resource(&pdev->dev, mem);
-- 
2.23.0

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

[PATCH 28/30] drm/sti: sti_vdo: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/sti/sti_dvo.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/sti/sti_dvo.c b/drivers/gpu/drm/sti/sti_dvo.c
index 68289b0b063a..20a3956b33bc 100644
--- a/drivers/gpu/drm/sti/sti_dvo.c
+++ b/drivers/gpu/drm/sti/sti_dvo.c
@@ -462,9 +462,7 @@ static int sti_dvo_bind(struct device *dev, struct device 
*master, void *data)
if (!bridge)
return -ENOMEM;
 
-   bridge->driver_private = dvo;
-   bridge->funcs = &sti_dvo_bridge_funcs;
-   bridge->of_node = dvo->dev.of_node;
+   drm_bridge_init(bridge, &dvo->dev, &sti_dvo_bridge_funcs, NULL, dvo);
drm_bridge_add(bridge);
 
err = drm_bridge_attach(encoder, bridge, NULL);
-- 
2.23.0

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

[PATCH 17/30] drm/bridge: tc358764: Use drm_bridge_init()

2019-11-26 Thread Mihail Atanassov
No functional change.

Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/tc358764.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/tc358764.c 
b/drivers/gpu/drm/bridge/tc358764.c
index db298f550a5a..861d4df687ee 100644
--- a/drivers/gpu/drm/bridge/tc358764.c
+++ b/drivers/gpu/drm/bridge/tc358764.c
@@ -457,9 +457,7 @@ static int tc358764_probe(struct mipi_dsi_device *dsi)
if (ret < 0)
return ret;
 
-   ctx->bridge.funcs = &tc358764_bridge_funcs;
-   ctx->bridge.of_node = dev->of_node;
-
+   drm_bridge_init(&ctx->bridge, dev, &tc358764_bridge_funcs, NULL, NULL);
drm_bridge_add(&ctx->bridge);
 
ret = mipi_dsi_attach(dsi);
-- 
2.23.0

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

[PATCH 00/30] drm/bridge: Add device links for lifetime control

2019-11-26 Thread Mihail Atanassov
Hi all,

This series adds device links support to drm_bridge. The motivation
behind it is that a drm_bridge in a module could get removed under the
feet of the bridge user without warning, so we need a way to remove and
reprobe the client as needed to avoid peering into the void.

1: Add a drm_bridge_init() function which wraps all initialisation of
the structure prior to calling drm_bridge_add().

2-26,28: Apply the drm_bridge_init() refactor to every bridge that uses
drm_bridge_add().

27: Minor cleanup in rcar-du.

29: Add of_drm_find_bridge_devlink() which functions the same as
of_drm_find_bridge() plus adds a device device link from the owning
drm_device to the bridge device.

30: As a motivating example, convert komeda to exclusively use
drm_bridge for its pipe outputs; this isn't a regression in usability
any more since device links bring the same automatic remove/reprobe
feature as components.

Mihail Atanassov (29):
  drm: Introduce drm_bridge_init()
  drm/bridge: adv7511: Use drm_bridge_init()
  drm/bridge: anx6345: Use drm_bridge_init()
  drm/bridge: anx78xx: Use drm_bridge_init()
  drm/bridge: cdns: Use drm_bridge_init()
  drm/bridge: dumb-vga-dac: Use drm_bridge_init()
  drm/bridge: lvds-encoder: Use drm_bridge_init()
  drm/bridge: megachips-stdp-ge-b850v3-fw: Use drm_bridge_init()
  drm/bridge: nxp-ptn3460: Use drm_bridge_init()
  drm/bridge: panel: Use drm_bridge_init()
  drm/bridge: ps8622: Use drm_bridge_init()
  drm/bridge: sii902x: Use drm_bridge_init()
  gpu: drm: bridge: sii9234: Use drm_bridge_init()
  drm/bridge: sil_sii8620: Use drm_bridge_init()
  drm/bridge: dw-hdmi: Use drm_bridge_init()
  drm/bridge/synopsys: dsi: Use drm_bridge_init()
  drm/bridge: tc358764: Use drm_bridge_init()
  drm/bridge: tc358767: Use drm_bridge_init()
  drm/bridge: thc63: Use drm_bridge_init()
  drm/bridge: ti-sn65dsi86: Use drm_bridge_init()
  drm/bridge: ti-tfp410: Use drm_bridge_init()
  drm/exynos: mic: Use drm_bridge_init()
  drm/i2c: tda998x: Use drm_bridge_init()
  drm/mcde: dsi: Use drm_bridge_init()
  drm/mediatek: hdmi: Use drm_bridge_init()
  drm: rcar-du: lvds: Use drm_bridge_init()
  drm: rcar-du: lvds: Don't set drm_bridge private pointer
  drm/sti: sti_vdo: Use drm_bridge_init()
  drm/komeda: Use drm_bridge interface for pipe outputs

Russell King (1):
  drm/bridge: add support for device links to bridge

 .../gpu/drm/arm/display/komeda/komeda_drv.c   | 54 ++---
 .../gpu/drm/arm/display/komeda/komeda_kms.c   | 77 --
 .../gpu/drm/arm/display/komeda/komeda_kms.h   |  2 +
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c  |  5 +-
 .../drm/bridge/analogix/analogix-anx6345.c|  5 +-
 .../drm/bridge/analogix/analogix-anx78xx.c|  8 +-
 drivers/gpu/drm/bridge/cdns-dsi.c |  4 +-
 drivers/gpu/drm/bridge/dumb-vga-dac.c |  6 +-
 drivers/gpu/drm/bridge/lvds-encoder.c |  7 +-
 .../bridge/megachips-stdp-ge-b850v3-fw.c  |  4 +-
 drivers/gpu/drm/bridge/nxp-ptn3460.c  |  4 +-
 drivers/gpu/drm/bridge/panel.c|  7 +-
 drivers/gpu/drm/bridge/parade-ps8622.c|  3 +-
 drivers/gpu/drm/bridge/sii902x.c  |  5 +-
 drivers/gpu/drm/bridge/sii9234.c  |  3 +-
 drivers/gpu/drm/bridge/sil-sii8620.c  |  3 +-
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c |  7 +-
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c |  7 +-
 drivers/gpu/drm/bridge/tc358764.c |  4 +-
 drivers/gpu/drm/bridge/tc358767.c |  3 +-
 drivers/gpu/drm/bridge/thc63lvd1024.c |  7 +-
 drivers/gpu/drm/bridge/ti-sn65dsi86.c |  5 +-
 drivers/gpu/drm/bridge/ti-tfp410.c|  5 +-
 drivers/gpu/drm/drm_bridge.c  | 78 +++
 drivers/gpu/drm/exynos/exynos_drm_mic.c   |  8 +-
 drivers/gpu/drm/i2c/tda998x_drv.c |  6 +-
 drivers/gpu/drm/mcde/mcde_dsi.c   |  3 +-
 drivers/gpu/drm/mediatek/mtk_hdmi.c   |  4 +-
 drivers/gpu/drm/rcar-du/rcar_lvds.c   |  5 +-
 drivers/gpu/drm/sti/sti_dvo.c |  4 +-
 include/drm/drm_bridge.h  |  8 ++
 31 files changed, 217 insertions(+), 134 deletions(-)

-- 
2.23.0

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

[PATCH 30/30] drm/komeda: Use drm_bridge interface for pipe outputs

2019-11-26 Thread Mihail Atanassov
To support more transmitters, we need to allow non-component framework
bridges to be attached to a dummy drm_encoder in our driver.

A/B tested for equivalence against tda998x, and also tested ti_tfp410 as
an alternate transmitter.

Signed-off-by: Mihail Atanassov 
---
 .../gpu/drm/arm/display/komeda/komeda_drv.c   | 54 ++---
 .../gpu/drm/arm/display/komeda/komeda_kms.c   | 77 +--
 .../gpu/drm/arm/display/komeda/komeda_kms.h   |  2 +
 3 files changed, 100 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c 
b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c
index d6cc5d33..2870123bef37 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c
@@ -6,10 +6,10 @@
  */
 #include 
 #include 
+#include 
 #include 
-#include 
 #include 
-#include 
+#include 
 #include "komeda_dev.h"
 #include "komeda_kms.h"
 
@@ -72,35 +72,29 @@ static int komeda_bind(struct device *dev)
return err;
 }
 
-static const struct component_master_ops komeda_master_ops = {
-   .bind   = komeda_bind,
-   .unbind = komeda_unbind,
-};
-
-static int compare_of(struct device *dev, void *data)
-{
-   return dev->of_node == data;
-}
-
-static void komeda_add_slave(struct device *master,
-struct component_match **match,
-struct device_node *np,
-u32 port, u32 endpoint)
+static int komeda_add_slave(struct device_node *np, u32 port, u32 endpoint)
 {
struct device_node *remote;
+   struct drm_bridge *bridge;
+   int ret = 0;
 
remote = of_graph_get_remote_node(np, port, endpoint);
-   if (remote) {
-   drm_of_component_match_add(master, match, compare_of, remote);
-   of_node_put(remote);
-   }
+   if (!remote)
+   return 0;
+
+   bridge = of_drm_find_bridge(remote);
+   if (!bridge)
+   ret = -EPROBE_DEFER;
+
+   of_node_put(remote);
+   return ret;
 }
 
 static int komeda_platform_probe(struct platform_device *pdev)
 {
struct device *dev = &pdev->dev;
-   struct component_match *match = NULL;
struct device_node *child;
+   int ret;
 
if (!dev->of_node)
return -ENODEV;
@@ -109,17 +103,25 @@ static int komeda_platform_probe(struct platform_device 
*pdev)
if (of_node_cmp(child->name, "pipeline") != 0)
continue;
 
-   /* add connector */
-   komeda_add_slave(dev, &match, child, KOMEDA_OF_PORT_OUTPUT, 0);
-   komeda_add_slave(dev, &match, child, KOMEDA_OF_PORT_OUTPUT, 1);
+   /* attach any remote devices if present */
+   ret = komeda_add_slave(child, KOMEDA_OF_PORT_OUTPUT, 0);
+   if (ret) {
+   of_node_put(child);
+   return ret;
+   }
+   ret = komeda_add_slave(child, KOMEDA_OF_PORT_OUTPUT, 1);
+   if (ret) {
+   of_node_put(child);
+   return ret;
+   }
}
 
-   return component_master_add_with_match(dev, &komeda_master_ops, match);
+   return komeda_bind(dev);
 }
 
 static int komeda_platform_remove(struct platform_device *pdev)
 {
-   component_master_del(&pdev->dev, &komeda_master_ops);
+   komeda_unbind(&pdev->dev);
return 0;
 }
 
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c 
b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
index e30a5b43caa9..2fc6cd9956fd 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
@@ -4,8 +4,8 @@
  * Author: James.Qian.Wang 
  *
  */
-#include 
 #include 
+#include 
 
 #include 
 #include 
@@ -14,6 +14,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 
@@ -257,6 +260,69 @@ static void komeda_kms_mode_config_init(struct 
komeda_kms_dev *kms,
config->helper_private = &komeda_mode_config_helpers;
 }
 
+static void komeda_encoder_destroy(struct drm_encoder *encoder)
+{
+   drm_encoder_cleanup(encoder);
+}
+
+static const struct drm_encoder_funcs komeda_dummy_enc_funcs = {
+   .destroy = komeda_encoder_destroy,
+};
+
+static int komeda_encoder_attach_bridge(struct komeda_dev *mdev,
+   struct komeda_kms_dev *kms,
+   struct drm_encoder *encoder,
+   struct device_node *np)
+{
+   struct device_node *remote;
+   struct drm_bridge *bridge;
+   u32 crtcs = 0;
+   int ret = 0;
+
+   remote = of_graph_get_remote_node(np, KOMEDA_OF_PORT_OUTPUT, 0);
+   if (!remote)
+   return 0;
+
+   bridge = of_drm_find_bridge_devlink(&kms->base, remote);
+   if (!bridge) {
+   ret = -EINVAL;
+ 

Re: [RFC 02/13] drm/i915/svm: Define SVM UAPI

2019-11-26 Thread Joonas Lahtinen
Quoting Niranjana Vishwanathapura (2019-11-22 22:57:23)
> Define UAPI for Shared Virtual Memory (SVM) fucntionality including
> SVM capability and configurability.
> When there is no GPU page fault support available, add ioctls
> to explicitly bind and migrate virtual address ranges.
> 
> Cc: Joonas Lahtinen 
> Cc: Jon Bloomfield 
> Cc: Daniel Vetter 
> Cc: Sudeep Dutt 
> Signed-off-by: Niranjana Vishwanathapura 
> Signed-off-by: Venkata Sandeep Dhanalakota 

Having this as a separate commit ahead of the functionality breaks
bisecting.

The uAPI should be exposed in similar sized chunks as it's implemented.
If it has to go in as single patch, that should be after all the
plumbing is already in place.

That also gives a clear indication to anybody backporting that you
need to backport until the uAPI patch.

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

[PATCH 3/7] drm/udl: Remove unused encoder and CRTC code

2019-11-26 Thread Thomas Zimmermann
The removed functionality is provided by simple-pipe helpers.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/udl/Makefile  |   2 +-
 drivers/gpu/drm/udl/udl_drv.h |   3 -
 drivers/gpu/drm/udl/udl_encoder.c |  70 ---
 drivers/gpu/drm/udl/udl_modeset.c | 138 --
 4 files changed, 1 insertion(+), 212 deletions(-)
 delete mode 100644 drivers/gpu/drm/udl/udl_encoder.c

diff --git a/drivers/gpu/drm/udl/Makefile b/drivers/gpu/drm/udl/Makefile
index 9c42820ae33d..177ce74f4cf4 100644
--- a/drivers/gpu/drm/udl/Makefile
+++ b/drivers/gpu/drm/udl/Makefile
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
-udl-y := udl_drv.o udl_modeset.o udl_connector.o udl_encoder.o udl_main.o 
udl_fb.o udl_transfer.o udl_gem.o
+udl-y := udl_drv.o udl_modeset.o udl_connector.o udl_main.o udl_fb.o 
udl_transfer.o udl_gem.o
 
 obj-$(CONFIG_DRM_UDL) := udl.o
diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index 23346bdc74bc..77b57d6abd23 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -19,7 +19,6 @@
 #include 
 #include 
 
-struct drm_encoder;
 struct drm_mode_create_dumb;
 
 #define DRIVER_NAME"udl"
@@ -82,8 +81,6 @@ int udl_modeset_init(struct drm_device *dev);
 void udl_modeset_cleanup(struct drm_device *dev);
 struct drm_connector *udl_connector_init(struct drm_device *dev);
 
-struct drm_encoder *udl_encoder_init(struct drm_device *dev);
-
 struct urb *udl_get_urb(struct drm_device *dev);
 
 int udl_submit_urb(struct drm_device *dev, struct urb *urb, size_t len);
diff --git a/drivers/gpu/drm/udl/udl_encoder.c 
b/drivers/gpu/drm/udl/udl_encoder.c
deleted file mode 100644
index 203f041e737c..
--- a/drivers/gpu/drm/udl/udl_encoder.c
+++ /dev/null
@@ -1,70 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (C) 2012 Red Hat
- * based in parts on udlfb.c:
- * Copyright (C) 2009 Roberto De Ioris 
- * Copyright (C) 2009 Jaya Kumar 
- * Copyright (C) 2009 Bernie Thompson 
- */
-
-#include 
-#include 
-
-#include "udl_drv.h"
-
-/* dummy encoder */
-static void udl_enc_destroy(struct drm_encoder *encoder)
-{
-   drm_encoder_cleanup(encoder);
-   kfree(encoder);
-}
-
-static void udl_encoder_disable(struct drm_encoder *encoder)
-{
-}
-
-static void udl_encoder_prepare(struct drm_encoder *encoder)
-{
-}
-
-static void udl_encoder_commit(struct drm_encoder *encoder)
-{
-}
-
-static void udl_encoder_mode_set(struct drm_encoder *encoder,
-struct drm_display_mode *mode,
-struct drm_display_mode *adjusted_mode)
-{
-}
-
-static void
-udl_encoder_dpms(struct drm_encoder *encoder, int mode)
-{
-}
-
-static const struct drm_encoder_helper_funcs udl_helper_funcs = {
-   .dpms = udl_encoder_dpms,
-   .prepare = udl_encoder_prepare,
-   .mode_set = udl_encoder_mode_set,
-   .commit = udl_encoder_commit,
-   .disable = udl_encoder_disable,
-};
-
-static const struct drm_encoder_funcs udl_enc_funcs = {
-   .destroy = udl_enc_destroy,
-};
-
-struct drm_encoder *udl_encoder_init(struct drm_device *dev)
-{
-   struct drm_encoder *encoder;
-
-   encoder = kzalloc(sizeof(struct drm_encoder), GFP_KERNEL);
-   if (!encoder)
-   return NULL;
-
-   drm_encoder_init(dev, encoder, &udl_enc_funcs, DRM_MODE_ENCODER_TMDS,
-NULL);
-   drm_encoder_helper_add(encoder, &udl_helper_funcs);
-   encoder->possible_crtcs = 1;
-   return encoder;
-}
diff --git a/drivers/gpu/drm/udl/udl_modeset.c 
b/drivers/gpu/drm/udl/udl_modeset.c
index c8bd438de6e9..72884cbda131 100644
--- a/drivers/gpu/drm/udl/udl_modeset.c
+++ b/drivers/gpu/drm/udl/udl_modeset.c
@@ -281,144 +281,6 @@ static void udl_crtc_dpms(struct drm_crtc *crtc, int mode)
 
 }
 
-#if 0
-static int
-udl_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb,
-  int x, int y, enum mode_set_atomic state)
-{
-   return 0;
-}
-
-static int
-udl_pipe_set_base(struct drm_crtc *crtc, int x, int y,
-   struct drm_framebuffer *old_fb)
-{
-   return 0;
-}
-#endif
-
-static int udl_crtc_mode_set(struct drm_crtc *crtc,
-  struct drm_display_mode *mode,
-  struct drm_display_mode *adjusted_mode,
-  int x, int y,
-  struct drm_framebuffer *old_fb)
-
-{
-   struct drm_device *dev = crtc->dev;
-   struct drm_framebuffer *fb = crtc->primary->fb;
-   struct udl_device *udl = dev->dev_private;
-   char *buf;
-   char *wrptr;
-   int color_depth = 0;
-
-   udl->crtc = crtc;
-
-   buf = (char *)udl->mode_buf;
-
-   /* for now we just clip 24 -> 16 - if we fix that fix this */
-   /*if  (crtc->fb->bits_per_pixel != 16)
- color_depth = 1; */
-
-   /* This first section has to do with setting the base addre

[PATCH 0/7] drm/udl: Convert to simple-pipe helpers and clean up

2019-11-26 Thread Thomas Zimmermann
With only a single display pipeline and primary plane, udl is perfect
for simple-pipe helpers. Patches 1 to 3 do the convertion. This enables
atomic modesetting for udl devices.

Patches 4 to 7 clean up handling of color depth and framebuffers. With
universal planes that come with simple pipe, display updates can be
implemented with DRM's damage handlers. The primary plane's formats
array allows to export the correct preferred color depth. The original
value was choosen for maximum compatibility, but did not represent the
device's capability.

The patchset has been tested by running the fb console, X11 and Weston
on a DisplayLink adapter.

Thomas Zimmermann (7):
  drm/udl: Init connector before encoder and CRTC
  drm/udl: Convert to struct drm_simple_display_pipe
  drm/udl: Remove unused encoder and CRTC code
  drm/udl: Set preferred color depth to 16 bpp
  drm/udl: Convert to drm_atomic_helper_dirtyfb()
  drm/udl: Remove struct udl_device.active_fb_16
  drm/udl: Move udl_handle_damage() into udl_modeset.c

 drivers/gpu/drm/udl/Makefile|   2 +-
 drivers/gpu/drm/udl/udl_connector.c |  19 +-
 drivers/gpu/drm/udl/udl_drv.c   |  11 +-
 drivers/gpu/drm/udl/udl_drv.h   |  19 +-
 drivers/gpu/drm/udl/udl_encoder.c   |  70 ---
 drivers/gpu/drm/udl/udl_fb.c| 216 --
 drivers/gpu/drm/udl/udl_main.c  |   3 -
 drivers/gpu/drm/udl/udl_modeset.c   | 276 +---
 8 files changed, 187 insertions(+), 429 deletions(-)
 delete mode 100644 drivers/gpu/drm/udl/udl_encoder.c
 delete mode 100644 drivers/gpu/drm/udl/udl_fb.c

--
2.23.0

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

[PATCH 4/7] drm/udl: Set preferred color depth to 16 bpp

2019-11-26 Thread Thomas Zimmermann
The current default color depth of 24 bpp is not even supported by
the driver. Being the native format for communicating with the adapter,
16 bpp is the correct choice.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/udl/udl_drv.c | 2 +-
 drivers/gpu/drm/udl/udl_modeset.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index b3fa6bf41acc..e6c1cd77d4d4 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -105,7 +105,7 @@ static int udl_usb_probe(struct usb_interface *interface,
 
DRM_INFO("Initialized udl on minor %d\n", udl->drm.primary->index);
 
-   r = drm_fbdev_generic_setup(&udl->drm, 16);
+   r = drm_fbdev_generic_setup(&udl->drm, 0);
if (r)
goto err_drm_dev_unregister;
 
diff --git a/drivers/gpu/drm/udl/udl_modeset.c 
b/drivers/gpu/drm/udl/udl_modeset.c
index 72884cbda131..1b5a46a91cb4 100644
--- a/drivers/gpu/drm/udl/udl_modeset.c
+++ b/drivers/gpu/drm/udl/udl_modeset.c
@@ -412,7 +412,7 @@ int udl_modeset_init(struct drm_device *dev)
dev->mode_config.max_height = 2048;
 
dev->mode_config.prefer_shadow = 0;
-   dev->mode_config.preferred_depth = 24;
+   dev->mode_config.preferred_depth = 16;
 
dev->mode_config.funcs = &udl_mode_funcs;
 
-- 
2.23.0

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

[PATCH 2/7] drm/udl: Convert to struct drm_simple_display_pipe

2019-11-26 Thread Thomas Zimmermann
Udl has a single display pipeline with aprimary plane; perfect for
simple-pipe helpers. Convert it over. The old encoder and CRTC code
becomes unused and obsolete.

Exported formats for the primary plane are RGB565 and XRGB, with
the latter being emulated. The 16-bit format is the default and what
is used when communicating with the device.

This patch enables atomic modesetting for udl devices.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/udl/udl_connector.c |  12 +--
 drivers/gpu/drm/udl/udl_drv.c   |   9 +-
 drivers/gpu/drm/udl/udl_drv.h   |   4 +-
 drivers/gpu/drm/udl/udl_modeset.c   | 142 
 4 files changed, 136 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_connector.c 
b/drivers/gpu/drm/udl/udl_connector.c
index 68e113ae44f7..47ab8d150f1a 100644
--- a/drivers/gpu/drm/udl/udl_connector.c
+++ b/drivers/gpu/drm/udl/udl_connector.c
@@ -7,6 +7,7 @@
  * Copyright (C) 2009 Bernie Thompson 
  */
 
+#include 
 #include 
 #include 
 
@@ -90,13 +91,6 @@ udl_detect(struct drm_connector *connector, bool force)
return connector_status_connected;
 }
 
-static int udl_connector_set_property(struct drm_connector *connector,
- struct drm_property *property,
- uint64_t val)
-{
-   return 0;
-}
-
 static void udl_connector_destroy(struct drm_connector *connector)
 {
struct udl_drm_connector *udl_connector =
@@ -117,10 +111,12 @@ static const struct drm_connector_helper_funcs 
udl_connector_helper_funcs = {
 
 static const struct drm_connector_funcs udl_connector_funcs = {
.dpms = drm_helper_connector_dpms,
+   .reset = drm_atomic_helper_connector_reset,
.detect = udl_detect,
.fill_modes = drm_helper_probe_single_connector_modes,
.destroy = udl_connector_destroy,
-   .set_property = udl_connector_set_property,
+   .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
+   .atomic_destroy_state   = drm_atomic_helper_connector_destroy_state,
 };
 
 struct drm_connector *udl_connector_init(struct drm_device *dev)
diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index d5783fa32c5b..b3fa6bf41acc 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -21,17 +21,14 @@ static int udl_usb_suspend(struct usb_interface *interface,
 {
struct drm_device *dev = usb_get_intfdata(interface);
 
-   drm_kms_helper_poll_disable(dev);
-   return 0;
+   return drm_mode_config_helper_suspend(dev);
 }
 
 static int udl_usb_resume(struct usb_interface *interface)
 {
struct drm_device *dev = usb_get_intfdata(interface);
 
-   drm_kms_helper_poll_enable(dev);
-   udl_modeset_restore(dev);
-   return 0;
+   return drm_mode_config_helper_resume(dev);
 }
 
 DEFINE_DRM_GEM_FOPS(udl_driver_fops);
@@ -45,7 +42,7 @@ static void udl_driver_release(struct drm_device *dev)
 }
 
 static struct drm_driver driver = {
-   .driver_features = DRIVER_MODESET | DRIVER_GEM,
+   .driver_features = DRIVER_ATOMIC | DRIVER_GEM | DRIVER_MODESET,
.release = udl_driver_release,
 
/* gem hooks */
diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index 8dc04717abac..23346bdc74bc 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct drm_encoder;
 struct drm_mode_create_dumb;
@@ -53,6 +54,8 @@ struct udl_device {
struct usb_device *udev;
struct drm_crtc *crtc;
 
+   struct drm_simple_display_pipe display_pipe;
+
/* active framebuffer on the 16-bit channel */
const struct drm_framebuffer *active_fb_16;
spinlock_t active_fb_16_lock;
@@ -76,7 +79,6 @@ struct udl_device {
 
 /* modeset */
 int udl_modeset_init(struct drm_device *dev);
-void udl_modeset_restore(struct drm_device *dev);
 void udl_modeset_cleanup(struct drm_device *dev);
 struct drm_connector *udl_connector_init(struct drm_device *dev);
 
diff --git a/drivers/gpu/drm/udl/udl_modeset.c 
b/drivers/gpu/drm/udl/udl_modeset.c
index 5bb1522036c7..c8bd438de6e9 100644
--- a/drivers/gpu/drm/udl/udl_modeset.c
+++ b/drivers/gpu/drm/udl/udl_modeset.c
@@ -9,12 +9,16 @@
 
  */
 
+#include 
 #include 
+#include 
 #include 
 #include 
 
 #include "udl_drv.h"
 
+#define UDL_COLOR_DEPTH_16BPP  0
+
 /*
  * All DisplayLink bulk operations start with 0xAF, followed by specific code
  * All operations are written to buffers which then later get sent to device
@@ -415,14 +419,126 @@ static int udl_crtc_init(struct drm_device *dev)
return 0;
 }
 
+/*
+ * Simple display pipeline
+ */
+
+static const uint32_t udl_simple_display_pipe_formats[] = {
+   DRM_FORMAT_RGB565,
+   DRM_FORMAT_XRGB,
+};
+
+static enum drm_mode_status
+udl_simple_display_pipe_mode_valid(struct drm_simple_display_pipe *pipe,
+  

[PATCH 6/7] drm/udl: Remove struct udl_device.active_fb_16

2019-11-26 Thread Thomas Zimmermann
The udl driver stores the currently active framebuffer to know from
where to accept damage updates.

With the conversion to plane-state damage handling, this is not necessary
any longer. The currently active framebuffer and damaged area are always
stored in the plane state.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/udl/udl_drv.h | 4 
 drivers/gpu/drm/udl/udl_fb.c  | 7 ---
 drivers/gpu/drm/udl/udl_main.c| 3 ---
 drivers/gpu/drm/udl/udl_modeset.c | 9 -
 4 files changed, 23 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index c6fd5c08f5fc..e540f8e64aa1 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -55,10 +55,6 @@ struct udl_device {
 
struct drm_simple_display_pipe display_pipe;
 
-   /* active framebuffer on the 16-bit channel */
-   const struct drm_framebuffer *active_fb_16;
-   spinlock_t active_fb_16_lock;
-
struct mutex gem_lock;
 
int sku_pixel_limit;
diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index ed01ebaaf468..3d8cf674dfa5 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -76,13 +76,6 @@ int udl_handle_damage(struct drm_framebuffer *fb, int x, int 
y,
 
log_bpp = __ffs(fb->format->cpp[0]);
 
-   spin_lock(&udl->active_fb_16_lock);
-   if (udl->active_fb_16 != fb) {
-   spin_unlock(&udl->active_fb_16_lock);
-   return 0;
-   }
-   spin_unlock(&udl->active_fb_16_lock);
-
vaddr = drm_gem_shmem_vmap(fb->obj[0]);
if (IS_ERR(vaddr)) {
DRM_ERROR("failed to vmap fb\n");
diff --git a/drivers/gpu/drm/udl/udl_main.c b/drivers/gpu/drm/udl/udl_main.c
index a23218fc7d8e..9b091b5b063e 100644
--- a/drivers/gpu/drm/udl/udl_main.c
+++ b/drivers/gpu/drm/udl/udl_main.c
@@ -317,9 +317,6 @@ int udl_init(struct udl_device *udl)
 
DRM_DEBUG("\n");
 
-   udl->active_fb_16 = NULL;
-   spin_lock_init(&udl->active_fb_16_lock);
-
mutex_init(&udl->gem_lock);
 
if (!udl_parse_vendor_descriptor(dev, udl->udev)) {
diff --git a/drivers/gpu/drm/udl/udl_modeset.c 
b/drivers/gpu/drm/udl/udl_modeset.c
index aade61ad097b..83e80083e0b2 100644
--- a/drivers/gpu/drm/udl/udl_modeset.c
+++ b/drivers/gpu/drm/udl/udl_modeset.c
@@ -333,9 +333,6 @@ udl_simple_display_pipe_enable(struct 
drm_simple_display_pipe *pipe,
 
wrptr = udl_dummy_render(wrptr);
 
-   spin_lock(&udl->active_fb_16_lock);
-   udl->active_fb_16 = fb;
-   spin_unlock(&udl->active_fb_16_lock);
udl->mode_buf_len = wrptr - buf;
 
udl_handle_damage(fb, 0, 0, fb->width, fb->height);
@@ -363,16 +360,10 @@ static void
 udl_simple_display_pipe_update(struct drm_simple_display_pipe *pipe,
   struct drm_plane_state *old_plane_state)
 {
-   struct drm_device *dev = pipe->crtc.dev;
-   struct udl_device *udl = dev->dev_private;
struct drm_plane_state *state = pipe->plane.state;
struct drm_framebuffer *fb = state->fb;
struct drm_rect rect;
 
-   spin_lock(&udl->active_fb_16_lock);
-   udl->active_fb_16 = fb;
-   spin_unlock(&udl->active_fb_16_lock);
-
if (!fb)
return;
 
-- 
2.23.0

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

[PATCH 5/7] drm/udl: Convert to drm_atomic_helper_dirtyfb()

2019-11-26 Thread Thomas Zimmermann
The infrastruture for atomic modesetting allows us to use the generic
code for dirty-FB and damage handling. Switch over udl and remove the
driver's implementation.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/udl/udl_drv.h |  5 ---
 drivers/gpu/drm/udl/udl_fb.c  | 67 ---
 drivers/gpu/drm/udl/udl_modeset.c | 11 +++--
 3 files changed, 8 insertions(+), 75 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index 77b57d6abd23..c6fd5c08f5fc 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -89,11 +89,6 @@ void udl_urb_completion(struct urb *urb);
 int udl_init(struct udl_device *udl);
 void udl_fini(struct drm_device *dev);
 
-struct drm_framebuffer *
-udl_fb_user_fb_create(struct drm_device *dev,
- struct drm_file *file,
- const struct drm_mode_fb_cmd2 *mode_cmd);
-
 int udl_render_hline(struct drm_device *dev, int log_bpp, struct urb **urb_ptr,
 const char *front, char **urb_buf_ptr,
 u32 byte_offset, u32 device_byte_offset, u32 byte_width,
diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index c1996ac73a1f..ed01ebaaf468 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -9,14 +9,9 @@
  */
 
 #include 
-#include 
 
-#include 
-#include 
 #include 
-#include 
 #include 
-#include 
 
 #include "udl_drv.h"
 
@@ -152,65 +147,3 @@ int udl_handle_damage(struct drm_framebuffer *fb, int x, 
int y,
drm_gem_shmem_vunmap(fb->obj[0], vaddr);
return ret;
 }
-
-static int udl_user_framebuffer_dirty(struct drm_framebuffer *fb,
- struct drm_file *file,
- unsigned flags, unsigned color,
- struct drm_clip_rect *clips,
- unsigned num_clips)
-{
-   struct udl_device *udl = fb->dev->dev_private;
-   struct dma_buf_attachment *import_attach;
-   int i;
-   int ret = 0;
-
-   drm_modeset_lock_all(fb->dev);
-
-   spin_lock(&udl->active_fb_16_lock);
-   if (udl->active_fb_16 != fb) {
-   spin_unlock(&udl->active_fb_16_lock);
-   goto unlock;
-   }
-   spin_unlock(&udl->active_fb_16_lock);
-
-   import_attach = fb->obj[0]->import_attach;
-
-   if (import_attach) {
-   ret = dma_buf_begin_cpu_access(import_attach->dmabuf,
-  DMA_FROM_DEVICE);
-   if (ret)
-   goto unlock;
-   }
-
-   for (i = 0; i < num_clips; i++) {
-   ret = udl_handle_damage(fb, clips[i].x1, clips[i].y1,
-   clips[i].x2 - clips[i].x1,
-   clips[i].y2 - clips[i].y1);
-   if (ret)
-   break;
-   }
-
-   if (import_attach)
-   ret = dma_buf_end_cpu_access(import_attach->dmabuf,
-DMA_FROM_DEVICE);
-
- unlock:
-   drm_modeset_unlock_all(fb->dev);
-
-   return ret;
-}
-
-static const struct drm_framebuffer_funcs udlfb_funcs = {
-   .destroy= drm_gem_fb_destroy,
-   .create_handle  = drm_gem_fb_create_handle,
-   .dirty  = udl_user_framebuffer_dirty,
-};
-
-struct drm_framebuffer *
-udl_fb_user_fb_create(struct drm_device *dev,
-  struct drm_file *file,
-  const struct drm_mode_fb_cmd2 *mode_cmd)
-{
-   return drm_gem_fb_create_with_funcs(dev, file, mode_cmd,
-   &udlfb_funcs);
-}
diff --git a/drivers/gpu/drm/udl/udl_modeset.c 
b/drivers/gpu/drm/udl/udl_modeset.c
index 1b5a46a91cb4..aade61ad097b 100644
--- a/drivers/gpu/drm/udl/udl_modeset.c
+++ b/drivers/gpu/drm/udl/udl_modeset.c
@@ -11,6 +11,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -364,7 +365,9 @@ udl_simple_display_pipe_update(struct 
drm_simple_display_pipe *pipe,
 {
struct drm_device *dev = pipe->crtc.dev;
struct udl_device *udl = dev->dev_private;
-   struct drm_framebuffer *fb = pipe->plane.state->fb;
+   struct drm_plane_state *state = pipe->plane.state;
+   struct drm_framebuffer *fb = state->fb;
+   struct drm_rect rect;
 
spin_lock(&udl->active_fb_16_lock);
udl->active_fb_16 = fb;
@@ -373,7 +376,9 @@ udl_simple_display_pipe_update(struct 
drm_simple_display_pipe *pipe,
if (!fb)
return;
 
-   udl_handle_damage(fb, 0, 0, fb->width, fb->height);
+   if (drm_atomic_helper_damage_merged(old_plane_state, state, &rect))
+   udl_handle_damage(fb, rect.x1, rect.y1, rect.x2 - rect.x1,
+ rect.y2 - rect.y1);
 }
 
 static const
@@ -391,7 +396,7 @@ struct drm_simple_display_pipe_funcs 
udl_simple_display_pipe_funcs = {

[PATCH 7/7] drm/udl: Move udl_handle_damage() into udl_modeset.c

2019-11-26 Thread Thomas Zimmermann
The only caller of udl_handle_damage() in the plane-update function
in udl_modeset.c. Move udl_handle_damage() there, make it static, and
remove several left-over macros.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/udl/Makefile  |   2 +-
 drivers/gpu/drm/udl/udl_drv.h |   3 -
 drivers/gpu/drm/udl/udl_fb.c  | 142 --
 drivers/gpu/drm/udl/udl_modeset.c |  88 ++
 4 files changed, 89 insertions(+), 146 deletions(-)
 delete mode 100644 drivers/gpu/drm/udl/udl_fb.c

diff --git a/drivers/gpu/drm/udl/Makefile b/drivers/gpu/drm/udl/Makefile
index 177ce74f4cf4..b50179bb4de0 100644
--- a/drivers/gpu/drm/udl/Makefile
+++ b/drivers/gpu/drm/udl/Makefile
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
-udl-y := udl_drv.o udl_modeset.o udl_connector.o udl_main.o udl_fb.o 
udl_transfer.o udl_gem.o
+udl-y := udl_drv.o udl_modeset.o udl_connector.o udl_main.o udl_transfer.o 
udl_gem.o
 
 obj-$(CONFIG_DRM_UDL) := udl.o
diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index e540f8e64aa1..ab62a6aecd06 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -93,9 +93,6 @@ int udl_render_hline(struct drm_device *dev, int log_bpp, 
struct urb **urb_ptr,
 struct drm_gem_object *udl_driver_gem_create_object(struct drm_device *dev,
size_t size);
 
-int udl_handle_damage(struct drm_framebuffer *fb, int x, int y,
- int width, int height);
-
 int udl_drop_usb(struct drm_device *dev);
 
 #define CMD_WRITE_RAW8   "\xAF\x60" /**< 8 bit raw write command. */
diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
deleted file mode 100644
index 3d8cf674dfa5..
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ /dev/null
@@ -1,142 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (C) 2012 Red Hat
- *
- * based in parts on udlfb.c:
- * Copyright (C) 2009 Roberto De Ioris 
- * Copyright (C) 2009 Jaya Kumar 
- * Copyright (C) 2009 Bernie Thompson 
- */
-
-#include 
-
-#include 
-#include 
-
-#include "udl_drv.h"
-
-#define DL_ALIGN_UP(x, a) ALIGN(x, a)
-#define DL_ALIGN_DOWN(x, a) ALIGN_DOWN(x, a)
-
-/** Read the red component (0..255) of a 32 bpp colour. */
-#define DLO_RGB_GETRED(col) (uint8_t)((col) & 0xFF)
-
-/** Read the green component (0..255) of a 32 bpp colour. */
-#define DLO_RGB_GETGRN(col) (uint8_t)(((col) >> 8) & 0xFF)
-
-/** Read the blue component (0..255) of a 32 bpp colour. */
-#define DLO_RGB_GETBLU(col) (uint8_t)(((col) >> 16) & 0xFF)
-
-/** Return red/green component of a 16 bpp colour number. */
-#define DLO_RG16(red, grn) (uint8_t)red) & 0xF8) | ((grn) >> 5)) & 0xFF)
-
-/** Return green/blue component of a 16 bpp colour number. */
-#define DLO_GB16(grn, blu) (uint8_t)(grn) & 0x1C) << 3) | ((blu) >> 3)) & 
0xFF)
-
-/** Return 8 bpp colour number from red, green and blue components. */
-#define DLO_RGB8(red, grn, blu) red) << 5) | (((grn) & 3) << 3) | ((blu) & 
7)) & 0xFF)
-
-#if 0
-static uint8_t rgb8(uint32_t col)
-{
-   uint8_t red = DLO_RGB_GETRED(col);
-   uint8_t grn = DLO_RGB_GETGRN(col);
-   uint8_t blu = DLO_RGB_GETBLU(col);
-
-   return DLO_RGB8(red, grn, blu);
-}
-
-static uint16_t rgb16(uint32_t col)
-{
-   uint8_t red = DLO_RGB_GETRED(col);
-   uint8_t grn = DLO_RGB_GETGRN(col);
-   uint8_t blu = DLO_RGB_GETBLU(col);
-
-   return (DLO_RG16(red, grn) << 8) + DLO_GB16(grn, blu);
-}
-#endif
-
-int udl_handle_damage(struct drm_framebuffer *fb, int x, int y,
- int width, int height)
-{
-   struct drm_device *dev = fb->dev;
-   struct udl_device *udl = to_udl(dev);
-   int i, ret;
-   char *cmd;
-   cycles_t start_cycles, end_cycles;
-   int bytes_sent = 0;
-   int bytes_identical = 0;
-   struct urb *urb;
-   int aligned_x;
-   int log_bpp;
-   void *vaddr;
-
-   if (WARN_ON(!is_power_of_2(fb->format->cpp[0])))
-   return -EINVAL;
-
-   log_bpp = __ffs(fb->format->cpp[0]);
-
-   vaddr = drm_gem_shmem_vmap(fb->obj[0]);
-   if (IS_ERR(vaddr)) {
-   DRM_ERROR("failed to vmap fb\n");
-   return 0;
-   }
-
-   aligned_x = DL_ALIGN_DOWN(x, sizeof(unsigned long));
-   width = DL_ALIGN_UP(width + (x-aligned_x), sizeof(unsigned long));
-   x = aligned_x;
-
-   if ((width <= 0) ||
-   (x + width > fb->width) ||
-   (y + height > fb->height)) {
-   ret = -EINVAL;
-   goto err_drm_gem_shmem_vunmap;
-   }
-
-   start_cycles = get_cycles();
-
-   urb = udl_get_urb(dev);
-   if (!urb)
-   goto out;
-   cmd = urb->transfer_buffer;
-
-   for (i = y; i < y + height ; i++) {
-   const int line_offset = fb->pitches[0] * i;
-   const int byte_offset = line_offset + (x << log_bpp);
-   const int dev_byte_offset = (fb->width

[PATCH 1/7] drm/udl: Init connector before encoder and CRTC

2019-11-26 Thread Thomas Zimmermann
To mimic simple-pipe, we initialize the connector before the rest of
the display pipeline.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/udl/udl_connector.c |  7 +++
 drivers/gpu/drm/udl/udl_drv.h   |  2 +-
 drivers/gpu/drm/udl/udl_modeset.c   | 16 ++--
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_connector.c 
b/drivers/gpu/drm/udl/udl_connector.c
index b4ae3e89a7b4..68e113ae44f7 100644
--- a/drivers/gpu/drm/udl/udl_connector.c
+++ b/drivers/gpu/drm/udl/udl_connector.c
@@ -123,14 +123,14 @@ static const struct drm_connector_funcs 
udl_connector_funcs = {
.set_property = udl_connector_set_property,
 };
 
-int udl_connector_init(struct drm_device *dev, struct drm_encoder *encoder)
+struct drm_connector *udl_connector_init(struct drm_device *dev)
 {
struct udl_drm_connector *udl_connector;
struct drm_connector *connector;
 
udl_connector = kzalloc(sizeof(struct udl_drm_connector), GFP_KERNEL);
if (!udl_connector)
-   return -ENOMEM;
+   return ERR_PTR(-ENOMEM);
 
connector = &udl_connector->connector;
drm_connector_init(dev, connector, &udl_connector_funcs,
@@ -138,9 +138,8 @@ int udl_connector_init(struct drm_device *dev, struct 
drm_encoder *encoder)
drm_connector_helper_add(connector, &udl_connector_helper_funcs);
 
drm_connector_register(connector);
-   drm_connector_attach_encoder(connector, encoder);
connector->polled = DRM_CONNECTOR_POLL_HPD |
DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT;
 
-   return 0;
+   return connector;
 }
diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index 66cbe04f832a..8dc04717abac 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -78,7 +78,7 @@ struct udl_device {
 int udl_modeset_init(struct drm_device *dev);
 void udl_modeset_restore(struct drm_device *dev);
 void udl_modeset_cleanup(struct drm_device *dev);
-int udl_connector_init(struct drm_device *dev, struct drm_encoder *encoder);
+struct drm_connector *udl_connector_init(struct drm_device *dev);
 
 struct drm_encoder *udl_encoder_init(struct drm_device *dev);
 
diff --git a/drivers/gpu/drm/udl/udl_modeset.c 
b/drivers/gpu/drm/udl/udl_modeset.c
index 91af25caed64..5bb1522036c7 100644
--- a/drivers/gpu/drm/udl/udl_modeset.c
+++ b/drivers/gpu/drm/udl/udl_modeset.c
@@ -421,7 +421,10 @@ static const struct drm_mode_config_funcs udl_mode_funcs = 
{
 
 int udl_modeset_init(struct drm_device *dev)
 {
+   struct drm_connector *connector;
struct drm_encoder *encoder;
+   int ret;
+
drm_mode_config_init(dev);
 
dev->mode_config.min_width = 640;
@@ -435,13 +438,22 @@ int udl_modeset_init(struct drm_device *dev)
 
dev->mode_config.funcs = &udl_mode_funcs;
 
+   connector = udl_connector_init(dev);
+   if (IS_ERR(connector)) {
+   ret = PTR_ERR(connector);
+   goto err_drm_mode_config_cleanup;
+   }
+
udl_crtc_init(dev);
 
encoder = udl_encoder_init(dev);
-
-   udl_connector_init(dev, encoder);
+   drm_connector_attach_encoder(connector, encoder);
 
return 0;
+
+err_drm_mode_config_cleanup:
+   drm_mode_config_cleanup(dev);
+   return ret;
 }
 
 void udl_modeset_restore(struct drm_device *dev)
-- 
2.23.0

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

Re: [Intel-gfx] [RFC 03/13] drm/i915/svm: Runtime (RT) allocator support

2019-11-26 Thread Joonas Lahtinen
Quoting Niranjan Vishwanathapura (2019-11-25 18:40:57)
> On Mon, Nov 25, 2019 at 09:59:37AM +, Chris Wilson wrote:
> >Quoting Niranjana Vishwanathapura (2019-11-22 20:57:24)
> >> Shared Virtual Memory (SVM) runtime allocator support allows
> >> binding a shared virtual address to a buffer object (BO) in the
> >> device page table through an ioctl call.
> >
> >The ioctl though is not svm specific, it is to do with "bulk residency"
> >and can be used to reduce execbuf traffic to provide virtual address
> >layout controls to e.g. Vulkan clients.
> >
> >I915_VM_BIND {
> >   uint32_t vm_id;
> >   int32_t fd; /* or -1 for anon, or buf depending on flags */
> >   uint64_t flags;
> >   uint64_t offset; /* offset info fd [page aligned] */
> >   uint64_t length; /* page aligned */
> >   uint64_t iova; /* page aligned */
> >   uint64_t extensions;
> >}; /* where page aligned is actually more I915_GTT_PAGE_ALIGNMENT */
> >
> >as I recall. I also recall it being part of a future command stream
> >interface to reduce ioctls, but that is another story.
> 
> Thanks Chris.
> I will change I915_BIND to I915_VM_BIND.

We're very much depending on GEM VM even if BOs wouldn't be used,
so this is best called I915_GEM_VM_BIND to match I915_GEM_VM_CREATE
and avoid user confusion.

> Currently, it is only addressing binding SVM system (buffer) and runtime (BOs)
> allocations. But it can be expanded for other bindings. I have 'type' field
> instead of 'fd' and 'extensions' & 'iov' can be added later if required.

We should try to have the uAPI as final as early as possible. The
change process is harder the later it is done, even for RFC :)

On the same note, I'm inclined to have I915_SVM_MIGRATE called
I915_GEM_VM_PREFAULT from the start, as I already have got some
confused questions from folks who mix it with memory pressure
initiated migration. And it's inherently racy as anybody could
race with it, so PREFAULT would give an impression of that.

And I think I915_GEM_VM_PREFAULT would be a generally applicable
function, just like I915_GEM_VM_BIND. So we should use a struct
member names that are close to I915_GEM_VM_BIND.

Better ideas for name to emphasis the nature of what is being
done? I915_GEM_VM_FAULT/I915_GEM_VM_{M,}ADVICE...

Regards, Joonas

> Is that OK?
> 
> >-Chris
> ___
> Intel-gfx mailing list
> intel-...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  1   2   >