Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t v2] scripts: Add new script for verbatim sync with kernel
@ 2026-05-14 13:27 Kamil Konieczny
  2026-05-15  8:10 ` Jani Nikula
  2026-05-15 14:37 ` Gustavo Sousa
  0 siblings, 2 replies; 6+ messages in thread
From: Kamil Konieczny @ 2026-05-14 13:27 UTC (permalink / raw)
  To: igt-dev
  Cc: Jani Nikula, Ankit Nautiyal, Ashutosh Dixit, Karthik B S,
	Kamil Konieczny

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
+KERNEL=$HOME/src/linux
+IGT=$HOME/src/intel-gpu-tools
+
+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
+		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 \
+		    -m "${prefix}: sync ${base} with kernel commit $commit" \
+		    -m "Synchronize ${base} with kernel commit:" \
+		    -m "$ref"
+		cd -
+	done
+done
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH i-g-t v2] scripts: Add new script for verbatim sync with kernel
  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
  1 sibling, 1 reply; 6+ messages in thread
From: Jani Nikula @ 2026-05-15  8:10 UTC (permalink / raw)
  To: Kamil Konieczny, igt-dev
  Cc: Ankit Nautiyal, Ashutosh Dixit, Karthik B S, Kamil Konieczny

On Thu, 14 May 2026, Kamil Konieczny <kamil.konieczny@linux.intel.com> wrote:
> 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.

First of all, thanks for picking this up.

Then some process nitpicks. ;)

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

I'm pretty sure I haven't sent this with my Signed-off-by. I admit I
should have, but Signed-off-by is a legal thing, and you can't add it on
my behalf.

Anyway,

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>
> +#

I'm generally against adding *any* Author: lines in comments in any
collaborative projects. They give a false sense of ownership, and they
create a perpetual problem of "when do you add another author". The
author lines are also (socially) difficult to remove afterwards.

In the kernel, we have Author: lines in files by folks that created the
file 10-15 years ago, but have been basically completely rewritten since
then by a dozen people. But nobody added another Author: line since
then. I think that's just misattribution and misleading.

I could basically add my name in almost every file in the i915 display
parts, and much more, but what would be the point of that?

The truth is really in the git history.

I want to reply with the above rant when anyone is adding a file with
Author:, and I sometimes do in the kernel. But I kind of shy away in igt
since there are already so many files with Author:.

But for sure I can say: Please remove the Author: line with my name
here.


Thanks,
Jani.



> +# 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
> +KERNEL=$HOME/src/linux
> +IGT=$HOME/src/intel-gpu-tools
> +
> +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
> +		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 \
> +		    -m "${prefix}: sync ${base} with kernel commit $commit" \
> +		    -m "Synchronize ${base} with kernel commit:" \
> +		    -m "$ref"
> +		cd -
> +	done
> +done

-- 
Jani Nikula, Intel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH i-g-t v2] scripts: Add new script for verbatim sync with kernel
  2026-05-15  8:10 ` Jani Nikula
@ 2026-05-15 10:33   ` Kamil Konieczny
  0 siblings, 0 replies; 6+ messages in thread
From: Kamil Konieczny @ 2026-05-15 10:33 UTC (permalink / raw)
  To: Jani Nikula; +Cc: igt-dev, Ankit Nautiyal, Ashutosh Dixit, Karthik B S

Hi Jani,
On 2026-05-15 at 11:10:44 +0300, Jani Nikula wrote:
> On Thu, 14 May 2026, Kamil Konieczny <kamil.konieczny@linux.intel.com> wrote:
> > 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.
> 
> First of all, thanks for picking this up.
> 
> Then some process nitpicks. ;)
> 
> > 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>
> 
> I'm pretty sure I haven't sent this with my Signed-off-by. I admit I
> should have, but Signed-off-by is a legal thing, and you can't add it on
> my behalf.
> 
> Anyway,
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> 

Sorry, this was your script sent few weeks ago, so not giving
your authorship nor s-o-b seems off to me. Thank you for
clarification and actual explicit s-o-b.

> 
> > 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>
> > +#
> 
> I'm generally against adding *any* Author: lines in comments in any
> collaborative projects. They give a false sense of ownership, and they
> create a perpetual problem of "when do you add another author". The
> author lines are also (socially) difficult to remove afterwards.
> 
> In the kernel, we have Author: lines in files by folks that created the
> file 10-15 years ago, but have been basically completely rewritten since
> then by a dozen people. But nobody added another Author: line since
> then. I think that's just misattribution and misleading.
> 
> I could basically add my name in almost every file in the i915 display
> parts, and much more, but what would be the point of that?
> 
> The truth is really in the git history.
> 
> I want to reply with the above rant when anyone is adding a file with
> Author:, and I sometimes do in the kernel. But I kind of shy away in igt
> since there are already so many files with Author:.
> 
> But for sure I can say: Please remove the Author: line with my name
> here.
> 
> 
> Thanks,
> Jani.
> 

