From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH v2 12/15] drm/edid: do invalid block filtering in-place
Date: Fri, 10 Jun 2022 22:30:03 +0300 [thread overview]
Message-ID: <YqObu/2oPghzDOVF@intel.com> (raw)
In-Reply-To: <42b16188052ac66868dcb68e08973d1e6912f325.1654674560.git.jani.nikula@intel.com>
On Wed, Jun 08, 2022 at 10:50:42AM +0300, Jani Nikula wrote:
> Rewrite edid_filter_invalid_blocks() to filter invalid blocks
> in-place. The main motivation is to not rely on passed in information on
> invalid block count or the allocation size, which will be helpful in
> follow-up work on HF-EEODB.
>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> drivers/gpu/drm/drm_edid.c | 43 ++++++++++++++++++++------------------
> 1 file changed, 23 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 4e788c5cbf25..77ec5b0e436d 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2020,33 +2020,37 @@ bool drm_edid_is_valid(struct edid *edid)
> }
> EXPORT_SYMBOL(drm_edid_is_valid);
>
> -static struct edid *edid_filter_invalid_blocks(const struct edid *edid,
> - int invalid_blocks,
> +static struct edid *edid_filter_invalid_blocks(struct edid *edid,
> size_t *alloc_size)
> {
> - struct edid *new, *dest_block;
> - int valid_extensions = edid->extensions - invalid_blocks;
> - int i;
> + struct edid *new;
> + int i, valid_blocks = 0;
>
> - *alloc_size = edid_size_by_blocks(valid_extensions + 1);
> + for (i = 0; i < edid_block_count(edid); i++) {
> + const void *src_block = edid_block_data(edid, i);
>
> - new = kmalloc(*alloc_size, GFP_KERNEL);
> - if (!new)
> - goto out;
> + if (edid_block_valid(src_block, i == 0)) {
> + void *dst_block = (void *)edid_block_data(edid, valid_blocks);
>
> - dest_block = new;
> - for (i = 0; i < edid_block_count(edid); i++) {
> - const void *block = edid_block_data(edid, i);
> + memmove(dst_block, src_block, EDID_LENGTH);
> + valid_blocks++;
> + }
> + }
>
> - if (edid_block_valid(block, i == 0))
> - memcpy(dest_block++, block, EDID_LENGTH);
> + /* We already trusted the base block to be valid here... */
> + if (WARN_ON(!valid_blocks)) {
> + kfree(edid);
> + return NULL;
> }
>
> - new->extensions = valid_extensions;
> - new->checksum = edid_block_compute_checksum(new);
> + edid->extensions = valid_blocks - 1;
> + edid->checksum = edid_block_compute_checksum(edid);
>
> -out:
> - kfree(edid);
> + *alloc_size = edid_size_by_blocks(valid_blocks);
> +
> + new = krealloc(edid, *alloc_size, GFP_KERNEL);
> + if (!new)
> + kfree(edid);
>
> return new;
> }
> @@ -2290,8 +2294,7 @@ static struct edid *_drm_do_get_edid(struct drm_connector *connector,
> if (invalid_blocks) {
> connector_bad_edid(connector, edid, edid_block_count(edid));
>
> - edid = edid_filter_invalid_blocks(edid, invalid_blocks,
> - &alloc_size);
> + edid = edid_filter_invalid_blocks(edid, &alloc_size);
> }
>
> ok:
> --
> 2.30.2
--
Ville Syrjälä
Intel
WARNING: multiple messages have this Message-ID (diff)
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 12/15] drm/edid: do invalid block filtering in-place
Date: Fri, 10 Jun 2022 22:30:03 +0300 [thread overview]
Message-ID: <YqObu/2oPghzDOVF@intel.com> (raw)
In-Reply-To: <42b16188052ac66868dcb68e08973d1e6912f325.1654674560.git.jani.nikula@intel.com>
On Wed, Jun 08, 2022 at 10:50:42AM +0300, Jani Nikula wrote:
> Rewrite edid_filter_invalid_blocks() to filter invalid blocks
> in-place. The main motivation is to not rely on passed in information on
> invalid block count or the allocation size, which will be helpful in
> follow-up work on HF-EEODB.
>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> drivers/gpu/drm/drm_edid.c | 43 ++++++++++++++++++++------------------
> 1 file changed, 23 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 4e788c5cbf25..77ec5b0e436d 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2020,33 +2020,37 @@ bool drm_edid_is_valid(struct edid *edid)
> }
> EXPORT_SYMBOL(drm_edid_is_valid);
>
> -static struct edid *edid_filter_invalid_blocks(const struct edid *edid,
> - int invalid_blocks,
> +static struct edid *edid_filter_invalid_blocks(struct edid *edid,
> size_t *alloc_size)
> {
> - struct edid *new, *dest_block;
> - int valid_extensions = edid->extensions - invalid_blocks;
> - int i;
> + struct edid *new;
> + int i, valid_blocks = 0;
>
> - *alloc_size = edid_size_by_blocks(valid_extensions + 1);
> + for (i = 0; i < edid_block_count(edid); i++) {
> + const void *src_block = edid_block_data(edid, i);
>
> - new = kmalloc(*alloc_size, GFP_KERNEL);
> - if (!new)
> - goto out;
> + if (edid_block_valid(src_block, i == 0)) {
> + void *dst_block = (void *)edid_block_data(edid, valid_blocks);
>
> - dest_block = new;
> - for (i = 0; i < edid_block_count(edid); i++) {
> - const void *block = edid_block_data(edid, i);
> + memmove(dst_block, src_block, EDID_LENGTH);
> + valid_blocks++;
> + }
> + }
>
> - if (edid_block_valid(block, i == 0))
> - memcpy(dest_block++, block, EDID_LENGTH);
> + /* We already trusted the base block to be valid here... */
> + if (WARN_ON(!valid_blocks)) {
> + kfree(edid);
> + return NULL;
> }
>
> - new->extensions = valid_extensions;
> - new->checksum = edid_block_compute_checksum(new);
> + edid->extensions = valid_blocks - 1;
> + edid->checksum = edid_block_compute_checksum(edid);
>
> -out:
> - kfree(edid);
> + *alloc_size = edid_size_by_blocks(valid_blocks);
> +
> + new = krealloc(edid, *alloc_size, GFP_KERNEL);
> + if (!new)
> + kfree(edid);
>
> return new;
> }
> @@ -2290,8 +2294,7 @@ static struct edid *_drm_do_get_edid(struct drm_connector *connector,
> if (invalid_blocks) {
> connector_bad_edid(connector, edid, edid_block_count(edid));
>
> - edid = edid_filter_invalid_blocks(edid, invalid_blocks,
> - &alloc_size);
> + edid = edid_filter_invalid_blocks(edid, &alloc_size);
> }
>
> ok:
> --
> 2.30.2
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2022-06-10 19:30 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-08 7:50 [Intel-gfx] [PATCH v2 00/15] drm/edid: expand on struct drm_edid usage Jani Nikula
2022-06-08 7:50 ` Jani Nikula
2022-06-08 7:50 ` [Intel-gfx] [PATCH v2 01/15] drm/edid: fix CTA data block collection size for CTA version 3 Jani Nikula
2022-06-08 7:50 ` Jani Nikula
2022-06-10 18:56 ` [Intel-gfx] " Ville Syrjälä
2022-06-10 18:56 ` Ville Syrjälä
2022-06-08 7:50 ` [Intel-gfx] [PATCH v2 02/15] drm/edid: abstract cea data block collection size Jani Nikula
2022-06-08 7:50 ` Jani Nikula
2022-06-10 18:58 ` [Intel-gfx] " Ville Syrjälä
2022-06-10 18:58 ` Ville Syrjälä
2022-06-08 7:50 ` [Intel-gfx] [PATCH v2 03/15] drm/edid: add block count and data helper functions for drm_edid Jani Nikula
2022-06-08 7:50 ` Jani Nikula
2022-06-08 7:50 ` [Intel-gfx] [PATCH v2 04/15] drm/edid: keep track of alloc size in drm_do_get_edid() Jani Nikula
2022-06-08 7:50 ` Jani Nikula
2022-06-10 19:35 ` [Intel-gfx] " Ville Syrjälä
2022-06-10 19:35 ` Ville Syrjälä
2022-06-08 7:50 ` [Intel-gfx] [PATCH v2 05/15] drm/edid: add new interfaces around struct drm_edid Jani Nikula
2022-06-08 7:50 ` Jani Nikula
2022-06-10 19:35 ` [Intel-gfx] " Ville Syrjälä
2022-06-10 19:35 ` Ville Syrjälä
2022-06-10 19:43 ` [Intel-gfx] " Ville Syrjälä
2022-06-10 19:43 ` Ville Syrjälä
2022-06-13 8:37 ` [Intel-gfx] " Jani Nikula
2022-06-13 8:37 ` Jani Nikula
2022-06-08 7:50 ` [Intel-gfx] [PATCH v2 06/15] drm/edid: add drm_edid_connector_update() Jani Nikula
2022-06-08 7:50 ` Jani Nikula
2022-06-10 19:15 ` [Intel-gfx] " Ville Syrjälä
2022-06-10 19:15 ` Ville Syrjälä
2022-06-08 7:50 ` [Intel-gfx] [PATCH v2 07/15] drm/probe-helper: abstract .get_modes() connector helper call Jani Nikula
2022-06-08 7:50 ` Jani Nikula
2022-06-10 19:36 ` [Intel-gfx] " Ville Syrjälä
2022-06-10 19:36 ` Ville Syrjälä
2022-06-08 7:50 ` [Intel-gfx] [PATCH v2 08/15] drm/probe-helper: add drm_connector_helper_get_modes() Jani Nikula
2022-06-08 7:50 ` Jani Nikula
2022-06-10 19:44 ` [Intel-gfx] " Ville Syrjälä
2022-06-10 19:44 ` Ville Syrjälä
2022-06-08 7:50 ` [Intel-gfx] [PATCH v2 09/15] drm/edid: add drm_edid_raw() to access the raw EDID data Jani Nikula
2022-06-08 7:50 ` Jani Nikula
2022-06-10 19:29 ` [Intel-gfx] " Ville Syrjälä
2022-06-10 19:29 ` Ville Syrjälä
2022-06-08 7:50 ` [Intel-gfx] [PATCH v2 10/15] drm/i915/edid: convert DP, HDMI and LVDS to drm_edid Jani Nikula
2022-06-08 7:50 ` Jani Nikula
2022-06-10 19:21 ` [Intel-gfx] " Ville Syrjälä
2022-06-10 19:21 ` Ville Syrjälä
2022-06-08 7:50 ` [Intel-gfx] [PATCH v2 11/15] drm/i915/bios: convert intel_bios_init_panel() " Jani Nikula
2022-06-08 7:50 ` Jani Nikula
2022-06-10 19:29 ` [Intel-gfx] " Ville Syrjälä
2022-06-10 19:29 ` Ville Syrjälä
2022-06-08 7:50 ` [Intel-gfx] [PATCH v2 12/15] drm/edid: do invalid block filtering in-place Jani Nikula
2022-06-08 7:50 ` Jani Nikula
2022-06-10 19:30 ` Ville Syrjälä [this message]
2022-06-10 19:30 ` Ville Syrjälä
2022-06-08 7:50 ` [Intel-gfx] [PATCH v2 13/15] drm/edid: add HF-EEODB support to EDID read and allocation Jani Nikula
2022-06-08 7:50 ` Jani Nikula
2022-06-10 19:30 ` [Intel-gfx] " Ville Syrjälä
2022-06-10 19:30 ` Ville Syrjälä
2022-06-08 7:50 ` [Intel-gfx] [PATCH v2 14/15] drm/edid: take HF-EEODB extension count into account Jani Nikula
2022-06-08 7:50 ` Jani Nikula
2022-06-10 19:34 ` [Intel-gfx] " Ville Syrjälä
2022-06-10 19:34 ` Ville Syrjälä
2022-06-08 7:50 ` [Intel-gfx] [PATCH v2 15/15] drm/todo: add entry for converting the subsystem to struct drm_edid Jani Nikula
2022-06-08 7:50 ` Jani Nikula
2022-06-08 8:30 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/edid: expand on struct drm_edid usage (rev3) Patchwork
2022-06-08 8:30 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-06-08 11:27 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-06-08 19:23 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2022-06-13 9:37 ` [Intel-gfx] [PATCH v2 00/15] drm/edid: expand on struct drm_edid usage Jani Nikula
2022-06-13 9:37 ` Jani Nikula
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=YqObu/2oPghzDOVF@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.