Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp158603lqs; Thu, 13 Jun 2024 06:51:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWpyim/nIYtvp8Nysy2/nNBZTD0ArL2hI7JiG4ZrsjFKH3OtA3/oVNaw8k3M0dAoEmd6t7kNvk9aVkeM67hawsE1b9mXwR+8/5rQaW3nA== X-Google-Smtp-Source: AGHT+IGgEy3o0ojBPZP+fhIxfcWjPN+9knUxgdZgA4NJxYwRRlA+U227bGlk4mutSMPOF0LJFQnJ X-Received: by 2002:a17:906:c259:b0:a6f:55e8:b357 with SMTP id a640c23a62f3a-a6f55e8e61fmr127039366b.10.1718286668387; Thu, 13 Jun 2024 06:51:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718286668; cv=pass; d=google.com; s=arc-20160816; b=NhKlC1+Ir7FyXogtf6fvNKLvR9VqZg0PU4tw5lcn/wdxM7huCKO9iEmWl8cQTmVnrI w11ujMR1QNb9B4TSXF3S2YUXOL4cJoWpp/ToLj6/u9Qk2OrDZ0Fde3jmgS9agCcS7pVk Yljq3vmZtp/GO/vsUDIfPW8YQFj4fddL/NpqWJK1pB+Ixvz8hCLNomvvcbFr2vsPtlbL LlbaDxQ5ZpRkgDWp2uZ5sEAQ0yBWexAhDz3lTqSeSYmp9hOSBHBXR38H1czEd+8sI6lQ 38oVPjXSJWaaj4kxmZrN/xTXjz1rzRiFdzSI9XNX+spcnQY1Jor7OT3Yrsy0pivM9BB/ Jj5A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=87qoC23DVLt7MKZNXl5MMqGxysljG9eHt2hKEDt1kjo=; fh=cLtOPLoOdgOVDuxiM/Zc07VLHGrh7PtlVdCxs0OyfDA=; b=j1129rF81zOk059gsYtQhYQZowu3H5Ktuw53FIWZSh0iGLv4PXZmVa1QZoyKUjX/e0 gZ13NAbiNa5DjF3R3APNdUEoA9v+NGH0eCOrvdVeGQyCMP55iW61UZplyg4tIqRYUxlA MfWKPT4PKEP0ntZ4ORxdZqDoVn4Iz9Rhk6lXKb7oN4tbyUHUwhUMgeNhtfGrGX9f9CU3 Y/T5aBSFsnP66YvqT4qzryBci9mjL701dsIjcpeyjTCBXHDA9GfWCPyUG+OVyVzx5wkN 9COb5gPTkJD6gxUcow/FJJgIurxwmYfXfBsv6tdlLA0MMYzKX7gsJzd8YIoGigoOZRuF +Igg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=n0FUOv3a; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-213368-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213368-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f56d21e16si69396266b.206.2024.06.13.06.51.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 06:51:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213368-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=n0FUOv3a; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-213368-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213368-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1E11E1F23D61 for ; Thu, 13 Jun 2024 13:51:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F2F53145B10; Thu, 13 Jun 2024 13:50:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="n0FUOv3a" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D726144D21; Thu, 13 Jun 2024 13:50:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718286640; cv=none; b=PdKr7UyeBOMeCmJTczqOVhg309NGGJ6CuiZ3LHgSEQw2gwbQx7tqY/qRxX+w9VHGsxhyMD7F64nDFHgRS/9YaVk3hnc39RUvnf/IrF0o0mSPRTy4syKIS4/omP/llrwMv6xz99hh6dxw/fSvxIKOANi/uUrpVBjj2rYEgBw2yiE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718286640; c=relaxed/simple; bh=th5seJF3vBX+X27ODP/uDhCZmMW2KCKtk8juv3MEKfg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D7zziaaBYQwyf58IYu6UlFRHQRYFZunnjt/7FqfcfJiIxJnTjUEi3u9XYQoT3JhrXnOIGHlfMRXRGUPHEPmjnzPehb1MHxMjOMnVTJTGGlTqnBgsTumxYiylmWCV9jMUPzSnEJtW7z1oOLtuT+7dwsAh2lTAxsU2Nc5XK9Z2Tnc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=n0FUOv3a; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1718286636; bh=th5seJF3vBX+X27ODP/uDhCZmMW2KCKtk8juv3MEKfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n0FUOv3agw37r9+4v5v97sFRYeVfEt9Poau2rpub37bk0MsW5XfHXFPpWrAcyZlsT xBiSmd/Av8NAZQjq8Op066tgjYtjv1cBDX9ZUxuT6FKcMDOgz9298q4F4AI/7PzVYP npg6AXeFRXzFZzQgzcnTRWpRIEzJIk+Kv5SYtt0FzlPYXzVc/LsAHnSzxcGT0p+VGc t9tGN/6WY6h++/VeLdedjlzv6liz/UTcmZyM5333OZhlzNWcwJ1NrZCo8QLa1qNm/F 7MwLHyywoqROiDYEHrwcSATTvSk3k1l9RmnSgwqTqhO5Bz7s20uaRORvmG47rx6PEY qOdqi/oNebkFA== Received: from jupiter.universe (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sre) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 997DA37821B5; Thu, 13 Jun 2024 13:50:36 +0000 (UTC) Received: by jupiter.universe (Postfix, from userid 1000) id 36AB84800CE; Thu, 13 Jun 2024 15:50:36 +0200 (CEST) From: Sebastian Reichel To: Ezequiel Garcia , Philipp Zabel , Nicolas Frattaroli , Heiko Stuebner Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jianfeng Liu , Emmanuel Gil Peyrot , Nicolas Dufresne , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel , kernel@collabora.com Subject: [PATCH v6 3/6] media: hantro: Disable multicore support Date: Thu, 13 Jun 2024 15:48:44 +0200 Message-ID: <20240613135034.31684-4-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240613135034.31684-1-sebastian.reichel@collabora.com> References: <20240613135034.31684-1-sebastian.reichel@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- .../media/platform/verisilicon/hantro_drv.c | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c index 34b123dafd89..7123479b3eab 100644 --- a/drivers/media/platform/verisilicon/hantro_drv.c +++ b/drivers/media/platform/verisilicon/hantro_drv.c @@ -992,6 +992,39 @@ static const struct media_device_ops hantro_m2m_media_ops = { .req_queue = v4l2_m2m_request_queue, }; +/* + * Some SoCs, like RK3588 have multiple identical Hantro cores, but the + * kernel is currently missing support for multi-core handling. Exposing + * separate devices for each core to userspace is bad, since that does + * not allow scheduling tasks properly (and creates ABI). With this workaround + * the driver will only probe for the first core and early exit for the other + * cores. Once the driver gains multi-core support, the same technique + * for detecting the main core can be used to cluster all cores together. + */ +static int hantro_disable_multicore(struct hantro_dev *vpu) +{ + const char *compatible; + struct device_node *node; + int ret; + + /* Intentionally ignores the fallback strings */ + ret = of_property_read_string(vpu->dev->of_node, "compatible", &compatible); + if (ret) + return ret; + + /* first compatible node found from the root node is considered the main core */ + node = of_find_compatible_node(NULL, NULL, compatible); + if (!node) + return -EINVAL; /* broken DT? */ + + if (vpu->dev->of_node != node) { + dev_info(vpu->dev, "missing multi-core support, ignoring this instance\n"); + return -ENODEV; + } + + return 0; +} + static int hantro_probe(struct platform_device *pdev) { const struct of_device_id *match; @@ -1011,6 +1044,10 @@ static int hantro_probe(struct platform_device *pdev) match = of_match_node(of_hantro_match, pdev->dev.of_node); vpu->variant = match->data; + ret = hantro_disable_multicore(vpu); + if (ret) + return ret; + /* * Support for nxp,imx8mq-vpu is kept for backwards compatibility * but it's deprecated. Please update your DTS file to use -- 2.43.0