UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Visitor maxrogozh
Visitor
527 Views
Registered: ‎08-01-2018

RPMSG reinitialization

  Hello! I have a question about reinitializing rpmsg on a RPU.  I successfully launched the standard echo_test example on the zynq-7000 platform. The libmetal rpmsg is initialized via remote application running on cpu1. I can access rmsg channel under linux(running on cpu0) using character device /dev/rpmsg0 created by rpmsg_user_dev_driver. When the symbol device /dev/rpmsg0 is closed, rpmsg_user_dev_driver sends to the remote kernel the SHUTDOWN_MSG message, after which the remote application terminates its work and destroys the rpmsg channel.  I want to modify RPU firmware in such a way, that when the character device /dev/rpmsg0 is closed, the remote application does not finish its work and does not destroy the rpmsg channel. (I mean that  I would like remote application was still working with active rpmsg channel).

  But I do not know how to do it correctly.
  The first thought was to comment out the processing logic of SHUTDOWN_MSG, but this did not result in success:
after several cycles of opening/closing of /dev /rpmsg0, the rpmsg_user_dev_driver module gives an error "unable to handle kernel paging request"

  The next thought was to destroy and re-create the rpmsg channel on the remote core. The sample code is below.

 

/*-----------------------------------------------------------------------------*
 *  Application
 *-----------------------------------------------------------------------------*/
int app(struct hil_proc *hproc)
{
	int status = 0;

	reInitLabel:
	
	/* Initialize RPMSG framework */
	LPRINTF("Try to init remoteproc resource\n");
	status = remoteproc_resource_init(&rsc_info, hproc,
				     rpmsg_channel_created,
				     rpmsg_channel_deleted, rpmsg_read_cb,
				     &proc, 0);

	if (RPROC_SUCCESS != status) {
		LPERROR("Failed  to initialize remoteproc resource.\n");
		return -1;
	}
	LPRINTF("Init remoteproc resource succeeded\n");

	hil_set_vdev_rst_cb(hproc, 0, virtio_rst_cb);

	LPRINTF("Waiting for events...\n");

	/* Stay in data processing loop until we receive a 'shutdown' message */
	while (1) {
		hil_poll(proc->proc, 0);

		/* we got a shutdown request, exit */
		if (evt_chnl_deleted) {
			break;
		}

		if (evt_virtio_rst) {
			/* vring rst callback, reset rpmsg */
			LPRINTF("De-initializing RPMsg\n");
			rpmsg_deinit(proc->rdev);
			proc->rdev = NULL;

			LPRINTF("Reinitializing RPMsg\n");
			status = rpmsg_init(hproc, &proc->rdev,
					    rpmsg_channel_created,
					    rpmsg_channel_deleted,
					    rpmsg_read_cb,
					    1);
			if (status != RPROC_SUCCESS) {
				LPERROR("Reinit RPMsg failed\n");
				break;
			}
			LPRINTF("Reinit RPMsg succeeded\n");
			evt_chnl_deleted=0;
			evt_virtio_rst = 0;
		}
	}

	
	LPRINTF("De-initializing RPMsg\n");
	rpmsg_deinit(proc->rdev);
	proc->rdev = NULL;
			
	/* disable interrupts and free resources */
	LPRINTF("De-initializating remoteproc resource\n");
	remoteproc_resource_deinit(proc);
	hil_delete_proc(hproc);
	
	/* Re-create proc instance */
	unsigned int proc_id = 0;
	hproc = platform_create_proc(proc_id);
	
	evt_chnl_deleted=0;
	evt_virtio_rst = 0;
	
	goto reInitLabel:


	return 0;
}

 

  The problem is that after remoteproc is reinitialized, the callback rpmsg_read_cb is immediately called with the SHUTDOWN_MSG message (even if rpmsg_user_dev_driver on Linux was unloaded), and remoteproc and rpmsg instances are removed immediately after reinitialization.

 

I will be glad to any help. Thanks.

 

0 Kudos