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

platform_get_resource fails when it is a child of a simple-mfd node #152

Open
shenki opened this issue Apr 27, 2018 · 0 comments
Open

platform_get_resource fails when it is a child of a simple-mfd node #152

shenki opened this issue Apr 27, 2018 · 0 comments

Comments

@shenki
Copy link
Member

shenki commented Apr 27, 2018

This fails to load the timeriomem_rng driver:

                          syscon: syscon@1e6e2000 {
                                  compatible = "aspeed,ast2500-scu", "syscon", "simple-mfd";
                                  reg = <0x1e6e2000 0x1a8>;
                                  #address-cells = <1>;
                                  #size-cells = <0>;
                                  #clock-cells = <1>;
                                  #reset-cells = <1>;
                                  hwrng@78 {
                                          compatible = "timeriomem_rng";
                                          reg = <0x1e6e2078 0x4>;
                                          period = <1>;
                                          quality = <100>;
                                  };
                          };

The line that fails is in drivers/char/hw_random/timeriomem-rng.c timeriomem_rng_probe:

          res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
          if (!res)
                  return -ENXIO;

If I move the hwrng node out of the syscon, it does load.

amboar pushed a commit that referenced this issue Dec 10, 2024
[ Upstream commit cadae3a ]

The dtl_access_lock needs to be a rw_sempahore, a sleeping lock, because
the code calls kmalloc() while holding it, which can sleep:

  # echo 1 > /proc/powerpc/vcpudispatch_stats
  BUG: sleeping function called from invalid context at include/linux/sched/mm.h:337
  in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 199, name: sh
  preempt_count: 1, expected: 0
  3 locks held by sh/199:
   #0: c00000000a0743f8 (sb_writers#3){.+.+}-{0:0}, at: vfs_write+0x324/0x438
   #1: c0000000028c7058 (dtl_enable_mutex){+.+.}-{3:3}, at: vcpudispatch_stats_write+0xd4/0x5f4
   #2: c0000000028c70b8 (dtl_access_lock){+.+.}-{2:2}, at: vcpudispatch_stats_write+0x220/0x5f4
  CPU: 0 PID: 199 Comm: sh Not tainted 6.10.0-rc4 #152
  Hardware name: IBM pSeries (emulated by qemu) POWER9 (raw) 0x4e1202 0xf000005 of:SLOF,HEAD hv:linux,kvm pSeries
  Call Trace:
    dump_stack_lvl+0x130/0x148 (unreliable)
    __might_resched+0x174/0x410
    kmem_cache_alloc_noprof+0x340/0x3d0
    alloc_dtl_buffers+0x124/0x1ac
    vcpudispatch_stats_write+0x2a8/0x5f4
    proc_reg_write+0xf4/0x150
    vfs_write+0xfc/0x438
    ksys_write+0x88/0x148
    system_call_exception+0x1c4/0x5a0
    system_call_common+0xf4/0x258

Fixes: 06220d7 ("powerpc/pseries: Introduce rwlock to gatekeep DTLB usage")
Tested-by: Kajol Jain <kjain@linux.ibm.com>
Reviewed-by: Nysal Jan K.A <nysal@linux.ibm.com>
Reviewed-by: Kajol Jain <kjain@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://patch.msgid.link/20240819122401.513203-1-mpe@ellerman.id.au
Signed-off-by: Sasha Levin <sashal@kernel.org>
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

No branches or pull requests

1 participant