blob: e22b5e3e244eac9f7e451781a380caba93f2ab17 [file] [log] [blame]
Simon Glassc8ab0312022-08-09 13:49:57 -06001.. SPDX-License-Identifier: GPL-2.0+
2
3Sending patches
4===============
5
Tom Rini62a2e1d2022-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 Rini0b1f0132022-08-29 12:59:34 -040014resource - use it. Being familiar with the :doc:`process` is also important.
Simon Glassc8ab0312022-08-09 13:49:57 -060015
Tom Rini62a2e1d2022-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 Glassc8ab0312022-08-09 13:49:57 -060019
Tom Rini62a2e1d2022-08-29 12:59:33 -040020Using patman
21------------
Simon Glassc8ab0312022-08-09 13:49:57 -060022
Maxim Cournoyer43228982022-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 Glassc8ab0312022-08-09 13:49:57 -060025sending multiple versions of a series.
26
27See more details at :doc:`patman`.
Tom Rini62a2e1d2022-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 Cournoyer43228982022-12-16 21:09:40 -050044* Patches should always contain exactly one complete logical change, i.e.
Tom Rini62a2e1d2022-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 Rini0b1f0132022-08-29 12:59:34 -040056* Some comments on running :doc:`checkpatch.pl <checkpatch>`:
Tom Rini62a2e1d2022-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 Cournoyer43228982022-12-16 21:09:40 -050071 adhere to the present coding style of the module. Relating checkpatch
Tom Rini62a2e1d2022-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 Rini9babffe2024-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
Tom Rini69e16272024-08-26 11:01:40 -060079 the mainline U-Boot git repository located at
80 https://source.denx.de/u-boot/u-boot.git as reference. For new features, if
81 the ``next`` branch has been opened (which happens with the release of
82 ``-rc2``) that branch should be used, otherwise ``master`` is acceptable.
Tom Rini62a2e1d2022-08-29 12:59:33 -040083
84* Make sure that your mailer does not mangle the patch by automatic changes
85 like wrapping of longer lines etc.
86 The best way to send patches is by not using your regular mail tool, but by
87 using either ``git send-email`` or the ``git imap-send`` command instead.
88 If you believe you need to use a mailing list for testing (instead of any
89 regular mail address you own), we have a special test list for such purposes.
90 It would be best to subscribe to the list for the duration of your tests to
91 avoid repeated moderation - see https://lists.denx.de/listinfo/test
92
93* Choose a meaningful Subject: - keep in mind that the Subject will also be
94 visible as headline of your commit message. Make sure the subject does not
95 exceed 60 characters or so.
96
Maxim Cournoyer43228982022-12-16 21:09:40 -050097* The start of the subject should be a meaningful tag (arm:, ppc:, tegra:,
Tom Rini62a2e1d2022-08-29 12:59:33 -040098 net:, ext2:, etc)
99
100* Include the string "PATCH" in the Subject: line of your message, e. g.
101 "[PATCH] Add support for feature X". ``git format-patch`` should automatically
102 do this.
103
104* If you are sending a patch series composed of multiple patches, make sure
105 their titles clearly state the patch order and total number of patches (``git
106 format-patch -n``). Also, often times an introductory email describing what
107 the patchset does is useful (``git format-patch -n --cover-letter``). As an
108 example::
109
110 [PATCH 0/3] Add support for new SuperCPU2000
111 (This email does not contain a patch, just a description)
112 [PATCH 1/3] Add core support for SuperCPU2000
113 [PATCH 2/3] Add support for SuperCPU2000's on-chip I2C controller
114 [PATCH 3/3] Add support for SuperCPU2000's on-chip UART
115
116* In the message body, include a description of your changes.
117
118 * For bug fixes: a description of the bug and how your patch fixes this bug.
119 Please try to include a way of demonstrating that the patch actually fixes
120 something.
121
122 * For new features: a description of the feature and your implementation.
123
124* Additional comments which you don't want included in U-Boot's history can be
Grzegorz Szymaszek0136a7c2024-01-06 11:36:54 +0100125 included below the first "``---``" in the message body.
Tom Rini62a2e1d2022-08-29 12:59:33 -0400126
127* If your description gets too long, that's a strong indication that you should
128 split up your patch.
129
130* Remember that there is a size limit of 100 kB on the mailing list. In most
131 cases, you did something wrong if your patch exceeds this limit. Think again
132 if you should not split it into separate logical parts.
133
134Attributing Code, Copyrights, Signing
135-------------------------------------
136
137* Sign your changes, i. e. add a *Signed-off-by:* line to the message body.
Tom Rini0b1f0132022-08-29 12:59:34 -0400138 This can be automated by using ``git commit -s``. Please see the
139 :ref:`Developer Certificate of Origin <dco>` section for more details here.
Tom Rini62a2e1d2022-08-29 12:59:33 -0400140
141* If you change or add *significant* parts to a file, then please make sure to
142 add your copyright to that file, for example like this::
143
144 (C) Copyright 2010 Joe Hacker <jh@hackers.paradise.com>
145
146 Please do *not* include a detailed description of your
147 changes. We use the *git* commit messages for this purpose.
148
149* If you add new files, please always make sure that these contain your
150 copyright note and a GPLv2+ SPDX-License-Identifier, for example like this::
151
152 (C) Copyright 2010 Joe Hacker <jh@hackers.paradise.com>
153
154 SPDX-License-Identifier:<TAB>GPL-2.0+
155
156* If you are copying or adapting code from other projects, like the Linux
157 kernel, or BusyBox, or similar, please make sure to state clearly where you
158 copied the code from, and provide terse but precise information which exact
159 version or even commit ID was used. Follow the ideas of this note from the
160 Linux "SubmittingPatches" document::
161
162 Special note to back-porters: It seems to be a common and useful practice
163 to insert an indication of the origin of a patch at the top of the commit
164 message (just after the subject line) to facilitate tracking. For instance,
165 here's what we see in 2.6-stable :
166
167 Date: Tue May 13 19:10:30 2008 +0000
168
169 SCSI: libiscsi regression in 2.6.25: fix nop timer handling
170
171 commit 4cf1043593db6a337f10e006c23c69e5fc93e722 upstream
172
173 And here's what appears in 2.4 :
174
175 Date: Tue May 13 22:12:27 2008 +0200
176
177 wireless, airo: waitbusy() won't delay
178
179 [backport of 2.6 commit b7acbdfbd1f277c1eb23f344f899cfa4cd0bf36a]
180
181Whatever the format, this information provides a valuable help to people
182tracking your trees, and to people trying to trouble-shoot bugs in your
183tree.
184
185Commit message conventions
186--------------------------
187
188Please adhere to the following conventions when writing your commit
189log messages.
190
191* The first line of the log message is the summary line. Keep this less than 70
192 characters long.
193
194* Don't use periods to end the summary line (e.g., don't do "Add support for
195 X.")
196
197* Use the present tense in your summary line (e.g., "Add support for X" rather
198 than "Added support for X"). Furthermore, use the present tense in your log
199 message to describe what the patch is doing. This isn't a strict rule -- it's
200 OK to use the past tense for describing things that were happening in the old
201 code for example.
202
203* Use the imperative tense in your summary line (e.g., "Add support for X"
204 rather than "Adds support for X"). In general, you can think of the summary
205 line as "this commit is meant to 'Add support for X'"
206
207* If applicable, prefix the summary line with a word describing what area of
208 code is being affected followed by a colon. This is a standard adopted by
209 both U-Boot and Linux. For example, if your change affects all mpc85xx
210 boards, prefix your summary line with "mpc85xx:". If your change affects the
211 PCI common code, prefix your summary line with "pci:". The best thing to do
212 is look at the "git log <file>" output to see what others have done so you
213 don't break conventions.
214
215* Insert a blank line after the summary line
216
217* For bug fixes, it's good practice to briefly describe how things behaved
218 before this commit
219
220* Put a detailed description after the summary and blank line. If the summary
221 line is sufficient to describe the change (e.g. it is a trivial spelling
222 correction or whitespace update), you can omit the blank line and detailed
223 description.
224
225* End your log message with S.O.B. (Signed-off-by) line. This is done
Tom Rini0b1f0132022-08-29 12:59:34 -0400226 automatically when you use ``git commit -s``. Please see the
227 :ref:`Developer Certificate of Origin <dco>` section for more details here.
Tom Rini62a2e1d2022-08-29 12:59:33 -0400228
229* Keep EVERY line under 72 characters. That is, your message should be
230 line-wrapped with line-feeds. However, don't get carried away and wrap it too
231 short either since this also looks funny.
232
233* Detail level: The audience of the commit log message that you should cater to
234 is those familiar with the underlying source code you are modifying, but who
235 are _not_ familiar with the patch you are submitting. They should be able to
236 determine what is being changed and why. Avoid excessive low-level detail.
237 Before submitting, re-read your commit log message with this audience in mind
238 and adjust as needed.
239
240Sending updated patch versions
241------------------------------
242
243It is pretty normal that the first version of a patch you are submitting does
244not get accepted as is, and that you are asked to submit another, improved
245version.
246
247When re-posting such a new version of your patch(es), please always make sure
248to observe the following rules.
249
250* Make an appropriate note that this is a re-submission in the subject line,
Maxim Cournoyer43228982022-12-16 21:09:40 -0500251 e.g. "[PATCH v2] Add support for feature X". ``git format-patch
Tom Rini62a2e1d2022-08-29 12:59:33 -0400252 --subject-prefix="PATCH v2"`` can be used in this case (see the example
253 below).
254
Maxim Cournoyer43228982022-12-16 21:09:40 -0500255* Please make sure to keep a "change log", i.e. a description of what you have
Tom Rini62a2e1d2022-08-29 12:59:33 -0400256 changed compared to previous versions of this patch. This change log should
Grzegorz Szymaszek0136a7c2024-01-06 11:36:54 +0100257 be added below the "``---``" line in the patch, which starts the "comment
Maxim Cournoyer43228982022-12-16 21:09:40 -0500258 section", i.e. which contains text that does not get included into the
Tom Rini62a2e1d2022-08-29 12:59:33 -0400259 actual commit message.
260 Note: it is *not* sufficient to provide a change log in some cover letter
261 that gets sent as a separate message with the patch series. The reason is
262 that such cover letters are not as easily reviewed in our `patchwork queue
263 <http://patchwork.ozlabs.org/project/uboot/list/>`_ so they are not helpful
264 to any reviewers using this tool. Example::
265
266 From: Joe Hacker <jh@hackers.paradise.com>
267 Date: Thu, 1 Jan 2222 12:21:22 +0200
268 Subject: [PATCH 1/2 v3] FOO: add timewarp-support
269
270 This patch adds timewarp-support for the FOO family of processors.
271
272 adapted for the current kernel structures.
273
274 Signed-off-by: Joe Hacker <jh@hackers.paradise.com>
275 Cc: Tom Maintainer <tm@u-boot.custodians.org>
276 ---
277 Changes for v2:
278 - Coding Style cleanup
279 - fixed miscalculation of time-space discontinuities
280 Changes for v3:
281 - fixed compiler warnings observed with GCC-17.3.5
282 - worked around integer overflow in warp driver
283
284 arch/foo/cpu/spacetime.c | 8 +
285 drivers/warp/Kconfig | 7 +
286 drivers/warp/Makefile | 42 +++
287 drivers/warp/warp-core.c | 255 +++++++++++++++++++++++++
288
289* Make sure that your mailer adds or keeps correct ``In-reply-to:`` and
290 ``References:`` headers, so threading of messages is working and everybody
291 can see that the new message refers to some older posting of the same topic.
292
293Uncommented and un-threaded repostings are extremely annoying and
294time-consuming, as we have to try to remember if anything similar has been
295posted before, look up the old threads, and then manually compare if anything
296has been changed, or what.
297
298If you have problems with your e-mail client, for example because it mangles
299white space or wraps long lines, then please read this article about `Email
300Clients and Patches <http://kerneltrap.org/Linux/Email_Clients_and_Patches>`_.
301
302Notes
303-----
304
3051. U-Boot is Free Software that can redistributed and/or modified under the
306 terms of the `GNU General Public License
Tom Rini0b1f0132022-08-29 12:59:34 -0400307 <http://www.fsf.org/licensing/licenses/gpl.html>`_ (GPL). Currently (August
308 2022) version 2 of the GPL applies. Please see :download:`Licensing
Tom Rini62a2e1d2022-08-29 12:59:33 -0400309 <../../Licenses/README>` for details. To allow that later versions of U-Boot
310 may be released under a later version of the GPL, all new code that gets
311 added to U-Boot shall use a "GPL-2.0+" SPDX-License-Identifier.
312
3132. All code must follow the :doc:`codingstyle` requirements.
314
Tom Rini0b1f0132022-08-29 12:59:34 -04003153. Before sending the patch, you *must* run some form of local testing.
Maxim Cournoyer43228982022-12-16 21:09:40 -0500316 Submitting a patch that does not build or function correctly is a mistake. For
Tom Rini0b1f0132022-08-29 12:59:34 -0400317 non-trivial patches, either building a number of platforms locally or making
318 use of :doc:`ci_testing` is strongly encouraged in order to avoid problems
319 that can be found when attempting to merge the patch.
Tom Rini62a2e1d2022-08-29 12:59:33 -0400320
3214. If you modify existing code, make sure that your new code does not add to
322 the memory footprint of the code. Remember: Small is beautiful! When adding
Tom Rini0b1f0132022-08-29 12:59:34 -0400323 new features follow the guidelines laid out in :doc:`system_configuration`.
Tom Rini62a2e1d2022-08-29 12:59:33 -0400324
325Patch Tracking
326--------------
327
Tom Rini0b1f0132022-08-29 12:59:34 -0400328Like some other projects, U-Boot uses `Patchwork <http://patchwork.ozlabs.org/>`_
Tom Rini62a2e1d2022-08-29 12:59:33 -0400329to track the state of patches. This is one of the reasons why it is mandatory
330to submit all patches to the U-Boot mailing list - only then they will be
331picked up by patchwork.
332
333At http://patchwork.ozlabs.org/project/uboot/list/ you can find the list of
334open U-Boot patches. By using the "Filters" link (Note: requires JavaScript)
335you can also select other views, for example, to include old patches that have,
336for example, already been applied or rejected.
337
Tom Rini0b1f0132022-08-29 12:59:34 -0400338Note that Patchwork automatically tracks and collects a number of git tags from
339follow-up mails, so it is usually better to apply a patch through the Patchwork
340commandline interface than just manually applying it from a posting on the
341mailing list (in which case you have to do all the tracking and adding of git
342tags yourself). This also obviates the need of a developer to resubmit a patch
343only in order to collect these tags.
344
Tom Rini62a2e1d2022-08-29 12:59:33 -0400345A Custodian has additional privileges and can:
346
347* **Delegate** a patch
348
349* **Change the state** of a patch. The following states exist:
350
351 * New
352
353 * Under Review
354
355 * Accepted
356
357 * Rejected
358
359 * RFC
360
361 * Not Applicable
362
363 * Changes Requested
364
365 * Awaiting Upstream
366
Mattijs Korpershoek5f8af842023-11-21 17:27:38 +0100367 * Superseded
Tom Rini62a2e1d2022-08-29 12:59:33 -0400368
369 * Deferred
370
371 * Archived
372
373Patchwork work-flow
374^^^^^^^^^^^^^^^^^^^
375
Tom Rini0b1f0132022-08-29 12:59:34 -0400376The following are a "rule of thumb" as to how the states are used in patchwork
377today. Not all states are used by all custodians.
Tom Rini62a2e1d2022-08-29 12:59:33 -0400378
379* New: Patch has been submitted to the list, and none of the maintainers has
380 changed it's state since.
381
Tom Rini0b1f0132022-08-29 12:59:34 -0400382* Under Review: A custodian is reviewing the patch currently.
Tom Rini62a2e1d2022-08-29 12:59:33 -0400383
384* Accepted: When a patch has been applied to a custodian repository that gets
385 used for pulling from into upstream, they are put into "accepted" state.
386
387* Rejected: Rejected means we just don't want to do what the patch does.
388
389* RFC: The patch is not intended to be applied to any of the mainline
390 repositories, but merely for discussing or testing some idea or new feature.
391
Tom Rini0b1f0132022-08-29 12:59:34 -0400392* Not Applicable: The patch either was not intended to be applied, as it was
393 a debugging or discussion aide that patchwork picked up, or was cross-posted
394 to our list but intended for another project entirely.
Tom Rini62a2e1d2022-08-29 12:59:33 -0400395
396* Changes Requested: The patch looks mostly OK, but requires some rework before
397 it will be accepted for mainline.
398
Tom Rini0b1f0132022-08-29 12:59:34 -0400399* Awaiting Upstream: A custodian may have applied this to the ``next`` branch
400 and has not merged yet to master, or has queued the patch up to be submitted
401 to be merged, but has not yet.
Tom Rini62a2e1d2022-08-29 12:59:33 -0400402
Mattijs Korpershoek5f8af842023-11-21 17:27:38 +0100403* Superseded: Patches are marked as 'superseded' when the poster submits a
Tom Rini62a2e1d2022-08-29 12:59:33 -0400404 new version of these patches.
405
406* Deferred: Deferred usually means the patch depends on something else that
407 isn't upstream, such as patches that only apply against some specific other
Tom Rini0b1f0132022-08-29 12:59:34 -0400408 repository. This is also used when a patch has been in patchwork for over a
409 year and it is unlikely to be applied as-is.
Tom Rini62a2e1d2022-08-29 12:59:33 -0400410
411* Archived: Archiving puts the patch away somewhere where it doesn't appear in
412 the normal pages and needs extra effort to get to.
413
Tom Rini62a2e1d2022-08-29 12:59:33 -0400414Apply patches
415^^^^^^^^^^^^^
416
417To apply a patch from the `patchwork queue
418<http://patchwork.ozlabs.org/project/uboot/list/>`_ using ``git``, download the
419mbox file and apply it using::
420
421 git am file
422
423The `openembedded wiki <http://wiki.openembedded.net/>`_ also provides a script
424named `pw-am.sh
425<http://cgit.openembedded.org/cgit.cgi/openembedded/tree/contrib/patchwork/pw-am.sh>`_
426which can be used to fetch an 'mbox' patch from patchwork and git am it::
427
428 usage: pw-am.sh <number>
429 example: 'pw-am.sh 71002' will get and apply the patch from http://patchwork.ozlabs.org/patch/71002/
430
431Update the state of patches
432^^^^^^^^^^^^^^^^^^^^^^^^^^^
433
434You have to register to be able to update the state of patches. You can use the
435Web interface, `pwclient`, or `pwparser`.
436
437pwclient
438^^^^^^^^
439
440The `pwclient` command line tool can be used for example to retrieve patches,
441search the queue or update the state.
442
443All necessary information for `pwclient` is linked from the bottom of
444http://patchwork.ozlabs.org/project/uboot/
445
446Use::
447
448 pwclient help
449
450for an overview on how to use it.
451
452pwparser
453^^^^^^^^
454
455See http://www.mail-archive.com/patchwork@lists.ozlabs.org/msg00057.html