Allwinner Kernel Upstreaming Experiences

38
Allwinner Kernel Upstreaming Experiences Chen-Yu Tsai (wens) 蔡鎮宇

Transcript of Allwinner Kernel Upstreaming Experiences

Page 1: Allwinner Kernel Upstreaming Experiences

Allwinner Kernel Upstreaming Experiences

Chen-Yu Tsai (wens)蔡鎮宇

Page 2: Allwinner Kernel Upstreaming Experiences

Chen-Yu Tsai 蔡鎮宇• Software Engineer @ CloudMosa

• Puffin Web Browser

• Totally not embedded Linux related

• Linux-sunxi community hobbyist• Contributions to U-boot and Linux

• git log --oneline --author “Chen-Yu Tsai”

• Translations

2015/8/25 2

Page 3: Allwinner Kernel Upstreaming Experiences

DisclaimerI have only done Allwinner/sunxi related stuff.

Linux-sunxi is community/volunteer based.

Your mileage may vary.

2015/8/25 3

Page 4: Allwinner Kernel Upstreaming Experiences

Outline• Current Status

• Where to start

• Tips

• What to expect

• New SoC bringup

• Supporting new boards

• Priorities

• Difficulties

2015/8/25 4

Page 5: Allwinner Kernel Upstreaming Experiences

Current StatusLet’s look at some ARM SoC vendors

2015/8/25 5

Page 6: Allwinner Kernel Upstreaming Experiences

linux-sunxi?• Cheap hardware

• Development boards

• Documents and SDKs available• Given by hardware vendors

• Allwinner now provides them on github• https://github.com/allwinner-zh/

2015/8/25 6

Page 7: Allwinner Kernel Upstreaming Experiences

Allwinner• Headless server w/ MMC/SATA/USB storage

• I2C & SPI

• LCD/HDMI/VGA display w/ simplefb

• Audio WIP

2015/8/25 7

Page 8: Allwinner Kernel Upstreaming Experiences

Allwinner• Community driven

• git lo --no-merges --perl-regexp --grep

'sunxi|sun[0-9]i' | grep -v m68k | wc –l

• 1118

• Extremely active

• Allwinner supplies documents and their source code• Answers questions

2015/8/25 8

Page 9: Allwinner Kernel Upstreaming Experiences

Rockchip• Basically a fully working system

• MMC/USB

• I2C & SPI

• Full KMS display support

• I2S & audio codecs

• Chromebook based on mainline kernel + dts

• IP blocks mostly from ARM or Synopsys

2015/8/25 9

Page 10: Allwinner Kernel Upstreaming Experiences

Rockchip• Hobbyist maintainer

• git lo --author 'Heiko Stuebner' | wc -l

• 158

• filtered out Samsung related

• Official support• git lo --author @rock-chips.com | wc -l

• 169

2015/8/25 10

Page 11: Allwinner Kernel Upstreaming Experiences

Mediatek• Basics (machine, clk, pinctrl , uart)

• Drivers for• I2C, SPI, MMC, PMIC, Audio

• Not seen in DTS yet

2015/8/25 11

Page 12: Allwinner Kernel Upstreaming Experiences

Mediatek• Outside maintainer

• git lo --author 'Matthias Brugger' | wc -l

• 53

• Since 2014/7/22

• Official support• git lo --author @mediatek.com | wc -l

• 122

• Since 2014/11/4

2015/8/25 12

Page 13: Allwinner Kernel Upstreaming Experiences

Where to start

2015/8/25 13

Page 14: Allwinner Kernel Upstreaming Experiences

Getting it to boot• Machine definition (arch/arm/mach-*)

• Basic DTS

• UART

2015/8/25 14

Page 15: Allwinner Kernel Upstreaming Experiences

Infrastructure• Clocks

• Pinctrl

• Reusable

2015/8/25 15

Page 16: Allwinner Kernel Upstreaming Experiences

Peripherals• Storage

• MMC

• SATA

• USB

• PMIC

• I2C

• SPI

• …

• Common vs custom IP?

2015/8/25 16

Page 17: Allwinner Kernel Upstreaming Experiences

TipsThe kernel is very big and moves very fast

2015/8/25 17

Page 18: Allwinner Kernel Upstreaming Experiences

Start small• Is it a known, supported IP block?

• Only standard resources?• MMIO, IRQ, clocks, resets

• Ex: USB host

• Hardware glue? Quirks?• Is the core supported?

• Is it a library?

• Write a glue driver

• Modify / port

• Ex: SATA AHCI, STMMAC

2015/8/25 18

Page 19: Allwinner Kernel Upstreaming Experiences

