public inbox for intel-xe@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Borah, Chaitanya Kumar" <chaitanya.kumar.borah@intel.com>
To: Suraj Kandpal <suraj.kandpal@intel.com>,
	<intel-xe@lists.freedesktop.org>,
	 <intel-gfx@lists.freedesktop.org>
Cc: <sowmiya.s@intel.com>, <uma.shankar@intel.com>,
	<swati2.sharma@intel.com>,  <arun.r.murthy@intel.com>
Subject: Re: [PATCH v3 05/26] drm/i915/writeback: Init writeback connector
Date: Tue, 31 Mar 2026 12:43:37 +0530	[thread overview]
Message-ID: <6a04bcb6-6cea-42e6-9886-2ef9fee06ce1@intel.com> (raw)
In-Reply-To: <20260325110744.1096786-6-suraj.kandpal@intel.com>



On 3/25/2026 4:37 PM, Suraj Kandpal wrote:
> Initialize writeback connector initialising the virtual encoder
> and intel connector. We also allocate memory for drm_writeback_connector
> but not the drm_connector within it due to a constraint
> we need all connectors to be an intel_connector.

Not true anymore.	

> The writeback_format arrays is used to tell the user which
> drm formats are supported by us.
> 
> Bspec: 49275
> Signed-off-by: Suraj Kandpal <suraj.kandpal@intel.com>
> ---
>   drivers/gpu/drm/i915/Makefile                 |   1 +
>   .../gpu/drm/i915/display/intel_writeback.c    | 126 ++++++++++++++++++
>   .../gpu/drm/i915/display/intel_writeback.h    |  17 +++
>   3 files changed, 144 insertions(+)
>   create mode 100644 drivers/gpu/drm/i915/display/intel_writeback.c
>   create mode 100644 drivers/gpu/drm/i915/display/intel_writeback.h
> 
> diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
> index b677720a1c2d..1e9140e7713c 100644
> --- a/drivers/gpu/drm/i915/Makefile
> +++ b/drivers/gpu/drm/i915/Makefile
> @@ -315,6 +315,7 @@ i915-y += \
>   	display/intel_vblank.o \
>   	display/intel_vga.o \
>   	display/intel_wm.o \
> +	display/intel_writeback.o \
>   	display/skl_prefill.o \
>   	display/skl_scaler.o \
>   	display/skl_universal_plane.o \
> diff --git a/drivers/gpu/drm/i915/display/intel_writeback.c b/drivers/gpu/drm/i915/display/intel_writeback.c
> new file mode 100644
> index 000000000000..73101ee17d74
> --- /dev/null
> +++ b/drivers/gpu/drm/i915/display/intel_writeback.c
> @@ -0,0 +1,126 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2025 Intel Corporation
> + */
> +
> +#include <linux/slab.h>
> +#include <drm/drm_atomic_state_helper.h>
> +#include <drm/drm_writeback.h>
> +#include <drm/drm_modeset_helper_vtables.h>
> +#include <drm/drm_probe_helper.h>
> +#include <drm/drm_fourcc.h>
> +#include <drm/drm_encoder.h>
> +
> +#include "intel_atomic.h"
> +#include "intel_connector.h"
> +#include "intel_de.h"
> +#include "intel_display_driver.h"
> +#include "intel_display_types.h"
> +#include "intel_writeback.h"
> +
> +struct intel_writeback_connector {
> +	struct intel_connector connector;
> +	struct intel_encoder encoder;
> +	enum transcoder trans;
> +	int frame_num;
> +};

As I understand, this struct sits at the same hierarchy level as struct 
intel_digital_port/struct intel_dsi.

Something like the following might fit better with the existing framework

struct intel_writeback {
	struct intel_encoder base; /* DRM_MODE_ENCODER_VIRTUAL */
	struct intel_connector *attached_connector;
}

I am not sure what is the implication of this for the rest of the 
series* but there are already signs in this patch that the current 
structure does not work well.

For example, kfree(&writeback_conn->encoder) is freeing up an embedded 
member.

*My guess is we should be good as long as we attach the encoder and 
connector properly.

