-
Notifications
You must be signed in to change notification settings - Fork 122
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
Charger smb1360: Increase timeout and current #314
Charger smb1360: Increase timeout and current #314
Conversation
60bd17a
to
e4dbd09
Compare
Changed comment and implementation of "fastcharge current", as discussed further above. |
e4dbd09
to
01aa49a
Compare
Rebased to I'm not very familiar with GitHub, it looks a bit strange with that list of all those commits up above. I hope I've done it correctly. |
Hm, nope, doesn't look like I've done the rebasing correctly. I'll try to fix this. |
Ah, fixed that by changing the base in the GitHub user interface. |
01aa49a
to
80dd6c7
Compare
Build failed because "mixing declarations and code". Therefore I moved the declarations to the beginning of function |
I removed the "draft" status and resolved the discussions so far. We could wait a bit longer, maybe Random Modder can add some testing experience. However, I think the current setting with "input current limit" at 800 mA and default AICL setting is the best compromise in the actual situation. |
I guess the charging timeout might also exist to continue charging a faulty battery forever. Should we really remove it completely? With the higher input current limit, how likely is it that you'd still discharge the device under heavy usage? |
My impression was that the charging timeout is an alternative to the recharge cycle, which can be disabled. However, I can't think of a use case where this would be a good choice. With a charging cable connected, stopping charging and switch to discharging is always a surprise to a user, I'd say. As switching to (complete) discharging doesn't happen when reaching the recharge cycle, it would only happen if the device is floating between empty and full until the timeout kicks in. Setting the timeout to 13 hours, this is quite unlikely to happen. Hypothetically at weak power supply after e.g. 10 hours of notable computing load and thereafter 3 more hours of charging might not reach the recharge cycle. Although I can't think of a realistic scenario where this would happen. Watching movies at a long flight – but the passenger needs to leave the airplane at some point anyway. Using the phone as a navigation device in the car – but that shouldn't cause a computing load that draws as much power as even a weak power supply would provide. Yet possibly there are use scenarios that are beyond my imagination, I didn't want to risk a user running into an unexpecedly discharged battery in such extreme cases. Another reason why I tended to disable the charging timeout was because there were some uncertainties about the behavior. One report was about switching to discharing after reaching 100 %. Another one was switching to discharging after several hours of recharging cycle. Both issues were neither understood nor could be reproduced. I wanted to avoid such things being caused by the charging timeout. However, the first issue should become unlikely when setting the timeout to 13 hours. The second one actually shouldn't happen, there is no obvious relation to the charging timeout.
In the downstream devicetrees, some timeouts were set to 0 and some to 768 minutes. That doesn't help for the decision neither. Another guideline could be the default setting of the chip. In the second code review discussion above I did a I now also realize that the name of this feature in the register is actually "safety time" and not "charging timeout". Summing up, it looks reasonable to set the "safety time" to 768 minutes. I'll change the pull request within the next days. |
80dd6c7
to
cae4101
Compare
As discussed, I enabled the charging timeout, set it to 768 minutes (approx. 13 hours) and adapted the commit message. |
The charging currents are not yet handled. Actually they should be set in runtime based on connector type detection (like an extcon device but for smb1360 a more complicated mechanism in USB PHY layer is needed, e.g. like in downstream [1]). The upper limits for the charging currents should be read from the devicetree. As a temporary solution, set hard-coded charging currents in the smb1360_hw_init() function. [1] https://github.com/bq/aquaris-X5/blob/aquaris-X5_5.x/drivers/usb/phy/phy-msm-usb.c#L2959-L3112 Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
The currently implemented charging timeout of 192 minutes (approx. 3 hours) turned out to be too short. When reaching the timeout, the device starts to discharge even though the charging cable is still attached. Therefore increase the charging timeout to 768 minutes (approx. 13 hours). This is the default setting in the smb1360 chip and also the value of some of the downstream devicetrees. Disabling the charging timeout entirely was considered but discarded in favor of safety. The timeout could avoid charging a faulty battery for too long. On the other hand, the probability of reaching the timeout of 13 hours by regular usage is considered very low – the timeout doesn't apply when the battery is reaching full state and the charger switches to recharge cycle. Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
cae4101
to
2bd3740
Compare
From my point of view [1] https://github.com/msm8916-mainline/linux/blob/msm8916/6.4-rc4/drivers/power/supply/smb1360.c#L1729-L1730 On the USB_500 quirk: I couldn't confirm the issue on my device. I'm on smb1360 chip rev. 3, device bq-paella. I also tried The other suggestions I have implemented:
I changed and extended the comments on the fastcharge currrent and hope it's ok that way. Otherwise let me know if you have suggestion for improvement. Additionally, in the comments I changed wording "extcon cable type" to a more general "connector type detection", as you explained further above in the second collapsed review the diffiulties on detecting the extcon cable type and the need of implemeting it in the USB PHY layer. And in the commit message I added a more specific hint to USB PHY layer incl. the downstream example (for bq-paella). |
Integrated this into |
[ Upstream commit 5d1935a ] When we online resize an ext4 filesystem with a oversized flexbg_size, mkfs.ext4 -F -G 67108864 $dev -b 4096 100M mount $dev $dir resize2fs $dev 16G the following WARN_ON is triggered: ================================================================== WARNING: CPU: 0 PID: 427 at mm/page_alloc.c:4402 __alloc_pages+0x411/0x550 Modules linked in: sg(E) CPU: 0 PID: 427 Comm: resize2fs Tainted: G E 6.6.0-rc5+ msm8916-mainline#314 RIP: 0010:__alloc_pages+0x411/0x550 Call Trace: <TASK> __kmalloc_large_node+0xa2/0x200 __kmalloc+0x16e/0x290 ext4_resize_fs+0x481/0xd80 __ext4_ioctl+0x1616/0x1d90 ext4_ioctl+0x12/0x20 __x64_sys_ioctl+0xf0/0x150 do_syscall_64+0x3b/0x90 ================================================================== This is because flexbg_size is too large and the size of the new_group_data array to be allocated exceeds MAX_ORDER. Currently, the minimum value of MAX_ORDER is 8, the minimum value of PAGE_SIZE is 4096, the corresponding maximum number of groups that can be allocated is: (PAGE_SIZE << MAX_ORDER) / sizeof(struct ext4_new_group_data) ≈ 21845 And the value that is down-aligned to the power of 2 is 16384. Therefore, this value is defined as MAX_RESIZE_BG, and the number of groups added each time does not exceed this value during resizing, and is added multiple times to complete the online resizing. The difference is that the metadata in a flex_bg may be more dispersed. Signed-off-by: Baokun Li <libaokun1@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20231023013057.2117948-4-libaokun1@huawei.com Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Sasha Levin <sashal@kernel.org>
[ Upstream commit a51cd6b ] In case when is64 == 1 in emit(A64_REV32(is64, dst, dst), ctx) the generated insn reverses byte order for both high and low 32-bit words, resuling in an incorrect swap as indicated by the jit test: [ 9757.262607] test_bpf: msm8916-mainline#312 BSWAP 16: 0x0123456789abcdef -> 0xefcd jited:1 8 PASS [ 9757.264435] test_bpf: msm8916-mainline#313 BSWAP 32: 0x0123456789abcdef -> 0xefcdab89 jited:1 ret 1460850314 != -271733879 (0x5712ce8a != 0xefcdab89)FAIL (1 times) [ 9757.266260] test_bpf: msm8916-mainline#314 BSWAP 64: 0x0123456789abcdef -> 0x67452301 jited:1 8 PASS [ 9757.268000] test_bpf: msm8916-mainline#315 BSWAP 64: 0x0123456789abcdef >> 32 -> 0xefcdab89 jited:1 8 PASS [ 9757.269686] test_bpf: msm8916-mainline#316 BSWAP 16: 0xfedcba9876543210 -> 0x1032 jited:1 8 PASS [ 9757.271380] test_bpf: msm8916-mainline#317 BSWAP 32: 0xfedcba9876543210 -> 0x10325476 jited:1 ret -1460850316 != 271733878 (0xa8ed3174 != 0x10325476)FAIL (1 times) [ 9757.273022] test_bpf: msm8916-mainline#318 BSWAP 64: 0xfedcba9876543210 -> 0x98badcfe jited:1 7 PASS [ 9757.274721] test_bpf: msm8916-mainline#319 BSWAP 64: 0xfedcba9876543210 >> 32 -> 0x10325476 jited:1 9 PASS Fix this by forcing 32bit variant of rev32. Fixes: 1104247 ("bpf, arm64: Support unconditional bswap") Signed-off-by: Artem Savkov <asavkov@redhat.com> Tested-by: Puranjay Mohan <puranjay12@gmail.com> Acked-by: Puranjay Mohan <puranjay12@gmail.com> Acked-by: Xu Kuohai <xukuohai@huawei.com> Message-ID: <20240321081809.158803-1-asavkov@redhat.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
[ Upstream commit 8ecf3c1 ] Recent additions in BPF like cpu v4 instructions, test_bpf module exhibits the following failures: test_bpf: #82 ALU_MOVSX | BPF_B jited:1 ret 2 != 1 (0x2 != 0x1)FAIL (1 times) test_bpf: #83 ALU_MOVSX | BPF_H jited:1 ret 2 != 1 (0x2 != 0x1)FAIL (1 times) test_bpf: #84 ALU64_MOVSX | BPF_B jited:1 ret 2 != 1 (0x2 != 0x1)FAIL (1 times) test_bpf: #85 ALU64_MOVSX | BPF_H jited:1 ret 2 != 1 (0x2 != 0x1)FAIL (1 times) test_bpf: #86 ALU64_MOVSX | BPF_W jited:1 ret 2 != 1 (0x2 != 0x1)FAIL (1 times) test_bpf: #165 ALU_SDIV_X: -6 / 2 = -3 jited:1 ret 2147483645 != -3 (0x7ffffffd != 0xfffffffd)FAIL (1 times) test_bpf: #166 ALU_SDIV_K: -6 / 2 = -3 jited:1 ret 2147483645 != -3 (0x7ffffffd != 0xfffffffd)FAIL (1 times) test_bpf: #169 ALU_SMOD_X: -7 % 2 = -1 jited:1 ret 1 != -1 (0x1 != 0xffffffff)FAIL (1 times) test_bpf: #170 ALU_SMOD_K: -7 % 2 = -1 jited:1 ret 1 != -1 (0x1 != 0xffffffff)FAIL (1 times) test_bpf: #172 ALU64_SMOD_K: -7 % 2 = -1 jited:1 ret 1 != -1 (0x1 != 0xffffffff)FAIL (1 times) test_bpf: msm8916-mainline#313 BSWAP 16: 0x0123456789abcdef -> 0xefcd eBPF filter opcode 00d7 (@2) unsupported jited:0 301 PASS test_bpf: msm8916-mainline#314 BSWAP 32: 0x0123456789abcdef -> 0xefcdab89 eBPF filter opcode 00d7 (@2) unsupported jited:0 555 PASS test_bpf: msm8916-mainline#315 BSWAP 64: 0x0123456789abcdef -> 0x67452301 eBPF filter opcode 00d7 (@2) unsupported jited:0 268 PASS test_bpf: msm8916-mainline#316 BSWAP 64: 0x0123456789abcdef >> 32 -> 0xefcdab89 eBPF filter opcode 00d7 (@2) unsupported jited:0 269 PASS test_bpf: msm8916-mainline#317 BSWAP 16: 0xfedcba9876543210 -> 0x1032 eBPF filter opcode 00d7 (@2) unsupported jited:0 460 PASS test_bpf: msm8916-mainline#318 BSWAP 32: 0xfedcba9876543210 -> 0x10325476 eBPF filter opcode 00d7 (@2) unsupported jited:0 320 PASS test_bpf: msm8916-mainline#319 BSWAP 64: 0xfedcba9876543210 -> 0x98badcfe eBPF filter opcode 00d7 (@2) unsupported jited:0 222 PASS test_bpf: msm8916-mainline#320 BSWAP 64: 0xfedcba9876543210 >> 32 -> 0x10325476 eBPF filter opcode 00d7 (@2) unsupported jited:0 273 PASS test_bpf: msm8916-mainline#344 BPF_LDX_MEMSX | BPF_B eBPF filter opcode 0091 (@5) unsupported jited:0 432 PASS test_bpf: msm8916-mainline#345 BPF_LDX_MEMSX | BPF_H eBPF filter opcode 0089 (@5) unsupported jited:0 381 PASS test_bpf: msm8916-mainline#346 BPF_LDX_MEMSX | BPF_W eBPF filter opcode 0081 (@5) unsupported jited:0 505 PASS test_bpf: torvalds#490 JMP32_JA: Unconditional jump: if (true) return 1 eBPF filter opcode 0006 (@1) unsupported jited:0 261 PASS test_bpf: Summary: 1040 PASSED, 10 FAILED, [924/1038 JIT'ed] Fix them by adding missing processing. Fixes: daabb2b ("bpf/tests: add tests for cpuv4 instructions") Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/91de862dda99d170697eb79ffb478678af7e0b27.1709652689.git.christophe.leroy@csgroup.eu Signed-off-by: Sasha Levin <sashal@kernel.org>
There has been an issue report pmaports #1949 that the charging of device bq-paella with charger smb1360 stops after 3 hours.
This PR disables the charging timeout in the devicetree of the devices using this charger. And additionally increases the charging current of the charger (hard-coded charging current as a temporary solution). More details can be found in the commit messages.
WIP: The changes are currently tested.