Start simple• Clocks can be done one at a time

• Driver describes clock controls

• Driver or DTS describes relationship between clocks• Both methods are used

• Pinctrl / GPIO• Transcribe datasheets

2015/8/25 19

Page 20: Allwinner Kernel Upstreaming Experiences

Look around and Ask• Subscribe to mailing lists

• Look at how other contributors write code

• Learn what reviewers ask for

• Look at how other platforms do it• mediatek pinctrl driver is very similar to sunxi

• Documentation is sometimes lacking• When in doubt, ask

• Release often• No one is going to review unsent code

2015/8/25 20

Page 21: Allwinner Kernel Upstreaming Experiences

What to expectNot getting merged is not the end of the world

2015/8/25 21

Page 22: Allwinner Kernel Upstreaming Experiences

Code issues• Code style

• Indentation

• Comments

• Error path

• Bugs• Resource leak?

2015/8/25 22

Page 23: Allwinner Kernel Upstreaming Experiences

NACK• Wrong design

• Ex: rfkill dt support

• Deprecated functions• Ex: platform_data

• Occasional disagreement• “simplefb: add clock handling code”

2015/8/25 23

Page 24: Allwinner Kernel Upstreaming Experiences

Maintainers are busy• Sometimes you don’t get feedback

• Maintainers often write code as well

• Lots of mailing list traffic

• Ping or resend

2015/8/25 24

Page 25: Allwinner Kernel Upstreaming Experiences

Didn’t get your patches in this release?• You can do better

• Write better code

• Respond to reviewers

• Keep working

• Release cycle is predictable

• Sometimes it’s not your fault• Maintainer missed your patch or pull request

• It happens

• Maintainer went on vacation

• Maintainer missing (?)

2015/8/25 25

Page 26: Allwinner Kernel Upstreaming Experiences

New SoC bringup

2015/8/25 26

Page 27: Allwinner Kernel Upstreaming Experiences

New SoC1. Getting it to Boot

• Machine definition (arch/arm/mach-*)• Basic DTS• UART

2. Clocks / Pinctrl

3. Peripherals• IP blocks don’t often change

• Existing drivers should work

• Quite satisfying!

2015/8/25 27

Page 28: Allwinner Kernel Upstreaming Experiences

Supporting new boards

2015/8/25 28

Page 29: Allwinner Kernel Upstreaming Experiences

Supporting new boards• Need schematics or hardware description

• What peripherals are connected to the board?

• What external ICs are there?• PMICs, audio codecs, sensors, storage…

• Extra GPIOs?• LEDs

• Write a .dts file

• Test that everything works

• Fairly easy!

2015/8/25 29

Page 30: Allwinner Kernel Upstreaming Experiences

Priorities

2015/8/25 30

Page 31: Allwinner Kernel Upstreaming Experiences

Paid work• Not really much say

• Getting products shipped is all that matters

• Still• You should try

• What benefits the most platforms / boards?

• Must have vs. want?• MMC vs USB vs audio

2015/8/25 31

Page 32: Allwinner Kernel Upstreaming Experiences

Community hackers• Expertise / prior experience

• Did clocks before, do it again

• Interest• Me: I want WiFi! I want SMP!

• Low hanging fruit• Me: Network is DWMAC based, only need glue code

• Popular demand• DMA engine

• Audio

2015/8/25 32

Page 33: Allwinner Kernel Upstreaming Experiences

Difficulties

2015/8/25 33

Page 34: Allwinner Kernel Upstreaming Experiences

Documents• NDA?

• Incorrect• How do you know it’s incorrect?

• Missing sections

• Completely non-existent

• No board schematics• Should you risk it going up in smoke?

2015/8/25 34

Page 35: Allwinner Kernel Upstreaming Experiences

Porting vendor code• Is often bad

• Because of time to market concerns

• Quite old• Android kernel still at 3.4?

• Custom frameworks• Obsoleted by common frameworks

• Clocks, resets, pinctrl, gpio, PHY, regmap, …

• Binary blobs• No source code

2015/8/25 35

Page 36: Allwinner Kernel Upstreaming Experiences

Binary drivers• Third-party IP vendors

• GPUs

• VPUs

• …

• NDAs

2015/8/25 36

Page 37: Allwinner Kernel Upstreaming Experiences

GPL violations• There shouldn’t be binary-only blobs in the kernel

• http://linux-sunxi.org/GPL_Violations

• http://www.xda-developers.com/have-you-paid-your-linux-kernel-source-license-fee/

2015/8/25 37

Page 38: Allwinner Kernel Upstreaming Experiences

Questions?

2015/8/25 38