Skip to content

Commit 27762b9

Browse files
bentheredonethatzeddii
authored andcommitted
openamp: xlnx: xlnx_rpmsg_ipi_parse: simplify logic
Signed-off-by: Ben Levinsky <[email protected]>
1 parent d059e2a commit 27762b9

File tree

1 file changed

+15
-93
lines changed

1 file changed

+15
-93
lines changed

lopper/assists/openamp_xlnx.py

Lines changed: 15 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -260,112 +260,34 @@ def xlnx_rpmsg_construct_carveouts(tree, carveouts, rpmsg_carveouts, native, cha
260260
return True
261261

262262

263-
def xlnxl_rpmsg_ipi_get_ipi_id(tree, ipi, role):
264-
ipi_node = None
265-
ipi_id_prop_name = "xlnx,ipi-id"
266-
ipi_node = tree.pnode( ipi )
267-
268-
if ipi_node == None:
269-
print("ERROR: Unable to find ipi: ", ipi, " for role: ", role)
270-
return False
271-
272-
ipi_id = ipi_node.props(ipi_id_prop_name)
273-
if ipi_id == []:
274-
print("ERROR: Unable to find IPI ID for ", ipi)
275-
return False
276-
277-
return ipi_id[0]
278-
279-
280-
def xlnx_rpmsg_ipi_parse_per_channel(remote_ipi, host_ipi, tree, node, openamp_channel_info,
281-
remote_node, channel_id, native, channel_index,
282-
verbose = 0):
283-
print(" -> xlnx_rpmsg_ipi_parse_per_channel", channel_id, host_ipi, remote_ipi, channel_index)
284-
285-
ipi_id_prop_name = "xlnx,ipi-id"
286-
platform = openamp_channel_info["platform"]
287-
buffered_ipi_chan = True
288-
289-
host_ipi_id = xlnxl_rpmsg_ipi_get_ipi_id(tree, host_ipi[channel_index], "host")
290-
291-
if host_ipi_id == False:
292-
return host_ipi_id
293-
294-
remote_ipi_id = xlnxl_rpmsg_ipi_get_ipi_id(tree, remote_ipi, "remote")
295-
if remote_ipi_id == False:
296-
return remote_ipi_id
297-
298-
host_ipi = tree.pnode( host_ipi[channel_index])
299-
300-
if platform in [ SOC_TYPE.VERSAL_NET , SOC_TYPE.VERSAL2 ] and (host_ipi_id.value[0] >= 9 or remote_ipi_id.value[0] >= 9):
301-
buffered_ipi_chan = False
302-
303-
# find host to remote buffers
304-
host_to_remote_ipi_channel = None
305-
for subnode in host_ipi.subnodes():
306-
subnode_ipi_id = subnode.props(ipi_id_prop_name)
307-
if subnode_ipi_id != [] and remote_ipi_id.value[0] == subnode_ipi_id[0].value[0]:
308-
openamp_channel_info["host_to_remote_ipi_channel_" + channel_id] = subnode
309-
host_to_remote_ipi_channel = subnode
310-
if host_to_remote_ipi_channel == None and buffered_ipi_chan:
311-
print("WARNING no host to remote IPI channel has been found.")
312-
return False
313-
314-
remote_ipi = tree.pnode( remote_ipi )
315-
316-
# find remote to host buffers
317-
remote_to_host_ipi_channel = None
318-
for subnode in remote_ipi.subnodes():
319-
subnode_ipi_id = subnode.props(ipi_id_prop_name)
320-
if subnode_ipi_id != [] and host_ipi_id.value[0] == subnode_ipi_id[0].value[0]:
321-
openamp_channel_info["remote_to_host_ipi_channel_" + channel_id] = subnode
322-
remote_to_host_ipi_channel = subnode
323-
if remote_to_host_ipi_channel == None and buffered_ipi_chan:
324-
print("WARNING no remote to host IPI channel has been found.")
325-
return False
326-
327-
openamp_channel_info["host_ipi_"+channel_id] = host_ipi
328-
openamp_channel_info["remote_ipi_"+channel_id] = remote_ipi
329-
330-
return True
331-
332-
333263
def xlnx_rpmsg_ipi_parse(tree, node, openamp_channel_info,
334264
remote_node, channel_id, native, channel_index,
335265
verbose = 0 ):
336266
print(" -> xlnx_rpmsg_ipi_parse", node, remote_node, channel_index, channel_id)
337267

338-
amba_node = None
339-
ipi_id_prop_name = "xlnx,ipi-id"
340-
host_to_remote_ipi = None
341-
remote_to_host_ipi = None
342-
343-
# collect host ipi
344-
host_ipi_prop = node.props("mbox")
345-
if host_ipi_prop == []:
346-
print("ERROR: ", node, " is missing mbox property")
347-
return False
348-
349-
host_ipi_prop = host_ipi_prop[0].value
350268
remote_rpmsg_relation = None
351269
try:
352270
remote_rpmsg_relation = tree[remote_node.abs_path + "/domain-to-domain/rpmsg-relation"]
353271
except:
354272
print("ERROR: ", remote_node, " is missing rpmsg relation")
355273
return False
356274

357-
# collect remote ipi
358-
remote_ipi_prop = remote_rpmsg_relation.props("mbox")
359-
if remote_ipi_prop == []:
360-
print("ERROR: ", remote_node, " is missing mbox property")
361-
return False
362-
363-
remote_ipi_prop = remote_ipi_prop[0].value
275+
# for each relevant IPI
276+
# find its mbox property in the relation node
277+
# map the mbox property phandle to a node in the tree
278+
# save node for later use
279+
#
280+
# note for remote relation only one mbox value is used so index at 0
281+
for (relation_node, role, idx) in [ (node, "host", channel_index), (remote_rpmsg_relation, "remote", 0) ]:
282+
if relation_node.propval("mbox") == ['']:
283+
print("ERROR: ", relation_node, " is missing mbox property")
284+
return False
285+
ipi_node = tree.pnode( relation_node.propval("mbox")[idx] )
286+
if ipi_node == None:
287+
print("ERROR: Unable to find ipi: ", ipi_phandle, " for role", role)
288+
return False
364289

365-
ret = xlnx_rpmsg_ipi_parse_per_channel(remote_ipi_prop[0], host_ipi_prop, tree, node, openamp_channel_info,
366-
remote_node, channel_id, native, channel_index, verbose)
367-
if ret != True:
368-
return False
290+
openamp_channel_info[f"{role}_ipi_{channel_id}"] = ipi_node
369291

370292
return True
371293

0 commit comments

Comments
 (0)