~anjan/momi.ca

e3da713b62a167a173cce164daecf7da2f930d18 — Anjandev Momi 2 years ago 32418f7
new post: mainline on the pinephone pro
1 files changed, 79 insertions(+), 0 deletions(-)

A src/posts/2022-09-07-mainline.org
A src/posts/2022-09-07-mainline.org => src/posts/2022-09-07-mainline.org +79 -0
@@ 0,0 1,79 @@
#+BEGIN_EXPORT html
<h1 class="page-title">The Pinephone Pro, PostmarketOS, and Why Mainlining Phones is Important</h1>
<p class="date">Published 2022-09-07 on <a href="/">Anjan's Homepage</a></p>
#+END_EXPORT
#+OPTIONS: toc:nil
#+OPTIONS: num:nil

In =#sxmo= on OFTC, users often ask why the pinephone pro is less functional on postmarketOS than other distros.
PostmarketOS uses a mainline pinephone pro kernel [fn:1].
There exists a heavily patched fork of the linux kernel called the megi kernel with broader support for the functionality of the pinephone pro [fn:2].
In this blog post, I will explain why postmarketOS has mainline-first approach.

#+begin_quote
Carrying around forks of the kernel is not sustainable as it becomes impossible to provide security patches after a short time. The only way to truly fix this for a device is mainlining it.
#+end_quote
- Source: postmarketOS wiki https://wiki.postmarketos.org/wiki/The_Mainline_Kernel

Moreover, I have ran into stability issues when using heavily forked kernels with postmarketOS.
Recall that postmarketOS is aiming for a 10 year lifecycle for smartphones.
Forked kernels are a hurdle we must overcome to achieve this goal.

It is often suggested that we use the megi forked kernel for the pinephone pro in the postmarketOS distro as a temporary solution.
However, it is easy to underestimate how permanent a temporary solution can be - the heavily forked megi kernel for the original pinephone is used in postmarketOS and has not been upstreamed [fn:7].
PostmarketOS cannot change from the megi kernel to the upstream kernel for the original pinephone without losing functionality.
Indeed, postmarketOS is trying to change the status quo where phones are a throwaway insecure mess cause the code is so heavily patched.
Only shipping the mainline kernel creates pressure for someone to mainline the megi kernel patches.

* Options

PostmarketOS is the only linux distro I have used on my pinephone, pinephone pro, and android phones because of how well the distro is maintained.
Indeed, the mainline-first approach encourages the community to enact best practices.
If you are convinced of the importance of mainlining and postmarketOS's approach, here is how you can help:

** Help mainline the pinephone pro kernel

The megi kernel is not as bad as a typical downstream kernel.
For example, megi's kernel has a ~500k line diff and OnePlus 6's downstream kernel has a ~5000k line diff [fn:8].
However, we should still work towards mainlining the megi kernel.
Megi expressed in the past that he is not interested in mainlining because rebasing to the latest Linux release is less work for him.
Megi's work is valuable and a good start.
I am thankful he is doing this work but we need to work as a community to make sure his work lives on forever.

There has been progress on mainlining the pinephone pro kernel!
The pinephone pro device tree has been merged into the upstream linux kernel [fn:3].
If you want to help, please checkout the =#cross-distro-kernel= channel on the libera.chat irc network and the gitlab [fn:6].
There are lots of people in =#postmarketos-mainline= channel on the oftc irc network to help you learn how to mainline.
Maybe you can mainline other Android phones?

** Buy functional mainlined devices

I have been daily driving the poco f1 with Sxmo for a couple months and it's the perfect phone [fn:4].
You can also use the OnePlus 6/6T for similar support.
These devices have proper mainline support in postmarketOS and can be obtained in Canada for 150 Canadian dollars.
Optionally, you can donate the money saved from buying [[https://wiki.postmarketos.org/wiki/Qualcomm_Snapdragon_845_(SDM845)][SDM845 devices]] to the developers making sure we have lots of mainline devices to use [fn:5].

* Conclusion

I appreciate megi's work as a start but we need to mainline devices to have a polished experience long term.
If postmarketOS merged heavily forked kernels for devices, a lot of work would need to be done to maintain those devices.
More likely, we wouldn't bother and have severely insecure devices after a couple years.
The large initial investment of mainlining is worth it.

* Footnotes

[fn:8] See: https://mainline.space/ https://not.mainline.space/

[fn:7] https://gitlab.com/postmarketOS/pmaports/-/blob/master/device/main/linux-postmarketos-allwinner/APKBUILD#L38

[fn:6] https://gitlab.com/pine64-org/linux

[fn:5] https://www.patreon.com/calebccff

[fn:4] Read my blog post: [[https://momi.ca/posts/2022-04-19-sxmopocof1.html][Sxmo on the poco f1]]

[fn:3] https://lore.kernel.org/all/166231195330.2423948.5394487959576836993.b4-ty@sntech.de/

[fn:2] https://megous.com/git/linux

[fn:1] https://gitlab.com/pine64-org/linux