> +
> +static const u32 writeback_formats[] = {
> +	DRM_FORMAT_XYUV8888,
> +	DRM_FORMAT_YUYV,
> +	DRM_FORMAT_XBGR8888,
> +	DRM_FORMAT_XVYU2101010,
> +	DRM_FORMAT_VYUY,
> +	DRM_FORMAT_XBGR2101010,
> +};
> +
> +static int intel_writeback_connector_init(struct intel_connector *connector)
> +{
> +	struct intel_digital_connector_state *conn_state;
> +
> +	conn_state = kzalloc(sizeof(*conn_state), GFP_KERNEL);
> +	if (!conn_state)
> +		return -ENOMEM;
> +
> +	__drm_atomic_helper_connector_reset(&connector->base,
> +					    &conn_state->base);
> +	return 0;
> +}
> +
> +static int
> +intel_writeback_connector_alloc(struct intel_connector *connector)
> +{
> +	if (intel_writeback_connector_init(connector) < 0) {
> +		kfree(connector);
> +		return -ENOMEM;
> +	}
> +
> +	return 0;
> +}
> +
> +static const struct drm_encoder_funcs drm_writeback_encoder_funcs = {
> +	.destroy = drm_encoder_cleanup,
> +};
> +
> +const struct drm_connector_funcs conn_funcs = {

To maintain consistency with the style used for other connectors

intel_writeback_connector_funcs

> +	.fill_modes = drm_helper_probe_single_connector_modes,
> +	.atomic_duplicate_state = intel_digital_connector_duplicate_state,
> +	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
> +};
> +
> +static const struct drm_connector_helper_funcs conn_helper_funcs = {

Same,
intel_writeback_connector_helper_funcs

> +};
> +
> +int intel_writeback_init(struct intel_display *display)
> +{
> +	struct intel_encoder *encoder;
> +	struct intel_writeback_connector *writeback_conn;
> +	struct intel_connector *connector;
> +	int ret;
> +
> +	writeback_conn = kzalloc(sizeof(*writeback_conn), GFP_KERNEL);
> +	if (!writeback_conn)
> +		return -ENOSPC;
> +
> +	encoder = &writeback_conn->encoder;
> +	encoder->base.possible_crtcs = 0xf;
> +	ret = drm_encoder_init(display->drm, &encoder->base,
> +			       &drm_writeback_encoder_funcs,
> +			       DRM_MODE_ENCODER_VIRTUAL, NULL);
> +	if (ret) {
> +		kfree(writeback_conn);
> +		return ret;
> +	}
> +
> +	encoder->type = INTEL_OUTPUT_WRITEBACK;
> +	encoder->pipe_mask = ~0;
> +	encoder->cloneable = 0;
> +
> +	connector = &writeback_conn->connector;
> +	ret = intel_writeback_connector_alloc(connector);
> +	if (ret) {
> +		kfree(writeback_conn);
> +		return ret;
> +	}
> +
> +	connector->base.interlace_allowed = 0;
> +	drm_connector_helper_add(&connector->base, &conn_helper_funcs);
> +	ret = drm_writeback_connector_init(display->drm, &connector->base,
> +					   &conn_funcs, &encoder->base,
> +					   writeback_formats,
> +					   ARRAY_SIZE(writeback_formats));

Probably means that we have to call drm_writeback_connector_cleanup() 
from somewhere, which is missing currently.

> +	if (ret) {
> +		intel_connector_free(connector);
> +		drm_encoder_cleanup(&encoder->base);
> +		kfree(&writeback_conn->encoder);
> +		kfree(writeback_conn);
> +		return ret;
> +	}

would be nice to follow the standard pattern of goto err instead of 
having this code block here.

> +
> +	intel_connector_attach_encoder(connector, encoder);
> +	connector->get_hw_state = intel_connector_get_hw_state;
> +	connector->base.status = connector_status_disconnected;
> +	writeback_conn->frame_num = 1;
> +
> +	return 0;
> +}
> diff --git a/drivers/gpu/drm/i915/display/intel_writeback.h b/drivers/gpu/drm/i915/display/intel_writeback.h
> new file mode 100644
> index 000000000000..5911684cb81a
> --- /dev/null
> +++ b/drivers/gpu/drm/i915/display/intel_writeback.h
> @@ -0,0 +1,17 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2025 Intel Corporation
> + */
> +
> +#ifndef __INTEL_WRITEBACK_H__
> +#define __INTEL_WRITEBACK_H__
> +
> +#include <linux/types.h>
> +
> +struct intel_display;
> +struct intel_writeback_connector;
> +
> +int intel_writeback_init(struct intel_display *display);
> +
> +#endif /* __INTEL_WRITEBACK_H__ */
> +


  parent reply	other threads:[~2026-03-31  7:13 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-25 11:07 [PATCH v3 00/26] Enable Pipe writeback Suraj Kandpal
2026-03-25 11:07 ` [PATCH v3 DO NOT REVIEW 01/26] drm: writeback: rename drm_writeback_connector_init_with_encoder() Suraj Kandpal
2026-03-25 11:07 ` [PATCH v3 DO NOT REVIEW 02/26] drm: writeback: Refactor drm_writeback_connector structure Suraj Kandpal
2026-03-25 11:07 ` [PATCH v3 03/26] drm/i915/writeback: Add writeback registers Suraj Kandpal
2026-03-25 11:42   ` Ville Syrjälä
2026-03-26  2:31     ` Kandpal, Suraj
2026-03-31  7:12   ` Borah, Chaitanya Kumar
2026-03-25 11:07 ` [PATCH v3 04/26] drm/i915/writeback: Add some preliminary writeback definitions Suraj Kandpal
2026-03-25 11:52   ` Ville Syrjälä
2026-03-26  2:37     ` Kandpal, Suraj
2026-03-31  7:13   ` Borah, Chaitanya Kumar
2026-03-25 11:07 ` [PATCH v3 05/26] drm/i915/writeback: Init writeback connector Suraj Kandpal
2026-03-25 12:15   ` Ville Syrjälä
2026-03-26  2:52     ` Kandpal, Suraj
2026-03-31  7:13   ` Borah, Chaitanya Kumar [this message]
2026-03-25 11:07 ` [PATCH v3 06/26] drm/i915/writeback: Add function to get modes Suraj Kandpal
2026-03-31  7:14   ` Borah, Chaitanya Kumar
2026-03-25 11:07 ` [PATCH v3 07/26] drm/i915/writeback: Add hook to check modes Suraj Kandpal
2026-03-25 11:07 ` [PATCH v3 08/26] drm/i915/writeback: Define encoder->get_hw_state Suraj Kandpal
2026-03-25 12:08   ` Ville Syrjälä
2026-03-31  7:15   ` Borah, Chaitanya Kumar
2026-03-25 11:07 ` [PATCH v3 09/26] drm/i915/writeback: Fill encoder->get_config Suraj Kandpal
2026-03-25 12:15   ` Ville Syrjälä
2026-03-26  2:52     ` Kandpal, Suraj
2026-03-25 11:07 ` [PATCH v3 10/26] drm/i915/writeback: Add private structure for writeback job Suraj Kandpal
2026-03-25 12:17   ` Ville Syrjälä
2026-03-26  2:53     ` Kandpal, Suraj
2026-03-25 11:07 ` [PATCH v3 11/26] drm/i915/writeback: Define function for prepare and cleanup hooks Suraj Kandpal
2026-03-25 12:29   ` Ville Syrjälä
2026-03-25 11:07 ` [PATCH v3 12/26] drm/i915/writeback: Define compute_config for writeback Suraj Kandpal
2026-03-25 12:19   ` Ville Syrjälä
2026-03-26  3:38     ` Kandpal, Suraj
2026-03-25 11:07 ` [PATCH v3 13/26] drm/i915/writeback: Define function for connector function detect Suraj Kandpal
2026-03-25 12:22   ` Ville Syrjälä
2026-03-25 11:07 ` [PATCH v3 14/26] drm/i915/writeback: Define function to destroy writeback connector Suraj Kandpal
2026-03-25 12:23   ` Ville Syrjälä
2026-03-26  3:39     ` Kandpal, Suraj
2026-03-25 11:07 ` [PATCH v3 15/26] drm/i915/writeback: Add connector atomic check Suraj Kandpal
2026-03-25 12:25   ` Ville Syrjälä
2026-03-26  3:43     ` Kandpal, Suraj
2026-03-31  7:16   ` Borah, Chaitanya Kumar
2026-03-25 11:07 ` [PATCH v3 16/26] drm/i915/writeback: Add writeback to xe Makefile Suraj Kandpal
2026-03-25 12:25   ` Ville Syrjälä
2026-03-26  3:44     ` Kandpal, Suraj
2026-03-25 11:07 ` [PATCH v3 17/26] drm/i915/writeback: Add the enable sequence from writeback Suraj Kandpal
2026-03-25 12:31   ` Ville Syrjälä
2026-03-31  7:16   ` Borah, Chaitanya Kumar
2026-03-25 11:07 ` [PATCH v3 18/26] drm/i915/writeback: Define writeback frame capture function Suraj Kandpal
2026-03-25 12:33   ` Ville Syrjälä
2026-03-26  3:47     ` Kandpal, Suraj
2026-04-07  8:28   ` Jani Nikula
2026-04-08  3:02     ` Kandpal, Suraj
2026-03-25 11:07 ` [PATCH v3 19/26] drm/{i915/xe}/writeback: Add a writeback helper to get ggtt address Suraj Kandpal
2026-03-31  7:25   ` Borah, Chaitanya Kumar
2026-04-07  8:32   ` Jani Nikula
2026-04-08  3:24     ` Kandpal, Suraj
2026-04-08  4:11     ` Kandpal, Suraj
2026-03-25 11:07 ` [PATCH v3 20/26] drm/i915/writeback: Configure WD_STRIDE reg Suraj Kandpal
2026-03-25 12:35   ` Ville Syrjälä
2026-03-26  3:52     ` Kandpal, Suraj
2026-03-31  7:17   ` Borah, Chaitanya Kumar
2026-03-25 11:07 ` [PATCH v3 21/26] drm/i915/writeback: Configure WD_SURF register Suraj Kandpal
2026-03-31  7:17   ` Borah, Chaitanya Kumar
2026-03-25 11:07 ` [PATCH v3 22/26] drm/i915/writeback: Enable writeback interrupts Suraj Kandpal
2026-03-25 12:59   ` Ville Syrjälä
2026-03-31  7:19   ` Borah, Chaitanya Kumar
2026-04-07  8:36   ` Jani Nikula
2026-03-25 11:07 ` [PATCH v3 23/26] drm/i915/writeback: Initialize writeback encoder Suraj Kandpal
2026-03-25 13:00   ` Ville Syrjälä
2026-03-26  4:01     ` Kandpal, Suraj
2026-03-31  7:23   ` Borah, Chaitanya Kumar
2026-03-25 11:07 ` [PATCH v3 24/26] drm/i915/writeback: Define the disable sequence for writeback Suraj Kandpal
2026-03-31  7:20   ` Borah, Chaitanya Kumar
2026-03-25 11:07 ` [PATCH v3 25/26] drm/i915/writeback: Make exception for writeback connector Suraj Kandpal
2026-03-31  7:20   ` Borah, Chaitanya Kumar
2026-04-07  8:40   ` Jani Nikula
2026-03-25 11:07 ` [PATCH v3 26/26] drm/i915/writeback: Modify state verify function Suraj Kandpal
2026-03-25 13:01   ` Ville Syrjälä
2026-03-26  3:57     ` Kandpal, Suraj
2026-03-25 11:19 ` ✗ CI.checkpatch: warning for Enable Pipe writeback (rev3) Patchwork
2026-03-25 11:20 ` ✓ CI.KUnit: success " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6a04bcb6-6cea-42e6-9886-2ef9fee06ce1@intel.com \
    --to=chaitanya.kumar.borah@intel.com \
    --cc=arun.r.murthy@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=sowmiya.s@intel.com \
    --cc=suraj.kandpal@intel.com \
    --cc=swati2.sharma@intel.com \
    --cc=uma.shankar@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox