Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial support for HTC One (M8) #12

Merged
merged 2 commits into from
Apr 5, 2024

Conversation

amessier
Copy link
Contributor

Add initial support for the HTC One (M8).

UART support is TBD, for now USB Networking can be used to access the Linux console.

Initial hardware supported:

  • eMMC
  • Power button
  • USB
  • Vibrator
  • Volume buttons (GPIO)
  • Wi-Fi

@z3ntu
Copy link
Member

z3ntu commented Mar 3, 2024

I'm assuming you checked all the regulator voltages against downstream? Generally looks good, just added some small comments.

I'm also encouraging you to send this dts upstream quite soon, I don't want this dts to get stuck in this repo only :)

@amessier
Copy link
Contributor Author

amessier commented Mar 4, 2024

I'm assuming you checked all the regulator voltages against downstream? Generally looks good, just added some small comments.

Yes indeed, I matched the regulator voltages against the vendor device trees.

I'm also encouraging you to send this dts upstream quite soon, I don't want this dts to get stuck in this repo only :)

That was part of my next steps :) I tried this series on top of 6.8-rc but I did not a valid boot (no ssh access). 6.7 did work though, so maybe it's something small. I will re-verify with 6.9-rc when it's released.

z3ntu pushed a commit that referenced this pull request Mar 10, 2024
…SR-IOV

