From patchwork Fri Feb 28 21:14:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ville Syrjala X-Patchwork-Id: 13997141 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 80260C282C6 for ; Fri, 28 Feb 2025 21:15:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C8C8310ED45; Fri, 28 Feb 2025 21:15:04 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="QeGlIM8n"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id C86D410ED42; Fri, 28 Feb 2025 21:15:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740777302; x=1772313302; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=awWZi+Om+LbgWvG/mpX6NzaEi/Shq4lbxv+GyeJFyec=; b=QeGlIM8nYdoA77Rr4gfh28GMGqfdMpFiSIz1w6r2e8e9hqQu0lHTsBas A5tDiGc/JaoXFPvox+nY9UZmuedAXjomTD2YEV6b07fDDJTA0TM1JEJkD nK7IJmb61LHIruLNx4rw0OVJLsfaTDeatomxbYpM3KzY0zy0iqTtPhFnQ 4OTmCFy67LI6/XL0dTvqTsFlrv4IZAdcL3GhmL5/WSMdscljPRissCwv9 aah0SW/qD5iy8Yex8nyyz6TldTbZo5rtLy+acYumCmOEsCerb1NHBIi2J HotGbq5/Glyka79cSkJu+rVMh3IIzaRbzVQ6uJpSAEqF4BV6UdE3kqO7d g==; X-CSE-ConnectionGUID: gyNfz4ltQluugycfYMtLlg== X-CSE-MsgGUID: CohS4/dESZev55ZLwSyohA== X-IronPort-AV: E=McAfee;i="6700,10204,11359"; a="52352291" X-IronPort-AV: E=Sophos;i="6.13,323,1732608000"; d="scan'208";a="52352291" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2025 13:15:01 -0800 X-CSE-ConnectionGUID: QGCfdCleRyCIFkp/SLcBzQ== X-CSE-MsgGUID: uzchl3J0RNml1JQr1dNhwg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="122684762" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by orviesa005.jf.intel.com with SMTP; 28 Feb 2025 13:14:59 -0800 Received: by stinkbox (sSMTP sendmail emulation); Fri, 28 Feb 2025 23:14:58 +0200 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org, Jani Nikula , Thomas Zimmermann Subject: [PATCH v2 1/8] drm/client: Constify modes Date: Fri, 28 Feb 2025 23:14:47 +0200 Message-ID: <20250228211454.8138-2-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250228211454.8138-1-ville.syrjala@linux.intel.com> References: <20250228211454.8138-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ville Syrjälä The modes used by the client code live on the connectors' mode lists, which are not owned by the client code, and thus it has no business modifying the modes. Mark the modes const to make that fact abundantly clear. Reviewed-by: Jani Nikula Reviewed-by: Thomas Zimmermann Signed-off-by: Ville Syrjälä --- drivers/gpu/drm/drm_client_modeset.c | 39 +++++++++++++++------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c index aca442c25209..b114d1b8793b 100644 --- a/drivers/gpu/drm/drm_client_modeset.c +++ b/drivers/gpu/drm/drm_client_modeset.c @@ -117,10 +117,10 @@ drm_client_find_modeset(struct drm_client_dev *client, struct drm_crtc *crtc) return NULL; } -static struct drm_display_mode * +static const struct drm_display_mode * drm_connector_get_tiled_mode(struct drm_connector *connector) { - struct drm_display_mode *mode; + const struct drm_display_mode *mode; list_for_each_entry(mode, &connector->modes, head) { if (mode->hdisplay == connector->tile_h_size && @@ -130,10 +130,10 @@ drm_connector_get_tiled_mode(struct drm_connector *connector) return NULL; } -static struct drm_display_mode * +static const struct drm_display_mode * drm_connector_fallback_non_tiled_mode(struct drm_connector *connector) { - struct drm_display_mode *mode; + const struct drm_display_mode *mode; list_for_each_entry(mode, &connector->modes, head) { if (mode->hdisplay == connector->tile_h_size && @@ -144,10 +144,10 @@ drm_connector_fallback_non_tiled_mode(struct drm_connector *connector) return NULL; } -static struct drm_display_mode * +static const struct drm_display_mode * drm_connector_preferred_mode(struct drm_connector *connector, int width, int height) { - struct drm_display_mode *mode; + const struct drm_display_mode *mode; list_for_each_entry(mode, &connector->modes, head) { if (mode->hdisplay > width || @@ -159,16 +159,18 @@ drm_connector_preferred_mode(struct drm_connector *connector, int width, int hei return NULL; } -static struct drm_display_mode *drm_connector_first_mode(struct drm_connector *connector) +static const struct drm_display_mode * +drm_connector_first_mode(struct drm_connector *connector) { return list_first_entry_or_null(&connector->modes, struct drm_display_mode, head); } -static struct drm_display_mode *drm_connector_pick_cmdline_mode(struct drm_connector *connector) +static const struct drm_display_mode * +drm_connector_pick_cmdline_mode(struct drm_connector *connector) { - struct drm_cmdline_mode *cmdline_mode; - struct drm_display_mode *mode; + const struct drm_cmdline_mode *cmdline_mode; + const struct drm_display_mode *mode; bool prefer_non_interlace; /* @@ -266,13 +268,14 @@ static void drm_client_connectors_enabled(struct drm_connector **connectors, static bool drm_client_target_cloned(struct drm_device *dev, struct drm_connector **connectors, unsigned int connector_count, - struct drm_display_mode **modes, + const struct drm_display_mode **modes, struct drm_client_offset *offsets, bool *enabled, int width, int height) { int count, i, j; bool can_clone = false; - struct drm_display_mode *dmt_mode, *mode; + const struct drm_display_mode *mode; + struct drm_display_mode *dmt_mode; /* only contemplate cloning in the single crtc case */ if (dev->mode_config.num_crtc > 1) @@ -351,7 +354,7 @@ static bool drm_client_target_cloned(struct drm_device *dev, static int drm_client_get_tile_offsets(struct drm_device *dev, struct drm_connector **connectors, unsigned int connector_count, - struct drm_display_mode **modes, + const struct drm_display_mode **modes, struct drm_client_offset *offsets, int idx, int h_idx, int v_idx) @@ -386,7 +389,7 @@ static int drm_client_get_tile_offsets(struct drm_device *dev, static bool drm_client_target_preferred(struct drm_device *dev, struct drm_connector **connectors, unsigned int connector_count, - struct drm_display_mode **modes, + const struct drm_display_mode **modes, struct drm_client_offset *offsets, bool *enabled, int width, int height) { @@ -505,7 +508,7 @@ static int drm_client_pick_crtcs(struct drm_client_dev *client, struct drm_connector **connectors, unsigned int connector_count, struct drm_crtc **best_crtcs, - struct drm_display_mode **modes, + const struct drm_display_mode **modes, int n, int width, int height) { struct drm_device *dev = client->dev; @@ -580,7 +583,7 @@ static bool drm_client_firmware_config(struct drm_client_dev *client, struct drm_connector **connectors, unsigned int connector_count, struct drm_crtc **crtcs, - struct drm_display_mode **modes, + const struct drm_display_mode **modes, struct drm_client_offset *offsets, bool *enabled, int width, int height) { @@ -800,7 +803,7 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width, struct drm_client_offset *offsets; unsigned int connector_count = 0; /* points to modes protected by mode_config.mutex */ - struct drm_display_mode **modes; + const struct drm_display_mode **modes; struct drm_crtc **crtcs; int i, ret = 0; bool *enabled; @@ -871,7 +874,7 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width, drm_client_modeset_release(client); for (i = 0; i < connector_count; i++) { - struct drm_display_mode *mode = modes[i]; + const struct drm_display_mode *mode = modes[i]; struct drm_crtc *crtc = crtcs[i]; struct drm_client_offset *offset = &offsets[i]; From patchwork Fri Feb 28 21:14:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ville Syrjala X-Patchwork-Id: 13997142 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1CEBEC282C5 for ; Fri, 28 Feb 2025 21:15:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8CC1310ED4A; Fri, 28 Feb 2025 21:15:11 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="lJxnOu/Y"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 66FA510ED46; Fri, 28 Feb 2025 21:15:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740777305; x=1772313305; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I9IG255jEJXxhFDsbb7jVaeLoVsGYBXc4mIT5lNwoaA=; b=lJxnOu/Yo/7jV80Knf414arhlxJnfLgWXG6qwKE/lhvsOrrdIOgGOmXE kJO4XA5iuTXv6Zl7Fyb9f1VW4xW8xpB4iB/l9lUrkQt5dF22YJmlasf0O KdyumUtJ9usy9RN6e/qajFDq3rFwmHsUn7K8bdLX7Z6EM9rWpcEyKYEwu DkHFmSEMx4T9OEJALxnCTyb7NRj33R30Q1rMiuR0e1/wWojj7CDsiEQSl RxEFAyzANzmeaR1Xua9tV3gKWsT6r0rItU7C968uEnZLBk0n5G6M47nCx t14EkT2QPlEQcg4k7uT+F2SmC/mwGlZdhka2YTulZoEMR681tczgM5zVp Q==; X-CSE-ConnectionGUID: BUXfHHy4Qamofgu3D0wjcw== X-CSE-MsgGUID: oTQ9uHCgSJCT6OLZl1RSag== X-IronPort-AV: E=McAfee;i="6700,10204,11359"; a="52352304" X-IronPort-AV: E=Sophos;i="6.13,323,1732608000"; d="scan'208";a="52352304" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2025 13:15:05 -0800 X-CSE-ConnectionGUID: MfqGhVWoRS+xo0mGSyOIrg== X-CSE-MsgGUID: tDUgI8/sQ0mCn0JqLVgPBg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="122684828" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by orviesa005.jf.intel.com with SMTP; 28 Feb 2025 13:15:02 -0800 Received: by stinkbox (sSMTP sendmail emulation); Fri, 28 Feb 2025 23:15:01 +0200 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org, Jani Nikula , Thomas Zimmermann Subject: [PATCH v2 2/8] drm/client: Use array notation for function arguments Date: Fri, 28 Feb 2025 23:14:48 +0200 Message-ID: <20250228211454.8138-3-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250228211454.8138-1-ville.syrjala@linux.intel.com> References: <20250228211454.8138-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ville Syrjälä Use the array notation rather that the pointer notation for function arguments. This makes it clear to the reader that we are in fact dealing with an array rather than a single pointer. Functionally the two are equivalent. Reviewed-by: Jani Nikula Reviewed-by: Thomas Zimmermann Signed-off-by: Ville Syrjälä --- drivers/gpu/drm/drm_client_modeset.c | 42 ++++++++++++++-------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c index b114d1b8793b..bdd4078e62ad 100644 --- a/drivers/gpu/drm/drm_client_modeset.c +++ b/drivers/gpu/drm/drm_client_modeset.c @@ -239,9 +239,9 @@ static bool drm_connector_enabled(struct drm_connector *connector, bool strict) return enable; } -static void drm_client_connectors_enabled(struct drm_connector **connectors, +static void drm_client_connectors_enabled(struct drm_connector *connectors[], unsigned int connector_count, - bool *enabled) + bool enabled[]) { bool any_enabled = false; struct drm_connector *connector; @@ -266,11 +266,11 @@ static void drm_client_connectors_enabled(struct drm_connector **connectors, } static bool drm_client_target_cloned(struct drm_device *dev, - struct drm_connector **connectors, + struct drm_connector *connectors[], unsigned int connector_count, - const struct drm_display_mode **modes, - struct drm_client_offset *offsets, - bool *enabled, int width, int height) + const struct drm_display_mode *modes[], + struct drm_client_offset offsets[], + bool enabled[], int width, int height) { int count, i, j; bool can_clone = false; @@ -352,10 +352,10 @@ static bool drm_client_target_cloned(struct drm_device *dev, } static int drm_client_get_tile_offsets(struct drm_device *dev, - struct drm_connector **connectors, + struct drm_connector *connectors[], unsigned int connector_count, - const struct drm_display_mode **modes, - struct drm_client_offset *offsets, + const struct drm_display_mode *modes[], + struct drm_client_offset offsets[], int idx, int h_idx, int v_idx) { @@ -387,11 +387,11 @@ static int drm_client_get_tile_offsets(struct drm_device *dev, } static bool drm_client_target_preferred(struct drm_device *dev, - struct drm_connector **connectors, + struct drm_connector *connectors[], unsigned int connector_count, - const struct drm_display_mode **modes, - struct drm_client_offset *offsets, - bool *enabled, int width, int height) + const struct drm_display_mode *modes[], + struct drm_client_offset offsets[], + bool enabled[], int width, int height) { const u64 mask = BIT_ULL(connector_count) - 1; struct drm_connector *connector; @@ -505,10 +505,10 @@ static bool connector_has_possible_crtc(struct drm_connector *connector, } static int drm_client_pick_crtcs(struct drm_client_dev *client, - struct drm_connector **connectors, + struct drm_connector *connectors[], unsigned int connector_count, - struct drm_crtc **best_crtcs, - const struct drm_display_mode **modes, + struct drm_crtc *best_crtcs[], + const struct drm_display_mode *modes[], int n, int width, int height) { struct drm_device *dev = client->dev; @@ -580,12 +580,12 @@ static int drm_client_pick_crtcs(struct drm_client_dev *client, /* Try to read the BIOS display configuration and use it for the initial config */ static bool drm_client_firmware_config(struct drm_client_dev *client, - struct drm_connector **connectors, + struct drm_connector *connectors[], unsigned int connector_count, - struct drm_crtc **crtcs, - const struct drm_display_mode **modes, - struct drm_client_offset *offsets, - bool *enabled, int width, int height) + struct drm_crtc *crtcs[], + const struct drm_display_mode *modes[], + struct drm_client_offset offsets[], + bool enabled[], int width, int height) { const int count = min_t(unsigned int, connector_count, BITS_PER_LONG); unsigned long conn_configured, conn_seq, mask; From patchwork Fri Feb 28 21:14:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ville Syrjala X-Patchwork-Id: 13997143 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 94782C282D0 for ; Fri, 28 Feb 2025 21:15:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BCDCD10ED4E; Fri, 28 Feb 2025 21:15:11 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="GYMhQRa4"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 07ED710ED4A; Fri, 28 Feb 2025 21:15:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740777309; x=1772313309; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=l7oCQFTV7k8lDDCRxbk6zzQ6EefvDW8p6MzecEeSw24=; b=GYMhQRa4V2xnsr1wLoAEKpfJoscMuBdE3ZhyN4hhNWnxBCt1E6tFvIdC XMUQuPonc+5ieDK+RZo+PS2XpgLhxBt3+0u15BbQDn2maWCqhLrXpGsuN qQfjva/ns2IZ4tTulBut5OiQi1Ck2PQLfxrmIA1muB4itG/tcp+8A2XMU C5pufZv8CONx99axeGzoaDaOb+GhqvMZmeJ9i3Qk8FIaHiCQs5xg8poxh op/JwImpNZMqU+BcuQZUaNqMFU7gf1l2gsl4AMHx1JHOIUu56YnsTiEGn CEi6N35AMggajSJ6b2MxSUaT2Soo0oiYdI14C8aBRDArbsn8WpnDyNq1K Q==; X-CSE-ConnectionGUID: Ov4rvku/R7WxNbRH4z7NNQ== X-CSE-MsgGUID: Y2lfYuuyTZKZ6pohDDqk7w== X-IronPort-AV: E=McAfee;i="6700,10204,11359"; a="52352313" X-IronPort-AV: E=Sophos;i="6.13,323,1732608000"; d="scan'208";a="52352313" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2025 13:15:09 -0800 X-CSE-ConnectionGUID: ItdpcqhXRlWt6o2ePwUpqA== X-CSE-MsgGUID: 8w5xE7GlRpirmkQZdBTuiw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="122684836" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by orviesa005.jf.intel.com with SMTP; 28 Feb 2025 13:15:06 -0800 Received: by stinkbox (sSMTP sendmail emulation); Fri, 28 Feb 2025 23:15:05 +0200 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH v2 3/8] drm/client: Streamline mode selection debugs Date: Fri, 28 Feb 2025 23:14:49 +0200 Message-ID: <20250228211454.8138-4-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250228211454.8138-1-ville.syrjala@linux.intel.com> References: <20250228211454.8138-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ville Syrjälä Get rid of all the redundant debugs and just wait until the end to print which mode (and of which type) we picked. Reviewed-by: Thomas Zimmermann Signed-off-by: Ville Syrjälä --- drivers/gpu/drm/drm_client_modeset.c | 70 +++++++++++++--------------- 1 file changed, 33 insertions(+), 37 deletions(-) diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c index bdd4078e62ad..148257287ae4 100644 --- a/drivers/gpu/drm/drm_client_modeset.c +++ b/drivers/gpu/drm/drm_client_modeset.c @@ -408,6 +408,8 @@ static bool drm_client_target_preferred(struct drm_device *dev, retry: for (i = 0; i < connector_count; i++) { + const char *mode_type; + connector = connectors[i]; if (conn_configured & BIT_ULL(i)) @@ -441,20 +443,20 @@ static bool drm_client_target_preferred(struct drm_device *dev, modes, offsets, i, connector->tile_h_loc, connector->tile_v_loc); } - drm_dbg_kms(dev, "[CONNECTOR:%d:%s] looking for cmdline mode\n", - connector->base.id, connector->name); - /* got for command line mode first */ + mode_type = "cmdline"; modes[i] = drm_connector_pick_cmdline_mode(connector); + if (!modes[i]) { - drm_dbg_kms(dev, "[CONNECTOR:%d:%s] looking for preferred mode, tile %d\n", - connector->base.id, connector->name, - connector->tile_group ? connector->tile_group->id : 0); + mode_type = "preferred"; modes[i] = drm_connector_preferred_mode(connector, width, height); } - /* No preferred modes, pick one off the list */ - if (!modes[i]) + + if (!modes[i]) { + mode_type = "first"; modes[i] = drm_connector_first_mode(connector); + } + /* * In case of tiled mode if all tiles not present fallback to * first available non tiled mode. @@ -469,18 +471,22 @@ static bool drm_client_target_preferred(struct drm_device *dev, (connector->tile_h_loc == 0 && connector->tile_v_loc == 0 && !drm_connector_get_tiled_mode(connector))) { - drm_dbg_kms(dev, - "[CONNECTOR:%d:%s] Falling back to non-tiled mode\n", - connector->base.id, connector->name); + mode_type = "non tiled"; modes[i] = drm_connector_fallback_non_tiled_mode(connector); } else { + mode_type = "tiled"; modes[i] = drm_connector_get_tiled_mode(connector); } } - drm_dbg_kms(dev, "[CONNECTOR:%d:%s] Found mode %s\n", - connector->base.id, connector->name, - modes[i] ? modes[i]->name : "none"); + if (modes[i]) + drm_dbg_kms(dev, "[CONNECTOR:%d:%s] found %s mode: %s\n", + connector->base.id, connector->name, + mode_type, modes[i]->name); + else + drm_dbg_kms(dev, "[CONNECTOR:%d:%s] no mode found\n", + connector->base.id, connector->name); + conn_configured |= BIT_ULL(i); } @@ -627,6 +633,7 @@ static bool drm_client_firmware_config(struct drm_client_dev *client, struct drm_connector *connector; struct drm_encoder *encoder; struct drm_crtc *new_crtc; + const char *mode_type; connector = connectors[i]; @@ -676,30 +683,22 @@ static bool drm_client_firmware_config(struct drm_client_dev *client, */ for (j = 0; j < count; j++) { if (crtcs[j] == new_crtc) { - drm_dbg_kms(dev, "fallback: cloned configuration\n"); + drm_dbg_kms(dev, "[CONNECTOR:%d:%s] fallback: cloned configuration\n", + connector->base.id, connector->name); goto bail; } } - drm_dbg_kms(dev, "[CONNECTOR:%d:%s] looking for cmdline mode\n", - connector->base.id, connector->name); - - /* go for command line mode first */ + mode_type = "cmdline"; modes[i] = drm_connector_pick_cmdline_mode(connector); - /* try for preferred next */ if (!modes[i]) { - drm_dbg_kms(dev, - "[CONNECTOR:%d:%s] looking for preferred mode, has tile: %s\n", - connector->base.id, connector->name, - str_yes_no(connector->has_tile)); + mode_type = "preferred"; modes[i] = drm_connector_preferred_mode(connector, width, height); } - /* No preferred mode marked by the EDID? Are there any modes? */ - if (!modes[i] && !list_empty(&connector->modes)) { - drm_dbg_kms(dev, "[CONNECTOR:%d:%s] using first listed mode\n", - connector->base.id, connector->name); + if (!modes[i]) { + mode_type = "first"; modes[i] = drm_connector_first_mode(connector); } @@ -716,28 +715,25 @@ static bool drm_client_firmware_config(struct drm_client_dev *client, * This is crtc->mode and not crtc->state->mode for the * fastboot check to work correctly. */ - drm_dbg_kms(dev, "[CONNECTOR:%d:%s] looking for current mode\n", - connector->base.id, connector->name); + mode_type = "current"; modes[i] = &connector->state->crtc->mode; } + /* * In case of tiled modes, if all tiles are not present * then fallback to a non tiled mode. */ if (connector->has_tile && num_tiled_conns < connector->num_h_tile * connector->num_v_tile) { - drm_dbg_kms(dev, "[CONNECTOR:%d:%s] Falling back to non-tiled mode\n", - connector->base.id, connector->name); + mode_type = "non tiled"; modes[i] = drm_connector_fallback_non_tiled_mode(connector); } crtcs[i] = new_crtc; - drm_dbg_kms(dev, "[CONNECTOR:%d:%s] on [CRTC:%d:%s]: %dx%d%s\n", + drm_dbg_kms(dev, "[CONNECTOR::%d:%s] on [CRTC:%d:%s] using %s mode: %s\n", connector->base.id, connector->name, - connector->state->crtc->base.id, - connector->state->crtc->name, - modes[i]->hdisplay, modes[i]->vdisplay, - modes[i]->flags & DRM_MODE_FLAG_INTERLACE ? "i" : ""); + new_crtc->base.id, new_crtc->name, + mode_type, modes[i]->name); fallback = false; conn_configured |= BIT(i); From patchwork Fri Feb 28 21:14:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ville Syrjala X-Patchwork-Id: 13997144 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8C247C282C6 for ; Fri, 28 Feb 2025 21:15:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CD1CE10ED52; Fri, 28 Feb 2025 21:15:13 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="bqkLPLOB"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 56D9910ED50; Fri, 28 Feb 2025 21:15:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740777312; x=1772313312; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LwDPpP/Od2VODLPdCVQtTN3jJru5UTC3AM6y89UOVaQ=; b=bqkLPLOBFeqixni9iBgoqj9GK07NJAXVwIM5Fxq9vOE0QrvS6J8EQZAX YrorT6bsB/iG38xC3r2xL+nFiSJqzDoIxh+Op3nG+8rnCTNzIF6C36qsI oAKIScb7Xbc62ySWKd9beHdbMVT8YLNlWUoDOPzslOsTT7xgYEwbIPTYV NDMJg1HX1XsrX5cqG4GWLtgAMc/wgAb2kQnRzp1V0Y4/nZzZ5JwZA/+e2 8fZfzf46EgnzK4PCdZYJuj/GPcgjBypb70LbHGMnDI4UDA+2a2yw/b3pQ yrYWmsQ1WXAwtQJVjIm2uvnfHsg+YbxoFmPWDUuib/sCbO3OG9eVgWNqL A==; X-CSE-ConnectionGUID: +8slSLHMROCtJOAjQOGUug== X-CSE-MsgGUID: kIwgSulqSumIaKzgroyOsg== X-IronPort-AV: E=McAfee;i="6700,10204,11359"; a="52352322" X-IronPort-AV: E=Sophos;i="6.13,323,1732608000"; d="scan'208";a="52352322" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2025 13:15:12 -0800 X-CSE-ConnectionGUID: o4ozXOPtRQqfPKpKYg7txQ== X-CSE-MsgGUID: DhmMuzlRS8i7rvs9PG78CQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="122684867" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by orviesa005.jf.intel.com with SMTP; 28 Feb 2025 13:15:10 -0800 Received: by stinkbox (sSMTP sendmail emulation); Fri, 28 Feb 2025 23:15:08 +0200 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org Subject: [PATCH v2 4/8] drm/client: Make copies of modes Date: Fri, 28 Feb 2025 23:14:50 +0200 Message-ID: <20250228211454.8138-5-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250228211454.8138-1-ville.syrjala@linux.intel.com> References: <20250228211454.8138-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ville Syrjälä drm_client_firmware_config() is currently picking up the current mode of the crtc via the legacy crtc->mode, which is not supposed to be used by atomic drivers at all. We can't simply switch over to the proper crtc->state->mode because we drop the crtc->mutex (which protects crtc->state) before the mode gets used. The most straightforward solution to extend the lifetime of modes[] seem to be to make full copies of the modes. And with this we can undo also commit 3eadd887dbac ("drm/client:Fully protect modes[] with dev->mode_config.mutex") as the lifetime of modes[] no longer has anything to do with that lock. v2: Don't try to copy NULL modes v3: Keep storing pointers and use drm_mode_{duplicate,destroy}() Signed-off-by: Ville Syrjälä --- drivers/gpu/drm/drm_client_modeset.c | 62 +++++++++++++++++++++------- 1 file changed, 47 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c index 148257287ae4..ff034359f063 100644 --- a/drivers/gpu/drm/drm_client_modeset.c +++ b/drivers/gpu/drm/drm_client_modeset.c @@ -265,6 +265,25 @@ static void drm_client_connectors_enabled(struct drm_connector *connectors[], enabled[i] = drm_connector_enabled(connectors[i], false); } +static void mode_replace(struct drm_device *dev, + const struct drm_display_mode **dst, + const struct drm_display_mode *src) +{ + drm_mode_destroy(dev, (struct drm_display_mode *)*dst); + + *dst = src ? drm_mode_duplicate(dev, src) : NULL; +} + +static void modes_destroy(struct drm_device *dev, + const struct drm_display_mode *modes[], + int count) +{ + int i; + + for (i = 0; i < count; i++) + mode_replace(dev, &modes[i], NULL); +} + static bool drm_client_target_cloned(struct drm_device *dev, struct drm_connector *connectors[], unsigned int connector_count, @@ -296,7 +315,9 @@ static bool drm_client_target_cloned(struct drm_device *dev, for (i = 0; i < connector_count; i++) { if (!enabled[i]) continue; - modes[i] = drm_connector_pick_cmdline_mode(connectors[i]); + + mode_replace(dev, &modes[i], + drm_connector_pick_cmdline_mode(connectors[i])); if (!modes[i]) { can_clone = false; break; @@ -335,7 +356,7 @@ static bool drm_client_target_cloned(struct drm_device *dev, DRM_MODE_MATCH_CLOCK | DRM_MODE_MATCH_FLAGS | DRM_MODE_MATCH_3D_FLAGS)) - modes[i] = mode; + mode_replace(dev, &modes[i], mode); } if (!modes[i]) can_clone = false; @@ -445,16 +466,19 @@ static bool drm_client_target_preferred(struct drm_device *dev, } mode_type = "cmdline"; - modes[i] = drm_connector_pick_cmdline_mode(connector); + mode_replace(dev, &modes[i], + drm_connector_pick_cmdline_mode(connector)); if (!modes[i]) { mode_type = "preferred"; - modes[i] = drm_connector_preferred_mode(connector, width, height); + mode_replace(dev, &modes[i], + drm_connector_preferred_mode(connector, width, height)); } if (!modes[i]) { mode_type = "first"; - modes[i] = drm_connector_first_mode(connector); + mode_replace(dev, &modes[i], + drm_connector_first_mode(connector)); } /* @@ -472,10 +496,12 @@ static bool drm_client_target_preferred(struct drm_device *dev, connector->tile_v_loc == 0 && !drm_connector_get_tiled_mode(connector))) { mode_type = "non tiled"; - modes[i] = drm_connector_fallback_non_tiled_mode(connector); + mode_replace(dev, &modes[i], + drm_connector_fallback_non_tiled_mode(connector)); } else { mode_type = "tiled"; - modes[i] = drm_connector_get_tiled_mode(connector); + mode_replace(dev, &modes[i], + drm_connector_get_tiled_mode(connector)); } } @@ -690,16 +716,19 @@ static bool drm_client_firmware_config(struct drm_client_dev *client, } mode_type = "cmdline"; - modes[i] = drm_connector_pick_cmdline_mode(connector); + mode_replace(dev, &modes[i], + drm_connector_pick_cmdline_mode(connector)); if (!modes[i]) { mode_type = "preferred"; - modes[i] = drm_connector_preferred_mode(connector, width, height); + mode_replace(dev, &modes[i], + drm_connector_preferred_mode(connector, width, height)); } if (!modes[i]) { mode_type = "first"; - modes[i] = drm_connector_first_mode(connector); + mode_replace(dev, &modes[i], + drm_connector_first_mode(connector)); } /* last resort: use current mode */ @@ -716,7 +745,8 @@ static bool drm_client_firmware_config(struct drm_client_dev *client, * fastboot check to work correctly. */ mode_type = "current"; - modes[i] = &connector->state->crtc->mode; + mode_replace(dev, &modes[i], + &connector->state->crtc->mode); } /* @@ -726,7 +756,8 @@ static bool drm_client_firmware_config(struct drm_client_dev *client, if (connector->has_tile && num_tiled_conns < connector->num_h_tile * connector->num_v_tile) { mode_type = "non tiled"; - modes[i] = drm_connector_fallback_non_tiled_mode(connector); + mode_replace(dev, &modes[i], + drm_connector_fallback_non_tiled_mode(connector)); } crtcs[i] = new_crtc; @@ -798,7 +829,6 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width, unsigned int total_modes_count = 0; struct drm_client_offset *offsets; unsigned int connector_count = 0; - /* points to modes protected by mode_config.mutex */ const struct drm_display_mode **modes; struct drm_crtc **crtcs; int i, ret = 0; @@ -850,7 +880,7 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width, if (!drm_client_firmware_config(client, connectors, connector_count, crtcs, modes, offsets, enabled, width, height)) { - memset(modes, 0, connector_count * sizeof(*modes)); + modes_destroy(dev, modes, connector_count); memset(crtcs, 0, connector_count * sizeof(*crtcs)); memset(offsets, 0, connector_count * sizeof(*offsets)); @@ -867,6 +897,8 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width, crtcs, modes, 0, width, height); } + mutex_unlock(&dev->mode_config.mutex); + drm_client_modeset_release(client); for (i = 0; i < connector_count; i++) { @@ -901,11 +933,11 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width, modeset->y = offset->y; } } - mutex_unlock(&dev->mode_config.mutex); mutex_unlock(&client->modeset_mutex); out: kfree(crtcs); + modes_destroy(dev, modes, connector_count); kfree(modes); kfree(offsets); kfree(enabled); From patchwork Fri Feb 28 21:14:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ville Syrjala X-Patchwork-Id: 13997146 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9A28EC282D3 for ; Fri, 28 Feb 2025 21:15:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 82AAF10ED56; Fri, 28 Feb 2025 21:15:24 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="jP0JZzRQ"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8FCA710ED4B; Fri, 28 Feb 2025 21:15:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740777315; x=1772313315; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bULcN5viyy0C1hLt2e4R+uly163iYAmhTg0lzJ8LsWw=; b=jP0JZzRQl0VFeyFjaugil6k4waB4F1rO4o5vyWGMaxNt403FABikuU9w Igy3YZV6Jd38n/ONZDUuHnc3WAyNIG+H9XgMytK4+1047kgAzJexKnyZy l4KUuApbzAh1Skb8RqMF8c4K3OmyhdQYptnfnu4ybH6dTpZMzNAfbbCyo bg3WLHZ8Us1uacbwQvLvzh4zBkCHye8kENGVoCcJE2ezUY6jm0F2/IiQs 4QBif3UAGwqkXbSIFATgNl1txAH1gV/v9I3oWVdLJ6eexghZ5eWyd6JNC 0ZFQRfavEoth7WVIvlmrtbT1PTuqSMLg2yUDHDXS2L+4uGsrpGZA5pwLY Q==; X-CSE-ConnectionGUID: BkCVrkqzSeKt1ZLVHQcvQA== X-CSE-MsgGUID: FYhC1MqVSryBSwmltC5DfA== X-IronPort-AV: E=McAfee;i="6700,10204,11359"; a="52352329" X-IronPort-AV: E=Sophos;i="6.13,323,1732608000"; d="scan'208";a="52352329" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2025 13:15:15 -0800 X-CSE-ConnectionGUID: e89fWaxdSk2kS2PRUZyADQ== X-CSE-MsgGUID: +bDzgA0cTDWM2Sj8vsFu5Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="122684887" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by orviesa005.jf.intel.com with SMTP; 28 Feb 2025 13:15:13 -0800 Received: by stinkbox (sSMTP sendmail emulation); Fri, 28 Feb 2025 23:15:12 +0200 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org Subject: [PATCH v2 5/8] drm/client: Stop using the legacy crtc->mode Date: Fri, 28 Feb 2025 23:14:51 +0200 Message-ID: <20250228211454.8138-6-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250228211454.8138-1-ville.syrjala@linux.intel.com> References: <20250228211454.8138-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ville Syrjälä crtc->mode is legacy junk and shouldn't really be used with atomic drivers. Most (all?) atomic drivers do end up still calling drm_atomic_helper_update_legacy_modeset_state() at some point, so crtc->mode does still get populated, and this does work for now. But now that the modes[] lifetime issues have been sorted out we can just switch over to the proper crtc->state->mode. v2: Rebase Signed-off-by: Ville Syrjälä --- drivers/gpu/drm/drm_client_modeset.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c index ff034359f063..4c64535fb82c 100644 --- a/drivers/gpu/drm/drm_client_modeset.c +++ b/drivers/gpu/drm/drm_client_modeset.c @@ -733,20 +733,9 @@ static bool drm_client_firmware_config(struct drm_client_dev *client, /* last resort: use current mode */ if (!modes[i]) { - /* - * IMPORTANT: We want to use the adjusted mode (i.e. - * after the panel fitter upscaling) as the initial - * config, not the input mode, which is what crtc->mode - * usually contains. But since our current - * code puts a mode derived from the post-pfit timings - * into crtc->mode this works out correctly. - * - * This is crtc->mode and not crtc->state->mode for the - * fastboot check to work correctly. - */ mode_type = "current"; mode_replace(dev, &modes[i], - &connector->state->crtc->mode); + &new_crtc->state->mode); } /* From patchwork Fri Feb 28 21:14:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ville Syrjala X-Patchwork-Id: 13997147 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE471C282CD for ; Fri, 28 Feb 2025 21:15:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EA42C10ED4D; Fri, 28 Feb 2025 21:15:23 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Mud5l11F"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id AA6F910ED5B; Fri, 28 Feb 2025 21:15:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740777319; x=1772313319; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ayCzSfXOBQ49h2iuqpmIcDKnMGz1UH6AV4XjAJXUbiU=; b=Mud5l11Ftp+/xvtQvXXfdaYORC6Cp0b6jVOxRoE/Bb3Lj/YwIT31esAI wAjoKXWbBVtfBfcjMq5Uf8iAurwkbuQwMj00JY9HNpIiJBBEeJwpAXU+y uLNTC+QZFGlHI5hFqKh2yViMWDuVafrg72ctj/7CO+Sjw6uE0dhzJbq9R KuiyUbLhpGAYmDMYuQNzUxIDdB4vWwbu3Xz4e9Cl/vkSgt2YVluWvPr3F r+xS2MmuL0MxwDqmeBH3tXhbMK1x4pMPRWTlAh7OhXVZF4852f3h5Lic9 brgwXxTgO9UC+r5U4Ynh6NU+nCZC5Ceq/KZCD3wItVzuJ3kzti74Hxu4T Q==; X-CSE-ConnectionGUID: sMw6vAPgSTiX9UGKr20f1g== X-CSE-MsgGUID: j7CIcgJFQQSYCDZ6vqufEg== X-IronPort-AV: E=McAfee;i="6700,10204,11359"; a="52352342" X-IronPort-AV: E=Sophos;i="6.13,323,1732608000"; d="scan'208";a="52352342" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2025 13:15:18 -0800 X-CSE-ConnectionGUID: b3+xOILrSda0hd6C000Usw== X-CSE-MsgGUID: 6BLtQardTdCdFBQUr7PJMw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="122684913" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by orviesa005.jf.intel.com with SMTP; 28 Feb 2025 13:15:16 -0800 Received: by stinkbox (sSMTP sendmail emulation); Fri, 28 Feb 2025 23:15:15 +0200 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org Subject: [PATCH v2 6/8] drm/client: s/new_crtc/crtc/ Date: Fri, 28 Feb 2025 23:14:52 +0200 Message-ID: <20250228211454.8138-7-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250228211454.8138-1-ville.syrjala@linux.intel.com> References: <20250228211454.8138-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ville Syrjälä Rename the 'new_crtc' variable to just 'crtc' in drm_client_firmware_config(). We don't call any of the other stuff in here new or old so this feels out of place. v2: Rebase Signed-off-by: Ville Syrjälä --- drivers/gpu/drm/drm_client_modeset.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c index 4c64535fb82c..a0caa2b229dd 100644 --- a/drivers/gpu/drm/drm_client_modeset.c +++ b/drivers/gpu/drm/drm_client_modeset.c @@ -658,7 +658,7 @@ static bool drm_client_firmware_config(struct drm_client_dev *client, for (i = 0; i < count; i++) { struct drm_connector *connector; struct drm_encoder *encoder; - struct drm_crtc *new_crtc; + struct drm_crtc *crtc; const char *mode_type; connector = connectors[i]; @@ -700,7 +700,7 @@ static bool drm_client_firmware_config(struct drm_client_dev *client, num_connectors_enabled++; - new_crtc = connector->state->crtc; + crtc = connector->state->crtc; /* * Make sure we're not trying to drive multiple connectors @@ -708,7 +708,7 @@ static bool drm_client_firmware_config(struct drm_client_dev *client, * match the BIOS. */ for (j = 0; j < count; j++) { - if (crtcs[j] == new_crtc) { + if (crtcs[j] == crtc) { drm_dbg_kms(dev, "[CONNECTOR:%d:%s] fallback: cloned configuration\n", connector->base.id, connector->name); goto bail; @@ -735,7 +735,7 @@ static bool drm_client_firmware_config(struct drm_client_dev *client, if (!modes[i]) { mode_type = "current"; mode_replace(dev, &modes[i], - &new_crtc->state->mode); + &crtc->state->mode); } /* @@ -748,11 +748,11 @@ static bool drm_client_firmware_config(struct drm_client_dev *client, mode_replace(dev, &modes[i], drm_connector_fallback_non_tiled_mode(connector)); } - crtcs[i] = new_crtc; + crtcs[i] = crtc; drm_dbg_kms(dev, "[CONNECTOR::%d:%s] on [CRTC:%d:%s] using %s mode: %s\n", connector->base.id, connector->name, - new_crtc->base.id, new_crtc->name, + crtc->base.id, crtc->name, mode_type, modes[i]->name); fallback = false; From patchwork Fri Feb 28 21:14:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ville Syrjala X-Patchwork-Id: 13997145 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C87BDC282C6 for ; Fri, 28 Feb 2025 21:15:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 41ABB10ED4B; Fri, 28 Feb 2025 21:15:23 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="cyfR+CbL"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id C5C7210ED4C; Fri, 28 Feb 2025 21:15:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740777322; x=1772313322; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nZhwkVdDFrW/cEmfLdhD2C5SpAJFryeQIbZrqy1Ms3Q=; b=cyfR+CbLrgPtPg2N0TOoZQPnbWBf3HFtkZVP7dKi58LJHg4R+UUsOiAP jLRqMFDi/ZH+60a5NTRhOxtrxIdVLHouTibAC0Aqag2vXIORkgX7DxMFT ErQ0+4rIXmRtShIlQSzC8o+iEF0lp7/0zITljnOOJtNmc99cultCTV5o1 lINbtuJuXiUUdhxQ+LJl2kv8/oyoR48K8iNTtYfvLZAh43IWL9aokSNYE twKGQqyMGxbszWnj2HYxbgZ8owMmPZ1U2qph79M5RH/yp4IbUDOVXT7Ao +7YdPYm5I5cRydz7f/zkStpxRf9Q62KkJj6GU2vZMeCeZu+zICR82wBxB g==; X-CSE-ConnectionGUID: /3FIKAb6TfG3P9sXB+79kw== X-CSE-MsgGUID: vNmuQa/wRBK6YUUfPB6ysg== X-IronPort-AV: E=McAfee;i="6700,10204,11359"; a="52352352" X-IronPort-AV: E=Sophos;i="6.13,323,1732608000"; d="scan'208";a="52352352" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2025 13:15:21 -0800 X-CSE-ConnectionGUID: CtuqCesEQn2C+qcGBEXBcA== X-CSE-MsgGUID: u3WQcDLARASdClanGAxzPw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="122684929" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by orviesa005.jf.intel.com with SMTP; 28 Feb 2025 13:15:19 -0800 Received: by stinkbox (sSMTP sendmail emulation); Fri, 28 Feb 2025 23:15:18 +0200 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org Subject: [PATCH v2 7/8] drm/client: Move variables to tighter scope Date: Fri, 28 Feb 2025 23:14:53 +0200 Message-ID: <20250228211454.8138-8-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250228211454.8138-1-ville.syrjala@linux.intel.com> References: <20250228211454.8138-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ville Syrjälä Bunch of variables are only needed inside loops and whatnot. Move them to a tighter scope to make the code less confusing. Signed-off-by: Ville Syrjälä --- drivers/gpu/drm/drm_client_modeset.c | 33 +++++++++++++++------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c index a0caa2b229dd..54cbcaa476e2 100644 --- a/drivers/gpu/drm/drm_client_modeset.c +++ b/drivers/gpu/drm/drm_client_modeset.c @@ -73,9 +73,10 @@ int drm_client_modeset_create(struct drm_client_dev *client) static void drm_client_modeset_release(struct drm_client_dev *client) { struct drm_mode_set *modeset; - unsigned int i; drm_client_for_each_modeset(modeset, client) { + unsigned int i; + drm_mode_destroy(client->dev, modeset->mode); modeset->mode = NULL; modeset->fb = NULL; @@ -291,9 +292,8 @@ static bool drm_client_target_cloned(struct drm_device *dev, struct drm_client_offset offsets[], bool enabled[], int width, int height) { - int count, i, j; + int count, i; bool can_clone = false; - const struct drm_display_mode *mode; struct drm_display_mode *dmt_mode; /* only contemplate cloning in the single crtc case */ @@ -313,6 +313,8 @@ static bool drm_client_target_cloned(struct drm_device *dev, /* check the command line or if nothing common pick 1024x768 */ can_clone = true; for (i = 0; i < connector_count; i++) { + int j; + if (!enabled[i]) continue; @@ -347,6 +349,8 @@ static bool drm_client_target_cloned(struct drm_device *dev, goto fail; for (i = 0; i < connector_count; i++) { + const struct drm_display_mode *mode; + if (!enabled[i]) continue; @@ -380,12 +384,12 @@ static int drm_client_get_tile_offsets(struct drm_device *dev, int idx, int h_idx, int v_idx) { - struct drm_connector *connector; int i; int hoffset = 0, voffset = 0; for (i = 0; i < connector_count; i++) { - connector = connectors[i]; + struct drm_connector *connector = connectors[i]; + if (!connector->has_tile) continue; @@ -415,7 +419,6 @@ static bool drm_client_target_preferred(struct drm_device *dev, bool enabled[], int width, int height) { const u64 mask = BIT_ULL(connector_count) - 1; - struct drm_connector *connector; u64 conn_configured = 0; int tile_pass = 0; int num_tiled_conns = 0; @@ -429,9 +432,9 @@ static bool drm_client_target_preferred(struct drm_device *dev, retry: for (i = 0; i < connector_count; i++) { + struct drm_connector *connector = connectors[i]; const char *mode_type; - connector = connectors[i]; if (conn_configured & BIT_ULL(i)) continue; @@ -546,9 +549,8 @@ static int drm_client_pick_crtcs(struct drm_client_dev *client, struct drm_device *dev = client->dev; struct drm_connector *connector; int my_score, best_score, score; - struct drm_crtc **crtcs, *crtc; + struct drm_crtc **crtcs; struct drm_mode_set *modeset; - int o; if (n == connector_count) return 0; @@ -578,7 +580,8 @@ static int drm_client_pick_crtcs(struct drm_client_dev *client, * remaining connectors */ drm_client_for_each_modeset(modeset, client) { - crtc = modeset->crtc; + struct drm_crtc *crtc = modeset->crtc; + int o; if (!connector_has_possible_crtc(connector, crtc)) continue; @@ -622,7 +625,7 @@ static bool drm_client_firmware_config(struct drm_client_dev *client, const int count = min_t(unsigned int, connector_count, BITS_PER_LONG); unsigned long conn_configured, conn_seq, mask; struct drm_device *dev = client->dev; - int i, j; + int i; bool *save_enabled; bool fallback = true, ret = true; int num_connectors_enabled = 0; @@ -656,12 +659,11 @@ static bool drm_client_firmware_config(struct drm_client_dev *client, retry: conn_seq = conn_configured; for (i = 0; i < count; i++) { - struct drm_connector *connector; + struct drm_connector *connector = connectors[i]; struct drm_encoder *encoder; struct drm_crtc *crtc; const char *mode_type; - - connector = connectors[i]; + int j; if (conn_configured & BIT(i)) continue; @@ -1239,11 +1241,12 @@ static void drm_client_modeset_dpms_legacy(struct drm_client_dev *client, int dp struct drm_connector *connector; struct drm_mode_set *modeset; struct drm_modeset_acquire_ctx ctx; - int j; int ret; DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret); drm_client_for_each_modeset(modeset, client) { + int j; + if (!modeset->crtc->enabled) continue; From patchwork Fri Feb 28 21:14:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ville Syrjala X-Patchwork-Id: 13997148 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 74A71C282D4 for ; Fri, 28 Feb 2025 21:15:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AD47910ED58; Fri, 28 Feb 2025 21:15:25 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="GjD7wLA5"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id D085C10ED58; Fri, 28 Feb 2025 21:15:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740777325; x=1772313325; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eFJSUo0VQyqq9qD4qi5Qi148Jlk8Ij47jPkoiPk2IzU=; b=GjD7wLA50AgqSoxbydzAnriBTUjLddIB5pj9SpVivVBoYAFT3eXB3nUH Af1pclhKuYE/fahbMLbqdq8Nism9LlimJ0oycaam+jMx7ck9BNg4mL5AA VBMXs027EG0BkJtxsUYwnLG/c7bKLZ8GwxGbWxLZ12zlHqgWRpuxseKuC QlSzTVbLY1ytf+9KmihQ89cSBqOAhKdQNvD3/wF3WldzJOXPETDe4KkaJ oZ7aeOhCxTfnB9fLk4hibkVh4/uKKJa2nszqOpg5BYFGYQKbMRMHok/4E AqDgmsUoXxLUpSu8p0/W+F5c4sd9gOyA5x8paf/SzPEN62laUI5rr20tc A==; X-CSE-ConnectionGUID: o7CEPzoDTsSDlDMq4vCkuA== X-CSE-MsgGUID: no+CKPpzTES6tavYSZ/Iug== X-IronPort-AV: E=McAfee;i="6700,10204,11359"; a="52352361" X-IronPort-AV: E=Sophos;i="6.13,323,1732608000"; d="scan'208";a="52352361" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2025 13:15:24 -0800 X-CSE-ConnectionGUID: Bu8f7V/fStOpImOQVeewMA== X-CSE-MsgGUID: qsN4KANtSFyBu99SJW1Dgw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="122684938" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by orviesa005.jf.intel.com with SMTP; 28 Feb 2025 13:15:22 -0800 Received: by stinkbox (sSMTP sendmail emulation); Fri, 28 Feb 2025 23:15:21 +0200 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org Subject: [PATCH v2 8/8] drm/client: s/unsigned int i/int i/ Date: Fri, 28 Feb 2025 23:14:54 +0200 Message-ID: <20250228211454.8138-9-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250228211454.8138-1-ville.syrjala@linux.intel.com> References: <20250228211454.8138-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ville Syrjälä Replace the 'unsigned int i' footguns with plain old signed int. Avoids accidents if/when someone decides they need to iterate backwards. Signed-off-by: Ville Syrjälä --- drivers/gpu/drm/drm_client_modeset.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c index 54cbcaa476e2..0f9d5ba36c81 100644 --- a/drivers/gpu/drm/drm_client_modeset.c +++ b/drivers/gpu/drm/drm_client_modeset.c @@ -39,7 +39,7 @@ int drm_client_modeset_create(struct drm_client_dev *client) unsigned int max_connector_count = 1; struct drm_mode_set *modeset; struct drm_crtc *crtc; - unsigned int i = 0; + int i = 0; /* Add terminating zero entry to enable index less iteration */ client->modesets = kcalloc(num_crtc + 1, sizeof(*client->modesets), GFP_KERNEL); @@ -75,7 +75,7 @@ static void drm_client_modeset_release(struct drm_client_dev *client) struct drm_mode_set *modeset; drm_client_for_each_modeset(modeset, client) { - unsigned int i; + int i; drm_mode_destroy(client->dev, modeset->mode); modeset->mode = NULL; @@ -960,7 +960,7 @@ bool drm_client_rotation(struct drm_mode_set *modeset, unsigned int *rotation) struct drm_plane *plane = modeset->crtc->primary; struct drm_cmdline_mode *cmdline; u64 valid_mask = 0; - unsigned int i; + int i; if (!modeset->num_connectors) return false;