[PATCH] drm/nouveau: remove spaces after '*'

2023-07-12 Thread sunran001

Fix four occurrences of the checkpatch.pl error:

ERROR: "foo * bar" should be "foo *bar"

Signed-off-by: Ran Sun 
---
 drivers/gpu/drm/nouveau/dispnv04/crtc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c 
b/drivers/gpu/drm/nouveau/dispnv04/crtc.c

index a6f2e681bde9..5ef84f4749e1 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -114,7 +114,7 @@ static void nv_crtc_set_image_sharpening(struct 
drm_crtc *crtc, int level)

  * bits 28-31: related to single stage mode? (bit 8/12)
  */

-static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct 
drm_display_mode * mode, int dot_clock)
+static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct 
drm_display_mode *mode, int dot_clock)

 {
 struct drm_device *dev = crtc->dev;
 struct nouveau_drm *drm = nouveau_drm(dev);
@@ -458,7 +458,7 @@ nv_crtc_mode_set_vga(struct drm_crtc *crtc, struct 
drm_display_mode *mode)

  * be easily turned on/off after this.
  */
 static void
-nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * 
mode)
+nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode 
*mode)

 {
 struct drm_device *dev = crtc->dev;
 struct nouveau_drm *drm = nouveau_drm(dev);


Re: [PATCH RFC v4 2/7] drm: Introduce pixel_source DRM plane property

2023-07-12 Thread Pekka Paalanen
On Tue, 11 Jul 2023 15:42:28 -0700
Abhinav Kumar  wrote:

> On 7/11/2023 3:19 PM, Dmitry Baryshkov wrote:
> > On 12/07/2023 01:07, Jessica Zhang wrote:  
> >>
> >>
> >> On 7/10/2023 1:11 PM, Dmitry Baryshkov wrote:  
> >>> On 10/07/2023 22:51, Jessica Zhang wrote:  
> 
> 
>  On 6/30/2023 1:27 AM, Pekka Paalanen wrote:  
> > On Fri, 30 Jun 2023 03:42:28 +0300
> > Dmitry Baryshkov  wrote:
> >  
> >> On 30/06/2023 03:25, Jessica Zhang wrote:  
> >>> Add support for pixel_source property to drm_plane and related
> >>> documentation.
> >>>
> >>> This enum property will allow user to specify a pixel source for the
> >>> plane. Possible pixel sources will be defined in the
> >>> drm_plane_pixel_source enum.
> >>>
> >>> The current possible pixel sources are DRM_PLANE_PIXEL_SOURCE_FB and
> >>> DRM_PLANE_PIXEL_SOURCE_COLOR. The default value is *_SOURCE_FB.  
> >>
> >> I think, this should come before the solid fill property addition. 
> >> First
> >> you tell that there is a possibility to define other pixel 
> >> sources, then
> >> additional sources are defined.  
> >
> > Hi,
> >
> > that would be logical indeed.  
> 
>  Hi Dmitry and Pekka,
> 
>  Sorry for the delay in response, was out of office last week.
> 
>  Acked.
>   
> >  
> >>>
> >>> Signed-off-by: Jessica Zhang 
> >>> ---
> >>>    drivers/gpu/drm/drm_atomic_state_helper.c |  1 +
> >>>    drivers/gpu/drm/drm_atomic_uapi.c |  4 ++
> >>>    drivers/gpu/drm/drm_blend.c   | 81 
> >>> +++
> >>>    include/drm/drm_blend.h  |  2 +
> >>>    include/drm/drm_plane.h  | 21 
> >>>    5 files changed, 109 insertions(+)
> >>>
> >>> diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c 
> >>> b/drivers/gpu/drm/drm_atomic_state_helper.c
> >>> index fe14be2bd2b2..86fb876efbe6 100644
> >>> --- a/drivers/gpu/drm/drm_atomic_state_helper.c
> >>> +++ b/drivers/gpu/drm/drm_atomic_state_helper.c
> >>> @@ -252,6 +252,7 @@ void 
> >>> __drm_atomic_helper_plane_state_reset(struct drm_plane_state 
> >>> *plane_state,
> >>>    plane_state->alpha = DRM_BLEND_ALPHA_OPAQUE;
> >>>    plane_state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI;
> >>> +    plane_state->pixel_source = DRM_PLANE_PIXEL_SOURCE_FB;
> >>>    if (plane_state->solid_fill_blob) {
> >>>    drm_property_blob_put(plane_state->solid_fill_blob);
> >>> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c 
> >>> b/drivers/gpu/drm/drm_atomic_uapi.c
> >>> index a28b4ee79444..6e59c21af66b 100644
> >>> --- a/drivers/gpu/drm/drm_atomic_uapi.c
> >>> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
> >>> @@ -596,6 +596,8 @@ static int 
> >>> drm_atomic_plane_set_property(struct drm_plane *plane,
> >>>    drm_property_blob_put(solid_fill);
> >>>    return ret;
> >>> +    } else if (property == plane->pixel_source_property) {
> >>> +    state->pixel_source = val;
> >>>    } else if (property == plane->alpha_property) {
> >>>    state->alpha = val;
> >>>    } else if (property == plane->blend_mode_property) {  
> >>
> >> I think, it was pointed out in the discussion that 
> >> drm_mode_setplane()
> >> (a pre-atomic IOCTL to turn the plane on and off) should also reset
> >> pixel_source to FB.  
> 
>  I don't remember drm_mode_setplane() being mentioned in the 
>  pixel_source discussion... can you share where it was mentioned?  
> >>>
> >>> https://lore.kernel.org/dri-devel/20230627105849.004050b3@eldfell/
> >>>
> >>> Let me quote it here:
> >>> "Legacy non-atomic UAPI wrappers can do whatever they want, and program
> >>> any (new) properties they want in order to implement the legacy
> >>> expectations, so that does not seem to be a problem."
> >>>
> >>>  
> 
>  I'd prefer to avoid having driver change the pixel_source directly 
>  as it could cause some unexpected side effects. In general, I would 
>  like userspace to assign the value of pixel_source without driver 
>  doing anything "under the hood".  
> >>>
> >>> s/driver/drm core/
> >>>
> >>> We have to remain compatible with old userspace, especially with the 
> >>> non-atomic one. If the userspace calls 
> >>> ioctl(DRM_IOCTL_MODE_SETPLANE), we have to display the specified FB, 
> >>> no matter what was the value of PIXEL_SOURCE before this ioctl.  
> >>
> >>
> >> Got it, thanks the clarification -- I see your point.
> >>
> >> I'm already setting plane_state->pixel_source to FB in 
> >> __drm_atomic_helper_plane_reset() and it seems to me that all drivers 
> >> are calling that within their respective plane_funcs->reset().
> >>
> >> Since (as far as I know) reset() is being called for both the atomic 
> >> and non

Re: [PATCH 1/3] dt-bindings: display: panel: add startek kd070fhfid015 support

2023-07-12 Thread Alexandre Mergnat

Hi Krzysztof,

Thanks for your review

On 12/07/2023 07:32, Krzysztof Kozlowski wrote:

On 11/07/2023 17:36, Alexandre Mergnat wrote:

The Startek KD070FHFID015 is a 7-inch TFT LCD display with a resolution


snip


+
+  dcdc-gpios: true


 From where does this come? Which schema defines it?


It's a miss. I will fix it and reset-gpios too by adding a maxItems and 
a description.



+
+  height-mm:
+const: 151
+
+  iovcc-supply:
+description: Reference to the regulator powering the panel IO pins.
+
+  reg:
+maxItems: 1
+description: DSI virtual channel
+
+  reset-gpios: true
+
+  port: true
+
+  power-supply: true
+
+  width-mm:
+const: 95
+
+additionalProperties: false
+
+required:
+  - compatible
+  - dcdc-gpios
+  - iovcc-supply
+  - reg
+  - reset-gpios
+  - port
+  - power-supply


Missing example.


I will add it.

--
Regards,
Alexandre


Re: [PATCH 1/3] dt-bindings: display: panel: add startek kd070fhfid015 support

2023-07-12 Thread Krzysztof Kozlowski
On 12/07/2023 10:01, Alexandre Mergnat wrote:
> Hi Krzysztof,
> 
> Thanks for your review
> 
> On 12/07/2023 07:32, Krzysztof Kozlowski wrote:
>> On 11/07/2023 17:36, Alexandre Mergnat wrote:
>>> The Startek KD070FHFID015 is a 7-inch TFT LCD display with a resolution
> 
> snip
> 
>>> +
>>> +  dcdc-gpios: true
>>
>>  From where does this come? Which schema defines it?
> 
> It's a miss. I will fix it and reset-gpios too by adding a maxItems and 
> a description.

reset-gpios come from panel-common, so they are fine.

Best regards,
Krzysztof



Re: Consider switching to WQ_UNBOUND messages (was: Re: [PATCH v2 6/7] workqueue: Report work funcs that trigger automatic CPU_INTENSIVE mechanism)

2023-07-12 Thread Peter Zijlstra
On Tue, Jul 11, 2023 at 11:39:17AM -1000, Tejun Heo wrote:

> I wonder whether the right thing to do here is somehow scaling the threshold
> according to the relative processing power. It's difficult to come up with a
> threshold which works well across the latest & fastest and really tiny CPUs.
> I'll think about it some more but if you have some ideas, please feel free
> to suggest.

We could scale by BogoMIPS I suppose, it's a bogus measurement, as per
the name, but it does have some relation to how fast the machine is.


Re: [PATCH 3/6] drm/amdgpu: Rework coredump to use memory dynamically

2023-07-12 Thread Christian König

Am 11.07.23 um 23:34 schrieb André Almeida:

Instead of storing coredump information inside amdgpu_device struct,
move if to a proper separated struct and allocate it dynamically. This
will make it easier to further expand the logged information.


Verry big NAK to this. The problem is that memory allocation isn't 
allowed during a GPU reset.


What you could do is to allocate the memory with GFP_ATOMIC or similar, 
but for a large structure that might not be possible.


Regards,
Christian.



Signed-off-by: André Almeida 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h| 14 +++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 65 ++
  2 files changed, 51 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index dbe062a087c5..e1cc83a89d46 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1068,11 +1068,6 @@ struct amdgpu_device {
uint32_t*reset_dump_reg_list;
uint32_t*reset_dump_reg_value;
int num_regs;
-#ifdef CONFIG_DEV_COREDUMP
-   struct amdgpu_task_info reset_task_info;
-   boolreset_vram_lost;
-   struct timespec64   reset_time;
-#endif
  
  	boolscpm_enabled;

uint32_tscpm_status;
@@ -1085,6 +1080,15 @@ struct amdgpu_device {
uint32_taid_mask;
  };
  
+#ifdef CONFIG_DEV_COREDUMP

+struct amdgpu_coredump_info {
+   struct amdgpu_device*adev;
+   struct amdgpu_task_info reset_task_info;
+   struct timespec64   reset_time;
+   boolreset_vram_lost;
+};
+#endif
+
  static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev)
  {
return container_of(ddev, struct amdgpu_device, ddev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index e25f085ee886..23b9784e9787 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -4963,12 +4963,17 @@ static int amdgpu_reset_reg_dumps(struct amdgpu_device 
*adev)
return 0;
  }
  
-#ifdef CONFIG_DEV_COREDUMP

+#ifndef CONFIG_DEV_COREDUMP
+static void amdgpu_coredump(struct amdgpu_device *adev, bool vram_lost,
+   struct amdgpu_reset_context *reset_context)
+{
+}
+#else
  static ssize_t amdgpu_devcoredump_read(char *buffer, loff_t offset,
size_t count, void *data, size_t datalen)
  {
struct drm_printer p;
-   struct amdgpu_device *adev = data;
+   struct amdgpu_coredump_info *coredump = data;
struct drm_print_iterator iter;
int i;
  
@@ -4982,21 +4987,21 @@ static ssize_t amdgpu_devcoredump_read(char *buffer, loff_t offset,

drm_printf(&p, " AMDGPU Device Coredump \n");
drm_printf(&p, "kernel: " UTS_RELEASE "\n");
drm_printf(&p, "module: " KBUILD_MODNAME "\n");
-   drm_printf(&p, "time: %lld.%09ld\n", adev->reset_time.tv_sec, 
adev->reset_time.tv_nsec);
-   if (adev->reset_task_info.pid)
+   drm_printf(&p, "time: %lld.%09ld\n", coredump->reset_time.tv_sec, 
coredump->reset_time.tv_nsec);
+   if (coredump->reset_task_info.pid)
drm_printf(&p, "process_name: %s PID: %d\n",
-  adev->reset_task_info.process_name,
-  adev->reset_task_info.pid);
+  coredump->reset_task_info.process_name,
+  coredump->reset_task_info.pid);
  
-	if (adev->reset_vram_lost)

+   if (coredump->reset_vram_lost)
drm_printf(&p, "VRAM is lost due to GPU reset!\n");
-   if (adev->num_regs) {
+   if (coredump->adev->num_regs) {
drm_printf(&p, "AMDGPU register dumps:\nOffset: Value:\n");
  
-		for (i = 0; i < adev->num_regs; i++)

+   for (i = 0; i < coredump->adev->num_regs; i++)
drm_printf(&p, "0x%08x: 0x%08x\n",
-  adev->reset_dump_reg_list[i],
-  adev->reset_dump_reg_value[i]);
+  coredump->adev->reset_dump_reg_list[i],
+  coredump->adev->reset_dump_reg_value[i]);
}
  
  	return count - iter.remain;

@@ -5004,14 +5009,34 @@ static ssize_t amdgpu_devcoredump_read(char *buffer, 
loff_t offset,
  
  static void amdgpu_devcoredump_free(void *data)

  {
+   kfree(data);
  }
  
-static void amdgpu_reset_capture_coredumpm(struct amdgpu_device *adev)

+static void amdgpu_coredump(struct amdgpu_device *adev, bool vram_lost,
+   struct amdgpu_reset_context *reset_context)
  {
+   struct amdgpu_coredump_info *coredump;
struct drm_device *dev = ad

[PATCH v3 1/2] drm/ast: Add BMC virtual connector

2023-07-12 Thread Jocelyn Falempe
Most aspeed devices have a BMC, which allows to remotely see the screen.
Also in the common use case, those servers don't have a display connected.
So add a Virtual connector, to reflect that even if no display is
connected, the framebuffer can still be seen remotely.
This prepares the work to implement a detect_ctx() for the Display port
connector.

Fixes: fae7d186403e ("drm/probe-helper: Default to 640x480 if no EDID on DP")
Signed-off-by: Jocelyn Falempe 
---
 drivers/gpu/drm/ast/ast_drv.h  |  4 ++
 drivers/gpu/drm/ast/ast_mode.c | 67 ++
 2 files changed, 71 insertions(+)

diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index 3f6e0c984523..c9659e72002f 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -214,6 +214,10 @@ struct ast_device {
struct drm_encoder encoder;
struct drm_connector connector;
} astdp;
+   struct {
+   struct drm_encoder encoder;
+   struct drm_connector connector;
+   } bmc;
} output;
 
bool support_wide_screen;
diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index f711d592da52..8896b22eb5cf 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -1735,6 +1735,70 @@ static int ast_astdp_output_init(struct ast_device *ast)
return 0;
 }
 
+/*
+ * BMC virtual Connector
+ */
+
+static int ast_bmc_connector_helper_get_modes(struct drm_connector *connector)
+{
+   return drm_add_modes_noedid(connector, 1024, 768);
+}
+
+static const struct drm_connector_helper_funcs ast_bmc_connector_helper_funcs 
= {
+   .get_modes = ast_bmc_connector_helper_get_modes,
+};
+
+static const struct drm_connector_funcs ast_bmc_connector_funcs = {
+   .reset = drm_atomic_helper_connector_reset,
+   .fill_modes = drm_helper_probe_single_connector_modes,
+   .destroy = drm_connector_cleanup,
+   .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
+   .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
+};
+
+static int ast_bmc_connector_init(struct drm_device *dev,
+ struct drm_connector *connector)
+{
+   int ret;
+
+   ret = drm_connector_init(dev, connector, &ast_bmc_connector_funcs,
+DRM_MODE_CONNECTOR_VIRTUAL);
+   if (ret)
+   return ret;
+
+   drm_connector_helper_add(connector, &ast_bmc_connector_helper_funcs);
+
+   connector->interlace_allowed = 0;
+   connector->doublescan_allowed = 0;
+   connector->polled = 0;
+
+   return 0;
+}
+
+static int ast_bmc_output_init(struct ast_device *ast)
+{
+   struct drm_device *dev = &ast->base;
+   struct drm_crtc *crtc = &ast->crtc;
+   struct drm_encoder *encoder = &ast->output.bmc.encoder;
+   struct drm_connector *connector = &ast->output.bmc.connector;
+   int ret;
+
+   ret = drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_VIRTUAL);
+   if (ret)
+   return ret;
+   encoder->possible_crtcs = drm_crtc_mask(crtc);
+
+   ret = ast_bmc_connector_init(dev, connector);
+   if (ret)
+   return ret;
+
+   ret = drm_connector_attach_encoder(connector, encoder);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
 /*
  * Mode config
  */
@@ -1842,6 +1906,9 @@ int ast_mode_config_init(struct ast_device *ast)
if (ret)
return ret;
}
+   ret = ast_bmc_output_init(ast);
+   if (ret)
+   return ret;
 
drm_mode_config_reset(dev);
 

base-commit: b32d5a51f3c21843011d68a58e6ac0b897bce9f2
-- 
2.41.0



[PATCH v3 2/2] drm/ast: report connection status on Display Port.

2023-07-12 Thread Jocelyn Falempe
Aspeed always report the display port as "connected", because it
doesn't set a .detect callback.
Fix this by providing the proper detect callback for astdp and dp501.

This also fixes the following regression:
Since commit fae7d186403e ("drm/probe-helper: Default to 640x480 if no
EDID on DP")
The default resolution is now 640x480 when no monitor is connected. But
Aspeed graphics is mostly used in servers, where no monitor is attached.
This also affects the remote BMC resolution to 640x480, which is
inconvenient, and breaks the anaconda installer.

v2: Add .detect callback to the dp/dp501 connector (Jani Nikula)
v3: Use .detect_ctx callback, and refactors (Thomas Zimmermann)
Add a BMC virtual connector

Fixes: fae7d186403e ("drm/probe-helper: Default to 640x480 if no EDID on DP")
Signed-off-by: Jocelyn Falempe 
---
 drivers/gpu/drm/ast/ast_dp.c| 11 ++
 drivers/gpu/drm/ast/ast_dp501.c | 37 ++---
 drivers/gpu/drm/ast/ast_drv.h   |  2 ++
 drivers/gpu/drm/ast/ast_mode.c  | 27 
 4 files changed, 65 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c
index 6dc1a09504e1..bf78f3d4aa3f 100644
--- a/drivers/gpu/drm/ast/ast_dp.c
+++ b/drivers/gpu/drm/ast/ast_dp.c
@@ -7,6 +7,17 @@
 #include 
 #include "ast_drv.h"
 
+bool ast_astdp_is_connected(struct ast_device *ast)
+{
+   if (!ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xD1, 
ASTDP_MCU_FW_EXECUTING))
+   return false;
+   if (!ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xDC, 
ASTDP_LINK_SUCCESS))
+   return false;
+   if (!ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xDF, ASTDP_HPD))
+   return false;
+   return true;
+}
+
 int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata)
 {
struct ast_device *ast = to_ast_device(dev);
diff --git a/drivers/gpu/drm/ast/ast_dp501.c b/drivers/gpu/drm/ast/ast_dp501.c
index a5d285850ffb..f10d53b0c94f 100644
--- a/drivers/gpu/drm/ast/ast_dp501.c
+++ b/drivers/gpu/drm/ast/ast_dp501.c
@@ -272,11 +272,9 @@ static bool ast_launch_m68k(struct drm_device *dev)
return true;
 }
 
-bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata)
+bool ast_dp501_is_connected(struct ast_device *ast)
 {
-   struct ast_device *ast = to_ast_device(dev);
-   u32 i, boot_address, offset, data;
-   u32 *pEDIDidx;
+   u32 boot_address, offset, data;
 
if (ast->config_mode == ast_use_p2a) {
boot_address = get_fw_base(ast);
@@ -292,14 +290,6 @@ bool ast_dp501_read_edid(struct drm_device *dev, u8 
*ediddata)
data = ast_mindwm(ast, boot_address + offset);
if (!(data & AST_DP501_PNP_CONNECTED))
return false;
-
-   /* Read EDID */
-   offset = AST_DP501_EDID_DATA;
-   for (i = 0; i < 128; i += 4) {
-   data = ast_mindwm(ast, boot_address + offset + i);
-   pEDIDidx = (u32 *)(ediddata + i);
-   *pEDIDidx = data;
-   }
} else {
if (!ast->dp501_fw_buf)
return false;
@@ -319,7 +309,30 @@ bool ast_dp501_read_edid(struct drm_device *dev, u8 
*ediddata)
data = readl(ast->dp501_fw_buf + offset);
if (!(data & AST_DP501_PNP_CONNECTED))
return false;
+   }
+   return true;
+}
+
+bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata)
+{
+   struct ast_device *ast = to_ast_device(dev);
+   u32 i, boot_address, offset, data;
+   u32 *pEDIDidx;
+
+   if (!ast_dp501_is_connected(ast))
+   return false;
+
+   if (ast->config_mode == ast_use_p2a) {
+   boot_address = get_fw_base(ast);
 
+   /* Read EDID */
+   offset = AST_DP501_EDID_DATA;
+   for (i = 0; i < 128; i += 4) {
+   data = ast_mindwm(ast, boot_address + offset + i);
+   pEDIDidx = (u32 *)(ediddata + i);
+   *pEDIDidx = data;
+   }
+   } else {
/* Read EDID */
offset = AST_DP501_EDID_DATA;
for (i = 0; i < 128; i += 4) {
diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index c9659e72002f..848a9f1403e8 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -514,6 +514,7 @@ void ast_patch_ahb_2500(struct ast_device *ast);
 /* ast dp501 */
 void ast_set_dp501_video_output(struct drm_device *dev, u8 mode);
 bool ast_backup_fw(struct drm_device *dev, u8 *addr, u32 size);
+bool ast_dp501_is_connected(struct ast_device *ast);
 bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata);
 u8 ast_get_dp501_max_clk(struct drm_device *dev);
 void ast_init_3rdtx(struct drm_device *dev);
@@ -522,6 +523,7 @@ void ast_init_3rdtx(struct drm_device *dev);
 stru

Re: [PATCH 2/6] drm/amdgpu: Mark contexts guilty for causing soft recoveries

2023-07-12 Thread Christian König




Am 11.07.23 um 23:34 schrieb André Almeida:

If a DRM fence is set to -ENODATA, that means that this context was a
cause of a soft reset, but is never marked as guilty. Flag it as guilty
and log to user that this context won't accept more submissions.

Signed-off-by: André Almeida 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 6 ++
  1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
index 0dc9c655c4fb..fe8e47d063da 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
@@ -459,6 +459,12 @@ int amdgpu_ctx_get_entity(struct amdgpu_ctx *ctx, u32 
hw_ip, u32 instance,
ctx_entity = &ctx->entities[hw_ip][ring]->entity;
r = drm_sched_entity_error(ctx_entity);
if (r) {
+   if (r == -ENODATA) {
+   DRM_ERROR("%s (%d) context caused a reset,"
+ "marking it guilty and refusing new 
submissions.\n",
+ current->comm, current->pid);
+   atomic_set(&ctx->guilty, 1);
+   }


I'm going back and forth with that as well.

Michel has a very good point that it often is sufficient to cancel just 
one rough shader to keep going.


But Marek has a very good point as well that when that happens multiple 
times we probably want to block the application from making further 
submissions.


Christian.


DRM_DEBUG("error entity %p\n", ctx_entity);
return r;
}




[PATCH 1/7] vgacon: switch vgacon_scrolldelta() and vgacon_restore_screen()

2023-07-12 Thread Jiri Slaby (SUSE)
Switch vgacon_scrolldelta() and vgacon_restore_screen() positions, so
that the former is not needed to be forward-declared.

Signed-off-by: Jiri Slaby (SUSE) 
Cc: Helge Deller 
Cc: linux-fb...@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
---
 drivers/video/console/vgacon.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index e25ba523892e..fbed2862c317 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -142,12 +142,6 @@ static inline void vga_set_mem_top(struct vc_data *c)
write_vga(12, (c->vc_visible_origin - vga_vram_base) / 2);
 }
 
-static void vgacon_restore_screen(struct vc_data *c)
-{
-   if (c->vc_origin != c->vc_visible_origin)
-   vgacon_scrolldelta(c, 0);
-}
-
 static void vgacon_scrolldelta(struct vc_data *c, int lines)
 {
vc_scrolldelta_helper(c, lines, vga_rolled_over, (void *)vga_vram_base,
@@ -155,6 +149,12 @@ static void vgacon_scrolldelta(struct vc_data *c, int 
lines)
vga_set_mem_top(c);
 }
 
+static void vgacon_restore_screen(struct vc_data *c)
+{
+   if (c->vc_origin != c->vc_visible_origin)
+   vgacon_scrolldelta(c, 0);
+}
+
 static const char *vgacon_startup(void)
 {
const char *display_desc = NULL;
-- 
2.41.0



[PATCH 2/7] vgacon: remove unneeded forward declarations

2023-07-12 Thread Jiri Slaby (SUSE)
Most of the forward declarations in vgacon are not needed. Drop them.

Signed-off-by: Jiri Slaby (SUSE) 
Cc: Helge Deller 
Cc: linux-fb...@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
---
 drivers/video/console/vgacon.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index fbed2862c317..a34cdfcc10c2 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -65,16 +65,8 @@ static struct vgastate vgastate;
  *  Interface used by the world
  */
 
-static const char *vgacon_startup(void);
-static void vgacon_init(struct vc_data *c, int init);
-static void vgacon_deinit(struct vc_data *c);
-static void vgacon_cursor(struct vc_data *c, int mode);
-static int vgacon_switch(struct vc_data *c);
-static int vgacon_blank(struct vc_data *c, int blank, int mode_switch);
-static void vgacon_scrolldelta(struct vc_data *c, int lines);
 static int vgacon_set_origin(struct vc_data *c);
-static void vgacon_save_screen(struct vc_data *c);
-static void vgacon_invert_region(struct vc_data *c, u16 * p, int count);
+
 static struct uni_pagedict *vgacon_uni_pagedir;
 static int vgacon_refcount;
 
-- 
2.41.0



[PATCH 4/7] vgacon: let vgacon_doresize() return void

2023-07-12 Thread Jiri Slaby (SUSE)
The return value is neither used, nor vgacon_doresize() returns an
error. So change the reurn type to void.

Signed-off-by: Jiri Slaby (SUSE) 
Cc: Helge Deller 
Cc: linux-fb...@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
---
 drivers/video/console/vgacon.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 7cb15851ea56..07f6b97d9b81 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -528,7 +528,7 @@ static void vgacon_cursor(struct vc_data *c, int mode)
}
 }
 
-static int vgacon_doresize(struct vc_data *c,
+static void vgacon_doresize(struct vc_data *c,
unsigned int width, unsigned int height)
 {
unsigned long flags;
@@ -587,7 +587,6 @@ static int vgacon_doresize(struct vc_data *c,
}
 
raw_spin_unlock_irqrestore(&vga_lock, flags);
-   return 0;
 }
 
 static int vgacon_switch(struct vc_data *c)
-- 
2.41.0



[PATCH 3/7] vgacon: remove unused xpos from vgacon_set_cursor_size()

2023-07-12 Thread Jiri Slaby (SUSE)
xpos is unused, remove it.

Signed-off-by: Jiri Slaby (SUSE) 
Cc: Helge Deller 
Cc: linux-fb...@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
---
 drivers/video/console/vgacon.c | 25 ++---
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index a34cdfcc10c2..7cb15851ea56 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -437,7 +437,7 @@ static void vgacon_invert_region(struct vc_data *c, u16 * 
p, int count)
}
 }
 
-static void vgacon_set_cursor_size(int xpos, int from, int to)
+static void vgacon_set_cursor_size(int from, int to)
 {
unsigned long flags;
int curs, cure;
@@ -479,9 +479,9 @@ static void vgacon_cursor(struct vc_data *c, int mode)
case CM_ERASE:
write_vga(14, (c->vc_pos - vga_vram_base) / 2);
if (vga_video_type >= VIDEO_TYPE_VGAC)
-   vgacon_set_cursor_size(c->state.x, 31, 30);
+   vgacon_set_cursor_size(31, 30);
else
-   vgacon_set_cursor_size(c->state.x, 31, 31);
+   vgacon_set_cursor_size(31, 31);
break;
 
case CM_MOVE:
@@ -489,8 +489,7 @@ static void vgacon_cursor(struct vc_data *c, int mode)
write_vga(14, (c->vc_pos - vga_vram_base) / 2);
switch (CUR_SIZE(c->vc_cursor_type)) {
case CUR_UNDERLINE:
-   vgacon_set_cursor_size(c->state.x,
-  c->vc_cell_height -
+   vgacon_set_cursor_size(c->vc_cell_height -
   (c->vc_cell_height <
10 ? 2 : 3),
   c->vc_cell_height -
@@ -498,35 +497,31 @@ static void vgacon_cursor(struct vc_data *c, int mode)
10 ? 1 : 2));
break;
case CUR_TWO_THIRDS:
-   vgacon_set_cursor_size(c->state.x,
-  c->vc_cell_height / 3,
+   vgacon_set_cursor_size(c->vc_cell_height / 3,
   c->vc_cell_height -
   (c->vc_cell_height <
10 ? 1 : 2));
break;
case CUR_LOWER_THIRD:
-   vgacon_set_cursor_size(c->state.x,
-  (c->vc_cell_height * 2) / 3,
+   vgacon_set_cursor_size((c->vc_cell_height * 2) / 3,
   c->vc_cell_height -
   (c->vc_cell_height <
10 ? 1 : 2));
break;
case CUR_LOWER_HALF:
-   vgacon_set_cursor_size(c->state.x,
-  c->vc_cell_height / 2,
+   vgacon_set_cursor_size(c->vc_cell_height / 2,
   c->vc_cell_height -
   (c->vc_cell_height <
10 ? 1 : 2));
break;
case CUR_NONE:
if (vga_video_type >= VIDEO_TYPE_VGAC)
-   vgacon_set_cursor_size(c->state.x, 31, 30);
+   vgacon_set_cursor_size(31, 30);
else
-   vgacon_set_cursor_size(c->state.x, 31, 31);
+   vgacon_set_cursor_size(31, 31);
break;
default:
-   vgacon_set_cursor_size(c->state.x, 1,
-  c->vc_cell_height);
+   vgacon_set_cursor_size(1, c->vc_cell_height);
break;
}
break;
-- 
2.41.0



[PATCH 6/7] sticon: make sticon_set_def_font() void and remove op parameter

2023-07-12 Thread Jiri Slaby (SUSE)
sticon_set_def_font() always returns 0, so make it void. And remove an
unused 'op' parameter.

Signed-off-by: Jiri Slaby (SUSE) 
Cc: "James E.J. Bottomley" 
Cc: Helge Deller 
Cc: linux-par...@vger.kernel.org
Cc: linux-fb...@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
---
 drivers/video/console/sticon.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c
index d11cfd2d68b5..992a4fa431aa 100644
--- a/drivers/video/console/sticon.c
+++ b/drivers/video/console/sticon.c
@@ -156,7 +156,7 @@ static bool sticon_scroll(struct vc_data *conp, unsigned 
int t,
 return false;
 }
 
-static int sticon_set_def_font(int unit, struct console_font *op)
+static void sticon_set_def_font(int unit)
 {
if (font_data[unit] != STI_DEF_FONT) {
if (--FNTREFCOUNT(font_data[unit]) == 0) {
@@ -165,8 +165,6 @@ static int sticon_set_def_font(int unit, struct 
console_font *op)
}
font_data[unit] = STI_DEF_FONT;
}
-
-   return 0;
 }
 
 static int sticon_set_font(struct vc_data *vc, struct console_font *op,
@@ -246,7 +244,7 @@ static int sticon_set_font(struct vc_data *vc, struct 
console_font *op,
  vc->vc_video_erase_char, font_data[vc->vc_num]);
 
/* delete old font in case it is a user font */
-   sticon_set_def_font(unit, NULL);
+   sticon_set_def_font(unit);
 
FNTREFCOUNT(cooked_font)++;
font_data[unit] = cooked_font;
@@ -264,7 +262,9 @@ static int sticon_set_font(struct vc_data *vc, struct 
console_font *op,
 
 static int sticon_font_default(struct vc_data *vc, struct console_font *op, 
char *name)
 {
-   return sticon_set_def_font(vc->vc_num, op);
+   sticon_set_def_font(vc->vc_num);
+
+   return 0;
 }
 
 static int sticon_font_set(struct vc_data *vc, struct console_font *font,
@@ -297,7 +297,7 @@ static void sticon_deinit(struct vc_data *c)
 
 /* free memory used by user font */
 for (i = 0; i < MAX_NR_CONSOLES; i++)
-   sticon_set_def_font(i, NULL);
+   sticon_set_def_font(i);
 }
 
 static void sticon_clear(struct vc_data *conp, int sy, int sx, int height,
-- 
2.41.0



[PATCH 5/7] vgacon: cache vc_cell_height in vgacon_cursor()

2023-07-12 Thread Jiri Slaby (SUSE)
There are many places c->vc_cell_height is used in the code of
vgacon_cursor(). Caching the value to a local variable makes the code
much easier to follow.

Signed-off-by: Jiri Slaby (SUSE) 
Cc: Helge Deller 
Cc: linux-fb...@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
---
 drivers/video/console/vgacon.c | 34 +++---
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 07f6b97d9b81..7ad047bcae17 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -470,11 +470,15 @@ static void vgacon_set_cursor_size(int from, int to)
 
 static void vgacon_cursor(struct vc_data *c, int mode)
 {
+   unsigned int c_height;
+
if (c->vc_mode != KD_TEXT)
return;
 
vgacon_restore_screen(c);
 
+   c_height = c->vc_cell_height;
+
switch (mode) {
case CM_ERASE:
write_vga(14, (c->vc_pos - vga_vram_base) / 2);
@@ -489,30 +493,22 @@ static void vgacon_cursor(struct vc_data *c, int mode)
write_vga(14, (c->vc_pos - vga_vram_base) / 2);
switch (CUR_SIZE(c->vc_cursor_type)) {
case CUR_UNDERLINE:
-   vgacon_set_cursor_size(c->vc_cell_height -
-  (c->vc_cell_height <
-   10 ? 2 : 3),
-  c->vc_cell_height -
-  (c->vc_cell_height <
-   10 ? 1 : 2));
+   vgacon_set_cursor_size(c_height -
+  (c_height < 10 ? 2 : 3),
+  c_height -
+  (c_height < 10 ? 1 : 2));
break;
case CUR_TWO_THIRDS:
-   vgacon_set_cursor_size(c->vc_cell_height / 3,
-  c->vc_cell_height -
-  (c->vc_cell_height <
-   10 ? 1 : 2));
+   vgacon_set_cursor_size(c_height / 3, c_height -
+  (c_height < 10 ? 1 : 2));
break;
case CUR_LOWER_THIRD:
-   vgacon_set_cursor_size((c->vc_cell_height * 2) / 3,
-  c->vc_cell_height -
-  (c->vc_cell_height <
-   10 ? 1 : 2));
+   vgacon_set_cursor_size(c_height * 2 / 3, c_height -
+  (c_height < 10 ? 1 : 2));
break;
case CUR_LOWER_HALF:
-   vgacon_set_cursor_size(c->vc_cell_height / 2,
-  c->vc_cell_height -
-  (c->vc_cell_height <
-   10 ? 1 : 2));
+   vgacon_set_cursor_size(c_height / 2, c_height -
+  (c_height < 10 ? 1 : 2));
break;
case CUR_NONE:
if (vga_video_type >= VIDEO_TYPE_VGAC)
@@ -521,7 +517,7 @@ static void vgacon_cursor(struct vc_data *c, int mode)
vgacon_set_cursor_size(31, 31);
break;
default:
-   vgacon_set_cursor_size(1, c->vc_cell_height);
+   vgacon_set_cursor_size(1, c_height);
break;
}
break;
-- 
2.41.0



Re: [PATCH 3/6] drm/amdgpu: Rework coredump to use memory dynamically

2023-07-12 Thread Lucas Stach
Am Mittwoch, dem 12.07.2023 um 10:37 +0200 schrieb Christian König:
> Am 11.07.23 um 23:34 schrieb André Almeida:
> > Instead of storing coredump information inside amdgpu_device struct,
> > move if to a proper separated struct and allocate it dynamically. This
> > will make it easier to further expand the logged information.
> 
> Verry big NAK to this. The problem is that memory allocation isn't 
> allowed during a GPU reset.
> 
> What you could do is to allocate the memory with GFP_ATOMIC or similar, 
> but for a large structure that might not be possible.
> 
I'm still not fully clear on what the rules are here. In etnaviv we do
devcoredump allocation in the GPU reset path with __GFP_NOWARN |
__GFP_NORETRY, which means the allocation will kick memory reclaim if
necessary, but will just give up if no memory could be made available
easily. This satisfies the forward progress guarantee in the absence of
successful memory allocation, which is the most important property in
this path, I think.

However, I'm not sure if the reclaim could lead to locking issues or
something like that with the more complex use-cases with MMU notifiers
and stuff like that. Christian, do you have any experience or
information that would be good to share in this regard?

Regards,
Lucas

> Regards,
> Christian.
> 
> > 
> > Signed-off-by: André Almeida 
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu.h| 14 +++--
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 65 ++
> >   2 files changed, 51 insertions(+), 28 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > index dbe062a087c5..e1cc83a89d46 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > @@ -1068,11 +1068,6 @@ struct amdgpu_device {
> > uint32_t*reset_dump_reg_list;
> > uint32_t*reset_dump_reg_value;
> > int num_regs;
> > -#ifdef CONFIG_DEV_COREDUMP
> > -   struct amdgpu_task_info reset_task_info;
> > -   boolreset_vram_lost;
> > -   struct timespec64   reset_time;
> > -#endif
> >   
> > boolscpm_enabled;
> > uint32_tscpm_status;
> > @@ -1085,6 +1080,15 @@ struct amdgpu_device {
> > uint32_taid_mask;
> >   };
> >   
> > +#ifdef CONFIG_DEV_COREDUMP
> > +struct amdgpu_coredump_info {
> > +   struct amdgpu_device*adev;
> > +   struct amdgpu_task_info reset_task_info;
> > +   struct timespec64   reset_time;
> > +   boolreset_vram_lost;
> > +};
> > +#endif
> > +
> >   static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev)
> >   {
> > return container_of(ddev, struct amdgpu_device, ddev);
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > index e25f085ee886..23b9784e9787 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > @@ -4963,12 +4963,17 @@ static int amdgpu_reset_reg_dumps(struct 
> > amdgpu_device *adev)
> > return 0;
> >   }
> >   
> > -#ifdef CONFIG_DEV_COREDUMP
> > +#ifndef CONFIG_DEV_COREDUMP
> > +static void amdgpu_coredump(struct amdgpu_device *adev, bool vram_lost,
> > +   struct amdgpu_reset_context *reset_context)
> > +{
> > +}
> > +#else
> >   static ssize_t amdgpu_devcoredump_read(char *buffer, loff_t offset,
> > size_t count, void *data, size_t datalen)
> >   {
> > struct drm_printer p;
> > -   struct amdgpu_device *adev = data;
> > +   struct amdgpu_coredump_info *coredump = data;
> > struct drm_print_iterator iter;
> > int i;
> >   
> > @@ -4982,21 +4987,21 @@ static ssize_t amdgpu_devcoredump_read(char 
> > *buffer, loff_t offset,
> > drm_printf(&p, " AMDGPU Device Coredump \n");
> > drm_printf(&p, "kernel: " UTS_RELEASE "\n");
> > drm_printf(&p, "module: " KBUILD_MODNAME "\n");
> > -   drm_printf(&p, "time: %lld.%09ld\n", adev->reset_time.tv_sec, 
> > adev->reset_time.tv_nsec);
> > -   if (adev->reset_task_info.pid)
> > +   drm_printf(&p, "time: %lld.%09ld\n", coredump->reset_time.tv_sec, 
> > coredump->reset_time.tv_nsec);
> > +   if (coredump->reset_task_info.pid)
> > drm_printf(&p, "process_name: %s PID: %d\n",
> > -  adev->reset_task_info.process_name,
> > -  adev->reset_task_info.pid);
> > +  coredump->reset_task_info.process_name,
> > +  coredump->reset_task_info.pid);
> >   
> > -   if (adev->reset_vram_lost)
> > +   if (coredump->reset_vram_lost)
> > drm_printf(&p, "VRAM is lost due to GPU reset!\n");
> > -   if (adev->num_regs) {
> > +   if (coredump->adev->num_regs) {
> > drm_printf(&p, "AMDGPU regist

[PATCH 7/7] fbcon: remove unused display (p) from fbcon_redraw()

2023-07-12 Thread Jiri Slaby (SUSE)
The parameter is unused.

Signed-off-by: Jiri Slaby (SUSE) 
Cc: Daniel Vetter 
Cc: Helge Deller 
Cc: linux-fb...@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
---
 drivers/video/fbdev/core/fbcon.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index c6c9d040bdec..887fad44e7ec 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -1612,8 +1612,7 @@ static void fbcon_redraw_blit(struct vc_data *vc, struct 
fb_info *info,
}
 }
 
-static void fbcon_redraw(struct vc_data *vc, struct fbcon_display *p,
-int line, int count, int offset)
+static void fbcon_redraw(struct vc_data *vc, int line, int count, int offset)
 {
unsigned short *d = (unsigned short *)
(vc->vc_origin + vc->vc_size_row * line);
@@ -1827,7 +1826,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int 
t, unsigned int b,
 
case SCROLL_REDRAW:
  redraw_up:
-   fbcon_redraw(vc, p, t, b - t - count,
+   fbcon_redraw(vc, t, b - t - count,
 count * vc->vc_cols);
fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
scr_memsetw((unsigned short *) (vc->vc_origin +
@@ -1913,7 +1912,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int 
t, unsigned int b,
 
case SCROLL_REDRAW:
  redraw_down:
-   fbcon_redraw(vc, p, b - 1, b - t - count,
+   fbcon_redraw(vc, b - 1, b - t - count,
 -count * vc->vc_cols);
fbcon_clear(vc, t, 0, count, vc->vc_cols);
scr_memsetw((unsigned short *) (vc->vc_origin +
-- 
2.41.0



Re: [PATCH] drm/virtio: remove some redundant code

2023-07-12 Thread Dan Carpenter
On Wed, Jul 12, 2023 at 09:18:42AM +0800, Su Hui wrote:
> On 2023/7/11 19:13, Dan Carpenter wrote:
> > On Tue, Jul 11, 2023 at 05:00:31PM +0800, Su Hui wrote:
> > > virtio_gpu_get_vbuf always be successful,
> > > so remove the error judgment.
> > > 
> > No, just ignore the static checker false positive in this case.  The
> > intent of the code is clear that if it did have an error it should
> > return an error pointer.
> 
> Hi, Dan,
> 
> Function "virtio_gpu_get_vbuf" call "kmem_cache_zalloc (vgdev->vbufs,
> GFP_KERNEL | __GFP_NOFAIL)" to
> allocate memory. Adding the " __GFP_NOFAIL”flag make sure it won't fail. And
> "virtio_gpu_get_vbuf" never
> return an error code, so I think this is not a false positive.

We all see this and agree.

However the check for if (IS_ERR()) is written deliberately because we
might change the code to return error pointers in the future.  Static
checkers are looking for code that does something unintentional but in
this case the code was written that way deliberately.

regards,
dan carpenter



Re: Consider switching to WQ_UNBOUND messages (was: Re: [PATCH v2 6/7] workqueue: Report work funcs that trigger automatic CPU_INTENSIVE mechanism)

2023-07-12 Thread Geert Uytterhoeven
Hoi Peter,

On Wed, Jul 12, 2023 at 10:05 AM Peter Zijlstra  wrote:
> On Tue, Jul 11, 2023 at 11:39:17AM -1000, Tejun Heo wrote:
> > I wonder whether the right thing to do here is somehow scaling the threshold
> > according to the relative processing power. It's difficult to come up with a
> > threshold which works well across the latest & fastest and really tiny CPUs.
> > I'll think about it some more but if you have some ideas, please feel free
> > to suggest.
>
> We could scale by BogoMIPS I suppose, it's a bogus measurement, as per
> the name, but it does have some relation to how fast the machine is.

That's gonna fail miserably on e.g. ARM and RISC-V, where BogoMIPS
depends on some timer frequency.

R-Car M2-W with 1.5 GHz Cortex-A15: 40.00 BogoMIPS
R-Car V4H with 1.8 GHz Cortex-A76: 33.33 BogoMIPS

while the real slow 48 MHz VexRiscV gets 128 BogoMIPS.

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [Intel-gfx] [PATCH v4] drm/i915/selftest/gsc: Ensure GSC Proxy init completes before selftests

2023-07-12 Thread Tvrtko Ursulin



On 11/07/2023 23:02, Alan Previn wrote:

On MTL, if the GSC Proxy init flows haven't completed, submissions to the
GSC engine will fail. Those init flows are dependent on the mei's
gsc_proxy component that is loaded in parallel with i915 and a
worker that could potentially start after i915 driver init is done.

That said, all subsytems that access the GSC engine today does check
for such init flow completion before using the GSC engine. However,
selftests currently don't wait on anything before starting.

To fix this, add a waiter function at the start of __run_selftests
that waits for gsc-proxy init flows to complete.

Difference from prior versions:
v4: - Remove generalized waiters function table framework (Tvrtko).
- Remove mention of CI-framework-timeout from comments (Tvrtko).
v3: - Rebase to latest drm-tip.
v2: - Based on internal testing, increase the timeout for gsc-proxy
  specific case to 8 seconds.

Signed-off-by: Alan Previn 
---
  .../gpu/drm/i915/selftests/i915_selftest.c| 25 +++
  1 file changed, 25 insertions(+)

diff --git a/drivers/gpu/drm/i915/selftests/i915_selftest.c 
b/drivers/gpu/drm/i915/selftests/i915_selftest.c
index 39da0fb0d6d2..bbfaaaeef505 100644
--- a/drivers/gpu/drm/i915/selftests/i915_selftest.c
+++ b/drivers/gpu/drm/i915/selftests/i915_selftest.c
@@ -24,6 +24,8 @@
  #include 
  
  #include "gt/intel_gt_pm.h"

+#include "gt/uc/intel_gsc_fw.h"
+
  #include "i915_driver.h"
  #include "i915_drv.h"
  #include "i915_selftest.h"
@@ -127,6 +129,26 @@ static void set_default_test_all(struct selftest *st, 
unsigned int count)
st[i].enabled = true;
  }
  
+static void

+__wait_gsc_proxy_completed(struct drm_i915_private *i915)
+{
+   bool need_to_wait = (IS_ENABLED(CONFIG_INTEL_MEI_GSC_PROXY) &&
+i915->media_gt &&
+HAS_ENGINE(i915->media_gt, GSC0) &&
+
intel_uc_fw_is_loadable(&i915->media_gt->uc.gsc.fw));
+   /*
+* The gsc proxy component depends on the kernel component driver load 
ordering
+* and in corner cases (the first time after an IFWI flash), 
init-completion
+* firmware flows take longer.
+*/
+   unsigned long timeout_ms = 8000;
+
+   if (need_to_wait &&
+   (wait_for(intel_gsc_uc_fw_proxy_init_done(&i915->media_gt->uc.gsc, 
true),
+   timeout_ms)))
+   pr_info(DRIVER_NAME "Timed out waiting for 
gsc_proxy_completion!\n");


Would it make sense to error out here? Or at least upgrade to pr_warn or 
something?


I didn't quite understand the points Daniele raised about engine loops 
and resets - in my mind GSC engine is this special thing exercised for 
highly specialized operations and not touched in random for_each_engine 
loop tests, but I also did not really look so might be totally wrong.


In any case, v4 reads clear - no confusing comments and not 
over-engineered so is acceptable to me.


Regards,

Tvrtko

P.S. Maybe the check *could* be moved to i915_live_selftests, where hw 
dependencies conceptually fit better, and maybe i915_perf_selftests 
would need it too then (?), but it is up to you.


Maybe even in the array selftests/i915_live_selftests.h if we could add 
a facility to make unskippable tests and add this one after the sanity 
check. Which would then achieve the same generalized thing you had in 
the previous version without needing to add a new array/loop.



+}
+
  static int __run_selftests(const char *name,
   struct selftest *st,
   unsigned int count,
@@ -134,6 +156,9 @@ static int __run_selftests(const char *name,
  {
int err = 0;
  
+	if (data)

+   __wait_gsc_proxy_completed(data);
+
while (!i915_selftest.random_seed)
i915_selftest.random_seed = get_random_u32();
  


base-commit: 01c4678ab6c623c621a1dea438133e39711291d4


[PATCH RFC v1 05/52] drm/arm: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 .../gpu/drm/arm/display/komeda/komeda_crtc.c  | 24 +--
 .../gpu/drm/arm/display/komeda/komeda_kms.c   |  2 +-
 drivers/gpu/drm/arm/hdlcd_crtc.c  |  4 ++--
 drivers/gpu/drm/arm/malidp_crtc.c |  7 +++---
 4 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c 
b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
index cea3fd5772b5..7055505818a8 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
@@ -108,7 +108,7 @@ komeda_crtc_atomic_check(struct drm_crtc *crtc,
 static int
 komeda_crtc_prepare(struct komeda_crtc *kcrtc)
 {
-   struct komeda_dev *mdev = kcrtc->base.dev->dev_private;
+   struct komeda_dev *mdev = kcrtc->base.drm_dev->dev_private;
struct komeda_pipeline *master = kcrtc->master;
struct komeda_crtc_state *kcrtc_st = to_kcrtc_st(kcrtc->base.state);
struct drm_display_mode *mode = &kcrtc_st->base.adjusted_mode;
@@ -161,7 +161,7 @@ komeda_crtc_prepare(struct komeda_crtc *kcrtc)
 static int
 komeda_crtc_unprepare(struct komeda_crtc *kcrtc)
 {
-   struct komeda_dev *mdev = kcrtc->base.dev->dev_private;
+   struct komeda_dev *mdev = kcrtc->base.drm_dev->dev_private;
struct komeda_pipeline *master = kcrtc->master;
u32 new_mode;
int err;
@@ -220,7 +220,7 @@ void komeda_crtc_handle_event(struct komeda_crtc   *kcrtc,
unsigned long flags;
struct drm_pending_vblank_event *event;
 
-   spin_lock_irqsave(&crtc->dev->event_lock, flags);
+   spin_lock_irqsave(&crtc->drm_dev->event_lock, flags);
if (kcrtc->disable_done) {
complete_all(kcrtc->disable_done);
kcrtc->disable_done = NULL;
@@ -236,7 +236,7 @@ void komeda_crtc_handle_event(struct komeda_crtc   *kcrtc,
DRM_WARN("CRTC[%d]: FLIP happened but no pending 
commit.\n",
 drm_crtc_index(&kcrtc->base));
}
-   spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
+   spin_unlock_irqrestore(&crtc->drm_dev->event_lock, flags);
}
 }
 
@@ -246,7 +246,7 @@ komeda_crtc_do_flush(struct drm_crtc *crtc,
 {
struct komeda_crtc *kcrtc = to_kcrtc(crtc);
struct komeda_crtc_state *kcrtc_st = to_kcrtc_st(crtc->state);
-   struct komeda_dev *mdev = kcrtc->base.dev->dev_private;
+   struct komeda_dev *mdev = kcrtc->base.drm_dev->dev_private;
struct komeda_pipeline *master = kcrtc->master;
struct komeda_pipeline *slave = kcrtc->slave;
struct komeda_wb_connector *wb_conn = kcrtc->wb_conn;
@@ -277,7 +277,7 @@ komeda_crtc_atomic_enable(struct drm_crtc *crtc,
 {
struct drm_crtc_state *old = drm_atomic_get_old_crtc_state(state,
   crtc);
-   pm_runtime_get_sync(crtc->dev->dev);
+   pm_runtime_get_sync(crtc->drm_dev->dev);
komeda_crtc_prepare(to_kcrtc(crtc));
drm_crtc_vblank_on(crtc);
WARN_ON(drm_crtc_vblank_get(crtc));
@@ -288,7 +288,7 @@ void
 komeda_crtc_flush_and_wait_for_flip_done(struct komeda_crtc *kcrtc,
 struct completion *input_flip_done)
 {
-   struct drm_device *drm = kcrtc->base.dev;
+   struct drm_device *drm = kcrtc->base.drm_dev;
struct komeda_dev *mdev = kcrtc->master->mdev;
struct completion *flip_done;
struct completion temp;
@@ -378,7 +378,7 @@ komeda_crtc_atomic_disable(struct drm_crtc *crtc,
drm_crtc_vblank_put(crtc);
drm_crtc_vblank_off(crtc);
komeda_crtc_unprepare(kcrtc);
-   pm_runtime_put(crtc->dev->dev);
+   pm_runtime_put(crtc->drm_dev->dev);
 }
 
 static void
@@ -414,7 +414,7 @@ komeda_calc_min_aclk_rate(struct komeda_crtc *kcrtc,
 unsigned long komeda_crtc_get_aclk(struct komeda_crtc_state *kcrtc_st)
 {
struct drm_crtc *crtc = kcrtc_st->base.crtc;
-   struct komeda_dev *mdev = crtc->dev->dev_private;
+   struct komeda_dev *mdev = crtc->drm_dev->dev_private;
unsigned long pxlclk = kcrtc_st->base.adjusted_mode.crtc_clock * 1000;
unsigned long min_aclk;
 
@@ -426,7 +426,7 @@ unsigned long komeda_crtc_get_aclk(struct komeda_crtc_state 
*kcrtc_st)
 static enum drm_mode_status
 komeda_crtc_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode *m)
 {
-   struct komeda_dev *mdev = crtc->dev->dev_private;
+   struct komeda_dev *mdev = crtc->drm_dev->dev_private;
struct komeda_crtc *kcrtc = to_kcrtc(crtc);
struct komeda_pipeline *master = kcrtc->master;
unsigned long min_pxlclk, min_aclk;
@@ -532,7 +532,7 @@

[PATCH RFC v1 04/52] drm/armada: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/armada/armada_crtc.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_crtc.c 
b/drivers/gpu/drm/armada/armada_crtc.c
index 15dd667aa2e7..b6f9b2bdfe8d 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -293,9 +293,9 @@ static void armada_drm_crtc_irq(struct armada_crtc *dcrtc, 
u32 stat)
if (stat & VSYNC_IRQ && !dcrtc->update_pending) {
event = xchg(&dcrtc->event, NULL);
if (event) {
-   spin_lock(&dcrtc->crtc.dev->event_lock);
+   spin_lock(&dcrtc->crtc.drm_dev->event_lock);
drm_crtc_send_vblank_event(&dcrtc->crtc, event);
-   spin_unlock(&dcrtc->crtc.dev->event_lock);
+   spin_unlock(&dcrtc->crtc.drm_dev->event_lock);
drm_crtc_vblank_put(&dcrtc->crtc);
}
}
@@ -502,9 +502,9 @@ static void armada_drm_crtc_atomic_disable(struct drm_crtc 
*crtc,
event = crtc->state->event;
crtc->state->event = NULL;
if (event) {
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
drm_crtc_send_vblank_event(crtc, event);
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
}
}
 }
@@ -766,7 +766,7 @@ static int armada_drm_crtc_cursor_move(struct drm_crtc 
*crtc, int x, int y)
 static void armada_drm_crtc_destroy(struct drm_crtc *crtc)
 {
struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
-   struct armada_private *priv = drm_to_armada_dev(crtc->dev);
+   struct armada_private *priv = drm_to_armada_dev(crtc->drm_dev);
 
if (dcrtc->cursor_obj)
drm_gem_object_put(&dcrtc->cursor_obj->obj);
-- 
2.39.2



[PATCH RFC v1 07/52] drm/ast: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/ast/ast_dp.c   |  2 +-
 drivers/gpu/drm/ast/ast_mode.c | 26 +-
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c
index 6dc1a09504e1..3438fcbbe1c2 100644
--- a/drivers/gpu/drm/ast/ast_dp.c
+++ b/drivers/gpu/drm/ast/ast_dp.c
@@ -187,7 +187,7 @@ void ast_dp_set_on_off(struct drm_device *dev, bool on)
 
 void ast_dp_set_mode(struct drm_crtc *crtc, struct ast_vbios_mode_info 
*vbios_mode)
 {
-   struct ast_device *ast = to_ast_device(crtc->dev);
+   struct ast_device *ast = to_ast_device(crtc->drm_dev);
 
u32 ulRefreshRateIndex;
u8 ModeIdx;
diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index b3c670af6ef2..f685c2e5bb7f 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -1007,7 +1007,7 @@ static int ast_cursor_plane_init(struct ast_device *ast)
 
 static void ast_crtc_dpms(struct drm_crtc *crtc, int mode)
 {
-   struct ast_device *ast = to_ast_device(crtc->dev);
+   struct ast_device *ast = to_ast_device(crtc->drm_dev);
u8 ch = AST_DPMS_VSYNC_OFF | AST_DPMS_HSYNC_OFF;
struct ast_crtc_state *ast_state;
const struct drm_format_info *format;
@@ -1021,12 +1021,12 @@ static void ast_crtc_dpms(struct drm_crtc *crtc, int 
mode)
ast_set_index_reg_mask(ast, AST_IO_SEQ_PORT,  0x01, 0xdf, 0);
ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb6, 0xfc, 0);
if (ast->tx_chip_types & AST_TX_DP501_BIT)
-   ast_set_dp501_video_output(crtc->dev, 1);
+   ast_set_dp501_video_output(crtc->drm_dev, 1);
 
if (ast->tx_chip_types & AST_TX_ASTDP_BIT) {
-   ast_dp_power_on_off(crtc->dev, AST_DP_POWER_ON);
+   ast_dp_power_on_off(crtc->drm_dev, AST_DP_POWER_ON);
ast_wait_for_vretrace(ast);
-   ast_dp_set_on_off(crtc->dev, 1);
+   ast_dp_set_on_off(crtc->drm_dev, 1);
}
 
ast_state = to_ast_crtc_state(crtc->state);
@@ -1048,11 +1048,11 @@ static void ast_crtc_dpms(struct drm_crtc *crtc, int 
mode)
case DRM_MODE_DPMS_OFF:
ch = mode;
if (ast->tx_chip_types & AST_TX_DP501_BIT)
-   ast_set_dp501_video_output(crtc->dev, 0);
+   ast_set_dp501_video_output(crtc->drm_dev, 0);
 
if (ast->tx_chip_types & AST_TX_ASTDP_BIT) {
-   ast_dp_set_on_off(crtc->dev, 0);
-   ast_dp_power_on_off(crtc->dev, AST_DP_POWER_OFF);
+   ast_dp_set_on_off(crtc->drm_dev, 0);
+   ast_dp_power_on_off(crtc->drm_dev, AST_DP_POWER_OFF);
}
 
ast_set_index_reg_mask(ast, AST_IO_SEQ_PORT,  0x01, 0xdf, 0x20);
@@ -1064,7 +1064,7 @@ static void ast_crtc_dpms(struct drm_crtc *crtc, int mode)
 static enum drm_mode_status
 ast_crtc_helper_mode_valid(struct drm_crtc *crtc, const struct 
drm_display_mode *mode)
 {
-   struct ast_device *ast = to_ast_device(crtc->dev);
+   struct ast_device *ast = to_ast_device(crtc->drm_dev);
enum drm_mode_status status;
uint32_t jtemp;
 
@@ -1138,7 +1138,7 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc 
*crtc,
struct drm_crtc_state *crtc_state = 
drm_atomic_get_new_crtc_state(state, crtc);
struct drm_crtc_state *old_crtc_state = 
drm_atomic_get_old_crtc_state(state, crtc);
struct ast_crtc_state *old_ast_crtc_state = 
to_ast_crtc_state(old_crtc_state);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct ast_crtc_state *ast_state;
const struct drm_format_info *format;
bool succ;
@@ -1188,7 +1188,7 @@ ast_crtc_helper_atomic_flush(struct drm_crtc *crtc,
 {
struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
  crtc);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct ast_device *ast = to_ast_device(dev);
struct ast_crtc_state *ast_crtc_state = to_ast_crtc_state(crtc_state);
struct ast_vbios_mode_info *vbios_mode_info = 
&ast_crtc_state->vbios_mode_info;
@@ -1213,7 +1213,7 @@ ast_crtc_helper_atomic_flush(struct drm_crtc *crtc,
 
 static void ast_crtc_helper_atomic_enable(struct drm_crtc *crtc, struct 
drm_atomic_state *state)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct ast_device *ast = to_ast_device(dev);
struct drm_crtc_state 

[PATCH RFC v1 11/52] drm/gma500: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/gma500/cdv_intel_display.c |  2 +-
 drivers/gpu/drm/gma500/cdv_intel_dp.c  |  2 +-
 drivers/gpu/drm/gma500/gma_display.c   | 20 ++--
 drivers/gpu/drm/gma500/oaktrail_crtc.c |  8 
 drivers/gpu/drm/gma500/oaktrail_hdmi.c |  4 ++--
 drivers/gpu/drm/gma500/psb_intel_display.c |  2 +-
 drivers/gpu/drm/gma500/psb_irq.c   |  6 +++---
 7 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/gma500/cdv_intel_display.c 
b/drivers/gpu/drm/gma500/cdv_intel_display.c
index bbd0abdd8382..ee4f7c7ded0a 100644
--- a/drivers/gpu/drm/gma500/cdv_intel_display.c
+++ b/drivers/gpu/drm/gma500/cdv_intel_display.c
@@ -574,7 +574,7 @@ static int cdv_intel_crtc_mode_set(struct drm_crtc *crtc,
   int x, int y,
   struct drm_framebuffer *old_fb)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
int pipe = gma_crtc->pipe;
diff --git a/drivers/gpu/drm/gma500/cdv_intel_dp.c 
b/drivers/gpu/drm/gma500/cdv_intel_dp.c
index 8992a95076f2..bdf5b81be380 100644
--- a/drivers/gpu/drm/gma500/cdv_intel_dp.c
+++ b/drivers/gpu/drm/gma500/cdv_intel_dp.c
@@ -983,7 +983,7 @@ void
 cdv_intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
 struct drm_display_mode *adjusted_mode)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
struct drm_mode_config *mode_config = &dev->mode_config;
struct drm_encoder *encoder;
diff --git a/drivers/gpu/drm/gma500/gma_display.c 
b/drivers/gpu/drm/gma500/gma_display.c
index f65e90d890f4..42db792307ff 100644
--- a/drivers/gpu/drm/gma500/gma_display.c
+++ b/drivers/gpu/drm/gma500/gma_display.c
@@ -29,7 +29,7 @@
  */
 bool gma_pipe_has_type(struct drm_crtc *crtc, int type)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct drm_connector_list_iter conn_iter;
struct drm_connector *connector;
 
@@ -58,7 +58,7 @@ void gma_wait_for_vblank(struct drm_device *dev)
 int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y,
  struct drm_framebuffer *old_fb)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
struct drm_framebuffer *fb = crtc->primary->fb;
@@ -143,7 +143,7 @@ int gma_pipe_set_base(struct drm_crtc *crtc, int x, int y,
 /* Loads the palette/gamma unit for the CRTC with the prepared values */
 void gma_crtc_load_lut(struct drm_crtc *crtc)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
const struct psb_offset *map = &dev_priv->regmap[gma_crtc->pipe];
@@ -196,7 +196,7 @@ static int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 
*red, u16 *green,
  */
 void gma_crtc_dpms(struct drm_crtc *crtc, int mode)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
int pipe = gma_crtc->pipe;
@@ -330,7 +330,7 @@ static int gma_crtc_cursor_set(struct drm_crtc *crtc,
   struct drm_file *file_priv, uint32_t handle,
   uint32_t width, uint32_t height)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
int pipe = gma_crtc->pipe;
@@ -443,7 +443,7 @@ static int gma_crtc_cursor_set(struct drm_crtc *crtc,
 
 static int gma_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
int pipe = gma_crtc->pipe;
uint32_t temp = 0;
@@ -518,7 +518,7 @@ int gma_crtc_page_flip(struct drm_crtc *crtc,
struct drm_framebuffer *current_fb = crtc->primary->fb;
struct drm_framebuffer *old_fb = crtc->primary->old_fb;
const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
 

[PATCH RFC v1 12/52] drm/gud: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/gud/gud_pipe.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/gud/gud_pipe.c b/drivers/gpu/drm/gud/gud_pipe.c
index dc16a92625d4..98b27a736e86 100644
--- a/drivers/gpu/drm/gud/gud_pipe.c
+++ b/drivers/gpu/drm/gud/gud_pipe.c
@@ -444,7 +444,7 @@ int gud_pipe_check(struct drm_simple_display_pipe *pipe,
   struct drm_plane_state *new_plane_state,
   struct drm_crtc_state *new_crtc_state)
 {
-   struct gud_device *gdrm = to_gud_device(pipe->crtc.dev);
+   struct gud_device *gdrm = to_gud_device(pipe->crtc.drm_dev);
struct drm_plane_state *old_plane_state = pipe->plane.state;
const struct drm_display_mode *mode = &new_crtc_state->mode;
struct drm_atomic_state *state = new_plane_state->state;
@@ -489,7 +489,7 @@ int gud_pipe_check(struct drm_simple_display_pipe *pipe,
if (!connector_state) {
struct drm_connector_list_iter conn_iter;
 
-   drm_connector_list_iter_begin(pipe->crtc.dev, &conn_iter);
+   drm_connector_list_iter_begin(pipe->crtc.drm_dev, &conn_iter);
drm_for_each_connector_iter(connector, &conn_iter) {
if (connector->state->crtc) {
connector_state = connector->state;
@@ -559,7 +559,7 @@ int gud_pipe_check(struct drm_simple_display_pipe *pipe,
 void gud_pipe_update(struct drm_simple_display_pipe *pipe,
 struct drm_plane_state *old_state)
 {
-   struct drm_device *drm = pipe->crtc.dev;
+   struct drm_device *drm = pipe->crtc.drm_dev;
struct gud_device *gdrm = to_gud_device(drm);
struct drm_plane_state *state = pipe->plane.state;
struct drm_shadow_plane_state *shadow_plane_state = 
to_drm_shadow_plane_state(state);
-- 
2.39.2



[PATCH RFC v1 14/52] drm/hyperv: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/hyperv/hyperv_drm_modeset.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/hyperv/hyperv_drm_modeset.c 
b/drivers/gpu/drm/hyperv/hyperv_drm_modeset.c
index 6c6b57298797..07ccc3cdc515 100644
--- a/drivers/gpu/drm/hyperv/hyperv_drm_modeset.c
+++ b/drivers/gpu/drm/hyperv/hyperv_drm_modeset.c
@@ -102,7 +102,7 @@ static void hyperv_pipe_enable(struct 
drm_simple_display_pipe *pipe,
   struct drm_crtc_state *crtc_state,
   struct drm_plane_state *plane_state)
 {
-   struct hyperv_drm_device *hv = to_hv(pipe->crtc.dev);
+   struct hyperv_drm_device *hv = to_hv(pipe->crtc.drm_dev);
struct drm_shadow_plane_state *shadow_plane_state = 
to_drm_shadow_plane_state(plane_state);
 
hyperv_hide_hw_ptr(hv->hdev);
@@ -117,7 +117,7 @@ static int hyperv_pipe_check(struct drm_simple_display_pipe 
*pipe,
 struct drm_plane_state *plane_state,
 struct drm_crtc_state *crtc_state)
 {
-   struct hyperv_drm_device *hv = to_hv(pipe->crtc.dev);
+   struct hyperv_drm_device *hv = to_hv(pipe->crtc.drm_dev);
struct drm_framebuffer *fb = plane_state->fb;
 
if (fb->format->format != DRM_FORMAT_XRGB)
@@ -135,7 +135,7 @@ static int hyperv_pipe_check(struct drm_simple_display_pipe 
*pipe,
 static void hyperv_pipe_update(struct drm_simple_display_pipe *pipe,
   struct drm_plane_state *old_state)
 {
-   struct hyperv_drm_device *hv = to_hv(pipe->crtc.dev);
+   struct hyperv_drm_device *hv = to_hv(pipe->crtc.drm_dev);
struct drm_plane_state *state = pipe->plane.state;
struct drm_shadow_plane_state *shadow_plane_state = 
to_drm_shadow_plane_state(state);
struct drm_rect rect;
-- 
2.39.2



[PATCH RFC v1 16/52] drm/imx: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/imx/dcss/dcss-crtc.c   | 20 ++--
 drivers/gpu/drm/imx/ipuv3/ipuv3-crtc.c | 15 ---
 drivers/gpu/drm/imx/lcdc/imx-lcdc.c| 16 
 3 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/imx/dcss/dcss-crtc.c 
b/drivers/gpu/drm/imx/dcss/dcss-crtc.c
index 31267c00782f..e85ceceb8ca4 100644
--- a/drivers/gpu/drm/imx/dcss/dcss-crtc.c
+++ b/drivers/gpu/drm/imx/dcss/dcss-crtc.c
@@ -16,7 +16,7 @@ static int dcss_enable_vblank(struct drm_crtc *crtc)
 {
struct dcss_crtc *dcss_crtc = container_of(crtc, struct dcss_crtc,
   base);
-   struct dcss_dev *dcss = crtc->dev->dev_private;
+   struct dcss_dev *dcss = crtc->drm_dev->dev_private;
 
dcss_dtg_vblank_irq_enable(dcss->dtg, true);
 
@@ -31,7 +31,7 @@ static void dcss_disable_vblank(struct drm_crtc *crtc)
 {
struct dcss_crtc *dcss_crtc = container_of(crtc, struct dcss_crtc,
   base);
-   struct dcss_dev *dcss = dcss_crtc->base.dev->dev_private;
+   struct dcss_dev *dcss = dcss_crtc->base.drm_dev->dev_private;
 
disable_irq_nosync(dcss_crtc->irq);
 
@@ -63,15 +63,15 @@ static void dcss_crtc_atomic_flush(struct drm_crtc *crtc,
 {
struct dcss_crtc *dcss_crtc = container_of(crtc, struct dcss_crtc,
   base);
-   struct dcss_dev *dcss = dcss_crtc->base.dev->dev_private;
+   struct dcss_dev *dcss = dcss_crtc->base.drm_dev->dev_private;
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
if (crtc->state->event) {
WARN_ON(drm_crtc_vblank_get(crtc));
drm_crtc_arm_vblank_event(crtc, crtc->state->event);
crtc->state->event = NULL;
}
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
 
if (dcss_dtg_is_enabled(dcss->dtg))
dcss_ctxld_enable(dcss->ctxld);
@@ -84,7 +84,7 @@ static void dcss_crtc_atomic_enable(struct drm_crtc *crtc,
  
crtc);
struct dcss_crtc *dcss_crtc = container_of(crtc, struct dcss_crtc,
   base);
-   struct dcss_dev *dcss = dcss_crtc->base.dev->dev_private;
+   struct dcss_dev *dcss = dcss_crtc->base.drm_dev->dev_private;
struct drm_display_mode *mode = &crtc->state->adjusted_mode;
struct drm_display_mode *old_mode = &old_crtc_state->adjusted_mode;
struct videomode vm;
@@ -120,18 +120,18 @@ static void dcss_crtc_atomic_disable(struct drm_crtc 
*crtc,
  
crtc);
struct dcss_crtc *dcss_crtc = container_of(crtc, struct dcss_crtc,
   base);
-   struct dcss_dev *dcss = dcss_crtc->base.dev->dev_private;
+   struct dcss_dev *dcss = dcss_crtc->base.drm_dev->dev_private;
struct drm_display_mode *mode = &crtc->state->adjusted_mode;
struct drm_display_mode *old_mode = &old_crtc_state->adjusted_mode;
 
drm_atomic_helper_disable_planes_on_crtc(old_crtc_state, false);
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
if (crtc->state->event) {
drm_crtc_send_vblank_event(crtc, crtc->state->event);
crtc->state->event = NULL;
}
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
 
dcss_dtg_ctxld_kick_irq_enable(dcss->dtg, true);
 
@@ -168,7 +168,7 @@ static const struct drm_crtc_helper_funcs dcss_helper_funcs 
= {
 static irqreturn_t dcss_crtc_irq_handler(int irq, void *dev_id)
 {
struct dcss_crtc *dcss_crtc = dev_id;
-   struct dcss_dev *dcss = dcss_crtc->base.dev->dev_private;
+   struct dcss_dev *dcss = dcss_crtc->base.drm_dev->dev_private;
 
if (!dcss_dtg_vblank_irq_valid(dcss->dtg))
return IRQ_NONE;
diff --git a/drivers/gpu/drm/imx/ipuv3/ipuv3-crtc.c 
b/drivers/gpu/drm/imx/ipuv3/ipuv3-crtc.c
index 5f26090b0c98..7ef9ff303e0b 100644
--- a/drivers/gpu/drm/imx/ipuv3/ipuv3-crtc.c
+++ b/drivers/gpu/drm/imx/ipuv3/ipuv3-crtc.c
@@ -99,12 +99,12 @@ static void ipu_crtc_atomic_disable(struct drm_crtc *crtc,
 
drm_crtc_vblank_off(crtc);
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
if (crtc->state->event && !crtc->state->active) {
drm_crtc_send_vblank_event(crtc, crtc->state->event);
crtc->state->event = NULL;
 

[PATCH RFC v1 21/52] drm/mediatek: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c 
b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index d40142842f85..1a41e49b6848 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -92,11 +92,11 @@ static void mtk_drm_crtc_finish_page_flip(struct 
mtk_drm_crtc *mtk_crtc)
struct drm_crtc *crtc = &mtk_crtc->base;
unsigned long flags;
 
-   spin_lock_irqsave(&crtc->dev->event_lock, flags);
+   spin_lock_irqsave(&crtc->drm_dev->event_lock, flags);
drm_crtc_send_vblank_event(crtc, mtk_crtc->event);
drm_crtc_vblank_put(crtc);
mtk_crtc->event = NULL;
-   spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
+   spin_unlock_irqrestore(&crtc->drm_dev->event_lock, flags);
 }
 
 static void mtk_drm_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
@@ -345,11 +345,11 @@ static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc 
*mtk_crtc)
height = crtc->state->adjusted_mode.vdisplay;
vrefresh = drm_mode_vrefresh(&crtc->state->adjusted_mode);
 
-   drm_for_each_encoder(encoder, crtc->dev) {
+   drm_for_each_encoder(encoder, crtc->drm_dev) {
if (encoder->crtc != crtc)
continue;
 
-   drm_connector_list_iter_begin(crtc->dev, &conn_iter);
+   drm_connector_list_iter_begin(crtc->drm_dev, &conn_iter);
drm_for_each_connector_iter(connector, &conn_iter) {
if (connector->encoder != encoder)
continue;
@@ -360,7 +360,7 @@ static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc 
*mtk_crtc)
drm_connector_list_iter_end(&conn_iter);
}
 
-   ret = pm_runtime_resume_and_get(crtc->dev->dev);
+   ret = pm_runtime_resume_and_get(crtc->drm_dev->dev);
if (ret < 0) {
DRM_ERROR("Failed to enable power domain: %d\n", ret);
return ret;
@@ -421,14 +421,14 @@ static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc 
*mtk_crtc)
 err_mutex_unprepare:
mtk_mutex_unprepare(mtk_crtc->mutex);
 err_pm_runtime_put:
-   pm_runtime_put(crtc->dev->dev);
+   pm_runtime_put(crtc->drm_dev->dev);
return ret;
 }
 
 static void mtk_crtc_ddp_hw_fini(struct mtk_drm_crtc *mtk_crtc)
 {
-   struct drm_device *drm = mtk_crtc->base.dev;
struct drm_crtc *crtc = &mtk_crtc->base;
+   struct drm_device *drm = crtc->drm_dev;
int i;
 
for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
@@ -460,10 +460,10 @@ static void mtk_crtc_ddp_hw_fini(struct mtk_drm_crtc 
*mtk_crtc)
pm_runtime_put(drm->dev);
 
if (crtc->state->event && !crtc->state->active) {
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
drm_crtc_send_vblank_event(crtc, crtc->state->event);
crtc->state->event = NULL;
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
}
 }
 
@@ -549,7 +549,7 @@ static void mtk_drm_crtc_update_config(struct mtk_drm_crtc 
*mtk_crtc,
struct cmdq_pkt *cmdq_handle = &mtk_crtc->cmdq_handle;
 #endif
struct drm_crtc *crtc = &mtk_crtc->base;
-   struct mtk_drm_private *priv = crtc->dev->dev_private;
+   struct mtk_drm_private *priv = crtc->drm_dev->dev_private;
unsigned int pending_planes = 0, pending_async_planes = 0;
int i;
 
@@ -616,7 +616,7 @@ static void mtk_crtc_ddp_irq(void *data)
 {
struct drm_crtc *crtc = data;
struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
-   struct mtk_drm_private *priv = crtc->dev->dev_private;
+   struct mtk_drm_private *priv = crtc->drm_dev->dev_private;
 
 #if IS_REACHABLE(CONFIG_MTK_CMDQ)
if (!priv->data->shadow_register && !mtk_crtc->cmdq_client.chan)
-- 
2.39.2



[PATCH RFC v1 33/52] drm/rockchip: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c  |  8 
 drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 15 ---
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index a530ecc4d207..811ddfd06d3e 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -758,9 +758,9 @@ static void vop_crtc_atomic_disable(struct drm_crtc *crtc,
 
 out:
if (crtc->state->event && !crtc->state->active) {
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
drm_crtc_send_vblank_event(crtc, crtc->state->event);
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
 
crtc->state->event = NULL;
}
@@ -1567,7 +1567,7 @@ static void vop_crtc_atomic_flush(struct drm_crtc *crtc,
 */
vop_wait_for_irq_handler(vop);
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
if (crtc->state->event) {
WARN_ON(drm_crtc_vblank_get(crtc) != 0);
WARN_ON(vop->event);
@@ -1575,7 +1575,7 @@ static void vop_crtc_atomic_flush(struct drm_crtc *crtc,
vop->event = crtc->state->event;
crtc->state->event = NULL;
}
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
 
for_each_oldnew_plane_in_state(old_state, plane, old_plane_state,
   new_plane_state, i) {
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
index ca73b8ccc29f..6cbdef324d82 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
@@ -924,9 +924,9 @@ static void vop2_crtc_atomic_disable(struct drm_crtc *crtc,
vop2_unlock(vop2);
 
if (crtc->state->event && !crtc->state->active) {
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
drm_crtc_send_vblank_event(crtc, crtc->state->event);
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
 
crtc->state->event = NULL;
}
@@ -1564,7 +1564,8 @@ static void vop2_crtc_atomic_enable(struct drm_crtc *crtc,
if (mode->flags & DRM_MODE_FLAG_PVSYNC)
polflags |= BIT(VSYNC_POSITIVE);
 
-   drm_for_each_encoder_mask(encoder, crtc->dev, crtc_state->encoder_mask) 
{
+   drm_for_each_encoder_mask(encoder, crtc->drm_dev,
+ crtc_state->encoder_mask) {
struct rockchip_encoder *rkencoder = 
to_rockchip_encoder(encoder);
 
rk3568_set_intf_mux(vp, rkencoder->crtc_endpoint_id, polflags);
@@ -2060,7 +2061,7 @@ static void vop2_crtc_atomic_flush(struct drm_crtc *crtc,
 
vop2_cfg_done(vp);
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
 
if (crtc->state->event) {
WARN_ON(drm_crtc_vblank_get(crtc));
@@ -2068,7 +2069,7 @@ static void vop2_crtc_atomic_flush(struct drm_crtc *crtc,
crtc->state->event = NULL;
}
 
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
 }
 
 static const struct drm_crtc_helper_funcs vop2_crtc_helper_funcs = {
@@ -2162,7 +2163,7 @@ static irqreturn_t vop2_isr(int irq, void *data)
 
if (irqs & VP_INT_FS_FIELD) {
drm_crtc_handle_vblank(crtc);
-   spin_lock(&crtc->dev->event_lock);
+   spin_lock(&crtc->drm_dev->event_lock);
if (vp->event) {
u32 val = vop2_readl(vop2, RK3568_REG_CFG_DONE);
 
@@ -2172,7 +2173,7 @@ static irqreturn_t vop2_isr(int irq, void *data)
drm_crtc_vblank_put(crtc);
}
}
-   spin_unlock(&crtc->dev->event_lock);
+   spin_unlock(&crtc->drm_dev->event_lock);
 
ret = IRQ_HANDLED;
}
-- 
2.39.2



[PATCH RFC v1 25/52] drm/mxsfb: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/mxsfb/lcdif_kms.c | 18 +-
 drivers/gpu/drm/mxsfb/mxsfb_kms.c | 16 
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c 
b/drivers/gpu/drm/mxsfb/lcdif_kms.c
index 2541d2de4e45..28353ad09119 100644
--- a/drivers/gpu/drm/mxsfb/lcdif_kms.c
+++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c
@@ -402,7 +402,7 @@ static void lcdif_crtc_mode_set_nofb(struct drm_crtc_state 
*crtc_state,
 struct drm_plane_state *plane_state)
 {
struct lcdif_crtc_state *lcdif_crtc_state = 
to_lcdif_crtc_state(crtc_state);
-   struct drm_device *drm = crtc_state->crtc->dev;
+   struct drm_device *drm = crtc_state->crtc->drm_dev;
struct lcdif_drm_private *lcdif = to_lcdif_drm_private(drm);
struct drm_display_mode *m = &crtc_state->adjusted_mode;
 
@@ -424,7 +424,7 @@ static void lcdif_crtc_mode_set_nofb(struct drm_crtc_state 
*crtc_state,
 static int lcdif_crtc_atomic_check(struct drm_crtc *crtc,
   struct drm_atomic_state *state)
 {
-   struct drm_device *drm = crtc->dev;
+   struct drm_device *drm = crtc->drm_dev;
struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
  crtc);
struct lcdif_crtc_state *lcdif_crtc_state = 
to_lcdif_crtc_state(crtc_state);
@@ -505,7 +505,7 @@ static int lcdif_crtc_atomic_check(struct drm_crtc *crtc,
 static void lcdif_crtc_atomic_flush(struct drm_crtc *crtc,
struct drm_atomic_state *state)
 {
-   struct lcdif_drm_private *lcdif = to_lcdif_drm_private(crtc->dev);
+   struct lcdif_drm_private *lcdif = to_lcdif_drm_private(crtc->drm_dev);
struct drm_pending_vblank_event *event;
u32 reg;
 
@@ -519,18 +519,18 @@ static void lcdif_crtc_atomic_flush(struct drm_crtc *crtc,
if (!event)
return;
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
if (drm_crtc_vblank_get(crtc) == 0)
drm_crtc_arm_vblank_event(crtc, event);
else
drm_crtc_send_vblank_event(crtc, event);
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
 }
 
 static void lcdif_crtc_atomic_enable(struct drm_crtc *crtc,
 struct drm_atomic_state *state)
 {
-   struct lcdif_drm_private *lcdif = to_lcdif_drm_private(crtc->dev);
+   struct lcdif_drm_private *lcdif = to_lcdif_drm_private(crtc->drm_dev);
struct drm_crtc_state *new_cstate = 
drm_atomic_get_new_crtc_state(state, crtc);
struct drm_plane_state *new_pstate = 
drm_atomic_get_new_plane_state(state,

crtc->primary);
@@ -560,7 +560,7 @@ static void lcdif_crtc_atomic_enable(struct drm_crtc *crtc,
 static void lcdif_crtc_atomic_disable(struct drm_crtc *crtc,
  struct drm_atomic_state *state)
 {
-   struct lcdif_drm_private *lcdif = to_lcdif_drm_private(crtc->dev);
+   struct lcdif_drm_private *lcdif = to_lcdif_drm_private(crtc->drm_dev);
struct drm_device *drm = lcdif->drm;
struct drm_pending_vblank_event *event;
 
@@ -623,7 +623,7 @@ lcdif_crtc_atomic_duplicate_state(struct drm_crtc *crtc)
 
 static int lcdif_crtc_enable_vblank(struct drm_crtc *crtc)
 {
-   struct lcdif_drm_private *lcdif = to_lcdif_drm_private(crtc->dev);
+   struct lcdif_drm_private *lcdif = to_lcdif_drm_private(crtc->drm_dev);
 
/* Clear and enable VBLANK IRQ */
writel(INT_STATUS_D0_VS_BLANK, lcdif->base + LCDC_V8_INT_STATUS_D0);
@@ -634,7 +634,7 @@ static int lcdif_crtc_enable_vblank(struct drm_crtc *crtc)
 
 static void lcdif_crtc_disable_vblank(struct drm_crtc *crtc)
 {
-   struct lcdif_drm_private *lcdif = to_lcdif_drm_private(crtc->dev);
+   struct lcdif_drm_private *lcdif = to_lcdif_drm_private(crtc->drm_dev);
 
/* Disable and clear VBLANK IRQ */
writel(0, lcdif->base + LCDC_V8_INT_ENABLE_D0);
diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c 
b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
index 3bcc9c0f2019..934529b785ff 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
@@ -279,7 +279,7 @@ static void mxsfb_crtc_mode_set_nofb(struct 
mxsfb_drm_private *mxsfb,
 struct drm_bridge_state *bridge_state,
 const u32 bus_format)
 {
-   struct drm_device *drm = mxsfb->crtc.dev;
+   struct drm_device *drm = mxsfb->crtc.drm_dev;
struct drm_display_mode *m = &mxsfb->crtc.state

[PATCH RFC v1 50/52] drm/xen: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/xen/xen_drm_front_kms.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/xen/xen_drm_front_kms.c 
b/drivers/gpu/drm/xen/xen_drm_front_kms.c
index dfa78a49a6d9..72042139b73a 100644
--- a/drivers/gpu/drm/xen/xen_drm_front_kms.c
+++ b/drivers/gpu/drm/xen/xen_drm_front_kms.c
@@ -93,7 +93,7 @@ static const struct drm_mode_config_funcs mode_config_funcs = 
{
 static void send_pending_event(struct xen_drm_front_drm_pipeline *pipeline)
 {
struct drm_crtc *crtc = &pipeline->pipe.crtc;
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
unsigned long flags;
 
spin_lock_irqsave(&dev->event_lock, flags);
@@ -113,7 +113,7 @@ static void display_enable(struct drm_simple_display_pipe 
*pipe,
struct drm_framebuffer *fb = plane_state->fb;
int ret, idx;
 
-   if (!drm_dev_enter(pipe->crtc.dev, &idx))
+   if (!drm_dev_enter(pipe->crtc.drm_dev, &idx))
return;
 
ret = xen_drm_front_mode_set(pipeline, crtc->x, crtc->y,
@@ -135,7 +135,7 @@ static void display_disable(struct drm_simple_display_pipe 
*pipe)
to_xen_drm_pipeline(pipe);
int ret = 0, idx;
 
-   if (drm_dev_enter(pipe->crtc.dev, &idx)) {
+   if (drm_dev_enter(pipe->crtc.drm_dev, &idx)) {
ret = xen_drm_front_mode_set(pipeline, 0, 0, 0, 0, 0,
 xen_drm_front_fb_to_cookie(NULL));
drm_dev_exit(idx);
@@ -251,7 +251,7 @@ static void display_update(struct drm_simple_display_pipe 
*pipe,
 
event = crtc->state->event;
if (event) {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
unsigned long flags;
 
WARN_ON(pipeline->pending_event);
@@ -263,7 +263,7 @@ static void display_update(struct drm_simple_display_pipe 
*pipe,
spin_unlock_irqrestore(&dev->event_lock, flags);
}
 
-   if (!drm_dev_enter(pipe->crtc.dev, &idx)) {
+   if (!drm_dev_enter(pipe->crtc.drm_dev, &idx)) {
send_pending_event(pipeline);
return;
}
-- 
2.39.2



[PATCH RFC v1 18/52] drm/kmb: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/kmb/kmb_crtc.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/kmb/kmb_crtc.c b/drivers/gpu/drm/kmb/kmb_crtc.c
index 647872f65bff..5be50909d63b 100644
--- a/drivers/gpu/drm/kmb/kmb_crtc.c
+++ b/drivers/gpu/drm/kmb/kmb_crtc.c
@@ -28,7 +28,7 @@ struct kmb_crtc_timing {
 
 static int kmb_crtc_enable_vblank(struct drm_crtc *crtc)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct kmb_drm_private *kmb = to_kmb(dev);
 
/* Clear interrupt */
@@ -44,7 +44,7 @@ static int kmb_crtc_enable_vblank(struct drm_crtc *crtc)
 
 static void kmb_crtc_disable_vblank(struct drm_crtc *crtc)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct kmb_drm_private *kmb = to_kmb(dev);
 
/* Clear interrupt */
@@ -68,7 +68,7 @@ static const struct drm_crtc_funcs kmb_crtc_funcs = {
 static void kmb_crtc_set_mode(struct drm_crtc *crtc,
  struct drm_atomic_state *old_state)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct drm_display_mode *m = &crtc->state->adjusted_mode;
struct kmb_crtc_timing vm;
struct kmb_drm_private *kmb = to_kmb(dev);
@@ -158,7 +158,7 @@ static void kmb_crtc_atomic_disable(struct drm_crtc *crtc,
 static void kmb_crtc_atomic_begin(struct drm_crtc *crtc,
  struct drm_atomic_state *state)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct kmb_drm_private *kmb = to_kmb(dev);
 
kmb_clr_bitmask_lcd(kmb, LCD_INT_ENABLE,
@@ -168,13 +168,13 @@ static void kmb_crtc_atomic_begin(struct drm_crtc *crtc,
 static void kmb_crtc_atomic_flush(struct drm_crtc *crtc,
  struct drm_atomic_state *state)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct kmb_drm_private *kmb = to_kmb(dev);
 
kmb_set_bitmask_lcd(kmb, LCD_INT_ENABLE,
LCD_INT_VERT_COMP);
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
if (crtc->state->event) {
if (drm_crtc_vblank_get(crtc) == 0)
drm_crtc_arm_vblank_event(crtc, crtc->state->event);
@@ -182,7 +182,7 @@ static void kmb_crtc_atomic_flush(struct drm_crtc *crtc,
drm_crtc_send_vblank_event(crtc, crtc->state->event);
}
crtc->state->event = NULL;
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
 }
 
 static enum drm_mode_status
@@ -190,7 +190,7 @@ static enum drm_mode_status
const struct drm_display_mode *mode)
 {
int refresh;
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
int vfp = mode->vsync_start - mode->vdisplay;
 
if (mode->vdisplay < KMB_CRTC_MAX_HEIGHT) {
-- 
2.39.2



[PATCH RFC v1 10/52] drm/fsl-dcu: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c 
b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
index 2af60d98f48f..8f55b3f56faa 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
@@ -23,7 +23,7 @@
 static void fsl_dcu_drm_crtc_atomic_flush(struct drm_crtc *crtc,
  struct drm_atomic_state *state)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
struct drm_pending_vblank_event *event = crtc->state->event;
 
@@ -33,12 +33,12 @@ static void fsl_dcu_drm_crtc_atomic_flush(struct drm_crtc 
*crtc,
if (event) {
crtc->state->event = NULL;
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
if (drm_crtc_vblank_get(crtc) == 0)
drm_crtc_arm_vblank_event(crtc, event);
else
drm_crtc_send_vblank_event(crtc, event);
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
}
 }
 
@@ -47,7 +47,7 @@ static void fsl_dcu_drm_crtc_atomic_disable(struct drm_crtc 
*crtc,
 {
struct drm_crtc_state *old_crtc_state = 
drm_atomic_get_old_crtc_state(state,
  
crtc);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
 
/* always disable planes on the CRTC */
@@ -66,7 +66,7 @@ static void fsl_dcu_drm_crtc_atomic_disable(struct drm_crtc 
*crtc,
 static void fsl_dcu_drm_crtc_atomic_enable(struct drm_crtc *crtc,
   struct drm_atomic_state *state)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
 
clk_prepare_enable(fsl_dev->pix_clk);
@@ -81,7 +81,7 @@ static void fsl_dcu_drm_crtc_atomic_enable(struct drm_crtc 
*crtc,
 
 static void fsl_dcu_drm_crtc_mode_set_nofb(struct drm_crtc *crtc)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
struct drm_connector *con = &fsl_dev->connector.base;
struct drm_display_mode *mode = &crtc->state->mode;
@@ -134,7 +134,7 @@ static const struct drm_crtc_helper_funcs 
fsl_dcu_drm_crtc_helper_funcs = {
 
 static int fsl_dcu_drm_crtc_enable_vblank(struct drm_crtc *crtc)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
unsigned int value;
 
@@ -147,7 +147,7 @@ static int fsl_dcu_drm_crtc_enable_vblank(struct drm_crtc 
*crtc)
 
 static void fsl_dcu_drm_crtc_disable_vblank(struct drm_crtc *crtc)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
unsigned int value;
 
-- 
2.39.2



[PATCH RFC v1 01/52] drm/crtc: Start renaming struct drm_crtc::dev to drm_dev

2023-07-12 Thread Uwe Kleine-König
"dev" is usually used for struct device pointers. Using it for struct
drm_device pointers is irritating (for me at least). Introduce a
"drm_dev" as an alias with the intention to remove "dev" once all
drivers are adapted.

Signed-off-by: Uwe Kleine-König 
---
 include/drm/drm_crtc.h | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 8e1cbc75143e..66b65108024e 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -935,8 +935,16 @@ struct drm_crtc_funcs {
  * allows the CRTC to be controlled.
  */
 struct drm_crtc {
-   /** @dev: parent DRM device */
-   struct drm_device *dev;
+   /** @drm_dev: parent DRM device */
+   union {
+   /* "dev" is a name that is typically (only) used for struct
+* device pointers. It's about to be renamed to "drm_dev" to be
+* easier to parse for humans. To not have to convert all
+* drivers in a single step keep the old name around for now.
+*/
+   struct drm_device *drm_dev;
+   struct drm_device *dev;
+   };
/** @port: OF node used by drm_of_find_possible_crtcs(). */
struct device_node *port;
/**
-- 
2.39.2



[PATCH RFC v1 17/52] drm/ingenic: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c 
b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
index 5ec75e9ba499..68b20991f60c 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
@@ -442,12 +442,12 @@ static void ingenic_drm_crtc_atomic_flush(struct drm_crtc 
*crtc,
if (event) {
crtc_state->event = NULL;
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
if (drm_crtc_vblank_get(crtc) == 0)
drm_crtc_arm_vblank_event(crtc, event);
else
drm_crtc_send_vblank_event(crtc, event);
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
}
 }
 
-- 
2.39.2



[PATCH RFC v1 27/52] drm/omapdrm: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c | 56 ++---
 drivers/gpu/drm/omapdrm/omap_irq.c  |  6 ++--
 2 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 63ddc5127f7b..ab7bed69c1bd 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -70,9 +70,9 @@ static bool omap_crtc_is_pending(struct drm_crtc *crtc)
unsigned long flags;
bool pending;
 
-   spin_lock_irqsave(&crtc->dev->event_lock, flags);
+   spin_lock_irqsave(&crtc->drm_dev->event_lock, flags);
pending = omap_crtc->pending;
-   spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
+   spin_unlock_irqrestore(&crtc->drm_dev->event_lock, flags);
 
return pending;
 }
@@ -109,7 +109,7 @@ void omap_crtc_dss_start_update(struct omap_drm_private 
*priv,
 void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
 {
struct omap_crtc_state *omap_state = to_omap_crtc_state(crtc->state);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct omap_drm_private *priv = dev->dev_private;
struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
enum omap_channel channel = omap_crtc->channel;
@@ -228,7 +228,7 @@ int omap_crtc_dss_register_framedone(
 {
struct drm_crtc *crtc = priv->channels[channel]->crtc;
struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
-   struct drm_device *dev = omap_crtc->base.dev;
+   struct drm_device *dev = omap_crtc->base.drm_dev;
 
if (omap_crtc->framedone_handler)
return -EBUSY;
@@ -247,7 +247,7 @@ void omap_crtc_dss_unregister_framedone(
 {
struct drm_crtc *crtc = priv->channels[channel]->crtc;
struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
-   struct drm_device *dev = omap_crtc->base.dev;
+   struct drm_device *dev = omap_crtc->base.drm_dev;
 
dev_dbg(dev->dev, "unregister framedone %s", omap_crtc->name);
 
@@ -278,17 +278,17 @@ void omap_crtc_error_irq(struct drm_crtc *crtc, u32 
irqstatus)
 void omap_crtc_vblank_irq(struct drm_crtc *crtc)
 {
struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
-   struct drm_device *dev = omap_crtc->base.dev;
+   struct drm_device *dev = omap_crtc->base.drm_dev;
struct omap_drm_private *priv = dev->dev_private;
bool pending;
 
-   spin_lock(&crtc->dev->event_lock);
+   spin_lock(&crtc->drm_dev->event_lock);
/*
 * If the dispc is busy we're racing the flush operation. Try again on
 * the next vblank interrupt.
 */
if (dispc_mgr_go_busy(priv->dispc, omap_crtc->channel)) {
-   spin_unlock(&crtc->dev->event_lock);
+   spin_unlock(&crtc->drm_dev->event_lock);
return;
}
 
@@ -300,7 +300,7 @@ void omap_crtc_vblank_irq(struct drm_crtc *crtc)
 
pending = omap_crtc->pending;
omap_crtc->pending = false;
-   spin_unlock(&crtc->dev->event_lock);
+   spin_unlock(&crtc->drm_dev->event_lock);
 
if (pending)
drm_crtc_vblank_put(crtc);
@@ -320,14 +320,14 @@ void omap_crtc_framedone_irq(struct drm_crtc *crtc, 
uint32_t irqstatus)
 
omap_crtc->framedone_handler(omap_crtc->framedone_handler_data);
 
-   spin_lock(&crtc->dev->event_lock);
+   spin_lock(&crtc->drm_dev->event_lock);
/* Send the vblank event if one has been requested. */
if (omap_crtc->event) {
drm_crtc_send_vblank_event(crtc, omap_crtc->event);
omap_crtc->event = NULL;
}
omap_crtc->pending = false;
-   spin_unlock(&crtc->dev->event_lock);
+   spin_unlock(&crtc->drm_dev->event_lock);
 
/* Wake up omap_atomic_complete. */
wake_up(&omap_crtc->pending_wait);
@@ -350,7 +350,7 @@ static void omap_crtc_manual_display_update(struct 
work_struct *data)
struct omap_crtc *omap_crtc =
container_of(data, struct omap_crtc, update_work.work);
struct omap_dss_device *dssdev = omap_crtc->pipe->output;
-   struct drm_device *dev = omap_crtc->base.dev;
+   struct drm_device *dev = omap_crtc->base.drm_dev;
int ret;
 
if (!dssdev || !dssdev->dsi_ops || !dssdev->dsi_ops->update)
@@ -394,7 +394,7 @@ static void omap_crtc_cpr_coefs_from_ctm(const struct 
drm_color_ctm *ctm,
 
 static void omap_crtc_write_crtc_properties(struct drm_crtc *crtc)
 {
-   struct omap_drm_private *priv = crtc->dev->dev_private;
+   struct omap_drm_private *priv = crtc->drm_dev->dev_private;
struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
struct omap_overlay_manager_info info;
 
@@ -447,7 +447,7 @@ stati

[PATCH RFC v1 28/52] drm/panel-ili9341: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/panel/panel-ilitek-ili9341.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9341.c 
b/drivers/gpu/drm/panel/panel-ilitek-ili9341.c
index 3fdf884b3257..66ef305f5ef8 100644
--- a/drivers/gpu/drm/panel/panel-ilitek-ili9341.c
+++ b/drivers/gpu/drm/panel/panel-ilitek-ili9341.c
@@ -489,12 +489,12 @@ static void ili9341_dbi_enable(struct 
drm_simple_display_pipe *pipe,
   struct drm_crtc_state *crtc_state,
   struct drm_plane_state *plane_state)
 {
-   struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev);
+   struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.drm_dev);
struct mipi_dbi *dbi = &dbidev->dbi;
u8 addr_mode;
int ret, idx;
 
-   if (!drm_dev_enter(pipe->crtc.dev, &idx))
+   if (!drm_dev_enter(pipe->crtc.drm_dev, &idx))
return;
 
ret = mipi_dbi_poweron_conditional_reset(dbidev);
-- 
2.39.2



[PATCH RFC v1 39/52] drm/tegra: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/tegra/dc.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 6e78416e64b0..05504fe99a77 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -1717,7 +1717,7 @@ static struct drm_info_list debugfs_files[] = {
 static int tegra_dc_late_register(struct drm_crtc *crtc)
 {
unsigned int i, count = ARRAY_SIZE(debugfs_files);
-   struct drm_minor *minor = crtc->dev->primary;
+   struct drm_minor *minor = crtc->drm_dev->primary;
struct dentry *root;
struct tegra_dc *dc = to_tegra_dc(crtc);
 
@@ -1743,7 +1743,7 @@ static int tegra_dc_late_register(struct drm_crtc *crtc)
 static void tegra_dc_early_unregister(struct drm_crtc *crtc)
 {
unsigned int count = ARRAY_SIZE(debugfs_files);
-   struct drm_minor *minor = crtc->dev->primary;
+   struct drm_minor *minor = crtc->drm_dev->primary;
struct tegra_dc *dc = to_tegra_dc(crtc);
 
drm_debugfs_remove_files(dc->debugfs_files, count, minor);
@@ -2119,14 +2119,14 @@ static void tegra_crtc_atomic_disable(struct drm_crtc 
*crtc,
tegra_dc_stats_reset(&dc->stats);
drm_crtc_vblank_off(crtc);
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
 
if (crtc->state->event) {
drm_crtc_send_vblank_event(crtc, crtc->state->event);
crtc->state->event = NULL;
}
 
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
 
err = host1x_client_suspend(&dc->client);
if (err < 0)
@@ -2279,14 +2279,14 @@ static void tegra_crtc_atomic_begin(struct drm_crtc 
*crtc,
tegra_crtc_update_memory_bandwidth(crtc, state, true);
 
if (crtc->state->event) {
-   spin_lock_irqsave(&crtc->dev->event_lock, flags);
+   spin_lock_irqsave(&crtc->drm_dev->event_lock, flags);
 
if (drm_crtc_vblank_get(crtc) != 0)
drm_crtc_send_vblank_event(crtc, crtc->state->event);
else
drm_crtc_arm_vblank_event(crtc, crtc->state->event);
 
-   spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
+   spin_unlock_irqrestore(&crtc->drm_dev->event_lock, flags);
 
crtc->state->event = NULL;
}
-- 
2.39.2



[PATCH RFC v1 23/52] drm/mgag200: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/mgag200/mgag200_g200.c   |  4 ++--
 drivers/gpu/drm/mgag200/mgag200_g200eh.c |  2 +-
 drivers/gpu/drm/mgag200/mgag200_g200er.c |  4 ++--
 drivers/gpu/drm/mgag200/mgag200_g200ev.c |  4 ++--
 drivers/gpu/drm/mgag200/mgag200_g200se.c |  6 +++---
 drivers/gpu/drm/mgag200/mgag200_g200wb.c |  2 +-
 drivers/gpu/drm/mgag200/mgag200_mode.c   | 10 +-
 7 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_g200.c 
b/drivers/gpu/drm/mgag200/mgag200_g200.c
index bf5d7fe525a3..93cf3d3d0b6b 100644
--- a/drivers/gpu/drm/mgag200/mgag200_g200.c
+++ b/drivers/gpu/drm/mgag200/mgag200_g200.c
@@ -69,7 +69,7 @@ static int mgag200_g200_pixpllc_atomic_check(struct drm_crtc 
*crtc, struct drm_a
static const int feed_div_min = 7;
static const int feed_div_max = 127;
 
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct mgag200_g200_device *g200 = to_mgag200_g200_device(dev);
struct drm_crtc_state *new_crtc_state = 
drm_atomic_get_new_crtc_state(new_state, crtc);
struct mgag200_crtc_state *new_mgag200_crtc_state = 
to_mgag200_crtc_state(new_crtc_state);
@@ -139,7 +139,7 @@ static int mgag200_g200_pixpllc_atomic_check(struct 
drm_crtc *crtc, struct drm_a
 static void mgag200_g200_pixpllc_atomic_update(struct drm_crtc *crtc,
   struct drm_atomic_state 
*old_state)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct mga_device *mdev = to_mga_device(dev);
struct drm_crtc_state *crtc_state = crtc->state;
struct mgag200_crtc_state *mgag200_crtc_state = 
to_mgag200_crtc_state(crtc_state);
diff --git a/drivers/gpu/drm/mgag200/mgag200_g200eh.c 
b/drivers/gpu/drm/mgag200/mgag200_g200eh.c
index fad62453a91d..409f0c5a7d7a 100644
--- a/drivers/gpu/drm/mgag200/mgag200_g200eh.c
+++ b/drivers/gpu/drm/mgag200/mgag200_g200eh.c
@@ -92,7 +92,7 @@ static int mgag200_g200eh_pixpllc_atomic_check(struct 
drm_crtc *crtc,
 void mgag200_g200eh_pixpllc_atomic_update(struct drm_crtc *crtc,
  struct drm_atomic_state *old_state)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct mga_device *mdev = to_mga_device(dev);
struct drm_crtc_state *crtc_state = crtc->state;
struct mgag200_crtc_state *mgag200_crtc_state = 
to_mgag200_crtc_state(crtc_state);
diff --git a/drivers/gpu/drm/mgag200/mgag200_g200er.c 
b/drivers/gpu/drm/mgag200/mgag200_g200er.c
index bce267e0f7de..c452debaada6 100644
--- a/drivers/gpu/drm/mgag200/mgag200_g200er.c
+++ b/drivers/gpu/drm/mgag200/mgag200_g200er.c
@@ -120,7 +120,7 @@ static int mgag200_g200er_pixpllc_atomic_check(struct 
drm_crtc *crtc,
 static void mgag200_g200er_pixpllc_atomic_update(struct drm_crtc *crtc,
 struct drm_atomic_state 
*old_state)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct mga_device *mdev = to_mga_device(dev);
struct drm_crtc_state *crtc_state = crtc->state;
struct mgag200_crtc_state *mgag200_crtc_state = 
to_mgag200_crtc_state(crtc_state);
@@ -183,7 +183,7 @@ static const struct drm_plane_funcs 
mgag200_g200er_primary_plane_funcs = {
 static void mgag200_g200er_crtc_helper_atomic_enable(struct drm_crtc *crtc,
 struct drm_atomic_state 
*old_state)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct mga_device *mdev = to_mga_device(dev);
const struct mgag200_device_funcs *funcs = mdev->funcs;
struct drm_crtc_state *crtc_state = crtc->state;
diff --git a/drivers/gpu/drm/mgag200/mgag200_g200ev.c 
b/drivers/gpu/drm/mgag200/mgag200_g200ev.c
index ac957f42abe1..dca055633f91 100644
--- a/drivers/gpu/drm/mgag200/mgag200_g200ev.c
+++ b/drivers/gpu/drm/mgag200/mgag200_g200ev.c
@@ -99,7 +99,7 @@ static int mgag200_g200ev_pixpllc_atomic_check(struct 
drm_crtc *crtc,
 static void mgag200_g200ev_pixpllc_atomic_update(struct drm_crtc *crtc,
 struct drm_atomic_state 
*old_state)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct mga_device *mdev = to_mga_device(dev);
struct drm_crtc_state *crtc_state = crtc->state;
struct mgag200_crtc_state *mgag200_crtc_state = 
to_mgag200_crtc_state(crtc_state);
@@ -184,7 +184,7 @@ static const struct drm_plane_funcs 
mgag200_g200ev_primary_plane_funcs = {
 static void mgag200_g200ev_crtc_helper_atomic_enable(struct drm_crtc *crtc,

[PATCH RFC v1 45/52] drm/vboxvideo: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/vboxvideo/vbox_mode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vboxvideo/vbox_mode.c 
b/drivers/gpu/drm/vboxvideo/vbox_mode.c
index 341edd982cb3..0d415e554898 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_mode.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_mode.c
@@ -41,7 +41,7 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
u16 flags;
s32 x_offset, y_offset;
 
-   vbox = to_vbox_dev(crtc->dev);
+   vbox = to_vbox_dev(crtc->drm_dev);
width = vbox_crtc->width ? vbox_crtc->width : 640;
height = vbox_crtc->height ? vbox_crtc->height : 480;
bpp = fb ? fb->format->cpp[0] * 8 : 32;
@@ -82,7 +82,7 @@ static void vbox_do_modeset(struct drm_crtc *crtc)
 static int vbox_set_view(struct drm_crtc *crtc)
 {
struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
-   struct vbox_private *vbox = to_vbox_dev(crtc->dev);
+   struct vbox_private *vbox = to_vbox_dev(crtc->drm_dev);
struct vbva_infoview *p;
 
/*
@@ -179,7 +179,7 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc 
*crtc,
int x, int y)
 {
struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(fb->obj[0]);
-   struct vbox_private *vbox = to_vbox_dev(crtc->dev);
+   struct vbox_private *vbox = to_vbox_dev(crtc->drm_dev);
struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
bool needs_modeset = drm_atomic_crtc_needs_modeset(crtc->state);
 
-- 
2.39.2



[PATCH RFC v1 19/52] drm/logicvc: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/logicvc/logicvc_crtc.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/logicvc/logicvc_crtc.c 
b/drivers/gpu/drm/logicvc/logicvc_crtc.c
index 43a675d03808..e7e65381ab6f 100644
--- a/drivers/gpu/drm/logicvc/logicvc_crtc.c
+++ b/drivers/gpu/drm/logicvc/logicvc_crtc.c
@@ -41,7 +41,7 @@ static void logicvc_crtc_atomic_begin(struct drm_crtc 
*drm_crtc,
struct logicvc_crtc *crtc = logicvc_crtc(drm_crtc);
struct drm_crtc_state *old_state =
drm_atomic_get_old_crtc_state(state, drm_crtc);
-   struct drm_device *drm_dev = drm_crtc->dev;
+   struct drm_device *drm_dev = drm_crtc->drm_dev;
unsigned long flags;
 
/*
@@ -63,14 +63,14 @@ static void logicvc_crtc_atomic_enable(struct drm_crtc 
*drm_crtc,
   struct drm_atomic_state *state)
 {
struct logicvc_crtc *crtc = logicvc_crtc(drm_crtc);
-   struct logicvc_drm *logicvc = logicvc_drm(drm_crtc->dev);
+   struct logicvc_drm *logicvc = logicvc_drm(drm_crtc->drm_dev);
struct drm_crtc_state *old_state =
drm_atomic_get_old_crtc_state(state, drm_crtc);
struct drm_crtc_state *new_state =
drm_atomic_get_new_crtc_state(state, drm_crtc);
struct drm_display_mode *mode = &new_state->adjusted_mode;
 
-   struct drm_device *drm_dev = drm_crtc->dev;
+   struct drm_device *drm_dev = drm_crtc->drm_dev;
unsigned int hact, hfp, hsl, hbp;
unsigned int vact, vfp, vsl, vbp;
unsigned long flags;
@@ -152,8 +152,8 @@ static void logicvc_crtc_atomic_enable(struct drm_crtc 
*drm_crtc,
 static void logicvc_crtc_atomic_disable(struct drm_crtc *drm_crtc,
struct drm_atomic_state *state)
 {
-   struct logicvc_drm *logicvc = logicvc_drm(drm_crtc->dev);
-   struct drm_device *drm_dev = drm_crtc->dev;
+   struct logicvc_drm *logicvc = logicvc_drm(drm_crtc->drm_dev);
+   struct drm_device *drm_dev = drm_crtc->drm_dev;
 
drm_crtc_vblank_off(drm_crtc);
 
@@ -190,7 +190,7 @@ static const struct drm_crtc_helper_funcs 
logicvc_crtc_helper_funcs = {
 
 static int logicvc_crtc_enable_vblank(struct drm_crtc *drm_crtc)
 {
-   struct logicvc_drm *logicvc = logicvc_drm(drm_crtc->dev);
+   struct logicvc_drm *logicvc = logicvc_drm(drm_crtc->drm_dev);
 
/* Clear any pending V_SYNC interrupt. */
regmap_write_bits(logicvc->regmap, LOGICVC_INT_STAT_REG,
@@ -205,7 +205,7 @@ static int logicvc_crtc_enable_vblank(struct drm_crtc 
*drm_crtc)
 
 static void logicvc_crtc_disable_vblank(struct drm_crtc *drm_crtc)
 {
-   struct logicvc_drm *logicvc = logicvc_drm(drm_crtc->dev);
+   struct logicvc_drm *logicvc = logicvc_drm(drm_crtc->drm_dev);
 
/* Mask V_SYNC interrupt. */
regmap_write_bits(logicvc->regmap, LOGICVC_INT_MASK_REG,
-- 
2.39.2



[PATCH RFC v1 44/52] drm/udl: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/udl/udl_modeset.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_modeset.c 
b/drivers/gpu/drm/udl/udl_modeset.c
index aa02fd2789c3..e8625fccad10 100644
--- a/drivers/gpu/drm/udl/udl_modeset.c
+++ b/drivers/gpu/drm/udl/udl_modeset.c
@@ -322,7 +322,7 @@ static int udl_crtc_helper_atomic_check(struct drm_crtc 
*crtc, struct drm_atomic
 
 static void udl_crtc_helper_atomic_enable(struct drm_crtc *crtc, struct 
drm_atomic_state *state)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct drm_crtc_state *crtc_state = 
drm_atomic_get_new_crtc_state(state, crtc);
struct drm_display_mode *mode = &crtc_state->mode;
struct urb *urb;
@@ -356,7 +356,7 @@ static void udl_crtc_helper_atomic_enable(struct drm_crtc 
*crtc, struct drm_atom
 
 static void udl_crtc_helper_atomic_disable(struct drm_crtc *crtc, struct 
drm_atomic_state *state)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct urb *urb;
char *buf;
int idx;
-- 
2.39.2



[PATCH RFC v1 36/52] drm/sti: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/sti/sti_crtc.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/sti/sti_crtc.c b/drivers/gpu/drm/sti/sti_crtc.c
index 3c7154f2d5f3..ce648439d0a3 100644
--- a/drivers/gpu/drm/sti/sti_crtc.c
+++ b/drivers/gpu/drm/sti/sti_crtc.c
@@ -134,7 +134,7 @@ sti_crtc_mode_set_nofb(struct drm_crtc *crtc)
 static void sti_crtc_atomic_flush(struct drm_crtc *crtc,
  struct drm_atomic_state *state)
 {
-   struct drm_device *drm_dev = crtc->dev;
+   struct drm_device *drm_dev = crtc->drm_dev;
struct sti_mixer *mixer = to_sti_mixer(crtc);
struct sti_compositor *compo = dev_get_drvdata(mixer->dev);
struct drm_plane *p;
@@ -209,12 +209,12 @@ static void sti_crtc_atomic_flush(struct drm_crtc *crtc,
if (event) {
crtc->state->event = NULL;
 
-   spin_lock_irqsave(&crtc->dev->event_lock, flags);
+   spin_lock_irqsave(&crtc->drm_dev->event_lock, flags);
if (drm_crtc_vblank_get(crtc) == 0)
drm_crtc_arm_vblank_event(crtc, event);
else
drm_crtc_send_vblank_event(crtc, event);
-   spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
+   spin_unlock_irqrestore(&crtc->drm_dev->event_lock, flags);
}
 }
 
@@ -264,7 +264,7 @@ int sti_crtc_vblank_cb(struct notifier_block *nb,
 
/* Disable mixer only if all overlay planes (GDP and VDP)
 * are disabled */
-   list_for_each_entry(p, &crtc->dev->mode_config.plane_list,
+   list_for_each_entry(p, &crtc->drm_dev->mode_config.plane_list,
head) {
struct sti_plane *plane = to_sti_plane(p);
 
@@ -280,7 +280,7 @@ int sti_crtc_vblank_cb(struct notifier_block *nb,
 
 static int sti_crtc_enable_vblank(struct drm_crtc *crtc)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
unsigned int pipe = crtc->index;
struct sti_private *dev_priv = dev->dev_private;
struct sti_compositor *compo = dev_priv->compo;
@@ -299,7 +299,7 @@ static int sti_crtc_enable_vblank(struct drm_crtc *crtc)
 
 static void sti_crtc_disable_vblank(struct drm_crtc *crtc)
 {
-   struct drm_device *drm_dev = crtc->dev;
+   struct drm_device *drm_dev = crtc->drm_dev;
unsigned int pipe = crtc->index;
struct sti_private *priv = drm_dev->dev_private;
struct sti_compositor *compo = priv->compo;
@@ -318,7 +318,7 @@ static int sti_crtc_late_register(struct drm_crtc *crtc)
struct sti_compositor *compo = dev_get_drvdata(mixer->dev);
 
if (drm_crtc_index(crtc) == 0)
-   sti_compositor_debugfs_init(compo, crtc->dev->primary);
+   sti_compositor_debugfs_init(compo, crtc->drm_dev->primary);
 
return 0;
 }
-- 
2.39.2



[PATCH RFC v1 40/52] drm/tidss: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/tidss/tidss_crtc.c | 19 ++-
 drivers/gpu/drm/tidss/tidss_irq.c  |  4 ++--
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/tidss/tidss_crtc.c 
b/drivers/gpu/drm/tidss/tidss_crtc.c
index 5e5e466f35d1..d3399d6ca5e5 100644
--- a/drivers/gpu/drm/tidss/tidss_crtc.c
+++ b/drivers/gpu/drm/tidss/tidss_crtc.c
@@ -20,7 +20,7 @@
 
 static void tidss_crtc_finish_page_flip(struct tidss_crtc *tcrtc)
 {
-   struct drm_device *ddev = tcrtc->crtc.dev;
+   struct drm_device *ddev = tcrtc->crtc.drm_dev;
struct tidss_device *tidss = to_tidss(ddev);
struct drm_pending_vblank_event *event;
unsigned long flags;
@@ -75,7 +75,8 @@ void tidss_crtc_error_irq(struct drm_crtc *crtc, u64 
irqstatus)
 {
struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
 
-   dev_err_ratelimited(crtc->dev->dev, "CRTC%u SYNC LOST: (irq %llx)\n",
+   dev_err_ratelimited(crtc->drm_dev->dev,
+   "CRTC%u SYNC LOST: (irq %llx)\n",
tcrtc->hw_videoport, irqstatus);
 }
 
@@ -86,7 +87,7 @@ static int tidss_crtc_atomic_check(struct drm_crtc *crtc,
 {
struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
  crtc);
-   struct drm_device *ddev = crtc->dev;
+   struct drm_device *ddev = crtc->drm_dev;
struct tidss_device *tidss = to_tidss(ddev);
struct dispc_device *dispc = tidss->dispc;
struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
@@ -165,7 +166,7 @@ static void tidss_crtc_atomic_flush(struct drm_crtc *crtc,
struct drm_crtc_state *old_crtc_state = 
drm_atomic_get_old_crtc_state(state,
  
crtc);
struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
-   struct drm_device *ddev = crtc->dev;
+   struct drm_device *ddev = crtc->drm_dev;
struct tidss_device *tidss = to_tidss(ddev);
unsigned long flags;
 
@@ -218,7 +219,7 @@ static void tidss_crtc_atomic_enable(struct drm_crtc *crtc,
struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state,
 crtc);
struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
-   struct drm_device *ddev = crtc->dev;
+   struct drm_device *ddev = crtc->drm_dev;
struct tidss_device *tidss = to_tidss(ddev);
const struct drm_display_mode *mode = &crtc->state->adjusted_mode;
unsigned long flags;
@@ -261,7 +262,7 @@ static void tidss_crtc_atomic_disable(struct drm_crtc *crtc,
  struct drm_atomic_state *state)
 {
struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
-   struct drm_device *ddev = crtc->dev;
+   struct drm_device *ddev = crtc->drm_dev;
struct tidss_device *tidss = to_tidss(ddev);
unsigned long flags;
 
@@ -297,7 +298,7 @@ enum drm_mode_status tidss_crtc_mode_valid(struct drm_crtc 
*crtc,
   const struct drm_display_mode *mode)
 {
struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
-   struct drm_device *ddev = crtc->dev;
+   struct drm_device *ddev = crtc->drm_dev;
struct tidss_device *tidss = to_tidss(ddev);
 
return dispc_vp_mode_valid(tidss->dispc, tcrtc->hw_videoport, mode);
@@ -316,7 +317,7 @@ static const struct drm_crtc_helper_funcs 
tidss_crtc_helper_funcs = {
 
 static int tidss_crtc_enable_vblank(struct drm_crtc *crtc)
 {
-   struct drm_device *ddev = crtc->dev;
+   struct drm_device *ddev = crtc->drm_dev;
struct tidss_device *tidss = to_tidss(ddev);
 
dev_dbg(ddev->dev, "%s\n", __func__);
@@ -330,7 +331,7 @@ static int tidss_crtc_enable_vblank(struct drm_crtc *crtc)
 
 static void tidss_crtc_disable_vblank(struct drm_crtc *crtc)
 {
-   struct drm_device *ddev = crtc->dev;
+   struct drm_device *ddev = crtc->drm_dev;
struct tidss_device *tidss = to_tidss(ddev);
 
dev_dbg(ddev->dev, "%s\n", __func__);
diff --git a/drivers/gpu/drm/tidss/tidss_irq.c 
b/drivers/gpu/drm/tidss/tidss_irq.c
index 0c681c7600bc..a30964e02a57 100644
--- a/drivers/gpu/drm/tidss/tidss_irq.c
+++ b/drivers/gpu/drm/tidss/tidss_irq.c
@@ -25,7 +25,7 @@ static void tidss_irq_update(struct tidss_device *tidss)
 
 void tidss_irq_enable_vblank(struct drm_crtc *crtc)
 {
-   struct drm_device *ddev = crtc->dev;
+   struct drm_device *ddev = crtc->drm_dev;
struct tidss_device *tidss = to_tidss(ddev);
struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
u32 hw_videoport = tcrtc->hw_videoport;
@@ -40,7 +40,7 @@ void tidss_irq_enable_vblank(struct drm_crtc 

[PATCH RFC v1 34/52] drm/solomon: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/solomon/ssd130x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/solomon/ssd130x.c 
b/drivers/gpu/drm/solomon/ssd130x.c
index 8cbf5aa66e19..d256ad065f3e 100644
--- a/drivers/gpu/drm/solomon/ssd130x.c
+++ b/drivers/gpu/drm/solomon/ssd130x.c
@@ -640,7 +640,7 @@ static const struct drm_plane_funcs 
ssd130x_primary_plane_funcs = {
 static enum drm_mode_status ssd130x_crtc_helper_mode_valid(struct drm_crtc 
*crtc,
   const struct 
drm_display_mode *mode)
 {
-   struct ssd130x_device *ssd130x = drm_to_ssd130x(crtc->dev);
+   struct ssd130x_device *ssd130x = drm_to_ssd130x(crtc->drm_dev);
 
if (mode->hdisplay != ssd130x->mode.hdisplay &&
mode->vdisplay != ssd130x->mode.vdisplay)
-- 
2.39.2



[PATCH RFC v1 20/52] drm/mcde: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/mcde/mcde_display.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/mcde/mcde_display.c 
b/drivers/gpu/drm/mcde/mcde_display.c
index 52043a12a2e8..3d5e3639d4af 100644
--- a/drivers/gpu/drm/mcde/mcde_display.c
+++ b/drivers/gpu/drm/mcde/mcde_display.c
@@ -1154,7 +1154,7 @@ static void mcde_display_enable(struct 
drm_simple_display_pipe *pipe,
 {
struct drm_crtc *crtc = &pipe->crtc;
struct drm_plane *plane = &pipe->plane;
-   struct drm_device *drm = crtc->dev;
+   struct drm_device *drm = crtc->drm_dev;
struct mcde *mcde = to_mcde(drm);
const struct drm_display_mode *mode = &cstate->mode;
struct drm_framebuffer *fb = plane->state->fb;
@@ -1300,7 +1300,7 @@ static void mcde_display_enable(struct 
drm_simple_display_pipe *pipe,
 static void mcde_display_disable(struct drm_simple_display_pipe *pipe)
 {
struct drm_crtc *crtc = &pipe->crtc;
-   struct drm_device *drm = crtc->dev;
+   struct drm_device *drm = crtc->drm_dev;
struct mcde *mcde = to_mcde(drm);
struct drm_pending_vblank_event *event;
int ret;
@@ -1321,9 +1321,9 @@ static void mcde_display_disable(struct 
drm_simple_display_pipe *pipe)
if (event) {
crtc->state->event = NULL;
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
drm_crtc_send_vblank_event(crtc, event);
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
}
 
ret = regulator_disable(mcde->epod);
@@ -1384,7 +1384,7 @@ static void mcde_display_update(struct 
drm_simple_display_pipe *pipe,
struct drm_plane_state *old_pstate)
 {
struct drm_crtc *crtc = &pipe->crtc;
-   struct drm_device *drm = crtc->dev;
+   struct drm_device *drm = crtc->drm_dev;
struct mcde *mcde = to_mcde(drm);
struct drm_pending_vblank_event *event = crtc->state->event;
struct drm_plane *plane = &pipe->plane;
@@ -1399,7 +1399,7 @@ static void mcde_display_update(struct 
drm_simple_display_pipe *pipe,
if (event) {
crtc->state->event = NULL;
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
/*
 * Hardware must be on before we can arm any vblank event,
 * this is not a scanout controller where there is always
@@ -1415,7 +1415,7 @@ static void mcde_display_update(struct 
drm_simple_display_pipe *pipe,
drm_crtc_send_vblank_event(crtc, event);
}
 
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
}
 
/*
@@ -1445,7 +1445,7 @@ static void mcde_display_update(struct 
drm_simple_display_pipe *pipe,
 static int mcde_display_enable_vblank(struct drm_simple_display_pipe *pipe)
 {
struct drm_crtc *crtc = &pipe->crtc;
-   struct drm_device *drm = crtc->dev;
+   struct drm_device *drm = crtc->drm_dev;
struct mcde *mcde = to_mcde(drm);
u32 val;
 
@@ -1464,7 +1464,7 @@ static int mcde_display_enable_vblank(struct 
drm_simple_display_pipe *pipe)
 static void mcde_display_disable_vblank(struct drm_simple_display_pipe *pipe)
 {
struct drm_crtc *crtc = &pipe->crtc;
-   struct drm_device *drm = crtc->dev;
+   struct drm_device *drm = crtc->drm_dev;
struct mcde *mcde = to_mcde(drm);
 
/* Disable all VBLANK IRQs */
-- 
2.39.2



[PATCH RFC v1 22/52] drm/meson: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/meson/meson_crtc.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/meson/meson_crtc.c 
b/drivers/gpu/drm/meson/meson_crtc.c
index d70616da8ce2..4bc082e45ed1 100644
--- a/drivers/gpu/drm/meson/meson_crtc.c
+++ b/drivers/gpu/drm/meson/meson_crtc.c
@@ -162,9 +162,9 @@ static void meson_g12a_crtc_atomic_disable(struct drm_crtc 
*crtc,
priv->viu.vd1_commit = false;
 
if (crtc->state->event && !crtc->state->active) {
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
drm_crtc_send_vblank_event(crtc, crtc->state->event);
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
 
crtc->state->event = NULL;
}
@@ -192,9 +192,9 @@ static void meson_crtc_atomic_disable(struct drm_crtc *crtc,
priv->io_base + _REG(VPP_MISC));
 
if (crtc->state->event && !crtc->state->active) {
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
drm_crtc_send_vblank_event(crtc, crtc->state->event);
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
 
crtc->state->event = NULL;
}
@@ -209,9 +209,9 @@ static void meson_crtc_atomic_begin(struct drm_crtc *crtc,
if (crtc->state->event) {
WARN_ON(drm_crtc_vblank_get(crtc) != 0);
 
-   spin_lock_irqsave(&crtc->dev->event_lock, flags);
+   spin_lock_irqsave(&crtc->drm_dev->event_lock, flags);
meson_crtc->event = crtc->state->event;
-   spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
+   spin_unlock_irqrestore(&crtc->drm_dev->event_lock, flags);
crtc->state->event = NULL;
}
 }
-- 
2.39.2



[PATCH RFC v1 02/52] drm/core: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/drm_atomic.c  | 22 ++---
 drivers/gpu/drm/drm_atomic_helper.c   | 20 +++-
 drivers/gpu/drm/drm_atomic_state_helper.c |  2 +-
 drivers/gpu/drm/drm_atomic_uapi.c | 22 ++---
 drivers/gpu/drm/drm_blend.c   |  2 +-
 drivers/gpu/drm/drm_color_mgmt.c  | 10 +++---
 drivers/gpu/drm/drm_crtc.c| 19 ++-
 drivers/gpu/drm/drm_crtc_helper.c | 10 +++---
 drivers/gpu/drm/drm_debugfs.c |  2 +-
 drivers/gpu/drm/drm_debugfs_crc.c |  2 +-
 drivers/gpu/drm/drm_fb_helper.c   |  6 ++--
 drivers/gpu/drm/drm_mipi_dbi.c|  4 +--
 drivers/gpu/drm/drm_plane.c   |  2 +-
 drivers/gpu/drm/drm_plane_helper.c|  2 +-
 drivers/gpu/drm/drm_self_refresh_helper.c |  2 +-
 drivers/gpu/drm/drm_vblank.c  | 40 +++
 drivers/gpu/drm/drm_vblank_work.c |  2 +-
 include/drm/drm_atomic_helper.h   |  2 +-
 18 files changed, 87 insertions(+), 84 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 2c454568a607..b607bcfdb616 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -76,7 +76,7 @@ int drm_crtc_commit_wait(struct drm_crtc_commit *commit)
 
ret = wait_for_completion_timeout(&commit->hw_done, timeout);
if (!ret) {
-   drm_err(commit->crtc->dev, "hw_done timed out\n");
+   drm_err(commit->crtc->drm_dev, "hw_done timed out\n");
return -ETIMEDOUT;
}
 
@@ -86,7 +86,7 @@ int drm_crtc_commit_wait(struct drm_crtc_commit *commit)
 */
ret = wait_for_completion_timeout(&commit->flip_done, timeout);
if (!ret) {
-   drm_err(commit->crtc->dev, "flip_done timed out\n");
+   drm_err(commit->crtc->drm_dev, "flip_done timed out\n");
return -ETIMEDOUT;
}
 
@@ -381,7 +381,7 @@ static int drm_atomic_crtc_check(const struct 
drm_crtc_state *old_crtc_state,
 */
 
if (new_crtc_state->active && !new_crtc_state->enable) {
-   drm_dbg_atomic(crtc->dev,
+   drm_dbg_atomic(crtc->drm_dev,
   "[CRTC:%d:%s] active without enabled\n",
   crtc->base.id, crtc->name);
return -EINVAL;
@@ -391,17 +391,17 @@ static int drm_atomic_crtc_check(const struct 
drm_crtc_state *old_crtc_state,
 * as this is a kernel-internal detail that userspace should never
 * be able to trigger.
 */
-   if (drm_core_check_feature(crtc->dev, DRIVER_ATOMIC) &&
+   if (drm_core_check_feature(crtc->drm_dev, DRIVER_ATOMIC) &&
WARN_ON(new_crtc_state->enable && !new_crtc_state->mode_blob)) {
-   drm_dbg_atomic(crtc->dev,
+   drm_dbg_atomic(crtc->drm_dev,
   "[CRTC:%d:%s] enabled without mode blob\n",
   crtc->base.id, crtc->name);
return -EINVAL;
}
 
-   if (drm_core_check_feature(crtc->dev, DRIVER_ATOMIC) &&
+   if (drm_core_check_feature(crtc->drm_dev, DRIVER_ATOMIC) &&
WARN_ON(!new_crtc_state->enable && new_crtc_state->mode_blob)) {
-   drm_dbg_atomic(crtc->dev,
+   drm_dbg_atomic(crtc->drm_dev,
   "[CRTC:%d:%s] disabled with mode blob\n",
   crtc->base.id, crtc->name);
return -EINVAL;
@@ -419,7 +419,7 @@ static int drm_atomic_crtc_check(const struct 
drm_crtc_state *old_crtc_state,
 */
if (new_crtc_state->event &&
!new_crtc_state->active && !old_crtc_state->active) {
-   drm_dbg_atomic(crtc->dev,
+   drm_dbg_atomic(crtc->drm_dev,
   "[CRTC:%d:%s] requesting event but off\n",
   crtc->base.id, crtc->name);
return -EINVAL;
@@ -1294,7 +1294,7 @@ drm_atomic_add_affected_connectors(struct 
drm_atomic_state *state,
if (ret)
return ret;
 
-   drm_dbg_atomic(crtc->dev,
+   drm_dbg_atomic(crtc->drm_dev,
   "Adding all current connectors for [CRTC:%d:%s] to %p\n",
   crtc->base.id, crtc->name, state);
 
@@ -1349,7 +1349,7 @@ drm_atomic_add_affected_planes(struct drm_atomic_state 
*state,
 
WARN_ON(!drm_atomic_get_new_crtc_state(state, crtc));
 
-   drm_dbg_atomic(crtc->dev,
+   drm_dbg_atomic(crtc->drm_dev,
   "Adding all current planes for [CRTC:%d:%s] to %p\n",
   crtc->base.id, crtc->name, state);
 
@@ -1561,7 +1561,7 @@ EXPORT_SYMBOL(__drm_atomic_helper_disable_plane);
 static int update_o

[PATCH RFC v1 29/52] drm/pl111: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/pl111/pl111_display.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/pl111/pl111_display.c 
b/drivers/gpu/drm/pl111/pl111_display.c
index b9fe926a49e8..6d16933ff7e5 100644
--- a/drivers/gpu/drm/pl111/pl111_display.c
+++ b/drivers/gpu/drm/pl111/pl111_display.c
@@ -51,7 +51,7 @@ static enum drm_mode_status
 pl111_mode_valid(struct drm_simple_display_pipe *pipe,
 const struct drm_display_mode *mode)
 {
-   struct drm_device *drm = pipe->crtc.dev;
+   struct drm_device *drm = pipe->crtc.drm_dev;
struct pl111_drm_dev_private *priv = drm->dev_private;
u32 cpp = DIV_ROUND_UP(priv->variant->fb_depth, 8);
u64 bw;
@@ -122,7 +122,7 @@ static void pl111_display_enable(struct 
drm_simple_display_pipe *pipe,
 {
struct drm_crtc *crtc = &pipe->crtc;
struct drm_plane *plane = &pipe->plane;
-   struct drm_device *drm = crtc->dev;
+   struct drm_device *drm = crtc->drm_dev;
struct pl111_drm_dev_private *priv = drm->dev_private;
const struct drm_display_mode *mode = &cstate->mode;
struct drm_framebuffer *fb = plane->state->fb;
@@ -357,7 +357,7 @@ static void pl111_display_enable(struct 
drm_simple_display_pipe *pipe,
 static void pl111_display_disable(struct drm_simple_display_pipe *pipe)
 {
struct drm_crtc *crtc = &pipe->crtc;
-   struct drm_device *drm = crtc->dev;
+   struct drm_device *drm = crtc->drm_dev;
struct pl111_drm_dev_private *priv = drm->dev_private;
u32 cntl;
 
@@ -390,7 +390,7 @@ static void pl111_display_update(struct 
drm_simple_display_pipe *pipe,
 struct drm_plane_state *old_pstate)
 {
struct drm_crtc *crtc = &pipe->crtc;
-   struct drm_device *drm = crtc->dev;
+   struct drm_device *drm = crtc->drm_dev;
struct pl111_drm_dev_private *priv = drm->dev_private;
struct drm_pending_vblank_event *event = crtc->state->event;
struct drm_plane *plane = &pipe->plane;
@@ -406,19 +406,19 @@ static void pl111_display_update(struct 
drm_simple_display_pipe *pipe,
if (event) {
crtc->state->event = NULL;
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
if (crtc->state->active && drm_crtc_vblank_get(crtc) == 0)
drm_crtc_arm_vblank_event(crtc, event);
else
drm_crtc_send_vblank_event(crtc, event);
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
}
 }
 
 static int pl111_display_enable_vblank(struct drm_simple_display_pipe *pipe)
 {
struct drm_crtc *crtc = &pipe->crtc;
-   struct drm_device *drm = crtc->dev;
+   struct drm_device *drm = crtc->drm_dev;
struct pl111_drm_dev_private *priv = drm->dev_private;
 
writel(CLCD_IRQ_NEXTBASE_UPDATE, priv->regs + priv->ienb);
@@ -429,7 +429,7 @@ static int pl111_display_enable_vblank(struct 
drm_simple_display_pipe *pipe)
 static void pl111_display_disable_vblank(struct drm_simple_display_pipe *pipe)
 {
struct drm_crtc *crtc = &pipe->crtc;
-   struct drm_device *drm = crtc->dev;
+   struct drm_device *drm = crtc->drm_dev;
struct pl111_drm_dev_private *priv = drm->dev_private;
 
writel(0, priv->regs + priv->ienb);
-- 
2.39.2



[PATCH RFC v1 43/52] drm/tve200: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/tve200/tve200_display.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/tve200/tve200_display.c 
b/drivers/gpu/drm/tve200/tve200_display.c
index 37bdd976ae59..93dfd2dfed2a 100644
--- a/drivers/gpu/drm/tve200/tve200_display.c
+++ b/drivers/gpu/drm/tve200/tve200_display.c
@@ -124,7 +124,7 @@ static void tve200_display_enable(struct 
drm_simple_display_pipe *pipe,
 {
struct drm_crtc *crtc = &pipe->crtc;
struct drm_plane *plane = &pipe->plane;
-   struct drm_device *drm = crtc->dev;
+   struct drm_device *drm = crtc->drm_dev;
struct tve200_drm_dev_private *priv = drm->dev_private;
const struct drm_display_mode *mode = &cstate->mode;
struct drm_framebuffer *fb = plane->state->fb;
@@ -242,7 +242,7 @@ static void tve200_display_enable(struct 
drm_simple_display_pipe *pipe,
 static void tve200_display_disable(struct drm_simple_display_pipe *pipe)
 {
struct drm_crtc *crtc = &pipe->crtc;
-   struct drm_device *drm = crtc->dev;
+   struct drm_device *drm = crtc->drm_dev;
struct tve200_drm_dev_private *priv = drm->dev_private;
 
drm_crtc_vblank_off(crtc);
@@ -258,7 +258,7 @@ static void tve200_display_update(struct 
drm_simple_display_pipe *pipe,
 struct drm_plane_state *old_pstate)
 {
struct drm_crtc *crtc = &pipe->crtc;
-   struct drm_device *drm = crtc->dev;
+   struct drm_device *drm = crtc->drm_dev;
struct tve200_drm_dev_private *priv = drm->dev_private;
struct drm_pending_vblank_event *event = crtc->state->event;
struct drm_plane *plane = &pipe->plane;
@@ -282,19 +282,19 @@ static void tve200_display_update(struct 
drm_simple_display_pipe *pipe,
if (event) {
crtc->state->event = NULL;
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
if (crtc->state->active && drm_crtc_vblank_get(crtc) == 0)
drm_crtc_arm_vblank_event(crtc, event);
else
drm_crtc_send_vblank_event(crtc, event);
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
}
 }
 
 static int tve200_display_enable_vblank(struct drm_simple_display_pipe *pipe)
 {
struct drm_crtc *crtc = &pipe->crtc;
-   struct drm_device *drm = crtc->dev;
+   struct drm_device *drm = crtc->drm_dev;
struct tve200_drm_dev_private *priv = drm->dev_private;
 
/* Clear any IRQs and enable */
@@ -306,7 +306,7 @@ static int tve200_display_enable_vblank(struct 
drm_simple_display_pipe *pipe)
 static void tve200_display_disable_vblank(struct drm_simple_display_pipe *pipe)
 {
struct drm_crtc *crtc = &pipe->crtc;
-   struct drm_device *drm = crtc->dev;
+   struct drm_device *drm = crtc->drm_dev;
struct tve200_drm_dev_private *priv = drm->dev_private;
 
writel(0, priv->regs + TVE200_INT_EN);
-- 
2.39.2



[PATCH RFC v1 41/52] drm/tilcdc: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 43 ++--
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index b5f60b2b2d0e..43134fef8282 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -62,7 +62,7 @@ struct tilcdc_crtc {
 
 static void set_scanout(struct drm_crtc *crtc, struct drm_framebuffer *fb)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct tilcdc_drm_private *priv = dev->dev_private;
struct drm_gem_dma_object *gem;
dma_addr_t start, end;
@@ -97,7 +97,7 @@ static void set_scanout(struct drm_crtc *crtc, struct 
drm_framebuffer *fb)
 static void tilcdc_crtc_load_palette(struct drm_crtc *crtc)
 {
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct tilcdc_drm_private *priv = dev->dev_private;
int ret;
 
@@ -176,7 +176,7 @@ static void tilcdc_crtc_disable_irqs(struct drm_device *dev)
 
 static void reset(struct drm_crtc *crtc)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct tilcdc_drm_private *priv = dev->dev_private;
 
if (priv->rev != 2)
@@ -201,7 +201,7 @@ static unsigned int tilcdc_pclk_diff(unsigned long rate,
 
 static void tilcdc_crtc_set_clk(struct drm_crtc *crtc)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct tilcdc_drm_private *priv = dev->dev_private;
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
unsigned long clk_rate, real_pclk_rate, pclk_rate;
@@ -273,7 +273,7 @@ static uint tilcdc_mode_hvtotal(const struct 
drm_display_mode *mode)
 static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
 {
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct tilcdc_drm_private *priv = dev->dev_private;
const struct tilcdc_panel_info *info = tilcdc_crtc->info;
uint32_t reg, hbp, hfp, hsw, vbp, vfp, vsw;
@@ -442,7 +442,7 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
 
 static void tilcdc_crtc_enable(struct drm_crtc *crtc)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
unsigned long flags;
 
@@ -491,7 +491,7 @@ static void tilcdc_crtc_atomic_enable(struct drm_crtc *crtc,
 static void tilcdc_crtc_off(struct drm_crtc *crtc, bool shutdown)
 {
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
int ret;
 
mutex_lock(&tilcdc_crtc->enable_lock);
@@ -517,14 +517,14 @@ static void tilcdc_crtc_off(struct drm_crtc *crtc, bool 
shutdown)
 
drm_crtc_vblank_off(crtc);
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
 
if (crtc->state->event) {
drm_crtc_send_vblank_event(crtc, crtc->state->event);
crtc->state->event = NULL;
}
 
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
 
tilcdc_crtc_disable_irqs(dev);
 
@@ -551,10 +551,10 @@ static void tilcdc_crtc_atomic_flush(struct drm_crtc 
*crtc,
if (!crtc->state->event)
return;
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
drm_crtc_send_vblank_event(crtc, crtc->state->event);
crtc->state->event = NULL;
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
 }
 
 void tilcdc_crtc_shutdown(struct drm_crtc *crtc)
@@ -573,7 +573,7 @@ static void tilcdc_crtc_recover_work(struct work_struct 
*work)
container_of(work, struct tilcdc_crtc, recover_work);
struct drm_crtc *crtc = &tilcdc_crtc->base;
 
-   dev_info(crtc->dev->dev, "%s: Reset CRTC", __func__);
+   dev_info(crtc->drm_dev->dev, "%s: Reset CRTC", __func__);
 
drm_modeset_lock(&crtc->mutex, NULL);
 
@@ -588,7 +588,7 @@ static void tilcdc_crtc_recover_work(struct work_struct 
*work)
 
 static void tilcdc_crtc_destroy(struct drm_crtc *crtc)
 {
-   struct tilcdc_drm_private *priv = crtc->dev->dev_private;
+   struct tilcdc_drm_private *priv = crtc->drm_dev->dev_private;
 
tilcdc_crtc_shutdown(crtc);
 
@@ -603,7 +603,7 @@ int tilcdc_crtc_update_fb(struct drm_crtc *crtc,
struc

[PATCH RFC v1 32/52] drm/renesas: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 .../gpu/drm/renesas/rcar-du/rcar_du_crtc.c| 14 ++---
 .../gpu/drm/renesas/shmobile/shmob_drm_crtc.c | 20 +--
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_du_crtc.c 
b/drivers/gpu/drm/renesas/rcar-du/rcar_du_crtc.c
index 7e175dbfd892..8de7e697b430 100644
--- a/drivers/gpu/drm/renesas/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/renesas/rcar-du/rcar_du_crtc.c
@@ -436,7 +436,7 @@ static void rcar_du_crtc_update_planes(struct rcar_du_crtc 
*rcrtc)
 void rcar_du_crtc_finish_page_flip(struct rcar_du_crtc *rcrtc)
 {
struct drm_pending_vblank_event *event;
-   struct drm_device *dev = rcrtc->crtc.dev;
+   struct drm_device *dev = rcrtc->crtc.drm_dev;
unsigned long flags;
 
spin_lock_irqsave(&dev->event_lock, flags);
@@ -457,7 +457,7 @@ void rcar_du_crtc_finish_page_flip(struct rcar_du_crtc 
*rcrtc)
 
 static bool rcar_du_crtc_page_flip_pending(struct rcar_du_crtc *rcrtc)
 {
-   struct drm_device *dev = rcrtc->crtc.dev;
+   struct drm_device *dev = rcrtc->crtc.drm_dev;
unsigned long flags;
bool pending;
 
@@ -703,7 +703,7 @@ static int rcar_du_crtc_atomic_check(struct drm_crtc *crtc,
/* Store the routes from the CRTC output to the DU outputs. */
rstate->outputs = 0;
 
-   drm_for_each_encoder_mask(encoder, crtc->dev,
+   drm_for_each_encoder_mask(encoder, crtc->drm_dev,
  crtc_state->encoder_mask) {
struct rcar_du_encoder *renc;
 
@@ -802,12 +802,12 @@ static void rcar_du_crtc_atomic_disable(struct drm_crtc 
*crtc,
rcar_mipi_dsi_pclk_disable(bridge);
}
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
if (crtc->state->event) {
drm_crtc_send_vblank_event(crtc, crtc->state->event);
crtc->state->event = NULL;
}
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
 }
 
 static void rcar_du_crtc_atomic_begin(struct drm_crtc *crtc,
@@ -843,7 +843,7 @@ static void rcar_du_crtc_atomic_flush(struct drm_crtc *crtc,
  struct drm_atomic_state *state)
 {
struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
-   struct drm_device *dev = rcrtc->crtc.dev;
+   struct drm_device *dev = rcrtc->crtc.drm_dev;
unsigned long flags;
 
rcar_du_crtc_update_planes(rcrtc);
@@ -1116,7 +1116,7 @@ static int rcar_du_crtc_set_crc_source(struct drm_crtc 
*crtc,
/* Perform an atomic commit to set the CRC source. */
drm_modeset_acquire_init(&ctx, 0);
 
-   state = drm_atomic_state_alloc(crtc->dev);
+   state = drm_atomic_state_alloc(crtc->drm_dev);
if (!state) {
ret = -ENOMEM;
goto unlock;
diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c 
b/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
index 11dd2bc803e7..4d25dbf4f58b 100644
--- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
+++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
@@ -64,7 +64,7 @@ static void shmob_drm_clk_off(struct shmob_drm_device *sdev)
 static void shmob_drm_crtc_setup_geometry(struct shmob_drm_crtc *scrtc)
 {
struct drm_crtc *crtc = &scrtc->crtc;
-   struct shmob_drm_device *sdev = crtc->dev->dev_private;
+   struct shmob_drm_device *sdev = crtc->drm_dev->dev_private;
const struct shmob_drm_interface_data *idata = &sdev->pdata->iface;
const struct drm_display_mode *mode = &crtc->mode;
u32 value;
@@ -121,7 +121,7 @@ static void shmob_drm_crtc_setup_geometry(struct 
shmob_drm_crtc *scrtc)
 
 static void shmob_drm_crtc_start_stop(struct shmob_drm_crtc *scrtc, bool start)
 {
-   struct shmob_drm_device *sdev = scrtc->crtc.dev->dev_private;
+   struct shmob_drm_device *sdev = scrtc->crtc.drm_dev->dev_private;
u32 value;
 
value = lcdc_read(sdev, LDCNT2R);
@@ -155,7 +155,7 @@ static void shmob_drm_crtc_start_stop(struct shmob_drm_crtc 
*scrtc, bool start)
 static void shmob_drm_crtc_start(struct shmob_drm_crtc *scrtc)
 {
struct drm_crtc *crtc = &scrtc->crtc;
-   struct shmob_drm_device *sdev = crtc->dev->dev_private;
+   struct shmob_drm_device *sdev = crtc->drm_dev->dev_private;
const struct shmob_drm_interface_data *idata = &sdev->pdata->iface;
const struct shmob_drm_format_info *format;
struct drm_device *dev = sdev->ddev;
@@ -257,7 +257,7 @@ static void shmob_drm_crtc_start(struct shmob_drm_crtc 
*scrtc)
 static void shmob_drm_crtc_stop(struct shmob_drm_crtc *scrtc)
 {
struct drm_crtc *crtc = &scrtc->crtc;
-   struct shmob_drm_device *sdev = crtc

[PATCH RFC v1 46/52] drm/vc4: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/vc4/vc4_crtc.c | 38 +-
 drivers/gpu/drm/vc4/vc4_hdmi.c |  2 +-
 drivers/gpu/drm/vc4/vc4_hvs.c  | 12 +--
 drivers/gpu/drm/vc4/vc4_txp.c  |  2 +-
 4 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
index bef9d45ef1df..09e65d322f1d 100644
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -99,7 +99,7 @@ static bool vc4_crtc_get_scanout_position(struct drm_crtc 
*crtc,
  ktime_t *stime, ktime_t *etime,
  const struct drm_display_mode *mode)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct vc4_dev *vc4 = to_vc4_dev(dev);
struct vc4_hvs *hvs = vc4->hvs;
struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
@@ -220,7 +220,7 @@ static u32 vc4_get_fifo_full_level(struct vc4_crtc 
*vc4_crtc, u32 format)
 {
const struct vc4_crtc_data *crtc_data = 
vc4_crtc_to_vc4_crtc_data(vc4_crtc);
const struct vc4_pv_data *pv_data = vc4_crtc_to_vc4_pv_data(vc4_crtc);
-   struct vc4_dev *vc4 = to_vc4_dev(vc4_crtc->base.dev);
+   struct vc4_dev *vc4 = to_vc4_dev(vc4_crtc->base.drm_dev);
u32 fifo_len_bytes = pv_data->fifo_depth;
 
/*
@@ -296,7 +296,7 @@ struct drm_encoder *vc4_get_crtc_encoder(struct drm_crtc 
*crtc,
 
WARN_ON(hweight32(state->encoder_mask) > 1);
 
-   drm_for_each_encoder_mask(encoder, crtc->dev, state->encoder_mask)
+   drm_for_each_encoder_mask(encoder, crtc->drm_dev, state->encoder_mask)
return encoder;
 
return NULL;
@@ -305,7 +305,7 @@ struct drm_encoder *vc4_get_crtc_encoder(struct drm_crtc 
*crtc,
 static void vc4_crtc_pixelvalve_reset(struct drm_crtc *crtc)
 {
struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
int idx;
 
if (!drm_dev_enter(dev, &idx))
@@ -321,7 +321,7 @@ static void vc4_crtc_pixelvalve_reset(struct drm_crtc *crtc)
 static void vc4_crtc_config_pv(struct drm_crtc *crtc, struct drm_encoder 
*encoder,
   struct drm_atomic_state *state)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct vc4_dev *vc4 = to_vc4_dev(dev);
struct vc4_encoder *vc4_encoder = to_vc4_encoder(encoder);
struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
@@ -468,7 +468,7 @@ static int vc4_crtc_disable(struct drm_crtc *crtc,
 {
struct vc4_encoder *vc4_encoder = to_vc4_encoder(encoder);
struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct vc4_dev *vc4 = to_vc4_dev(dev);
int idx, ret;
 
@@ -514,7 +514,7 @@ static int vc4_crtc_disable(struct drm_crtc *crtc,
 
 int vc4_crtc_disable_at_boot(struct drm_crtc *crtc)
 {
-   struct drm_device *drm = crtc->dev;
+   struct drm_device *drm = crtc->drm_dev;
struct vc4_dev *vc4 = to_vc4_dev(drm);
struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
enum vc4_encoder_type encoder_type;
@@ -571,7 +571,7 @@ int vc4_crtc_disable_at_boot(struct drm_crtc *crtc)
 
 void vc4_crtc_send_vblank(struct drm_crtc *crtc)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
unsigned long flags;
 
if (!crtc->state || !crtc->state->event)
@@ -590,7 +590,7 @@ static void vc4_crtc_atomic_disable(struct drm_crtc *crtc,
 crtc);
struct vc4_crtc_state *old_vc4_state = to_vc4_crtc_state(old_state);
struct drm_encoder *encoder = vc4_get_crtc_encoder(crtc, old_state);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
 
drm_dbg(dev, "Disabling CRTC %s (%u) connected to Encoder %s (%u)",
crtc->name, crtc->base.id, encoder->name, encoder->base.id);
@@ -614,7 +614,7 @@ static void vc4_crtc_atomic_enable(struct drm_crtc *crtc,
 {
struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state,
 crtc);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
struct drm_encoder *encoder = vc4_get_crtc_encoder(crtc, new_state);
struct vc4_encoder *vc4_encoder = to_vc4_encoder(encoder);
@@ -747,7 +747,7 @@ int vc4_crtc_atomic_check(struct drm_crtc *crtc,
 static int vc4_enable_vblank(struct drm_crt

[PATCH RFC v1 35/52] drm/sprd: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/sprd/sprd_dpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/sprd/sprd_dpu.c b/drivers/gpu/drm/sprd/sprd_dpu.c
index b96fc6837b0d..37709bf5a655 100644
--- a/drivers/gpu/drm/sprd/sprd_dpu.c
+++ b/drivers/gpu/drm/sprd/sprd_dpu.c
@@ -624,7 +624,7 @@ static void sprd_crtc_mode_set_nofb(struct drm_crtc *crtc)
 
drm_display_mode_to_videomode(mode, &dpu->ctx.vm);
 
-   drm_for_each_encoder_mask(encoder, crtc->dev,
+   drm_for_each_encoder_mask(encoder, crtc->drm_dev,
  crtc->state->encoder_mask) {
dsi = encoder_to_dsi(encoder);
 
@@ -651,7 +651,7 @@ static void sprd_crtc_atomic_disable(struct drm_crtc *crtc,
 struct drm_atomic_state *state)
 {
struct sprd_dpu *dpu = to_sprd_crtc(crtc);
-   struct drm_device *drm = dpu->base.dev;
+   struct drm_device *drm = dpu->base.drm_dev;
 
drm_crtc_vblank_off(&dpu->base);
 
@@ -670,7 +670,7 @@ static void sprd_crtc_atomic_flush(struct drm_crtc *crtc,
 
 {
struct sprd_dpu *dpu = to_sprd_crtc(crtc);
-   struct drm_device *drm = dpu->base.dev;
+   struct drm_device *drm = dpu->base.drm_dev;
 
sprd_dpu_flip(dpu);
 
-- 
2.39.2



[PATCH RFC v1 49/52] drm/vmwgfx: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  |  4 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 10 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c |  8 
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index b62207be3363..f26b89eee8b0 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -762,7 +762,7 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *old_state = 
drm_atomic_get_old_plane_state(state,
   
plane);
struct drm_crtc *crtc = new_state->crtc ?: old_state->crtc;
-   struct vmw_private *dev_priv = vmw_priv(crtc->dev);
+   struct vmw_private *dev_priv = vmw_priv(crtc->drm_dev);
struct vmw_display_unit *du = vmw_crtc_to_du(crtc);
struct vmw_plane_state *vps = vmw_plane_state_to_vps(new_state);
struct vmw_plane_state *old_vps = vmw_plane_state_to_vps(old_state);
@@ -2240,7 +2240,7 @@ int vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
  uint32_t size,
  struct drm_modeset_acquire_ctx *ctx)
 {
-   struct vmw_private *dev_priv = vmw_priv(crtc->dev);
+   struct vmw_private *dev_priv = vmw_priv(crtc->drm_dev);
int i;
 
for (i = 0; i < size; i++) {
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
index 556a403b7eb5..5d653a624b74 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
@@ -219,7 +219,7 @@ static void vmw_sou_crtc_mode_set_nofb(struct drm_crtc 
*crtc)
int ret;
 
sou = vmw_crtc_to_sou(crtc);
-   dev_priv = vmw_priv(crtc->dev);
+   dev_priv = vmw_priv(crtc->drm_dev);
ps = crtc->primary->state;
fb = ps->fb;
vps = vmw_plane_state_to_vps(ps);
@@ -303,7 +303,7 @@ static void vmw_sou_crtc_atomic_disable(struct drm_crtc 
*crtc,
}
 
sou = vmw_crtc_to_sou(crtc);
-   dev_priv = vmw_priv(crtc->dev);
+   dev_priv = vmw_priv(crtc->drm_dev);
 
if (sou->defined) {
ret = vmw_sou_fifo_destroy(dev_priv, sou);
@@ -384,7 +384,7 @@ vmw_sou_primary_plane_cleanup_fb(struct drm_plane *plane,
plane->state->crtc : old_state->crtc;
 
if (vps->bo)
-   vmw_bo_unpin(vmw_priv(crtc->dev), vps->bo, false);
+   vmw_bo_unpin(vmw_priv(crtc->drm_dev), vps->bo, false);
vmw_bo_unreference(&vps->bo);
vps->bo_size = 0;
 
@@ -426,7 +426,7 @@ vmw_sou_primary_plane_prepare_fb(struct drm_plane *plane,
}
 
bo_params.size = new_state->crtc_w * new_state->crtc_h * 4;
-   dev_priv = vmw_priv(crtc->dev);
+   dev_priv = vmw_priv(crtc->drm_dev);
 
if (vps->bo) {
if (vps->bo_size == bo_params.size) {
@@ -730,7 +730,7 @@ vmw_sou_primary_plane_atomic_update(struct drm_plane *plane,
 
/* In case of device error, maintain consistent atomic state */
if (crtc && new_state->fb) {
-   struct vmw_private *dev_priv = vmw_priv(crtc->dev);
+   struct vmw_private *dev_priv = vmw_priv(crtc->drm_dev);
struct vmw_framebuffer *vfb =
vmw_framebuffer_to_vfb(new_state->fb);
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
index ba0c0e12cfe9..a08d81ea9c94 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
@@ -371,7 +371,7 @@ static void vmw_stdu_crtc_mode_set_nofb(struct drm_crtc 
*crtc)
int x, y, ret;
 
stdu = vmw_crtc_to_stdu(crtc);
-   dev_priv = vmw_priv(crtc->dev);
+   dev_priv = vmw_priv(crtc->drm_dev);
conn_state = stdu->base.connector.state;
vmw_conn_state = vmw_connector_state_to_vcs(conn_state);
 
@@ -427,7 +427,7 @@ static void vmw_stdu_crtc_atomic_disable(struct drm_crtc 
*crtc,
}
 
stdu = vmw_crtc_to_stdu(crtc);
-   dev_priv = vmw_priv(crtc->dev);
+   dev_priv = vmw_priv(crtc->drm_dev);
 
if (stdu->defined) {
ret = vmw_stdu_bind_st(dev_priv, stdu, NULL);
@@ -1363,7 +1363,7 @@ vmw_stdu_primary_plane_atomic_update(struct drm_plane 
*plane,
struct vmw_framebuffer *vfb =
vmw_framebuffer_to_vfb(new_state->fb);
stdu = vmw_crtc_to_stdu(crtc);
-   dev_priv = vmw_priv(crtc->dev);
+   dev_priv = vmw_priv(crtc->drm_dev);
 
stdu->display_srf = vps->surf;
stdu->content_fb_type = vps->content_fb_type;
@@ -1385,7 +1385,7 @@ vmw_stdu_primary_plane_atomic_update(struct drm_plane 
*pl

[PATCH RFC v1 09/52] drm/exynos: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/exynos/exynos_drm_crtc.c  | 8 
 drivers/gpu/drm/exynos/exynos_drm_plane.c | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c 
b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index 4153f302de7c..c1e2c14ab07d 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -40,9 +40,9 @@ static void exynos_drm_crtc_atomic_disable(struct drm_crtc 
*crtc,
exynos_crtc->ops->atomic_disable(exynos_crtc);
 
if (crtc->state->event && !crtc->state->active) {
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
drm_crtc_send_vblank_event(crtc, crtc->state->event);
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
 
crtc->state->event = NULL;
}
@@ -129,9 +129,9 @@ void exynos_crtc_handle_event(struct exynos_drm_crtc 
*exynos_crtc)
 
WARN_ON(drm_crtc_vblank_get(crtc) != 0);
 
-   spin_lock_irqsave(&crtc->dev->event_lock, flags);
+   spin_lock_irqsave(&crtc->drm_dev->event_lock, flags);
drm_crtc_arm_vblank_event(crtc, event);
-   spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
+   spin_unlock_irqrestore(&crtc->drm_dev->event_lock, flags);
 }
 
 static void exynos_drm_crtc_destroy(struct drm_crtc *crtc)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c 
b/drivers/gpu/drm/exynos/exynos_drm_plane.c
index 7c3aa77186d3..1a8cb7b6af57 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_plane.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c
@@ -115,7 +115,7 @@ static void exynos_plane_mode_set(struct 
exynos_drm_plane_state *exynos_state)
exynos_state->crtc.w = actual_w;
exynos_state->crtc.h = actual_h;
 
-   DRM_DEV_DEBUG_KMS(crtc->dev->dev,
+   DRM_DEV_DEBUG_KMS(crtc->drm_dev->dev,
  "plane : offset_x/y(%d,%d), width/height(%d,%d)",
  exynos_state->crtc.x, exynos_state->crtc.y,
  exynos_state->crtc.w, exynos_state->crtc.h);
@@ -224,7 +224,7 @@ exynos_drm_plane_check_size(const struct 
exynos_drm_plane_config *config,
if (width_ok && height_ok)
return 0;
 
-   DRM_DEV_DEBUG_KMS(crtc->dev->dev, "scaling mode is not supported");
+   DRM_DEV_DEBUG_KMS(crtc->drm_dev->dev, "scaling mode is not supported");
return -ENOTSUPP;
 }
 
-- 
2.39.2



[PATCH RFC v1 37/52] drm/stm: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/stm/ltdc.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
index b8be4c1db423..d7bf7b63d8df 100644
--- a/drivers/gpu/drm/stm/ltdc.c
+++ b/drivers/gpu/drm/stm/ltdc.c
@@ -484,7 +484,7 @@ static const u32 
ltdc_ycbcr2rgb_coeffs[DRM_COLOR_ENCODING_MAX][DRM_COLOR_RANGE_M
 
 static inline struct ltdc_device *crtc_to_ltdc(struct drm_crtc *crtc)
 {
-   return (struct ltdc_device *)crtc->dev->dev_private;
+   return (struct ltdc_device *) crtc->drm_dev->dev_private;
 }
 
 static inline struct ltdc_device *plane_to_ltdc(struct drm_plane *plane)
@@ -775,7 +775,7 @@ static void ltdc_crtc_atomic_enable(struct drm_crtc *crtc,
struct drm_atomic_state *state)
 {
struct ltdc_device *ldev = crtc_to_ltdc(crtc);
-   struct drm_device *ddev = crtc->dev;
+   struct drm_device *ddev = crtc->drm_dev;
 
DRM_DEBUG_DRIVER("\n");
 
@@ -798,7 +798,7 @@ static void ltdc_crtc_atomic_disable(struct drm_crtc *crtc,
 struct drm_atomic_state *state)
 {
struct ltdc_device *ldev = crtc_to_ltdc(crtc);
-   struct drm_device *ddev = crtc->dev;
+   struct drm_device *ddev = crtc->drm_dev;
int layer_index = 0;
 
DRM_DEBUG_DRIVER("\n");
@@ -891,7 +891,7 @@ static bool ltdc_crtc_mode_fixup(struct drm_crtc *crtc,
 static void ltdc_crtc_mode_set_nofb(struct drm_crtc *crtc)
 {
struct ltdc_device *ldev = crtc_to_ltdc(crtc);
-   struct drm_device *ddev = crtc->dev;
+   struct drm_device *ddev = crtc->drm_dev;
struct drm_connector_list_iter iter;
struct drm_connector *connector = NULL;
struct drm_encoder *encoder = NULL, *en_iter;
@@ -1034,7 +1034,7 @@ static void ltdc_crtc_atomic_flush(struct drm_crtc *crtc,
   struct drm_atomic_state *state)
 {
struct ltdc_device *ldev = crtc_to_ltdc(crtc);
-   struct drm_device *ddev = crtc->dev;
+   struct drm_device *ddev = crtc->drm_dev;
struct drm_pending_vblank_event *event = crtc->state->event;
 
DRM_DEBUG_ATOMIC("\n");
@@ -1063,7 +1063,7 @@ static bool ltdc_crtc_get_scanout_position(struct 
drm_crtc *crtc,
   ktime_t *stime, ktime_t *etime,
   const struct drm_display_mode *mode)
 {
-   struct drm_device *ddev = crtc->dev;
+   struct drm_device *ddev = crtc->drm_dev;
struct ltdc_device *ldev = ddev->dev_private;
int line, vactive_start, vactive_end, vtotal;
 
-- 
2.39.2



[PATCH RFC v1 08/52] drm/atmel-hlcdc: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index 58184cd6ab0b..40573991568d 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -168,7 +168,7 @@ atmel_hlcdc_crtc_mode_valid(struct drm_crtc *c,
 static void atmel_hlcdc_crtc_atomic_disable(struct drm_crtc *c,
struct drm_atomic_state *state)
 {
-   struct drm_device *dev = c->dev;
+   struct drm_device *dev = c->drm_dev;
struct atmel_hlcdc_crtc *crtc = drm_crtc_to_atmel_hlcdc_crtc(c);
struct regmap *regmap = crtc->dc->hlcdc->regmap;
unsigned int status;
@@ -203,7 +203,7 @@ static void atmel_hlcdc_crtc_atomic_disable(struct drm_crtc 
*c,
 static void atmel_hlcdc_crtc_atomic_enable(struct drm_crtc *c,
   struct drm_atomic_state *state)
 {
-   struct drm_device *dev = c->dev;
+   struct drm_device *dev = c->drm_dev;
struct atmel_hlcdc_crtc *crtc = drm_crtc_to_atmel_hlcdc_crtc(c);
struct regmap *regmap = crtc->dc->hlcdc->regmap;
unsigned int status;
@@ -353,7 +353,7 @@ static void atmel_hlcdc_crtc_atomic_flush(struct drm_crtc 
*c,
struct atmel_hlcdc_crtc *crtc = drm_crtc_to_atmel_hlcdc_crtc(c);
unsigned long flags;
 
-   spin_lock_irqsave(&c->dev->event_lock, flags);
+   spin_lock_irqsave(&c->drm_dev->event_lock, flags);
 
if (c->state->event) {
c->state->event->pipe = drm_crtc_index(c);
@@ -363,7 +363,7 @@ static void atmel_hlcdc_crtc_atomic_flush(struct drm_crtc 
*c,
crtc->event = c->state->event;
c->state->event = NULL;
}
-   spin_unlock_irqrestore(&c->dev->event_lock, flags);
+   spin_unlock_irqrestore(&c->drm_dev->event_lock, flags);
 }
 
 static const struct drm_crtc_helper_funcs lcdc_crtc_helper_funcs = {
@@ -386,7 +386,7 @@ static void atmel_hlcdc_crtc_destroy(struct drm_crtc *c)
 
 static void atmel_hlcdc_crtc_finish_page_flip(struct atmel_hlcdc_crtc *crtc)
 {
-   struct drm_device *dev = crtc->base.dev;
+   struct drm_device *dev = crtc->base.drm_dev;
unsigned long flags;
 
spin_lock_irqsave(&dev->event_lock, flags);
-- 
2.39.2



[PATCH RFC v1 48/52] drm/vkms: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/vkms/vkms_crtc.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
index 515f6772b866..4935690ec475 100644
--- a/drivers/gpu/drm/vkms/vkms_crtc.c
+++ b/drivers/gpu/drm/vkms/vkms_crtc.c
@@ -61,7 +61,7 @@ static enum hrtimer_restart vkms_vblank_simulate(struct 
hrtimer *timer)
 
 static int vkms_enable_vblank(struct drm_crtc *crtc)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
unsigned int pipe = drm_crtc_index(crtc);
struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
struct vkms_output *out = drm_crtc_to_vkms_output(crtc);
@@ -87,7 +87,7 @@ static bool vkms_get_vblank_timestamp(struct drm_crtc *crtc,
  int *max_error, ktime_t *vblank_time,
  bool in_vblank_irq)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
unsigned int pipe = crtc->index;
struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev);
struct vkms_output *output = &vkmsdev->output;
@@ -190,7 +190,7 @@ static int vkms_crtc_atomic_check(struct drm_crtc *crtc,
if (ret < 0)
return ret;
 
-   drm_for_each_plane_mask(plane, crtc->dev, crtc_state->plane_mask) {
+   drm_for_each_plane_mask(plane, crtc->drm_dev, crtc_state->plane_mask) {
plane_state = 
drm_atomic_get_existing_plane_state(crtc_state->state,
  plane);
WARN_ON(!plane_state);
@@ -207,7 +207,7 @@ static int vkms_crtc_atomic_check(struct drm_crtc *crtc,
vkms_state->num_active_planes = i;
 
i = 0;
-   drm_for_each_plane_mask(plane, crtc->dev, crtc_state->plane_mask) {
+   drm_for_each_plane_mask(plane, crtc->drm_dev, crtc_state->plane_mask) {
plane_state = 
drm_atomic_get_existing_plane_state(crtc_state->state,
  plane);
 
@@ -250,14 +250,14 @@ static void vkms_crtc_atomic_flush(struct drm_crtc *crtc,
struct vkms_output *vkms_output = drm_crtc_to_vkms_output(crtc);
 
if (crtc->state->event) {
-   spin_lock(&crtc->dev->event_lock);
+   spin_lock(&crtc->drm_dev->event_lock);
 
if (drm_crtc_vblank_get(crtc) != 0)
drm_crtc_send_vblank_event(crtc, crtc->state->event);
else
drm_crtc_arm_vblank_event(crtc, crtc->state->event);
 
-   spin_unlock(&crtc->dev->event_lock);
+   spin_unlock(&crtc->drm_dev->event_lock);
 
crtc->state->event = NULL;
}
-- 
2.39.2



[PATCH RFC v1 38/52] drm/sun4i: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/sun4i/sun4i_crtc.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_crtc.c 
b/drivers/gpu/drm/sun4i/sun4i_crtc.c
index c06d7cd45388..a1e38bcf3125 100644
--- a/drivers/gpu/drm/sun4i/sun4i_crtc.c
+++ b/drivers/gpu/drm/sun4i/sun4i_crtc.c
@@ -38,7 +38,7 @@ static struct drm_encoder *sun4i_crtc_get_encoder(struct 
drm_crtc *crtc)
 {
struct drm_encoder *encoder;
 
-   drm_for_each_encoder(encoder, crtc->dev)
+   drm_for_each_encoder(encoder, crtc->drm_dev)
if (encoder->crtc == crtc)
return encoder;
 
@@ -66,7 +66,7 @@ static void sun4i_crtc_atomic_begin(struct drm_crtc *crtc,
struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state,
 crtc);
struct sun4i_crtc *scrtc = drm_crtc_to_sun4i_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct sunxi_engine *engine = scrtc->engine;
unsigned long flags;
 
@@ -96,12 +96,12 @@ static void sun4i_crtc_atomic_flush(struct drm_crtc *crtc,
if (event) {
crtc->state->event = NULL;
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
if (drm_crtc_vblank_get(crtc) == 0)
drm_crtc_arm_vblank_event(crtc, event);
else
drm_crtc_send_vblank_event(crtc, event);
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
}
 }
 
@@ -118,9 +118,9 @@ static void sun4i_crtc_atomic_disable(struct drm_crtc *crtc,
sun4i_tcon_set_status(scrtc->tcon, encoder, false);
 
if (crtc->state->event && !crtc->state->active) {
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
drm_crtc_send_vblank_event(crtc, crtc->state->event);
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
 
crtc->state->event = NULL;
}
-- 
2.39.2



[PATCH RFC v1 06/52] drm/aspeed: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c 
b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
index 7877a57b8e26..84c4b28e7c9c 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
@@ -26,7 +26,7 @@ drm_pipe_to_aspeed_gfx(struct drm_simple_display_pipe *pipe)
 static int aspeed_gfx_set_pixel_fmt(struct aspeed_gfx *priv, u32 *bpp)
 {
struct drm_crtc *crtc = &priv->pipe.crtc;
-   struct drm_device *drm = crtc->dev;
+   struct drm_device *drm = crtc->drm_dev;
const u32 format = crtc->primary->state->fb->format->format;
u32 ctrl1;
 
@@ -169,7 +169,7 @@ static void aspeed_gfx_pipe_update(struct 
drm_simple_display_pipe *pipe,
struct drm_pending_vblank_event *event;
struct drm_gem_dma_object *gem;
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
event = crtc->state->event;
if (event) {
crtc->state->event = NULL;
@@ -179,7 +179,7 @@ static void aspeed_gfx_pipe_update(struct 
drm_simple_display_pipe *pipe,
else
drm_crtc_send_vblank_event(crtc, event);
}
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
 
if (!fb)
return;
-- 
2.39.2



[PATCH RFC v1 47/52] drm/virtio: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/virtio/virtgpu_display.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c 
b/drivers/gpu/drm/virtio/virtgpu_display.c
index ad924a8502e9..bc7c537706ca 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -85,7 +85,7 @@ virtio_gpu_framebuffer_init(struct drm_device *dev,
 
 static void virtio_gpu_crtc_mode_set_nofb(struct drm_crtc *crtc)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct virtio_gpu_device *vgdev = dev->dev_private;
struct virtio_gpu_output *output = drm_crtc_to_virtio_gpu_output(crtc);
 
@@ -103,7 +103,7 @@ static void virtio_gpu_crtc_atomic_enable(struct drm_crtc 
*crtc,
 static void virtio_gpu_crtc_atomic_disable(struct drm_crtc *crtc,
   struct drm_atomic_state *state)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct virtio_gpu_device *vgdev = dev->dev_private;
struct virtio_gpu_output *output = drm_crtc_to_virtio_gpu_output(crtc);
 
-- 
2.39.2



[PATCH RFC v1 26/52] drm/nouveau: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/nouveau/dispnv04/crtc.c | 58 +++--
 drivers/gpu/drm/nouveau/dispnv04/cursor.c   | 10 ++--
 drivers/gpu/drm/nouveau/dispnv50/atom.h |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/crc.c  | 30 +--
 drivers/gpu/drm/nouveau/dispnv50/crc907d.c  |  6 +--
 drivers/gpu/drm/nouveau/dispnv50/crcc37d.c  |  6 +--
 drivers/gpu/drm/nouveau/dispnv50/crcc57d.c  |  2 +-
 drivers/gpu/drm/nouveau/dispnv50/disp.c |  5 +-
 drivers/gpu/drm/nouveau/dispnv50/head.c |  4 +-
 drivers/gpu/drm/nouveau/dispnv50/head507d.c | 26 -
 drivers/gpu/drm/nouveau/dispnv50/head827d.c | 10 ++--
 drivers/gpu/drm/nouveau/dispnv50/head907d.c | 26 -
 drivers/gpu/drm/nouveau/dispnv50/head917d.c |  6 +--
 drivers/gpu/drm/nouveau/dispnv50/headc37d.c | 18 +++
 drivers/gpu/drm/nouveau/dispnv50/headc57d.c | 10 ++--
 drivers/gpu/drm/nouveau/nouveau_connector.h |  2 +-
 drivers/gpu/drm/nouveau/nouveau_display.c   |  2 +-
 17 files changed, 113 insertions(+), 110 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c 
b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index a6f2e681bde9..fad5c6dc2cf7 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -56,18 +56,18 @@ nv04_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
 static void
 crtc_wr_cio_state(struct drm_crtc *crtc, struct nv04_crtc_reg *crtcstate, int 
index)
 {
-   NVWriteVgaCrtc(crtc->dev, nouveau_crtc(crtc)->index, index,
+   NVWriteVgaCrtc(crtc->drm_dev, nouveau_crtc(crtc)->index, index,
   crtcstate->CRTC[index]);
 }
 
 static void nv_crtc_set_digital_vibrance(struct drm_crtc *crtc, int level)
 {
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct nv04_crtc_reg *regp = 
&nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index];
 
regp->CRTC[NV_CIO_CRE_CSB] = nv_crtc->saturation = level;
-   if (nv_crtc->saturation && nv_gf4_disp_arch(crtc->dev)) {
+   if (nv_crtc->saturation && nv_gf4_disp_arch(crtc->drm_dev)) {
regp->CRTC[NV_CIO_CRE_CSB] = 0x80;
regp->CRTC[NV_CIO_CRE_5B] = nv_crtc->saturation << 2;
crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_5B);
@@ -78,14 +78,15 @@ static void nv_crtc_set_digital_vibrance(struct drm_crtc 
*crtc, int level)
 static void nv_crtc_set_image_sharpening(struct drm_crtc *crtc, int level)
 {
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct nv04_crtc_reg *regp = 
&nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index];
 
nv_crtc->sharpness = level;
if (level < 0)  /* blur is in hw range 0x3f -> 0x20 */
level += 0x40;
regp->ramdac_634 = level;
-   NVWriteRAMDAC(crtc->dev, nv_crtc->index, NV_PRAMDAC_634, 
regp->ramdac_634);
+   NVWriteRAMDAC(crtc->drm_dev, nv_crtc->index, NV_PRAMDAC_634,
+ regp->ramdac_634);
 }
 
 #define PLLSEL_VPLL1_MASK  \
@@ -116,7 +117,7 @@ static void nv_crtc_set_image_sharpening(struct drm_crtc 
*crtc, int level)
 
 static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct 
drm_display_mode * mode, int dot_clock)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_bios *bios = nvxx_bios(&drm->client.device);
struct nvkm_clk *clk = nvxx_clk(&drm->client.device);
@@ -175,7 +176,7 @@ static void
 nv_crtc_dpms(struct drm_crtc *crtc, int mode)
 {
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct nouveau_drm *drm = nouveau_drm(dev);
unsigned char seq1 = 0, crtc17 = 0;
unsigned char crtc1A;
@@ -236,7 +237,7 @@ nv_crtc_dpms(struct drm_crtc *crtc, int mode)
 static void
 nv_crtc_mode_set_vga(struct drm_crtc *crtc, struct drm_display_mode *mode)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
struct nv04_crtc_reg *regp = 
&nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index];
struct drm_framebuffer *fb = crtc->primary->fb;
@@ -460,7 +461,7 @@ nv_crtc_mode_set_vga(struct drm_crtc *crtc, struct 
drm_display_mode *mode)
 static void
 nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct nouveau_drm *drm = nouveau_drm(dev);
 

[PATCH RFC v1 30/52] drm/qxl: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/qxl/qxl_display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/qxl/qxl_display.c 
b/drivers/gpu/drm/qxl/qxl_display.c
index 6492a70e3c39..1b83e5d4a0d4 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -315,7 +315,7 @@ static void qxl_send_monitors_config(struct qxl_device 
*qdev)
 static void qxl_crtc_update_monitors_config(struct drm_crtc *crtc,
const char *reason)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct qxl_device *qdev = to_qxl(dev);
struct qxl_crtc *qcrtc = to_qxl_crtc(crtc);
struct qxl_head head;
-- 
2.39.2



[PATCH RFC v1 31/52] drm/radeon: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/radeon/atombios_crtc.c  | 54 ++---
 drivers/gpu/drm/radeon/radeon_cursor.c  | 14 +++---
 drivers/gpu/drm/radeon/radeon_display.c | 28 +--
 drivers/gpu/drm/radeon/radeon_kms.c |  6 +--
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c | 16 +++---
 5 files changed, 60 insertions(+), 58 deletions(-)

diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c 
b/drivers/gpu/drm/radeon/atombios_crtc.c
index ade13173921b..76a2924a8590 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -39,7 +39,7 @@ static void atombios_overscan_setup(struct drm_crtc *crtc,
struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct radeon_device *rdev = dev->dev_private;
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
SET_CRTC_OVERSCAN_PS_ALLOCATION args;
@@ -82,7 +82,7 @@ static void atombios_overscan_setup(struct drm_crtc *crtc,
 
 static void atombios_scaler_setup(struct drm_crtc *crtc)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct radeon_device *rdev = dev->dev_private;
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
ENABLE_SCALER_PS_ALLOCATION args;
@@ -167,7 +167,7 @@ static void atombios_scaler_setup(struct drm_crtc *crtc)
 static void atombios_lock_crtc(struct drm_crtc *crtc, int lock)
 {
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct radeon_device *rdev = dev->dev_private;
int index =
GetIndexIntoMasterTable(COMMAND, UpdateCRTC_DoubleBufferRegisters);
@@ -184,7 +184,7 @@ static void atombios_lock_crtc(struct drm_crtc *crtc, int 
lock)
 static void atombios_enable_crtc(struct drm_crtc *crtc, int state)
 {
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct radeon_device *rdev = dev->dev_private;
int index = GetIndexIntoMasterTable(COMMAND, EnableCRTC);
ENABLE_CRTC_PS_ALLOCATION args;
@@ -200,7 +200,7 @@ static void atombios_enable_crtc(struct drm_crtc *crtc, int 
state)
 static void atombios_enable_crtc_memreq(struct drm_crtc *crtc, int state)
 {
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct radeon_device *rdev = dev->dev_private;
int index = GetIndexIntoMasterTable(COMMAND, EnableCRTCMemReq);
ENABLE_CRTC_PS_ALLOCATION args;
@@ -226,7 +226,7 @@ static const u32 vga_control_regs[6] =
 static void atombios_blank_crtc(struct drm_crtc *crtc, int state)
 {
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct radeon_device *rdev = dev->dev_private;
int index = GetIndexIntoMasterTable(COMMAND, BlankCRTC);
BLANK_CRTC_PS_ALLOCATION args;
@@ -251,7 +251,7 @@ static void atombios_blank_crtc(struct drm_crtc *crtc, int 
state)
 static void atombios_powergate_crtc(struct drm_crtc *crtc, int state)
 {
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct radeon_device *rdev = dev->dev_private;
int index = GetIndexIntoMasterTable(COMMAND, EnableDispPowerGating);
ENABLE_DISP_POWER_GATING_PARAMETERS_V2_1 args;
@@ -266,7 +266,7 @@ static void atombios_powergate_crtc(struct drm_crtc *crtc, 
int state)
 
 void atombios_crtc_dpms(struct drm_crtc *crtc, int mode)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct radeon_device *rdev = dev->dev_private;
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
 
@@ -303,7 +303,7 @@ atombios_set_crtc_dtd_timing(struct drm_crtc *crtc,
 struct drm_display_mode *mode)
 {
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct radeon_device *rdev = dev->dev_private;
SET_CRTC_USING_DTD_TIMING_PARAMETERS args;
int index = GetIndexIntoMasterTable(COMMAND, SetCRTC_UsingDTDTiming);
@@ -350,7 +350,7 @@ static void atombios_crtc_set_timing(struct drm_crtc *crtc,
 struct drm_display_mode *

[PATCH RFC v1 52/52] drm/crtc: Complete renaming struct drm_crtc::dev to drm_dev

2023-07-12 Thread Uwe Kleine-König
Now that all drivers use the new and better name, the old one can be
dropped.

Signed-off-by: Uwe Kleine-König 
---
 include/drm/drm_crtc.h | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 66b65108024e..33a6e90f8d19 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -936,15 +936,7 @@ struct drm_crtc_funcs {
  */
 struct drm_crtc {
/** @drm_dev: parent DRM device */
-   union {
-   /* "dev" is a name that is typically (only) used for struct
-* device pointers. It's about to be renamed to "drm_dev" to be
-* easier to parse for humans. To not have to convert all
-* drivers in a single step keep the old name around for now.
-*/
-   struct drm_device *drm_dev;
-   struct drm_device *dev;
-   };
+   struct drm_device *drm_dev;
/** @port: OF node used by drm_of_find_possible_crtcs(). */
struct device_node *port;
/**
-- 
2.39.2



[PATCH RFC v1 51/52] drm/xlnx: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/xlnx/zynqmp_kms.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/xlnx/zynqmp_kms.c 
b/drivers/gpu/drm/xlnx/zynqmp_kms.c
index a7f8611be6f4..ba12efc4b9e4 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_kms.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_kms.c
@@ -232,12 +232,12 @@ static void zynqmp_dpsub_crtc_atomic_disable(struct 
drm_crtc *crtc,
 
drm_crtc_vblank_off(crtc);
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
if (crtc->state->event) {
drm_crtc_send_vblank_event(crtc, crtc->state->event);
crtc->state->event = NULL;
}
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
 
clk_disable_unprepare(dpsub->vid_clk);
pm_runtime_put_sync(dpsub->dev);
@@ -269,9 +269,9 @@ static void zynqmp_dpsub_crtc_atomic_flush(struct drm_crtc 
*crtc,
 
WARN_ON(drm_crtc_vblank_get(crtc) != 0);
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
drm_crtc_arm_vblank_event(crtc, event);
-   spin_unlock_irq(&crtc->dev->event_lock);
+   spin_unlock_irq(&crtc->drm_dev->event_lock);
}
 }
 
-- 
2.39.2



[PATCH RFC v1 13/52] drm/hisilicon: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_de.c| 20 +--
 .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c   |  4 ++--
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
index 89bed78f1466..4682b17fc5ff 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
@@ -159,7 +159,7 @@ static const struct drm_plane_helper_funcs 
hibmc_plane_helper_funcs = {
 
 static void hibmc_crtc_dpms(struct drm_crtc *crtc, u32 dpms)
 {
-   struct hibmc_drm_private *priv = to_hibmc_drm_private(crtc->dev);
+   struct hibmc_drm_private *priv = to_hibmc_drm_private(crtc->drm_dev);
u32 reg;
 
reg = readl(priv->mmio + HIBMC_CRT_DISP_CTL);
@@ -175,7 +175,7 @@ static void hibmc_crtc_atomic_enable(struct drm_crtc *crtc,
 struct drm_atomic_state *state)
 {
u32 reg;
-   struct hibmc_drm_private *priv = to_hibmc_drm_private(crtc->dev);
+   struct hibmc_drm_private *priv = to_hibmc_drm_private(crtc->drm_dev);
 
hibmc_set_power_mode(priv, HIBMC_PW_MODE_CTL_MODE_MODE0);
 
@@ -194,7 +194,7 @@ static void hibmc_crtc_atomic_disable(struct drm_crtc *crtc,
  struct drm_atomic_state *state)
 {
u32 reg;
-   struct hibmc_drm_private *priv = to_hibmc_drm_private(crtc->dev);
+   struct hibmc_drm_private *priv = to_hibmc_drm_private(crtc->drm_dev);
 
hibmc_crtc_dpms(crtc, HIBMC_CRT_DPMS_OFF);
drm_crtc_vblank_off(crtc);
@@ -361,7 +361,7 @@ static void hibmc_crtc_mode_set_nofb(struct drm_crtc *crtc)
 {
u32 val;
struct drm_display_mode *mode = &crtc->state->mode;
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct hibmc_drm_private *priv = to_hibmc_drm_private(dev);
u32 width = mode->hsync_end - mode->hsync_start;
u32 height = mode->vsync_end - mode->vsync_start;
@@ -395,7 +395,7 @@ static void hibmc_crtc_atomic_begin(struct drm_crtc *crtc,
struct drm_atomic_state *state)
 {
u32 reg;
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct hibmc_drm_private *priv = to_hibmc_drm_private(dev);
 
hibmc_set_power_mode(priv, HIBMC_PW_MODE_CTL_MODE_MODE0);
@@ -417,16 +417,16 @@ static void hibmc_crtc_atomic_flush(struct drm_crtc *crtc,
 {
unsigned long flags;
 
-   spin_lock_irqsave(&crtc->dev->event_lock, flags);
+   spin_lock_irqsave(&crtc->drm_dev->event_lock, flags);
if (crtc->state->event)
drm_crtc_send_vblank_event(crtc, crtc->state->event);
crtc->state->event = NULL;
-   spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
+   spin_unlock_irqrestore(&crtc->drm_dev->event_lock, flags);
 }
 
 static int hibmc_crtc_enable_vblank(struct drm_crtc *crtc)
 {
-   struct hibmc_drm_private *priv = to_hibmc_drm_private(crtc->dev);
+   struct hibmc_drm_private *priv = to_hibmc_drm_private(crtc->drm_dev);
 
writel(HIBMC_RAW_INTERRUPT_EN_VBLANK(1),
   priv->mmio + HIBMC_RAW_INTERRUPT_EN);
@@ -436,7 +436,7 @@ static int hibmc_crtc_enable_vblank(struct drm_crtc *crtc)
 
 static void hibmc_crtc_disable_vblank(struct drm_crtc *crtc)
 {
-   struct hibmc_drm_private *priv = to_hibmc_drm_private(crtc->dev);
+   struct hibmc_drm_private *priv = to_hibmc_drm_private(crtc->drm_dev);
 
writel(HIBMC_RAW_INTERRUPT_EN_VBLANK(0),
   priv->mmio + HIBMC_RAW_INTERRUPT_EN);
@@ -444,7 +444,7 @@ static void hibmc_crtc_disable_vblank(struct drm_crtc *crtc)
 
 static void hibmc_crtc_load_lut(struct drm_crtc *crtc)
 {
-   struct hibmc_drm_private *priv = to_hibmc_drm_private(crtc->dev);
+   struct hibmc_drm_private *priv = to_hibmc_drm_private(crtc->drm_dev);
void __iomem   *mmio = priv->mmio;
u16 *r, *g, *b;
u32 reg;
diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c 
b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
index 871f79a6b17e..a3cfae5d17dd 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
@@ -516,12 +516,12 @@ static void ade_crtc_atomic_flush(struct drm_crtc *crtc,
if (event) {
crtc->state->event = NULL;
 
-   spin_lock_irq(&crtc->dev->event_lock);
+   spin_lock_irq(&crtc->drm_dev->event_lock);
if (drm_crtc_vblank_get(crtc) == 0)
drm_crtc_arm_vblank_event(crtc, event);
else
drm_crtc_send_vblank_event(crtc, event);
-   spin

[PATCH RFC v1 03/52] drm/amd: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   | 18 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   |  6 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_pll.c   |  6 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c  |  8 ++---
 drivers/gpu/drm/amd/amdgpu/atombios_crtc.c| 22 +++---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c| 26 -
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c| 28 +-
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 26 -
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 26 -
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 29 ++-
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c | 20 ++---
 .../amd/display/amdgpu_dm/amdgpu_dm_crtc.c|  8 ++---
 .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 22 +++---
 .../amd/display/amdgpu_dm/amdgpu_dm_plane.c   |  2 +-
 14 files changed, 125 insertions(+), 122 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index b702f499f5fb..cc796e56c3d7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -147,14 +147,14 @@ static void amdgpu_display_flip_work_func(struct 
work_struct *__work)
}
 
/* We borrow the event spin lock for protecting flip_status */
-   spin_lock_irqsave(&crtc->dev->event_lock, flags);
+   spin_lock_irqsave(&crtc->drm_dev->event_lock, flags);
 
/* Do the flip (mmio) */
adev->mode_info.funcs->page_flip(adev, work->crtc_id, work->base, 
work->async);
 
/* Set the flip status */
amdgpu_crtc->pflip_status = AMDGPU_FLIP_SUBMITTED;
-   spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
+   spin_unlock_irqrestore(&crtc->drm_dev->event_lock, flags);
 
 
drm_dbg_vbl(adev_to_drm(adev),
@@ -191,7 +191,7 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc 
*crtc,
uint32_t page_flip_flags, uint32_t target,
struct drm_modeset_acquire_ctx *ctx)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct amdgpu_device *adev = drm_to_adev(dev);
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
struct drm_gem_object *obj;
@@ -262,10 +262,10 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc 
*crtc,
amdgpu_get_vblank_counter_kms(crtc);
 
/* we borrow the event spin lock for protecting flip_wrok */
-   spin_lock_irqsave(&crtc->dev->event_lock, flags);
+   spin_lock_irqsave(&crtc->drm_dev->event_lock, flags);
if (amdgpu_crtc->pflip_status != AMDGPU_FLIP_NONE) {
DRM_DEBUG_DRIVER("flip queue: crtc already busy\n");
-   spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
+   spin_unlock_irqrestore(&crtc->drm_dev->event_lock, flags);
r = -EBUSY;
goto pflip_cleanup;
}
@@ -278,7 +278,7 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc 
*crtc,
 amdgpu_crtc->crtc_id, amdgpu_crtc, 
work);
/* update crtc fb */
crtc->primary->fb = fb;
-   spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
+   spin_unlock_irqrestore(&crtc->drm_dev->event_lock, flags);
amdgpu_display_flip_work_func(&work->flip_work.work);
return 0;
 
@@ -316,7 +316,7 @@ int amdgpu_display_crtc_set_config(struct drm_mode_set *set,
if (!set || !set->crtc)
return -EINVAL;
 
-   dev = set->crtc->dev;
+   dev = set->crtc->drm_dev;
 
ret = pm_runtime_get_sync(dev->dev);
if (ret < 0)
@@ -1353,7 +1353,7 @@ bool amdgpu_display_crtc_scaling_mode_fixup(struct 
drm_crtc *crtc,
const struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct drm_encoder *encoder;
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
struct amdgpu_encoder *amdgpu_encoder;
@@ -1587,7 +1587,7 @@ bool amdgpu_crtc_get_scanout_position(struct drm_crtc 
*crtc,
int *hpos, ktime_t *stime, ktime_t *etime,
const struct drm_display_mode *mode)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
unsigned int pipe = crtc->index;
 
return amdgpu_display_get_crtc_scanoutpos(dev, pipe, 0, vpos, hpos,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index cca5a495611f

[PATCH RFC v1 24/52] drm/msm: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c |  6 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c  | 70 +++
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c   |  2 +-
 drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c | 12 ++--
 drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 20 +++---
 drivers/gpu/drm/msm/msm_drv.c |  4 +-
 6 files changed, 62 insertions(+), 52 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
index 1d9d83d7b99e..a71169776690 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
@@ -102,7 +102,7 @@ static u64 _dpu_core_perf_calc_clk(struct dpu_kms *kms,
 static struct dpu_kms *_dpu_crtc_get_kms(struct drm_crtc *crtc)
 {
struct msm_drm_private *priv;
-   priv = crtc->dev->dev_private;
+   priv = crtc->drm_dev->dev_private;
return to_dpu_kms(priv->kms);
 }
 
@@ -171,7 +171,7 @@ int dpu_core_perf_crtc_check(struct drm_crtc *crtc,
bw_sum_of_intfs = dpu_cstate->new_perf.bw_ctl;
curr_client_type = dpu_crtc_get_client_type(crtc);
 
-   drm_for_each_crtc(tmp_crtc, crtc->dev) {
+   drm_for_each_crtc(tmp_crtc, crtc->drm_dev) {
if (tmp_crtc->enabled &&
(dpu_crtc_get_client_type(tmp_crtc) ==
curr_client_type) && (tmp_crtc != crtc)) {
@@ -217,7 +217,7 @@ static int _dpu_core_perf_crtc_update_bus(struct dpu_kms 
*kms,
int i, ret = 0;
u64 avg_bw;
 
-   drm_for_each_crtc(tmp_crtc, crtc->dev) {
+   drm_for_each_crtc(tmp_crtc, crtc->drm_dev) {
if (tmp_crtc->enabled &&
curr_client_type ==
dpu_crtc_get_client_type(tmp_crtc)) {
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
index 1edf2b6b0a26..ca9a95a0b028 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
@@ -46,7 +46,7 @@
 
 static struct dpu_kms *_dpu_crtc_get_kms(struct drm_crtc *crtc)
 {
-   struct msm_drm_private *priv = crtc->dev->dev_private;
+   struct msm_drm_private *priv = crtc->drm_dev->dev_private;
 
return to_dpu_kms(priv->kms);
 }
@@ -64,7 +64,7 @@ static void dpu_crtc_destroy(struct drm_crtc *crtc)
 
 static struct drm_encoder *get_encoder_from_crtc(struct drm_crtc *crtc)
 {
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
struct drm_encoder *encoder;
 
drm_for_each_encoder(encoder, dev)
@@ -106,7 +106,7 @@ static int dpu_crtc_verify_crc_source(struct drm_crtc *crtc,
 
*values_cnt = 0;
 
-   drm_for_each_encoder_mask(drm_enc, crtc->dev, 
crtc->state->encoder_mask)
+   drm_for_each_encoder_mask(drm_enc, crtc->drm_dev, 
crtc->state->encoder_mask)
*values_cnt += dpu_encoder_get_crc_values_cnt(drm_enc);
}
 
@@ -133,7 +133,8 @@ static void dpu_crtc_setup_encoder_misr(struct drm_crtc 
*crtc)
 {
struct drm_encoder *drm_enc;
 
-   drm_for_each_encoder_mask(drm_enc, crtc->dev, crtc->state->encoder_mask)
+   drm_for_each_encoder_mask(drm_enc, crtc->drm_dev,
+ crtc->state->encoder_mask)
dpu_encoder_setup_misr(drm_enc);
 }
 
@@ -142,7 +143,7 @@ static int dpu_crtc_set_crc_source(struct drm_crtc *crtc, 
const char *src_name)
enum dpu_crtc_crc_source source = dpu_crtc_parse_crc_source(src_name);
enum dpu_crtc_crc_source current_source;
struct dpu_crtc_state *crtc_state;
-   struct drm_device *drm_dev = crtc->dev;
+   struct drm_device *drm_dev = crtc->drm_dev;
 
bool was_enabled;
bool enable = false;
@@ -244,7 +245,8 @@ static int dpu_crtc_get_encoder_crc(struct drm_crtc *crtc)
int rc, pos = 0;
u32 crcs[INTF_MAX];
 
-   drm_for_each_encoder_mask(drm_enc, crtc->dev, 
crtc->state->encoder_mask) {
+   drm_for_each_encoder_mask(drm_enc, crtc->drm_dev,
+ crtc->state->encoder_mask) {
rc = dpu_encoder_get_crc(drm_enc, crcs, pos);
if (rc < 0) {
if (rc != -ENODATA)
@@ -569,7 +571,7 @@ static void _dpu_crtc_blend_setup(struct drm_crtc *crtc)
 static void _dpu_crtc_complete_flip(struct drm_crtc *crtc)
 {
struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
+   struct drm_device *dev = crtc->drm_dev;
unsigned long flags;
 
spin_lock_irqsave(&dev->event_lock, flags);
@@ -599,7 +601,8 @@ enum dpu_intf_mode dpu_crtc_get_intf_mode(struct drm_crtc 
*crtc)
WARN_ON(!drm_modeset_is_lock

[PATCH RFC v1 42/52] drm/tiny: Use struct drm_crtc::drm_dev instead of struct drm_crtc::dev

2023-07-12 Thread Uwe Kleine-König
Prepare dropping the alias "dev" for struct drm_crtc::drm_dev. "drm_dev"
is the better name as "dev" is usually a struct device pointer.

No semantic changes.

Signed-off-by: Uwe Kleine-König 
---
 drivers/gpu/drm/tiny/bochs.c  | 6 +++---
 drivers/gpu/drm/tiny/cirrus.c | 2 +-
 drivers/gpu/drm/tiny/gm12u320.c   | 4 ++--
 drivers/gpu/drm/tiny/hx8357d.c| 4 ++--
 drivers/gpu/drm/tiny/ili9163.c| 4 ++--
 drivers/gpu/drm/tiny/ili9225.c| 8 
 drivers/gpu/drm/tiny/ili9341.c| 4 ++--
 drivers/gpu/drm/tiny/ili9486.c| 4 ++--
 drivers/gpu/drm/tiny/mi0283qt.c   | 4 ++--
 drivers/gpu/drm/tiny/ofdrm.c  | 8 
 drivers/gpu/drm/tiny/panel-mipi-dbi.c | 6 +++---
 drivers/gpu/drm/tiny/repaper.c| 8 
 drivers/gpu/drm/tiny/simpledrm.c  | 2 +-
 drivers/gpu/drm/tiny/st7586.c | 6 +++---
 drivers/gpu/drm/tiny/st7735r.c| 4 ++--
 15 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c
index d254679a136e..d22c08ba4bd3 100644
--- a/drivers/gpu/drm/tiny/bochs.c
+++ b/drivers/gpu/drm/tiny/bochs.c
@@ -440,7 +440,7 @@ static void bochs_pipe_enable(struct 
drm_simple_display_pipe *pipe,
  struct drm_crtc_state *crtc_state,
  struct drm_plane_state *plane_state)
 {
-   struct bochs_device *bochs = pipe->crtc.dev->dev_private;
+   struct bochs_device *bochs = pipe->crtc.drm_dev->dev_private;
 
bochs_hw_setmode(bochs, &crtc_state->mode);
bochs_plane_update(bochs, plane_state);
@@ -448,7 +448,7 @@ static void bochs_pipe_enable(struct 
drm_simple_display_pipe *pipe,
 
 static void bochs_pipe_disable(struct drm_simple_display_pipe *pipe)
 {
-   struct bochs_device *bochs = pipe->crtc.dev->dev_private;
+   struct bochs_device *bochs = pipe->crtc.drm_dev->dev_private;
 
bochs_hw_blank(bochs, true);
 }
@@ -456,7 +456,7 @@ static void bochs_pipe_disable(struct 
drm_simple_display_pipe *pipe)
 static void bochs_pipe_update(struct drm_simple_display_pipe *pipe,
  struct drm_plane_state *old_state)
 {
-   struct bochs_device *bochs = pipe->crtc.dev->dev_private;
+   struct bochs_device *bochs = pipe->crtc.drm_dev->dev_private;
 
bochs_plane_update(bochs, pipe->plane.state);
 }
diff --git a/drivers/gpu/drm/tiny/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
index 594bc472862f..efa446041bb1 100644
--- a/drivers/gpu/drm/tiny/cirrus.c
+++ b/drivers/gpu/drm/tiny/cirrus.c
@@ -499,7 +499,7 @@ static int cirrus_crtc_helper_atomic_check(struct drm_crtc 
*crtc, struct drm_ato
 static void cirrus_crtc_helper_atomic_enable(struct drm_crtc *crtc,
 struct drm_atomic_state *state)
 {
-   struct cirrus_device *cirrus = to_cirrus(crtc->dev);
+   struct cirrus_device *cirrus = to_cirrus(crtc->drm_dev);
struct drm_crtc_state *crtc_state = 
drm_atomic_get_new_crtc_state(state, crtc);
int idx;
 
diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c
index c5bb683e440c..d18f7b8223ed 100644
--- a/drivers/gpu/drm/tiny/gm12u320.c
+++ b/drivers/gpu/drm/tiny/gm12u320.c
@@ -554,7 +554,7 @@ static void gm12u320_pipe_enable(struct 
drm_simple_display_pipe *pipe,
 struct drm_plane_state *plane_state)
 {
struct drm_rect rect = { 0, 0, GM12U320_USER_WIDTH, GM12U320_HEIGHT };
-   struct gm12u320_device *gm12u320 = to_gm12u320(pipe->crtc.dev);
+   struct gm12u320_device *gm12u320 = to_gm12u320(pipe->crtc.drm_dev);
struct drm_shadow_plane_state *shadow_plane_state = 
to_drm_shadow_plane_state(plane_state);
 
gm12u320->fb_update.draw_status_timeout = FIRST_FRAME_TIMEOUT;
@@ -563,7 +563,7 @@ static void gm12u320_pipe_enable(struct 
drm_simple_display_pipe *pipe,
 
 static void gm12u320_pipe_disable(struct drm_simple_display_pipe *pipe)
 {
-   struct gm12u320_device *gm12u320 = to_gm12u320(pipe->crtc.dev);
+   struct gm12u320_device *gm12u320 = to_gm12u320(pipe->crtc.drm_dev);
 
gm12u320_stop_fb_update(gm12u320);
 }
diff --git a/drivers/gpu/drm/tiny/hx8357d.c b/drivers/gpu/drm/tiny/hx8357d.c
index cdc4486e059b..640a279980f2 100644
--- a/drivers/gpu/drm/tiny/hx8357d.c
+++ b/drivers/gpu/drm/tiny/hx8357d.c
@@ -48,12 +48,12 @@ static void yx240qv29_enable(struct drm_simple_display_pipe 
*pipe,
 struct drm_crtc_state *crtc_state,
 struct drm_plane_state *plane_state)
 {
-   struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev);
+   struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.drm_dev);
struct mipi_dbi *dbi = &dbidev->dbi;
u8 addr_mode;
int ret, idx;
 
-   if (!drm_dev_enter(pipe->crtc.dev, &idx))
+   if (!drm_dev_enter(pipe->crtc.drm_dev, &idx))
return;
 
DRM_DEBUG_K

Re: [PATCH 10/17] hid/picolcd: Remove flag FBINFO_FLAG_DEFAULT from fbdev driver

2023-07-12 Thread Bruno Prémont
On Mon, 10 Jul 2023 14:50:14 +0200 Thomas Zimmermann wrote:
> The flag FBINFO_FLAG_DEFAULT is 0 and has no effect, as struct
> fbinfo.flags has been allocated to zero by framebuffer_alloc(). So do
> not set it.
> 
> Flags should signal differences from the default values. After cleaning
> up all occurences of FBINFO_FLAG_DEFAULT, the token can be removed.
> 
> Signed-off-by: Thomas Zimmermann 
> Cc: "Bruno Prémont" 
> Cc: Jiri Kosina 
> Cc: Benjamin Tissoires 

Acked-by: Bruno Prémont 

Cheers,
Bruno


> ---
>  drivers/hid/hid-picolcd_fb.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/hid/hid-picolcd_fb.c b/drivers/hid/hid-picolcd_fb.c
> index dabcd054dad9..d726aaafb146 100644
> --- a/drivers/hid/hid-picolcd_fb.c
> +++ b/drivers/hid/hid-picolcd_fb.c
> @@ -527,7 +527,6 @@ int picolcd_init_framebuffer(struct picolcd_data *data)
>   info->var = picolcdfb_var;
>   info->fix = picolcdfb_fix;
>   info->fix.smem_len   = PICOLCDFB_SIZE*8;
> - info->flags = FBINFO_FLAG_DEFAULT;
>  
>   fbdata = info->par;
>   spin_lock_init(&fbdata->lock);



Re: Consider switching to WQ_UNBOUND messages (was: Re: [PATCH v2 6/7] workqueue: Report work funcs that trigger automatic CPU_INTENSIVE mechanism)

2023-07-12 Thread Geert Uytterhoeven
Hi Tejun,

On Wed, Jul 12, 2023 at 2:30 AM Tejun Heo  wrote:
> On Tue, Jul 11, 2023 at 11:39:17AM -1000, Tejun Heo wrote:
> > On Tue, Jul 11, 2023 at 04:06:22PM +0200, Geert Uytterhoeven wrote:
> > > On Tue, Jul 11, 2023 at 3:55 PM Geert Uytterhoeven  
> > > wrote:
> ...
> > > workqueue: neigh_managed_work hogged CPU for >1us 4 times,
> > > consider switching to WQ_UNBOUND
> >
> > I wonder whether the right thing to do here is somehow scaling the threshold
> > according to the relative processing power. It's difficult to come up with a
> > threshold which works well across the latest & fastest and really tiny CPUs.
> > I'll think about it some more but if you have some ideas, please feel free
> > to suggest.
>
> Geert, do you mind posting the full kernel logs for the affected machines?

https://drive.google.com/file/d/1toDs7ugZJ2eXatpdvySY4yxSsNam9xAC
is an archive with boot and s2ram logs.  Note that my kernels do contain
local debug code, and may be noisy.

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


[Bug 217664] New: Laptop doesnt wake up from suspend mode.

2023-07-12 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=217664

Bug ID: 217664
   Summary: Laptop doesnt wake up from suspend mode.
   Product: Drivers
   Version: 2.5
  Hardware: All
OS: Linux
Status: NEW
  Severity: normal
  Priority: P3
 Component: Video(DRI - non Intel)
  Assignee: drivers_video-...@kernel-bugs.osdl.org
  Reporter: pentelja...@o2.pl
Regression: No

Operating System: Kubuntu 23.04
KDE Plasma Version: 5.27.4
KDE Frameworks Version: 5.104.0
Qt Version: 5.15.8
Kernel Version: 6.2.0-25-generic (64-bit)
Graphics Platform: X11
Processors: 12 × AMD Ryzen 5 5600H with Radeon Graphics
Memory: 22.8 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Manufacturer: MEDION
Product Name: Crawler E25
System Version: Not Applicable


05:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI]
Cezanne [Radeon Vega Series / Radeon Vega Mobile Series] (rev c6) (prog-if 00
[VGA controller])
Subsystem: CLEVO/KAPOK Computer Cezanne [Radeon Vega Series / Radeon
Vega Mobile Series]
Flags: bus master, fast devsel, latency 0, IRQ 50, IOMMU group 6
Memory at fc1000 (64-bit, prefetchable) [size=256M]
Memory at fc2000 (64-bit, prefetchable) [size=2M]
I/O ports at 1000 [size=256]
Memory at d150 (32-bit, non-prefetchable) [size=512K]
Capabilities: [48] Vendor Specific Information: Len=08 
Capabilities: [50] Power Management version 3
Capabilities: [64] Express Legacy Endpoint, MSI 00
Capabilities: [a0] MSI: Enable- Count=1/4 Maskable- 64bit+
Capabilities: [c0] MSI-X: Enable+ Count=4 Masked-
Capabilities: [100] Vendor Specific Information: ID=0001 Rev=1 Len=010

Capabilities: [270] Secondary PCI Express
Capabilities: [2b0] Address Translation Service (ATS)
Capabilities: [2c0] Page Request Interface (PRI)
Capabilities: [2d0] Process Address Space ID (PASID)
Capabilities: [400] Data Link Feature 
Capabilities: [410] Physical Layer 16.0 GT/s 
Capabilities: [440] Lane Margining at the Receiver 
Kernel driver in use: amdgpu
Kernel modules: amdgpu
```

dmesg --> https://pastebin.com/SXmYX9NL

`



Since closing lid is a basic thing of laptops and only sense it would be good
to use this functionality. Many people having same problem, ignored for many
years. Dont know which section it should be reported: X11, drivers or ACPI.
dmesg saying nothing.
Opening lid doenst turn on screen but fans still are alive. Hard shutdown works
(power button for few seconds), in general system works ( i suspect) beyond
main feature - display

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.

[Bug 217664] Laptop doesnt wake up from suspend mode.

2023-07-12 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=217664

--- Comment #1 from popus_czy_to_ty (pentelja...@o2.pl) ---
second card. somehow didnt add it, cant edit.

01:00.0 VGA compatible controller: NVIDIA Corporation GA107M [GeForce RTX 3050
Mobile] (rev a1) (prog-if 00 [VGA controller])
Subsystem: CLEVO/KAPOK Computer GA107M [GeForce RTX 3050 Mobile]
Physical Slot: 0
Flags: bus master, fast devsel, latency 0, IRQ 80, IOMMU group 9
Memory at d000 (32-bit, non-prefetchable) [size=16M]
Memory at fb (64-bit, prefetchable) [size=4G]
Memory at fc (64-bit, prefetchable) [size=32M]
I/O ports at 3000 [size=128]
Expansion ROM at d108 [virtual] [disabled] [size=512K]
Capabilities: [60] Power Management version 3
Capabilities: [68] MSI: Enable+ Count=1/1 Maskable- 64bit+
Capabilities: [78] Express Legacy Endpoint, MSI 00
Capabilities: [b4] Vendor Specific Information: Len=14 
Capabilities: [100] Virtual Channel
Capabilities: [258] L1 PM Substates
Capabilities: [128] Power Budgeting 
Capabilities: [420] Advanced Error Reporting
Capabilities: [600] Vendor Specific Information: ID=0001 Rev=1 Len=024

Capabilities: [900] Secondary PCI Express
Capabilities: [bb0] Physical Resizable BAR
Capabilities: [c1c] Physical Layer 16.0 GT/s 
Capabilities: [d00] Lane Margining at the Receiver 
Capabilities: [e00] Data Link Feature 
Kernel driver in use: nvidia
Kernel modules: nvidiafb, nouveau, nvidia_drm, nvidia

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.

Re: [Intel-gfx] [PATCH] drm/i915/huc: check HuC and GuC version compatibility on MTL

2023-07-12 Thread Andrzej Hajda

On 11.07.2023 22:31, Daniele Ceraolo Spurio wrote:

Due to a change in the auth flow on MTL, GuC 70.7.0 and newer will only
be able to authenticate HuC 8.5.1 and newer. The plan is to update the 2
binaries sinchronously in linux-firmware so that the fw repo always has
a matching pair that works; still, it's better to check in the kernel so
we can print an error message and abort HuC loading if the binaries are
out of sync instead of failing the authentication.

Signed-off-by: Daniele Ceraolo Spurio 
Cc: John Harrison 
---
  drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 42 
  1 file changed, 42 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c 
b/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c
index 08e16017584b..f0cc5bb47fa0 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c
@@ -803,11 +803,53 @@ static int try_firmware_load(struct intel_uc_fw *uc_fw, 
const struct firmware **
return 0;
  }
  
+static int check_mtl_huc_guc_compatibility(struct intel_gt *gt,

+  struct intel_uc_fw_file 
*huc_selected)
+{
+   struct intel_uc_fw_file *guc_selected = >->uc.guc.fw.file_selected;
+   struct intel_uc_fw_ver *huc_ver = &huc_selected->ver;
+   struct intel_uc_fw_ver *guc_ver = &guc_selected->ver;
+   bool new_huc;
+   bool new_guc;
+
+   /* we can only do this check after having fetched both GuC and HuC */
+   GEM_BUG_ON(!huc_selected->path || !guc_selected->path);
+
+   /*
+* Due to changes in the authentication flow for MTL, HuC 8.5.1 or newer
+* requires GuC 70.7.0 or newer. Older HuC binaries will instead require
+* GuC < 70.7.0.
+*/
+   new_huc = huc_ver->major > 8 ||
+ (huc_ver->major == 8 && huc_ver->minor > 5) ||
+ (huc_ver->major == 8 && huc_ver->minor == 5 && huc_ver->patch 
>= 1);
+
+   new_guc = guc_ver->major > 70 ||
+ (guc_ver->major == 70 && guc_ver->minor >= 7);


Wouldn't be more readable to define sth like UC_VER_FULL(v)
then use UC_VER_FULL(huc_ver) >= IP_VER_FULL(8, 5, 1).
I am not sure if it is worth for two checks.



+
+   if (new_huc != new_guc) {
+   UNEXPECTED(gt, "HuC %u.%u.%u is incompatible with GuC 
%u.%u.%u\n",
+  huc_ver->major, huc_ver->minor, huc_ver->patch,
+  guc_ver->major, guc_ver->minor, guc_ver->patch);
+   gt_info(gt, "MTL GuC 70.7.0+ and HuC 8.5.1+ don't work with older 
releases\n");
+   return -ENOEXEC;
+   }
+
+   return 0;
+}
+
  int intel_uc_check_file_version(struct intel_uc_fw *uc_fw, bool *old_ver)
  {
struct intel_gt *gt = __uc_fw_to_gt(uc_fw);
struct intel_uc_fw_file *wanted = &uc_fw->file_wanted;
struct intel_uc_fw_file *selected = &uc_fw->file_selected;
+   int ret;
+
+   if (IS_METEORLAKE(gt->i915) && uc_fw->type == INTEL_UC_FW_TYPE_HUC) {


Moving this check inside check function would make it more generic, up 
to you.


Reviewed-by: Andrzej Hajda 

Regards
Andrzej



+   ret = check_mtl_huc_guc_compatibility(gt, selected);
+   if (ret)
+   return ret;
+   }
  
  	if (!wanted->ver.major || !selected->ver.major)

return 0;




[Bug 217664] Laptop doesnt wake up from suspend mode.

2023-07-12 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=217664

--- Comment #2 from popus_czy_to_ty (pentelja...@o2.pl) ---
second card. somehow didnt add it, cant edit.

01:00.0 VGA compatible controller: NVIDIA Corporation GA107M [GeForce RTX 3050
Mobile] (rev a1) (prog-if 00 [VGA controller])
Subsystem: CLEVO/KAPOK Computer GA107M [GeForce RTX 3050 Mobile]
Physical Slot: 0
Flags: bus master, fast devsel, latency 0, IRQ 80, IOMMU group 9
Memory at d000 (32-bit, non-prefetchable) [size=16M]
Memory at fb (64-bit, prefetchable) [size=4G]
Memory at fc (64-bit, prefetchable) [size=32M]
I/O ports at 3000 [size=128]
Expansion ROM at d108 [virtual] [disabled] [size=512K]
Capabilities: [60] Power Management version 3
Capabilities: [68] MSI: Enable+ Count=1/1 Maskable- 64bit+
Capabilities: [78] Express Legacy Endpoint, MSI 00
Capabilities: [b4] Vendor Specific Information: Len=14 
Capabilities: [100] Virtual Channel
Capabilities: [258] L1 PM Substates
Capabilities: [128] Power Budgeting 
Capabilities: [420] Advanced Error Reporting
Capabilities: [600] Vendor Specific Information: ID=0001 Rev=1 Len=024

Capabilities: [900] Secondary PCI Express
Capabilities: [bb0] Physical Resizable BAR
Capabilities: [c1c] Physical Layer 16.0 GT/s 
Capabilities: [d00] Lane Margining at the Receiver 
Capabilities: [e00] Data Link Feature 
Kernel driver in use: nvidia
Kernel modules: nvidiafb, nouveau, nvidia_drm, nvidia

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.

Re: [PATCH] drm/virtio: remove some redundant code

2023-07-12 Thread Su Hui

On 2023/7/12 14:36, Dan Carpenter wrote:


On Wed, Jul 12, 2023 at 09:18:42AM +0800, Su Hui wrote:

On 2023/7/11 19:13, Dan Carpenter wrote:

On Tue, Jul 11, 2023 at 05:00:31PM +0800, Su Hui wrote:

virtio_gpu_get_vbuf always be successful,
so remove the error judgment.


No, just ignore the static checker false positive in this case.  The
intent of the code is clear that if it did have an error it should
return an error pointer.

Hi, Dan,

Function "virtio_gpu_get_vbuf" call "kmem_cache_zalloc (vgdev->vbufs,
GFP_KERNEL | __GFP_NOFAIL)" to
allocate memory. Adding the " __GFP_NOFAIL”flag make sure it won't fail. And
"virtio_gpu_get_vbuf" never
return an error code, so I think this is not a false positive.

We all see this and agree.

However the check for if (IS_ERR()) is written deliberately because we
might change the code to return error pointers in the future.  Static
checkers are looking for code that does something unintentional but in
this case the code was written that way deliberately.
Got it ,  I shouldn't remove it because the check may be useful in the 
future.

Thanks for your explanation.

Su Hui



regards,
dan carpenter



Re: [PATCH v3 2/2] drm/ast: report connection status on Display Port.

2023-07-12 Thread Thomas Zimmermann

Hi

Am 12.07.23 um 10:35 schrieb Jocelyn Falempe:

Aspeed always report the display port as "connected", because it
doesn't set a .detect callback.
Fix this by providing the proper detect callback for astdp and dp501.

This also fixes the following regression:
Since commit fae7d186403e ("drm/probe-helper: Default to 640x480 if no
EDID on DP")
The default resolution is now 640x480 when no monitor is connected. But
Aspeed graphics is mostly used in servers, where no monitor is attached.
This also affects the remote BMC resolution to 640x480, which is
inconvenient, and breaks the anaconda installer.

v2: Add .detect callback to the dp/dp501 connector (Jani Nikula)
v3: Use .detect_ctx callback, and refactors (Thomas Zimmermann)
 Add a BMC virtual connector

Fixes: fae7d186403e ("drm/probe-helper: Default to 640x480 if no EDID on DP")
Signed-off-by: Jocelyn Falempe 


Reviewed-by: Thomas Zimmermann 

with a minor comment below.


---
  drivers/gpu/drm/ast/ast_dp.c| 11 ++
  drivers/gpu/drm/ast/ast_dp501.c | 37 ++---
  drivers/gpu/drm/ast/ast_drv.h   |  2 ++
  drivers/gpu/drm/ast/ast_mode.c  | 27 
  4 files changed, 65 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c
index 6dc1a09504e1..bf78f3d4aa3f 100644
--- a/drivers/gpu/drm/ast/ast_dp.c
+++ b/drivers/gpu/drm/ast/ast_dp.c
@@ -7,6 +7,17 @@
  #include 
  #include "ast_drv.h"
  
+bool ast_astdp_is_connected(struct ast_device *ast)

+{
+   if (!ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xD1, 
ASTDP_MCU_FW_EXECUTING))
+   return false;
+   if (!ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xDC, 
ASTDP_LINK_SUCCESS))
+   return false;
+   if (!ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xDF, ASTDP_HPD))
+   return false;
+   return true;
+}
+
  int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata)
  {
struct ast_device *ast = to_ast_device(dev);
diff --git a/drivers/gpu/drm/ast/ast_dp501.c b/drivers/gpu/drm/ast/ast_dp501.c
index a5d285850ffb..f10d53b0c94f 100644
--- a/drivers/gpu/drm/ast/ast_dp501.c
+++ b/drivers/gpu/drm/ast/ast_dp501.c
@@ -272,11 +272,9 @@ static bool ast_launch_m68k(struct drm_device *dev)
return true;
  }
  
-bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata)

+bool ast_dp501_is_connected(struct ast_device *ast)
  {
-   struct ast_device *ast = to_ast_device(dev);
-   u32 i, boot_address, offset, data;
-   u32 *pEDIDidx;
+   u32 boot_address, offset, data;
  
  	if (ast->config_mode == ast_use_p2a) {

boot_address = get_fw_base(ast);
@@ -292,14 +290,6 @@ bool ast_dp501_read_edid(struct drm_device *dev, u8 
*ediddata)
data = ast_mindwm(ast, boot_address + offset);
if (!(data & AST_DP501_PNP_CONNECTED))
return false;
-
-   /* Read EDID */
-   offset = AST_DP501_EDID_DATA;
-   for (i = 0; i < 128; i += 4) {
-   data = ast_mindwm(ast, boot_address + offset + i);
-   pEDIDidx = (u32 *)(ediddata + i);
-   *pEDIDidx = data;
-   }
} else {
if (!ast->dp501_fw_buf)
return false;
@@ -319,7 +309,30 @@ bool ast_dp501_read_edid(struct drm_device *dev, u8 
*ediddata)
data = readl(ast->dp501_fw_buf + offset);
if (!(data & AST_DP501_PNP_CONNECTED))
return false;
+   }
+   return true;
+}
+
+bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata)
+{
+   struct ast_device *ast = to_ast_device(dev);
+   u32 i, boot_address, offset, data;
+   u32 *pEDIDidx;
+
+   if (!ast_dp501_is_connected(ast))
+   return false;
+
+   if (ast->config_mode == ast_use_p2a) {
+   boot_address = get_fw_base(ast);
  
+		/* Read EDID */

+   offset = AST_DP501_EDID_DATA;
+   for (i = 0; i < 128; i += 4) {
+   data = ast_mindwm(ast, boot_address + offset + i);
+   pEDIDidx = (u32 *)(ediddata + i);
+   *pEDIDidx = data;
+   }
+   } else {
/* Read EDID */
offset = AST_DP501_EDID_DATA;
for (i = 0; i < 128; i += 4) {
diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index c9659e72002f..848a9f1403e8 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -514,6 +514,7 @@ void ast_patch_ahb_2500(struct ast_device *ast);
  /* ast dp501 */
  void ast_set_dp501_video_output(struct drm_device *dev, u8 mode);
  bool ast_backup_fw(struct drm_device *dev, u8 *addr, u32 size);
+bool ast_dp501_is_connected(struct ast_device *ast);
  bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata);
  u8 ast_get_dp501_max_clk(struct drm_device

Re: [PATCH v2 5/5] drm/ssd130x: Remove hardcoded bits-per-pixel in ssd130x_buf_alloc()

2023-07-12 Thread Geert Uytterhoeven
Hi Javier,

Thanks for your patch!

On Fri, Jun 9, 2023 at 7:09 PM Javier Martinez Canillas
 wrote:
> The driver only supports OLED controllers that have a native DRM_FORMAT_C1

DRM_FORMAT_R1 (colormap is fixed to white-on-black).

> pixel format and that is why it has harcoded a division of the width by 8.

hardcoded.

> But the driver might be extended to support devices that have a different
> pixel format. So it's better to use the struct drm_format_info helpers to
> compute the size of the buffer, used to store the pixels in native format.
>
> Signed-off-by: Javier Martinez Canillas 
> Reviewed-by: Thomas Zimmermann 

> --- a/drivers/gpu/drm/solomon/ssd130x.c
> +++ b/drivers/gpu/drm/solomon/ssd130x.c
> @@ -150,9 +150,16 @@ static int ssd130x_buf_alloc(struct ssd130x_device 
> *ssd130x)
>  {
> unsigned int page_height = ssd130x->device_info->page_height;
> unsigned int pages = DIV_ROUND_UP(ssd130x->height, page_height);
> +   const struct drm_format_info *fi;
> +   unsigned int pitch;
>
> -   ssd130x->buffer = kcalloc(DIV_ROUND_UP(ssd130x->width, 8),
> - ssd130x->height, GFP_KERNEL);
> +   fi = drm_format_info(DRM_FORMAT_C1);

DRM_FORMAT_R1.

> +   if (!fi)
> +   return -EINVAL;
> +
> +   pitch = drm_format_info_min_pitch(fi, 0, ssd130x->width);
> +
> +   ssd130x->buffer = kcalloc(pitch, ssd130x->height, GFP_KERNEL);
> if (!ssd130x->buffer)
> return -ENOMEM;

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: (subset) [PATCH v3 0/4] Qualcomm REFGEN regulator

2023-07-12 Thread Mark Brown
On Mon, 03 Jul 2023 20:15:53 +0200, Konrad Dybcio wrote:
> Recent Qualcomm SoCs have a REFGEN (reference voltage generator) regulator
> responsible for providing a reference voltage to some on-SoC IPs (like DSI
> or PHYs). It can be turned off when unused to save power.
> 
> This series introduces the driver for it and lets the DSI driver
> consume it.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git 
for-next

Thanks!

[1/4] dt-bindings: regulator: Describe Qualcomm REFGEN regulator
  commit: d16db38c2a66060ee25c6b86ee7b6d66d40fc8e0
[2/4] regulator: Introduce Qualcomm REFGEN regulator driver
  commit: 7cbfbe23796086fdb72b681e2c182b02acd36a04

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark



Re: [PATCH 3/6] drm/amdgpu: Rework coredump to use memory dynamically

2023-07-12 Thread Christian König

Am 12.07.23 um 10:59 schrieb Lucas Stach:

Am Mittwoch, dem 12.07.2023 um 10:37 +0200 schrieb Christian König:

Am 11.07.23 um 23:34 schrieb André Almeida:

Instead of storing coredump information inside amdgpu_device struct,
move if to a proper separated struct and allocate it dynamically. This
will make it easier to further expand the logged information.

Verry big NAK to this. The problem is that memory allocation isn't
allowed during a GPU reset.

What you could do is to allocate the memory with GFP_ATOMIC or similar,
but for a large structure that might not be possible.


I'm still not fully clear on what the rules are here. In etnaviv we do
devcoredump allocation in the GPU reset path with __GFP_NOWARN |
__GFP_NORETRY, which means the allocation will kick memory reclaim if
necessary, but will just give up if no memory could be made available
easily. This satisfies the forward progress guarantee in the absence of
successful memory allocation, which is the most important property in
this path, I think.

However, I'm not sure if the reclaim could lead to locking issues or
something like that with the more complex use-cases with MMU notifiers
and stuff like that. Christian, do you have any experience or
information that would be good to share in this regard?


Yeah, very good question.

__GFP_NORETRY isn't sufficient as far as I know. Reclaim must be 
completely suppressed to be able to allocate in a GPU reset handler.


Daniel added lockdep annotation to some of the dma-fence signaling paths 
and this yielded quite a bunch of potential deadlocks.


It's not even that reclaim itself waits for dma_fences (that can happen, 
but is quite unlikely), but rather that reclaim needs locks and under 
those locks we then wait for dma_fences.


We should probably add a define somewhere which documents that 
(GFP_ATOMIC | __NO_WARN) should be used in the GPU reset handlers when 
allocating memory for coredumps.


Regards,
Christian.



Regards,
Lucas


Regards,
Christian.


Signed-off-by: André Almeida 
---
   drivers/gpu/drm/amd/amdgpu/amdgpu.h| 14 +++--
   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 65 ++
   2 files changed, 51 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index dbe062a087c5..e1cc83a89d46 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1068,11 +1068,6 @@ struct amdgpu_device {
uint32_t*reset_dump_reg_list;
uint32_t*reset_dump_reg_value;
int num_regs;
-#ifdef CONFIG_DEV_COREDUMP
-   struct amdgpu_task_info reset_task_info;
-   boolreset_vram_lost;
-   struct timespec64   reset_time;
-#endif
   
   	boolscpm_enabled;

uint32_tscpm_status;
@@ -1085,6 +1080,15 @@ struct amdgpu_device {
uint32_taid_mask;
   };
   
+#ifdef CONFIG_DEV_COREDUMP

+struct amdgpu_coredump_info {
+   struct amdgpu_device*adev;
+   struct amdgpu_task_info reset_task_info;
+   struct timespec64   reset_time;
+   boolreset_vram_lost;
+};
+#endif
+
   static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev)
   {
return container_of(ddev, struct amdgpu_device, ddev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index e25f085ee886..23b9784e9787 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -4963,12 +4963,17 @@ static int amdgpu_reset_reg_dumps(struct amdgpu_device 
*adev)
return 0;
   }
   
-#ifdef CONFIG_DEV_COREDUMP

+#ifndef CONFIG_DEV_COREDUMP
+static void amdgpu_coredump(struct amdgpu_device *adev, bool vram_lost,
+   struct amdgpu_reset_context *reset_context)
+{
+}
+#else
   static ssize_t amdgpu_devcoredump_read(char *buffer, loff_t offset,
size_t count, void *data, size_t datalen)
   {
struct drm_printer p;
-   struct amdgpu_device *adev = data;
+   struct amdgpu_coredump_info *coredump = data;
struct drm_print_iterator iter;
int i;
   
@@ -4982,21 +4987,21 @@ static ssize_t amdgpu_devcoredump_read(char *buffer, loff_t offset,

drm_printf(&p, " AMDGPU Device Coredump \n");
drm_printf(&p, "kernel: " UTS_RELEASE "\n");
drm_printf(&p, "module: " KBUILD_MODNAME "\n");
-   drm_printf(&p, "time: %lld.%09ld\n", adev->reset_time.tv_sec, 
adev->reset_time.tv_nsec);
-   if (adev->reset_task_info.pid)
+   drm_printf(&p, "time: %lld.%09ld\n", coredump->reset_time.tv_sec, 
coredump->reset_time.tv_nsec);
+   if (coredump->reset_task_info.pid)
drm_printf(&p, "process_name: %s PID: %d\n"

Re: [PATCH v3 1/2] drm/ast: Add BMC virtual connector

2023-07-12 Thread Thomas Zimmermann

Hi,

thanks for this patch.

Am 12.07.23 um 10:35 schrieb Jocelyn Falempe:

Most aspeed devices have a BMC, which allows to remotely see the screen.
Also in the common use case, those servers don't have a display connected.
So add a Virtual connector, to reflect that even if no display is
connected, the framebuffer can still be seen remotely.
This prepares the work to implement a detect_ctx() for the Display port
connector.

Fixes: fae7d186403e ("drm/probe-helper: Default to 640x480 if no EDID on DP")
Signed-off-by: Jocelyn Falempe 
---
  drivers/gpu/drm/ast/ast_drv.h  |  4 ++
  drivers/gpu/drm/ast/ast_mode.c | 67 ++
  2 files changed, 71 insertions(+)

diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index 3f6e0c984523..c9659e72002f 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -214,6 +214,10 @@ struct ast_device {
struct drm_encoder encoder;
struct drm_connector connector;
} astdp;
+   struct {
+   struct drm_encoder encoder;
+   struct drm_connector connector;
+   } bmc;
} output;
  
  	bool support_wide_screen;

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index f711d592da52..8896b22eb5cf 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -1735,6 +1735,70 @@ static int ast_astdp_output_init(struct ast_device *ast)
return 0;
  }
  
+/*

+ * BMC virtual Connector
+ */
+
+static int ast_bmc_connector_helper_get_modes(struct drm_connector *connector)
+{
+   return drm_add_modes_noedid(connector, 1024, 768);


That's probably too small. The CRTC lists resolutions up to 1920x1200. 
Returning 1024x768 could easily filter out those higher-res modes.


The BMC can probably just use whatever the CRTC offers. So rather call 
drm_add_modes_noedid() with 4096x4096. At 32 bpp, this covers the max 
memory of 64 MiB.  The CRTC will filter out unsupported modes.




+}
+
+static const struct drm_connector_helper_funcs ast_bmc_connector_helper_funcs 
= {
+   .get_modes = ast_bmc_connector_helper_get_modes,
+};
+
+static const struct drm_connector_funcs ast_bmc_connector_funcs = {
+   .reset = drm_atomic_helper_connector_reset,
+   .fill_modes = drm_helper_probe_single_connector_modes,
+   .destroy = drm_connector_cleanup,
+   .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
+   .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
+};
+
+static int ast_bmc_connector_init(struct drm_device *dev,
+ struct drm_connector *connector)
+{
+   int ret;
+
+   ret = drm_connector_init(dev, connector, &ast_bmc_connector_funcs,
+DRM_MODE_CONNECTOR_VIRTUAL);
+   if (ret)
+   return ret;
+
+   drm_connector_helper_add(connector, &ast_bmc_connector_helper_funcs);
+
+   connector->interlace_allowed = 0;
+   connector->doublescan_allowed = 0;
+   connector->polled = 0;


It's zero-allocated memory. Please don't clear these fields manually. (I 
know that ast doesn't get this right.)



+
+   return 0;
+}
+
+static int ast_bmc_output_init(struct ast_device *ast)
+{
+   struct drm_device *dev = &ast->base;
+   struct drm_crtc *crtc = &ast->crtc;
+   struct drm_encoder *encoder = &ast->output.bmc.encoder;
+   struct drm_connector *connector = &ast->output.bmc.connector;
+   int ret;
+
+   ret = drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_VIRTUAL);


Adding the simple_encoder helper was a mistake. Please open-code its 
functionality in ast. (Also something that ast currently does not.)



+   if (ret)
+   return ret;
+   encoder->possible_crtcs = drm_crtc_mask(crtc);
+
+   ret = ast_bmc_connector_init(dev, connector);


Maybe just inline this call. It's simple enough.

Best regards
Thomas


+   if (ret)
+   return ret;
+
+   ret = drm_connector_attach_encoder(connector, encoder);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
  /*
   * Mode config
   */
@@ -1842,6 +1906,9 @@ int ast_mode_config_init(struct ast_device *ast)
if (ret)
return ret;
}
+   ret = ast_bmc_output_init(ast);
+   if (ret)
+   return ret;
  
  	drm_mode_config_reset(dev);
  


base-commit: b32d5a51f3c21843011d68a58e6ac0b897bce9f2


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


OpenPGP_signature
Description: OpenPGP digital signature


Re: [PATCH 3/6] drm/amdgpu: Rework coredump to use memory dynamically

2023-07-12 Thread Lucas Stach
Am Mittwoch, dem 12.07.2023 um 12:39 +0200 schrieb Christian König:
> Am 12.07.23 um 10:59 schrieb Lucas Stach:
> > Am Mittwoch, dem 12.07.2023 um 10:37 +0200 schrieb Christian König:
> > > Am 11.07.23 um 23:34 schrieb André Almeida:
> > > > Instead of storing coredump information inside amdgpu_device struct,
> > > > move if to a proper separated struct and allocate it dynamically. This
> > > > will make it easier to further expand the logged information.
> > > Verry big NAK to this. The problem is that memory allocation isn't
> > > allowed during a GPU reset.
> > > 
> > > What you could do is to allocate the memory with GFP_ATOMIC or similar,
> > > but for a large structure that might not be possible.
> > > 
> > I'm still not fully clear on what the rules are here. In etnaviv we do
> > devcoredump allocation in the GPU reset path with __GFP_NOWARN |
> > __GFP_NORETRY, which means the allocation will kick memory reclaim if
> > necessary, but will just give up if no memory could be made available
> > easily. This satisfies the forward progress guarantee in the absence of
> > successful memory allocation, which is the most important property in
> > this path, I think.
> > 
> > However, I'm not sure if the reclaim could lead to locking issues or
> > something like that with the more complex use-cases with MMU notifiers
> > and stuff like that. Christian, do you have any experience or
> > information that would be good to share in this regard?
> 
> Yeah, very good question.
> 
> __GFP_NORETRY isn't sufficient as far as I know. Reclaim must be 
> completely suppressed to be able to allocate in a GPU reset handler.
> 
> Daniel added lockdep annotation to some of the dma-fence signaling paths 
> and this yielded quite a bunch of potential deadlocks.
> 
> It's not even that reclaim itself waits for dma_fences (that can happen, 
> but is quite unlikely), but rather that reclaim needs locks and under 
> those locks we then wait for dma_fences.
> 
> We should probably add a define somewhere which documents that 
> (GFP_ATOMIC | __NO_WARN) should be used in the GPU reset handlers when 
> allocating memory for coredumps.
> 
> Regards,
> Christian.
> 
> > 
> > Regards,
> > Lucas
> > 
> > > Regards,
> > > Christian.
> > > 
> > > > Signed-off-by: André Almeida 
> > > > ---
> > > >drivers/gpu/drm/amd/amdgpu/amdgpu.h| 14 +++--
> > > >drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 65 
> > > > ++
> > > >2 files changed, 51 insertions(+), 28 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
> > > > b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > > > index dbe062a087c5..e1cc83a89d46 100644
> > > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > > > @@ -1068,11 +1068,6 @@ struct amdgpu_device {
> > > > uint32_t*reset_dump_reg_list;
> > > > uint32_t*reset_dump_reg_value;
> > > > int num_regs;
> > > > -#ifdef CONFIG_DEV_COREDUMP
> > > > -   struct amdgpu_task_info reset_task_info;
> > > > -   boolreset_vram_lost;
> > > > -   struct timespec64   reset_time;
> > > > -#endif
> > > >
> > > > boolscpm_enabled;
> > > > uint32_tscpm_status;
> > > > @@ -1085,6 +1080,15 @@ struct amdgpu_device {
> > > > uint32_taid_mask;
> > > >};
> > > >
> > > > +#ifdef CONFIG_DEV_COREDUMP
> > > > +struct amdgpu_coredump_info {
> > > > +   struct amdgpu_device*adev;
> > > > +   struct amdgpu_task_info reset_task_info;
> > > > +   struct timespec64   reset_time;
> > > > +   boolreset_vram_lost;
> > > > +};
> > > > +#endif
> > > > +
> > > >static inline struct amdgpu_device *drm_to_adev(struct drm_device 
> > > > *ddev)
> > > >{
> > > > return container_of(ddev, struct amdgpu_device, ddev);
> > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
> > > > b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > > > index e25f085ee886..23b9784e9787 100644
> > > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > > > @@ -4963,12 +4963,17 @@ static int amdgpu_reset_reg_dumps(struct 
> > > > amdgpu_device *adev)
> > > > return 0;
> > > >}
> > > >
> > > > -#ifdef CONFIG_DEV_COREDUMP
> > > > +#ifndef CONFIG_DEV_COREDUMP
> > > > +static void amdgpu_coredump(struct amdgpu_device *adev, bool vram_lost,
> > > > +   struct amdgpu_reset_context *reset_context)
> > > > +{
> > > > +}
> > > > +#else
> > > >static ssize_t amdgpu_devcoredump_read(char *buffer, loff_t offset,
> > > > size_t count, void *data, size_t datalen)
> > > >{
> > > > struct drm_printer p;
> > > > -   st

Re: [PATCH 3/6] drm/amdgpu: Rework coredump to use memory dynamically

2023-07-12 Thread Lucas Stach
Sorry, accidentally hit sent on the previous mail.

Am Mittwoch, dem 12.07.2023 um 12:39 +0200 schrieb Christian König:
> Am 12.07.23 um 10:59 schrieb Lucas Stach:
> > Am Mittwoch, dem 12.07.2023 um 10:37 +0200 schrieb Christian König:
> > > Am 11.07.23 um 23:34 schrieb André Almeida:
> > > > Instead of storing coredump information inside amdgpu_device struct,
> > > > move if to a proper separated struct and allocate it dynamically. This
> > > > will make it easier to further expand the logged information.
> > > Verry big NAK to this. The problem is that memory allocation isn't
> > > allowed during a GPU reset.
> > > 
> > > What you could do is to allocate the memory with GFP_ATOMIC or similar,
> > > but for a large structure that might not be possible.
> > > 
> > I'm still not fully clear on what the rules are here. In etnaviv we do
> > devcoredump allocation in the GPU reset path with __GFP_NOWARN |
> > __GFP_NORETRY, which means the allocation will kick memory reclaim if
> > necessary, but will just give up if no memory could be made available
> > easily. This satisfies the forward progress guarantee in the absence of
> > successful memory allocation, which is the most important property in
> > this path, I think.
> > 
> > However, I'm not sure if the reclaim could lead to locking issues or
> > something like that with the more complex use-cases with MMU notifiers
> > and stuff like that. Christian, do you have any experience or
> > information that would be good to share in this regard?
> 
> Yeah, very good question.
> 
> __GFP_NORETRY isn't sufficient as far as I know. Reclaim must be 
> completely suppressed to be able to allocate in a GPU reset handler.
> 
> Daniel added lockdep annotation to some of the dma-fence signaling paths 
> and this yielded quite a bunch of potential deadlocks.
> 
> It's not even that reclaim itself waits for dma_fences (that can happen, 
> but is quite unlikely), but rather that reclaim needs locks and under 
> those locks we then wait for dma_fences.
> 
> We should probably add a define somewhere which documents that 
> (GFP_ATOMIC | __NO_WARN) should be used in the GPU reset handlers when 
> allocating memory for coredumps.
> 
Hm, if the problem is the direct reclaim path where we might recurse on
a lock through those indirect dependencies then we should document this
somewhere. kswapd reclaim should be fine as far as I can see, as we'll
guarantee progress without waiting for the background reclaim.

I don't think it's appropriate to dip into the atomic allocation
reserves for a best-effort thing like writing the devcoredump, so I
think this should be GFP_NOWAIT, which will also avoid the direct
reclaim path.

Regards,
Lucas

> Regards,
> Christian.
> 
> > 
> > Regards,
> > Lucas
> > 
> > > Regards,
> > > Christian.
> > > 
> > > > Signed-off-by: André Almeida 
> > > > ---
> > > >drivers/gpu/drm/amd/amdgpu/amdgpu.h| 14 +++--
> > > >drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 65 
> > > > ++
> > > >2 files changed, 51 insertions(+), 28 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
> > > > b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > > > index dbe062a087c5..e1cc83a89d46 100644
> > > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > > > @@ -1068,11 +1068,6 @@ struct amdgpu_device {
> > > > uint32_t*reset_dump_reg_list;
> > > > uint32_t*reset_dump_reg_value;
> > > > int num_regs;
> > > > -#ifdef CONFIG_DEV_COREDUMP
> > > > -   struct amdgpu_task_info reset_task_info;
> > > > -   boolreset_vram_lost;
> > > > -   struct timespec64   reset_time;
> > > > -#endif
> > > >
> > > > boolscpm_enabled;
> > > > uint32_tscpm_status;
> > > > @@ -1085,6 +1080,15 @@ struct amdgpu_device {
> > > > uint32_taid_mask;
> > > >};
> > > >
> > > > +#ifdef CONFIG_DEV_COREDUMP
> > > > +struct amdgpu_coredump_info {
> > > > +   struct amdgpu_device*adev;
> > > > +   struct amdgpu_task_info reset_task_info;
> > > > +   struct timespec64   reset_time;
> > > > +   boolreset_vram_lost;
> > > > +};
> > > > +#endif
> > > > +
> > > >static inline struct amdgpu_device *drm_to_adev(struct drm_device 
> > > > *ddev)
> > > >{
> > > > return container_of(ddev, struct amdgpu_device, ddev);
> > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
> > > > b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > > > index e25f085ee886..23b9784e9787 100644
> > > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > > > @@ -4963,12 +4963,17 @@ static int amdgpu_reset_reg_dumps(struct 
> > 

Re: [PATCH 3/6] drm/amdgpu: Rework coredump to use memory dynamically

2023-07-12 Thread Christian König

Am 12.07.23 um 12:56 schrieb Lucas Stach:

Sorry, accidentally hit sent on the previous mail.

Am Mittwoch, dem 12.07.2023 um 12:39 +0200 schrieb Christian König:

Am 12.07.23 um 10:59 schrieb Lucas Stach:

Am Mittwoch, dem 12.07.2023 um 10:37 +0200 schrieb Christian König:

Am 11.07.23 um 23:34 schrieb André Almeida:

Instead of storing coredump information inside amdgpu_device struct,
move if to a proper separated struct and allocate it dynamically. This
will make it easier to further expand the logged information.

Verry big NAK to this. The problem is that memory allocation isn't
allowed during a GPU reset.

What you could do is to allocate the memory with GFP_ATOMIC or similar,
but for a large structure that might not be possible.


I'm still not fully clear on what the rules are here. In etnaviv we do
devcoredump allocation in the GPU reset path with __GFP_NOWARN |
__GFP_NORETRY, which means the allocation will kick memory reclaim if
necessary, but will just give up if no memory could be made available
easily. This satisfies the forward progress guarantee in the absence of
successful memory allocation, which is the most important property in
this path, I think.

However, I'm not sure if the reclaim could lead to locking issues or
something like that with the more complex use-cases with MMU notifiers
and stuff like that. Christian, do you have any experience or
information that would be good to share in this regard?

Yeah, very good question.

__GFP_NORETRY isn't sufficient as far as I know. Reclaim must be
completely suppressed to be able to allocate in a GPU reset handler.

Daniel added lockdep annotation to some of the dma-fence signaling paths
and this yielded quite a bunch of potential deadlocks.

It's not even that reclaim itself waits for dma_fences (that can happen,
but is quite unlikely), but rather that reclaim needs locks and under
those locks we then wait for dma_fences.

We should probably add a define somewhere which documents that
(GFP_ATOMIC | __NO_WARN) should be used in the GPU reset handlers when
allocating memory for coredumps.


Hm, if the problem is the direct reclaim path where we might recurse on
a lock through those indirect dependencies then we should document this
somewhere. kswapd reclaim should be fine as far as I can see, as we'll
guarantee progress without waiting for the background reclaim.

I don't think it's appropriate to dip into the atomic allocation
reserves for a best-effort thing like writing the devcoredump,


Yeah, that was also my concern the last time we discussed this.


so I think this should be GFP_NOWAIT, which will also avoid the direct
reclaim path.


Yeah, good idea. I wasn't aware that this existed.

Regards,
Christian.



Regards,
Lucas


Regards,
Christian.


Regards,
Lucas


Regards,
Christian.


Signed-off-by: André Almeida 
---
drivers/gpu/drm/amd/amdgpu/amdgpu.h| 14 +++--
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 65 ++
2 files changed, 51 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index dbe062a087c5..e1cc83a89d46 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1068,11 +1068,6 @@ struct amdgpu_device {
uint32_t*reset_dump_reg_list;
uint32_t*reset_dump_reg_value;
int num_regs;
-#ifdef CONFIG_DEV_COREDUMP
-   struct amdgpu_task_info reset_task_info;
-   boolreset_vram_lost;
-   struct timespec64   reset_time;
-#endif

	boolscpm_enabled;

uint32_tscpm_status;
@@ -1085,6 +1080,15 @@ struct amdgpu_device {
uint32_taid_mask;
};

+#ifdef CONFIG_DEV_COREDUMP

+struct amdgpu_coredump_info {
+   struct amdgpu_device*adev;
+   struct amdgpu_task_info reset_task_info;
+   struct timespec64   reset_time;
+   boolreset_vram_lost;
+};
+#endif
+
static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev)
{
return container_of(ddev, struct amdgpu_device, ddev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index e25f085ee886..23b9784e9787 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -4963,12 +4963,17 @@ static int amdgpu_reset_reg_dumps(struct amdgpu_device 
*adev)
return 0;
}

-#ifdef CONFIG_DEV_COREDUMP

+#ifndef CONFIG_DEV_COREDUMP
+static void amdgpu_coredump(struct amdgpu_device *adev, bool vram_lost,
+   struct amdgpu_reset_context *reset_context)
+{
+}
+#else
static ssize_t amdgpu_devcoredump_read(char *buffer, loff_t offset,
size_t count, void *dat

[RFC v5 00/17] DRM cgroup controller with scheduling control and memory stats

2023-07-12 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

This series contains a proposal for a DRM cgroup controller which implements a
weight based hierarchical GPU usage budget based controller similar in concept
to some of the existing controllers and also exposes GPU memory usage as a read-
only field.

Motivation mostly comes from my earlier proposal where I identified that GPU
scheduling lags significantly behind what is available for CPU and IO. Whereas
back then I was proposing to somehow tie this with process nice, feedback mostly
was that people wanted cgroups. So here it is - in the world of heterogenous
computing pipelines I think it is time to do something about this gap.

Code is not finished but should survive some light experimenting with. I am
sharing it early since the topic has been controversial in the past. I hope to
demonstrate there are gains to be had in real world usage(*), today, and that
the concepts the proposal relies are well enough established and stable.

*) Specifically under ChromeOS which uses cgroups to control CPU bandwith for
   VMs based on the window focused status. It can be demonstrated how GPU
   scheduling control can easily be integrated into that setup.

*) Another real world example later in the cover letter.

There should be no conflict with this proposal and any efforts to implement
memory usage based controller. Skeleton DRM cgroup controller is deliberatly
purely a skeleton patch where any further functionality can be added with no
real conflicts. [In fact, perhaps scheduling is even easier to deal with than
memory accounting.]

Structure of the series is as follows:

  1-5) A separate/different series which adds fdinfo memory stats support to
   i915. This is only a pre-requisite for patches 16-17 so can be ignored in
   scope of this series.
6) Improve client ownership tracking in DRM core. Also a pre-requisite which
   can be ignored.
7) Adds a skeleton DRM cgroup controller with no functionality.
 8-11) Laying down some infrastructure to enable the controller.
   12) The scheduling controller itself.
13-14) i915 support for the scheduling controller.
   15) Expose GPU utilisation from the controller.
   16) Add memory stats plumbing and core logic to the controller.
   17) i915 support for controller memory stats.

The proposals defines a delegation of duties between the tree parties: cgroup
controller, DRM core and individual drivers. Two way communication interfaces
are then defined to enable the delegation to work.

DRM scheduling soft limits
~~

Because of the heterogenous hardware and driver DRM capabilities, soft limits
are implemented as a loose co-operative (bi-directional) interface between the
controller and DRM core.

The controller configures the GPU time allowed per group and periodically scans
the belonging tasks to detect the over budget condition, at which point it
invokes a callback notifying the DRM core of the condition.

DRM core provides an API to query per process GPU utilization and 2nd API to
receive notification from the cgroup controller when the group enters or exits
the over budget condition.

Individual DRM drivers which implement the interface are expected to act on this
in the best-effort manner only. There are no guarantees that the soft limits
will be respected.

DRM controller interface files
~~

  drm.active_us
GPU time used by the group recursively including all child groups.

  drm.weight
Standard cgroup weight based control [1, 1] used to configure the
relative distributing of GPU time between the sibling groups.

  drm.memory.stat
A nested file containing cumulative memory statistics for the whole
sub-hierarchy, broken down into separate GPUs and separate memory
regions supported by the latter.

For example::

  $ cat drm.memory.stat
  card0 region=system total=12898304 shared=0 active=0 
resident=12111872 purgeable=167936
  card0 region=stolen-system total=0 shared=0 active=0 resident=0 
purgeable=0

Card designation corresponds to the DRM device names and multiple line
entries can be present per card.

Memory region names should be expected to be driver specific with the
exception of 'system' which is standardised and applicable for GPUs
which can operate on system memory buffers.

Sub-keys 'resident' and 'purgeable' are optional.

Per category region usage is reported in bytes.

This builds upon the per client GPU utilisation work which landed recently for a
few drivers. My thinking is that in principle, an intersect of drivers which
support both that and some sort of scheduling control, like  priorities, could
also in theory support this controller.

Another really interesting angle for this controller is that it mimics the same
control menthod used by the CPU scheduler. That is the proportional/weight based
GPU time budgeting. Which m

[PATCH 01/17] drm/i915: Add ability for tracking buffer objects per client

2023-07-12 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

In order to show per client memory usage lets add some infrastructure
which enables tracking buffer objects owned by clients.

We add a per client list protected by a new per client lock and to support
delayed destruction (post client exit) we make tracked objects hold
references to the owning client.

Also, object memory region teardown is moved to the existing RCU free
callback to allow safe dereference from the fdinfo RCU read section.

Signed-off-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/gem/i915_gem_object.c| 13 +--
 .../gpu/drm/i915/gem/i915_gem_object_types.h  | 12 +++
 drivers/gpu/drm/i915/i915_drm_client.c| 36 +++
 drivers/gpu/drm/i915/i915_drm_client.h| 32 +
 4 files changed, 90 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.c 
b/drivers/gpu/drm/i915/gem/i915_gem_object.c
index 97ac6fb37958..3dc4fbb67d2b 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.c
@@ -105,6 +105,10 @@ void i915_gem_object_init(struct drm_i915_gem_object *obj,
 
INIT_LIST_HEAD(&obj->mm.link);
 
+#ifdef CONFIG_PROC_FS
+   INIT_LIST_HEAD(&obj->client_link);
+#endif
+
INIT_LIST_HEAD(&obj->lut_list);
spin_lock_init(&obj->lut_lock);
 
@@ -292,6 +296,10 @@ void __i915_gem_free_object_rcu(struct rcu_head *head)
container_of(head, typeof(*obj), rcu);
struct drm_i915_private *i915 = to_i915(obj->base.dev);
 
+   /* We need to keep this alive for RCU read access from fdinfo. */
+   if (obj->mm.n_placements > 1)
+   kfree(obj->mm.placements);
+
i915_gem_object_free(obj);
 
GEM_BUG_ON(!atomic_read(&i915->mm.free_count));
@@ -388,9 +396,6 @@ void __i915_gem_free_object(struct drm_i915_gem_object *obj)
if (obj->ops->release)
obj->ops->release(obj);
 
-   if (obj->mm.n_placements > 1)
-   kfree(obj->mm.placements);
-
if (obj->shares_resv_from)
i915_vm_resv_put(obj->shares_resv_from);
 
@@ -441,6 +446,8 @@ static void i915_gem_free_object(struct drm_gem_object 
*gem_obj)
 
GEM_BUG_ON(i915_gem_object_is_framebuffer(obj));
 
+   i915_drm_client_remove_object(obj);
+
/*
 * Before we free the object, make sure any pure RCU-only
 * read-side critical sections are complete, e.g.
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h 
b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
index e72c57716bee..8de2b91b3edf 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
@@ -300,6 +300,18 @@ struct drm_i915_gem_object {
 */
struct i915_address_space *shares_resv_from;
 
+#ifdef CONFIG_PROC_FS
+   /**
+* @client: @i915_drm_client which created the object
+*/
+   struct i915_drm_client *client;
+
+   /**
+* @client_link: Link into @i915_drm_client.objects_list
+*/
+   struct list_head client_link;
+#endif
+
union {
struct rcu_head rcu;
struct llist_node freed;
diff --git a/drivers/gpu/drm/i915/i915_drm_client.c 
b/drivers/gpu/drm/i915/i915_drm_client.c
index 2a44b3876cb5..2e5e69edc0f9 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.c
+++ b/drivers/gpu/drm/i915/i915_drm_client.c
@@ -28,6 +28,10 @@ struct i915_drm_client *i915_drm_client_alloc(void)
kref_init(&client->kref);
spin_lock_init(&client->ctx_lock);
INIT_LIST_HEAD(&client->ctx_list);
+#ifdef CONFIG_PROC_FS
+   spin_lock_init(&client->objects_lock);
+   INIT_LIST_HEAD(&client->objects_list);
+#endif
 
return client;
 }
@@ -108,4 +112,36 @@ void i915_drm_client_fdinfo(struct drm_printer *p, struct 
drm_file *file)
for (i = 0; i < ARRAY_SIZE(uabi_class_names); i++)
show_client_class(p, i915, file_priv->client, i);
 }
+
+void i915_drm_client_add_object(struct i915_drm_client *client,
+   struct drm_i915_gem_object *obj)
+{
+   unsigned long flags;
+
+   GEM_WARN_ON(obj->client);
+   GEM_WARN_ON(!list_empty(&obj->client_link));
+
+   spin_lock_irqsave(&client->objects_lock, flags);
+   obj->client = i915_drm_client_get(client);
+   list_add_tail_rcu(&obj->client_link, &client->objects_list);
+   spin_unlock_irqrestore(&client->objects_lock, flags);
+}
+
+bool i915_drm_client_remove_object(struct drm_i915_gem_object *obj)
+{
+   struct i915_drm_client *client = fetch_and_zero(&obj->client);
+   unsigned long flags;
+
+   /* Object may not be associated with a client. */
+   if (!client)
+   return false;
+
+   spin_lock_irqsave(&client->objects_lock, flags);
+   list_del_rcu(&obj->client_link);
+   spin_unlock_irqrestore(&client->objects_lock, flags);
+
+   i915_drm_client_put(client);
+
+   return t

[PATCH 04/17] drm/i915: Account ring buffer and context state storage

2023-07-12 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Account ring buffers and logical context space against the owning client
memory usage stats.

Signed-off-by: Tvrtko Ursulin 
Reviewed-by: Aravind Iddamsetty 
---
 drivers/gpu/drm/i915/gt/intel_context.c | 14 ++
 drivers/gpu/drm/i915/i915_drm_client.c  | 10 ++
 drivers/gpu/drm/i915/i915_drm_client.h  |  9 +
 3 files changed, 33 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/intel_context.c 
b/drivers/gpu/drm/i915/gt/intel_context.c
index a53b26178f0a..a2f1245741bb 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.c
+++ b/drivers/gpu/drm/i915/gt/intel_context.c
@@ -6,6 +6,7 @@
 #include "gem/i915_gem_context.h"
 #include "gem/i915_gem_pm.h"
 
+#include "i915_drm_client.h"
 #include "i915_drv.h"
 #include "i915_trace.h"
 
@@ -50,6 +51,7 @@ intel_context_create(struct intel_engine_cs *engine)
 
 int intel_context_alloc_state(struct intel_context *ce)
 {
+   struct i915_gem_context *ctx;
int err = 0;
 
if (mutex_lock_interruptible(&ce->pin_mutex))
@@ -66,6 +68,18 @@ int intel_context_alloc_state(struct intel_context *ce)
goto unlock;
 
set_bit(CONTEXT_ALLOC_BIT, &ce->flags);
+
+   rcu_read_lock();
+   ctx = rcu_dereference(ce->gem_context);
+   if (ctx && !kref_get_unless_zero(&ctx->ref))
+   ctx = NULL;
+   rcu_read_unlock();
+   if (ctx) {
+   if (ctx->client)
+   i915_drm_client_add_context_objects(ctx->client,
+   ce);
+   i915_gem_context_put(ctx);
+   }
}
 
 unlock:
diff --git a/drivers/gpu/drm/i915/i915_drm_client.c 
b/drivers/gpu/drm/i915/i915_drm_client.c
index 2e5e69edc0f9..a61356012df8 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.c
+++ b/drivers/gpu/drm/i915/i915_drm_client.c
@@ -144,4 +144,14 @@ bool i915_drm_client_remove_object(struct 
drm_i915_gem_object *obj)
 
return true;
 }
+
+void i915_drm_client_add_context_objects(struct i915_drm_client *client,
+struct intel_context *ce)
+{
+   if (ce->state)
+   i915_drm_client_add_object(client, ce->state->obj);
+
+   if (ce->ring != ce->engine->legacy.ring && ce->ring->vma)
+   i915_drm_client_add_object(client, ce->ring->vma->obj);
+}
 #endif
diff --git a/drivers/gpu/drm/i915/i915_drm_client.h 
b/drivers/gpu/drm/i915/i915_drm_client.h
index 5f58fdf7dcb8..69cedfcd3d69 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.h
+++ b/drivers/gpu/drm/i915/i915_drm_client.h
@@ -14,6 +14,7 @@
 
 #include "i915_file_private.h"
 #include "gem/i915_gem_object_types.h"
+#include "gt/intel_context_types.h"
 
 #define I915_LAST_UABI_ENGINE_CLASS I915_ENGINE_CLASS_COMPUTE
 
@@ -70,6 +71,8 @@ void i915_drm_client_fdinfo(struct drm_printer *p, struct 
drm_file *file);
 void i915_drm_client_add_object(struct i915_drm_client *client,
struct drm_i915_gem_object *obj);
 bool i915_drm_client_remove_object(struct drm_i915_gem_object *obj);
+void i915_drm_client_add_context_objects(struct i915_drm_client *client,
+struct intel_context *ce);
 #else
 static inline void i915_drm_client_add_object(struct i915_drm_client *client,
  struct drm_i915_gem_object *obj)
@@ -79,6 +82,12 @@ static inline void i915_drm_client_add_object(struct 
i915_drm_client *client,
 static inline bool i915_drm_client_remove_object(struct drm_i915_gem_object 
*obj)
 {
 }
+
+static inline void
+i915_drm_client_add_context_objects(struct i915_drm_client *client,
+   struct intel_context *ce)
+{
+}
 #endif
 
 #endif /* !__I915_DRM_CLIENT_H__ */
-- 
2.39.2



[PATCH 03/17] drm/i915: Track page table backing store usage

2023-07-12 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Account page table backing store against the owning client memory usage
stats.

Signed-off-by: Tvrtko Ursulin 
Reviewed-by: Aravind Iddamsetty 
---
 drivers/gpu/drm/i915/gt/intel_gtt.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/intel_gtt.c 
b/drivers/gpu/drm/i915/gt/intel_gtt.c
index 731d9f2bbc56..065099362a98 100644
--- a/drivers/gpu/drm/i915/gt/intel_gtt.c
+++ b/drivers/gpu/drm/i915/gt/intel_gtt.c
@@ -58,6 +58,9 @@ struct drm_i915_gem_object *alloc_pt_lmem(struct 
i915_address_space *vm, int sz)
if (!IS_ERR(obj)) {
obj->base.resv = i915_vm_resv_get(vm);
obj->shares_resv_from = vm;
+
+   if (vm->fpriv)
+   i915_drm_client_add_object(vm->fpriv->client, obj);
}
 
return obj;
@@ -79,6 +82,9 @@ struct drm_i915_gem_object *alloc_pt_dma(struct 
i915_address_space *vm, int sz)
if (!IS_ERR(obj)) {
obj->base.resv = i915_vm_resv_get(vm);
obj->shares_resv_from = vm;
+
+   if (vm->fpriv)
+   i915_drm_client_add_object(vm->fpriv->client, obj);
}
 
return obj;
-- 
2.39.2



[PATCH 05/17] drm/i915: Implement fdinfo memory stats printing

2023-07-12 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Use the newly added drm_print_memory_stats helper to show memory
utilisation of our objects in drm/driver specific fdinfo output.

To collect the stats we walk the per memory regions object lists
and accumulate object size into the respective drm_memory_stats
categories.

Objects with multiple possible placements are reported in multiple
regions for total and shared sizes, while other categories are
counted only for the currently active region.

Signed-off-by: Tvrtko Ursulin 
Cc: Aravind Iddamsetty 
Cc: Rob Clark 
---
 drivers/gpu/drm/i915/i915_drm_client.c | 85 ++
 1 file changed, 85 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_drm_client.c 
b/drivers/gpu/drm/i915/i915_drm_client.c
index a61356012df8..9e7a6075ee25 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.c
+++ b/drivers/gpu/drm/i915/i915_drm_client.c
@@ -45,6 +45,89 @@ void __i915_drm_client_free(struct kref *kref)
 }
 
 #ifdef CONFIG_PROC_FS
+static void
+obj_meminfo(struct drm_i915_gem_object *obj,
+   struct drm_memory_stats stats[INTEL_REGION_UNKNOWN])
+{
+   struct intel_memory_region *mr;
+   u64 sz = obj->base.size;
+   enum intel_region_id id;
+   unsigned int i;
+
+   /* Attribute size and shared to all possible memory regions. */
+   for (i = 0; i < obj->mm.n_placements; i++) {
+   mr = obj->mm.placements[i];
+   id = mr->id;
+
+   if (obj->base.handle_count > 1)
+   stats[id].shared += sz;
+   else
+   stats[id].private += sz;
+   }
+
+   /* Attribute other categories to only the current region. */
+   mr = obj->mm.region;
+   if (mr)
+   id = mr->id;
+   else
+   id = INTEL_REGION_SMEM;
+
+   if (!obj->mm.n_placements) {
+   if (obj->base.handle_count > 1)
+   stats[id].shared += sz;
+   else
+   stats[id].private += sz;
+   }
+
+   if (i915_gem_object_has_pages(obj)) {
+   stats[id].resident += sz;
+
+   if (!dma_resv_test_signaled(obj->base.resv,
+   dma_resv_usage_rw(true)))
+   stats[id].active += sz;
+   else if (i915_gem_object_is_shrinkable(obj) &&
+obj->mm.madv == I915_MADV_DONTNEED)
+   stats[id].purgeable += sz;
+   }
+}
+
+static void show_meminfo(struct drm_printer *p, struct drm_file *file)
+{
+   struct drm_memory_stats stats[INTEL_REGION_UNKNOWN] = {};
+   struct drm_i915_file_private *fpriv = file->driver_priv;
+   struct i915_drm_client *client = fpriv->client;
+   struct drm_i915_private *i915 = fpriv->i915;
+   struct drm_i915_gem_object *obj;
+   struct intel_memory_region *mr;
+   struct list_head *pos;
+   unsigned int id;
+
+   /* Public objects. */
+   spin_lock(&file->table_lock);
+   idr_for_each_entry(&file->object_idr, obj, id)
+   obj_meminfo(obj, stats);
+   spin_unlock(&file->table_lock);
+
+   /* Internal objects. */
+   rcu_read_lock();
+   list_for_each_rcu(pos, &client->objects_list) {
+   obj = i915_gem_object_get_rcu(list_entry(pos, typeof(*obj),
+client_link));
+   if (!obj)
+   continue;
+   obj_meminfo(obj, stats);
+   i915_gem_object_put(obj);
+   }
+   rcu_read_unlock();
+
+   for_each_memory_region(mr, i915, id)
+   drm_print_memory_stats(p,
+  &stats[id],
+  DRM_GEM_OBJECT_RESIDENT |
+  DRM_GEM_OBJECT_PURGEABLE,
+  mr->name);
+}
+
 static const char * const uabi_class_names[] = {
[I915_ENGINE_CLASS_RENDER] = "render",
[I915_ENGINE_CLASS_COPY] = "copy",
@@ -106,6 +189,8 @@ void i915_drm_client_fdinfo(struct drm_printer *p, struct 
drm_file *file)
 * **
 */
 
+   show_meminfo(p, file);
+
if (GRAPHICS_VER(i915) < 8)
return;
 
-- 
2.39.2



[PATCH 06/17] drm: Update file owner during use

2023-07-12 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

With the typical model where the display server opens the file descriptor
and then hands it over to the client(*), we were showing stale data in
debugfs.

Fix it by updating the drm_file->pid on ioctl access from a different
process.

The field is also made RCU protected to allow for lockless readers. Update
side is protected with dev->filelist_mutex.

Before:

$ cat /sys/kernel/debug/dri/0/clients
 command   pid dev master a   uid  magic
Xorg  2344   0   yy 0  0
Xorg  2344   0   ny 0  2
Xorg  2344   0   ny 0  3
Xorg  2344   0   ny 0  4

After:

$ cat /sys/kernel/debug/dri/0/clients
 command  tgid dev master a   uid  magic
Xorg   830   0   yy 0  0
   xfce4-session   880   0   ny 0  1
   xfwm4   943   0   ny 0  2
   neverball  1095   0   ny 0  3

*)
More detailed and historically accurate description of various handover
implementation kindly provided by Emil Velikov:

"""
The traditional model, the server was the orchestrator managing the
primary device node. From the fd, to the master status and
authentication. But looking at the fd alone, this has varied across
the years.

IIRC in the DRI1 days, Xorg (libdrm really) would have a list of open
fd(s) and reuse those whenever needed, DRI2 the client was responsible
for open() themselves and with DRI3 the fd was passed to the client.

Around the inception of DRI3 and systemd-logind, the latter became
another possible orchestrator. Whereby Xorg and Wayland compositors
could ask it for the fd. For various reasons (hysterical and genuine
ones) Xorg has a fallback path going the open(), whereas Wayland
compositors are moving to solely relying on logind... some never had
fallback even.

Over the past few years, more projects have emerged which provide
functionality similar (be that on API level, Dbus, or otherwise) to
systemd-logind.
"""

v2:
 * Fixed typo in commit text and added a fine historical explanation
   from Emil.

Signed-off-by: Tvrtko Ursulin 
Cc: "Christian König" 
Cc: Daniel Vetter 
Acked-by: Christian König 
Reviewed-by: Emil Velikov 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c |  6 ++--
 drivers/gpu/drm/drm_auth.c  |  3 +-
 drivers/gpu/drm/drm_debugfs.c   | 10 ---
 drivers/gpu/drm/drm_file.c  | 40 +++--
 drivers/gpu/drm/drm_ioctl.c |  3 ++
 drivers/gpu/drm/nouveau/nouveau_drm.c   |  5 +++-
 drivers/gpu/drm/vmwgfx/vmwgfx_gem.c |  6 ++--
 include/drm/drm_file.h  | 13 ++--
 8 files changed, 71 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 74055cba3dc9..849097dff02b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -963,6 +963,7 @@ static int amdgpu_debugfs_gem_info_show(struct seq_file *m, 
void *unused)
list_for_each_entry(file, &dev->filelist, lhead) {
struct task_struct *task;
struct drm_gem_object *gobj;
+   struct pid *pid;
int id;
 
/*
@@ -972,8 +973,9 @@ static int amdgpu_debugfs_gem_info_show(struct seq_file *m, 
void *unused)
 * Therefore, we need to protect this ->comm access using RCU.
 */
rcu_read_lock();
-   task = pid_task(file->pid, PIDTYPE_TGID);
-   seq_printf(m, "pid %8d command %s:\n", pid_nr(file->pid),
+   pid = rcu_dereference(file->pid);
+   task = pid_task(pid, PIDTYPE_TGID);
+   seq_printf(m, "pid %8d command %s:\n", pid_nr(pid),
   task ? task->comm : "");
rcu_read_unlock();
 
diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
index cf92a9ae8034..2ed2585ded37 100644
--- a/drivers/gpu/drm/drm_auth.c
+++ b/drivers/gpu/drm/drm_auth.c
@@ -235,7 +235,8 @@ static int drm_new_set_master(struct drm_device *dev, 
struct drm_file *fpriv)
 static int
 drm_master_check_perm(struct drm_device *dev, struct drm_file *file_priv)
 {
-   if (file_priv->pid == task_pid(current) && file_priv->was_master)
+   if (file_priv->was_master &&
+   rcu_access_pointer(file_priv->pid) == task_pid(current))
return 0;
 
if (!capable(CAP_SYS_ADMIN))
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index 4855230ba2c6..b46f5ceb24c6 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -90,15 +90,17 @@ static int drm_clients_info(struct seq_file *m, void *data)
 */
mutex_lock(&dev->filelist_mutex);
list_for_each_entry_reverse(priv, &dev->filelist, lhead) {
-   struct task_struct 

[PATCH 02/17] drm/i915: Record which client owns a VM

2023-07-12 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

To enable accounting of indirect client memory usage (such as page tables)
in the following patch, lets start recording the creator of each PPGTT.

Signed-off-by: Tvrtko Ursulin 
Reviewed-by: Aravind Iddamsetty 
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c   | 11 ---
 drivers/gpu/drm/i915/gem/i915_gem_context_types.h |  3 +++
 drivers/gpu/drm/i915/gem/selftests/mock_context.c |  4 ++--
 drivers/gpu/drm/i915/gt/intel_gtt.h   |  1 +
 4 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c 
b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index 9a9ff84c90d7..35cf6608180e 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -279,7 +279,8 @@ static int proto_context_set_protected(struct 
drm_i915_private *i915,
 }
 
 static struct i915_gem_proto_context *
-proto_context_create(struct drm_i915_private *i915, unsigned int flags)
+proto_context_create(struct drm_i915_file_private *fpriv,
+struct drm_i915_private *i915, unsigned int flags)
 {
struct i915_gem_proto_context *pc, *err;
 
@@ -287,6 +288,7 @@ proto_context_create(struct drm_i915_private *i915, 
unsigned int flags)
if (!pc)
return ERR_PTR(-ENOMEM);
 
+   pc->fpriv = fpriv;
pc->num_user_engines = -1;
pc->user_engines = NULL;
pc->user_flags = BIT(UCONTEXT_BANNABLE) |
@@ -1621,6 +1623,7 @@ i915_gem_create_context(struct drm_i915_private *i915,
err = PTR_ERR(ppgtt);
goto err_ctx;
}
+   ppgtt->vm.fpriv = pc->fpriv;
vm = &ppgtt->vm;
}
if (vm)
@@ -1740,7 +1743,7 @@ int i915_gem_context_open(struct drm_i915_private *i915,
/* 0 reserved for invalid/unassigned ppgtt */
xa_init_flags(&file_priv->vm_xa, XA_FLAGS_ALLOC1);
 
-   pc = proto_context_create(i915, 0);
+   pc = proto_context_create(file_priv, i915, 0);
if (IS_ERR(pc)) {
err = PTR_ERR(pc);
goto err;
@@ -1822,6 +1825,7 @@ int i915_gem_vm_create_ioctl(struct drm_device *dev, void 
*data,
 
GEM_BUG_ON(id == 0); /* reserved for invalid/unassigned ppgtt */
args->vm_id = id;
+   ppgtt->vm.fpriv = file_priv;
return 0;
 
 err_put:
@@ -2284,7 +2288,8 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, 
void *data,
return -EIO;
}
 
-   ext_data.pc = proto_context_create(i915, args->flags);
+   ext_data.pc = proto_context_create(file->driver_priv, i915,
+  args->flags);
if (IS_ERR(ext_data.pc))
return PTR_ERR(ext_data.pc);
 
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h 
b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
index cb78214a7dcd..c573c067779f 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
@@ -188,6 +188,9 @@ struct i915_gem_proto_engine {
  * CONTEXT_CREATE_SET_PARAM during GEM_CONTEXT_CREATE.
  */
 struct i915_gem_proto_context {
+   /** @fpriv: Client which creates the context */
+   struct drm_i915_file_private *fpriv;
+
/** @vm: See &i915_gem_context.vm */
struct i915_address_space *vm;
 
diff --git a/drivers/gpu/drm/i915/gem/selftests/mock_context.c 
b/drivers/gpu/drm/i915/gem/selftests/mock_context.c
index 8ac6726ec16b..125584ada282 100644
--- a/drivers/gpu/drm/i915/gem/selftests/mock_context.c
+++ b/drivers/gpu/drm/i915/gem/selftests/mock_context.c
@@ -83,7 +83,7 @@ live_context(struct drm_i915_private *i915, struct file *file)
int err;
u32 id;
 
-   pc = proto_context_create(i915, 0);
+   pc = proto_context_create(fpriv, i915, 0);
if (IS_ERR(pc))
return ERR_CAST(pc);
 
@@ -152,7 +152,7 @@ kernel_context(struct drm_i915_private *i915,
struct i915_gem_context *ctx;
struct i915_gem_proto_context *pc;
 
-   pc = proto_context_create(i915, 0);
+   pc = proto_context_create(NULL, i915, 0);
if (IS_ERR(pc))
return ERR_CAST(pc);
 
diff --git a/drivers/gpu/drm/i915/gt/intel_gtt.h 
b/drivers/gpu/drm/i915/gt/intel_gtt.h
index 4d6296cdbcfd..7192a534a654 100644
--- a/drivers/gpu/drm/i915/gt/intel_gtt.h
+++ b/drivers/gpu/drm/i915/gt/intel_gtt.h
@@ -248,6 +248,7 @@ struct i915_address_space {
struct drm_mm mm;
struct intel_gt *gt;
struct drm_i915_private *i915;
+   struct drm_i915_file_private *fpriv;
struct device *dma;
u64 total;  /* size addr space maps (ex. 2GB for ggtt) */
u64 reserved;   /* size addr space reserved */
-- 
2.39.2



[PATCH 07/17] cgroup: Add the DRM cgroup controller

2023-07-12 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Skeleton controller without any functionality.

Signed-off-by: Tvrtko Ursulin 
---
 include/linux/cgroup_drm.h|  9 ++
 include/linux/cgroup_subsys.h |  4 +++
 init/Kconfig  |  7 
 kernel/cgroup/Makefile|  1 +
 kernel/cgroup/drm.c   | 60 +++
 5 files changed, 81 insertions(+)
 create mode 100644 include/linux/cgroup_drm.h
 create mode 100644 kernel/cgroup/drm.c

diff --git a/include/linux/cgroup_drm.h b/include/linux/cgroup_drm.h
new file mode 100644
index ..8ef66a47619f
--- /dev/null
+++ b/include/linux/cgroup_drm.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#ifndef _CGROUP_DRM_H
+#define _CGROUP_DRM_H
+
+#endif /* _CGROUP_DRM_H */
diff --git a/include/linux/cgroup_subsys.h b/include/linux/cgroup_subsys.h
index 445235487230..49460494a010 100644
--- a/include/linux/cgroup_subsys.h
+++ b/include/linux/cgroup_subsys.h
@@ -65,6 +65,10 @@ SUBSYS(rdma)
 SUBSYS(misc)
 #endif
 
+#if IS_ENABLED(CONFIG_CGROUP_DRM)
+SUBSYS(drm)
+#endif
+
 /*
  * The following subsystems are not supported on the default hierarchy.
  */
diff --git a/init/Kconfig b/init/Kconfig
index f7f65af4ee12..485cff856c0b 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1065,6 +1065,13 @@ config CGROUP_RDMA
  Attaching processes with active RDMA resources to the cgroup
  hierarchy is allowed even if can cross the hierarchy's limit.
 
+config CGROUP_DRM
+   bool "DRM controller"
+   help
+ Provides the DRM subsystem controller.
+
+ ...
+
 config CGROUP_FREEZER
bool "Freezer controller"
help
diff --git a/kernel/cgroup/Makefile b/kernel/cgroup/Makefile
index 12f8457ad1f9..849bd2917477 100644
--- a/kernel/cgroup/Makefile
+++ b/kernel/cgroup/Makefile
@@ -6,4 +6,5 @@ obj-$(CONFIG_CGROUP_PIDS) += pids.o
 obj-$(CONFIG_CGROUP_RDMA) += rdma.o
 obj-$(CONFIG_CPUSETS) += cpuset.o
 obj-$(CONFIG_CGROUP_MISC) += misc.o
+obj-$(CONFIG_CGROUP_DRM) += drm.o
 obj-$(CONFIG_CGROUP_DEBUG) += debug.o
diff --git a/kernel/cgroup/drm.c b/kernel/cgroup/drm.c
new file mode 100644
index ..02c8eaa633d3
--- /dev/null
+++ b/kernel/cgroup/drm.c
@@ -0,0 +1,60 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#include 
+#include 
+#include 
+
+struct drm_cgroup_state {
+   struct cgroup_subsys_state css;
+};
+
+struct drm_root_cgroup_state {
+   struct drm_cgroup_state drmcs;
+};
+
+static struct drm_root_cgroup_state root_drmcs;
+
+static inline struct drm_cgroup_state *
+css_to_drmcs(struct cgroup_subsys_state *css)
+{
+   return container_of(css, struct drm_cgroup_state, css);
+}
+
+static void drmcs_free(struct cgroup_subsys_state *css)
+{
+   struct drm_cgroup_state *drmcs = css_to_drmcs(css);
+
+   if (drmcs != &root_drmcs.drmcs)
+   kfree(drmcs);
+}
+
+static struct cgroup_subsys_state *
+drmcs_alloc(struct cgroup_subsys_state *parent_css)
+{
+   struct drm_cgroup_state *drmcs;
+
+   if (!parent_css) {
+   drmcs = &root_drmcs.drmcs;
+   } else {
+   drmcs = kzalloc(sizeof(*drmcs), GFP_KERNEL);
+   if (!drmcs)
+   return ERR_PTR(-ENOMEM);
+   }
+
+   return &drmcs->css;
+}
+
+struct cftype files[] = {
+   { } /* Zero entry terminates. */
+};
+
+struct cgroup_subsys drm_cgrp_subsys = {
+   .css_alloc  = drmcs_alloc,
+   .css_free   = drmcs_free,
+   .early_init = false,
+   .legacy_cftypes = files,
+   .dfl_cftypes= files,
+};
-- 
2.39.2



[PATCH 08/17] drm/cgroup: Track DRM clients per cgroup

2023-07-12 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

To enable propagation of settings from the cgroup DRM controller to DRM
and vice-versa, we need to start tracking to which cgroups DRM clients
belong.

Signed-off-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/drm_file.c |  6 
 include/drm/drm_file.h |  6 
 include/linux/cgroup_drm.h | 20 
 kernel/cgroup/drm.c| 62 +-
 4 files changed, 93 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index e692770ef6d3..794ffb487472 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -32,6 +32,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -304,6 +305,8 @@ static void drm_close_helper(struct file *filp)
list_del(&file_priv->lhead);
mutex_unlock(&dev->filelist_mutex);
 
+   drmcgroup_client_close(file_priv);
+
drm_file_free(file_priv);
 }
 
@@ -367,6 +370,8 @@ int drm_open_helper(struct file *filp, struct drm_minor 
*minor)
list_add(&priv->lhead, &dev->filelist);
mutex_unlock(&dev->filelist_mutex);
 
+   drmcgroup_client_open(priv);
+
 #ifdef CONFIG_DRM_LEGACY
 #ifdef __alpha__
/*
@@ -533,6 +538,7 @@ void drm_file_update_pid(struct drm_file *filp)
mutex_unlock(&dev->filelist_mutex);
 
if (pid != old) {
+   drmcgroup_client_migrate(filp);
get_pid(pid);
synchronize_rcu();
put_pid(old);
diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
index c76249d5467e..e8fb3a39d482 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -30,6 +30,7 @@
 #ifndef _DRM_FILE_H_
 #define _DRM_FILE_H_
 
+#include 
 #include 
 #include 
 #include 
@@ -283,6 +284,11 @@ struct drm_file {
/** @minor: &struct drm_minor for this file. */
struct drm_minor *minor;
 
+#if IS_ENABLED(CONFIG_CGROUP_DRM)
+   struct cgroup_subsys_state *__css;
+   struct list_head clink;
+#endif
+
/**
 * @object_idr:
 *
diff --git a/include/linux/cgroup_drm.h b/include/linux/cgroup_drm.h
index 8ef66a47619f..176431842d8e 100644
--- a/include/linux/cgroup_drm.h
+++ b/include/linux/cgroup_drm.h
@@ -6,4 +6,24 @@
 #ifndef _CGROUP_DRM_H
 #define _CGROUP_DRM_H
 
+#include 
+
+#if IS_ENABLED(CONFIG_CGROUP_DRM)
+void drmcgroup_client_open(struct drm_file *file_priv);
+void drmcgroup_client_close(struct drm_file *file_priv);
+void drmcgroup_client_migrate(struct drm_file *file_priv);
+#else
+static inline void drmcgroup_client_open(struct drm_file *file_priv)
+{
+}
+
+static inline void drmcgroup_client_close(struct drm_file *file_priv)
+{
+}
+
+static void drmcgroup_client_migrate(struct drm_file *file_priv)
+{
+}
+#endif
+
 #endif /* _CGROUP_DRM_H */
diff --git a/kernel/cgroup/drm.c b/kernel/cgroup/drm.c
index 02c8eaa633d3..d702be1b441f 100644
--- a/kernel/cgroup/drm.c
+++ b/kernel/cgroup/drm.c
@@ -5,17 +5,25 @@
 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 struct drm_cgroup_state {
struct cgroup_subsys_state css;
+
+   struct list_head clients;
 };
 
 struct drm_root_cgroup_state {
struct drm_cgroup_state drmcs;
 };
 
-static struct drm_root_cgroup_state root_drmcs;
+static struct drm_root_cgroup_state root_drmcs = {
+   .drmcs.clients = LIST_HEAD_INIT(root_drmcs.drmcs.clients),
+};
+
+static DEFINE_MUTEX(drmcg_mutex);
 
 static inline struct drm_cgroup_state *
 css_to_drmcs(struct cgroup_subsys_state *css)
@@ -42,11 +50,63 @@ drmcs_alloc(struct cgroup_subsys_state *parent_css)
drmcs = kzalloc(sizeof(*drmcs), GFP_KERNEL);
if (!drmcs)
return ERR_PTR(-ENOMEM);
+
+   INIT_LIST_HEAD(&drmcs->clients);
}
 
return &drmcs->css;
 }
 
+void drmcgroup_client_open(struct drm_file *file_priv)
+{
+   struct drm_cgroup_state *drmcs;
+
+   drmcs = css_to_drmcs(task_get_css(current, drm_cgrp_id));
+
+   mutex_lock(&drmcg_mutex);
+   file_priv->__css = &drmcs->css; /* Keeps the reference. */
+   list_add_tail(&file_priv->clink, &drmcs->clients);
+   mutex_unlock(&drmcg_mutex);
+}
+EXPORT_SYMBOL_GPL(drmcgroup_client_open);
+
+void drmcgroup_client_close(struct drm_file *file_priv)
+{
+   struct drm_cgroup_state *drmcs;
+
+   drmcs = css_to_drmcs(file_priv->__css);
+
+   mutex_lock(&drmcg_mutex);
+   list_del(&file_priv->clink);
+   file_priv->__css = NULL;
+   mutex_unlock(&drmcg_mutex);
+
+   css_put(&drmcs->css);
+}
+EXPORT_SYMBOL_GPL(drmcgroup_client_close);
+
+void drmcgroup_client_migrate(struct drm_file *file_priv)
+{
+   struct drm_cgroup_state *src, *dst;
+   struct cgroup_subsys_state *old;
+
+   mutex_lock(&drmcg_mutex);
+
+   old = file_priv->__css;
+   src = css_to_drmcs(old);
+   dst = css_to_drmcs(task_get_css(current, drm_cgrp_id));
+
+   if (src != dst) {
+   file_priv->__css = &dst->css; /* Keeps

[PATCH 09/17] drm/cgroup: Add ability to query drm cgroup GPU time

2023-07-12 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Add a driver callback and core helper which allow querying the time spent
on GPUs for processes belonging to a group.

Signed-off-by: Tvrtko Ursulin 
---
 include/drm/drm_drv.h | 28 
 kernel/cgroup/drm.c   | 20 
 2 files changed, 48 insertions(+)

diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index b77f2c7275b7..3116fa4dbc48 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -151,6 +151,24 @@ enum drm_driver_feature {
DRIVER_HAVE_IRQ = BIT(30),
 };
 
+/**
+ * struct drm_cgroup_ops
+ *
+ * This structure contains a number of callbacks that drivers can provide if
+ * they are able to support one or more of the functionalities implemented by
+ * the DRM cgroup controller.
+ */
+struct drm_cgroup_ops {
+   /**
+* @active_time_us:
+*
+* Optional callback for reporting the GPU time consumed by this client.
+*
+* Used by the DRM core when queried by the DRM cgroup controller.
+*/
+   u64 (*active_time_us) (struct drm_file *);
+};
+
 /**
  * struct drm_driver - DRM driver structure
  *
@@ -428,6 +446,16 @@ struct drm_driver {
 */
const struct file_operations *fops;
 
+#ifdef CONFIG_CGROUP_DRM
+   /**
+* @cg_ops:
+*
+* Optional pointer to driver callbacks facilitating integration with
+* the DRM cgroup controller.
+*/
+   const struct drm_cgroup_ops *cg_ops;
+#endif
+
 #ifdef CONFIG_DRM_LEGACY
/* Everything below here is for legacy driver, never use! */
/* private: */
diff --git a/kernel/cgroup/drm.c b/kernel/cgroup/drm.c
index d702be1b441f..acdb76635b60 100644
--- a/kernel/cgroup/drm.c
+++ b/kernel/cgroup/drm.c
@@ -9,6 +9,8 @@
 #include 
 #include 
 
+#include 
+
 struct drm_cgroup_state {
struct cgroup_subsys_state css;
 
@@ -31,6 +33,24 @@ css_to_drmcs(struct cgroup_subsys_state *css)
return container_of(css, struct drm_cgroup_state, css);
 }
 
+static u64 drmcs_get_active_time_us(struct drm_cgroup_state *drmcs)
+{
+   struct drm_file *fpriv;
+   u64 total = 0;
+
+   lockdep_assert_held(&drmcg_mutex);
+
+   list_for_each_entry(fpriv, &drmcs->clients, clink) {
+   const struct drm_cgroup_ops *cg_ops =
+   fpriv->minor->dev->driver->cg_ops;
+
+   if (cg_ops && cg_ops->active_time_us)
+   total += cg_ops->active_time_us(fpriv);
+   }
+
+   return total;
+}
+
 static void drmcs_free(struct cgroup_subsys_state *css)
 {
struct drm_cgroup_state *drmcs = css_to_drmcs(css);
-- 
2.39.2



[PATCH 11/17] drm/cgroup: Only track clients which are providing drm_cgroup_ops

2023-07-12 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

To reduce the number of tracking going on, especially with drivers which
will not support any sort of control from the drm cgroup controller side,
lets express the funcionality as opt-in and use the presence of
drm_cgroup_ops as activation criteria.

Signed-off-by: Tvrtko Ursulin 
---
 kernel/cgroup/drm.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/kernel/cgroup/drm.c b/kernel/cgroup/drm.c
index 68f31797c4f0..60e1f3861576 100644
--- a/kernel/cgroup/drm.c
+++ b/kernel/cgroup/drm.c
@@ -97,6 +97,9 @@ void drmcgroup_client_open(struct drm_file *file_priv)
 {
struct drm_cgroup_state *drmcs;
 
+   if (!file_priv->minor->dev->driver->cg_ops)
+   return;
+
drmcs = css_to_drmcs(task_get_css(current, drm_cgrp_id));
 
mutex_lock(&drmcg_mutex);
@@ -112,6 +115,9 @@ void drmcgroup_client_close(struct drm_file *file_priv)
 
drmcs = css_to_drmcs(file_priv->__css);
 
+   if (!file_priv->minor->dev->driver->cg_ops)
+   return;
+
mutex_lock(&drmcg_mutex);
list_del(&file_priv->clink);
file_priv->__css = NULL;
@@ -126,6 +132,9 @@ void drmcgroup_client_migrate(struct drm_file *file_priv)
struct drm_cgroup_state *src, *dst;
struct cgroup_subsys_state *old;
 
+   if (!file_priv->minor->dev->driver->cg_ops)
+   return;
+
mutex_lock(&drmcg_mutex);
 
old = file_priv->__css;
-- 
2.39.2



[PATCH 13/17] drm/i915: Wire up with drm controller GPU time query

2023-07-12 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Implement the drm_cgroup_ops->active_time_us callback.

Signed-off-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/i915_driver.c |   8 ++
 drivers/gpu/drm/i915/i915_drm_client.c | 116 ++---
 drivers/gpu/drm/i915/i915_drm_client.h |   2 +
 3 files changed, 94 insertions(+), 32 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_driver.c 
b/drivers/gpu/drm/i915/i915_driver.c
index 294b022de22b..62a544d17659 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -1791,6 +1791,12 @@ static const struct drm_ioctl_desc i915_ioctls[] = {
DRM_IOCTL_DEF_DRV(I915_GEM_VM_DESTROY, i915_gem_vm_destroy_ioctl, 
DRM_RENDER_ALLOW),
 };
 
+#ifdef CONFIG_CGROUP_DRM
+static const struct drm_cgroup_ops i915_drm_cgroup_ops = {
+   .active_time_us = i915_drm_cgroup_get_active_time_us,
+};
+#endif
+
 /*
  * Interface history:
  *
@@ -1820,6 +1826,8 @@ static const struct drm_driver i915_drm_driver = {
.postclose = i915_driver_postclose,
.show_fdinfo = PTR_IF(IS_ENABLED(CONFIG_PROC_FS), 
i915_drm_client_fdinfo),
 
+   .cg_ops = PTR_IF(IS_ENABLED(CONFIG_CGROUP_DRM), &i915_drm_cgroup_ops),
+
.gem_prime_import = i915_gem_prime_import,
 
.dumb_create = i915_gem_dumb_create,
diff --git a/drivers/gpu/drm/i915/i915_drm_client.c 
b/drivers/gpu/drm/i915/i915_drm_client.c
index 9e7a6075ee25..c3298beb094a 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.c
+++ b/drivers/gpu/drm/i915/i915_drm_client.c
@@ -44,6 +44,86 @@ void __i915_drm_client_free(struct kref *kref)
kfree(client);
 }
 
+#if defined(CONFIG_PROC_FS) || defined(CONFIG_CGROUP_DRM)
+static const char * const uabi_class_names[] = {
+   [I915_ENGINE_CLASS_RENDER] = "render",
+   [I915_ENGINE_CLASS_COPY] = "copy",
+   [I915_ENGINE_CLASS_VIDEO] = "video",
+   [I915_ENGINE_CLASS_VIDEO_ENHANCE] = "video-enhance",
+   [I915_ENGINE_CLASS_COMPUTE] = "compute",
+};
+
+static u64 busy_add(struct i915_gem_context *ctx, unsigned int class)
+{
+   struct i915_gem_engines_iter it;
+   struct intel_context *ce;
+   u64 total = 0;
+
+   for_each_gem_engine(ce, rcu_dereference(ctx->engines), it) {
+   if (ce->engine->uabi_class != class)
+   continue;
+
+   total += intel_context_get_total_runtime_ns(ce);
+   }
+
+   return total;
+}
+
+static u64 get_class_active_ns(struct i915_drm_client *client,
+  struct drm_i915_private *i915,
+  unsigned int class,
+  unsigned int *capacity)
+{
+   struct i915_gem_context *ctx;
+   u64 total;
+
+   *capacity = i915->engine_uabi_class_count[class];
+   if (!*capacity)
+   return 0;
+
+   total = atomic64_read(&client->past_runtime[class]);
+
+   rcu_read_lock();
+   list_for_each_entry_rcu(ctx, &client->ctx_list, client_link)
+   total += busy_add(ctx, class);
+   rcu_read_unlock();
+
+   return total;
+}
+
+static bool supports_stats(struct drm_i915_private *i915)
+{
+   return GRAPHICS_VER(i915) >= 8;
+}
+#endif
+
+#if defined(CONFIG_CGROUP_DRM)
+u64 i915_drm_cgroup_get_active_time_us(struct drm_file *file)
+{
+   struct drm_i915_file_private *fpriv = file->driver_priv;
+   struct i915_drm_client *client = fpriv->client;
+   struct drm_i915_private *i915 = fpriv->i915;
+   unsigned int i;
+   u64 busy = 0;
+
+   if (!supports_stats(i915))
+   return 0;
+
+   for (i = 0; i < ARRAY_SIZE(uabi_class_names); i++) {
+   unsigned int capacity;
+   u64 b;
+
+   b = get_class_active_ns(client, i915, i, &capacity);
+   if (capacity) {
+   b = DIV_ROUND_UP_ULL(b, capacity * 1000);
+   busy += b;
+   }
+   }
+
+   return busy;
+}
+#endif
+
 #ifdef CONFIG_PROC_FS
 static void
 obj_meminfo(struct drm_i915_gem_object *obj,
@@ -128,44 +208,16 @@ static void show_meminfo(struct drm_printer *p, struct 
drm_file *file)
   mr->name);
 }
 
-static const char * const uabi_class_names[] = {
-   [I915_ENGINE_CLASS_RENDER] = "render",
-   [I915_ENGINE_CLASS_COPY] = "copy",
-   [I915_ENGINE_CLASS_VIDEO] = "video",
-   [I915_ENGINE_CLASS_VIDEO_ENHANCE] = "video-enhance",
-   [I915_ENGINE_CLASS_COMPUTE] = "compute",
-};
-
-static u64 busy_add(struct i915_gem_context *ctx, unsigned int class)
-{
-   struct i915_gem_engines_iter it;
-   struct intel_context *ce;
-   u64 total = 0;
-
-   for_each_gem_engine(ce, rcu_dereference(ctx->engines), it) {
-   if (ce->engine->uabi_class != class)
-   continue;
-
-   total += intel_context_get_total_runtime_ns(ce);
-   }
-
-   return total;
-}
-
 static void
 show_client_class(struct drm_printer *p,
  

[PATCH 10/17] drm/cgroup: Add over budget signalling callback

2023-07-12 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Add a new callback via which the drm cgroup controller is notifying the
drm core that a certain process is above its allotted GPU time.

Signed-off-by: Tvrtko Ursulin 
---
 include/drm/drm_drv.h |  8 
 kernel/cgroup/drm.c   | 16 
 2 files changed, 24 insertions(+)

diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index 3116fa4dbc48..29e11a87bf75 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -167,6 +167,14 @@ struct drm_cgroup_ops {
 * Used by the DRM core when queried by the DRM cgroup controller.
 */
u64 (*active_time_us) (struct drm_file *);
+
+   /**
+* @signal_budget:
+*
+* Optional callback used by the DRM core to forward over/under GPU time
+* messages sent by the DRM cgroup controller.
+*/
+   int (*signal_budget) (struct drm_file *, u64 used, u64 budget);
 };
 
 /**
diff --git a/kernel/cgroup/drm.c b/kernel/cgroup/drm.c
index acdb76635b60..68f31797c4f0 100644
--- a/kernel/cgroup/drm.c
+++ b/kernel/cgroup/drm.c
@@ -51,6 +51,22 @@ static u64 drmcs_get_active_time_us(struct drm_cgroup_state 
*drmcs)
return total;
 }
 
+static void
+drmcs_signal_budget(struct drm_cgroup_state *drmcs, u64 usage, u64 budget)
+{
+   struct drm_file *fpriv;
+
+   lockdep_assert_held(&drmcg_mutex);
+
+   list_for_each_entry(fpriv, &drmcs->clients, clink) {
+   const struct drm_cgroup_ops *cg_ops =
+   fpriv->minor->dev->driver->cg_ops;
+
+   if (cg_ops && cg_ops->signal_budget)
+   cg_ops->signal_budget(fpriv, usage, budget);
+   }
+}
+
 static void drmcs_free(struct cgroup_subsys_state *css)
 {
struct drm_cgroup_state *drmcs = css_to_drmcs(css);
-- 
2.39.2



[PATCH 12/17] cgroup/drm: Introduce weight based drm cgroup control

2023-07-12 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

Similar to CPU scheduling, implement a concept of weight in the drm cgroup
controller.

Uses the same range and default as the CPU controller - CGROUP_WEIGHT_MIN,
CGROUP_WEIGHT_DFL and CGROUP_WEIGHT_MAX.

Later each cgroup is assigned a time budget proportionaly based on the
relative weights of it's siblings. This time budget is in turn split by
the group's children and so on.

This will be used to implement a soft, or best effort signal from drm
cgroup to drm core notifying about groups which are over their allotted
budget.

No guarantees that the limit can be enforced are provided or implied.

Checking of GPU usage is done periodically by the controller which can be
configured via drmcg_period_ms kernel boot parameter and which defaults
to 2s.

Signed-off-by: Tvrtko Ursulin 
Cc: Michal Koutný 
Cc: Tejun Heo 
---
 Documentation/admin-guide/cgroup-v2.rst |  31 ++
 kernel/cgroup/drm.c | 409 +++-
 2 files changed, 437 insertions(+), 3 deletions(-)

diff --git a/Documentation/admin-guide/cgroup-v2.rst 
b/Documentation/admin-guide/cgroup-v2.rst
index 4ef890191196..da350858c59f 100644
--- a/Documentation/admin-guide/cgroup-v2.rst
+++ b/Documentation/admin-guide/cgroup-v2.rst
@@ -2418,6 +2418,37 @@ HugeTLB Interface Files
 hugetlb pages of  in this cgroup.  Only active in
 use hugetlb pages are included.  The per-node values are in bytes.
 
+DRM
+---
+
+The DRM controller allows configuring scheduling soft limits.
+
+DRM scheduling soft limits
+~~
+
+Because of the heterogenous hardware and driver DRM capabilities, soft limits
+are implemented as a loose co-operative (bi-directional) interface between the
+controller and DRM core.
+
+The controller configures the GPU time allowed per group and periodically scans
+the belonging tasks to detect the over budget condition, at which point it
+invokes a callback notifying the DRM core of the condition.
+
+DRM core provides an API to query per process GPU utilization and 2nd API to
+receive notification from the cgroup controller when the group enters or exits
+the over budget condition.
+
+Individual DRM drivers which implement the interface are expected to act on 
this
+in the best-effort manner only. There are no guarantees that the soft limits
+will be respected.
+
+DRM scheduling soft limits interface files
+~~
+
+  drm.weight
+   Standard cgroup weight based control [1, 1] used to configure the
+   relative distributing of GPU time between the sibling groups.
+
 Misc
 
 
diff --git a/kernel/cgroup/drm.c b/kernel/cgroup/drm.c
index 60e1f3861576..b244e3d828cc 100644
--- a/kernel/cgroup/drm.c
+++ b/kernel/cgroup/drm.c
@@ -6,7 +6,9 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 
 #include 
@@ -15,10 +17,28 @@ struct drm_cgroup_state {
struct cgroup_subsys_state css;
 
struct list_head clients;
+
+   unsigned int weight;
+
+   unsigned int sum_children_weights;
+
+   bool over;
+   bool over_budget;
+
+   u64 per_s_budget_us;
+   u64 prev_active_us;
+   u64 active_us;
 };
 
 struct drm_root_cgroup_state {
struct drm_cgroup_state drmcs;
+
+   unsigned int period_us;
+
+   unsigned int last_scan_duration_us;
+   ktime_t prev_timestamp;
+
+   struct delayed_work scan_work;
 };
 
 static struct drm_root_cgroup_state root_drmcs = {
@@ -27,6 +47,9 @@ static struct drm_root_cgroup_state root_drmcs = {
 
 static DEFINE_MUTEX(drmcg_mutex);
 
+static int drmcg_period_ms = 2000;
+module_param(drmcg_period_ms, int, 0644);
+
 static inline struct drm_cgroup_state *
 css_to_drmcs(struct cgroup_subsys_state *css)
 {
@@ -67,12 +90,263 @@ drmcs_signal_budget(struct drm_cgroup_state *drmcs, u64 
usage, u64 budget)
}
 }
 
+static u64
+drmcs_read_weight(struct cgroup_subsys_state *css, struct cftype *cft)
+{
+   struct drm_cgroup_state *drmcs = css_to_drmcs(css);
+
+   return drmcs->weight;
+}
+
+static int
+drmcs_write_weight(struct cgroup_subsys_state *css, struct cftype *cftype,
+  u64 weight)
+{
+   struct drm_cgroup_state *drmcs = css_to_drmcs(css);
+   int ret;
+
+   if (weight < CGROUP_WEIGHT_MIN || weight > CGROUP_WEIGHT_MAX)
+   return -ERANGE;
+
+   ret = mutex_lock_interruptible(&drmcg_mutex);
+   if (ret)
+   return ret;
+   drmcs->weight = weight;
+   mutex_unlock(&drmcg_mutex);
+
+   return 0;
+}
+
+static bool __start_scanning(unsigned int period_us)
+{
+   struct drm_cgroup_state *root = &root_drmcs.drmcs;
+   struct cgroup_subsys_state *node;
+   ktime_t start, now;
+   bool ok = false;
+
+   lockdep_assert_held(&drmcg_mutex);
+
+   start = ktime_get();
+   if (period_us > root_drmcs.last_scan_duration_us)
+   period_us -= root_drmcs.last_scan_duration_us;
+
+   rcu_read_lock();
+
+   

  1   2   3   >