crypto: qat - rename and relocate timer logic
authorGeorge Abraham P <george.abraham.p@intel.com>
Wed, 30 Apr 2025 11:34:43 +0000 (12:34 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 5 May 2025 10:20:44 +0000 (18:20 +0800)
Rename adf_gen4_timer.c to adf_timer.c and adf_gen4_timer.h to
adf_timer.h to make the files generation-agnostic. This includes
renaming the start() and stop() timer APIs and macro definitions
to be generic, allowing for reuse across different device
generations.
This does not introduce any functional changes.

Signed-off-by: George Abraham P <george.abraham.p@intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/intel/qat/qat_420xx/adf_420xx_hw_data.c
drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c
drivers/crypto/intel/qat/qat_common/Makefile
drivers/crypto/intel/qat/qat_common/adf_gen4_timer.c [deleted file]
drivers/crypto/intel/qat/qat_common/adf_gen4_timer.h [deleted file]
drivers/crypto/intel/qat/qat_common/adf_timer.c [new file with mode: 0644]
drivers/crypto/intel/qat/qat_common/adf_timer.h [new file with mode: 0644]

index 795f4598400bcee526290cde46b3bfbd89d7a4dd..5817b31641856f03b47db776fa8f84d4e9ad8802 100644 (file)
@@ -15,9 +15,9 @@
 #include <adf_gen4_pfvf.h>
 #include <adf_gen4_pm.h>
 #include <adf_gen4_ras.h>
-#include <adf_gen4_timer.h>
 #include <adf_gen4_tl.h>
 #include <adf_gen4_vf_mig.h>
+#include <adf_timer.h>
 #include "adf_420xx_hw_data.h"
 #include "icp_qat_hw.h"
 
@@ -468,8 +468,8 @@ void adf_init_hw_data_420xx(struct adf_hw_device_data *hw_data, u32 dev_id)
        hw_data->enable_pm = adf_gen4_enable_pm;
        hw_data->handle_pm_interrupt = adf_gen4_handle_pm_interrupt;
        hw_data->dev_config = adf_gen4_dev_config;
-       hw_data->start_timer = adf_gen4_timer_start;
-       hw_data->stop_timer = adf_gen4_timer_stop;
+       hw_data->start_timer = adf_timer_start;
+       hw_data->stop_timer = adf_timer_stop;
        hw_data->get_hb_clock = adf_gen4_get_heartbeat_clock;
        hw_data->num_hb_ctrs = ADF_NUM_HB_CNT_PER_AE;
        hw_data->clock_frequency = ADF_420XX_AE_FREQ;
index 7d4c366aa8b22e75aede9c8981b361bc558d0bd8..2d89d4a3a7b9d9404a4e35a9e584087cdb689e24 100644 (file)
@@ -15,9 +15,9 @@
 #include <adf_gen4_pfvf.h>
 #include <adf_gen4_pm.h>
 #include "adf_gen4_ras.h"
-#include <adf_gen4_timer.h>
 #include <adf_gen4_tl.h>
 #include <adf_gen4_vf_mig.h>
+#include <adf_timer.h>
 #include "adf_4xxx_hw_data.h"
 #include "icp_qat_hw.h"
 
@@ -454,8 +454,8 @@ void adf_init_hw_data_4xxx(struct adf_hw_device_data *hw_data, u32 dev_id)
        hw_data->enable_pm = adf_gen4_enable_pm;
        hw_data->handle_pm_interrupt = adf_gen4_handle_pm_interrupt;
        hw_data->dev_config = adf_gen4_dev_config;
-       hw_data->start_timer = adf_gen4_timer_start;
-       hw_data->stop_timer = adf_gen4_timer_stop;
+       hw_data->start_timer = adf_timer_start;
+       hw_data->stop_timer = adf_timer_stop;
        hw_data->get_hb_clock = adf_gen4_get_heartbeat_clock;
        hw_data->num_hb_ctrs = ADF_NUM_HB_CNT_PER_AE;
        hw_data->clock_frequency = ADF_4XXX_AE_FREQ;
index af5df29fd2e348f03609d40defdeca4b645ad6cd..0370eaad42b113e66c1673f1814022c7d088a4be 100644 (file)
@@ -19,7 +19,6 @@ intel_qat-y := adf_accel_engine.o \
        adf_gen4_hw_data.o \
        adf_gen4_pm.o \
        adf_gen4_ras.o \
-       adf_gen4_timer.o \
        adf_gen4_vf_mig.o \
        adf_hw_arbiter.o \
        adf_init.o \
@@ -30,6 +29,7 @@ intel_qat-y := adf_accel_engine.o \
        adf_sysfs.o \
        adf_sysfs_ras_counters.o \
        adf_sysfs_rl.o \
+       adf_timer.o \
        adf_transport.o \
        qat_algs.o \
        qat_algs_send.o \
diff --git a/drivers/crypto/intel/qat/qat_common/adf_gen4_timer.c b/drivers/crypto/intel/qat/qat_common/adf_gen4_timer.c
deleted file mode 100644 (file)
index 35ccb91..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/* Copyright(c) 2023 Intel Corporation */
-
-#include <linux/container_of.h>
-#include <linux/dev_printk.h>
-#include <linux/export.h>
-#include <linux/jiffies.h>
-#include <linux/ktime.h>
-#include <linux/slab.h>
-#include <linux/workqueue.h>
-
-#include "adf_admin.h"
-#include "adf_accel_devices.h"
-#include "adf_common_drv.h"
-#include "adf_gen4_timer.h"
-
-#define ADF_GEN4_TIMER_PERIOD_MS 200
-
-/* This periodic update is used to trigger HB, RL & TL fw events */
-static void work_handler(struct work_struct *work)
-{
-       struct adf_accel_dev *accel_dev;
-       struct adf_timer *timer_ctx;
-       u32 time_periods;
-
-       timer_ctx = container_of(to_delayed_work(work), struct adf_timer, work_ctx);
-       accel_dev = timer_ctx->accel_dev;
-
-       adf_misc_wq_queue_delayed_work(&timer_ctx->work_ctx,
-                                      msecs_to_jiffies(ADF_GEN4_TIMER_PERIOD_MS));
-
-       time_periods = div_u64(ktime_ms_delta(ktime_get_real(), timer_ctx->initial_ktime),
-                              ADF_GEN4_TIMER_PERIOD_MS);
-
-       if (adf_send_admin_tim_sync(accel_dev, time_periods))
-               dev_err(&GET_DEV(accel_dev), "Failed to synchronize qat timer\n");
-}
-
-int adf_gen4_timer_start(struct adf_accel_dev *accel_dev)
-{
-       struct adf_timer *timer_ctx;
-
-       timer_ctx = kzalloc(sizeof(*timer_ctx), GFP_KERNEL);
-       if (!timer_ctx)
-               return -ENOMEM;
-
-       timer_ctx->accel_dev = accel_dev;
-       accel_dev->timer = timer_ctx;
-       timer_ctx->initial_ktime = ktime_get_real();
-
-       INIT_DELAYED_WORK(&timer_ctx->work_ctx, work_handler);
-       adf_misc_wq_queue_delayed_work(&timer_ctx->work_ctx,
-                                      msecs_to_jiffies(ADF_GEN4_TIMER_PERIOD_MS));
-
-       return 0;
-}
-EXPORT_SYMBOL_GPL(adf_gen4_timer_start);
-
-void adf_gen4_timer_stop(struct adf_accel_dev *accel_dev)
-{
-       struct adf_timer *timer_ctx = accel_dev->timer;
-
-       if (!timer_ctx)
-               return;
-
-       cancel_delayed_work_sync(&timer_ctx->work_ctx);
-
-       kfree(timer_ctx);
-       accel_dev->timer = NULL;
-}
-EXPORT_SYMBOL_GPL(adf_gen4_timer_stop);
diff --git a/drivers/crypto/intel/qat/qat_common/adf_gen4_timer.h b/drivers/crypto/intel/qat/qat_common/adf_gen4_timer.h
deleted file mode 100644 (file)
index 66a709e..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/* Copyright(c) 2023 Intel Corporation */
-
-#ifndef ADF_GEN4_TIMER_H_
-#define ADF_GEN4_TIMER_H_
-
-#include <linux/ktime.h>
-#include <linux/workqueue.h>
-
-struct adf_accel_dev;
-
-struct adf_timer {
-       struct adf_accel_dev *accel_dev;
-       struct delayed_work work_ctx;
-       ktime_t initial_ktime;
-};
-
-int adf_gen4_timer_start(struct adf_accel_dev *accel_dev);
-void adf_gen4_timer_stop(struct adf_accel_dev *accel_dev);
-
-#endif /* ADF_GEN4_TIMER_H_ */
diff --git a/drivers/crypto/intel/qat/qat_common/adf_timer.c b/drivers/crypto/intel/qat/qat_common/adf_timer.c
new file mode 100644 (file)
index 0000000..8962a49
--- /dev/null
@@ -0,0 +1,71 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright(c) 2023 Intel Corporation */
+
+#include <linux/container_of.h>
+#include <linux/dev_printk.h>
+#include <linux/export.h>
+#include <linux/jiffies.h>
+#include <linux/ktime.h>
+#include <linux/slab.h>
+#include <linux/workqueue.h>
+
+#include "adf_admin.h"
+#include "adf_accel_devices.h"
+#include "adf_common_drv.h"
+#include "adf_timer.h"
+
+#define ADF_DEFAULT_TIMER_PERIOD_MS 200
+
+/* This periodic update is used to trigger HB, RL & TL fw events */
+static void work_handler(struct work_struct *work)
+{
+       struct adf_accel_dev *accel_dev;
+       struct adf_timer *timer_ctx;
+       u32 time_periods;
+
+       timer_ctx = container_of(to_delayed_work(work), struct adf_timer, work_ctx);
+       accel_dev = timer_ctx->accel_dev;
+
+       adf_misc_wq_queue_delayed_work(&timer_ctx->work_ctx,
+                                      msecs_to_jiffies(ADF_DEFAULT_TIMER_PERIOD_MS));
+
+       time_periods = div_u64(ktime_ms_delta(ktime_get_real(), timer_ctx->initial_ktime),
+                              ADF_DEFAULT_TIMER_PERIOD_MS);
+
+       if (adf_send_admin_tim_sync(accel_dev, time_periods))
+               dev_err(&GET_DEV(accel_dev), "Failed to synchronize qat timer\n");
+}
+
+int adf_timer_start(struct adf_accel_dev *accel_dev)
+{
+       struct adf_timer *timer_ctx;
+
+       timer_ctx = kzalloc(sizeof(*timer_ctx), GFP_KERNEL);
+       if (!timer_ctx)
+               return -ENOMEM;
+
+       timer_ctx->accel_dev = accel_dev;
+       accel_dev->timer = timer_ctx;
+       timer_ctx->initial_ktime = ktime_get_real();
+
+       INIT_DELAYED_WORK(&timer_ctx->work_ctx, work_handler);
+       adf_misc_wq_queue_delayed_work(&timer_ctx->work_ctx,
+                                      msecs_to_jiffies(ADF_DEFAULT_TIMER_PERIOD_MS));
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(adf_timer_start);
+
+void adf_timer_stop(struct adf_accel_dev *accel_dev)
+{
+       struct adf_timer *timer_ctx = accel_dev->timer;
+
+       if (!timer_ctx)
+               return;
+
+       cancel_delayed_work_sync(&timer_ctx->work_ctx);
+
+       kfree(timer_ctx);
+       accel_dev->timer = NULL;
+}
+EXPORT_SYMBOL_GPL(adf_timer_stop);
diff --git a/drivers/crypto/intel/qat/qat_common/adf_timer.h b/drivers/crypto/intel/qat/qat_common/adf_timer.h
new file mode 100644 (file)
index 0000000..68e5136
--- /dev/null
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright(c) 2023 Intel Corporation */
+
+#ifndef ADF_TIMER_H_
+#define ADF_TIMER_H_
+
+#include <linux/ktime.h>
+#include <linux/workqueue.h>
+
+struct adf_accel_dev;
+
+struct adf_timer {
+       struct adf_accel_dev *accel_dev;
+       struct delayed_work work_ctx;
+       ktime_t initial_ktime;
+};
+
+int adf_timer_start(struct adf_accel_dev *accel_dev);
+void adf_timer_stop(struct adf_accel_dev *accel_dev);
+
+#endif /* ADF_TIMER_H_ */