summaryrefslogtreecommitdiff
path: root/portingBetweenAmdgpuAndRadeon.mdwn
blob: 8f0d9a84b86371db587839a357b65657d12be09a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
This page describes how changes can be ported between xf86-video-amdgpu and xf86-video-ati, preserving the original changes as much as possible. This is important because it makes it easy to compare the Git histories of the two drivers.

The examples below are for porting a change from amdgpu to radeon. When porting in the opposite direction, the steps have to be adapted accordingly.


[[!toc ]]


## Adding the other driver's repository as a remote

[[!format txt """
git remote add amdgpu git://anongit.freedesktop.org/xorg/driver/xf86-video-amdgpu
"""]]


## Looking at the changes available in the other driver's repository

[[!format txt """
gitk ..amdgpu/master &
"""]]


## Trying to cherry pick a change to be ported

[[!format txt """
git cherry-pick -x <commit>
"""]]

At the very least, this should create a commit with the original log and other metadata of the original commit preserved.
It may also manage to actually apply some parts of the original change to the code, though it'll usually need to be fixed up
manually, e.g. to convert identifiers between amdgpu/radeon.

Get rid of files which only exist in the other driver's repository:

[[!format txt """
git rm src/amdgpu_*
"""]]

## Porting the rest of the changes

Create a temporary patch file for the original change:

[[!format txt """
git show <commit> >/tmp/<commit>.diff
"""]]

Remove any hunks which were already applied by git cherry-pick. The following scripts may be helpful for converting at least some of the remaining hunks:

> <https://people.freedesktop.org/~daenzer/convert-patch-amdgpu-radeon-untabify.sh>

> <https://people.freedesktop.org/~daenzer/convert-patch-amdgpu-radeon.sh>

> <https://people.freedesktop.org/~daenzer/convert-patch-radeon-amdgpu-tabify.sh>

> <https://people.freedesktop.org/~daenzer/convert-patch-radeon-amdgpu.sh>

For example:

[[!format txt """
convert-patch-amdgpu-radeon.sh </tmp/<commit>.diff | patch -p1 --dry-run
"""]]

(remove --dry-run to actually apply the converted changes)

For hunks which don't apply directly after conversion by a script, one can compare the patch file and the code it should apply to side by side. There are two possible strategies from there:

* Tweak the patch file until it can be applied after conversion by a script
* Apply the changes to the code manually

Choose the better strategy on a hunk by hunk basis.


## Amending the commit log

Once all hunks have been ported and the resulting code compiles without warnings and works, 

[[!format txt """
git add <any files with conflicts from git cherry-pick>
git commit --amend
"""]]

In order to link the ported change to the original one, the commit log should be amended with something like:

[[!format txt """
(Ported from amdgpu commit <commit>)
Signed-off-by: <name and e-mail of person who ported the change>
"""]]