Re: [PATCH v6 12/14] drm/mediatek: Support CRC in display driver

2024-03-31 Thread 胡俊光


Re: [PATCH 01/11] drm/mediatek: aal: drop driver owner initialization

2024-03-31 Thread 胡俊光


Re: [PATCH] drm/mediatek: Init `ddp_comp` with devm_kcalloc()

2024-03-31 Thread 胡俊光


[PATCH V2] drm/ttm: remove unused paramter

2024-03-31 Thread jesse.zhang
From: Jesse Zhang 

remove the unsed the paramter in the function
ttm_bo_bounce_temp_buffer and ttm_bo_add_move_fence.
 V2:rebase the patch on top of drm-misc-next (Christian)

Signed-off-by: Jesse Zhang 
Reviewed-by: Christian König 
---
 drivers/gpu/drm/ttm/ttm_bo.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index e059b1e1b13b..6396dece0db1 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -402,7 +402,6 @@ void ttm_bo_put(struct ttm_buffer_object *bo)
 EXPORT_SYMBOL(ttm_bo_put);
 
 static int ttm_bo_bounce_temp_buffer(struct ttm_buffer_object *bo,
-struct ttm_resource **mem,
 struct ttm_operation_ctx *ctx,
 struct ttm_place *hop)
 {
@@ -469,7 +468,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo,
if (ret != -EMULTIHOP)
break;
 
-   ret = ttm_bo_bounce_temp_buffer(bo, _mem, ctx, );
+   ret = ttm_bo_bounce_temp_buffer(bo, ctx, );
} while (!ret);
 
