blob: 9308f428bbdb2e762457666cb7380fd87220feee [file] [log] [blame]
Simon Glass37c42b72022-08-09 13:49:57 -06001.. SPDX-License-Identifier: GPL-2.0+
2
3Sending patches
4===============
5
Tom Rini6349b182022-08-29 12:59:33 -04006*Before you begin* to implement any new ideas or concepts it is always a good
7idea to present your plans on the `U-Boot mailing list
8<https://lists.denx.de/listinfo/u-boot>`_. U-Boot supports a huge amount of
9very different systems, and it is often impossible for the individual developer
10to oversee the consequences of a specific change to all architectures.
11Discussing concepts early can help you to avoid spending effort on code which,
12when submitted as a patch, might be rejected and/or will need lots of rework
13because it does not fit for some reason. Early peer review is an important
Tom Rini286ed782022-08-29 12:59:34 -040014resource - use it. Being familiar with the :doc:`process` is also important.
Simon Glass37c42b72022-08-09 13:49:57 -060015
Tom Rini6349b182022-08-29 12:59:33 -040016A good introduction how to prepare for submitting patches can be found in the
17LWN article `How to Get Your Change Into the Linux Kernel
18<http://lwn.net/Articles/139918/>`_ as the same rules apply to U-Boot, too.
Simon Glass37c42b72022-08-09 13:49:57 -060019
Tom Rini6349b182022-08-29 12:59:33 -040020Using patman
21------------
Simon Glass37c42b72022-08-09 13:49:57 -060022
Maxim Cournoyere7d962b2022-12-16 21:09:40 -050023You can use a tool called patman to prepare, check and send patches. It creates
24change logs, cover letters and patch notes. It also simplifies the process of
Simon Glass37c42b72022-08-09 13:49:57 -060025sending multiple versions of a series.
26
27See more details at :doc:`patman`.
Tom Rini6349b182022-08-29 12:59:33 -040028
29General Patch Submission Rules
30------------------------------
31
32* All patches must be sent to the `u-boot@lists.denx.de
33 <https://lists.denx.de/listinfo/u-boot>`_ mailing list.
34
35* If your patch affects the code maintained by one of the :ref:`custodians`, CC
36 them when emailing your patch. The easiest way to make sure you don't forget
37 this even when you resubmit the patch later is to add a ``Cc: name
38 <address>`` line after your ``Signed-off-by:`` line (see the example below).
39
40* Take a look at the commit logs of the files you are modifying. Authors of
41 past commits might have input to your change, so also CC them if you think
42 they may have feedback.
43
Maxim Cournoyere7d962b2022-12-16 21:09:40 -050044* Patches should always contain exactly one complete logical change, i.e.
Tom Rini6349b182022-08-29 12:59:33 -040045
46 * Changes that contain different, unrelated modifications shall be submitted
47 as *separate* patches, one patch per changeset.
48
49 * If one logical set of modifications affects or creates several files, all
50 these changes shall be submitted in a *single* patch.
51
52* Non-functional changes, i.e. whitespace and reformatting changes, should be
53 done in separate patches marked as ``cosmetic``. This separation of functional
54 and cosmetic changes greatly facilitates the review process.
55
Tom Rini286ed782022-08-29 12:59:34 -040056* Some comments on running :doc:`checkpatch.pl <checkpatch>`:
Tom Rini6349b182022-08-29 12:59:33 -040057
58 * Checkpatch is a tool that can help you find some style problems, but is
59 imperfect, and the things it complains about are of varying importance.
60 So use common sense in interpreting the results.
61
62 * Warnings that clearly only make sense in the Linux kernel can be ignored.
63 This includes ``Use #include <linux/$file> instead of <asm/$file>`` for
64 example.
65
66 * If you encounter warnings for existing code, not modified by your patch,
67 consider submitting a separate, cosmetic-only patch -- clearly described
68 as such -- that *precedes* your substantive patch.
69
70 * For minor modifications (e.g. changed arguments of a function call),
Maxim Cournoyere7d962b2022-12-16 21:09:40 -050071 adhere to the present coding style of the module. Relating checkpatch
Tom Rini6349b182022-08-29 12:59:33 -040072 warnings can be ignored in this case. A respective note in the commit or
73 cover letter why they are ignored is desired.
74
75* Send your patches as plain text messages: no HTML, no MIME, no links, no
Tom Rini85deb7f2024-08-26 10:39:17 -060076 compression, no attachments. Just plain text. The best way to generate
77 patches is by using the ``git format-patch`` command. For a patch that is
78 fixing a bug or regression of some sort, please use the ``master`` branch of
79 the mainline U-Boot git repository
80 (``https://source.denx.de/u-boot/u-boot.git``) as reference. For new
81 features, if the ``next`` branch has been opened (which happens with the
82 release of ``-rc2``) that branch should be used, otherwise ``master`` is
83 acceptable.
Tom Rini6349b182022-08-29 12:59:33 -040084
85* Make sure that your mailer does not mangle the patch by automatic changes
86 like wrapping of longer lines etc.
87 The best way to send patches is by not using your regular mail tool, but by
88 using either ``git send-email`` or the ``git imap-send`` command instead.
89 If you believe you need to use a mailing list for testing (instead of any
90 regular mail address you own), we have a special test list for such purposes.
91 It would be best to subscribe to the list for the duration of your tests to
92 avoid repeated moderation - see https://lists.denx.de/listinfo/test
93
94* Choose a meaningful Subject: - keep in mind that the Subject will also be
95 visible as headline of your commit message. Make sure the subject does not
96 exceed 60 characters or so.
97
Maxim Cournoyere7d962b2022-12-16 21:09:40 -050098* The start of the subject should be a meaningful tag (arm:, ppc:, tegra:,
Tom Rini6349b182022-08-29 12:59:33 -040099 net:, ext2:, etc)
100
101* Include the string "PATCH" in the Subject: line of your message, e. g.
102 "[PATCH] Add support for feature X". ``git format-patch`` should automatically
103 do this.
104
105* If you are sending a patch series composed of multiple patches, make sure
106 their titles clearly state the patch order and total number of patches (``git
107 format-patch -n``). Also, often times an introductory email describing what
108 the patchset does is useful (``git format-patch -n --cover-letter``). As an
109 example::
110
111 [PATCH 0/3] Add support for new SuperCPU2000
112 (This email does not contain a patch, just a description)
113 [PATCH 1/3] Add core support for SuperCPU2000
114 [PATCH 2/3] Add support for SuperCPU2000's on-chip I2C controller
115 [PATCH 3/3] Add support for SuperCPU2000's on-chip UART
116
117* In the message body, include a description of your changes.
118
119 * For bug fixes: a description of the bug and how your patch fixes this bug.
120 Please try to include a way of demonstrating that the patch actually fixes
121 something.
122
123 * For new features: a description of the feature and your implementation.
124
125* Additional comments which you don't want included in U-Boot's history can be
Grzegorz Szymaszek753f76e2024-01-06 11:36:54 +0100126 included below the first "``---``" in the message body.
Tom Rini6349b182022-08-29 12:59:33 -0400127
128* If your description gets too long, that's a strong indication that you should
129 split up your patch.
130
131* Remember that there is a size limit of 100 kB on the mailing list. In most
132 cases, you did something wrong if your patch exceeds this limit. Think again
133 if you should not split it into separate logical parts.
134
135Attributing Code, Copyrights, Signing
136-------------------------------------
137
138* Sign your changes, i. e. add a *Signed-off-by:* line to the message body.
Tom Rini286ed782022-08-29 12:59:34 -0400139 This can be automated by using ``git commit -s``. Please see the
140 :ref:`Developer Certificate of Origin <dco>` section for more details here.
Tom Rini6349b182022-08-29 12:59:33 -0400141
142* If you change or add *significant* parts to a file, then please make sure to
143 add your copyright to that file, for example like this::
144
145 (C) Copyright 2010 Joe Hacker <jh@hackers.paradise.com>
146
147 Please do *not* include a detailed description of your
148 changes. We use the *git* commit messages for this purpose.
149
150* If you add new files, please always make sure that these contain your
151 copyright note and a GPLv2+ SPDX-License-Identifier, for example like this::
152
153 (C) Copyright 2010 Joe Hacker <jh@hackers.paradise.com>
154
155 SPDX-License-Identifier:<TAB>GPL-2.0+
156
157* If you are copying or adapting code from other projects, like the Linux
158 kernel, or BusyBox, or similar, please make sure to state clearly where you
159 copied the code from, and provide terse but precise information which exact
160 version or even commit ID was used. Follow the ideas of this note from the
161 Linux "SubmittingPatches" document::
162
163 Special note to back-porters: It seems to be a common and useful practice
164 to insert an indication of the origin of a patch at the top of the commit
165 message (just after the subject line) to facilitate tracking. For instance,
166 here's what we see in 2.6-stable :
167
168 Date: Tue May 13 19:10:30 2008 +0000
169
170 SCSI: libiscsi regression in 2.6.25: fix nop timer handling
171
172 commit 4cf1043593db6a337f10e006c23c69e5fc93e722 upstream
173
174 And here's what appears in 2.4 :
175
176 Date: Tue May 13 22:12:27 2008 +0200
177
178 wireless, airo: waitbusy() won't delay
179
180 [backport of 2.6 commit b7acbdfbd1f277c1eb23f344f899cfa4cd0bf36a]
181
182Whatever the format, this information provides a valuable help to people
183tracking your trees, and to people trying to trouble-shoot bugs in your
184tree.
185
186Commit message conventions
187--------------------------
188
189Please adhere to the following conventions when writing your commit
190log messages.
191
192* The first line of the log message is the summary line. Keep this less than 70
193 characters long.
194
195* Don't use periods to end the summary line (e.g., don't do "Add support for
196 X.")
197
198* Use the present tense in your summary line (e.g., "Add support for X" rather
199 than "Added support for X"). Furthermore, use the present tense in your log
200 message to describe what the patch is doing. This isn't a strict rule -- it's
201 OK to use the past tense for describing things that were happening in the old
202 code for example.
203
204* Use the imperative tense in your summary line (e.g., "Add support for X"
205 rather than "Adds support for X"). In general, you can think of the summary
206 line as "this commit is meant to 'Add support for X'"
207
208* If applicable, prefix the summary line with a word describing what area of
209 code is being affected followed by a colon. This is a standard adopted by
210 both U-Boot and Linux. For example, if your change affects all mpc85xx
211 boards, prefix your summary line with "mpc85xx:". If your change affects the
212 PCI common code, prefix your summary line with "pci:". The best thing to do
213 is look at the "git log <file>" output to see what others have done so you
214 don't break conventions.
215
216* Insert a blank line after the summary line
217
218* For bug fixes, it's good practice to briefly describe how things behaved
219 before this commit
220
221* Put a detailed description after the summary and blank line. If the summary
222 line is sufficient to describe the change (e.g. it is a trivial spelling
223 correction or whitespace update), you can omit the blank line and detailed
224 description.
225
226* End your log message with S.O.B. (Signed-off-by) line. This is done
Tom Rini286ed782022-08-29 12:59:34 -0400227 automatically when you use ``git commit -s``. Please see the
228 :ref:`Developer Certificate of Origin <dco>` section for more details here.
Tom Rini6349b182022-08-29 12:59:33 -0400229
230* Keep EVERY line under 72 characters. That is, your message should be
231 line-wrapped with line-feeds. However, don't get carried away and wrap it too
232 short either since this also looks funny.
233
234* Detail level: The audience of the commit log message that you should cater to
235 is those familiar with the underlying source code you are modifying, but who
236 are _not_ familiar with the patch you are submitting. They should be able to
237 determine what is being changed and why. Avoid excessive low-level detail.
238 Before submitting, re-read your commit log message with this audience in mind
239 and adjust as needed.
240
241Sending updated patch versions
242------------------------------
243
244It is pretty normal that the first version of a patch you are submitting does
245not get accepted as is, and that you are asked to submit another, improved
246version.
247
248When re-posting such a new version of your patch(es), please always make sure
249to observe the following rules.
250
251* Make an appropriate note that this is a re-submission in the subject line,
Maxim Cournoyere7d962b2022-12-16 21:09:40 -0500252 e.g. "[PATCH v2] Add support for feature X". ``git format-patch
Tom Rini6349b182022-08-29 12:59:33 -0400253 --subject-prefix="PATCH v2"`` can be used in this case (see the example
254 below).
255
Maxim Cournoyere7d962b2022-12-16 21:09:40 -0500256* Please make sure to keep a "change log", i.e. a description of what you have
Tom Rini6349b182022-08-29 12:59:33 -0400257 changed compared to previous versions of this patch. This change log should
Grzegorz Szymaszek753f76e2024-01-06 11:36:54 +0100258 be added below the "``---``" line in the patch, which starts the "comment
Maxim Cournoyere7d962b2022-12-16 21:09:40 -0500259 section", i.e. which contains text that does not get included into the
Tom Rini6349b182022-08-29 12:59:33 -0400260 actual commit message.
261 Note: it is *not* sufficient to provide a change log in some cover letter
262 that gets sent as a separate message with the patch series. The reason is
263 that such cover letters are not as easily reviewed in our `patchwork queue
264 <http://patchwork.ozlabs.org/project/uboot/list/>`_ so they are not helpful
265 to any reviewers using this tool. Example::
266
267 From: Joe Hacker <jh@hackers.paradise.com>
268 Date: Thu, 1 Jan 2222 12:21:22 +0200
269 Subject: [PATCH 1/2 v3] FOO: add timewarp-support
270
271 This patch adds timewarp-support for the FOO family of processors.
272
273 adapted for the current kernel structures.
274
275 Signed-off-by: Joe Hacker <jh@hackers.paradise.com>
276 Cc: Tom Maintainer <tm@u-boot.custodians.org>
277 ---
278 Changes for v2:
279 - Coding Style cleanup
280 - fixed miscalculation of time-space discontinuities
281 Changes for v3:
282 - fixed compiler warnings observed with GCC-17.3.5
283 - worked around integer overflow in warp driver
284
285 arch/foo/cpu/spacetime.c | 8 +
286 drivers/warp/Kconfig | 7 +
287 drivers/warp/Makefile | 42 +++
288 drivers/warp/warp-core.c | 255 +++++++++++++++++++++++++
289
290* Make sure that your mailer adds or keeps correct ``In-reply-to:`` and
291 ``References:`` headers, so threading of messages is working and everybody
292 can see that the new message refers to some older posting of the same topic.
293
294Uncommented and un-threaded repostings are extremely annoying and
295time-consuming, as we have to try to remember if anything similar has been
296posted before, look up the old threads, and then manually compare if anything
297has been changed, or what.
298
299If you have problems with your e-mail client, for example because it mangles
300white space or wraps long lines, then please read this article about `Email
301Clients and Patches <http://kerneltrap.org/Linux/Email_Clients_and_Patches>`_.
302
303Notes
304-----
305
3061. U-Boot is Free Software that can redistributed and/or modified under the
307 terms of the `GNU General Public License
Tom Rini286ed782022-08-29 12:59:34 -0400308 <http://www.fsf.org/licensing/licenses/gpl.html>`_ (GPL). Currently (August
309 2022) version 2 of the GPL applies. Please see :download:`Licensing
Tom Rini6349b182022-08-29 12:59:33 -0400310 <../../Licenses/README>` for details. To allow that later versions of U-Boot
311 may be released under a later version of the GPL, all new code that gets
312 added to U-Boot shall use a "GPL-2.0+" SPDX-License-Identifier.
313
3142. All code must follow the :doc:`codingstyle` requirements.
315
Tom Rini286ed782022-08-29 12:59:34 -04003163. Before sending the patch, you *must* run some form of local testing.
Maxim Cournoyere7d962b2022-12-16 21:09:40 -0500317 Submitting a patch that does not build or function correctly is a mistake. For
Tom Rini286ed782022-08-29 12:59:34 -0400318 non-trivial patches, either building a number of platforms locally or making
319 use of :doc:`ci_testing` is strongly encouraged in order to avoid problems
320 that can be found when attempting to merge the patch.
Tom Rini6349b182022-08-29 12:59:33 -0400321
3224. If you modify existing code, make sure that your new code does not add to
323 the memory footprint of the code. Remember: Small is beautiful! When adding
Tom Rini286ed782022-08-29 12:59:34 -0400324 new features follow the guidelines laid out in :doc:`system_configuration`.
Tom Rini6349b182022-08-29 12:59:33 -0400325
326Patch Tracking
327--------------
328
Tom Rini286ed782022-08-29 12:59:34 -0400329Like some other projects, U-Boot uses `Patchwork <http://patchwork.ozlabs.org/>`_
Tom Rini6349b182022-08-29 12:59:33 -0400330to track the state of patches. This is one of the reasons why it is mandatory
331to submit all patches to the U-Boot mailing list - only then they will be
332picked up by patchwork.
333
334At http://patchwork.ozlabs.org/project/uboot/list/ you can find the list of
335open U-Boot patches. By using the "Filters" link (Note: requires JavaScript)
336you can also select other views, for example, to include old patches that have,
337for example, already been applied or rejected.
338
Tom Rini286ed782022-08-29 12:59:34 -0400339Note that Patchwork automatically tracks and collects a number of git tags from
340follow-up mails, so it is usually better to apply a patch through the Patchwork
341commandline interface than just manually applying it from a posting on the
342mailing list (in which case you have to do all the tracking and adding of git
343tags yourself). This also obviates the need of a developer to resubmit a patch
344only in order to collect these tags.
345
Tom Rini6349b182022-08-29 12:59:33 -0400346A Custodian has additional privileges and can:
347
348* **Delegate** a patch
349
350* **Change the state** of a patch. The following states exist:
351
352 * New
353
354 * Under Review
355
356 * Accepted
357
358 * Rejected
359
360 * RFC
361
362 * Not Applicable
363
364 * Changes Requested
365
366 * Awaiting Upstream
367
Mattijs Korpershoek1e8a8f32023-11-21 17:27:38 +0100368 * Superseded
Tom Rini6349b182022-08-29 12:59:33 -0400369
370 * Deferred
371
372 * Archived
373
374Patchwork work-flow
375^^^^^^^^^^^^^^^^^^^
376
Tom Rini286ed782022-08-29 12:59:34 -0400377The following are a "rule of thumb" as to how the states are used in patchwork
378today. Not all states are used by all custodians.
Tom Rini6349b182022-08-29 12:59:33 -0400379
380* New: Patch has been submitted to the list, and none of the maintainers has
381 changed it's state since.
382
Tom Rini286ed782022-08-29 12:59:34 -0400383* Under Review: A custodian is reviewing the patch currently.
Tom Rini6349b182022-08-29 12:59:33 -0400384
385* Accepted: When a patch has been applied to a custodian repository that gets
386 used for pulling from into upstream, they are put into "accepted" state.
387
388* Rejected: Rejected means we just don't want to do what the patch does.
389
390* RFC: The patch is not intended to be applied to any of the mainline
391 repositories, but merely for discussing or testing some idea or new feature.
392
Tom Rini286ed782022-08-29 12:59:34 -0400393* Not Applicable: The patch either was not intended to be applied, as it was
394 a debugging or discussion aide that patchwork picked up, or was cross-posted
395 to our list but intended for another project entirely.
Tom Rini6349b182022-08-29 12:59:33 -0400396
397* Changes Requested: The patch looks mostly OK, but requires some rework before
398 it will be accepted for mainline.
399
Tom Rini286ed782022-08-29 12:59:34 -0400400* Awaiting Upstream: A custodian may have applied this to the ``next`` branch
401 and has not merged yet to master, or has queued the patch up to be submitted
402 to be merged, but has not yet.
Tom Rini6349b182022-08-29 12:59:33 -0400403
Mattijs Korpershoek1e8a8f32023-11-21 17:27:38 +0100404* Superseded: Patches are marked as 'superseded' when the poster submits a
Tom Rini6349b182022-08-29 12:59:33 -0400405 new version of these patches.
406
407* Deferred: Deferred usually means the patch depends on something else that
408 isn't upstream, such as patches that only apply against some specific other
Tom Rini286ed782022-08-29 12:59:34 -0400409 repository. This is also used when a patch has been in patchwork for over a
410 year and it is unlikely to be applied as-is.
Tom Rini6349b182022-08-29 12:59:33 -0400411
412* Archived: Archiving puts the patch away somewhere where it doesn't appear in
413 the normal pages and needs extra effort to get to.
414
Tom Rini6349b182022-08-29 12:59:33 -0400415Apply patches
416^^^^^^^^^^^^^
417
418To apply a patch from the `patchwork queue
419<http://patchwork.ozlabs.org/project/uboot/list/>`_ using ``git``, download the
420mbox file and apply it using::
421
422 git am file
423
424The `openembedded wiki <http://wiki.openembedded.net/>`_ also provides a script
425named `pw-am.sh
426<http://cgit.openembedded.org/cgit.cgi/openembedded/tree/contrib/patchwork/pw-am.sh>`_
427which can be used to fetch an 'mbox' patch from patchwork and git am it::
428
429 usage: pw-am.sh <number>
430 example: 'pw-am.sh 71002' will get and apply the patch from http://patchwork.ozlabs.org/patch/71002/
431
432Update the state of patches
433^^^^^^^^^^^^^^^^^^^^^^^^^^^
434
435You have to register to be able to update the state of patches. You can use the
436Web interface, `pwclient`, or `pwparser`.
437
438pwclient
439^^^^^^^^
440
441The `pwclient` command line tool can be used for example to retrieve patches,
442search the queue or update the state.
443
444All necessary information for `pwclient` is linked from the bottom of
445http://patchwork.ozlabs.org/project/uboot/
446
447Use::
448
449 pwclient help
450
451for an overview on how to use it.
452
453pwparser
454^^^^^^^^
455
456See http://www.mail-archive.com/patchwork@lists.ozlabs.org/msg00057.html