Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: hantro: Disable multicore support

Avoid exposing equal Hantro video codecs to userspace. Equal video
codecs allow scheduling work between the cores. For that kernel support
is required, which does not yet exist. Until that is implemented avoid
exposing each core separately to userspace so that multicore can be
added in the future without breaking userspace ABI.

This was written with Rockchip RK3588 in mind (which has 4 Hantro H1
cores), but applies to all SoCs.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

authored by

Sebastian Reichel and committed by
Hans Verkuil
ccdeb8d5 1e490a1e

+47
+47
drivers/media/platform/verisilicon/hantro_drv.c
··· 992 992 .req_queue = v4l2_m2m_request_queue, 993 993 }; 994 994 995 + /* 996 + * Some SoCs, like RK3588 have multiple identical Hantro cores, but the 997 + * kernel is currently missing support for multi-core handling. Exposing 998 + * separate devices for each core to userspace is bad, since that does 999 + * not allow scheduling tasks properly (and creates ABI). With this workaround 1000 + * the driver will only probe for the first core and early exit for the other 1001 + * cores. Once the driver gains multi-core support, the same technique 1002 + * for detecting the main core can be used to cluster all cores together. 1003 + */ 1004 + static int hantro_disable_multicore(struct hantro_dev *vpu) 1005 + { 1006 + struct device_node *node = NULL; 1007 + const char *compatible; 1008 + bool is_main_core; 1009 + int ret; 1010 + 1011 + /* Intentionally ignores the fallback strings */ 1012 + ret = of_property_read_string(vpu->dev->of_node, "compatible", &compatible); 1013 + if (ret) 1014 + return ret; 1015 + 1016 + /* The first compatible and available node found is considered the main core */ 1017 + do { 1018 + node = of_find_compatible_node(node, NULL, compatible); 1019 + if (of_device_is_available(node)) 1020 + break; 1021 + } while (node); 1022 + 1023 + if (!node) 1024 + return -EINVAL; 1025 + 1026 + is_main_core = (vpu->dev->of_node == node); 1027 + 1028 + of_node_put(node); 1029 + 1030 + if (!is_main_core) { 1031 + dev_info(vpu->dev, "missing multi-core support, ignoring this instance\n"); 1032 + return -ENODEV; 1033 + } 1034 + 1035 + return 0; 1036 + } 1037 + 995 1038 static int hantro_probe(struct platform_device *pdev) 996 1039 { 997 1040 const struct of_device_id *match; ··· 1053 1010 1054 1011 match = of_match_node(of_hantro_match, pdev->dev.of_node); 1055 1012 vpu->variant = match->data; 1013 + 1014 + ret = hantro_disable_multicore(vpu); 1015 + if (ret) 1016 + return ret; 1056 1017 1057 1018 /* 1058 1019 * Support for nxp,imx8mq-vpu is kept for backwards compatibility