Skip to content

Commit 182b5f3

Browse files
iabdalkaderdpgeorge
authored andcommitted
alif/mpmetalport: Use MHU to notify remote cores.
Unlike HWSEM, the MHU IRQ can wake up cores from low-power modes, making it better suited for notifying remote cores. Note that no special function is required to wake up a remote core—the act of sending a message alone will notify it. Signed-off-by: iabdalkader <[email protected]>
1 parent b9e5f1f commit 182b5f3

File tree

2 files changed

+7
-38
lines changed

2 files changed

+7
-38
lines changed

ports/alif/mpmetalport.c

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,21 @@
2727
*/
2828

2929
#include ALIF_CMSIS_H
30-
#include "hwsem.h"
31-
3230
#include "py/mperrno.h"
3331
#include "py/mphal.h"
3432

3533
#include "metal/sys.h"
3634
#include "metal/utilities.h"
3735
#include "metal/device.h"
3836

37+
#include "se_services.h"
38+
3939
struct metal_state _metal;
4040
static mp_sched_node_t rproc_notify_node;
4141

4242
int metal_sys_init(const struct metal_init_params *params) {
4343
metal_unused(params);
4444

45-
// Reset the hardware semaphore.
46-
hwsem_reset(METAL_HSEM_DEVICE);
47-
#if MICROPY_PY_OPENAMP_HOST
48-
hwsem_reset(METAL_HSEM_REMOTE);
49-
#endif
50-
5145
// If cache management is not enabled, configure the MPU to disable
5246
// caching for the entire Open-AMP shared memory region.
5347
#ifndef VIRTIO_USE_DCACHE
@@ -59,18 +53,10 @@ int metal_sys_init(const struct metal_init_params *params) {
5953
#endif
6054

6155
metal_bus_register(&metal_generic_bus);
62-
63-
// Enable the hardware semaphore IRQ.
64-
NVIC_ClearPendingIRQ(METAL_HSEM_IRQn);
65-
NVIC_SetPriority(METAL_HSEM_IRQn, IRQ_PRI_HWSEM);
66-
NVIC_EnableIRQ(METAL_HSEM_IRQn);
6756
return 0;
6857
}
6958

7059
void metal_sys_finish(void) {
71-
NVIC_DisableIRQ(METAL_HSEM_IRQn);
72-
NVIC_ClearPendingIRQ(METAL_HSEM_IRQn);
73-
hwsem_reset(METAL_HSEM_DEVICE);
7460
metal_bus_unregister(&metal_generic_bus);
7561
}
7662

@@ -99,15 +85,12 @@ void metal_machine_cache_invalidate(void *addr, unsigned int len) {
9985
}
10086

10187
int metal_rproc_notify(void *priv, uint32_t id) {
102-
// Release the HW semaphore to notify the other core.
103-
hwsem_release(METAL_HSEM_REMOTE, HWSEM_MASTERID);
88+
// Notify the remote core.
89+
se_services_notify();
10490
return 0;
10591
}
10692

107-
void METAL_HSEM_IRQ_HANDLER(void) {
108-
// Schedule the node only if the other core released the Semaphore.
109-
if (METAL_HSEM_DEVICE->HWSEM_REL_REG == 0) {
110-
mp_sched_schedule_node(&rproc_notify_node, openamp_remoteproc_notified);
111-
}
112-
hwsem_request(METAL_HSEM_DEVICE, METAL_HSEM_REMOTE_ID);
93+
void metal_rproc_notified(void) {
94+
// The remote core notified this core.
95+
mp_sched_schedule_node(&rproc_notify_node, openamp_remoteproc_notified);
11396
}

ports/alif/mpmetalport.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,6 @@
3838

3939
#define METAL_MAX_DEVICE_REGIONS 2
4040

41-
#if MICROPY_PY_OPENAMP_HOST
42-
#define METAL_HSEM_DEVICE ((HWSEM_Type *)HWSEM14_BASE)
43-
#define METAL_HSEM_REMOTE ((HWSEM_Type *)HWSEM15_BASE)
44-
#define METAL_HSEM_REMOTE_ID (0x410FD222U)
45-
#define METAL_HSEM_IRQn HWSEM_IRQ14_IRQn
46-
#define METAL_HSEM_IRQ_HANDLER HWSEM_IRQ14Handler
47-
#else
48-
#define METAL_HSEM_DEVICE ((HWSEM_Type *)HWSEM15_BASE)
49-
#define METAL_HSEM_REMOTE ((HWSEM_Type *)HWSEM14_BASE)
50-
#define METAL_HSEM_REMOTE_ID (0x410FD221U)
51-
#define METAL_HSEM_IRQn HWSEM_IRQ15_IRQn
52-
#define METAL_HSEM_IRQ_HANDLER HWSEM_IRQ15Handler
53-
#endif
54-
5541
// Set to 1 to enable log output.
5642
#define METAL_LOG_HANDLER_ENABLE 0
5743

0 commit comments

Comments
 (0)