diff options
author | Sam Nelson <sam.nelson@ti.com> | 2020-01-20 14:44:56 -0500 |
---|---|---|
committer | Sam Nelson <sam.nelson@ti.com> | 2020-01-31 11:29:04 -0500 |
commit | 77c681fb002b05d3f2fc048987f48bef88fa9f33 (patch) | |
tree | c858988c6cef66d03641f6591445b4b027b4065f | |
parent | 04c97cd4ba19221290278a0ee515d6224ee04049 (diff) | |
download | ipc-77c681fb002b05d3f2fc048987f48bef88fa9f33.tar.gz |
VirtQueue: K2: poll for init completion status
Virtqueue device address is provided by host, so poll the completion
status for this operation before proceeding. Otherwise we end up using
bad virtqueue address.
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
-rw-r--r-- | packages/ti/ipc/family/tci6638/VirtQueue.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/packages/ti/ipc/family/tci6638/VirtQueue.c b/packages/ti/ipc/family/tci6638/VirtQueue.c index 804bf48..9892a3d 100644 --- a/packages/ti/ipc/family/tci6638/VirtQueue.c +++ b/packages/ti/ipc/family/tci6638/VirtQueue.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2019 Texas Instruments Incorporated - http://www.ti.com + * Copyright (c) 2011-2020 Texas Instruments Incorporated - http://www.ti.com * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -62,6 +62,7 @@ #include <ti/sysbios/knl/Swi.h> #include <ti/ipc/remoteproc/Resource.h> +#include <ti/ipc/remoteproc/rsc_types.h> #include <ti/ipc/MultiProc.h> @@ -72,6 +73,17 @@ #include <ti/ipc/rpmsg/_VirtQueue.h> #include <ti/ipc/rpmsg/virtio_ring.h> +/* + * The following three VIRTIO_* defines must match those in + * <Linux_kernel>/include/uapi/linux/virtio_config.h + */ +#define VIRTIO_CONFIG_S_ACKNOWLEDGE 1 +#define VIRTIO_CONFIG_S_DRIVER 2 +#define VIRTIO_CONFIG_S_DRIVER_OK 4 + +#define VRING_BUFS_PRIMED (VIRTIO_CONFIG_S_ACKNOWLEDGE | \ + VIRTIO_CONFIG_S_DRIVER | VIRTIO_CONFIG_S_DRIVER_OK) + /* Used for defining the size of the virtqueue registry */ #define NUM_QUEUES 2 @@ -113,6 +125,17 @@ Void VirtQueue_init() UInt16 clusterId; UInt16 procId; + if (!VirtQueue_module->virtQueueInitialized) { + Log_print1(Diags_USER1, "_VirtQueue_init: VDEV status: 0x%x\n", + Resource_getVdevStatus(VIRTIO_ID_RPMSG)); + Log_print0(Diags_USER1, "_VirtQueue_init: Polling VDEV status...\n"); + while (Resource_getVdevStatus(VIRTIO_ID_RPMSG) != VRING_BUFS_PRIMED); + Log_print1(Diags_USER1, "_VirtQueue_init: VDEV status synced: 0x%x\n", + Resource_getVdevStatus(VIRTIO_ID_RPMSG)); + + VirtQueue_module->virtQueueInitialized = 1; + } + /* VirtQueue_init() must be called before MultiProcSetup_init(). * Check the xdc_runtime_Startup_firstFxns__A array in the XDC * generated code. Abort if the procId has already been set; we |