Todd Kjos | f8978f4 | 2019-10-24 17:07:24 -0700 | [diff] [blame] | 1 | # How do I submit patches to Android Common Kernels |
| 2 | |
| 3 | 1. BEST: Make all of your changes to upstream Linux. If appropriate, backport to the stable releases. |
| 4 | These patches will be merged automatically in the corresponding common kernels. If the patch is already |
| 5 | in upstream Linux, post a backport of the patch that conforms to the patch requirements below. |
Todd Kjos | 2f886a6 | 2019-12-12 11:36:29 -0800 | [diff] [blame] | 6 | - Do not send patches upstream that contain only symbol exports. To be considered for upstream Linux, |
| 7 | additions of `EXPORT_SYMBOL_GPL()` require an in-tree modular driver that uses the symbol -- so include |
| 8 | the new driver or changes to an existing driver in the same patchset as the export. |
| 9 | - When sending patches upstream, the commit message must contain a clear case for why the patch |
| 10 | is needed and beneficial to the community. Enabling out-of-tree drivers or functionality is not |
Eric Biggers | c0a7947 | 2023-07-08 00:10:20 +0000 | [diff] [blame] | 11 | a persuasive case. |
Todd Kjos | f8978f4 | 2019-10-24 17:07:24 -0700 | [diff] [blame] | 12 | |
| 13 | 2. LESS GOOD: Develop your patches out-of-tree (from an upstream Linux point-of-view). Unless these are |
| 14 | fixing an Android-specific bug, these are very unlikely to be accepted unless they have been |
| 15 | coordinated with kernel-team@android.com. If you want to proceed, post a patch that conforms to the |
| 16 | patch requirements below. |
| 17 | |
| 18 | # Common Kernel patch requirements |
| 19 | |
Carlos Llamas | 3b3f474 | 2021-04-07 23:11:23 +0000 | [diff] [blame] | 20 | - All patches must conform to the Linux kernel coding standards and pass `scripts/checkpatch.pl` |
Todd Kjos | f8978f4 | 2019-10-24 17:07:24 -0700 | [diff] [blame] | 21 | - Patches shall not break gki_defconfig or allmodconfig builds for arm, arm64, x86, x86_64 architectures |
| 22 | (see https://source.android.com/setup/build/building-kernels) |
| 23 | - If the patch is not merged from an upstream branch, the subject must be tagged with the type of patch: |
| 24 | `UPSTREAM:`, `BACKPORT:`, `FROMGIT:`, `FROMLIST:`, or `ANDROID:`. |
| 25 | - All patches must have a `Change-Id:` tag (see https://gerrit-review.googlesource.com/Documentation/user-changeid.html) |
| 26 | - If an Android bug has been assigned, there must be a `Bug:` tag. |
| 27 | - All patches must have a `Signed-off-by:` tag by the author and the submitter |
| 28 | |
| 29 | Additional requirements are listed below based on patch type |
| 30 | |
| 31 | ## Requirements for backports from mainline Linux: `UPSTREAM:`, `BACKPORT:` |
| 32 | |
| 33 | - If the patch is a cherry-pick from Linux mainline with no changes at all |
| 34 | - tag the patch subject with `UPSTREAM:`. |
Matthias Maennich | 21ec9a7 | 2019-12-03 08:03:21 +0000 | [diff] [blame] | 35 | - add upstream commit information with a `(cherry picked from commit ...)` line |
Yongqin Liu | 8ad9aa94 | 2024-07-25 12:43:19 +0800 | [diff] [blame] | 36 | - if applicable, prefer to cherry-pick the commit from the corresponding LTS branch. |
Yongqin Liu | 6dfa553 | 2024-07-25 13:02:51 +0800 | [diff] [blame] | 37 | - append new signature tags (e.g. `Bug:`, `Change-Id:`, etc.) at the end to keep the |
| 38 | chronological order. |
Todd Kjos | f8978f4 | 2019-10-24 17:07:24 -0700 | [diff] [blame] | 39 | - Example: |
| 40 | - if the upstream commit message is |
| 41 | ``` |
| 42 | important patch from upstream |
| 43 | |
| 44 | This is the detailed description of the important patch |
| 45 | |
| 46 | Signed-off-by: Fred Jones <fred.jones@foo.org> |
| 47 | ``` |
Todd Kjos | 21578d5 | 2019-12-12 10:57:32 -0800 | [diff] [blame] | 48 | >- then Joe Smith would upload the patch for the common kernel as |
Todd Kjos | f8978f4 | 2019-10-24 17:07:24 -0700 | [diff] [blame] | 49 | ``` |
| 50 | UPSTREAM: important patch from upstream |
| 51 | |
| 52 | This is the detailed description of the important patch |
| 53 | |
| 54 | Signed-off-by: Fred Jones <fred.jones@foo.org> |
| 55 | |
| 56 | Bug: 135791357 |
| 57 | Change-Id: I4caaaa566ea080fa148c5e768bb1a0b6f7201c01 |
Matthias Maennich | 21ec9a7 | 2019-12-03 08:03:21 +0000 | [diff] [blame] | 58 | (cherry picked from commit c31e73121f4c1ec41143423ac6ce3ce6dafdcec1) |
Todd Kjos | f8978f4 | 2019-10-24 17:07:24 -0700 | [diff] [blame] | 59 | Signed-off-by: Joe Smith <joe.smith@foo.org> |
| 60 | ``` |
| 61 | |
| 62 | - If the patch requires any changes from the upstream version, tag the patch with `BACKPORT:` |
| 63 | instead of `UPSTREAM:`. |
| 64 | - use the same tags as `UPSTREAM:` |
Matthias Maennich | 21ec9a7 | 2019-12-03 08:03:21 +0000 | [diff] [blame] | 65 | - add comments about the changes under the `(cherry picked from commit ...)` line |
Todd Kjos | f8978f4 | 2019-10-24 17:07:24 -0700 | [diff] [blame] | 66 | - Example: |
| 67 | ``` |
| 68 | BACKPORT: important patch from upstream |
| 69 | |
| 70 | This is the detailed description of the important patch |
| 71 | |
| 72 | Signed-off-by: Fred Jones <fred.jones@foo.org> |
| 73 | |
| 74 | Bug: 135791357 |
| 75 | Change-Id: I4caaaa566ea080fa148c5e768bb1a0b6f7201c01 |
Matthias Maennich | 21ec9a7 | 2019-12-03 08:03:21 +0000 | [diff] [blame] | 76 | (cherry picked from commit c31e73121f4c1ec41143423ac6ce3ce6dafdcec1) |
Matthias Maennich | cba941a | 2020-01-08 15:11:06 +0000 | [diff] [blame] | 77 | [joe: Resolved minor conflict in drivers/foo/bar.c ] |
Todd Kjos | f8978f4 | 2019-10-24 17:07:24 -0700 | [diff] [blame] | 78 | Signed-off-by: Joe Smith <joe.smith@foo.org> |
| 79 | ``` |
| 80 | |
| 81 | ## Requirements for other backports: `FROMGIT:`, `FROMLIST:`, |
| 82 | |
| 83 | - If the patch has been merged into an upstream maintainer tree, but has not yet |
| 84 | been merged into Linux mainline |
| 85 | - tag the patch subject with `FROMGIT:` |
| 86 | - add info on where the patch came from as `(cherry picked from commit <sha1> <repo> <branch>)`. This |
| 87 | must be a stable maintainer branch (not rebased, so don't use `linux-next` for example). |
| 88 | - if changes were required, use `BACKPORT: FROMGIT:` |
| 89 | - Example: |
| 90 | - if the commit message in the maintainer tree is |
| 91 | ``` |
| 92 | important patch from upstream |
| 93 | |
| 94 | This is the detailed description of the important patch |
| 95 | |
| 96 | Signed-off-by: Fred Jones <fred.jones@foo.org> |
| 97 | ``` |
Todd Kjos | 21578d5 | 2019-12-12 10:57:32 -0800 | [diff] [blame] | 98 | >- then Joe Smith would upload the patch for the common kernel as |
Todd Kjos | f8978f4 | 2019-10-24 17:07:24 -0700 | [diff] [blame] | 99 | ``` |
| 100 | FROMGIT: important patch from upstream |
| 101 | |
| 102 | This is the detailed description of the important patch |
| 103 | |
| 104 | Signed-off-by: Fred Jones <fred.jones@foo.org> |
| 105 | |
| 106 | Bug: 135791357 |
| 107 | (cherry picked from commit 878a2fd9de10b03d11d2f622250285c7e63deace |
| 108 | https://git.kernel.org/pub/scm/linux/kernel/git/foo/bar.git test-branch) |
| 109 | Change-Id: I4caaaa566ea080fa148c5e768bb1a0b6f7201c01 |
| 110 | Signed-off-by: Joe Smith <joe.smith@foo.org> |
| 111 | ``` |
| 112 | |
| 113 | |
| 114 | - If the patch has been submitted to LKML, but not accepted into any maintainer tree |
| 115 | - tag the patch subject with `FROMLIST:` |
Matthias Maennich | 511b851 | 2019-10-28 23:46:05 +0000 | [diff] [blame] | 116 | - add a `Link:` tag with a link to the submittal on lore.kernel.org |
Todd Kjos | 9794e7e | 2020-05-01 13:43:26 -0700 | [diff] [blame] | 117 | - add a `Bug:` tag with the Android bug (required for patches not accepted into |
| 118 | a maintainer tree) |
Todd Kjos | f8978f4 | 2019-10-24 17:07:24 -0700 | [diff] [blame] | 119 | - if changes were required, use `BACKPORT: FROMLIST:` |
| 120 | - Example: |
| 121 | ``` |
| 122 | FROMLIST: important patch from upstream |
| 123 | |
| 124 | This is the detailed description of the important patch |
| 125 | |
| 126 | Signed-off-by: Fred Jones <fred.jones@foo.org> |
| 127 | |
| 128 | Bug: 135791357 |
| 129 | Link: https://lore.kernel.org/lkml/20190619171517.GA17557@someone.com/ |
| 130 | Change-Id: I4caaaa566ea080fa148c5e768bb1a0b6f7201c01 |
| 131 | Signed-off-by: Joe Smith <joe.smith@foo.org> |
| 132 | ``` |
| 133 | |
Greg Kroah-Hartman | 748f075 | 2025-01-24 07:42:15 +0100 | [diff] [blame] | 134 | - If a patch has been submitted to the community, but rejected, do NOT use the |
| 135 | `FROMLIST:` tag to try to hide this fact. Use the `ANDROID:` tag as |
| 136 | described below as this must be considered as an Android-specific submission, |
| 137 | not an upstream submission as the community will not accept these changes |
| 138 | as-is. |
| 139 | |
Todd Kjos | f8978f4 | 2019-10-24 17:07:24 -0700 | [diff] [blame] | 140 | ## Requirements for Android-specific patches: `ANDROID:` |
| 141 | |
| 142 | - If the patch is fixing a bug to Android-specific code |
| 143 | - tag the patch subject with `ANDROID:` |
| 144 | - add a `Fixes:` tag that cites the patch with the bug |
| 145 | - Example: |
| 146 | ``` |
| 147 | ANDROID: fix android-specific bug in foobar.c |
| 148 | |
| 149 | This is the detailed description of the important fix |
| 150 | |
| 151 | Fixes: 1234abcd2468 ("foobar: add cool feature") |
| 152 | Change-Id: I4caaaa566ea080fa148c5e768bb1a0b6f7201c01 |
| 153 | Signed-off-by: Joe Smith <joe.smith@foo.org> |
| 154 | ``` |
| 155 | |
| 156 | - If the patch is a new feature |
| 157 | - tag the patch subject with `ANDROID:` |
| 158 | - add a `Bug:` tag with the Android bug (required for android-specific features) |
| 159 | |