When kdump kernel tries to copy dump data over SR-IOV, LPAR panics due
to NULL pointer exception:

  Kernel attempted to read user page (0) - exploit attempt? (uid: 0)
  BUG: Kernel NULL pointer dereference on read at 0x00000000
  Faulting instruction address: 0xc000000020847ad4
  Oops: Kernel access of bad area, sig: 11 [#1]
  LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries
  Modules linked in: mlx5_core(+) vmx_crypto pseries_wdt papr_scm libnvdimm mlxfw tls psample sunrpc fuse overlay squashfs loop
  CPU: 12 PID: 315 Comm: systemd-udevd Not tainted 6.4.0-Test102+ #12
  Hardware name: IBM,9080-HEX POWER10 (raw) 0x800200 0xf000006 of:IBM,FW1060.00 (NH1060_008) hv:phyp pSeries
  NIP:  c000000020847ad4 LR: c00000002083b2dc CTR: 00000000006cd18c
  REGS: c000000029162ca0 TRAP: 0300   Not tainted  (6.4.0-Test102+)
  MSR:  800000000280b033 <SF,VEC,VSX,EE,FP,ME,IR,DR,RI,LE>  CR: 48288244  XER: 00000008
  CFAR: c00000002083b2d8 DAR: 0000000000000000 DSISR: 40000000 IRQMASK: 1
  ...
  NIP _find_next_zero_bit+0x24/0x110
  LR  bitmap_find_next_zero_area_off+0x5c/0xe0
  Call Trace:
    dev_printk_emit+0x38/0x48 (unreliable)
    iommu_area_alloc+0xc4/0x180
    iommu_range_alloc+0x1e8/0x580
    iommu_alloc+0x60/0x130
    iommu_alloc_coherent+0x158/0x2b0
    dma_iommu_alloc_coherent+0x3c/0x50
    dma_alloc_attrs+0x170/0x1f0
    mlx5_cmd_init+0xc0/0x760 [mlx5_core]
    mlx5_function_setup+0xf0/0x510 [mlx5_core]
    mlx5_init_one+0x84/0x210 [mlx5_core]
    probe_one+0x118/0x2c0 [mlx5_core]
    local_pci_probe+0x68/0x110
    pci_call_probe+0x68/0x200
    pci_device_probe+0xbc/0x1a0
    really_probe+0x104/0x540
    __driver_probe_device+0xb4/0x230
    driver_probe_device+0x54/0x130
    __driver_attach+0x158/0x2b0
    bus_for_each_dev+0xa8/0x130
    driver_attach+0x34/0x50
    bus_add_driver+0x16c/0x300
    driver_register+0xa4/0x1b0
    __pci_register_driver+0x68/0x80
    mlx5_init+0xb8/0x100 [mlx5_core]
    do_one_initcall+0x60/0x300
    do_init_module+0x7c/0x2b0

At the time of LPAR dump, before kexec hands over control to kdump
kernel, DDWs (Dynamic DMA Windows) are scanned and added to the FDT.
For the SR-IOV case, default DMA window "ibm,dma-window" is removed from
the FDT and DDW added, for the device.

Now, kexec hands over control to the kdump kernel.

When the kdump kernel initializes, PCI busses are scanned and IOMMU
group/tables created, in pci_dma_bus_setup_pSeriesLP(). For the SR-IOV
case, there is no "ibm,dma-window". The original commit: b1fc44e,
fixes the path where memory is pre-mapped (direct mapped) to the DDW.
When TCEs are direct mapped, there is no need to initialize IOMMU
tables.

iommu_table_setparms_lpar() only considers "ibm,dma-window" property
when initiallizing IOMMU table. In the scenario where TCEs are
dynamically allocated for SR-IOV, newly created IOMMU table is not
initialized. Later, when the device driver tries to enter TCEs for the
SR-IOV device, NULL pointer execption is thrown from iommu_area_alloc().

The fix is to initialize the IOMMU table with DDW property stored in the
FDT. There are 2 points to remember:

	1. For the dedicated adapter, kdump kernel would encounter both
	   default and DDW in FDT. In this case, DDW property is used to
	   initialize the IOMMU table.

	2. A DDW could be direct or dynamic mapped. kdump kernel would
	   initialize IOMMU table and mark the existing DDW as
	   "dynamic". This works fine since, at the time of table
	   initialization, iommu_table_clear() makes some space in the
	   DDW, for some predefined number of TCEs which are needed for
	   kdump to succeed.

Fixes: b1fc44e ("pseries/iommu/ddw: Fix kdump to work in absence of ibm,dma-window")
Signed-off-by: Gaurav Batra <[email protected]>
Reviewed-by: Brian King <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
Link: https://msgid.link/[email protected]
@z3ntu
Copy link
Member

z3ntu commented Mar 10, 2024

You can rebase on top of qcom-msm8974-6.8.y (if that already exists by the time you read this) or qcom-msm8974-6.8-wip, that branch seems to work fine on my devices.

@amessier amessier changed the base branch from qcom-msm8974-6.7.y to qcom-msm8974-6.8.y March 18, 2024 06:06
@amessier
Copy link
Contributor Author

You can rebase on top of qcom-msm8974-6.8.y (if that already exists by the time you read this) or qcom-msm8974-6.8-wip, that branch seems to work fine on my devices.

I rebased on top of qcom-msm8974-6.8.y. I had the same issue as when I tried mainline 6.8, turns out it was the smbb node not being enabled, and the USB was probe-deferred indefinitely thus no USB networking. But with that fixed, it works like on 6.7.

I also updated the device tree a bit:

  • reordered the pinctrl lines to put the pinctrl-names last
  • updated the gpio debounce value as per vendor kernel value
  • fixed make CHECK_DTBS=y W=1 warning on the gpio_keys_default node

@z3ntu
Copy link
Member

z3ntu commented Mar 20, 2024

Thanks, pushed a tiny fixup on top.

But one major thing is still pending, I'm thinking M8 is actually based on msm8974pro, can you run this command on mainline and post the output? tail /sys/devices/soc0/*

@amessier
Copy link
Contributor Author

But one major thing is still pending, I'm thinking M8 is actually based on msm8974pro, can you run this command on mainline and post the output? tail /sys/devices/soc0/*

You are correct, it's a msm8974pro variant AB.

Here is the output as requested:

htc-m8:~$ tail /sys/devices/soc0/*
==> /sys/devices/soc0/family <==
Snapdragon

==> /sys/devices/soc0/machine <==
MSM8974PRO-AB

==> /sys/devices/soc0/power <==
tail: read error: Is a directory

==> /sys/devices/soc0/revision <==
1.1

==> /sys/devices/soc0/serial_number <==
xxxxxxxxxx

==> /sys/devices/soc0/soc_id <==
218

==> /sys/devices/soc0/subsystem <==
tail: read error: Is a directory

==> /sys/devices/soc0/uevent <==
htc-m8:~$

Indeed, I originally thought of using qcom-msm8974pro.dtsi (due to the pro in the name matching the model), but it looks like that file is made for the MSM8974PRO-AC only, as it will enable the AC specific faster sdhc1 clocks.

In the vendor kernel those clocks are not used and even #if 0'd out.

So I don't think we can use qcom-msm8974pro.dtsi for the AB variant, which is why I used qcom-msm8974.dtsi instead (and matched the model name in the dts name).

@z3ntu
Copy link
Member

z3ntu commented Mar 21, 2024

Nope, qcom-msm8974pro.dtsi is meant for Snapdragon 801 a.k.a MSM8974PRO.

MSM8974PRO-AC a.k.a MSM8974AB-AC (or basically whatever identifier was chosen that includes -AC) is another thing again (https://github.com/torvalds/linux/blob/master/arch/arm/boot/dts/qcom/qcom-msm8974pro-oneplus-bacon.dts#L190). But true, the clock driver seems to handle PRO-AA/PRO-AB and PRO-AC the same way which is probably not what's correct(?) torvalds/linux@c685841

But still, please rename your dtb to msm8974pro-htc-* and use msm8974pro.dtsi include. Also add msm8974pro compatible to the compatible list of the board, see other boards for example. Because it's definitely a PRO chip. I honestly don't think you'll see any problems because of this since we're using msm8974pro.dtsi for a while for also PRO-AA and PRO-AB devices.

@nghfp9wa7bzq
Copy link

((Not sure, why pronto is needed at first glance...))
Can you invite amessier to the chat please?
Thanks.

@z3ntu
Copy link
Member

z3ntu commented Mar 21, 2024

https://matrix.to/#/#msm8974-mainline:postmarketos.org - if joining through that doesn't work (let me know if it doesn't), you can try https://matrix.to/#/#msm8974-mainline:z3ntu.xyz which hopefully works.

@amessier
Copy link
Contributor Author

amessier commented Apr 1, 2024

Sorry for the delay, I agree that the M8 is a 8974pro, the correct fix would maybe to introduce a new dtsi for the AB (like qcom-msm8974pr-ab.dtsi) which would use the qcom,gcc-msm8974 compatible (or could also create qcom,gcc-msm8974pro-ab since a -ac compatible already exists).

In any case, I tried with the current situation, and the phone still boots and works, but you get a kernel warning splat:

[    0.787516] ------------[ cut here ]------------
[    0.787546] WARNING: CPU: 0 PID: 71 at drivers/clk/qcom/clk-rcg2.c:133 update_config+0xe4/0xf0
[    0.787590] sdcc1_apps_clk_src: rcg didn't update its configuration.
[    0.787598] Modules linked in:
[    0.787639] CPU: 0 PID: 71 Comm: kworker/u9:3 Not tainted 6.8.0-postmarketos-qcom-msm8974 #5
[    0.787669] Hardware name: Generic DT based system
[    0.787690] Workqueue: events_unbound async_run_entry_fn
[    0.787738] [<c01108f0>] (unwind_backtrace) from [<c010bc88>] (show_stack+0x10/0x14)
[    0.787784] [<c010bc88>] (show_stack) from [<c0c5faa4>] (dump_stack_lvl+0x40/0x4c)
[    0.787827] [<c0c5faa4>] (dump_stack_lvl) from [<c0121e60>] (__warn+0x78/0x154)
[    0.787873] [<c0121e60>] (__warn) from [<c0122118>] (warn_slowpath_fmt+0x1dc/0x1e4)
[    0.787916] [<c0122118>] (warn_slowpath_fmt) from [<c06a8b14>] (update_config+0xe4/0xf0)
[    0.787960] [<c06a8b14>] (update_config) from [<c06a8fc4>] (clk_rcg2_configure+0xa8/0xb0)
[    0.787999] [<c06a8fc4>] (clk_rcg2_configure) from [<c069b84c>] (clk_change_rate+0x98/0x548)
[    0.788040] [<c069b84c>] (clk_change_rate) from [<c069c1e0>] (clk_core_set_rate_nolock+0x1d8/0x3c0)
[    0.788078] [<c069c1e0>] (clk_core_set_rate_nolock) from [<c069c3f8>] (clk_set_rate+0x30/0x154)
[    0.788116] [<c069c3f8>] (clk_set_rate) from [<c09539b8>] (_opp_config_clk_single+0x24/0x84)
[    0.788165] [<c09539b8>] (_opp_config_clk_single) from [<c0956c6c>] (dev_pm_opp_set_rate+0x1c0/0x228)
[    0.788210] [<c0956c6c>] (dev_pm_opp_set_rate) from [<c098b154>] (sdhci_msm_probe+0x324/0xabc)
[    0.788258] [<c098b154>] (sdhci_msm_probe) from [<c07c1ab8>] (platform_probe+0x5c/0xb0)
[    0.788307] [<c07c1ab8>] (platform_probe) from [<c07beda8>] (really_probe+0xe0/0x3f8)
[    0.788346] [<c07beda8>] (really_probe) from [<c07bf15c>] (__driver_probe_device+0x9c/0x1f0)
[    0.788382] [<c07bf15c>] (__driver_probe_device) from [<c07bf2e0>] (driver_probe_device+0x30/0xc0)
[    0.788419] [<c07bf2e0>] (driver_probe_device) from [<c07bf418>] (__device_attach_driver+0xa8/0x120)
[    0.788455] [<c07bf418>] (__device_attach_driver) from [<c07bcdb4>] (bus_for_each_drv+0x84/0xd8)
[    0.788503] [<c07bcdb4>] (bus_for_each_drv) from [<c07be738>] (__device_attach_async_helper+0xac/0x100)
[    0.788546] [<c07be738>] (__device_attach_async_helper) from [<c014c8f0>] (async_run_entry_fn+0x40/0x158)
[    0.788590] [<c014c8f0>] (async_run_entry_fn) from [<c0141018>] (process_one_work+0x154/0x3c0)
[    0.788632] [<c0141018>] (process_one_work) from [<c0141500>] (worker_thread+0x27c/0x4ac)
[    0.788668] [<c0141500>] (worker_thread) from [<c0148a98>] (kthread+0xfc/0x12c)
[    0.788711] [<c0148a98>] (kthread) from [<c010014c>] (ret_from_fork+0x14/0x28)
[    0.788751] Exception stack(0xf0bf5fb0 to 0xf0bf5ff8)
[    0.788775] 5fa0:                                     00000000 00000000 00000000 00000000
[    0.788804] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    0.788830] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[    0.788853] ---[ end trace 0000000000000000 ]---

In any case, if there isn't anything else, this should be good to go.

For the Matrix chatroom, I don't currently have an account, when I get one I'll join, thanks!

amessier added 2 commits April 5, 2024 18:34
Add a compatible for the HTC One (M8), which is based on the msm8974pro.

Signed-off-by: Alexandre Messier <[email protected]>
Add initial device tree for the HTC One (M8) smartphone.

Initial support includes:
 - eMMC
 - Power button
 - USB
 - Vibrator
 - Volume buttons (GPIO)
 - Wi-Fi

Signed-off-by: Alexandre Messier <[email protected]>
@z3ntu
Copy link
Member

z3ntu commented Apr 5, 2024

This warning is (unfortunately) normal, so no worries about that. Shouldn't cause any functional issues I believe.

Please also send your patch upstream, if you need any help with that please let me know!

Copy link
Member

@z3ntu z3ntu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@z3ntu z3ntu merged commit 88494d0 into msm8974-mainline:qcom-msm8974-6.8.y Apr 5, 2024
@amessier amessier deleted the m8-slim branch April 6, 2024 06:14
@z3ntu
Copy link
Member

z3ntu commented May 20, 2024

Hi @amessier , any progress on sending the patches upstream?

@amessier
Copy link
Contributor Author

Hi @amessier , any progress on sending the patches upstream?

@z3ntu sorry I don't have any progress, except I tested today with qcom for-next like you mentioned on Matrix. No issue, so I hope to send to the ML by next weekend. Thanks!

@z3ntu
Copy link
Member

z3ntu commented May 21, 2024

Great to hear!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants