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

PRU /dev/rpmsg_pruXX is not closed when PRU stopped and queue was fully consumed #185

Open
nahuel opened this issue Sep 28, 2018 · 3 comments

Comments

@nahuel
Copy link

nahuel commented Sep 28, 2018

To reproduce the problem:

cd /tmp
git clone git://git.ti.com/pru-software-support-package/pru-software-support-package.git
cd /tmp/pru-software-support-package/examples/am335x/PRU_RPMsg_Echo_Interrupt0
export PRU_CGT=/usr/share/ti/cgt-pru
make
cp gen/PRU_RPMsg_Echo_Interrupt0.out /lib/firmware/am335x-pru0-fw
echo start > /sys/class/remoteproc/remoteproc1/state

Now dmesg will show:

[  142.480770] remoteproc remoteproc1: powering up 4a334000.pru
[  142.487884] remoteproc remoteproc1: Booting fw image am335x-pru0-fw, size 74432
[  142.500918] pruss 4a300000.pruss: configured system_events[63-0] = 0x00000000.00030000
[  142.511928] pruss 4a300000.pruss: configured intr_channels = 0x00000005 host_intr = 0x00000005
[  142.528225] remoteproc remoteproc1: registered virtio0 (type 7)
[  142.540164] remoteproc remoteproc1: remote processor 4a334000.pru is now up
[  142.597314] virtio_rpmsg_bus virtio0: creating channel rpmsg-pru addr 0x1e
[  142.605230] virtio_rpmsg_bus virtio0: rpmsg host is online
[  142.641390] rpmsg_pru virtio0.rpmsg-pru.-1.30: new rpmsg_pru device: /dev/rpmsg_pru30

Then do:

echo hello > /dev/rpmsg_pru30

And open a new console and execute this without killing cat, keep it active:

# cat /dev/rpmsg_pru30
hello

Now stop the PRU:

echo stop > /sys/class/remoteproc/remoteproc1/state

dmesg will show:

[  163.736825] pruss 4a300000.pruss: unconfigured system_events[63-0] = 0x00000000.00030000
[  163.755473] pruss 4a300000.pruss: unconfigured host_intr = 0x00000005
[  163.773323] remoteproc remoteproc1: stopped remote processor 4a334000.pru

And now /dev/rpmsg_pru30 is removed but cat has the file descriptor opened. The problem is cat DOESN'T STOP. I think the correct kernel behaviour is to close the file descriptor after the PRU is stopped and the queue is fully consumed, so the user-space program has a way to know it needs to finish.

@jadonk
Copy link
Sponsor Member

jadonk commented Oct 26, 2018

Makes sense. We should bring it up on linux-omap.

@pdp7
Copy link
Contributor

pdp7 commented Jun 10, 2020

@nahuel @jadonk does this still happen with the current images?

@MarkAYoder this might be a good thing to check while doing the PRU cookbook

@MarkAYoder
Copy link

@pdp7 I was able to reproduce this on both a BB Black and the AI.

Sorry, no solution.

RobertCNelson pushed a commit that referenced this issue Sep 25, 2020
commit c92d30e upstream.

In commit f3b98e3 ("media: vsp1: Provide support for extended
command pools"), the vsp pointer used for referencing the VSP1 device
structure from a command pool during vsp1_dl_ext_cmd_pool_destroy() was
not populated.

Correctly assign the pointer to prevent the following
null-pointer-dereference when removing the device:

[*] h3ulcb-kf #>
echo fea28000.vsp > /sys/bus/platform/devices/fea28000.vsp/driver/unbind
 Unable to handle kernel NULL pointer dereference at virtual address 0000000000000028
 Mem abort info:
   ESR = 0x96000006
   EC = 0x25: DABT (current EL), IL = 32 bits
   SET = 0, FnV = 0
   EA = 0, S1PTW = 0
 Data abort info:
   ISV = 0, ISS = 0x00000006
   CM = 0, WnR = 0
 user pgtable: 4k pages, 48-bit VAs, pgdp=00000007318be000
 [0000000000000028] pgd=00000007333a1003, pud=00000007333a6003, pmd=0000000000000000
 Internal error: Oops: 96000006 [#1] PREEMPT SMP
 Modules linked in:
 CPU: 1 PID: 486 Comm: sh Not tainted 5.7.0-rc6-arm64-renesas-00118-ge644645abf47 #185
 Hardware name: Renesas H3ULCB Kingfisher board based on r8a77951 (DT)
 pstate: 40000005 (nZcv daif -PAN -UAO)
 pc : vsp1_dlm_destroy+0xe4/0x11c
 lr : vsp1_dlm_destroy+0xc8/0x11c
 sp : ffff800012963b60
 x29: ffff800012963b60 x28: ffff0006f83fc440
 x27: 0000000000000000 x26: ffff0006f5e13e80
 x25: ffff0006f5e13ed0 x24: ffff0006f5e13ed0
 x23: ffff0006f5e13ed0 x22: dead000000000122
 x21: ffff0006f5e3a080 x20: ffff0006f5df2938
 x19: ffff0006f5df2980 x18: 0000000000000003
 x17: 0000000000000000 x16: 0000000000000016
 x15: 0000000000000003 x14: 00000000000393c0
 x13: ffff800011a5ec18 x12: ffff800011d8d000
 x11: ffff0006f83fcc68 x10: ffff800011a53d70
 x9 : ffff8000111f3000 x8 : 0000000000000000
 x7 : 0000000000210d00 x6 : 0000000000000000
 x5 : ffff800010872e60 x4 : 0000000000000004
 x3 : 0000000078068000 x2 : ffff800012781000
 x1 : 0000000000002c00 x0 : 0000000000000000
 Call trace:
  vsp1_dlm_destroy+0xe4/0x11c
  vsp1_wpf_destroy+0x10/0x20
  vsp1_entity_destroy+0x24/0x4c
  vsp1_destroy_entities+0x54/0x130
  vsp1_remove+0x1c/0x40
  platform_drv_remove+0x28/0x50
  __device_release_driver+0x178/0x220
  device_driver_detach+0x44/0xc0
  unbind_store+0xe0/0x104
  drv_attr_store+0x20/0x30
  sysfs_kf_write+0x48/0x70
  kernfs_fop_write+0x148/0x230
  __vfs_write+0x18/0x40
  vfs_write+0xdc/0x1c4
  ksys_write+0x68/0xf0
  __arm64_sys_write+0x18/0x20
  el0_svc_common.constprop.0+0x70/0x170
  do_el0_svc+0x20/0x80
  el0_sync_handler+0x134/0x1b0
  el0_sync+0x140/0x180
 Code: b40000c2 f9403a60 d2800084 a9400663 (f9401400)
 ---[ end trace 3875369841fb288a ]---

Fixes: f3b98e3 ("media: vsp1: Provide support for extended command pools")
Cc: stable@vger.kernel.org # v4.19+
Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants