aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorKristofer Jonsson <kristofer.jonsson@arm.com>2023-01-04 17:09:28 +0100
committerKristofer Jonsson <kristofer.jonsson@arm.com>2023-02-02 16:11:45 +0100
commitb42bc0b95dcc5fac60d52e956056fd46bfe2beb9 (patch)
tree3e739e1d609a669cdfef21ffb302fcfb92423ada /kernel
parenta70bfde653b44763e2f4d230d30aa8382c1ac5f9 (diff)
downloadethos-u-linux-driver-stack-b42bc0b95dcc5fac60d52e956056fd46bfe2beb9.tar.gz
Removing watchdog and reset
Removing watchdog and firmware reset as a preparations for the migrations to rpmsg. Change-Id: Ic1053e3f4301ecadbde8c59dbaed437625a0a5ea
Diffstat (limited to 'kernel')
-rw-r--r--kernel/Kbuild3
-rw-r--r--kernel/ethosu_cancel_inference.c34
-rw-r--r--kernel/ethosu_capabilities.c16
-rw-r--r--kernel/ethosu_device.c101
-rw-r--r--kernel/ethosu_device.h24
-rw-r--r--kernel/ethosu_inference.c33
-rw-r--r--kernel/ethosu_mailbox.c58
-rw-r--r--kernel/ethosu_mailbox.h16
-rw-r--r--kernel/ethosu_network_info.c21
-rw-r--r--kernel/ethosu_watchdog.c130
-rw-r--r--kernel/ethosu_watchdog.h82
11 files changed, 19 insertions, 499 deletions
diff --git a/kernel/Kbuild b/kernel/Kbuild
index d4610bc..867d6aa 100644
--- a/kernel/Kbuild
+++ b/kernel/Kbuild
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2020,2022 Arm Limited.
+# Copyright 2020,2022-2023 Arm Limited and/or its affiliates
#
# This program is free software and is provided to you under the terms of the
# GNU General Public License version 2 as published by the Free Software
@@ -27,6 +27,5 @@ ethosu-objs := ethosu_driver.o \
ethosu_mailbox.o \
ethosu_network.o \
ethosu_network_info.o \
- ethosu_watchdog.o \
ethosu_capabilities.o \
ethosu_cancel_inference.o
diff --git a/kernel/ethosu_cancel_inference.c b/kernel/ethosu_cancel_inference.c
index e2acb22..c1d31b3 100644
--- a/kernel/ethosu_cancel_inference.c
+++ b/kernel/ethosu_cancel_inference.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022 Arm Limited.
+ * Copyright 2022-2023 Arm Limited and/or its affiliates
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
@@ -61,25 +61,6 @@ static void ethosu_cancel_inference_fail(struct ethosu_mailbox_msg *msg)
complete(&cancellation->done);
}
-static int ethosu_cancel_inference_complete(struct ethosu_mailbox_msg *msg)
-{
- struct ethosu_cancel_inference *cancellation =
- container_of(msg, typeof(*cancellation), msg);
-
- if (completion_done(&cancellation->done))
- return 0;
-
- cancellation->errno = 0;
- cancellation->uapi->status =
- cancellation->inf->done &&
- cancellation->inf->status != ETHOSU_UAPI_STATUS_OK ?
- ETHOSU_UAPI_STATUS_OK :
- ETHOSU_UAPI_STATUS_ERROR;
- complete(&cancellation->done);
-
- return 0;
-}
-
int ethosu_cancel_inference_request(struct ethosu_inference *inf,
struct ethosu_uapi_cancel_inference_status *uapi)
{
@@ -111,10 +92,6 @@ int ethosu_cancel_inference_request(struct ethosu_inference *inf,
init_completion(&cancellation->done);
cancellation->msg.fail = ethosu_cancel_inference_fail;
- /* Never resend messages but always complete, since we have restart the
- * whole firmware and marked the inference as aborted */
- cancellation->msg.resend = ethosu_cancel_inference_complete;
-
ret = ethosu_mailbox_register(&cancellation->edev->mailbox,
&cancellation->msg);
if (ret < 0)
@@ -151,15 +128,6 @@ int ethosu_cancel_inference_request(struct ethosu_inference *inf,
goto deregister;
}
- /* if cancellation failed and the inference did not complete then reset
- * the firmware */
- if (cancellation->uapi->status == ETHOSU_UAPI_STATUS_ERROR &&
- !cancellation->inf->done) {
- ret = ethosu_firmware_reset(cancellation->edev);
- if (ret)
- goto deregister;
- }
-
deregister:
ethosu_mailbox_deregister(&cancellation->edev->mailbox,
&cancellation->msg);
diff --git a/kernel/ethosu_capabilities.c b/kernel/ethosu_capabilities.c
index d5f77f2..9735ee2 100644
--- a/kernel/ethosu_capabilities.c
+++ b/kernel/ethosu_capabilities.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022 Arm Limited.
+ * Copyright 2022-2023 Arm Limited and/or its affiliates
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
@@ -58,19 +58,6 @@ static void ethosu_capabilities_fail(struct ethosu_mailbox_msg *msg)
complete(&cap->done);
}
-static int ethosu_capabilities_resend(struct ethosu_mailbox_msg *msg)
-{
- struct ethosu_capabilities *cap =
- container_of(msg, typeof(*cap), msg);
-
- /* Don't resend request if response has already been received */
- if (completion_done(&cap->done))
- return 0;
-
- /* Resend request */
- return ethosu_capabilities_send(cap);
-}
-
void ethosu_capability_rsp(struct ethosu_device *edev,
struct ethosu_core_msg_capabilities_rsp *rsp)
{
@@ -126,7 +113,6 @@ int ethosu_capabilities_request(struct ethosu_device *edev,
cap->uapi = uapi;
init_completion(&cap->done);
cap->msg.fail = ethosu_capabilities_fail;
- cap->msg.resend = ethosu_capabilities_resend;
ret = ethosu_mailbox_register(&cap->edev->mailbox, &cap->msg);
if (ret < 0)
diff --git a/kernel/ethosu_device.c b/kernel/ethosu_device.c
index 0f1a284..36b776f 100644
--- a/kernel/ethosu_device.c
+++ b/kernel/ethosu_device.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2022 Arm Limited.
+ * Copyright 2020-2023 Arm Limited and/or its affiliates
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
@@ -39,7 +39,6 @@
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/of_reserved_mem.h>
-#include <linux/reset.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
@@ -204,85 +203,6 @@ static int ethosu_handle_msg(struct ethosu_device *edev)
return ret;
}
-int ethosu_firmware_reset(struct ethosu_device *edev)
-{
- int ret;
-
- /* No reset control for this device */
- if (IS_ERR(edev->reset))
- return PTR_ERR(edev->reset);
-
- dev_info(edev->dev, "Resetting firmware.");
-
- ret = reset_control_assert(edev->reset);
- if (ret) {
- dev_err(edev->dev, "Failed to reset assert firmware. ret=%d",
- ret);
-
- return ret;
- }
-
- /* Initialize mailbox header with illegal values */
- ethosu_mailbox_wait_prepare(&edev->mailbox);
-
- /* If this call fails we have a problem. We managed halt the firmware,
- * but not to release the reset.
- */
- ret = reset_control_deassert(edev->reset);
- if (ret) {
- dev_err(edev->dev, "Failed to reset deassert firmware. ret=%d",
- ret);
- goto fail;
- }
-
- /* Wait for firmware to boot up and initialize mailbox */
- ret = ethosu_mailbox_wait_firmware(&edev->mailbox);
- if (ret) {
- dev_err(edev->dev, "Wait on firmware boot timed out. ret=%d",
- ret);
- goto fail;
- }
-
- edev->mailbox.ping_count = 0;
- ethosu_watchdog_reset(&edev->watchdog);
-
- ret = ethosu_mailbox_ping(&edev->mailbox);
- if (ret) {
- dev_warn(edev->dev,
- "Failed to send ping after firmware reset. ret=%d",
- ret);
- goto fail;
- }
-
- /* Resend messages */
- ethosu_mailbox_resend(&edev->mailbox);
-
- return ret;
-
-fail:
- ethosu_mailbox_fail(&edev->mailbox);
-
- return ret;
-}
-
-static void ethosu_watchdog_callback(struct ethosu_watchdog *wdog)
-{
- struct ethosu_device *edev =
- container_of(wdog, struct ethosu_device, watchdog);
-
- mutex_lock(&edev->mutex);
-
- dev_warn(edev->dev, "Device watchdog timeout. ping_count=%u",
- edev->mailbox.ping_count);
-
- if (edev->mailbox.ping_count < 1)
- ethosu_mailbox_ping(&edev->mailbox);
- else
- ethosu_firmware_reset(edev);
-
- mutex_unlock(&edev->mutex);
-}
-
static int ethosu_open(struct inode *inode,
struct file *file)
{
@@ -414,25 +334,16 @@ int ethosu_dev_init(struct ethosu_device *edev,
edev->devt = devt;
mutex_init(&edev->mutex);
- edev->reset = devm_reset_control_get_by_index(edev->dev, 0);
- if (IS_ERR(edev->reset))
- dev_warn(edev->dev, "No reset control found for this device.");
-
ret = of_reserved_mem_device_init(edev->dev);
if (ret)
return ret;
dma_set_mask_and_coherent(edev->dev, DMA_BIT_MASK(DMA_ADDR_BITS));
- ret = ethosu_watchdog_init(&edev->watchdog, dev,
- ethosu_watchdog_callback);
- if (ret)
- goto release_reserved_mem;
-
ret = ethosu_mailbox_init(&edev->mailbox, dev, in_queue, out_queue,
- ethosu_mbox_rx, edev, &edev->watchdog);
+ ethosu_mbox_rx, edev);
if (ret)
- goto deinit_watchdog;
+ goto release_reserved_mem;
cdev_init(&edev->cdev, &fops);
edev->cdev.owner = THIS_MODULE;
@@ -451,8 +362,6 @@ int ethosu_dev_init(struct ethosu_device *edev,
goto del_cdev;
}
- ethosu_firmware_reset(edev);
-
dev_info(edev->dev,
"Created Arm Ethos-U device. name=%s, major=%d, minor=%d\n",
dev_name(sysdev), MAJOR(edev->devt), MINOR(edev->devt));
@@ -465,9 +374,6 @@ del_cdev:
deinit_mailbox:
ethosu_mailbox_deinit(&edev->mailbox);
-deinit_watchdog:
- ethosu_watchdog_deinit(&edev->watchdog);
-
release_reserved_mem:
of_reserved_mem_device_release(edev->dev);
@@ -477,7 +383,6 @@ release_reserved_mem:
void ethosu_dev_deinit(struct ethosu_device *edev)
{
ethosu_mailbox_deinit(&edev->mailbox);
- ethosu_watchdog_deinit(&edev->watchdog);
device_destroy(edev->class, edev->cdev.dev);
cdev_del(&edev->cdev);
of_reserved_mem_device_release(edev->dev);
diff --git a/kernel/ethosu_device.h b/kernel/ethosu_device.h
index d1e4334..8e81f91 100644
--- a/kernel/ethosu_device.h
+++ b/kernel/ethosu_device.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2022 Arm Limited.
+ * Copyright 2020-2023 Arm Limited and/or its affiliates
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
@@ -27,7 +27,6 @@
#include "uapi/ethosu.h"
#include "ethosu_mailbox.h"
-#include "ethosu_watchdog.h"
#include <linux/device.h>
#include <linux/cdev.h>
@@ -38,20 +37,16 @@
* Types
****************************************************************************/
-struct reset_control;
-
/**
* struct ethosu_device - Device structure
*/
struct ethosu_device {
- struct device *dev;
- struct cdev cdev;
- struct class *class;
- dev_t devt;
- struct mutex mutex;
- struct ethosu_mailbox mailbox;
- struct ethosu_watchdog watchdog;
- struct reset_control *reset;
+ struct device *dev;
+ struct cdev cdev;
+ struct class *class;
+ dev_t devt;
+ struct mutex mutex;
+ struct ethosu_mailbox mailbox;
};
/****************************************************************************
@@ -75,9 +70,4 @@ int ethosu_dev_init(struct ethosu_device *edev,
*/
void ethosu_dev_deinit(struct ethosu_device *edev);
-/**
- * ethosu_firmware_reset() - Reset the device running firmware
- */
-int ethosu_firmware_reset(struct ethosu_device *edev);
-
#endif /* ETHOSU_DEVICE_H */
diff --git a/kernel/ethosu_inference.c b/kernel/ethosu_inference.c
index 1a3c45a..58501f7 100644
--- a/kernel/ethosu_inference.c
+++ b/kernel/ethosu_inference.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020,2022 Arm Limited.
+ * Copyright 2020,2022-2023 Arm Limited and/or its affiliates
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
@@ -141,36 +141,6 @@ static void ethosu_inference_fail(struct ethosu_mailbox_msg *msg)
wake_up_interruptible(&inf->waitq);
}
-static int ethosu_inference_resend(struct ethosu_mailbox_msg *msg)
-{
- struct ethosu_inference *inf =
- container_of(msg, typeof(*inf), msg);
- int ret;
-
- /* Don't resend request if response has already been received */
- if (inf->done)
- return 0;
-
- /* If marked as ABORTING simply fail it and return */
- if (inf->status == ETHOSU_UAPI_STATUS_ABORTING) {
- ethosu_inference_fail(msg);
-
- return 0;
- }
-
- /* Decrement reference count for pending request */
- ret = ethosu_inference_put(inf);
- if (ret)
- return 0;
-
- /* Resend request */
- ret = ethosu_inference_send(inf);
- if (ret)
- return ret;
-
- return 0;
-}
-
static bool ethosu_inference_verify(struct file *file)
{
return file->f_op == &ethosu_inference_fops;
@@ -322,7 +292,6 @@ int ethosu_inference_create(struct ethosu_device *edev,
kref_init(&inf->kref);
init_waitqueue_head(&inf->waitq);
inf->msg.fail = ethosu_inference_fail;
- inf->msg.resend = ethosu_inference_resend;
/* Add inference to pending list */
ret = ethosu_mailbox_register(&edev->mailbox, &inf->msg);
diff --git a/kernel/ethosu_mailbox.c b/kernel/ethosu_mailbox.c
index b5cde0d..870a4ef 100644
--- a/kernel/ethosu_mailbox.c
+++ b/kernel/ethosu_mailbox.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2022 Arm Limited.
+ * Copyright 2020-2023 Arm Limited and/or its affiliates
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
@@ -27,7 +27,6 @@
#include "ethosu_buffer.h"
#include "ethosu_core_interface.h"
#include "ethosu_device.h"
-#include "ethosu_watchdog.h"
#include <linux/jiffies.h>
#include <linux/resource.h>
@@ -49,36 +48,6 @@
* Functions
****************************************************************************/
-static void ethosu_wd_inc(struct ethosu_mailbox *mbox,
- enum ethosu_core_msg_type type)
-{
- switch (type) {
- case ETHOSU_CORE_MSG_PING:
- mbox->ping_count++;
- fallthrough;
- case ETHOSU_CORE_MSG_INFERENCE_REQ:
- ethosu_watchdog_inc(mbox->wdog);
- break;
- default:
- break;
- }
-}
-
-static void ethosu_wd_dec(struct ethosu_mailbox *mbox,
- enum ethosu_core_msg_type type)
-{
- switch (type) {
- case ETHOSU_CORE_MSG_PONG:
- mbox->ping_count--;
- fallthrough;
- case ETHOSU_CORE_MSG_INFERENCE_RSP:
- ethosu_watchdog_dec(mbox->wdog);
- break;
- default:
- break;
- }
-}
-
static void ethosu_core_set_size(struct ethosu_buffer *buf,
struct ethosu_core_buffer *cbuf)
{
@@ -164,8 +133,6 @@ static int ethosu_queue_write_msg(struct ethosu_mailbox *mbox,
if (ret)
return ret;
- ethosu_wd_inc(mbox, type);
-
return 0;
}
@@ -278,8 +245,6 @@ int ethosu_mailbox_read(struct ethosu_mailbox *mbox,
return -EBADMSG;
}
- ethosu_wd_dec(mbox, header->type);
-
return 0;
}
@@ -321,22 +286,6 @@ void ethosu_mailbox_fail(struct ethosu_mailbox *mbox)
}
}
-void ethosu_mailbox_resend(struct ethosu_mailbox *mbox)
-{
- struct ethosu_mailbox_msg *cur;
- int id;
- int ret;
-
- idr_for_each_entry(&mbox->msg_idr, cur, id) {
- ret = cur->resend(cur);
- if (ret) {
- dev_warn(mbox->dev, "Failed to resend msg. ret=%d",
- ret);
- cur->fail(cur);
- }
- }
-}
-
int ethosu_mailbox_ping(struct ethosu_mailbox *mbox)
{
return ethosu_queue_write_msg(mbox, ETHOSU_CORE_MSG_PING, NULL, 0);
@@ -481,16 +430,13 @@ int ethosu_mailbox_init(struct ethosu_mailbox *mbox,
struct resource *in_queue,
struct resource *out_queue,
ethosu_mailbox_cb callback,
- void *user_arg,
- struct ethosu_watchdog *wdog)
+ void *user_arg)
{
int ret;
mbox->dev = dev;
mbox->callback = callback;
mbox->user_arg = user_arg;
- mbox->wdog = wdog;
- mbox->ping_count = 0;
idr_init(&mbox->msg_idr);
mbox->client.dev = dev;
diff --git a/kernel/ethosu_mailbox.h b/kernel/ethosu_mailbox.h
index 26367f6..c3f5579 100644
--- a/kernel/ethosu_mailbox.h
+++ b/kernel/ethosu_mailbox.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2022 Arm Limited.
+ * Copyright 2020-2023 Arm Limited and/or its affiliates
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
@@ -40,7 +40,6 @@ struct ethosu_buffer;
struct ethosu_device;
struct ethosu_core_msg;
struct ethosu_core_queue;
-struct ethosu_watchdog;
struct resource;
typedef void (*ethosu_mailbox_cb)(void *user_arg);
@@ -57,14 +56,11 @@ struct ethosu_mailbox {
ethosu_mailbox_cb callback;
void *user_arg;
struct idr msg_idr;
- struct ethosu_watchdog *wdog;
- unsigned ping_count;
};
struct ethosu_mailbox_msg {
int id;
void (*fail)(struct ethosu_mailbox_msg *msg);
- int (*resend)(struct ethosu_mailbox_msg *msg);
};
/****************************************************************************
@@ -81,8 +77,7 @@ int ethosu_mailbox_init(struct ethosu_mailbox *mbox,
struct resource *in_queue,
struct resource *out_queue,
ethosu_mailbox_cb callback,
- void *user_arg,
- struct ethosu_watchdog *wdog);
+ void *user_arg);
/**
* ethosu_mailbox_deinit() - Deinitialize mailbox
@@ -149,13 +144,6 @@ struct ethosu_mailbox_msg *ethosu_mailbox_find(struct ethosu_mailbox *mbox,
void ethosu_mailbox_fail(struct ethosu_mailbox *mbox);
/**
- * ethosu_mailbox_resend() - Resend mailbox messages
- *
- * Call resend() callback on all messages in pending list.
- */
-void ethosu_mailbox_resend(struct ethosu_mailbox *mbox);
-
-/**
* ethosu_mailbox_reset() - Reset to end of queue
*/
void ethosu_mailbox_reset(struct ethosu_mailbox *mbox);
diff --git a/kernel/ethosu_network_info.c b/kernel/ethosu_network_info.c
index a99ca84..5469b6c 100644
--- a/kernel/ethosu_network_info.c
+++ b/kernel/ethosu_network_info.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022 ARM Limited.
+ * Copyright 2022-2023 Arm Limited and/or its affiliates
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
@@ -52,24 +52,6 @@ static void ethosu_network_info_fail(struct ethosu_mailbox_msg *msg)
complete(&info->done);
}
-static int ethosu_network_info_resend(struct ethosu_mailbox_msg *msg)
-{
- struct ethosu_network_info *info =
- container_of(msg, typeof(*info), msg);
- int ret;
-
- /* Don't resend request if response has already been received */
- if (completion_done(&info->done))
- return 0;
-
- /* Resend request */
- ret = ethosu_network_info_send(info);
- if (ret)
- return ret;
-
- return 0;
-}
-
int ethosu_network_info_request(struct ethosu_network *net,
struct ethosu_uapi_network_info *uapi)
{
@@ -86,7 +68,6 @@ int ethosu_network_info_request(struct ethosu_network *net,
info->uapi = uapi;
init_completion(&info->done);
info->msg.fail = ethosu_network_info_fail;
- info->msg.resend = ethosu_network_info_resend;
ret = ethosu_mailbox_register(&info->edev->mailbox, &info->msg);
if (ret < 0)
diff --git a/kernel/ethosu_watchdog.c b/kernel/ethosu_watchdog.c
deleted file mode 100644
index bde0803..0000000
--- a/kernel/ethosu_watchdog.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2022 Arm Limited.
- *
- * This program is free software and is provided to you under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation, and any use by you of this program is subject to the terms
- * of such GNU licence.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can access it online at
- * http://www.gnu.org/licenses/gpl-2.0.html.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- */
-
-/****************************************************************************
- * Includes
- ****************************************************************************/
-
-#include "ethosu_watchdog.h"
-
-#include <linux/device.h>
-#include <linux/jiffies.h>
-#include <linux/moduleparam.h>
-#include <linux/version.h>
-
-/****************************************************************************
- * Variables
- ****************************************************************************/
-
-static unsigned long watchdog_timeout_ms = 3000;
-module_param(watchdog_timeout_ms, ulong, 0664);
-MODULE_PARM_DESC(watchdog_timeout_ms,
- "Watchdog timeout in milliseconds for unresponsive firmware.");
-
-/****************************************************************************
- * Functions
- ****************************************************************************/
-
-static void ethosu_watchdog_update(struct ethosu_watchdog *wdog)
-{
- int ret;
-
- ret = mod_timer(&wdog->timer,
- jiffies + msecs_to_jiffies(watchdog_timeout_ms));
-
- dev_info(wdog->dev,
- "Wdog: Update watchdog timeout. ret=%d, timeout_ms=%lu, refcount=%u", ret,
- watchdog_timeout_ms, atomic_read(&wdog->refcount));
-}
-
-static void ethosu_watchdog_work(struct work_struct *work)
-{
- struct ethosu_watchdog *wdog =
- container_of(work, struct ethosu_watchdog, work);
-
- dev_info(wdog->dev, "Wdog: Watchdog timeout. refcount=%u",
- atomic_read(&wdog->refcount));
-
- wdog->callback(wdog);
-}
-
-static void ethosu_watchdog_timeout(struct timer_list *timer)
-{
- struct ethosu_watchdog *wdog =
- container_of(timer, struct ethosu_watchdog, timer);
-
- queue_work(system_unbound_wq, &wdog->work);
-}
-
-#if KERNEL_VERSION(4, 14, 0) > LINUX_VERSION_CODE
-static void ethosu_watchdog_timeout_legacy(unsigned long data)
-{
- ethosu_watchdog_timeout((struct timer_list *)data);
-}
-
-#endif
-
-int ethosu_watchdog_init(struct ethosu_watchdog *wdog,
- struct device *dev,
- ethosu_watchdog_cb callback)
-{
- wdog->dev = dev;
- wdog->callback = callback;
- atomic_set(&wdog->refcount, 0);
- INIT_WORK(&wdog->work, ethosu_watchdog_work);
-
-#if KERNEL_VERSION(4, 14, 0) <= LINUX_VERSION_CODE
- timer_setup(&wdog->timer, ethosu_watchdog_timeout, 0);
-#else
- setup_timer(&wdog->timer, ethosu_watchdog_timeout_legacy,
- (unsigned long)&wdog->timer);
-#endif
-
- return 0;
-}
-
-void ethosu_watchdog_deinit(struct ethosu_watchdog *wdog)
-{
- del_timer(&wdog->timer);
-}
-
-int ethosu_watchdog_reset(struct ethosu_watchdog *wdog)
-{
- del_timer(&wdog->timer);
- atomic_set(&wdog->refcount, 0);
-
- return 0;
-}
-
-void ethosu_watchdog_inc(struct ethosu_watchdog *wdog)
-{
- atomic_inc(&wdog->refcount);
- ethosu_watchdog_update(wdog);
-}
-
-void ethosu_watchdog_dec(struct ethosu_watchdog *wdog)
-{
- if (atomic_dec_and_test(&wdog->refcount)) {
- dev_info(wdog->dev, "Wdog: Cancel watchdog timeout");
- del_timer(&wdog->timer);
- } else {
- ethosu_watchdog_update(wdog);
- }
-}
diff --git a/kernel/ethosu_watchdog.h b/kernel/ethosu_watchdog.h
deleted file mode 100644
index d288af4..0000000
--- a/kernel/ethosu_watchdog.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2022 Arm Limited.
- *
- * This program is free software and is provided to you under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation, and any use by you of this program is subject to the terms
- * of such GNU licence.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can access it online at
- * http://www.gnu.org/licenses/gpl-2.0.html.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- */
-
-#ifndef ETHOSU_WATCHDOG_H
-#define ETHOSU_WATCHDOG_H
-
-/****************************************************************************
- * Includes
- ****************************************************************************/
-
-#include <linux/types.h>
-#include <linux/timer.h>
-#include <linux/workqueue.h>
-
-/****************************************************************************
- * Types
- ****************************************************************************/
-
-struct device;
-struct ethosu_watchdog;
-
-typedef void (*ethosu_watchdog_cb)(struct ethosu_watchdog *wdog);
-
-struct ethosu_watchdog {
- struct device *dev;
- ethosu_watchdog_cb callback;
- struct timer_list timer;
- struct work_struct work;
- atomic_t refcount;
-};
-
-/****************************************************************************
- * Functions
- ****************************************************************************/
-
-/**
- * ethosu_watchdog_init() - Initialize watchdog
- *
- * Return: 0 on success, else error code.
- */
-int ethosu_watchdog_init(struct ethosu_watchdog *wdog,
- struct device *dev,
- ethosu_watchdog_cb callback);
-
-/**
- * ethosu_watchdog_deinit() - Deinitialize watchdog
- */
-void ethosu_watchdog_deinit(struct ethosu_watchdog *wdog);
-
-/**
- * ethosu_watchdog_reset() - Reset watchdog
- */
-int ethosu_watchdog_reset(struct ethosu_watchdog *wdog);
-
-/**
- * ethosu_watchdog_inc() - Increment reference count
- */
-void ethosu_watchdog_inc(struct ethosu_watchdog *wdog);
-
-/**
- * ethosu_watchdog_dec() - Decrement reference count
- */
-void ethosu_watchdog_dec(struct ethosu_watchdog *wdog);
-
-#endif /* ETHOSU_WATCHDOG_H */