host: isp: Deprecate nvhost syncpt APIs

Replace Nvhost syncpt APIs with host1x equivalents in the ISP
host1x driver and the ISP channel driver.
Note the WAR to include host1x-next.h before nvhost.h. The nvhost.h
header will be deprecated in the future.

Bug 4922416

Change-Id: I2dd298d60e1a55fe7a0cbb3ae804f5aa3b5d3610
Signed-off-by: Akihiro Mizusawa <amizusawa@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3300668
Reviewed-by: Chinniah Poosapadi <cpoosapadi@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Frank Chen <frankc@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: FNU Raunak <fraunak@nvidia.com>
This commit is contained in:
Akihiro Mizusawa
2025-02-11 23:18:38 +00:00
committed by Jon Hunter
parent da67f89f15
commit cb4fd77199
2 changed files with 62 additions and 10 deletions

View File

@@ -23,6 +23,12 @@
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/nospec.h> #include <linux/nospec.h>
/*
* The host1x-next.h header must be included before the nvhost.h
* header, as the nvhost.h header includes the host1x.h header,
* which is mutually exclusive with host1x-next.h.
*/
#include <linux/host1x-next.h>
#include <linux/nvhost.h> #include <linux/nvhost.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/printk.h> #include <linux/printk.h>
@@ -170,6 +176,8 @@ static int isp_capture_setup_syncpt(
struct syncpoint_info *sp) struct syncpoint_info *sp)
{ {
struct platform_device *pdev = chan->ndev; struct platform_device *pdev = chan->ndev;
struct nvhost_device_data *pdata = platform_get_drvdata(pdev);
struct host1x_syncpt *host1x_sp;
uint32_t gos_index = GOS_INDEX_INVALID; uint32_t gos_index = GOS_INDEX_INVALID;
uint32_t gos_offset = 0; uint32_t gos_offset = 0;
int err; int err;
@@ -184,9 +192,13 @@ static int isp_capture_setup_syncpt(
if (err) if (err)
return err; return err;
err = nvhost_syncpt_read_ext_check(pdev, sp->id, &sp->threshold); host1x_sp = host1x_syncpt_get_by_id_noref(pdata->host1x, sp->id);
if (err) if (!host1x_sp) {
err = -EINVAL;
goto cleanup; goto cleanup;
}
sp->threshold = host1x_syncpt_read(host1x_sp);
err = chan->ops->get_syncpt_gos_backing(pdev, sp->id, &sp->shim_addr, err = chan->ops->get_syncpt_gos_backing(pdev, sp->id, &sp->shim_addr,
&gos_index, &gos_offset); &gos_index, &gos_offset);
@@ -314,17 +326,19 @@ static int isp_capture_read_syncpt(
struct syncpoint_info *sp, struct syncpoint_info *sp,
uint32_t *val) uint32_t *val)
{ {
int err; struct platform_device *pdev = chan->ndev;
struct nvhost_device_data *pdata = platform_get_drvdata(pdev);
struct host1x_syncpt *host1x_sp;
if (sp->id) { if (sp->id) {
err = nvhost_syncpt_read_ext_check(chan->ndev, host1x_sp = host1x_syncpt_get_by_id_noref(pdata->host1x, sp->id);
sp->id, val); if (!host1x_sp) {
if (err < 0) {
dev_err(chan->isp_dev, dev_err(chan->isp_dev,
"%s: get syncpt %i val failed\n", __func__, "%s: get syncpt %i val failed\n", __func__,
sp->id); sp->id);
return -EINVAL; return -EINVAL;
} }
*val = host1x_syncpt_read(host1x_sp);
} }
return 0; return 0;

View File

@@ -1,9 +1,15 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
// SPDX-FileCopyrightText: Copyright (c) 2017-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-FileCopyrightText: Copyright (c) 2017-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#include <nvidia/conftest.h> #include <nvidia/conftest.h>
#include <asm/ioctls.h> #include <asm/ioctls.h>
/*
* The host1x-next.h header must be included before the nvhost.h
* header, as the nvhost.h header includes the host1x.h header,
* which is mutually exclusive with host1x-next.h.
*/
#include <linux/host1x-next.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/device.h> #include <linux/device.h>
@@ -49,13 +55,24 @@ static int isp5_alloc_syncpt(struct platform_device *pdev,
uint32_t *syncpt_id) uint32_t *syncpt_id)
{ {
uint32_t id; uint32_t id;
struct nvhost_device_data *pdata = platform_get_drvdata(pdev);
struct host1x_syncpt *sp = NULL;
if (syncpt_id == NULL) { if (syncpt_id == NULL) {
dev_err(&pdev->dev, "%s: null argument\n", __func__); dev_err(&pdev->dev, "%s: null argument\n", __func__);
return -EINVAL; return -EINVAL;
} }
id = nvhost_get_syncpt_client_managed(pdev, name); sp = host1x_syncpt_alloc(pdata->host1x, HOST1X_SYNCPT_CLIENT_MANAGED,
name ? name : dev_name(&pdev->dev));
if (!sp) {
dev_err(&pdev->dev,
"%s: allocation of requested sync point failed (name=%s, size=%d)\n",
__func__, name ? name : "", GFP_KERNEL);
return -ENOMEM;
}
id = host1x_syncpt_id(sp);
if (id == 0) { if (id == 0) {
dev_err(&pdev->dev, "%s: syncpt allocation failed\n", __func__); dev_err(&pdev->dev, "%s: syncpt allocation failed\n", __func__);
return -ENODEV; return -ENODEV;
@@ -68,14 +85,35 @@ static int isp5_alloc_syncpt(struct platform_device *pdev,
static void isp5_release_syncpt(struct platform_device *pdev, uint32_t id) static void isp5_release_syncpt(struct platform_device *pdev, uint32_t id)
{ {
struct nvhost_device_data *pdata = platform_get_drvdata(pdev);
struct host1x_syncpt *sp = NULL;
dev_dbg(&pdev->dev, "%s: id=%u\n", __func__, id); dev_dbg(&pdev->dev, "%s: id=%u\n", __func__, id);
nvhost_syncpt_put_ref_ext(pdev, id);
sp = host1x_syncpt_get_by_id_noref(pdata->host1x, id);
if (WARN_ON(!sp))
return;
host1x_syncpt_put(sp);
} }
static void isp5_fast_forward_syncpt(struct platform_device *pdev, uint32_t id, uint32_t threshold) static void isp5_fast_forward_syncpt(struct platform_device *pdev, uint32_t id, uint32_t threshold)
{ {
struct nvhost_device_data *pdata = platform_get_drvdata(pdev);
struct host1x_syncpt *sp = NULL;
uint32_t cur;
dev_dbg(&pdev->dev, "%s: id=%u -> thresh=%u\n", __func__, id, threshold); dev_dbg(&pdev->dev, "%s: id=%u -> thresh=%u\n", __func__, id, threshold);
nvhost_syncpt_set_min_update(pdev, id, threshold);
sp = host1x_syncpt_get_by_id_noref(pdata->host1x, id);
if (WARN_ON(!sp))
return;
cur = host1x_syncpt_read(sp);
while (cur++ != threshold)
host1x_syncpt_incr(sp);
host1x_syncpt_read(sp);
} }
static int isp5_get_syncpt_gos_backing(struct platform_device *pdev, static int isp5_get_syncpt_gos_backing(struct platform_device *pdev,