-
Notifications
You must be signed in to change notification settings - Fork 134
[RFC]ASoC: SOF: remove runtime PM calls during debugfs read #620
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
Conversation
runtime PM calls during debugfs reads are not necessary because: 1. If the DSP is active, there's no need to wake it up. 2. If the DSP is suspended, there's no updates to its status, so there's no need to wake it up. Besides pm_runtime_get_noresume() doesn't really resume the DSP but just increments the device counter. 3. If the DSP is in panic, runtime PM is pointless. We cannot resume/suspend it anyway. 4. The runtime_pm_put_autosuspend() call at the end of memcpy cannot be paired with a pm_runtime_get_noresume(). 5. Finally, this I'm not entirely sure about this but I think when we read a debugfs memory, we're only reading the shared memory between the host and DSP. We don't really copy memory from the DSP's SRAM to the shared memory. Signed-off-by: Ranjani Sridharan <[email protected]>
a45b905
to
b598268
Compare
I don't know either why pm_runtime was enabled for debugfs. This was modified in #237 but there's nothing that tells me why this was needed in the first place. |
Actually no, this won't work. static const struct snd_sof_debugfs_map byt_debugfs[] = {
{"dmac0", BYT_DSP_BAR, DMAC0_OFFSET, DMAC_SIZE},
{"dmac1", BYT_DSP_BAR, DMAC1_OFFSET, DMAC_SIZE},
{"ssp0", BYT_DSP_BAR, SSP0_OFFSET, SSP_SIZE},
{"ssp1", BYT_DSP_BAR, SSP1_OFFSET, SSP_SIZE},
{"ssp2", BYT_DSP_BAR, SSP2_OFFSET, SSP_SIZE},
{"iram", BYT_DSP_BAR, IRAM_OFFSET, IRAM_SIZE},
{"dram", BYT_DSP_BAR, DRAM_OFFSET, DRAM_SIZE},
{"shim", BYT_DSP_BAR, SHIM_OFFSET, SHIM_SIZE},
}; BYT is a bad example since PM is not enabled, but in general some of those resources will not be available when the device is suspended. |
@plbossart just to confirm then we do need to resume the DSP to read the debugfs entries if the device in runtime suspended? Is this true for all the memory windows including exception? |
@plbossart <https://github.com/plbossart> just to confirm then we do
need to resume the DSP to read the debugfs entries if the device in
runtime suspended? Is this true for all the memory windows including
exception?
That's not clear to me.
Some of the registers exposed through debugfs are not tied to the DSP
state, so the answer is no in general.
We might need a flag in the debugfs_map which states is the mmio
survives a suspend case.
@lgirdwood, thoughts?
|
@plbossart I had a discussion with Liam and Lech about this today. What they told me was that once the DSP is in D3, the contents of the memory windows are invalid. So their suggestion was to have a debugfs entry that prevents the DSP from entering D3 before reading the memory windows. Also, the last case would be when reading the memory windows when the DSP is in D3. In this case, Liam suggested we should let the userspace know that the contents might be invalid as the DSP is suspended. Please let me know what you think and i'll change the PR accordingly. |
@ranj063 I still believe we need to add a flag for each debugfs file that states if it's affected or not by a transition to a D3 state. yes the memory windows are probably not correct in D3 (even D0i1), so you'd want to copy it to some mirror before suspending, but others such as SSP registers or PP parts can be accessed as desired. |
@plbossart ok that makes sense. When you say mirror it, do you mean cache it in the driver? And we would do this every time prior to the DSP entering D3? |
yes. On suspend you mirror, and you only update the mirror and pass the data to debugfs if the device is active. |
@plbossart I will update and submit a new PR based on our discussion. Closing this one. |
There are two types of the lower interface of rmnet that are VND and BRIDGE. Each lower interface can have only one type either VND or BRIDGE. But, there is a case, which uses both lower interface types. Due to this unexpected behavior, lower interface leak occurs. Test commands: ip link add dummy0 type dummy ip link add dummy1 type dummy ip link add rmnet0 link dummy0 type rmnet mux_id 1 ip link set dummy1 master rmnet0 ip link add rmnet1 link dummy1 type rmnet mux_id 2 ip link del rmnet0 The dummy1 was attached as BRIDGE interface of rmnet0. Then, it also was attached as VND interface of rmnet1. This is unexpected behavior and there is no code for handling this case. So that below splat occurs when the rmnet0 interface is deleted. Splat looks like: [ 53.254112][ C1] WARNING: CPU: 1 PID: 1192 at net/core/dev.c:8992 rollback_registered_many+0x986/0xcf0 [ 53.254117][ C1] Modules linked in: rmnet dummy openvswitch nsh nf_conncount nf_nat nf_conntrack nf_defrag_ipv6 nfx [ 53.254182][ C1] CPU: 1 PID: 1192 Comm: ip Not tainted 5.8.0-rc1+ #620 [ 53.254188][ C1] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [ 53.254192][ C1] RIP: 0010:rollback_registered_many+0x986/0xcf0 [ 53.254200][ C1] Code: 41 8b 4e cc 45 31 c0 31 d2 4c 89 ee 48 89 df e8 e0 47 ff ff 85 c0 0f 84 cd fc ff ff 0f 0b e5 [ 53.254205][ C1] RSP: 0018:ffff888050a5f2e0 EFLAGS: 00010287 [ 53.254214][ C1] RAX: ffff88805756d658 RBX: ffff88804d99c000 RCX: ffffffff8329d323 [ 53.254219][ C1] RDX: 1ffffffff0be6410 RSI: 0000000000000008 RDI: ffffffff85f32080 [ 53.254223][ C1] RBP: dffffc0000000000 R08: fffffbfff0be6411 R09: fffffbfff0be6411 [ 53.254228][ C1] R10: ffffffff85f32087 R11: 0000000000000001 R12: ffff888050a5f480 [ 53.254233][ C1] R13: ffff88804d99c0b8 R14: ffff888050a5f400 R15: ffff8880548ebe40 [ 53.254238][ C1] FS: 00007f6b86b370c0(0000) GS:ffff88806c200000(0000) knlGS:0000000000000000 [ 53.254243][ C1] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 53.254248][ C1] CR2: 0000562c62438758 CR3: 000000003f600005 CR4: 00000000000606e0 [ 53.254253][ C1] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 53.254257][ C1] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 53.254261][ C1] Call Trace: [ 53.254266][ C1] ? lockdep_hardirqs_on_prepare+0x379/0x540 [ 53.254270][ C1] ? netif_set_real_num_tx_queues+0x780/0x780 [ 53.254275][ C1] ? rmnet_unregister_real_device+0x56/0x90 [rmnet] [ 53.254279][ C1] ? __kasan_slab_free+0x126/0x150 [ 53.254283][ C1] ? kfree+0xdc/0x320 [ 53.254288][ C1] ? rmnet_unregister_real_device+0x56/0x90 [rmnet] [ 53.254293][ C1] unregister_netdevice_many.part.135+0x13/0x1b0 [ 53.254297][ C1] rtnl_delete_link+0xbc/0x100 [ 53.254301][ C1] ? rtnl_af_register+0xc0/0xc0 [ 53.254305][ C1] rtnl_dellink+0x2dc/0x840 [ 53.254309][ C1] ? find_held_lock+0x39/0x1d0 [ 53.254314][ C1] ? valid_fdb_dump_strict+0x620/0x620 [ 53.254318][ C1] ? rtnetlink_rcv_msg+0x457/0x890 [ 53.254322][ C1] ? lock_contended+0xd20/0xd20 [ 53.254326][ C1] rtnetlink_rcv_msg+0x4a8/0x890 [ ... ] [ 73.813696][ T1192] unregister_netdevice: waiting for rmnet0 to become free. Usage count = 1 Fixes: 037f9cd ("net: rmnet: use upper/lower device infrastructure") Signed-off-by: Taehee Yoo <[email protected]> Signed-off-by: David S. Miller <[email protected]>
runtime PM calls during debugfs reads are not necessary because:
status, so there's no need to wake it up. Besides
pm_runtime_get_noresume() doesn't really resume the DSP
but just increments the device counter.
cannot resume/suspend it anyway.
cannot be paired with a pm_runtime_get_noresume().
when we read a debugfs memory, we're only reading the shared
memory between the host and DSP. We don't really copy memory
from the DSP's SRAM to the shared memory.
Signed-off-by: Ranjani Sridharan [email protected]