if (ret) {
@@ -698,7 +697,6 @@ EXPORT_SYMBOL(ttm_bo_unpin);
  */
 static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
 struct ttm_resource_manager *man,
-struct ttm_resource *mem,
 bool no_wait_gpu)
 {
struct dma_fence *fence;
@@ -787,7 +785,7 @@ static int ttm_bo_alloc_resource(struct ttm_buffer_object 
*bo,
if (ret)
continue;
 
-   ret = ttm_bo_add_move_fence(bo, man, *res, ctx->no_wait_gpu);
+   ret = ttm_bo_add_move_fence(bo, man, ctx->no_wait_gpu);
if (unlikely(ret)) {
ttm_resource_free(bo, res);
if (ret == -EBUSY)
@@ -894,7 +892,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
 bounce:
ret = ttm_bo_handle_move_mem(bo, res, false, ctx, );
if (ret == -EMULTIHOP) {
-   ret = ttm_bo_bounce_temp_buffer(bo, , ctx, );
+   ret = ttm_bo_bounce_temp_buffer(bo, ctx, );
/* try and move to final place now. */
if (!ret)
goto bounce;
-- 
2.25.1



[PATCH v5 17/18] drm/msm: drop C++ parts of a6xx.xml.h

2024-03-31 Thread Dmitry Baryshkov
As a preparation to removal of a6xx.xml.h, drop the C++ part of the
heder, it is not used by the kernel anyway.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/adreno/a6xx.xml.h | 2478 -
 1 file changed, 2478 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx.xml.h 
b/drivers/gpu/drm/msm/adreno/a6xx.xml.h
index 92e23bf2458d..8bf80df683e1 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx.xml.h
+++ b/drivers/gpu/drm/msm/adreno/a6xx.xml.h
@@ -9377,2482 +9377,4 @@ static inline uint32_t 
A6XX_CX_DBGC_CFG_DBGBUS_BYTEL_1_BYTEL15(uint32_t val)
 
 #define REG_A7XX_CX_MISC_TCM_RET_CNTL  0x0039
 
-#ifdef __cplusplus
-template constexpr inline uint16_t CMD_REGS[] = {};
-template constexpr inline uint16_t RP_BLIT_REGS[] = {};
-template<> constexpr inline uint16_t CMD_REGS[] = {
-   0xc03,
-   0xc04,
-   0xc30,
-   0xc31,
-   0xc32,
-   0xc33,
-   0xc34,
-   0xc35,
-   0xc36,
-   0xc37,
-   0xe12,
-   0xe17,
-   0xe19,
-   0x8099,
-   0x80af,
-   0x810a,
-   0x8110,
-   0x8600,
-   0x880e,
-   0x8811,
-   0x8818,
-   0x8819,
-   0x881a,
-   0x881b,
-   0x881c,
-   0x881d,
-   0x881e,
-   0x8864,
-   0x8891,
-   0x88f0,
-   0x8927,
-   0x8928,
-   0x8e01,
-   0x8e04,
-   0x8e07,
-   0x9210,
-   0x9211,
-   0x9218,
-   0x9219,
-   0x921a,
-   0x921b,
-   0x921c,
-   0x921d,
-   0x921e,
-   0x921f,
-   0x9220,
-   0x9221,
-   0x9222,
-   0x9223,
-   0x9224,
-   0x9225,
-   0x9226,
-   0x9227,
-   0x9228,
-   0x9229,
-   0x922a,
-   0x922b,
-   0x922c,
-   0x922d,
-   0x922e,
-   0x922f,
-   0x9230,
-   0x9231,
-   0x9232,
-   0x9233,
-   0x9234,
-   0x9235,
-   0x9236,
-   0x9300,
-   0x9600,
-   0x9601,
-   0x9602,
-   0x9e08,
-   0x9e09,
-   0x9e72,
-   0xa007,
-   0xa009,
-   0xa8a0,
-   0xa8a1,
-   0xa8a2,
-   0xa8a3,
-   0xa8a4,
-   0xa8a5,
-   0xa8a6,
-   0xa8a7,
-   0xa8a8,
-   0xa8a9,
-   0xa8aa,
-   0xa8ab,
-   0xa8ac,
-   0xa8ad,
-   0xa8ae,
-   0xa8af,
-   0xa9a8,
-   0xa9b0,
-   0xa9b1,
-   0xa9b2,
-   0xa9b3,
-   0xa9b4,
-   0xa9b5,
-   0xa9b6,
-   0xa9b7,
-   0xa9b8,
-   0xa9b9,
-   0xa9ba,
-   0xa9bb,
-   0xa9bc,
-   0xa9bd,
-   0xa9c2,
-   0xa9c3,
-   0xa9e2,
-   0xa9e3,
-   0xa9e6,
-   0xa9e7,
-   0xa9e8,
-   0xa9e9,
-   0xa9ea,
-   0xa9eb,
-   0xa9ec,
-   0xa9ed,
-   0xa9ee,
-   0xa9ef,
-   0xa9f0,
-   0xa9f1,
-   0xaaf2,
-   0xab1a,
-   0xab1b,
-   0xab20,
-   0xae00,
-   0xae03,
-   0xae04,
-   0xae0f,
-   0xb180,
-   0xb181,
-   0xb182,
-   0xb183,
-   0xb302,
-   0xb303,
-   0xb309,
-   0xb600,
-   0xb602,
-   0xb605,
-   0xb987,
-   0xb9d0,
-   0xbb08,
-   0xbb11,
-   0xbb20,
-   0xbb21,
-   0xbb22,
-   0xbb23,
-   0xbb24,
-   0xbb25,
-   0xbb26,
-   0xbb27,
-   0xbb28,
-   0xbb29,
-   0xbe00,
-   0xbe01,
-   0xbe04,
-};
-template<> constexpr inline uint16_t CMD_REGS[] = {
-   0xc03,
-   0xc04,
-   0xc30,
-   0xc31,
-   0xc32,
-   0xc33,
-   0xc34,
-   0xc35,
-   0xc36,
-   0xc37,
-   0xce2,
-   0xce3,
-   0xce4,
-   0xce5,
-   0xce6,
-   0xce7,
-   0xe10,
-   0xe11,
-   0xe12,
-   0xe17,
-   0xe19,
-   0x8008,
-   0x8009,
-   0x800a,
-   0x800b,
-   0x800c,
-   0x8099,
-   0x80a7,
-   0x80af,
-   0x80f4,
-   0x80f5,
-   0x80f5,
-   0x80f6,
-   0x80f6,
-   0x80f7,
-   0x80f8,
-   0x80f9,
-   0x80f9,
-   0x80fa,
-   0x80fa,
-   0x80fb,
-   0x810a,
-   0x810b,
-   0x8110,
-   0x8120,
-   0x8121,
-   0x8600,
-   0x880e,
-   0x8811,
-   0x8818,
-   0x8819,
-   0x881a,
-   0x881b,
-   0x881c,
-   0x881d,
-   0x881e,
-   0x8864,
-   0x8891,
-   0x8899,
-   0x88e5,
-   0x88f0,
-   0x8927,
-   0x8928,
-   0x8e01,
-   0x8e04,
-   0x8e06,
-   0x8e07,
-   0x8e09,
-   0x8e79,
-   0x9218,
-   0x9219,
-   0x921a,
-   0x921b,
-   0x921c,
-   0x921d,
-   0x921e,
-   0x921f,
-   0x9220,
-   0x9221,
-   0x9222,
-   0x9223,
-   0x9224,
-   0x9225,
-   0x9226,
-   0x9227,
-   0x9228,
-   0x9229,
-   0x922a,
-   0x922b,
-   0x922c,
-   0x922d,
-   0x922e,
-   0x922f,
-   0x9230,
-   0x9231,
-   0x9232,
-   0x9233,
-   0x9234,
-   

[PATCH v5 10/18] drm/msm: import gen_header.py script from Mesa

2024-03-31 Thread Dmitry Baryshkov
Import the gen_headers.py script from Mesa, commit b5414e716684
("freedreno/registers: Add license header"). This script will be used to
generate MSM register files on the fly during compilation.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/registers/gen_header.py | 961 
 1 file changed, 961 insertions(+)

diff --git a/drivers/gpu/drm/msm/registers/gen_header.py 
b/drivers/gpu/drm/msm/registers/gen_header.py
new file mode 100644
index ..9b2842d4a354
--- /dev/null
+++ b/drivers/gpu/drm/msm/registers/gen_header.py
@@ -0,0 +1,961 @@
+#!/usr/bin/python3
+#
+# Copyright © 2019-2024 Google, Inc.
+#
+# SPDX-License-Identifier: MIT
+
+import xml.parsers.expat
+import sys
+import os
+import collections
+import argparse
+import time
+import datetime
+
+class Error(Exception):
+   def __init__(self, message):
+   self.message = message
+
+class Enum(object):
+   def __init__(self, name):
+   self.name = name
+   self.values = []
+
+   def has_name(self, name):
+   for (n, value) in self.values:
+   if n == name:
+   return True
+   return False
+
+   def names(self):
+   return [n for (n, value) in self.values]
+
+   def dump(self):
+   use_hex = False
+   for (name, value) in self.values:
+   if value > 0x1000:
+   use_hex = True
+
+   print("enum %s {" % self.name)
+   for (name, value) in self.values:
+   if use_hex:
+   print("\t%s = 0x%08x," % (name, value))
+   else:
+   print("\t%s = %d," % (name, value))
+   print("};\n")
+
+   def dump_pack_struct(self):
+   pass
+
+class Field(object):
+   def __init__(self, name, low, high, shr, type, parser):
+   self.name = name
+   self.low = low
+   self.high = high
+   self.shr = shr
+   self.type = type
+
+   builtin_types = [ None, "a3xx_regid", "boolean", "uint", "hex", 
"int", "fixed", "ufixed", "float", "address", "waddress" ]
+
+   maxpos = parser.current_bitsize - 1
+
+   if low < 0 or low > maxpos:
+   raise parser.error("low attribute out of range: %d" % 
low)
+   if high < 0 or high > maxpos:
+   raise parser.error("high attribute out of range: %d" % 
high)
+   if high < low:
+   raise parser.error("low is greater than high: low=%d, 
high=%d" % (low, high))
+   if self.type == "boolean" and not low == high:
+   raise parser.error("booleans should be 1 bit fields")
+   elif self.type == "float" and not (high - low == 31 or high - 
low == 15):
+   raise parser.error("floats should be 16 or 32 bit 
fields")
+   elif not self.type in builtin_types and not self.type in 
parser.enums:
+   raise parser.error("unknown type '%s'" % self.type)
+
+   def ctype(self, var_name):
+   if self.type == None:
+   type = "uint32_t"
+   val = var_name
+   elif self.type == "boolean":
+   type = "bool"
+   val = var_name
+   elif self.type == "uint" or self.type == "hex" or self.type == 
"a3xx_regid":
+   type = "uint32_t"
+   val = var_name
+   elif self.type == "int":
+   type = "int32_t"
+   val = var_name
+   elif self.type == "fixed":
+   type = "float"
+   val = "((int32_t)(%s * %d.0))" % (var_name, 1 << 
self.radix)
+   elif self.type == "ufixed":
+   type = "float"
+   val = "((uint32_t)(%s * %d.0))" % (var_name, 1 << 
self.radix)
+   elif self.type == "float" and self.high - self.low == 31:
+   type = "float"
+   val = "fui(%s)" % var_name
+   elif self.type == "float" and self.high - self.low == 15:
+   type = "float"
+   val = "_mesa_float_to_half(%s)" % var_name
+   elif self.type in [ "address", "waddress" ]:
+   type = "uint64_t"
+   val = var_name
+   else:
+   type = "enum %s" % self.type
+   val = var_name
+
+   if self.shr > 0:
+   val = "(%s >> %d)" % (val, self.shr)
+
+   return (type, val)
+
+def tab_to(name, value):
+   tab_count = (68 - (len(name) & ~7)) // 8
+   if tab_count <= 0:
+   tab_count = 

[PATCH v5 16/18] drm/msm: drop A6xx GMU header

2024-03-31 Thread Dmitry Baryshkov
Now as the headers are generated during the build step, drop
pre-generated copies of the Adreno A6xx GMU header.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h | 422 --
 1 file changed, 422 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h 
b/drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h
deleted file mode 100644
index 9d7f93929367..
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h
+++ /dev/null
@@ -1,422 +0,0 @@
-#ifndef A6XX_GMU_XML
-#define A6XX_GMU_XML
-
-/* Autogenerated file, DO NOT EDIT manually!
-
-This file was generated by the rules-ng-ng gen_header.py tool in this git 
repository:
-http://gitlab.freedesktop.org/mesa/mesa/
-git clone https://gitlab.freedesktop.org/mesa/mesa.git
-
-The rules-ng-ng source files this header was generated from are:
-
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/adreno/a6xx_gmu.xml 
 (  11820 bytes, from Fri Jun  2 14:59:26 2023)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/freedreno_copyright.xml 
 (   1572 bytes, from Fri Jun  2 14:59:26 2023)
-- 
/home/robclark/src/mesa/mesa/src/freedreno/registers/adreno/adreno_common.xml ( 
 15434 bytes, from Fri Jun  2 14:59:26 2023)
-
-Copyright (C) 2013-2024 by the following authors:
-- Rob Clark  Rob Clark
-- Ilia Mirkin  Ilia Mirkin
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
-
-#ifdef __KERNEL__
-#include 
-#define assert(x) BUG_ON(!(x))
-#else
-#include 
-#endif
-
-#ifdef __cplusplus
-#define __struct_cast(X)
-#else
-#define __struct_cast(X) (struct X)
-#endif
-
-#define A6XX_GMU_GPU_IDLE_STATUS_BUSY_IGN_AHB  0x0080
-#define A6XX_GMU_GPU_IDLE_STATUS_CX_GX_CPU_BUSY_IGN_AHB
0x4000
-
-#define A6XX_GMU_OOB_BOOT_SLUMBER_SET_MASK 0x0040
-#define A6XX_GMU_OOB_BOOT_SLUMBER_CHECK_MASK   0x4000
-#define A6XX_GMU_OOB_BOOT_SLUMBER_CLEAR_MASK   0x4000
-#define A6XX_GMU_OOB_DCVS_SET_MASK 0x0080
-#define A6XX_GMU_OOB_DCVS_CHECK_MASK   0x8000
-#define A6XX_GMU_OOB_DCVS_CLEAR_MASK   0x8000
-#define A6XX_GMU_OOB_GPU_SET_MASK  0x0004
-#define A6XX_GMU_OOB_GPU_CHECK_MASK0x0400
-#define A6XX_GMU_OOB_GPU_CLEAR_MASK0x0400
-#define A6XX_GMU_OOB_PERFCNTR_SET_MASK 0x0002
-#define A6XX_GMU_OOB_PERFCNTR_CHECK_MASK   0x0200
-#define A6XX_GMU_OOB_PERFCNTR_CLEAR_MASK   0x0200
-
-#define A6XX_HFI_IRQ_MSGQ_MASK 0x0001
-#define A6XX_HFI_IRQ_DSGQ_MASK 0x0002
-#define A6XX_HFI_IRQ_BLOCKED_MSG_MASK  0x0004
-#define A6XX_HFI_IRQ_CM3_FAULT_MASK0x0080
-#define A6XX_HFI_IRQ_GMU_ERR_MASK__MASK
0x007f
-#define A6XX_HFI_IRQ_GMU_ERR_MASK__SHIFT   16
-static inline uint32_t A6XX_HFI_IRQ_GMU_ERR_MASK(uint32_t val)
-{
-   return ((val) << A6XX_HFI_IRQ_GMU_ERR_MASK__SHIFT) & 
A6XX_HFI_IRQ_GMU_ERR_MASK__MASK;
-}
-#define A6XX_HFI_IRQ_OOB_MASK__MASK0xff00
-#define A6XX_HFI_IRQ_OOB_MASK__SHIFT   24
-static inline uint32_t A6XX_HFI_IRQ_OOB_MASK(uint32_t val)
-{
-   return ((val) << A6XX_HFI_IRQ_OOB_MASK__SHIFT) & 
A6XX_HFI_IRQ_OOB_MASK__MASK;
-}
-
-#define A6XX_HFI_H2F_IRQ_MASK_BIT  0x0001
-
-#define REG_A6XX_GPU_GMU_GX_SPTPRAC_CLOCK_CONTROL  0x0080
-
-#define REG_A6XX_GMU_GX_SPTPRAC_POWER_CONTROL  0x0081
-
-#define REG_A6XX_GMU_CM3_ITCM_START0x0c00
-
-#define REG_A6XX_GMU_CM3_DTCM_START0x1c00
-

[PATCH v5 11/18] drm/msm: generate headers on the fly

2024-03-31 Thread Dmitry Baryshkov
Generate DRM/MSM headers on the fly during kernel build. This removes a
need to push register changes to Mesa with the following manual
synchronization step. Existing headers will be removed in the following
commits (split away to ease reviews).

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/.gitignore |  1 +
 drivers/gpu/drm/msm/Makefile   | 97 +-
 2 files changed, 77 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/msm/.gitignore b/drivers/gpu/drm/msm/.gitignore
new file mode 100644
index ..9ab870da897d
--- /dev/null
+++ b/drivers/gpu/drm/msm/.gitignore
@@ -0,0 +1 @@
+generated/
diff --git a/drivers/gpu/drm/msm/Makefile b/drivers/gpu/drm/msm/Makefile
index 26ed4f443149..c861de58286c 100644
--- a/drivers/gpu/drm/msm/Makefile
+++ b/drivers/gpu/drm/msm/Makefile
@@ -1,10 +1,11 @@
 # SPDX-License-Identifier: GPL-2.0
 ccflags-y := -I $(srctree)/$(src)
+ccflags-y += -I $(obj)/generated
 ccflags-y += -I $(srctree)/$(src)/disp/dpu1
 ccflags-$(CONFIG_DRM_MSM_DSI) += -I $(srctree)/$(src)/dsi
 ccflags-$(CONFIG_DRM_MSM_DP) += -I $(srctree)/$(src)/dp
 
-msm-y := \
+adreno-y := \
adreno/adreno_device.o \
adreno/adreno_gpu.o \
adreno/a2xx_gpu.o \
@@ -18,7 +19,11 @@ msm-y := \
adreno/a6xx_gmu.o \
adreno/a6xx_hfi.o \
 
-msm-$(CONFIG_DRM_MSM_HDMI) += \
+adreno-$(CONFIG_DEBUG_FS) += adreno/a5xx_debugfs.o \
+
+adreno-$(CONFIG_DRM_MSM_GPU_STATE) += adreno/a6xx_gpu_state.o
+
+msm-display-$(CONFIG_DRM_MSM_HDMI) += \
hdmi/hdmi.o \
hdmi/hdmi_audio.o \
hdmi/hdmi_bridge.o \
@@ -31,7 +36,7 @@ msm-$(CONFIG_DRM_MSM_HDMI) += \
hdmi/hdmi_phy_8x74.o \
hdmi/hdmi_pll_8960.o \
 
-msm-$(CONFIG_DRM_MSM_MDP4) += \
+msm-display-$(CONFIG_DRM_MSM_MDP4) += \
disp/mdp4/mdp4_crtc.o \
disp/mdp4/mdp4_dsi_encoder.o \
disp/mdp4/mdp4_dtv_encoder.o \
@@ -42,7 +47,7 @@ msm-$(CONFIG_DRM_MSM_MDP4) += \
disp/mdp4/mdp4_kms.o \
disp/mdp4/mdp4_plane.o \
 
-msm-$(CONFIG_DRM_MSM_MDP5) += \
+msm-display-$(CONFIG_DRM_MSM_MDP5) += \
disp/mdp5/mdp5_cfg.o \
disp/mdp5/mdp5_cmd_encoder.o \
disp/mdp5/mdp5_ctl.o \
@@ -55,7 +60,7 @@ msm-$(CONFIG_DRM_MSM_MDP5) += \
disp/mdp5/mdp5_plane.o \
disp/mdp5/mdp5_smp.o \
 
-msm-$(CONFIG_DRM_MSM_DPU) += \
+msm-display-$(CONFIG_DRM_MSM_DPU) += \
disp/dpu1/dpu_core_perf.o \
disp/dpu1/dpu_crtc.o \
disp/dpu1/dpu_encoder.o \
@@ -85,14 +90,16 @@ msm-$(CONFIG_DRM_MSM_DPU) += \
disp/dpu1/dpu_vbif.o \
disp/dpu1/dpu_writeback.o
 
-msm-$(CONFIG_DRM_MSM_MDSS) += \
+msm-display-$(CONFIG_DRM_MSM_MDSS) += \
msm_mdss.o \
 
-msm-y += \
+msm-display-y += \
disp/mdp_format.o \
disp/mdp_kms.o \
disp/msm_disp_snapshot.o \
disp/msm_disp_snapshot_util.o \
+
+msm-y += \
msm_atomic.o \
msm_atomic_tracepoints.o \
msm_debugfs.o \
@@ -115,12 +122,12 @@ msm-y += \
msm_submitqueue.o \
msm_gpu_tracepoints.o \
 
-msm-$(CONFIG_DEBUG_FS) += adreno/a5xx_debugfs.o \
-   dp/dp_debug.o
+msm-$(CONFIG_DRM_FBDEV_EMULATION) += msm_fbdev.o
 
-msm-$(CONFIG_DRM_MSM_GPU_STATE)+= adreno/a6xx_gpu_state.o
+msm-display-$(CONFIG_DEBUG_FS) += \
+   dp/dp_debug.o
 
-msm-$(CONFIG_DRM_MSM_DP)+= dp/dp_aux.o \
+msm-display-$(CONFIG_DRM_MSM_DP)+= dp/dp_aux.o \
dp/dp_catalog.o \
dp/dp_ctrl.o \
dp/dp_display.o \
@@ -130,21 +137,69 @@ msm-$(CONFIG_DRM_MSM_DP)+= dp/dp_aux.o \
dp/dp_audio.o \
dp/dp_utils.o
 
-msm-$(CONFIG_DRM_FBDEV_EMULATION) += msm_fbdev.o
-
-msm-$(CONFIG_DRM_MSM_HDMI_HDCP) += hdmi/hdmi_hdcp.o
+msm-display-$(CONFIG_DRM_MSM_HDMI_HDCP) += hdmi/hdmi_hdcp.o
 
-msm-$(CONFIG_DRM_MSM_DSI) += dsi/dsi.o \
+msm-display-$(CONFIG_DRM_MSM_DSI) += dsi/dsi.o \
dsi/dsi_cfg.o \
dsi/dsi_host.o \
dsi/dsi_manager.o \
dsi/phy/dsi_phy.o
 
-msm-$(CONFIG_DRM_MSM_DSI_28NM_PHY) += dsi/phy/dsi_phy_28nm.o
-msm-$(CONFIG_DRM_MSM_DSI_20NM_PHY) += dsi/phy/dsi_phy_20nm.o
-msm-$(CONFIG_DRM_MSM_DSI_28NM_8960_PHY) += dsi/phy/dsi_phy_28nm_8960.o
-msm-$(CONFIG_DRM_MSM_DSI_14NM_PHY) += dsi/phy/dsi_phy_14nm.o
-msm-$(CONFIG_DRM_MSM_DSI_10NM_PHY) += dsi/phy/dsi_phy_10nm.o
-msm-$(CONFIG_DRM_MSM_DSI_7NM_PHY) += dsi/phy/dsi_phy_7nm.o
+msm-display-$(CONFIG_DRM_MSM_DSI_28NM_PHY) += dsi/phy/dsi_phy_28nm.o
+msm-display-$(CONFIG_DRM_MSM_DSI_20NM_PHY) += dsi/phy/dsi_phy_20nm.o
+msm-display-$(CONFIG_DRM_MSM_DSI_28NM_8960_PHY) += dsi/phy/dsi_phy_28nm_8960.o
+msm-display-$(CONFIG_DRM_MSM_DSI_14NM_PHY) += dsi/phy/dsi_phy_14nm.o
+msm-display-$(CONFIG_DRM_MSM_DSI_10NM_PHY) += dsi/phy/dsi_phy_10nm.o
+msm-display-$(CONFIG_DRM_MSM_DSI_7NM_PHY) += dsi/phy/dsi_phy_7nm.o
+
+msm-y += $(adreno-y) $(msm-display-y)
 
 obj-$(CONFIG_DRM_MSM)  += msm.o
+
+quiet_cmd_headergen = GENHDR  $@
+  cmd_headergen = mkdir -p $(obj)/generated && 

[PATCH v5 03/18] drm/msm/dsi: drop mmss_cc.xml.h

2024-03-31 Thread Dmitry Baryshkov
The mmss_cc.xml.h file describes bits of the MMSS clock controller on
APQ8064 / MSM8960 platforms. They are not used by the driver and do not
belong to the DRM MSM driver. Drop the file.

Reviewed-by: Abhinav Kumar 
Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/dsi/mmss_cc.xml.h | 131 --
 1 file changed, 131 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/mmss_cc.xml.h 
b/drivers/gpu/drm/msm/dsi/mmss_cc.xml.h
deleted file mode 100644
index 7062f7164216..
--- a/drivers/gpu/drm/msm/dsi/mmss_cc.xml.h
+++ /dev/null
@@ -1,131 +0,0 @@
-#ifndef MMSS_CC_XML
-#define MMSS_CC_XML
-
-/* Autogenerated file, DO NOT EDIT manually!
-
-This file was generated by the rules-ng-ng headergen tool in this git 
repository:
-http://github.com/freedreno/envytools/
-git clone https://github.com/freedreno/envytools.git
-
-The rules-ng-ng source files this header was generated from are:
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/msm.xml 
  (944 bytes, from 2022-07-23 20:21:46)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/freedreno_copyright.xml 
  (   1572 bytes, from 2022-07-23 20:21:46)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/mdp/mdp4.xml
  (  20912 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/mdp/mdp_common.xml  
  (   2849 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/mdp/mdp5.xml
  (  37461 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/dsi/dsi.xml 
  (  18746 bytes, from 2022-04-28 17:29:36)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/dsi/dsi_phy_v2.xml  
  (   3236 bytes, from 2022-03-08 17:40:42)
-- 
/home/robclark/src/mesa/mesa/src/freedreno/registers/dsi/dsi_phy_28nm_8960.xml 
(   4935 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/dsi/dsi_phy_28nm.xml
  (   7004 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/dsi/dsi_phy_20nm.xml
  (   3712 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/dsi/dsi_phy_14nm.xml
  (   5381 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/dsi/dsi_phy_10nm.xml
  (   4499 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/dsi/dsi_phy_7nm.xml 
  (  11007 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/dsi/sfpb.xml
  (602 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/dsi/mmss_cc.xml 
  (   1686 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/hdmi/qfprom.xml 
  (600 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/hdmi/hdmi.xml   
  (  42350 bytes, from 2022-09-20 17:45:56)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/edp/edp.xml 
  (  10416 bytes, from 2022-03-08 17:40:42)
-
-Copyright (C) 2013-2022 by the following authors:
-- Rob Clark  (robclark)
-- Ilia Mirkin  (imirkin)
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-
-enum mmss_cc_clk {
-   CLK = 0,
-   PCLK = 1,
-};
-
-#define REG_MMSS_CC_AHB
0x0008
-
-static inline uint32_t __offset_CLK(enum mmss_cc_clk idx)
-{
-   switch (idx) {
-   case CLK: return 0x004c;
-   case PCLK: return 0x0130;
-   default: return INVALID_IDX(idx);
-   }
-}
-static inline uint32_t REG_MMSS_CC_CLK(enum mmss_cc_clk i0) { return 
0x + __offset_CLK(i0); }
-
-static inline uint32_t REG_MMSS_CC_CLK_CC(enum mmss_cc_clk i0) { return 
0x + __offset_CLK(i0); }
-#define 

[PATCH v5 04/18] drm/msm: move msm_gpummu.c to adreno/a2xx_gpummu.c

2024-03-31 Thread Dmitry Baryshkov
The msm_gpummu.c implementation is used only on A2xx and it is tied to
the A2xx registers. Rename the source file accordingly.

Reviewed-by: Akhil P Oommen 
Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/Makefile   |  2 +-
 drivers/gpu/drm/msm/adreno/a2xx_gpu.c  |  4 +-
 drivers/gpu/drm/msm/adreno/a2xx_gpu.h  |  4 ++
 .../drm/msm/{msm_gpummu.c => adreno/a2xx_gpummu.c} | 45 --
 drivers/gpu/drm/msm/msm_mmu.h  |  5 ---
 5 files changed, 31 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/msm/Makefile b/drivers/gpu/drm/msm/Makefile
index b21ae2880c71..26ed4f443149 100644
--- a/drivers/gpu/drm/msm/Makefile
+++ b/drivers/gpu/drm/msm/Makefile
@@ -8,6 +8,7 @@ msm-y := \
adreno/adreno_device.o \
adreno/adreno_gpu.o \
adreno/a2xx_gpu.o \
+   adreno/a2xx_gpummu.o \
adreno/a3xx_gpu.o \
adreno/a4xx_gpu.o \
adreno/a5xx_gpu.o \
@@ -113,7 +114,6 @@ msm-y += \
msm_ringbuffer.o \
msm_submitqueue.o \
msm_gpu_tracepoints.o \
-   msm_gpummu.o
 
 msm-$(CONFIG_DEBUG_FS) += adreno/a5xx_debugfs.o \
dp/dp_debug.o
diff --git a/drivers/gpu/drm/msm/adreno/a2xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a2xx_gpu.c
index 0d8133f3174b..0dc255ddf5ce 100644
--- a/drivers/gpu/drm/msm/adreno/a2xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a2xx_gpu.c
@@ -113,7 +113,7 @@ static int a2xx_hw_init(struct msm_gpu *gpu)
uint32_t *ptr, len;
int i, ret;
 
-   msm_gpummu_params(gpu->aspace->mmu, _base, _error);
+   a2xx_gpummu_params(gpu->aspace->mmu, _base, _error);
 
DBG("%s", gpu->name);
 
@@ -469,7 +469,7 @@ static struct msm_gpu_state *a2xx_gpu_state_get(struct 
msm_gpu *gpu)
 static struct msm_gem_address_space *
 a2xx_create_address_space(struct msm_gpu *gpu, struct platform_device *pdev)
 {
-   struct msm_mmu *mmu = msm_gpummu_new(>dev, gpu);
+   struct msm_mmu *mmu = a2xx_gpummu_new(>dev, gpu);
struct msm_gem_address_space *aspace;
 
aspace = msm_gem_address_space_create(mmu, "gpu", SZ_16M,
diff --git a/drivers/gpu/drm/msm/adreno/a2xx_gpu.h 
b/drivers/gpu/drm/msm/adreno/a2xx_gpu.h
index 161a075f94af..53702f19990f 100644
--- a/drivers/gpu/drm/msm/adreno/a2xx_gpu.h
+++ b/drivers/gpu/drm/msm/adreno/a2xx_gpu.h
@@ -19,4 +19,8 @@ struct a2xx_gpu {
 };
 #define to_a2xx_gpu(x) container_of(x, struct a2xx_gpu, base)
 
+struct msm_mmu *a2xx_gpummu_new(struct device *dev, struct msm_gpu *gpu);
+void a2xx_gpummu_params(struct msm_mmu *mmu, dma_addr_t *pt_base,
+   dma_addr_t *tran_error);
+
 #endif /* __A2XX_GPU_H__ */
diff --git a/drivers/gpu/drm/msm/msm_gpummu.c 
b/drivers/gpu/drm/msm/adreno/a2xx_gpummu.c
similarity index 67%
rename from drivers/gpu/drm/msm/msm_gpummu.c
rename to drivers/gpu/drm/msm/adreno/a2xx_gpummu.c
index f7d1945e0c9f..39641551eeb6 100644
--- a/drivers/gpu/drm/msm/msm_gpummu.c
+++ b/drivers/gpu/drm/msm/adreno/a2xx_gpummu.c
@@ -5,30 +5,33 @@
 
 #include "msm_drv.h"
 #include "msm_mmu.h"
-#include "adreno/adreno_gpu.h"
-#include "adreno/a2xx.xml.h"
 
-struct msm_gpummu {
+#include "adreno_gpu.h"
+#include "a2xx_gpu.h"
+
+#include "a2xx.xml.h"
+
+struct a2xx_gpummu {
struct msm_mmu base;
struct msm_gpu *gpu;
dma_addr_t pt_base;
uint32_t *table;
 };
-#define to_msm_gpummu(x) container_of(x, struct msm_gpummu, base)
+#define to_a2xx_gpummu(x) container_of(x, struct a2xx_gpummu, base)
 
 #define GPUMMU_VA_START SZ_16M
 #define GPUMMU_VA_RANGE (0xfff * SZ_64K)
 #define GPUMMU_PAGE_SIZE SZ_4K
 #define TABLE_SIZE (sizeof(uint32_t) * GPUMMU_VA_RANGE / GPUMMU_PAGE_SIZE)
 
-static void msm_gpummu_detach(struct msm_mmu *mmu)
+static void a2xx_gpummu_detach(struct msm_mmu *mmu)
 {
 }
 
-static int msm_gpummu_map(struct msm_mmu *mmu, uint64_t iova,
+static int a2xx_gpummu_map(struct msm_mmu *mmu, uint64_t iova,
struct sg_table *sgt, size_t len, int prot)
 {
-   struct msm_gpummu *gpummu = to_msm_gpummu(mmu);
+   struct a2xx_gpummu *gpummu = to_a2xx_gpummu(mmu);
unsigned idx = (iova - GPUMMU_VA_START) / GPUMMU_PAGE_SIZE;
struct sg_dma_page_iter dma_iter;
unsigned prot_bits = 0;
@@ -53,9 +56,9 @@ static int msm_gpummu_map(struct msm_mmu *mmu, uint64_t iova,
return 0;
 }
 
-static int msm_gpummu_unmap(struct msm_mmu *mmu, uint64_t iova, size_t len)
+static int a2xx_gpummu_unmap(struct msm_mmu *mmu, uint64_t iova, size_t len)
 {
-   struct msm_gpummu *gpummu = to_msm_gpummu(mmu);
+   struct a2xx_gpummu *gpummu = to_a2xx_gpummu(mmu);
unsigned idx = (iova - GPUMMU_VA_START) / GPUMMU_PAGE_SIZE;
unsigned i;
 
@@ -68,13 +71,13 @@ static int msm_gpummu_unmap(struct msm_mmu *mmu, uint64_t 
iova, size_t len)
return 0;
 }
 
-static void msm_gpummu_resume_translation(struct msm_mmu *mmu)
+static void a2xx_gpummu_resume_translation(struct msm_mmu *mmu)
 {
 }
 
-static void 

[PATCH v5 05/18] drm/msm: remove dependencies from core onto adreno headers

2024-03-31 Thread Dmitry Baryshkov
Two core driver files include headers from Adreno subdir, which also
brings dependency on the Adreno register headers. Rework those includes
to remove unnecessary dependency.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/msm_drv.c | 3 ++-
 drivers/gpu/drm/msm/msm_gpu.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 97790faffd23..9c33f4e3f822 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -17,8 +17,9 @@
 
 #include "msm_drv.h"
 #include "msm_debugfs.h"
+#include "msm_gem.h"
+#include "msm_gpu.h"
 #include "msm_kms.h"
-#include "adreno/adreno_gpu.h"
 
 /*
  * MSM driver version:
diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index 655002b21b0d..cd185b9636d2 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -11,7 +11,7 @@
 #include "msm_mmu.h"
 #include "msm_fence.h"
 #include "msm_gpu_trace.h"
-#include "adreno/adreno_gpu.h"
+//#include "adreno/adreno_gpu.h"
 
 #include 
 #include 

-- 
2.39.2



[PATCH v5 02/18] drm/msm/hdmi: drop qfprom.xml.h

2024-03-31 Thread Dmitry Baryshkov
The qfprom.xml.h contains definitions for the nvmem code. They are not
used in the existing code. Also if we were to use them later, we should
have used nvmem cell API instead of using these defs. Drop the file.

Reviewed-by: Abhinav Kumar 
Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/hdmi/qfprom.xml.h | 61 ---
 1 file changed, 61 deletions(-)

diff --git a/drivers/gpu/drm/msm/hdmi/qfprom.xml.h 
b/drivers/gpu/drm/msm/hdmi/qfprom.xml.h
deleted file mode 100644
index 498801526695..
--- a/drivers/gpu/drm/msm/hdmi/qfprom.xml.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef QFPROM_XML
-#define QFPROM_XML
-
-/* Autogenerated file, DO NOT EDIT manually!
-
-This file was generated by the rules-ng-ng headergen tool in this git 
repository:
-http://github.com/freedreno/envytools/
-git clone https://github.com/freedreno/envytools.git
-
-The rules-ng-ng source files this header was generated from are:
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/msm.xml 
  (944 bytes, from 2022-07-23 20:21:46)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/freedreno_copyright.xml 
  (   1572 bytes, from 2022-07-23 20:21:46)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/mdp/mdp4.xml
  (  20912 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/mdp/mdp_common.xml  
  (   2849 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/mdp/mdp5.xml
  (  37461 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/dsi/dsi.xml 
  (  18746 bytes, from 2022-04-28 17:29:36)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/dsi/dsi_phy_v2.xml  
  (   3236 bytes, from 2022-03-08 17:40:42)
-- 
/home/robclark/src/mesa/mesa/src/freedreno/registers/dsi/dsi_phy_28nm_8960.xml 
(   4935 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/dsi/dsi_phy_28nm.xml
  (   7004 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/dsi/dsi_phy_20nm.xml
  (   3712 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/dsi/dsi_phy_14nm.xml
  (   5381 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/dsi/dsi_phy_10nm.xml
  (   4499 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/dsi/dsi_phy_7nm.xml 
  (  11007 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/dsi/sfpb.xml
  (602 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/dsi/mmss_cc.xml 
  (   1686 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/hdmi/qfprom.xml 
  (600 bytes, from 2022-03-08 17:40:42)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/hdmi/hdmi.xml   
  (  42350 bytes, from 2022-09-20 17:45:56)
-- /home/robclark/src/mesa/mesa/src/freedreno/registers/edp/edp.xml 
  (  10416 bytes, from 2022-03-08 17:40:42)
-
-Copyright (C) 2013-2022 by the following authors:
-- Rob Clark  (robclark)
-- Ilia Mirkin  (imirkin)
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-
-#define REG_QFPROM_CONFIG_ROW0_LSB 0x0238
-#define QFPROM_CONFIG_ROW0_LSB_HDMI_DISABLE0x0020
-#define QFPROM_CONFIG_ROW0_LSB_HDCP_DISABLE0x0040
-
-
-#endif /* QFPROM_XML */

-- 
2.39.2



[PATCH v5 01/18] drm/msm/mdp5: add writeback block bases

2024-03-31 Thread Dmitry Baryshkov
In order to stop patching the mdp5 headers, import definitions for the
writeback blocks. This part is extracted from the old Rob's patch.

Co-developed-by: Rob Clark 
Signed-off-by: Rob Clark 
Reviewed-by: Abhinav Kumar 
Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.h | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.h 
b/drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.h
index 26c5d8b4ab46..4b988e69fbfc 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.h
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.h
@@ -69,6 +69,16 @@ struct mdp5_mdp_block {
uint32_t caps;  /* MDP capabilities: MDP_CAP_xxx bits */
 };
 
+struct mdp5_wb_instance {
+   int id;
+   int lm;
+};
+
+struct mdp5_wb_block {
+   MDP5_SUB_BLOCK_DEFINITION;
+   struct mdp5_wb_instance instances[MAX_BASES];
+};
+
 #define MDP5_INTF_NUM_MAX  5
 
 struct mdp5_intf_block {
@@ -98,6 +108,7 @@ struct mdp5_cfg_hw {
struct mdp5_sub_block pp;
struct mdp5_sub_block dsc;
struct mdp5_sub_block cdm;
+   struct mdp5_wb_block wb;
struct mdp5_intf_block intf;
struct mdp5_perf_block perf;
 

-- 
2.39.2



[PATCH v5 00/18] drm/msm: generate register header files

2024-03-31 Thread Dmitry Baryshkov
Currently display-related register headers are generated from XML files
shipped withing Mesa source tree. This is not fully optimal: it requires
multi-stage process of the changes first being landed to Mesa and only
then synced to the kernel tree.

Move original XML files to the kernel tree and generate header files
when required. Display-related XMLs are going to be dropped from the
Mesa, with the kernel becoming the primary source. Adreno-related XMLs
are still going to handled by Mesa and should be synced from Mesa to the
kernel when required. The gen_header.py script should also be synced
between Mesa and the kernel tree.

Unless there are any objections, I'd like to consider this a final
revision with the target of it being merged for 6.10. Please review.

Signed-off-by: Dmitry Baryshkov 
---
Changes in v5:
- Updated gen_header.py to include licence header (Abhinav, Akhil)
- Split the #include rework to a separate patch (Abhinav)
- Link to v4: 
https://lore.kernel.org/r/20240323-fd-xml-shipped-v4-0-cca5e8457...@linaro.org

Changes in v4:
- Updated headers, schema and script to the latest version merged to
  Mesa
- Further split of Adreno XML / Adreno headers patches in order to pass
  through more ML filters.
- Dropped the RFC tag
- Link to v3: 
https://lore.kernel.org/r/20240315-fd-xml-shipped-v3-0-0fc122e36...@linaro.org

Changes in v3:
- Split XML and git rm patches in hope to pass ML limitations
- Link to v2: 
https://lore.kernel.org/r/20240315-fd-xml-shipped-v2-0-7cd68ecc4...@linaro.org

Changes in v2:
- Removed the _shipped files, always generating the headers (Masahiro
  Yamada)
- Replaced headergen2 with gen_headers.py
- Simplify Makefile rules, making all Adreno objects depend on Adreno
  headers and all displau objects depend on all display headers
- Also handle Adreno registers
- Link to v1: 
https://lore.kernel.org/r/20240226-fd-xml-shipped-v1-0-86bb6c334...@linaro.org

---
Dmitry Baryshkov (18):
  drm/msm/mdp5: add writeback block bases
  drm/msm/hdmi: drop qfprom.xml.h
  drm/msm/dsi: drop mmss_cc.xml.h
  drm/msm: move msm_gpummu.c to adreno/a2xx_gpummu.c
  drm/msm: remove dependencies from core onto adreno headers
  drm/msm: import XML display registers database
  drm/msm: import A2xx-A4xx XML display registers database
  drm/msm: import A5xx XML display registers database
  drm/msm: import A6xx XML display registers database
  drm/msm: import gen_header.py script from Mesa
  drm/msm: generate headers on the fly
  drm/msm: drop display-related headers
  drm/msm: drop A2xx and common headers
  drm/msm: drop A3xx and A4xx headers
  drm/msm: drop A5xx header
  drm/msm: drop A6xx GMU header
  drm/msm: drop C++ parts of a6xx.xml.h
  drm/msm: drop A6xx header

 drivers/gpu/drm/msm/.gitignore | 1 +
 drivers/gpu/drm/msm/Makefile   |99 +-
 drivers/gpu/drm/msm/adreno/a2xx.xml.h  |  3251 -
 drivers/gpu/drm/msm/adreno/a2xx_gpu.c  | 4 +-
 drivers/gpu/drm/msm/adreno/a2xx_gpu.h  | 4 +
 .../drm/msm/{msm_gpummu.c => adreno/a2xx_gpummu.c} |45 +-
 drivers/gpu/drm/msm/adreno/a3xx.xml.h  |  3268 -
 drivers/gpu/drm/msm/adreno/a4xx.xml.h  |  4379 ---
 drivers/gpu/drm/msm/adreno/a5xx.xml.h  |  5572 -
 drivers/gpu/drm/msm/adreno/a6xx.xml.h  | 11858 ---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h  |   422 -
 drivers/gpu/drm/msm/adreno/adreno_common.xml.h |   539 -
 drivers/gpu/drm/msm/adreno/adreno_pm4.xml.h|  2803 -
 drivers/gpu/drm/msm/disp/mdp4/mdp4.xml.h   |  1181 --
 drivers/gpu/drm/msm/disp/mdp5/mdp5.xml.h   |  1979 
 drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.h   |11 +
 drivers/gpu/drm/msm/disp/mdp_common.xml.h  |   111 -
 drivers/gpu/drm/msm/dsi/dsi.xml.h  |   790 --
 drivers/gpu/drm/msm/dsi/dsi_phy_10nm.xml.h |   227 -
 drivers/gpu/drm/msm/dsi/dsi_phy_14nm.xml.h |   309 -
 drivers/gpu/drm/msm/dsi/dsi_phy_20nm.xml.h |   237 -
 drivers/gpu/drm/msm/dsi/dsi_phy_28nm.xml.h |   384 -
 drivers/gpu/drm/msm/dsi/dsi_phy_28nm_8960.xml.h|   286 -
 drivers/gpu/drm/msm/dsi/dsi_phy_7nm.xml.h  |   483 -
 drivers/gpu/drm/msm/dsi/mmss_cc.xml.h  |   131 -
 drivers/gpu/drm/msm/dsi/sfpb.xml.h |70 -
 drivers/gpu/drm/msm/hdmi/hdmi.xml.h|  1399 ---
 drivers/gpu/drm/msm/hdmi/qfprom.xml.h  |61 -
 drivers/gpu/drm/msm/msm_drv.c  | 3 +-
 drivers/gpu/drm/msm/msm_gpu.c  | 2 +-
 drivers/gpu/drm/msm/msm_mmu.h  | 5 -
 drivers/gpu/drm/msm/registers/.gitignore   | 4 +
 drivers/gpu/drm/msm/registers/adreno/a2xx.xml  |  1865 +++
 drivers/gpu/drm/msm/registers/adreno/a3xx.xml  |  1751 +++
 

Re: [PATCH] drm/ast: Fix soft lockup

2024-03-31 Thread 黃立銘
Hi Thomas and Jocelyn,

What we do in ast_dp_set_on_off() is a handshake between host driver
and bmc-fw to confirm
the operation, on/off, is completed.

We use some scratch registers in bmc to handshake with host. This
handshake only work if
BMC's scu-lock is opened. If scu-lock is opened too late, then it
could lead to this issue.

Best regards
Jammy

Thomas Zimmermann  於 2024年3月28日 週四 上午4:28寫道:
>
> Hi
>
> Am 27.03.24 um 09:53 schrieb Jocelyn Falempe:
> > Hi,
> >
> > Thanks for your patch.
> > I'm wondering how you can trigger this infinite loop ?
>
> Yeah, a bit more context for this bug would be welcome. It's hard to
> judge the fix without.
>
> Best regards
> Thomas
>
> >
> > Also this looks like a simple fix, that can be easily backported, so
> > I'm adding stable in Cc.
> >
> > If Thomas has no objections, I can push it to drm-misc-fixes.
> >
> > Reviewed-by: Jocelyn Falempe 
> >
>
>
>
> --
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Frankenstrasse 146, 90461 Nuernberg, Germany
> GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
> HRB 36809 (AG Nuernberg)
>


Re: [PATCH] drm/ast: Fix soft lockup

2024-03-31 Thread 黃立銘
Hi Thomas and Jocelyn,

What we do in ast_dp_set_on_off() is a handshake between host driver and
bmc-fw to confirm
the operation, on/off, is completed.

We use some scratch registers in bmc to handshake with host. This handshake
only work if
BMC's scu-lock is opened. If scu-lock is opened too late, then it could
lead to this issue.

Best regards
Jammy

Thomas Zimmermann  於 2024年3月28日 週四 上午4:28寫道:

> Hi
>
> Am 27.03.24 um 09:53 schrieb Jocelyn Falempe:
> > Hi,
> >
> > Thanks for your patch.
> > I'm wondering how you can trigger this infinite loop ?
>
> Yeah, a bit more context for this bug would be welcome. It's hard to
> judge the fix without.
>
> Best regards
> Thomas
>
> >
> > Also this looks like a simple fix, that can be easily backported, so
> > I'm adding stable in Cc.
> >
> > If Thomas has no objections, I can push it to drm-misc-fixes.
> >
> > Reviewed-by: Jocelyn Falempe 
> >
>
>
>
> --
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Frankenstrasse 146, 90461 Nuernberg, Germany
> GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
> HRB 36809 (AG Nuernberg)
>
>


Re: 2024 X.Org Foundation Membership deadline for voting in the election

2024-03-31 Thread Marc Balmer
How often will you send this spam again?

> Am 31.03.2024 um 18:46 schrieb Ricardo Garcia :
> 
> This is a reminder that the membership renewal period ends in 2 days,
> and elections will start after that. Please register as an X.Org
> Foundation member to be able to vote in the upcoming elections. Thanks!
> 
> -Ricardo Garcia, on behalf of the X.Org elections committee.
> 
>> On Tue, 2024-03-26 at 11:42 -0400, Christopher Michael wrote:
>> The 2024 X.Org Foundation membership renewal period has been extended
>> one additional week and elections will start the following week on 01
>> April 2024.
>> 
>> Please note that only current members can vote in the upcoming election,
>> and that the deadline for new memberships or renewals to vote in the
>> upcoming election is 01 April 2024 at 23:59 UTC.
>> 
>> If you are interested in joining the X.Org Foundation or in renewing
>> your membership, please visit the membership system site at:
>> https://members.x.org/
>> 
>> Christopher Michael, on behalf of the X.Org elections committee
>> 
>> 
>> 
> 



[PATCH v2 8/8] fbdev: omapfb: use of_graph_get_remote_port()

2024-03-31 Thread Kuninori Morimoto
We already have of_graph_get_remote_port(), Let's use it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 15 +--
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
index 14965a3fd05b..4040e247e026 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
@@ -117,19 +117,6 @@ u32 dss_of_port_get_port_number(struct device_node *port)
return reg;
 }
 
-static struct device_node *omapdss_of_get_remote_port(const struct device_node 
*node)
-{
-   struct device_node *np;
-
-   np = of_graph_get_remote_endpoint(node);
-   if (!np)
-   return NULL;
-
-   np = of_get_next_parent(np);
-
-   return np;
-}
-
 struct omap_dss_device *
 omapdss_of_find_source_for_first_ep(struct device_node *node)
 {
@@ -141,7 +128,7 @@ omapdss_of_find_source_for_first_ep(struct device_node 
*node)
if (!ep)
return ERR_PTR(-EINVAL);
 
-   src_port = omapdss_of_get_remote_port(ep);
+   src_port = of_graph_get_remote_port(ep);
if (!src_port) {
of_node_put(ep);
return ERR_PTR(-EINVAL);
-- 
2.25.1



[PATCH v2 7/8] video: fbdev: use for_each_endpoint_of_node()

2024-03-31 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c 
b/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c
index 09f719af0d0c..d80720c84323 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c
@@ -149,8 +149,7 @@ static void __init omapdss_walk_device(struct device_node 
*node, bool root)
 
of_node_put(n);
 
-   n = NULL;
-   while ((n = of_graph_get_next_endpoint(node, n)) != NULL) {
+   for_each_endpoint_of_node(node, n) {
struct device_node *pn;
 
pn = of_graph_get_remote_port_parent(n);
-- 
2.25.1



[PATCH v2 6/8] staging: media: atmel: use for_each_endpoint_of_node()

2024-03-31 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c | 6 +-
 drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c | 6 +-
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c 
b/drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c
index 31b2b48085c5..cbfbec0c6cb5 100644
--- a/drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c
+++ b/drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c
@@ -340,13 +340,9 @@ static int isc_parse_dt(struct device *dev, struct 
isc_device *isc)
 
INIT_LIST_HEAD(>subdev_entities);
 
-   while (1) {
+   for_each_endpoint_of_node(np, epn) {
struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type = 0 };
 
-   epn = of_graph_get_next_endpoint(np, epn);
-   if (!epn)
-   return 0;
-
ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(epn),
 _epn);
if (ret) {
diff --git a/drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c 
b/drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c
index 020034f631f5..7c477b1d3c48 100644
--- a/drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c
+++ b/drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c
@@ -326,13 +326,9 @@ static int xisc_parse_dt(struct device *dev, struct 
isc_device *isc)
 
mipi_mode = of_property_read_bool(np, "microchip,mipi-mode");
 
-   while (1) {
+   for_each_endpoint_of_node(np, epn) {
struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type = 0 };
 
-   epn = of_graph_get_next_endpoint(np, epn);
-   if (!epn)
-   return 0;
-
ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(epn),
 _epn);
if (ret) {
-- 
2.25.1



[PATCH v2 5/8] media: platform: xilinx: use for_each_endpoint_of_node()

2024-03-31 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/media/platform/xilinx/xilinx-vipp.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c 
b/drivers/media/platform/xilinx/xilinx-vipp.c
index 996684a73038..38818b82a575 100644
--- a/drivers/media/platform/xilinx/xilinx-vipp.c
+++ b/drivers/media/platform/xilinx/xilinx-vipp.c
@@ -205,12 +205,7 @@ static int xvip_graph_build_dma(struct 
xvip_composite_device *xdev)
 
dev_dbg(xdev->dev, "creating links for DMA engines\n");
 
-   while (1) {
-   /* Get the next endpoint and parse its link. */
-   ep = of_graph_get_next_endpoint(node, ep);
-   if (ep == NULL)
-   break;
-
+   for_each_endpoint_of_node(node, ep) {
dev_dbg(xdev->dev, "processing endpoint %pOF\n", ep);
 
ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), );
-- 
2.25.1



[PATCH v2 4/8] media: platform: ti: use for_each_endpoint_of_node()

2024-03-31 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/media/platform/ti/am437x/am437x-vpfe.c   | 12 +---
 drivers/media/platform/ti/davinci/vpif_capture.c | 12 ++--
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/media/platform/ti/am437x/am437x-vpfe.c 
b/drivers/media/platform/ti/am437x/am437x-vpfe.c
index 77e12457d149..009ff68a2b43 100644
--- a/drivers/media/platform/ti/am437x/am437x-vpfe.c
+++ b/drivers/media/platform/ti/am437x/am437x-vpfe.c
@@ -2287,7 +2287,7 @@ static const struct v4l2_async_notifier_operations 
vpfe_async_ops = {
 static struct vpfe_config *
 vpfe_get_pdata(struct vpfe_device *vpfe)
 {
-   struct device_node *endpoint = NULL;
+   struct device_node *endpoint;
struct device *dev = vpfe->pdev;
struct vpfe_subdev_info *sdinfo;
struct vpfe_config *pdata;
@@ -2306,14 +2306,11 @@ vpfe_get_pdata(struct vpfe_device *vpfe)
if (!pdata)
return NULL;
 
-   for (i = 0; ; i++) {
+   i = 0;
+   for_each_endpoint_of_node(dev->of_node, endpoint) {
struct v4l2_fwnode_endpoint bus_cfg = { .bus_type = 0 };
struct device_node *rem;
 
-   endpoint = of_graph_get_next_endpoint(dev->of_node, endpoint);
-   if (!endpoint)
-   break;
-
sdinfo = >sub_devs[i];
sdinfo->grp_id = 0;
 
@@ -2371,9 +2368,10 @@ vpfe_get_pdata(struct vpfe_device *vpfe)
of_node_put(rem);
if (IS_ERR(pdata->asd[i]))
goto cleanup;
+
+   i++;
}
 
-   of_node_put(endpoint);
return pdata;
 
 cleanup:
diff --git a/drivers/media/platform/ti/davinci/vpif_capture.c 
b/drivers/media/platform/ti/davinci/vpif_capture.c
index c31a5566fc5a..3db4e82c8a80 100644
--- a/drivers/media/platform/ti/davinci/vpif_capture.c
+++ b/drivers/media/platform/ti/davinci/vpif_capture.c
@@ -1517,16 +1517,12 @@ vpif_capture_get_pdata(struct platform_device *pdev,
if (!pdata->subdev_info)
return NULL;
 
-   for (i = 0; i < VPIF_CAPTURE_NUM_CHANNELS; i++) {
+   i = 0;
+   for_each_endpoint_of_node(pdev->dev.of_node, endpoint) {
struct v4l2_fwnode_endpoint bus_cfg = { .bus_type = 0 };
unsigned int flags;
int err;
 
-   endpoint = of_graph_get_next_endpoint(pdev->dev.of_node,
- endpoint);
-   if (!endpoint)
-   break;
-
rem = of_graph_get_remote_port_parent(endpoint);
if (!rem) {
dev_dbg(>dev, "Remote device at %pOF not found\n",
@@ -1577,6 +1573,10 @@ vpif_capture_get_pdata(struct platform_device *pdev,
goto err_cleanup;
 
of_node_put(rem);
+
+   i++;
+   if (i >= VPIF_CAPTURE_NUM_CHANNELS)
+   break;
}
 
 done:
-- 
2.25.1



[PATCH v2 3/8] media: platform: microchip: use for_each_endpoint_of_node()

2024-03-31 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
---
 .../microchip/microchip-sama5d2-isc.c | 19 +++
 .../microchip/microchip-sama7g5-isc.c | 19 +++
 2 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/drivers/media/platform/microchip/microchip-sama5d2-isc.c 
b/drivers/media/platform/microchip/microchip-sama5d2-isc.c
index 5ac149cf3647..d9298771f509 100644
--- a/drivers/media/platform/microchip/microchip-sama5d2-isc.c
+++ b/drivers/media/platform/microchip/microchip-sama5d2-isc.c
@@ -356,30 +356,26 @@ static int isc_parse_dt(struct device *dev, struct 
isc_device *isc)
struct device_node *epn = NULL;
struct isc_subdev_entity *subdev_entity;
unsigned int flags;
-   int ret;
 
INIT_LIST_HEAD(>subdev_entities);
 
-   while (1) {
+   for_each_endpoint_of_node(np, epn) {
struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type = 0 };
-
-   epn = of_graph_get_next_endpoint(np, epn);
-   if (!epn)
-   return 0;
+   int ret;
 
ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(epn),
 _epn);
if (ret) {
-   ret = -EINVAL;
+   of_node_put(epn);
dev_err(dev, "Could not parse the endpoint\n");
-   break;
+   return -EINVAL;
}
 
subdev_entity = devm_kzalloc(dev, sizeof(*subdev_entity),
 GFP_KERNEL);
if (!subdev_entity) {
-   ret = -ENOMEM;
-   break;
+   of_node_put(epn);
+   return -ENOMEM;
}
subdev_entity->epn = epn;
 
@@ -400,9 +396,8 @@ static int isc_parse_dt(struct device *dev, struct 
isc_device *isc)
 
list_add_tail(_entity->list, >subdev_entities);
}
-   of_node_put(epn);
 
-   return ret;
+   return 0;
 }
 
 static int microchip_isc_probe(struct platform_device *pdev)
diff --git a/drivers/media/platform/microchip/microchip-sama7g5-isc.c 
b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
index 73445f33d26b..36204fee10aa 100644
--- a/drivers/media/platform/microchip/microchip-sama7g5-isc.c
+++ b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
@@ -339,33 +339,29 @@ static int xisc_parse_dt(struct device *dev, struct 
isc_device *isc)
struct device_node *epn = NULL;
struct isc_subdev_entity *subdev_entity;
unsigned int flags;
-   int ret;
bool mipi_mode;
 
INIT_LIST_HEAD(>subdev_entities);
 
mipi_mode = of_property_read_bool(np, "microchip,mipi-mode");
 
-   while (1) {
+   for_each_endpoint_of_node(np, epn) {
struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type = 0 };
-
-   epn = of_graph_get_next_endpoint(np, epn);
-   if (!epn)
-   return 0;
+   int ret;
 
ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(epn),
 _epn);
if (ret) {
-   ret = -EINVAL;
+   of_node_put(epn);
dev_err(dev, "Could not parse the endpoint\n");
-   break;
+   return -EINVAL;
}
 
subdev_entity = devm_kzalloc(dev, sizeof(*subdev_entity),
 GFP_KERNEL);
if (!subdev_entity) {
-   ret = -ENOMEM;
-   break;
+   of_node_put(epn);
+   return -ENOMEM;
}
subdev_entity->epn = epn;
 
@@ -389,9 +385,8 @@ static int xisc_parse_dt(struct device *dev, struct 
isc_device *isc)
 
list_add_tail(_entity->list, >subdev_entities);
}
-   of_node_put(epn);
 
-   return ret;
+   return 0;
 }
 
 static int microchip_xisc_probe(struct platform_device *pdev)
-- 
2.25.1



[PATCH v2 2/8] hwtracing: use for_each_endpoint_of_node()

2024-03-31 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
Reviewed-by: Suzuki K Poulose 
---
 drivers/hwtracing/coresight/coresight-platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-platform.c 
b/drivers/hwtracing/coresight/coresight-platform.c
index 9d550f5697fa..e9683e613d52 100644
--- a/drivers/hwtracing/coresight/coresight-platform.c
+++ b/drivers/hwtracing/coresight/coresight-platform.c
@@ -275,7 +275,7 @@ static int of_get_coresight_platform_data(struct device 
*dev,
 */
if (!parent) {
/*
-* Avoid warnings in of_graph_get_next_endpoint()
+* Avoid warnings in for_each_endpoint_of_node()
 * if the device doesn't have any graph connections
 */
if (!of_graph_is_present(node))
@@ -286,7 +286,7 @@ static int of_get_coresight_platform_data(struct device 
*dev,
}
 
/* Iterate through each output port to discover topology */
-   while ((ep = of_graph_get_next_endpoint(parent, ep))) {
+   for_each_endpoint_of_node(parent, ep) {
/*
 * Legacy binding mixes input/output ports under the
 * same parent. So, skip the input ports if we are dealing
-- 
2.25.1



[PATCH v2 1/8] gpu: drm: use for_each_endpoint_of_node()

2024-03-31 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/gpu/drm/omapdrm/dss/base.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index 050ca7eafac5..5f8002f6bb7a 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -242,8 +242,7 @@ static void omapdss_walk_device(struct device *dev, struct 
device_node *node,
 
of_node_put(n);
 
-   n = NULL;
-   while ((n = of_graph_get_next_endpoint(node, n)) != NULL) {
+   for_each_endpoint_of_node(node, n) {
struct device_node *pn = of_graph_get_remote_port_parent(n);
 
if (!pn)
-- 
2.25.1



[PATCH v2 0/8] use for_each_endpoint_of_node()

2024-03-31 Thread Kuninori Morimoto


Hi Rob, Helge

We already have for_each_endpoint_of_node(), but some drivers are
not using it. This patch-set replace it.

This patch-set is related to "OF" (= Rob), but many driveres are for
"MultiMedia" (= Helge). I'm not sure who handle these.

[o] done
[*] this patch-set

[o] tidyup of_graph_get_endpoint_count()
[o] replace endpoint func - use endpoint_by_regs()
[*] replace endpoint func - use for_each()
[ ] rename endpoint func to device_endpoint
[ ] add new port function
[ ] add new endpont function
[ ] remove of_graph_get_next_device_endpoint()

v1 -> v2
- fixup TI patch

Link: https://lore.kernel.org/r/8734sf6mgn.wl-kuninori.morimoto...@renesas.com

Kuninori Morimoto (8):
  gpu: drm: use for_each_endpoint_of_node()
  hwtracing: use for_each_endpoint_of_node()
  media: platform: microchip: use for_each_endpoint_of_node()
  media: platform: ti: use for_each_endpoint_of_node()
  media: platform: xilinx: use for_each_endpoint_of_node()
  staging: media: atmel: use for_each_endpoint_of_node()
  video: fbdev: use for_each_endpoint_of_node()
  fbdev: omapfb: use of_graph_get_remote_port()

 drivers/gpu/drm/omapdrm/dss/base.c|  3 +--
 .../hwtracing/coresight/coresight-platform.c  |  4 ++--
 .../microchip/microchip-sama5d2-isc.c | 19 +++
 .../microchip/microchip-sama7g5-isc.c | 19 +++
 .../media/platform/ti/am437x/am437x-vpfe.c| 12 +---
 .../media/platform/ti/davinci/vpif_capture.c  | 12 ++--
 drivers/media/platform/xilinx/xilinx-vipp.c   |  7 +--
 .../deprecated/atmel/atmel-sama5d2-isc.c  |  6 +-
 .../deprecated/atmel/atmel-sama7g5-isc.c  |  6 +-
 drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 15 +--
 .../omap2/omapfb/dss/omapdss-boot-init.c  |  3 +--
 11 files changed, 33 insertions(+), 73 deletions(-)

-- 
2.25.1



[PATCH v2] drm/bridge: adv7511: make it honour next bridge in DT

2024-03-31 Thread Dmitry Baryshkov
DT bindings for adv7511 and adv7533 bridges specify HDMI output to be
present at the port@1. This allows board DT to add e.g. HDMI connector
nodes or any other next chained bridge. Make adv7511 driver discover
that bridge and attach it to the chain.

Signed-off-by: Dmitry Baryshkov 
---
Changes in v2:
- Fixed the absent next bridge usecase
- Link to v1: 
https://lore.kernel.org/r/20240309-adv7511-next-bridge-v1-1-d1ad522ef...@linaro.org
---
 drivers/gpu/drm/bridge/adv7511/adv7511.h |  1 +
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 12 
 2 files changed, 13 insertions(+)

diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511.h 
b/drivers/gpu/drm/bridge/adv7511/adv7511.h
index 39c9ece373b0..ea271f62b214 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511.h
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h
@@ -356,6 +356,7 @@ struct adv7511 {
enum drm_connector_status status;
bool powered;
 
+   struct drm_bridge *next_bridge;
struct drm_display_mode curr_mode;
 
unsigned int f_tmds;
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c 
b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
index b5518ff97165..c50d994a33b5 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -946,6 +947,12 @@ static int adv7511_bridge_attach(struct drm_bridge *bridge,
struct adv7511 *adv = bridge_to_adv7511(bridge);
int ret = 0;
 
+   if (adv->next_bridge) {
+   ret = drm_bridge_attach(bridge->encoder, adv->next_bridge, 
bridge, flags);
+   if (ret)
+   return ret;
+   }
+
if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) {
ret = adv7511_connector_init(adv);
if (ret < 0)
@@ -1216,6 +1223,11 @@ static int adv7511_probe(struct i2c_client *i2c)
 
memset(_config, 0, sizeof(link_config));
 
+   ret = drm_of_find_panel_or_bridge(dev->of_node, 1, -1, NULL,
+ >next_bridge);
+   if (ret && ret != -ENODEV)
+   return ret;
+
if (adv7511->info->link_config)
ret = adv7511_parse_dt(dev->of_node, _config);
else

---
base-commit: 1843e16d2df9d98427ef8045589571749d627cf7
change-id: 20240309-adv7511-next-bridge-10d8bbe0544e

Best regards,
-- 
Dmitry Baryshkov 



[PATCH v2 03/12] drm/imx: cleanup the imx-drm header

2024-03-31 Thread Dmitry Baryshkov
Drop unused defines and obsolete prototypes from the imx-drm.h header.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/imx/ipuv3/imx-drm.h | 12 
 1 file changed, 12 deletions(-)

diff --git a/drivers/gpu/drm/imx/ipuv3/imx-drm.h 
b/drivers/gpu/drm/imx/ipuv3/imx-drm.h
index e721bebda2bd..e01f026047de 100644
--- a/drivers/gpu/drm/imx/ipuv3/imx-drm.h
+++ b/drivers/gpu/drm/imx/ipuv3/imx-drm.h
@@ -3,14 +3,9 @@
 #define _IMX_DRM_H_
 
 struct device_node;
-struct drm_crtc;
 struct drm_connector;
 struct drm_device;
-struct drm_display_mode;
 struct drm_encoder;
-struct drm_framebuffer;
-struct drm_plane;
-struct platform_device;
 
 struct imx_crtc_state {
struct drm_crtc_state   base;
@@ -24,16 +19,9 @@ static inline struct imx_crtc_state 
*to_imx_crtc_state(struct drm_crtc_state *s)
 {
return container_of(s, struct imx_crtc_state, base);
 }
-int imx_drm_init_drm(struct platform_device *pdev,
-   int preferred_bpp);
-int imx_drm_exit_drm(void);
 
 extern struct platform_driver ipu_drm_driver;
 
-void imx_drm_mode_config_init(struct drm_device *drm);
-
-struct drm_gem_dma_object *imx_drm_fb_get_obj(struct drm_framebuffer *fb);
-
 int imx_drm_encoder_parse_of(struct drm_device *drm,
struct drm_encoder *encoder, struct device_node *np);
 

-- 
2.39.2



[PATCH v2 10/12] drm/imx: ldb: switch to imx_legacy_bridge / drm_bridge_connector

2024-03-31 Thread Dmitry Baryshkov
Use the imx_legacy bridge driver instead of handlign display modes via
the connector node.

All existing usecases already support attaching using
the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag, while the imx_legacy bridge
doesn't support creating connector at all. Switch to
drm_bridge_connector at the same time.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/imx/ipuv3/Kconfig   |   1 +
 drivers/gpu/drm/imx/ipuv3/imx-ldb.c | 103 ++--
 2 files changed, 30 insertions(+), 74 deletions(-)

diff --git a/drivers/gpu/drm/imx/ipuv3/Kconfig 
b/drivers/gpu/drm/imx/ipuv3/Kconfig
index 8aaf2441bcef..3e5c0f4a1d0d 100644
--- a/drivers/gpu/drm/imx/ipuv3/Kconfig
+++ b/drivers/gpu/drm/imx/ipuv3/Kconfig
@@ -33,6 +33,7 @@ config DRM_IMX_LDB
depends on DRM_BRIDGE
select DRM_PANEL
select DRM_PANEL_BRIDGE
+   select DRM_IMX_LEGACY_BRIDGE
help
  Choose this to enable the internal LVDS Display Bridge (LDB)
  found on i.MX53 and i.MX6 processors.
diff --git a/drivers/gpu/drm/imx/ipuv3/imx-ldb.c 
b/drivers/gpu/drm/imx/ipuv3/imx-ldb.c
index 74b41a507219..10e608f0b040 100644
--- a/drivers/gpu/drm/imx/ipuv3/imx-ldb.c
+++ b/drivers/gpu/drm/imx/ipuv3/imx-ldb.c
@@ -19,18 +19,17 @@
 #include 
 #include 
 
-#include 
-#include 
-
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include "imx-drm.h"
 
@@ -54,7 +53,6 @@
 struct imx_ldb_channel;
 
 struct imx_ldb_encoder {
-   struct drm_connector connector;
struct drm_encoder encoder;
struct imx_ldb_channel *channel;
 };
@@ -68,17 +66,9 @@ struct imx_ldb_channel {
 
struct device_node *child;
int chno;
-   struct drm_display_mode mode;
-   int mode_valid;
u32 bus_format;
-   u32 bus_flags;
 };
 
-static inline struct imx_ldb_channel *con_to_imx_ldb_ch(struct drm_connector 
*c)
-{
-   return container_of(c, struct imx_ldb_encoder, connector)->channel;
-}
-
 static inline struct imx_ldb_channel *enc_to_imx_ldb_ch(struct drm_encoder *e)
 {
return container_of(e, struct imx_ldb_encoder, encoder)->channel;
@@ -128,25 +118,6 @@ static void imx_ldb_ch_set_bus_format(struct 
imx_ldb_channel *imx_ldb_ch,
}
 }
 
-static int imx_ldb_connector_get_modes(struct drm_connector *connector)
-{
-   struct imx_ldb_channel *imx_ldb_ch = con_to_imx_ldb_ch(connector);
-   int num_modes;
-
-   if (imx_ldb_ch->mode_valid) {
-   struct drm_display_mode *mode;
-
-   mode = drm_mode_duplicate(connector->dev, _ldb_ch->mode);
-   if (!mode)
-   return -EINVAL;
-   mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
-   drm_mode_probed_add(connector, mode);
-   num_modes++;
-   }
-
-   return num_modes;
-}
-
 static void imx_ldb_set_clock(struct imx_ldb *ldb, int mux, int chno,
unsigned long serial_clk, unsigned long di_clk)
 {
@@ -348,11 +319,12 @@ static int imx_ldb_encoder_atomic_check(struct 
drm_encoder *encoder,
/* Bus format description in DT overrides connector display info. */
if (!bus_format && di->num_bus_formats) {
bus_format = di->bus_formats[0];
-   imx_crtc_state->bus_flags = di->bus_flags;
} else {
bus_format = imx_ldb_ch->bus_format;
-   imx_crtc_state->bus_flags = imx_ldb_ch->bus_flags;
}
+
+   imx_crtc_state->bus_flags = di->bus_flags;
+
switch (bus_format) {
case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
imx_crtc_state->bus_format = MEDIA_BUS_FMT_RGB666_1X18;
@@ -372,18 +344,6 @@ static int imx_ldb_encoder_atomic_check(struct drm_encoder 
*encoder,
 }
 
 
-static const struct drm_connector_funcs imx_ldb_connector_funcs = {
-   .fill_modes = drm_helper_probe_single_connector_modes,
-   .destroy = imx_drm_connector_destroy,
-   .reset = drm_atomic_helper_connector_reset,
-   .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
-   .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
-};
-
-static const struct drm_connector_helper_funcs imx_ldb_connector_helper_funcs 
= {
-   .get_modes = imx_ldb_connector_get_modes,
-};
-
 static const struct drm_encoder_helper_funcs imx_ldb_encoder_helper_funcs = {
.atomic_mode_set = imx_ldb_encoder_atomic_mode_set,
.enable = imx_ldb_encoder_enable,
@@ -421,7 +381,6 @@ static int imx_ldb_register(struct drm_device *drm,
return PTR_ERR(ldb_encoder);
 
ldb_encoder->channel = imx_ldb_ch;
-   connector = _encoder->connector;
encoder = _encoder->encoder;
 
ret = imx_drm_encoder_parse_of(drm, encoder, imx_ldb_ch->child);
@@ -440,24 +399,16 @@ static int imx_ldb_register(struct drm_device *drm,
 
drm_encoder_helper_add(encoder, _ldb_encoder_helper_funcs);
 
-   if 

[PATCH v2 05/12] drm/imx: ldb: drop custom EDID support

2024-03-31 Thread Dmitry Baryshkov
Bindings for the imx-ldb never allowed specifying the EDID in DT. None
of the existing DT files use it. Drop it now in favour of using debugfs
overrides or the drm.edid_firmware support.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/imx/ipuv3/imx-ldb.c | 27 ++-
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/imx/ipuv3/imx-ldb.c 
b/drivers/gpu/drm/imx/ipuv3/imx-ldb.c
index 71d70194fcbd..1924d8921c62 100644
--- a/drivers/gpu/drm/imx/ipuv3/imx-ldb.c
+++ b/drivers/gpu/drm/imx/ipuv3/imx-ldb.c
@@ -72,7 +72,6 @@ struct imx_ldb_channel {
struct device_node *child;
struct i2c_adapter *ddc;
int chno;
-   void *edid;
struct drm_display_mode mode;
int mode_valid;
u32 bus_format;
@@ -142,13 +141,16 @@ static int imx_ldb_connector_get_modes(struct 
drm_connector *connector)
if (num_modes > 0)
return num_modes;
 
-   if (!imx_ldb_ch->edid && imx_ldb_ch->ddc)
-   imx_ldb_ch->edid = drm_get_edid(connector, imx_ldb_ch->ddc);
+   if (imx_ldb_ch->ddc) {
+   const struct drm_edid *edid = drm_edid_read_ddc(connector,
+   
imx_ldb_ch->ddc);
 
-   if (imx_ldb_ch->edid) {
-   drm_connector_update_edid_property(connector,
-   imx_ldb_ch->edid);
-   num_modes = drm_add_edid_modes(connector, imx_ldb_ch->edid);
+   if (edid) {
+   drm_edid_connector_update(connector, edid);
+   drm_edid_free(edid);
+
+   return drm_edid_connector_add_modes(connector);
+   }
}
 
if (imx_ldb_ch->mode_valid) {
@@ -553,7 +555,6 @@ static int imx_ldb_panel_ddc(struct device *dev,
struct imx_ldb_channel *channel, struct device_node *child)
 {
struct device_node *ddc_node;
-   const u8 *edidp;
int ret;
 
ddc_node = of_parse_phandle(child, "ddc-i2c-bus", 0);
@@ -567,17 +568,10 @@ static int imx_ldb_panel_ddc(struct device *dev,
}
 
if (!channel->ddc) {
-   int edid_len;
-
/* if no DDC available, fallback to hardcoded EDID */
dev_dbg(dev, "no ddc available\n");
 
-   edidp = of_get_property(child, "edid", _len);
-   if (edidp) {
-   channel->edid = kmemdup(edidp, edid_len, GFP_KERNEL);
-   if (!channel->edid)
-   return -ENOMEM;
-   } else if (!channel->panel) {
+   if (!channel->panel) {
/* fallback to display-timings node */
ret = of_get_drm_display_mode(child,
  >mode,
@@ -744,7 +738,6 @@ static void imx_ldb_remove(struct platform_device *pdev)
for (i = 0; i < 2; i++) {
struct imx_ldb_channel *channel = _ldb->channel[i];
 
-   kfree(channel->edid);
i2c_put_adapter(channel->ddc);
}
 

-- 
2.39.2



[PATCH v2 11/12] drm/imx: parallel-display: switch to imx_legacy_bridge / drm_bridge_connector

2024-03-31 Thread Dmitry Baryshkov
Use the imx_legacy bridge driver instead of handlign display modes via
the connector node.

All existing usecases already support attaching using
the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag, while the imx_legacy bridge
doesn't support creating connector at all. Switch to
drm_bridge_connector at the same time.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/imx/ipuv3/parallel-display.c | 99 ++--
 1 file changed, 19 insertions(+), 80 deletions(-)

diff --git a/drivers/gpu/drm/imx/ipuv3/parallel-display.c 
b/drivers/gpu/drm/imx/ipuv3/parallel-display.c
index b7743b30475a..cf29021f497e 100644
--- a/drivers/gpu/drm/imx/ipuv3/parallel-display.c
+++ b/drivers/gpu/drm/imx/ipuv3/parallel-display.c
@@ -12,10 +12,9 @@
 #include 
 #include 
 
-#include 
-
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -25,7 +24,6 @@
 #include "imx-drm.h"
 
 struct imx_parallel_display_encoder {
-   struct drm_connector connector;
struct drm_encoder encoder;
struct drm_bridge bridge;
struct imx_parallel_display *pd;
@@ -34,51 +32,14 @@ struct imx_parallel_display_encoder {
 struct imx_parallel_display {
struct device *dev;
u32 bus_format;
-   u32 bus_flags;
-   struct drm_display_mode mode;
struct drm_bridge *next_bridge;
 };
 
-static inline struct imx_parallel_display *con_to_imxpd(struct drm_connector 
*c)
-{
-   return container_of(c, struct imx_parallel_display_encoder, 
connector)->pd;
-}
-
 static inline struct imx_parallel_display *bridge_to_imxpd(struct drm_bridge 
*b)
 {
return container_of(b, struct imx_parallel_display_encoder, bridge)->pd;
 }
 
-static int imx_pd_connector_get_modes(struct drm_connector *connector)
-{
-   struct imx_parallel_display *imxpd = con_to_imxpd(connector);
-   struct device_node *np = imxpd->dev->of_node;
-   int num_modes;
-
-   if (np) {
-   struct drm_display_mode *mode = drm_mode_create(connector->dev);
-   int ret;
-
-   if (!mode)
-   return 0;
-
-   ret = of_get_drm_display_mode(np, >mode,
- >bus_flags,
- OF_USE_NATIVE_MODE);
-   if (ret) {
-   drm_mode_destroy(connector->dev, mode);
-   return 0;
-   }
-
-   drm_mode_copy(mode, >mode);
-   mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
-   drm_mode_probed_add(connector, mode);
-   num_modes++;
-   }
-
-   return num_modes;
-}
-
 static const u32 imx_pd_bus_fmts[] = {
MEDIA_BUS_FMT_RGB888_1X24,
MEDIA_BUS_FMT_BGR888_1X24,
@@ -172,7 +133,6 @@ static int imx_pd_bridge_atomic_check(struct drm_bridge 
*bridge,
 {
struct imx_crtc_state *imx_crtc_state = to_imx_crtc_state(crtc_state);
struct drm_display_info *di = _state->connector->display_info;
-   struct imx_parallel_display *imxpd = bridge_to_imxpd(bridge);
struct drm_bridge_state *next_bridge_state = NULL;
struct drm_bridge *next_bridge;
u32 bus_flags, bus_fmt;
@@ -184,10 +144,8 @@ static int imx_pd_bridge_atomic_check(struct drm_bridge 
*bridge,
 
if (next_bridge_state)
bus_flags = next_bridge_state->input_bus_cfg.flags;
-   else if (di->num_bus_formats)
-   bus_flags = di->bus_flags;
else
-   bus_flags = imxpd->bus_flags;
+   bus_flags = di->bus_flags;
 
bus_fmt = bridge_state->input_bus_cfg.format;
if (!imx_pd_format_supported(bus_fmt))
@@ -203,19 +161,16 @@ static int imx_pd_bridge_atomic_check(struct drm_bridge 
*bridge,
return 0;
 }
 
-static const struct drm_connector_funcs imx_pd_connector_funcs = {
-   .fill_modes = drm_helper_probe_single_connector_modes,
-   .destroy = imx_drm_connector_destroy,
-   .reset = drm_atomic_helper_connector_reset,
-   .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
-   .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
-};
+static int imx_pd_bridge_attach(struct drm_bridge *bridge,
+   enum drm_bridge_attach_flags flags)
+{
+   struct imx_parallel_display *imxpd = bridge_to_imxpd(bridge);
 
-static const struct drm_connector_helper_funcs imx_pd_connector_helper_funcs = 
{
-   .get_modes = imx_pd_connector_get_modes,
-};
+   return drm_bridge_attach(bridge->encoder, imxpd->next_bridge, bridge, 
flags);
+}
 
 static const struct drm_bridge_funcs imx_pd_bridge_funcs = {
+   .attach = imx_pd_bridge_attach,
.atomic_reset = drm_atomic_helper_bridge_reset,
.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
@@ -240,7 +195,6 @@ static int imx_pd_bind(struct device *dev, struct device 

[PATCH v2 09/12] drm/imx: add internal bridge handling display-timings DT node

2024-03-31 Thread Dmitry Baryshkov
i.MX DRM DT bindings allow using either a proper panel / bridge graph to
provide information about connected panels, or just a display-timings DT
node, describing just the timings and the flags. Add helper bridge
driver supporting the latter usecase. It will be used by both LDB and
parallel-display drivers.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/bridge/imx/Kconfig | 10 +++
 drivers/gpu/drm/bridge/imx/Makefile|  1 +
 drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c | 85 ++
 include/drm/bridge/imx.h   | 13 
 4 files changed, 109 insertions(+)

diff --git a/drivers/gpu/drm/bridge/imx/Kconfig 
b/drivers/gpu/drm/bridge/imx/Kconfig
index 5965e8027529..708faf0b75ae 100644
--- a/drivers/gpu/drm/bridge/imx/Kconfig
+++ b/drivers/gpu/drm/bridge/imx/Kconfig
@@ -3,6 +3,16 @@ if ARCH_MXC || COMPILE_TEST
 config DRM_IMX_LDB_HELPER
tristate
 
+config DRM_IMX_LEGACY_BRIDGE
+   tristate
+   depends on DRM_IMX
+   help
+ This is a DRM bridge implementation for the DRM i.MX IPUv3 driver,
+ that uses of_get_drm_display_mode to acquire display mode.
+
+ Newer designs should not use this bridge and should use proper panel
+ driver instead.
+
 config DRM_IMX8MP_DW_HDMI_BRIDGE
tristate "Freescale i.MX8MP HDMI-TX bridge support"
depends on OF
diff --git a/drivers/gpu/drm/bridge/imx/Makefile 
b/drivers/gpu/drm/bridge/imx/Makefile
index edb0a7b71b30..dd5d48584806 100644
--- a/drivers/gpu/drm/bridge/imx/Makefile
+++ b/drivers/gpu/drm/bridge/imx/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_DRM_IMX_LDB_HELPER) += imx-ldb-helper.o
+obj-$(CONFIG_DRM_IMX_LEGACY_BRIDGE) += imx-legacy-bridge.o
 obj-$(CONFIG_DRM_IMX8MP_DW_HDMI_BRIDGE) += imx8mp-hdmi-tx.o
 obj-$(CONFIG_DRM_IMX8MP_HDMI_PVI) += imx8mp-hdmi-pvi.o
 obj-$(CONFIG_DRM_IMX8QM_LDB) += imx8qm-ldb.o
diff --git a/drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c 
b/drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c
new file mode 100644
index ..fb3a030928f0
--- /dev/null
+++ b/drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c
@@ -0,0 +1,85 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Freescale i.MX drm driver
+ *
+ * bridge driver for legacy DT bindings, utilizing display-timings node
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+struct imx_legacy_bridge {
+   struct drm_bridge base;
+
+   struct drm_display_mode mode;
+   u32 bus_flags;
+};
+
+#define to_imx_legacy_bridge(bridge)   container_of(bridge, struct 
imx_legacy_bridge, base)
+
+static int imx_legacy_bridge_attach(struct drm_bridge *bridge,
+  enum drm_bridge_attach_flags flags)
+{
+   if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR))
+   return -EINVAL;
+
+   return 0;
+}
+
+static int imx_legacy_bridge_get_modes(struct drm_bridge *bridge,
+  struct drm_connector *connector)
+{
+   struct imx_legacy_bridge *imx_bridge = to_imx_legacy_bridge(bridge);
+   int ret;
+
+   ret = drm_connector_helper_get_modes_fixed(connector, 
_bridge->mode);
+   if (ret)
+   return ret;
+
+   connector->display_info.bus_flags = imx_bridge->bus_flags;
+
+   return 0;
+}
+
+struct drm_bridge_funcs imx_legacy_bridge_funcs = {
+   .attach = imx_legacy_bridge_attach,
+   .get_modes = imx_legacy_bridge_get_modes,
+};
+
+struct drm_bridge *devm_imx_drm_legacy_bridge(struct device *dev,
+ struct device_node *np,
+ int type)
+{
+   struct imx_legacy_bridge *imx_bridge;
+   int ret;
+
+   imx_bridge = devm_kzalloc(dev, sizeof(*imx_bridge), GFP_KERNEL);
+   if (!imx_bridge)
+   return ERR_PTR(-ENOMEM);
+
+   ret = of_get_drm_display_mode(np,
+ _bridge->mode,
+ _bridge->bus_flags,
+ OF_USE_NATIVE_MODE);
+   if (ret)
+   return ERR_PTR(ret);
+
+   imx_bridge->mode.type |= DRM_MODE_TYPE_DRIVER;
+
+   imx_bridge->base.funcs = _legacy_bridge_funcs;
+   imx_bridge->base.of_node = np;
+   imx_bridge->base.ops = DRM_BRIDGE_OP_MODES;
+   imx_bridge->base.type = type;
+
+   ret = devm_drm_bridge_add(dev, _bridge->base);
+   if (ret)
+   return ERR_PTR(ret);
+
+   return _bridge->base;
+}
+EXPORT_SYMBOL_GPL(devm_imx_drm_legacy_bridge);
diff --git a/include/drm/bridge/imx.h b/include/drm/bridge/imx.h
new file mode 100644
index ..e14f429a9ca2
--- /dev/null
+++ b/include/drm/bridge/imx.h
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2012 Sascha Hauer, Pengutronix
+ */
+
+#ifndef DRM_IMX_BRIDGE_H
+#define DRM_IMX_BRIDGE_H
+
+struct drm_bridge *devm_imx_drm_legacy_bridge(struct device *dev,
+   

[PATCH v2 12/12] drm/imx: move imx_drm_connector_destroy to imx-tve

2024-03-31 Thread Dmitry Baryshkov
The imx-tve driver is the only remaining user of
imx_drm_connector_destroy(). Move the function to imx-tve.c

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/imx/ipuv3/imx-drm-core.c | 7 ---
 drivers/gpu/drm/imx/ipuv3/imx-drm.h  | 2 --
 drivers/gpu/drm/imx/ipuv3/imx-tve.c  | 8 +++-
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/imx/ipuv3/imx-drm-core.c 
b/drivers/gpu/drm/imx/ipuv3/imx-drm-core.c
index 4cfabcf7375a..189d395349b8 100644
--- a/drivers/gpu/drm/imx/ipuv3/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/ipuv3/imx-drm-core.c
@@ -34,13 +34,6 @@ module_param(legacyfb_depth, int, 0444);
 
 DEFINE_DRM_GEM_DMA_FOPS(imx_drm_driver_fops);
 
-void imx_drm_connector_destroy(struct drm_connector *connector)
-{
-   drm_connector_unregister(connector);
-   drm_connector_cleanup(connector);
-}
-EXPORT_SYMBOL_GPL(imx_drm_connector_destroy);
-
 static int imx_drm_atomic_check(struct drm_device *dev,
struct drm_atomic_state *state)
 {
diff --git a/drivers/gpu/drm/imx/ipuv3/imx-drm.h 
b/drivers/gpu/drm/imx/ipuv3/imx-drm.h
index e01f026047de..0c85bf83ffbf 100644
--- a/drivers/gpu/drm/imx/ipuv3/imx-drm.h
+++ b/drivers/gpu/drm/imx/ipuv3/imx-drm.h
@@ -25,8 +25,6 @@ extern struct platform_driver ipu_drm_driver;
 int imx_drm_encoder_parse_of(struct drm_device *drm,
struct drm_encoder *encoder, struct device_node *np);
 
-void imx_drm_connector_destroy(struct drm_connector *connector);
-
 int ipu_planes_assign_pre(struct drm_device *dev,
  struct drm_atomic_state *state);
 
diff --git a/drivers/gpu/drm/imx/ipuv3/imx-tve.c 
b/drivers/gpu/drm/imx/ipuv3/imx-tve.c
index b49bddb85535..a5118504b522 100644
--- a/drivers/gpu/drm/imx/ipuv3/imx-tve.c
+++ b/drivers/gpu/drm/imx/ipuv3/imx-tve.c
@@ -307,9 +307,15 @@ static int imx_tve_atomic_check(struct drm_encoder 
*encoder,
return 0;
 }
 
+static void imx_tve_connector_destroy(struct drm_connector *connector)
+{
+   drm_connector_unregister(connector);
+   drm_connector_cleanup(connector);
+}
+
 static const struct drm_connector_funcs imx_tve_connector_funcs = {
.fill_modes = drm_helper_probe_single_connector_modes,
-   .destroy = imx_drm_connector_destroy,
+   .destroy = imx_tve_connector_destroy,
.reset = drm_atomic_helper_connector_reset,
.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,

-- 
2.39.2



[PATCH v2 08/12] drm/imx: parallel-display: switch to drm_panel_bridge

2024-03-31 Thread Dmitry Baryshkov
Defer panel handling to drm_panel_bridge, unifying codepaths for the
panel and bridge cases.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/imx/ipuv3/Kconfig|  2 ++
 drivers/gpu/drm/imx/ipuv3/parallel-display.c | 35 +++-
 2 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/imx/ipuv3/Kconfig 
b/drivers/gpu/drm/imx/ipuv3/Kconfig
index 4e41611c8532..8aaf2441bcef 100644
--- a/drivers/gpu/drm/imx/ipuv3/Kconfig
+++ b/drivers/gpu/drm/imx/ipuv3/Kconfig
@@ -13,6 +13,8 @@ config DRM_IMX_PARALLEL_DISPLAY
tristate "Support for parallel displays"
select DRM_PANEL
depends on DRM_IMX
+   depends on DRM_BRIDGE
+   select DRM_PANEL_BRIDGE
select VIDEOMODE_HELPERS
 
 config DRM_IMX_TVE
diff --git a/drivers/gpu/drm/imx/ipuv3/parallel-display.c 
b/drivers/gpu/drm/imx/ipuv3/parallel-display.c
index 4d17fb96e77c..b7743b30475a 100644
--- a/drivers/gpu/drm/imx/ipuv3/parallel-display.c
+++ b/drivers/gpu/drm/imx/ipuv3/parallel-display.c
@@ -36,7 +36,6 @@ struct imx_parallel_display {
u32 bus_format;
u32 bus_flags;
struct drm_display_mode mode;
-   struct drm_panel *panel;
struct drm_bridge *next_bridge;
 };
 
@@ -56,10 +55,6 @@ static int imx_pd_connector_get_modes(struct drm_connector 
*connector)
struct device_node *np = imxpd->dev->of_node;
int num_modes;
 
-   num_modes = drm_panel_get_modes(imxpd->panel, connector);
-   if (num_modes > 0)
-   return num_modes;
-
if (np) {
struct drm_display_mode *mode = drm_mode_create(connector->dev);
int ret;
@@ -84,22 +79,6 @@ static int imx_pd_connector_get_modes(struct drm_connector 
*connector)
return num_modes;
 }
 
-static void imx_pd_bridge_enable(struct drm_bridge *bridge)
-{
-   struct imx_parallel_display *imxpd = bridge_to_imxpd(bridge);
-
-   drm_panel_prepare(imxpd->panel);
-   drm_panel_enable(imxpd->panel);
-}
-
-static void imx_pd_bridge_disable(struct drm_bridge *bridge)
-{
-   struct imx_parallel_display *imxpd = bridge_to_imxpd(bridge);
-
-   drm_panel_disable(imxpd->panel);
-   drm_panel_unprepare(imxpd->panel);
-}
-
 static const u32 imx_pd_bus_fmts[] = {
MEDIA_BUS_FMT_RGB888_1X24,
MEDIA_BUS_FMT_BGR888_1X24,
@@ -237,8 +216,6 @@ static const struct drm_connector_helper_funcs 
imx_pd_connector_helper_funcs = {
 };
 
 static const struct drm_bridge_funcs imx_pd_bridge_funcs = {
-   .enable = imx_pd_bridge_enable,
-   .disable = imx_pd_bridge_disable,
.atomic_reset = drm_atomic_helper_bridge_reset,
.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
@@ -315,10 +292,14 @@ static int imx_pd_probe(struct platform_device *pdev)
return -ENOMEM;
 
/* port@1 is the output port */
-   ret = drm_of_find_panel_or_bridge(np, 1, 0, >panel,
- >next_bridge);
-   if (ret && ret != -ENODEV)
-   return ret;
+   imxpd->next_bridge = devm_drm_of_get_bridge(dev, np, 1, 0);
+   if (IS_ERR(imxpd->next_bridge)) {
+   ret = PTR_ERR(imxpd->next_bridge);
+   if (ret != -ENODEV)
+   return ret;
+
+   imxpd->next_bridge = NULL;
+   }
 
ret = of_property_read_string(np, "interface-pix-fmt", );
if (!ret) {

-- 
2.39.2



[PATCH v2 07/12] drm/imx: ldb: switch to drm_panel_bridge

2024-03-31 Thread Dmitry Baryshkov
Defer panel handling to drm_panel_bridge, unifying codepaths for the
panel and bridge cases.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/imx/ipuv3/Kconfig   |  2 ++
 drivers/gpu/drm/imx/ipuv3/imx-ldb.c | 44 -
 2 files changed, 16 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/imx/ipuv3/Kconfig 
b/drivers/gpu/drm/imx/ipuv3/Kconfig
index bacf0655ebaf..4e41611c8532 100644
--- a/drivers/gpu/drm/imx/ipuv3/Kconfig
+++ b/drivers/gpu/drm/imx/ipuv3/Kconfig
@@ -28,7 +28,9 @@ config DRM_IMX_LDB
tristate "Support for LVDS displays"
depends on DRM_IMX && MFD_SYSCON
depends on COMMON_CLK
+   depends on DRM_BRIDGE
select DRM_PANEL
+   select DRM_PANEL_BRIDGE
help
  Choose this to enable the internal LVDS Display Bridge (LDB)
  found on i.MX53 and i.MX6 processors.
diff --git a/drivers/gpu/drm/imx/ipuv3/imx-ldb.c 
b/drivers/gpu/drm/imx/ipuv3/imx-ldb.c
index 380edc1c4507..74b41a507219 100644
--- a/drivers/gpu/drm/imx/ipuv3/imx-ldb.c
+++ b/drivers/gpu/drm/imx/ipuv3/imx-ldb.c
@@ -28,7 +28,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -65,8 +64,6 @@ struct imx_ldb;
 struct imx_ldb_channel {
struct imx_ldb *ldb;
 
-   /* Defines what is connected to the ldb, only one at a time */
-   struct drm_panel *panel;
struct drm_bridge *bridge;
 
struct device_node *child;
@@ -136,10 +133,6 @@ static int imx_ldb_connector_get_modes(struct 
drm_connector *connector)
struct imx_ldb_channel *imx_ldb_ch = con_to_imx_ldb_ch(connector);
int num_modes;
 
-   num_modes = drm_panel_get_modes(imx_ldb_ch->panel, connector);
-   if (num_modes > 0)
-   return num_modes;
-
if (imx_ldb_ch->mode_valid) {
struct drm_display_mode *mode;
 
@@ -194,8 +187,6 @@ static void imx_ldb_encoder_enable(struct drm_encoder 
*encoder)
return;
}
 
-   drm_panel_prepare(imx_ldb_ch->panel);
-
if (dual) {
clk_set_parent(ldb->clk_sel[mux], ldb->clk[0]);
clk_set_parent(ldb->clk_sel[mux], ldb->clk[1]);
@@ -234,8 +225,6 @@ static void imx_ldb_encoder_enable(struct drm_encoder 
*encoder)
}
 
regmap_write(ldb->regmap, IOMUXC_GPR2, ldb->ldb_ctrl);
-
-   drm_panel_enable(imx_ldb_ch->panel);
 }
 
 static void
@@ -312,8 +301,6 @@ static void imx_ldb_encoder_disable(struct drm_encoder 
*encoder)
int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN;
int mux, ret;
 
-   drm_panel_disable(imx_ldb_ch->panel);
-
if (imx_ldb_ch == >channel[0] || dual)
ldb->ldb_ctrl &= ~LDB_CH0_MODE_EN_MASK;
if (imx_ldb_ch == >channel[1] || dual)
@@ -347,8 +334,6 @@ static void imx_ldb_encoder_disable(struct drm_encoder 
*encoder)
dev_err(ldb->dev,
"unable to set di%d parent clock to original parent\n",
mux);
-
-   drm_panel_unprepare(imx_ldb_ch->panel);
 }
 
 static int imx_ldb_encoder_atomic_check(struct drm_encoder *encoder,
@@ -641,13 +626,15 @@ static int imx_ldb_probe(struct platform_device *pdev)
 * The output port is port@4 with an external 4-port mux or
 * port@2 with the internal 2-port mux.
 */
-   ret = drm_of_find_panel_or_bridge(child,
- imx_ldb->lvds_mux ? 4 : 2, 0,
- >panel, 
>bridge);
-   if (ret && ret != -ENODEV)
-   goto free_child;
+   channel->bridge = devm_drm_of_get_bridge(dev, child,
+   imx_ldb->lvds_mux ? 4 : 2, 0);
+   if (IS_ERR(channel->bridge)) {
+   ret = PTR_ERR(channel->bridge);
+   if (ret != -ENODEV)
+   goto free_child;
+
+   channel->bridge = NULL;
 
-   if (!channel->bridge && !channel->panel) {
ret = of_get_drm_display_mode(child,
  >mode,
  >bus_flags,
@@ -659,15 +646,12 @@ static int imx_ldb_probe(struct platform_device *pdev)
}
 
bus_format = of_get_bus_format(dev, child);
-   if (bus_format == -EINVAL) {
-   /*
-* If no bus format was specified in the device tree,
-* we can still get it from the connected panel later.
-*/
-   if (channel->panel && channel->panel->funcs &&
-   channel->panel->funcs->get_modes)
-   bus_format = 0;
-   }
+   /*
+* If no bus format was specified in the device tree,
+ 

[PATCH v2 02/12] dt-bindings: display: imx/ldb: drop ddc-i2c-bus property

2024-03-31 Thread Dmitry Baryshkov
The in-kernel DT files do not use ddc-i2c-bus property with the iMX LVDS
Display Bridge. If in future a need arises to support such usecase, the
panel-simple should be used, which is able to handle the DDC bus.

Acked-by: Rob Herring 
Signed-off-by: Dmitry Baryshkov 
---
 Documentation/devicetree/bindings/display/imx/ldb.txt | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/display/imx/ldb.txt 
b/Documentation/devicetree/bindings/display/imx/ldb.txt
index 8e6e7d797943..03653a291b54 100644
--- a/Documentation/devicetree/bindings/display/imx/ldb.txt
+++ b/Documentation/devicetree/bindings/display/imx/ldb.txt
@@ -62,7 +62,6 @@ Required properties:
display-timings are used instead.
 
 Optional properties (required if display-timings are used):
- - ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing
  - display-timings : A node that describes the display timings as defined in
Documentation/devicetree/bindings/display/panel/display-timing.txt.
  - fsl,data-mapping : should be "spwg" or "jeida"

-- 
2.39.2



[PATCH v2 01/12] dt-bindings: display: fsl-imx-drm: drop edid property support

2024-03-31 Thread Dmitry Baryshkov
None of the in-kernel DT files ever used edid override with the
fsl-imx-drm driver. In case the EDID needs to be specified manually, DRM
core allows one to either override it via the debugfs or to load it via
request_firmware by using DRM_LOAD_EDID_FIRMWARE. In all other cases
EDID and/or modes are to be provided as a part of the panel driver.

Drop the edid property from the fsl-imx-drm bindings.

Acked-by: Rob Herring 
Signed-off-by: Dmitry Baryshkov 
---
 Documentation/devicetree/bindings/display/imx/fsl-imx-drm.txt | 2 --
 1 file changed, 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/imx/fsl-imx-drm.txt 
b/Documentation/devicetree/bindings/display/imx/fsl-imx-drm.txt
index 3c35338a2867..269b1ae2fca9 100644
--- a/Documentation/devicetree/bindings/display/imx/fsl-imx-drm.txt
+++ b/Documentation/devicetree/bindings/display/imx/fsl-imx-drm.txt
@@ -119,7 +119,6 @@ Optional properties:
 - interface-pix-fmt: How this display is connected to the
   display interface. Currently supported types: "rgb24", "rgb565", "bgr666"
   and "lvds666".
-- edid: verbatim EDID data block describing attached display.
 - ddc: phandle describing the i2c bus handling the display data
   channel
 - port@[0-1]: Port nodes with endpoint definitions as defined in
@@ -131,7 +130,6 @@ example:
 
 disp0 {
compatible = "fsl,imx-parallel-display";
-   edid = [edid-data];
interface-pix-fmt = "rgb24";
 
port@0 {

-- 
2.39.2



[PATCH v2 06/12] drm/imx: ldb: drop custom DDC bus support

2024-03-31 Thread Dmitry Baryshkov
None of the boards ever supported by the upstream kernel used the custom
DDC bus support with the LDB connector. If a need arises to do so, one
should use panel-simple and its DDC bus code. Drop ddc-i2c-bus support
from the imx-ldb driver.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/imx/ipuv3/imx-ldb.c | 72 ++---
 1 file changed, 10 insertions(+), 62 deletions(-)

diff --git a/drivers/gpu/drm/imx/ipuv3/imx-ldb.c 
b/drivers/gpu/drm/imx/ipuv3/imx-ldb.c
index 1924d8921c62..380edc1c4507 100644
--- a/drivers/gpu/drm/imx/ipuv3/imx-ldb.c
+++ b/drivers/gpu/drm/imx/ipuv3/imx-ldb.c
@@ -70,7 +70,6 @@ struct imx_ldb_channel {
struct drm_bridge *bridge;
 
struct device_node *child;
-   struct i2c_adapter *ddc;
int chno;
struct drm_display_mode mode;
int mode_valid;
@@ -141,18 +140,6 @@ static int imx_ldb_connector_get_modes(struct 
drm_connector *connector)
if (num_modes > 0)
return num_modes;
 
-   if (imx_ldb_ch->ddc) {
-   const struct drm_edid *edid = drm_edid_read_ddc(connector,
-   
imx_ldb_ch->ddc);
-
-   if (edid) {
-   drm_edid_connector_update(connector, edid);
-   drm_edid_free(edid);
-
-   return drm_edid_connector_add_modes(connector);
-   }
-   }
-
if (imx_ldb_ch->mode_valid) {
struct drm_display_mode *mode;
 
@@ -481,10 +468,9 @@ static int imx_ldb_register(struct drm_device *drm,
 */
drm_connector_helper_add(connector,
 _ldb_connector_helper_funcs);
-   drm_connector_init_with_ddc(drm, connector,
-   _ldb_connector_funcs,
-   DRM_MODE_CONNECTOR_LVDS,
-   imx_ldb_ch->ddc);
+   drm_connector_init(drm, connector,
+  _ldb_connector_funcs,
+  DRM_MODE_CONNECTOR_LVDS);
drm_connector_attach_encoder(connector, encoder);
}
 
@@ -551,39 +537,6 @@ static const struct of_device_id imx_ldb_dt_ids[] = {
 };
 MODULE_DEVICE_TABLE(of, imx_ldb_dt_ids);
 
-static int imx_ldb_panel_ddc(struct device *dev,
-   struct imx_ldb_channel *channel, struct device_node *child)
-{
-   struct device_node *ddc_node;
-   int ret;
-
-   ddc_node = of_parse_phandle(child, "ddc-i2c-bus", 0);
-   if (ddc_node) {
-   channel->ddc = of_find_i2c_adapter_by_node(ddc_node);
-   of_node_put(ddc_node);
-   if (!channel->ddc) {
-   dev_warn(dev, "failed to get ddc i2c adapter\n");
-   return -EPROBE_DEFER;
-   }
-   }
-
-   if (!channel->ddc) {
-   /* if no DDC available, fallback to hardcoded EDID */
-   dev_dbg(dev, "no ddc available\n");
-
-   if (!channel->panel) {
-   /* fallback to display-timings node */
-   ret = of_get_drm_display_mode(child,
- >mode,
- >bus_flags,
- OF_USE_NATIVE_MODE);
-   if (!ret)
-   channel->mode_valid = 1;
-   }
-   }
-   return 0;
-}
-
 static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
 {
struct drm_device *drm = data;
@@ -694,11 +647,15 @@ static int imx_ldb_probe(struct platform_device *pdev)
if (ret && ret != -ENODEV)
goto free_child;
 
-   /* panel ddc only if there is no bridge */
-   if (!channel->bridge) {
-   ret = imx_ldb_panel_ddc(dev, channel, child);
+   if (!channel->bridge && !channel->panel) {
+   ret = of_get_drm_display_mode(child,
+ >mode,
+ >bus_flags,
+ OF_USE_NATIVE_MODE);
if (ret)
goto free_child;
+
+   channel->mode_valid = 1;
}
 
bus_format = of_get_bus_format(dev, child);
@@ -732,15 +689,6 @@ static int imx_ldb_probe(struct platform_device *pdev)
 
 static void imx_ldb_remove(struct platform_device *pdev)
 {
-   struct imx_ldb *imx_ldb = platform_get_drvdata(pdev);
-   int i;
-
-   for (i = 0; i < 2; i++) {
-   struct imx_ldb_channel *channel = _ldb->channel[i];
-
-   i2c_put_adapter(channel->ddc);
-   }
-
component_del(>dev, 

[PATCH v2 04/12] drm/imx: parallel-display: drop edid override support

2024-03-31 Thread Dmitry Baryshkov
None of the in-kernel DT files ever used edid override with the
fsl-imx-drm driver. In case the EDID needs to be specified manually, DRM
core allows one to either override it via the debugfs or to load it via
request_firmware by using DRM_LOAD_EDID_FIRMWARE. In all other cases
EDID and/or modes are to be provided as a part of the panel driver.

Drop support for the edid property.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/imx/ipuv3/parallel-display.c | 13 -
 1 file changed, 13 deletions(-)

diff --git a/drivers/gpu/drm/imx/ipuv3/parallel-display.c 
b/drivers/gpu/drm/imx/ipuv3/parallel-display.c
index 55dedd73f528..4d17fb96e77c 100644
--- a/drivers/gpu/drm/imx/ipuv3/parallel-display.c
+++ b/drivers/gpu/drm/imx/ipuv3/parallel-display.c
@@ -16,7 +16,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -34,7 +33,6 @@ struct imx_parallel_display_encoder {
 
 struct imx_parallel_display {
struct device *dev;
-   void *edid;
u32 bus_format;
u32 bus_flags;
struct drm_display_mode mode;
@@ -62,11 +60,6 @@ static int imx_pd_connector_get_modes(struct drm_connector 
*connector)
if (num_modes > 0)
return num_modes;
 
-   if (imxpd->edid) {
-   drm_connector_update_edid_property(connector, imxpd->edid);
-   num_modes = drm_add_edid_modes(connector, imxpd->edid);
-   }
-
if (np) {
struct drm_display_mode *mode = drm_mode_create(connector->dev);
int ret;
@@ -312,9 +305,7 @@ static int imx_pd_probe(struct platform_device *pdev)
 {
struct device *dev = >dev;
struct device_node *np = dev->of_node;
-   const u8 *edidp;
struct imx_parallel_display *imxpd;
-   int edid_len;
int ret;
u32 bus_format = 0;
const char *fmt;
@@ -329,10 +320,6 @@ static int imx_pd_probe(struct platform_device *pdev)
if (ret && ret != -ENODEV)
return ret;
 
-   edidp = of_get_property(np, "edid", _len);
-   if (edidp)
-   imxpd->edid = devm_kmemdup(dev, edidp, edid_len, GFP_KERNEL);
-
ret = of_property_read_string(np, "interface-pix-fmt", );
if (!ret) {
if (!strcmp(fmt, "rgb24"))

-- 
2.39.2



[PATCH v2 00/12] drm/imx/ipuv3: switch LDB and parallel-display driver to use drm_bridge_connector

2024-03-31 Thread Dmitry Baryshkov
The IPUv3 DRM i.MX driver contains several codepaths for different
usescases: both LDB and paralllel-display drivers handle next-bridge,
panel and the legacy display-timings DT node on their own.

Drop unused ddc-i2c-bus and edid handling (none of the DT files merged
upstream ever used these features), switch to panel-bridge driver,
removing the need to handle drm_panel codepaths separately and finally
switch to drm_bridge_connector, removing requirement for the downstream
bridges to create drm_connector on their own.

This has been tested on the iMX53 with the DPI panel attached to LDB via
LVDS decoder, using all possible usecases (lvds-codec + panel, panel
linked directly to LDB node and the display-timings node).

Signed-off-by: Dmitry Baryshkov 
---
Changes in v2:
- Fixed drm_bridge_attach flags in imx/parallel-display driver.
- Moved the legacy bridge to drivers/gpu/drm/bridge
- Added missing EXPORT_SYMBOL_GPL to the iMX legacy bridge
- Link to v1: 
https://lore.kernel.org/r/20240311-drm-imx-cleanup-v1-0-e104f05ca...@linaro.org

---
Dmitry Baryshkov (12):
  dt-bindings: display: fsl-imx-drm: drop edid property support
  dt-bindings: display: imx/ldb: drop ddc-i2c-bus property
  drm/imx: cleanup the imx-drm header
  drm/imx: parallel-display: drop edid override support
  drm/imx: ldb: drop custom EDID support
  drm/imx: ldb: drop custom DDC bus support
  drm/imx: ldb: switch to drm_panel_bridge
  drm/imx: parallel-display: switch to drm_panel_bridge
  drm/imx: add internal bridge handling display-timings DT node
  drm/imx: ldb: switch to imx_legacy_bridge / drm_bridge_connector
  drm/imx: parallel-display: switch to imx_legacy_bridge / 
drm_bridge_connector
  drm/imx: move imx_drm_connector_destroy to imx-tve

 .../bindings/display/imx/fsl-imx-drm.txt   |   2 -
 .../devicetree/bindings/display/imx/ldb.txt|   1 -
 drivers/gpu/drm/bridge/imx/Kconfig |  10 +
 drivers/gpu/drm/bridge/imx/Makefile|   1 +
 drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c |  85 +
 drivers/gpu/drm/imx/ipuv3/Kconfig  |   5 +
 drivers/gpu/drm/imx/ipuv3/imx-drm-core.c   |   7 -
 drivers/gpu/drm/imx/ipuv3/imx-drm.h|  14 --
 drivers/gpu/drm/imx/ipuv3/imx-ldb.c| 202 +
 drivers/gpu/drm/imx/ipuv3/imx-tve.c|   8 +-
 drivers/gpu/drm/imx/ipuv3/parallel-display.c   | 137 +++---
 include/drm/bridge/imx.h   |  13 ++
 12 files changed, 184 insertions(+), 301 deletions(-)
---
base-commit: 13ee4a7161b6fd938aef6688ff43b163f6d83e37
change-id: 20240310-drm-imx-cleanup-10746a9b71f5

Best regards,
-- 
Dmitry Baryshkov 



Re: [PATCH] drm/display: fix typo

2024-03-31 Thread Oleksandr Natalenko
On sobota 20. ledna 2024 7:44:45, CEST Randy Dunlap wrote:
> 
> On 1/19/24 02:22, Oleksandr Natalenko wrote:
> > While studying the code I've bumped into a small typo within the
> > kernel-doc for two functions, apparently, due to copy-paste.
> > 
> > This commit fixes "sizo" word to be "size".
> > 
> > Signed-off-by: Oleksandr Natalenko 
> 
> Acked-by: Randy Dunlap 
> 
> Thanks.
> 
> > ---
> >  drivers/gpu/drm/display/drm_dp_dual_mode_helper.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/display/drm_dp_dual_mode_helper.c 
> > b/drivers/gpu/drm/display/drm_dp_dual_mode_helper.c
> > index bd61e20770a5b..14a2a8473682b 100644
> > --- a/drivers/gpu/drm/display/drm_dp_dual_mode_helper.c
> > +++ b/drivers/gpu/drm/display/drm_dp_dual_mode_helper.c
> > @@ -52,7 +52,7 @@
> >   * @adapter: I2C adapter for the DDC bus
> >   * @offset: register offset
> >   * @buffer: buffer for return data
> > - * @size: sizo of the buffer
> > + * @size: size of the buffer
> >   *
> >   * Reads @size bytes from the DP dual mode adaptor registers
> >   * starting at @offset.
> > @@ -116,7 +116,7 @@ EXPORT_SYMBOL(drm_dp_dual_mode_read);
> >   * @adapter: I2C adapter for the DDC bus
> >   * @offset: register offset
> >   * @buffer: buffer for write data
> > - * @size: sizo of the buffer
> > + * @size: size of the buffer
> >   *
> >   * Writes @size bytes to the DP dual mode adaptor registers
> >   * starting at @offset.
> 
> 

Gentle ping. I don't see this change in linux-next, so probably it got lost.

-- 
Oleksandr Natalenko (post-factum)

signature.asc
Description: This is a digitally signed message part.


Re: [PATCH v2 11/25] firmware: arm_scmi: virtio: drop owner assignment

2024-03-31 Thread Sudeep Holla
On Sun, Mar 31, 2024 at 10:43:58AM +0200, Krzysztof Kozlowski wrote:
> virtio core already sets the .owner, so driver does not need to.
>

Acked-by: Sudeep Holla 

-- 
Regards,
Sudeep


Re: [PATCH v2 21/25] nvdimm: virtio_pmem: drop owner assignment

2024-03-31 Thread Pankaj Gupta
virtio core already sets the .owner, so driver does not need to.
>
> Acked-by: Dave Jiang 
> Signed-off-by: Krzysztof Kozlowski 
>
Reviewed-by: Pankaj Gupta 
> Depends on the first patch.
> ---
>  drivers/nvdimm/virtio_pmem.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/drivers/nvdimm/virtio_pmem.c b/drivers/nvdimm/virtio_pmem.c
> index 4ceced5cefcf..c9b97aeabf85 100644
> --- a/drivers/nvdimm/virtio_pmem.c
> +++ b/drivers/nvdimm/virtio_pmem.c
> @@ -151,7 +151,6 @@ static struct virtio_driver virtio_pmem_driver = {
> .feature_table  = features,
> .feature_table_size = ARRAY_SIZE(features),
> .driver.name= KBUILD_MODNAME,
> -   .driver.owner   = THIS_MODULE,
> .id_table   = id_table,
> .validate   = virtio_pmem_validate,
> .probe  = virtio_pmem_probe,
>
> --
> 2.34.1
>
>


Re: [PATCH 01/22] virtio: store owner from modules with register_virtio_driver()

2024-03-31 Thread Michael S. Tsirkin
On Wed, Mar 27, 2024 at 01:40:54PM +0100, Krzysztof Kozlowski wrote:
> Modules registering driver with register_virtio_driver() might forget to
> set .owner field.  i2c-virtio.c for example has it missing.  The field
> is used by some of other kernel parts for reference counting
> (try_module_get()), so it is expected that drivers will set it.
> 
> Solve the problem by moving this task away from the drivers to the core
> amba bus code, just like we did for platform_driver in
> commit 9447057eaff8 ("platform_device: use a macro instead of
> platform_driver_register").
> 
> Signed-off-by: Krzysztof Kozlowski 



This makes sense. So this will be:

Fixes: 3cfc88380413 ("i2c: virtio: add a virtio i2c frontend driver")
Cc: "Jie Deng" 

and I think I will pick this patch for this cycle to fix
the bug. The cleanups can go in the next cycle.


> ---
>  Documentation/driver-api/virtio/writing_virtio_drivers.rst | 1 -
>  drivers/virtio/virtio.c| 6 --
>  include/linux/virtio.h | 7 +--
>  3 files changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/Documentation/driver-api/virtio/writing_virtio_drivers.rst 
> b/Documentation/driver-api/virtio/writing_virtio_drivers.rst
> index e14c58796d25..e5de6f5d061a 100644
> --- a/Documentation/driver-api/virtio/writing_virtio_drivers.rst
> +++ b/Documentation/driver-api/virtio/writing_virtio_drivers.rst
> @@ -97,7 +97,6 @@ like this::
>  
>   static struct virtio_driver virtio_dummy_driver = {
>   .driver.name =  KBUILD_MODNAME,
> - .driver.owner = THIS_MODULE,
>   .id_table = id_table,
>   .probe =virtio_dummy_probe,
>   .remove =   virtio_dummy_remove,
> diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
> index f173587893cb..9510c551dce8 100644
> --- a/drivers/virtio/virtio.c
> +++ b/drivers/virtio/virtio.c
> @@ -362,14 +362,16 @@ static const struct bus_type virtio_bus = {
>   .remove = virtio_dev_remove,
>  };
>  
> -int register_virtio_driver(struct virtio_driver *driver)
> +int __register_virtio_driver(struct virtio_driver *driver, struct module 
> *owner)
>  {
>   /* Catch this early. */
>   BUG_ON(driver->feature_table_size && !driver->feature_table);
>   driver->driver.bus = _bus;
> + driver->driver.owner = owner;
> +
>   return driver_register(>driver);
>  }
> -EXPORT_SYMBOL_GPL(register_virtio_driver);
> +EXPORT_SYMBOL_GPL(__register_virtio_driver);
>  
>  void unregister_virtio_driver(struct virtio_driver *driver)
>  {
> diff --git a/include/linux/virtio.h b/include/linux/virtio.h
> index b0201747a263..26c4325aa373 100644
> --- a/include/linux/virtio.h
> +++ b/include/linux/virtio.h
> @@ -170,7 +170,7 @@ size_t virtio_max_dma_size(const struct virtio_device 
> *vdev);
>  
>  /**
>   * struct virtio_driver - operations for a virtio I/O driver
> - * @driver: underlying device driver (populate name and owner).
> + * @driver: underlying device driver (populate name).
>   * @id_table: the ids serviced by this driver.
>   * @feature_table: an array of feature numbers supported by this driver.
>   * @feature_table_size: number of entries in the feature table array.
> @@ -208,7 +208,10 @@ static inline struct virtio_driver *drv_to_virtio(struct 
> device_driver *drv)
>   return container_of(drv, struct virtio_driver, driver);
>  }
>  
> -int register_virtio_driver(struct virtio_driver *drv);
> +/* use a macro to avoid include chaining to get THIS_MODULE */
> +#define register_virtio_driver(drv) \
> + __register_virtio_driver(drv, THIS_MODULE)
> +int __register_virtio_driver(struct virtio_driver *drv, struct module 
> *owner);
>  void unregister_virtio_driver(struct virtio_driver *drv);
>  
>  /* module_virtio_driver() - Helper macro for drivers that don't do
> 
> -- 
> 2.34.1



[PATCH v2 25/25] sound: virtio: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Signed-off-by: Krzysztof Kozlowski 

---

Depends on the first patch.
---
 sound/virtio/virtio_card.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sound/virtio/virtio_card.c b/sound/virtio/virtio_card.c
index 2da20c625247..7805daea0102 100644
--- a/sound/virtio/virtio_card.c
+++ b/sound/virtio/virtio_card.c
@@ -438,7 +438,6 @@ static unsigned int features[] = {
 
 static struct virtio_driver virtsnd_driver = {
.driver.name = KBUILD_MODNAME,
-   .driver.owner = THIS_MODULE,
.id_table = id_table,
.feature_table = features,
.feature_table_size = ARRAY_SIZE(features),

-- 
2.34.1



[PATCH v2 24/25] fuse: virtio: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Signed-off-by: Krzysztof Kozlowski 

---

Depends on the first patch.
---
 fs/fuse/virtio_fs.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
index 322af827a232..ca7b64f9c3c7 100644
--- a/fs/fuse/virtio_fs.c
+++ b/fs/fuse/virtio_fs.c
@@ -1023,7 +1023,6 @@ static const unsigned int feature_table[] = {};
 
 static struct virtio_driver virtio_fs_driver = {
.driver.name= KBUILD_MODNAME,
-   .driver.owner   = THIS_MODULE,
.id_table   = id_table,
.feature_table  = feature_table,
.feature_table_size = ARRAY_SIZE(feature_table),

-- 
2.34.1



[PATCH v2 20/25] wifi: mac80211_hwsim: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Signed-off-by: Krzysztof Kozlowski 

---

Depends on the first patch.
---
 drivers/net/wireless/virtual/mac80211_hwsim.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/wireless/virtual/mac80211_hwsim.c 
b/drivers/net/wireless/virtual/mac80211_hwsim.c
index b55fe320633c..ef38b7cc9fdf 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim.c
@@ -6662,7 +6662,6 @@ MODULE_DEVICE_TABLE(virtio, id_table);
 
 static struct virtio_driver virtio_hwsim = {
.driver.name = KBUILD_MODNAME,
-   .driver.owner = THIS_MODULE,
.id_table = id_table,
.probe = hwsim_virtio_probe,
.remove = hwsim_virtio_remove,

-- 
2.34.1



[PATCH v2 22/25] rpmsg: virtio: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Reviewed-by: Mathieu Poirier 
Signed-off-by: Krzysztof Kozlowski 
---

Depends on the first patch.
---
 drivers/rpmsg/virtio_rpmsg_bus.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
index 1062939c3264..e9e8c1f7829f 100644
--- a/drivers/rpmsg/virtio_rpmsg_bus.c
+++ b/drivers/rpmsg/virtio_rpmsg_bus.c
@@ -1053,7 +1053,6 @@ static struct virtio_driver virtio_ipc_driver = {
.feature_table  = features,
.feature_table_size = ARRAY_SIZE(features),
.driver.name= KBUILD_MODNAME,
-   .driver.owner   = THIS_MODULE,
.id_table   = id_table,
.probe  = rpmsg_probe,
.remove = rpmsg_remove,

-- 
2.34.1



[PATCH v2 18/25] net: 9p: virtio: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Signed-off-by: Krzysztof Kozlowski 

---

Depends on the first patch.
---
 net/9p/trans_virtio.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index e305071eb7b8..0b8086f58ad5 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -781,7 +781,6 @@ static struct virtio_driver p9_virtio_drv = {
.feature_table  = features,
.feature_table_size = ARRAY_SIZE(features),
.driver.name= KBUILD_MODNAME,
-   .driver.owner   = THIS_MODULE,
.id_table   = id_table,
.probe  = p9_virtio_probe,
.remove = p9_virtio_remove,

-- 
2.34.1



[PATCH v2 19/25] vsock/virtio: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Acked-by: Stefano Garzarella 
Signed-off-by: Krzysztof Kozlowski 
---

Depends on the first patch.
---
 net/vmw_vsock/virtio_transport.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c
index 1748268e0694..13f42a62b034 100644
--- a/net/vmw_vsock/virtio_transport.c
+++ b/net/vmw_vsock/virtio_transport.c
@@ -858,7 +858,6 @@ static struct virtio_driver virtio_vsock_driver = {
.feature_table = features,
.feature_table_size = ARRAY_SIZE(features),
.driver.name = KBUILD_MODNAME,
-   .driver.owner = THIS_MODULE,
.id_table = id_table,
.probe = virtio_vsock_probe,
.remove = virtio_vsock_remove,

-- 
2.34.1



[PATCH v2 23/25] scsi: virtio: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Signed-off-by: Krzysztof Kozlowski 

---

Depends on the first patch.
---
 drivers/scsi/virtio_scsi.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 617eb892f4ad..89ca26945721 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -1052,7 +1052,6 @@ static struct virtio_driver virtio_scsi_driver = {
.feature_table = features,
.feature_table_size = ARRAY_SIZE(features),
.driver.name = KBUILD_MODNAME,
-   .driver.owner = THIS_MODULE,
.id_table = id_table,
.probe = virtscsi_probe,
 #ifdef CONFIG_PM_SLEEP

-- 
2.34.1



[PATCH v2 21/25] nvdimm: virtio_pmem: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Acked-by: Dave Jiang 
Signed-off-by: Krzysztof Kozlowski 
---

Depends on the first patch.
---
 drivers/nvdimm/virtio_pmem.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/nvdimm/virtio_pmem.c b/drivers/nvdimm/virtio_pmem.c
index 4ceced5cefcf..c9b97aeabf85 100644
--- a/drivers/nvdimm/virtio_pmem.c
+++ b/drivers/nvdimm/virtio_pmem.c
@@ -151,7 +151,6 @@ static struct virtio_driver virtio_pmem_driver = {
.feature_table  = features,
.feature_table_size = ARRAY_SIZE(features),
.driver.name= KBUILD_MODNAME,
-   .driver.owner   = THIS_MODULE,
.id_table   = id_table,
.validate   = virtio_pmem_validate,
.probe  = virtio_pmem_probe,

-- 
2.34.1



[PATCH v2 17/25] net: virtio: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Signed-off-by: Krzysztof Kozlowski 

---

Depends on the first patch.
---
 drivers/net/virtio_net.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index c22d1118a133..61f680699648 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -5021,7 +5021,6 @@ static struct virtio_driver virtio_net_driver = {
.feature_table_legacy = features_legacy,
.feature_table_size_legacy = ARRAY_SIZE(features_legacy),
.driver.name =  KBUILD_MODNAME,
-   .driver.owner = THIS_MODULE,
.id_table = id_table,
.validate = virtnet_validate,
.probe =virtnet_probe,

-- 
2.34.1



[PATCH v2 16/25] net: caif: virtio: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Signed-off-by: Krzysztof Kozlowski 

---

Depends on the first patch.
---
 drivers/net/caif/caif_virtio.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/caif/caif_virtio.c b/drivers/net/caif/caif_virtio.c
index 0b0f234b0b50..99d984851fef 100644
--- a/drivers/net/caif/caif_virtio.c
+++ b/drivers/net/caif/caif_virtio.c
@@ -782,7 +782,6 @@ static struct virtio_driver caif_virtio_driver = {
.feature_table  = features,
.feature_table_size = ARRAY_SIZE(features),
.driver.name= KBUILD_MODNAME,
-   .driver.owner   = THIS_MODULE,
.id_table   = id_table,
.probe  = cfv_probe,
.remove = cfv_remove,

-- 
2.34.1



[PATCH v2 15/25] misc: nsm: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Signed-off-by: Krzysztof Kozlowski 

---

Depends on the first patch.
---
 drivers/misc/nsm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/misc/nsm.c b/drivers/misc/nsm.c
index 0eaa3b4484bd..ef7b32742340 100644
--- a/drivers/misc/nsm.c
+++ b/drivers/misc/nsm.c
@@ -494,7 +494,6 @@ static struct virtio_driver virtio_nsm_driver = {
.feature_table_legacy  = 0,
.feature_table_size_legacy = 0,
.driver.name   = KBUILD_MODNAME,
-   .driver.owner  = THIS_MODULE,
.id_table  = id_table,
.probe = nsm_device_probe,
.remove= nsm_device_remove,

-- 
2.34.1



[PATCH v2 14/25] iommu: virtio: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Signed-off-by: Krzysztof Kozlowski 

---

Depends on the first patch.
---
 drivers/iommu/virtio-iommu.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c
index 04048f64a2c0..9ed8958a42bf 100644
--- a/drivers/iommu/virtio-iommu.c
+++ b/drivers/iommu/virtio-iommu.c
@@ -1261,7 +1261,6 @@ MODULE_DEVICE_TABLE(virtio, id_table);
 
 static struct virtio_driver virtio_iommu_drv = {
.driver.name= KBUILD_MODNAME,
-   .driver.owner   = THIS_MODULE,
.id_table   = id_table,
.feature_table  = features,
.feature_table_size = ARRAY_SIZE(features),

-- 
2.34.1



[PATCH v2 13/25] drm/virtio: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Signed-off-by: Krzysztof Kozlowski 

---

Depends on the first patch.
---
 drivers/gpu/drm/virtio/virtgpu_drv.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c 
b/drivers/gpu/drm/virtio/virtgpu_drv.c
index 9539aa28937f..188e126383c2 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.c
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
@@ -154,7 +154,6 @@ static struct virtio_driver virtio_gpu_driver = {
.feature_table = features,
.feature_table_size = ARRAY_SIZE(features),
.driver.name = KBUILD_MODNAME,
-   .driver.owner = THIS_MODULE,
.id_table = id_table,
.probe = virtio_gpu_probe,
.remove = virtio_gpu_remove,

-- 
2.34.1



[PATCH v2 10/25] crypto: virtio - drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Signed-off-by: Krzysztof Kozlowski 

---

Depends on the first patch.
---
 drivers/crypto/virtio/virtio_crypto_core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/crypto/virtio/virtio_crypto_core.c 
b/drivers/crypto/virtio/virtio_crypto_core.c
index 6a67d70e7f1c..30cd040aa03b 100644
--- a/drivers/crypto/virtio/virtio_crypto_core.c
+++ b/drivers/crypto/virtio/virtio_crypto_core.c
@@ -581,7 +581,6 @@ static const struct virtio_device_id id_table[] = {
 
 static struct virtio_driver virtio_crypto_driver = {
.driver.name = KBUILD_MODNAME,
-   .driver.owner= THIS_MODULE,
.feature_table   = features,
.feature_table_size  = ARRAY_SIZE(features),
.id_table= id_table,

-- 
2.34.1



[PATCH v2 12/25] gpio: virtio: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Acked-by: Bartosz Golaszewski 
Acked-by: Viresh Kumar 
Signed-off-by: Krzysztof Kozlowski 
---

Depends on the first patch.
---
 drivers/gpio/gpio-virtio.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpio/gpio-virtio.c b/drivers/gpio/gpio-virtio.c
index fcc5e8c08973..9fae8e396c58 100644
--- a/drivers/gpio/gpio-virtio.c
+++ b/drivers/gpio/gpio-virtio.c
@@ -653,7 +653,6 @@ static struct virtio_driver virtio_gpio_driver = {
.remove = virtio_gpio_remove,
.driver = {
.name   = KBUILD_MODNAME,
-   .owner  = THIS_MODULE,
},
 };
 module_virtio_driver(virtio_gpio_driver);

-- 
2.34.1



[PATCH v2 11/25] firmware: arm_scmi: virtio: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Signed-off-by: Krzysztof Kozlowski 

---

Depends on the first patch.
---
 drivers/firmware/arm_scmi/virtio.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/firmware/arm_scmi/virtio.c 
b/drivers/firmware/arm_scmi/virtio.c
index d68c01cb7aa0..4892058445ce 100644
--- a/drivers/firmware/arm_scmi/virtio.c
+++ b/drivers/firmware/arm_scmi/virtio.c
@@ -908,7 +908,6 @@ static const struct virtio_device_id id_table[] = {
 
 static struct virtio_driver virtio_scmi_driver = {
.driver.name = "scmi-virtio",
-   .driver.owner = THIS_MODULE,
.feature_table = features,
.feature_table_size = ARRAY_SIZE(features),
.id_table = id_table,

-- 
2.34.1



[PATCH v2 09/25] virtio_console: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Signed-off-by: Krzysztof Kozlowski 

---

Depends on the first patch.
---
 drivers/char/virtio_console.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 035f89f1a251..d9ee2dbc7eab 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -2173,7 +2173,6 @@ static struct virtio_driver virtio_console = {
.feature_table = features,
.feature_table_size = ARRAY_SIZE(features),
.driver.name =  KBUILD_MODNAME,
-   .driver.owner = THIS_MODULE,
.id_table = id_table,
.probe =virtcons_probe,
.remove =   virtcons_remove,
@@ -2188,7 +2187,6 @@ static struct virtio_driver virtio_rproc_serial = {
.feature_table = rproc_serial_features,
.feature_table_size = ARRAY_SIZE(rproc_serial_features),
.driver.name =  "virtio_rproc_serial",
-   .driver.owner = THIS_MODULE,
.id_table = rproc_serial_id_table,
.probe =virtcons_probe,
.remove =   virtcons_remove,

-- 
2.34.1



[PATCH v2 08/25] hwrng: virtio: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Signed-off-by: Krzysztof Kozlowski 

---

Depends on the first patch.
---
 drivers/char/hw_random/virtio-rng.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/char/hw_random/virtio-rng.c 
b/drivers/char/hw_random/virtio-rng.c
index 7a4b45393acb..dd998f4fe4f2 100644
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@ -245,7 +245,6 @@ static const struct virtio_device_id id_table[] = {
 
 static struct virtio_driver virtio_rng_driver = {
.driver.name =  KBUILD_MODNAME,
-   .driver.owner = THIS_MODULE,
.id_table = id_table,
.probe =virtrng_probe,
.remove =   virtrng_remove,

-- 
2.34.1



[PATCH v2 07/25] bluetooth: virtio: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Signed-off-by: Krzysztof Kozlowski 

---

Depends on the first patch.
---
 drivers/bluetooth/virtio_bt.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/bluetooth/virtio_bt.c b/drivers/bluetooth/virtio_bt.c
index 2ac70b560c46..463b49ca2492 100644
--- a/drivers/bluetooth/virtio_bt.c
+++ b/drivers/bluetooth/virtio_bt.c
@@ -417,7 +417,6 @@ static const unsigned int virtbt_features[] = {
 
 static struct virtio_driver virtbt_driver = {
.driver.name = KBUILD_MODNAME,
-   .driver.owner= THIS_MODULE,
.feature_table   = virtbt_features,
.feature_table_size  = ARRAY_SIZE(virtbt_features),
.id_table= virtbt_table,

-- 
2.34.1



[PATCH v2 06/25] virtio_blk: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Signed-off-by: Krzysztof Kozlowski 

---

Depends on the first patch.
---
 drivers/block/virtio_blk.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 42dea7601d87..46bdbad1ab48 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -1658,7 +1658,6 @@ static struct virtio_driver virtio_blk = {
.feature_table_legacy   = features_legacy,
.feature_table_size_legacy  = ARRAY_SIZE(features_legacy),
.driver.name= KBUILD_MODNAME,
-   .driver.owner   = THIS_MODULE,
.id_table   = id_table,
.probe  = virtblk_probe,
.remove = virtblk_remove,

-- 
2.34.1



[PATCH v2 05/25] um: virt-pci: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Acked-by: Johannes Berg 
Signed-off-by: Krzysztof Kozlowski 
---

Depends on the first patch.
---
 arch/um/drivers/virt-pci.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/um/drivers/virt-pci.c b/arch/um/drivers/virt-pci.c
index 97a37c062997..7cb503469bbd 100644
--- a/arch/um/drivers/virt-pci.c
+++ b/arch/um/drivers/virt-pci.c
@@ -752,7 +752,6 @@ MODULE_DEVICE_TABLE(virtio, id_table);
 
 static struct virtio_driver um_pci_virtio_driver = {
.driver.name = "virtio-pci",
-   .driver.owner = THIS_MODULE,
.id_table = id_table,
.probe = um_pci_virtio_probe,
.remove = um_pci_virtio_remove,

-- 
2.34.1



[PATCH v2 04/25] virtio: mem: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Signed-off-by: Krzysztof Kozlowski 

---

Changes in v2:
1. New patch
---
 drivers/virtio/virtio_mem.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c
index e8355f55a8f7..e605d906639f 100644
--- a/drivers/virtio/virtio_mem.c
+++ b/drivers/virtio/virtio_mem.c
@@ -2991,7 +2991,6 @@ static struct virtio_driver virtio_mem_driver = {
.feature_table = virtio_mem_features,
.feature_table_size = ARRAY_SIZE(virtio_mem_features),
.driver.name = KBUILD_MODNAME,
-   .driver.owner = THIS_MODULE,
.id_table = virtio_mem_id_table,
.probe = virtio_mem_probe,
.remove = virtio_mem_remove,

-- 
2.34.1



[PATCH v2 03/25] virtio: input: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Signed-off-by: Krzysztof Kozlowski 

---

Changes in v2:
1. New patch
---
 drivers/virtio/virtio_input.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/virtio/virtio_input.c b/drivers/virtio/virtio_input.c
index 3aa46703872d..1a730d6c0b55 100644
--- a/drivers/virtio/virtio_input.c
+++ b/drivers/virtio/virtio_input.c
@@ -394,7 +394,6 @@ static const struct virtio_device_id id_table[] = {
 
 static struct virtio_driver virtio_input_driver = {
.driver.name = KBUILD_MODNAME,
-   .driver.owner= THIS_MODULE,
.feature_table   = features,
.feature_table_size  = ARRAY_SIZE(features),
.id_table= id_table,

-- 
2.34.1



[PATCH v2 02/25] virtio: balloon: drop owner assignment

2024-03-31 Thread Krzysztof Kozlowski
virtio core already sets the .owner, so driver does not need to.

Signed-off-by: Krzysztof Kozlowski 

---

Changes in v2:
1. New patch
---
 drivers/virtio/virtio_balloon.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 1f5b3dd31fcf..85d28a0a404d 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -1155,7 +1155,6 @@ static struct virtio_driver virtio_balloon_driver = {
.feature_table = features,
.feature_table_size = ARRAY_SIZE(features),
.driver.name =  KBUILD_MODNAME,
-   .driver.owner = THIS_MODULE,
.id_table = id_table,
.validate = virtballoon_validate,
.probe =virtballoon_probe,

-- 
2.34.1



[PATCH v2 01/25] virtio: store owner from modules with register_virtio_driver()

2024-03-31 Thread Krzysztof Kozlowski
Modules registering driver with register_virtio_driver() might forget to
set .owner field.  i2c-virtio.c for example has it missing.  The field
is used by some of other kernel parts for reference counting
(try_module_get()), so it is expected that drivers will set it.

Solve the problem by moving this task away from the drivers to the core
virtio code, just like we did for platform_driver in
commit 9447057eaff8 ("platform_device: use a macro instead of
platform_driver_register").

Signed-off-by: Krzysztof Kozlowski 
---
 Documentation/driver-api/virtio/writing_virtio_drivers.rst | 1 -
 drivers/virtio/virtio.c| 6 --
 include/linux/virtio.h | 7 +--
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/Documentation/driver-api/virtio/writing_virtio_drivers.rst 
b/Documentation/driver-api/virtio/writing_virtio_drivers.rst
index e14c58796d25..e5de6f5d061a 100644
--- a/Documentation/driver-api/virtio/writing_virtio_drivers.rst
+++ b/Documentation/driver-api/virtio/writing_virtio_drivers.rst
@@ -97,7 +97,6 @@ like this::
 
static struct virtio_driver virtio_dummy_driver = {
.driver.name =  KBUILD_MODNAME,
-   .driver.owner = THIS_MODULE,
.id_table = id_table,
.probe =virtio_dummy_probe,
.remove =   virtio_dummy_remove,
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index f173587893cb..9510c551dce8 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -362,14 +362,16 @@ static const struct bus_type virtio_bus = {
.remove = virtio_dev_remove,
 };
 
-int register_virtio_driver(struct virtio_driver *driver)
+int __register_virtio_driver(struct virtio_driver *driver, struct module 
*owner)
 {
/* Catch this early. */
BUG_ON(driver->feature_table_size && !driver->feature_table);
driver->driver.bus = _bus;
+   driver->driver.owner = owner;
+
return driver_register(>driver);
 }
-EXPORT_SYMBOL_GPL(register_virtio_driver);
+EXPORT_SYMBOL_GPL(__register_virtio_driver);
 
 void unregister_virtio_driver(struct virtio_driver *driver)
 {
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index b0201747a263..26c4325aa373 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -170,7 +170,7 @@ size_t virtio_max_dma_size(const struct virtio_device 
*vdev);
 
 /**
  * struct virtio_driver - operations for a virtio I/O driver
- * @driver: underlying device driver (populate name and owner).
+ * @driver: underlying device driver (populate name).
  * @id_table: the ids serviced by this driver.
  * @feature_table: an array of feature numbers supported by this driver.
  * @feature_table_size: number of entries in the feature table array.
@@ -208,7 +208,10 @@ static inline struct virtio_driver *drv_to_virtio(struct 
device_driver *drv)
return container_of(drv, struct virtio_driver, driver);
 }
 
-int register_virtio_driver(struct virtio_driver *drv);
+/* use a macro to avoid include chaining to get THIS_MODULE */
+#define register_virtio_driver(drv) \
+   __register_virtio_driver(drv, THIS_MODULE)
+int __register_virtio_driver(struct virtio_driver *drv, struct module *owner);
 void unregister_virtio_driver(struct virtio_driver *drv);
 
 /* module_virtio_driver() - Helper macro for drivers that don't do

-- 
2.34.1



[PATCH v2 00/25] virtio: store owner from modules with register_virtio_driver()

2024-03-31 Thread Krzysztof Kozlowski
Changes in v2:
- Three new patches: virtio mem+input+balloon
- Minor commit msg adjustments
- Add tags
- Link to v1: 
https://lore.kernel.org/r/20240327-module-owner-virtio-v1-0-0feffab77...@linaro.org

Merging
===
All further patches depend on the first virtio patch, therefore please ack
and this should go via one tree: maybe virtio?

Description
===
Modules registering driver with register_virtio_driver() often forget to
set .owner field.

Solve the problem by moving this task away from the drivers to the core
virtio code, just like we did for platform_driver in commit
9447057eaff8 ("platform_device: use a macro instead of
platform_driver_register").

Best regards,
Krzysztof

---
Krzysztof Kozlowski (25):
  virtio: store owner from modules with register_virtio_driver()
  virtio: balloon: drop owner assignment
  virtio: input: drop owner assignment
  virtio: mem: drop owner assignment
  um: virt-pci: drop owner assignment
  virtio_blk: drop owner assignment
  bluetooth: virtio: drop owner assignment
  hwrng: virtio: drop owner assignment
  virtio_console: drop owner assignment
  crypto: virtio - drop owner assignment
  firmware: arm_scmi: virtio: drop owner assignment
  gpio: virtio: drop owner assignment
  drm/virtio: drop owner assignment
  iommu: virtio: drop owner assignment
  misc: nsm: drop owner assignment
  net: caif: virtio: drop owner assignment
  net: virtio: drop owner assignment
  net: 9p: virtio: drop owner assignment
  vsock/virtio: drop owner assignment
  wifi: mac80211_hwsim: drop owner assignment
  nvdimm: virtio_pmem: drop owner assignment
  rpmsg: virtio: drop owner assignment
  scsi: virtio: drop owner assignment
  fuse: virtio: drop owner assignment
  sound: virtio: drop owner assignment

 Documentation/driver-api/virtio/writing_virtio_drivers.rst | 1 -
 arch/um/drivers/virt-pci.c | 1 -
 drivers/block/virtio_blk.c | 1 -
 drivers/bluetooth/virtio_bt.c  | 1 -
 drivers/char/hw_random/virtio-rng.c| 1 -
 drivers/char/virtio_console.c  | 2 --
 drivers/crypto/virtio/virtio_crypto_core.c | 1 -
 drivers/firmware/arm_scmi/virtio.c | 1 -
 drivers/gpio/gpio-virtio.c | 1 -
 drivers/gpu/drm/virtio/virtgpu_drv.c   | 1 -
 drivers/iommu/virtio-iommu.c   | 1 -
 drivers/misc/nsm.c | 1 -
 drivers/net/caif/caif_virtio.c | 1 -
 drivers/net/virtio_net.c   | 1 -
 drivers/net/wireless/virtual/mac80211_hwsim.c  | 1 -
 drivers/nvdimm/virtio_pmem.c   | 1 -
 drivers/rpmsg/virtio_rpmsg_bus.c   | 1 -
 drivers/scsi/virtio_scsi.c | 1 -
 drivers/virtio/virtio.c| 6 --
 drivers/virtio/virtio_balloon.c| 1 -
 drivers/virtio/virtio_input.c  | 1 -
 drivers/virtio/virtio_mem.c| 1 -
 fs/fuse/virtio_fs.c| 1 -
 include/linux/virtio.h | 7 +--
 net/9p/trans_virtio.c  | 1 -
 net/vmw_vsock/virtio_transport.c   | 1 -
 sound/virtio/virtio_card.c | 1 -
 27 files changed, 9 insertions(+), 30 deletions(-)
---
base-commit: 7fdcff3312e16ba8d1419f8a18f465c5cc235ecf
change-id: 20240327-module-owner-virtio-546763b3ca22

Best regards,
-- 
Krzysztof Kozlowski 



[PATCH v2] drm/radeon/radeon_display: Decrease the size of allocated memory

2024-03-31 Thread Erick Archer
This is an effort to get rid of all multiplications from allocation
functions in order to prevent integer overflows [1] [2].

In this case, the memory allocated to store RADEONFB_CONN_LIMIT pointers
to "drm_connector" structures can be avoided. This is because this
memory area is never accessed.

Also, in the kzalloc function, it is preferred to use sizeof(*pointer)
instead of sizeof(type) due to the type of the variable can change and
one needs not change the former (unlike the latter).

At the same time take advantage to remove the "#if 0" block, the code
where the removed memory area was accessed, and the RADEONFB_CONN_LIMIT
constant due to now is never used.

Link: 
https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments
 [1]
Link: https://github.com/KSPP/linux/issues/160 [2]
Signed-off-by: Erick Archer 
---
Changes in v2:
- Rebase against linux-next.

Previous versions:
v1 -> 
https://lore.kernel.org/linux-hardening/20240222180431.7451-1-erick.arc...@gmx.com/

Hi everyone,

Any comments would be greatly appreciated. The first version was
not commented.

Thanks,
Erick
---
 drivers/gpu/drm/radeon/radeon.h | 1 -
 drivers/gpu/drm/radeon/radeon_display.c | 8 +---
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 3e5ff17e3caf..0999c8eaae94 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -132,7 +132,6 @@ extern int radeon_cik_support;
 /* RADEON_IB_POOL_SIZE must be a power of 2 */
 #define RADEON_IB_POOL_SIZE16
 #define RADEON_DEBUGFS_MAX_COMPONENTS  32
-#define RADEONFB_CONN_LIMIT4
 #define RADEON_BIOS_NUM_SCRATCH8
 
 /* internal ring indices */
diff --git a/drivers/gpu/drm/radeon/radeon_display.c 
b/drivers/gpu/drm/radeon/radeon_display.c
index efd18c8d84c8..5f1d24d3120c 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -683,7 +683,7 @@ static void radeon_crtc_init(struct drm_device *dev, int 
index)
struct radeon_device *rdev = dev->dev_private;
struct radeon_crtc *radeon_crtc;
 
-   radeon_crtc = kzalloc(sizeof(struct radeon_crtc) + (RADEONFB_CONN_LIMIT 
* sizeof(struct drm_connector *)), GFP_KERNEL);
+   radeon_crtc = kzalloc(sizeof(*radeon_crtc), GFP_KERNEL);
if (radeon_crtc == NULL)
return;
 
@@ -709,12 +709,6 @@ static void radeon_crtc_init(struct drm_device *dev, int 
index)
dev->mode_config.cursor_width = radeon_crtc->max_cursor_width;
dev->mode_config.cursor_height = radeon_crtc->max_cursor_height;
 
-#if 0
-   radeon_crtc->mode_set.crtc = _crtc->base;
-   radeon_crtc->mode_set.connectors = (struct drm_connector 
**)(radeon_crtc + 1);
-   radeon_crtc->mode_set.num_connectors = 0;
-#endif
-
if (rdev->is_atom_bios && (ASIC_IS_AVIVO(rdev) || radeon_r4xx_atom))
radeon_atombios_init_crtc(dev, radeon_crtc);
else
-- 
2.25.1



[PATCH] drm: nv04: Add check to avoid out of bounds access

2024-03-31 Thread Mikhail Kobuk
Output Resource (dcb->or) value is not guaranteed to be non-zero (i.e.
in drivers/gpu/drm/nouveau/nouveau_bios.c, in 'fabricate_dcb_encoder_table()'
'dcb->or' is assigned value '0' in call to 'fabricate_dcb_output()').

Add check to validate 'dcb->or' before it's used.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 2e5702aff395 ("drm/nouveau: fabricate DCB encoder table for iMac G4")
Signed-off-by: Mikhail Kobuk 
---
 drivers/gpu/drm/nouveau/dispnv04/dac.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/dac.c 
b/drivers/gpu/drm/nouveau/dispnv04/dac.c
index d6b8e0cce2ac..0c8d4fc95ff3 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/dac.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/dac.c
@@ -428,7 +428,7 @@ void nv04_dac_update_dacclk(struct drm_encoder *encoder, 
bool enable)
struct drm_device *dev = encoder->dev;
struct dcb_output *dcb = nouveau_encoder(encoder)->dcb;
 
-   if (nv_gf4_disp_arch(dev)) {
+   if (nv_gf4_disp_arch(dev) && ffs(dcb->or)) {
uint32_t *dac_users = 
_display(dev)->dac_users[ffs(dcb->or) - 1];
int dacclk_off = NV_PRAMDAC_DACCLK + 
nv04_dac_output_offset(encoder);
uint32_t dacclk = NVReadRAMDAC(dev, 0, dacclk_off);
@@ -453,7 +453,7 @@ bool nv04_dac_in_use(struct drm_encoder *encoder)
struct drm_device *dev = encoder->dev;
struct dcb_output *dcb = nouveau_encoder(encoder)->dcb;
 
-   return nv_gf4_disp_arch(encoder->dev) &&
+   return nv_gf4_disp_arch(encoder->dev) && ffs(dcb->or) &&
(nv04_display(dev)->dac_users[ffs(dcb->or) - 1] & ~(1 << 
dcb->index));
 }
 
-- 
2.44.0



Re: 2024 X.Org Foundation Membership deadline for voting in the election

2024-03-31 Thread Ricardo Garcia
This is a reminder that the membership renewal period ends in 2 days,
and elections will start after that. Please register as an X.Org
Foundation member to be able to vote in the upcoming elections. Thanks!

-Ricardo Garcia, on behalf of the X.Org elections committee.
 
On Tue, 2024-03-26 at 11:42 -0400, Christopher Michael wrote:
> The 2024 X.Org Foundation membership renewal period has been extended 
> one additional week and elections will start the following week on 01 
> April 2024.
> 
> Please note that only current members can vote in the upcoming election, 
> and that the deadline for new memberships or renewals to vote in the 
> upcoming election is 01 April 2024 at 23:59 UTC.
> 
> If you are interested in joining the X.Org Foundation or in renewing 
> your membership, please visit the membership system site at: 
> https://members.x.org/
> 
> Christopher Michael, on behalf of the X.Org elections committee
> 
> 
>