Ok, I agree, I will sent v3 with this removed.
 
 
> > +# 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

I will also update this to match latest sync with pciids.h

Regards,
Kamil

> > +KERNEL=$HOME/src/linux
> > +IGT=$HOME/src/intel-gpu-tools
> > +
> > +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
> > +		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 \
> > +		    -m "${prefix}: sync ${base} with kernel commit $commit" \
> > +		    -m "Synchronize ${base} with kernel commit:" \
> > +		    -m "$ref"
> > +		cd -
> > +	done
> > +done
> 
> -- 
> Jani Nikula, Intel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH i-g-t v2] scripts: Add new script for verbatim sync with kernel
  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 14:37 ` Gustavo Sousa
  2026-05-15 14:53   ` Jani Nikula
  1 sibling, 1 reply; 6+ messages in thread
From: Gustavo Sousa @ 2026-05-15 14:37 UTC (permalink / raw)
  To: Kamil Konieczny, igt-dev
  Cc: Jani Nikula, Ankit Nautiyal, Ashutosh Dixit, Karthik B S,
	Kamil Konieczny

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH i-g-t v2] scripts: Add new script for verbatim sync with kernel
  2026-05-15 14:37 ` Gustavo Sousa
@ 2026-05-15 14:53   ` Jani Nikula
  2026-05-15 15:39     ` Gustavo Sousa
  0 siblings, 1 reply; 6+ messages in thread
From: Jani Nikula @ 2026-05-15 14:53 UTC (permalink / raw)
  To: Gustavo Sousa, Kamil Konieczny, igt-dev
  Cc: Ankit Nautiyal, Ashutosh Dixit, Karthik B S, Kamil Konieczny

On Fri, 15 May 2026, Gustavo Sousa <gustavo.sousa@intel.com> wrote:
> 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.

It's just a starting point to not go through the entire history. It'll
find the matching commit after that. It's sufficient to update SINCE
when it gets too slow.

> 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".

Fair; I originally wrote this for myself.

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

This is the bit that finds the last matching commit.

>> +
>> +	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?

I wrote this at a time when I'd done a lot of refactoring kernel
side. When each of those kernel changes needed corresponding IGT changes
*outside* of the files being synced, it was tremendously helpful to
split it to smaller changes.

If there's no such need, you can trivially manually squash them with git
rebase -i, but I think it's helpful for the script to do individual
changes.

>
>> +		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 ...".

Fair.

BR,
Jani.

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

-- 
Jani Nikula, Intel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH i-g-t v2] scripts: Add new script for verbatim sync with kernel
  2026-05-15 14:53   ` Jani Nikula
@ 2026-05-15 15:39     ` Gustavo Sousa
  0 siblings, 0 replies; 6+ messages in thread
From: Gustavo Sousa @ 2026-05-15 15:39 UTC (permalink / raw)
  To: Jani Nikula, Kamil Konieczny, igt-dev
  Cc: Ankit Nautiyal, Ashutosh Dixit, Karthik B S, Kamil Konieczny

Jani Nikula <jani.nikula@intel.com> writes:

> On Fri, 15 May 2026, Gustavo Sousa <gustavo.sousa@intel.com> wrote:
>> 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.
>
> It's just a starting point to not go through the entire history. It'll
> find the matching commit after that. It's sufficient to update SINCE
> when it gets too slow.

Makes sense. I guess we could add a comment so that people are aware
that we don't need to update this constantly.

>
>> 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".
>
> Fair; I originally wrote this for myself.
>
>>> +
>>> +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
>
> This is the bit that finds the last matching commit.
>
>>> +
>>> +	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?
>
> I wrote this at a time when I'd done a lot of refactoring kernel
> side. When each of those kernel changes needed corresponding IGT changes
> *outside* of the files being synced, it was tremendously helpful to
> split it to smaller changes.

Ah. Got it.

>
> If there's no such need, you can trivially manually squash them with git
> rebase -i, but I think it's helpful for the script to do individual
> changes.

Sounds good.

--
Gustavo Sousa

>
>>
>>> +		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 ...".
>
> Fair.
>
> BR,
> Jani.
>
>>
>> --
>> Gustavo Sousa
>>
>>> +		    -m "${prefix}: sync ${base} with kernel commit $commit" \
>>> +		    -m "Synchronize ${base} with kernel commit:" \
>>> +		    -m "$ref"
>>> +		cd -
>>> +	done
>>> +done
>>> -- 
>>> 2.54.0
>
> -- 
> Jani Nikula, Intel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-05-15 15:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2026-05-15 14:53   ` Jani Nikula
2026-05-15 15:39     ` Gustavo Sousa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox