Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Gustavo Sousa <gustavo.sousa@intel.com>
To: Kamil Konieczny <kamil.konieczny@linux.intel.com>,
	<igt-dev@lists.freedesktop.org>
Cc: Jani Nikula <jani.nikula@intel.com>,
	Ankit Nautiyal <ankit.k.nautiyal@intel.com>,
	Ashutosh Dixit <ashutosh.dixit@intel.com>,
	Karthik B S <karthik.b.s@intel.com>,
	Kamil Konieczny <kamil.konieczny@linux.intel.com>
Subject: Re: [PATCH i-g-t v2] scripts: Add new script for verbatim sync with kernel
Date: Fri, 15 May 2026 11:37:37 -0300	[thread overview]
Message-ID: <87lddkpwlq.fsf@intel.com> (raw)
In-Reply-To: <20260514132713.35818-1-kamil.konieczny@linux.intel.com>

Kamil Konieczny <kamil.konieczny@linux.intel.com> writes:

> From: Jani Nikula <jani.nikula@intel.com>
>
> This is a helper script used in cases when a verbatim kernel
> file should be copied into igt-dev.
>
> Cc: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
> Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
> Cc: Karthik B S <karthik.b.s@intel.com>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> Signed-off-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
> ---
>  scripts/sync_with_kernel.sh | 57 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 57 insertions(+)
>  create mode 100755 scripts/sync_with_kernel.sh
>
> diff --git a/scripts/sync_with_kernel.sh b/scripts/sync_with_kernel.sh
> new file mode 100755
> index 000000000..65753677c
> --- /dev/null
> +++ b/scripts/sync_with_kernel.sh
> @@ -0,0 +1,57 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: MIT
> +#
> +# Copyright © 2026 Intel Corporation
> +#
> +# Author: Jani Nikula <jani.nikula@intel.com>
> +#
> +# Use this for verbatim copies from kernel into igt-dev-tools
> +# Change paths to yours, update the repos, cd to IGT, and run.
> +
> +SINCE=962601ac4c78

So, the plan is for us to keep updating the SINCE value manually? I
wonder if we could do better.

One idea is to try to infer it from the files in the IGT repository: for
each file, we can try to find the latest IGT commit in the format "...:
sync ... with kernel commit ...". In case we do not find any, I guess we
can fallback to using ..HEAD as the revision range when searching for
$last down below.

> +KERNEL=$HOME/src/linux
> +IGT=$HOME/src/intel-gpu-tools

I think the script should not assume specific locations for the
repositories. I think:

- The location for the kernel repository should be given as an argument;
- We should assume that scripts/sync_with_kernel.sh is called from the
  IGT repository and we can infer the repository toplevel directory
  based on "$(realpath "$(dirname "${BASH_SOURCE[0]}")")" and "git
  rev-parse --show-toplevel".

> +
> +declare -g -A map
> +map["drivers/gpu/drm/i915/display/intel_vbt_defs.h"]="tools/intel_vbt_defs.h"
> +map["drivers/gpu/drm/i915/display/intel_dsi_vbt_defs.h"]="tools/intel_dsi_vbt_defs.h"
> +map["include/drm/intel/pciids.h"]="lib/pciids.h"
> +
> +cd $KERNEL
> +
> +for infile in "${!map[@]}"; do
> +	outfile=${map[$infile]}
> +
> +	echo "processing $infile -> $outfile"
> +
> +	last=
> +	for commit in $(git log --reverse --pretty=%h $SINCE..HEAD -- $infile); do
> +		if ! git cat-file -e $commit:$infile 2>/dev/null; then
> +			continue
> +		fi
> +		if git show $commit:$infile | diff -q $IGT/$outfile - >/dev/null; then
> +			last=$commit
> +			break
> +		fi
> +	done
> +
> +	if [[ -z "$last" ]]; then
> +		echo "last update to $infile not found"
> +		continue
> +	fi
> +
> +	for commit in $(git log --reverse --pretty=%h $last..HEAD -- $infile); do

Do we really need the intermediate commits when synchronizing?  What
would be the value in adding those?

> +		prefix="${outfile%.*}"
> +		base="$(basename $outfile)"
> +		# ref=$(git cite $commit)
> +		# alias: cite = log -1 --abbrev=12 '--format=%h (\"%s\")'
> +		ref=$(git log -1 --abbrev=12 '--format=%h (\"%s\")' $commit)
> +		git show $commit:$infile > $IGT/$outfile
> +		cd $IGT
> +		git commit -as \

We can avoid changing directories with git -C "$IGT" commit ...

Also, perhaps using "git commit ... -- $IGT/$outfile" is safer than
using "git commit -a ...".

--
Gustavo Sousa

> +		    -m "${prefix}: sync ${base} with kernel commit $commit" \
> +		    -m "Synchronize ${base} with kernel commit:" \
> +		    -m "$ref"
> +		cd -
> +	done
> +done
> -- 
> 2.54.0

  parent reply	other threads:[~2026-05-15 14:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-14 13:27 [PATCH i-g-t v2] scripts: Add new script for verbatim sync with kernel Kamil Konieczny
2026-05-15  8:10 ` Jani Nikula
2026-05-15 10:33   ` Kamil Konieczny
2026-05-15 14:37 ` Gustavo Sousa [this message]
2026-05-15 14:53   ` Jani Nikula
2026-05-15 15:39     ` Gustavo Sousa

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=87lddkpwlq.fsf@intel.com \
    --to=gustavo.sousa@intel.com \
    --cc=ankit.k.nautiyal@intel.com \
    --cc=ashutosh.dixit@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=karthik.b.s@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