2024-02-26 17:33:31

by Ricardo Ribalda

[permalink] [raw]
Subject: [PATCH v2 0/3] media: Fix warnings building with LLVM=1

LLVM does check -Wcast-function-type-sctrict, which is triggered in a
couple of places in the media subsystem.

Signed-off-by: Ricardo Ribalda <[email protected]>
---
Changes in v2:
- Refactor media: mediatek patchset
- sta2x11: Fix Christmas tree order
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Ricardo Ribalda (3):
media: pci: sta2x11: Fix Wcast-function-type-strict warnings
media: usb: pvrusb2: Fix Wcast-function-type-strict warnings
media: mediatek: vcodedc: Fix Wcast-function-type-strict warnings

drivers/media/pci/sta2x11/sta2x11_vip.c | 5 +++--
drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c | 12 ++++++------
.../media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h | 2 +-
.../platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c | 10 +---------
drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c | 2 +-
drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c | 2 +-
drivers/media/usb/pvrusb2/pvrusb2-context.c | 5 +++--
drivers/media/usb/pvrusb2/pvrusb2-dvb.c | 7 ++++---
drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 7 ++++---
drivers/remoteproc/mtk_scp.c | 4 ++--
include/linux/remoteproc/mtk_scp.h | 2 +-
include/linux/rpmsg/mtk_rpmsg.h | 2 +-
12 files changed, 28 insertions(+), 32 deletions(-)
---
base-commit: d206a76d7d2726f3b096037f2079ce0bd3ba329b
change-id: 20240128-fix-clang-warnings-6c12920467cb

Best regards,
--
Ricardo Ribalda <[email protected]>



2024-02-26 17:33:52

by Ricardo Ribalda

[permalink] [raw]
Subject: [PATCH v2 1/3] media: pci: sta2x11: Fix Wcast-function-type-strict warnings

Building with LLVM=1 throws the following warning:
drivers/media/pci/sta2x11/sta2x11_vip.c:1057:6: warning: cast from 'irqreturn_t (*)(int, struct sta2x11_vip *)' (aka 'enum irqreturn (*)(int, struct sta2x11_vip *)') to 'irq_handler_t' (aka 'enum irqreturn (*)(int, void *)') converts to incompatible function type [-Wcast-function-type-strict]

Reviewed-by: Nathan Chancellor <[email protected]>
Signed-off-by: Ricardo Ribalda <[email protected]>
---
drivers/media/pci/sta2x11/sta2x11_vip.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c b/drivers/media/pci/sta2x11/sta2x11_vip.c
index e4cf9d63e926d..a6456673be3f6 100644
--- a/drivers/media/pci/sta2x11/sta2x11_vip.c
+++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
@@ -757,7 +757,7 @@ static const struct video_device video_dev_template = {
/**
* vip_irq - interrupt routine
* @irq: Number of interrupt ( not used, correct number is assumed )
- * @vip: local data structure containing all information
+ * @data: local data structure containing all information
*
* check for both frame interrupts set ( top and bottom ).
* check FIFO overflow, but limit number of log messages after open.
@@ -767,8 +767,9 @@ static const struct video_device video_dev_template = {
*
* IRQ_HANDLED, interrupt done.
*/
-static irqreturn_t vip_irq(int irq, struct sta2x11_vip *vip)
+static irqreturn_t vip_irq(int irq, void *data)
{
+ struct sta2x11_vip *vip = data;
unsigned int status;

status = reg_read(vip, DVP_ITS);

--
2.44.0.rc0.258.g7320e95886-goog


2024-02-26 17:33:57

by Ricardo Ribalda

[permalink] [raw]
Subject: [PATCH v2 2/3] media: usb: pvrusb2: Fix Wcast-function-type-strict warnings

Building with LLVM=1 throws the following warning:
drivers/media/usb/pvrusb2/pvrusb2-context.c:110:6: warning: cast from 'void (*)(struct pvr2_context *)' to 'void (*)(void *)' converts to incompatible function type [-Wcast-function-type-strict]
drivers/media/usb/pvrusb2/pvrusb2-v4l2.c:1070:30: warning: cast from 'void (*)(struct pvr2_v4l2_fh *)' to 'pvr2_stream_callback' (aka 'void (*)(void *)') converts to incompatible function type [-Wcast-function-type-strict] drivers/media/usb/pvrusb2/pvrusb2-dvb.c:152:6: warning: cast from 'void (*)(struct pvr2_dvb_adapter *)' to 'pvr2_stream_callback' (aka 'void (*)(void *)') converts to incompatible function type [-Wcast-function-type-strict]

Reviewed-by: Nathan Chancellor <[email protected]>
Signed-off-by: Ricardo Ribalda <[email protected]>
---
drivers/media/usb/pvrusb2/pvrusb2-context.c | 5 +++--
drivers/media/usb/pvrusb2/pvrusb2-dvb.c | 7 ++++---
drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 7 ++++---
3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/media/usb/pvrusb2/pvrusb2-context.c b/drivers/media/usb/pvrusb2/pvrusb2-context.c
index 1764674de98bc..16edabda191c4 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-context.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-context.c
@@ -90,8 +90,9 @@ static void pvr2_context_destroy(struct pvr2_context *mp)
}


-static void pvr2_context_notify(struct pvr2_context *mp)
+static void pvr2_context_notify(void *data)
{
+ struct pvr2_context *mp = data;
pvr2_context_set_notify(mp,!0);
}

@@ -107,7 +108,7 @@ static void pvr2_context_check(struct pvr2_context *mp)
"pvr2_context %p (initialize)", mp);
/* Finish hardware initialization */
if (pvr2_hdw_initialize(mp->hdw,
- (void (*)(void *))pvr2_context_notify,
+ pvr2_context_notify,
mp)) {
mp->video_stream.stream =
pvr2_hdw_get_video_stream(mp->hdw);
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-dvb.c b/drivers/media/usb/pvrusb2/pvrusb2-dvb.c
index 26811efe0fb58..8b9f1a09bd53d 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-dvb.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-dvb.c
@@ -88,8 +88,9 @@ static int pvr2_dvb_feed_thread(void *data)
return stat;
}

-static void pvr2_dvb_notify(struct pvr2_dvb_adapter *adap)
+static void pvr2_dvb_notify(void *data)
{
+ struct pvr2_dvb_adapter *adap = data;
wake_up(&adap->buffer_wait_data);
}

@@ -148,8 +149,8 @@ static int pvr2_dvb_stream_do_start(struct pvr2_dvb_adapter *adap)
if (!(adap->buffer_storage[idx])) return -ENOMEM;
}

- pvr2_stream_set_callback(pvr->video_stream.stream,
- (pvr2_stream_callback) pvr2_dvb_notify, adap);
+ pvr2_stream_set_callback(pvr->video_stream.stream, pvr2_dvb_notify,
+ adap);

ret = pvr2_stream_set_buffer_count(stream, PVR2_DVB_BUFFER_COUNT);
if (ret < 0) return ret;
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
index c04ab7258d645..590f80949bbfc 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
@@ -1032,9 +1032,10 @@ static int pvr2_v4l2_open(struct file *file)
return 0;
}

-
-static void pvr2_v4l2_notify(struct pvr2_v4l2_fh *fhp)
+static void pvr2_v4l2_notify(void *data)
{
+ struct pvr2_v4l2_fh *fhp = data;
+
wake_up(&fhp->wait_data);
}

@@ -1067,7 +1068,7 @@ static int pvr2_v4l2_iosetup(struct pvr2_v4l2_fh *fh)

hdw = fh->channel.mc_head->hdw;
sp = fh->pdi->stream->stream;
- pvr2_stream_set_callback(sp,(pvr2_stream_callback)pvr2_v4l2_notify,fh);
+ pvr2_stream_set_callback(sp, pvr2_v4l2_notify, fh);
pvr2_hdw_set_stream_type(hdw,fh->pdi->config);
if ((ret = pvr2_hdw_set_streaming(hdw,!0)) < 0) return ret;
return pvr2_ioread_set_enabled(fh->rhp,!0);

--
2.44.0.rc0.258.g7320e95886-goog


2024-02-26 18:04:32

by Ricardo Ribalda

[permalink] [raw]
Subject: [PATCH v2 3/3] media: mediatek: vcodedc: Fix Wcast-function-type-strict warnings

Building with LLVM=1 throws the following warning:
drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c:38:32: warning: cast from 'mtk_vcodec_ipi_handler' (aka 'void (*)(void *, unsigned int, void *)') to 'ipi_handler_t' (aka 'void (*)(const void *, unsigned int, void *)') converts to incompatible function type [-Wcast-function-type-strict]

Constify the types to avoid the warning.

Signed-off-by: Ricardo Ribalda <[email protected]>
---
drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c | 12 ++++++------
.../media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h | 2 +-
.../platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c | 10 +---------
drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c | 2 +-
drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c | 2 +-
drivers/remoteproc/mtk_scp.c | 4 ++--
include/linux/remoteproc/mtk_scp.h | 2 +-
include/linux/rpmsg/mtk_rpmsg.h | 2 +-
8 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c
index 49fc2e9d45dd5..c4f1c49b9d52a 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c
@@ -77,10 +77,10 @@ void mdp_vpu_shared_mem_free(struct mdp_vpu_dev *vpu)
dma_free_wc(dev, vpu->config_size, vpu->config, vpu->config_addr);
}

-static void mdp_vpu_ipi_handle_init_ack(void *data, unsigned int len,
+static void mdp_vpu_ipi_handle_init_ack(const void *data, unsigned int len,
void *priv)
{
- struct mdp_ipi_init_msg *msg = (struct mdp_ipi_init_msg *)data;
+ const struct mdp_ipi_init_msg *msg = data;
struct mdp_vpu_dev *vpu =
(struct mdp_vpu_dev *)(unsigned long)msg->drv_data;

@@ -91,10 +91,10 @@ static void mdp_vpu_ipi_handle_init_ack(void *data, unsigned int len,
complete(&vpu->ipi_acked);
}

-static void mdp_vpu_ipi_handle_deinit_ack(void *data, unsigned int len,
+static void mdp_vpu_ipi_handle_deinit_ack(const void *data, unsigned int len,
void *priv)
{
- struct mdp_ipi_deinit_msg *msg = (struct mdp_ipi_deinit_msg *)data;
+ const struct mdp_ipi_deinit_msg *msg = data;
struct mdp_vpu_dev *vpu =
(struct mdp_vpu_dev *)(unsigned long)msg->drv_data;

@@ -102,10 +102,10 @@ static void mdp_vpu_ipi_handle_deinit_ack(void *data, unsigned int len,
complete(&vpu->ipi_acked);
}

-static void mdp_vpu_ipi_handle_frame_ack(void *data, unsigned int len,
+static void mdp_vpu_ipi_handle_frame_ack(const void *data, unsigned int len,
void *priv)
{
- struct img_sw_addr *addr = (struct img_sw_addr *)data;
+ const struct img_sw_addr *addr = data;
struct img_ipi_frameparam *param =
(struct img_ipi_frameparam *)(unsigned long)addr->va;
struct mdp_vpu_dev *vpu =
diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h
index 300363a40158c..2561b99c95871 100644
--- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h
+++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h
@@ -23,7 +23,7 @@ enum mtk_vcodec_fw_use {

struct mtk_vcodec_fw;

-typedef void (*mtk_vcodec_ipi_handler) (void *data,
+typedef void (*mtk_vcodec_ipi_handler) (const void *data,
unsigned int len, void *priv);

struct mtk_vcodec_fw *mtk_vcodec_fw_select(void *priv, enum mtk_vcodec_fw_type type,
diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c
index 9f6e4b59455da..4c34344dc7dcb 100644
--- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c
+++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c
@@ -29,15 +29,7 @@ static int mtk_vcodec_vpu_set_ipi_register(struct mtk_vcodec_fw *fw, int id,
mtk_vcodec_ipi_handler handler,
const char *name, void *priv)
{
- /*
- * The handler we receive takes a void * as its first argument. We
- * cannot change this because it needs to be passed down to the rproc
- * subsystem when SCP is used. VPU takes a const argument, which is
- * more constrained, so the conversion below is safe.
- */
- ipi_handler_t handler_const = (ipi_handler_t)handler;
-
- return vpu_ipi_register(fw->pdev, id, handler_const, name, priv);
+ return vpu_ipi_register(fw->pdev, id, handler, name, priv);
}

static int mtk_vcodec_vpu_ipi_send(struct mtk_vcodec_fw *fw, int id, void *buf,
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c
index 82e57ae983d55..a840dd2a48d0e 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c
@@ -97,7 +97,7 @@ static bool vpu_dec_check_ap_inst(struct mtk_vcodec_dec_dev *dec_dev, struct vde
* This function runs in interrupt context and it means there's an IPI MSG
* from VPU.
*/
-static void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv)
+static void vpu_dec_ipi_handler(const void *data, unsigned int len, void *priv)
{
struct mtk_vcodec_dec_dev *dec_dev;
const struct vdec_vpu_ipi_ack *msg = data;
diff --git a/drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c b/drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c
index 84ad1cc6ad171..ea0c4a281d1a1 100644
--- a/drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c
+++ b/drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c
@@ -57,7 +57,7 @@ static bool vpu_enc_check_ap_inst(struct mtk_vcodec_enc_dev *enc_dev, struct ven
return ret;
}

-static void vpu_enc_ipi_handler(void *data, unsigned int len, void *priv)
+static void vpu_enc_ipi_handler(const void *data, unsigned int len, void *priv)
{
struct mtk_vcodec_enc_dev *enc_dev;
const struct venc_vpu_ipi_msg_common *msg = data;
diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
index a35409eda0cf2..b508136b416a8 100644
--- a/drivers/remoteproc/mtk_scp.c
+++ b/drivers/remoteproc/mtk_scp.c
@@ -78,10 +78,10 @@ static void scp_wdt_handler(struct mtk_scp *scp, u32 scp_to_host)
rproc_report_crash(scp_node->rproc, RPROC_WATCHDOG);
}

-static void scp_init_ipi_handler(void *data, unsigned int len, void *priv)
+static void scp_init_ipi_handler(const void *data, unsigned int len, void *priv)
{
struct mtk_scp *scp = priv;
- struct scp_run *run = data;
+ const struct scp_run *run = data;

scp->run.signaled = run->signaled;
strscpy(scp->run.fw_ver, run->fw_ver, SCP_FW_VER_LEN);
diff --git a/include/linux/remoteproc/mtk_scp.h b/include/linux/remoteproc/mtk_scp.h
index 7c2b7cc9fe6c1..84e579940b8e5 100644
--- a/include/linux/remoteproc/mtk_scp.h
+++ b/include/linux/remoteproc/mtk_scp.h
@@ -8,7 +8,7 @@

#include <linux/platform_device.h>

-typedef void (*scp_ipi_handler_t) (void *data,
+typedef void (*scp_ipi_handler_t) (const void *data,
unsigned int len,
void *priv);
struct mtk_scp;
diff --git a/include/linux/rpmsg/mtk_rpmsg.h b/include/linux/rpmsg/mtk_rpmsg.h
index 363b60178040b..9d67507471fba 100644
--- a/include/linux/rpmsg/mtk_rpmsg.h
+++ b/include/linux/rpmsg/mtk_rpmsg.h
@@ -9,7 +9,7 @@
#include <linux/platform_device.h>
#include <linux/remoteproc.h>

-typedef void (*ipi_handler_t)(void *data, unsigned int len, void *priv);
+typedef void (*ipi_handler_t)(const void *data, unsigned int len, void *priv);

/*
* struct mtk_rpmsg_info - IPI functions tied to the rpmsg device.

--
2.44.0.rc0.258.g7320e95886-goog


2024-02-26 18:09:06

by Ricardo Ribalda

[permalink] [raw]
Subject: Re: [PATCH v2 3/3] media: mediatek: vcodedc: Fix Wcast-function-type-strict warnings

Hi

On Mon, 26 Feb 2024 at 18:32, Ricardo Ribalda <[email protected]> wrote:
>
> Building with LLVM=1 throws the following warning:
> drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c:38:32: warning: cast from 'mtk_vcodec_ipi_handler' (aka 'void (*)(void *, unsigned int, void *)') to 'ipi_handler_t' (aka 'void (*)(const void *, unsigned int, void *)') converts to incompatible function type [-Wcast-function-type-strict]
>
> Constify the types to avoid the warning.

Please note that this has only been compile tested.


>
> Signed-off-by: Ricardo Ribalda <[email protected]>
> ---
> drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c | 12 ++++++------
> .../media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h | 2 +-
> .../platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c | 10 +---------
> drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c | 2 +-
> drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c | 2 +-
> drivers/remoteproc/mtk_scp.c | 4 ++--
> include/linux/remoteproc/mtk_scp.h | 2 +-
> include/linux/rpmsg/mtk_rpmsg.h | 2 +-
> 8 files changed, 14 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c
> index 49fc2e9d45dd5..c4f1c49b9d52a 100644
> --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c
> +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c
> @@ -77,10 +77,10 @@ void mdp_vpu_shared_mem_free(struct mdp_vpu_dev *vpu)
> dma_free_wc(dev, vpu->config_size, vpu->config, vpu->config_addr);
> }
>
> -static void mdp_vpu_ipi_handle_init_ack(void *data, unsigned int len,
> +static void mdp_vpu_ipi_handle_init_ack(const void *data, unsigned int len,
> void *priv)
> {
> - struct mdp_ipi_init_msg *msg = (struct mdp_ipi_init_msg *)data;
> + const struct mdp_ipi_init_msg *msg = data;
> struct mdp_vpu_dev *vpu =
> (struct mdp_vpu_dev *)(unsigned long)msg->drv_data;
>
> @@ -91,10 +91,10 @@ static void mdp_vpu_ipi_handle_init_ack(void *data, unsigned int len,
> complete(&vpu->ipi_acked);
> }
>
> -static void mdp_vpu_ipi_handle_deinit_ack(void *data, unsigned int len,
> +static void mdp_vpu_ipi_handle_deinit_ack(const void *data, unsigned int len,
> void *priv)
> {
> - struct mdp_ipi_deinit_msg *msg = (struct mdp_ipi_deinit_msg *)data;
> + const struct mdp_ipi_deinit_msg *msg = data;
> struct mdp_vpu_dev *vpu =
> (struct mdp_vpu_dev *)(unsigned long)msg->drv_data;
>
> @@ -102,10 +102,10 @@ static void mdp_vpu_ipi_handle_deinit_ack(void *data, unsigned int len,
> complete(&vpu->ipi_acked);
> }
>
> -static void mdp_vpu_ipi_handle_frame_ack(void *data, unsigned int len,
> +static void mdp_vpu_ipi_handle_frame_ack(const void *data, unsigned int len,
> void *priv)
> {
> - struct img_sw_addr *addr = (struct img_sw_addr *)data;
> + const struct img_sw_addr *addr = data;
> struct img_ipi_frameparam *param =
> (struct img_ipi_frameparam *)(unsigned long)addr->va;
> struct mdp_vpu_dev *vpu =
> diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h
> index 300363a40158c..2561b99c95871 100644
> --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h
> +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h
> @@ -23,7 +23,7 @@ enum mtk_vcodec_fw_use {
>
> struct mtk_vcodec_fw;
>
> -typedef void (*mtk_vcodec_ipi_handler) (void *data,
> +typedef void (*mtk_vcodec_ipi_handler) (const void *data,
> unsigned int len, void *priv);
>
> struct mtk_vcodec_fw *mtk_vcodec_fw_select(void *priv, enum mtk_vcodec_fw_type type,
> diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c
> index 9f6e4b59455da..4c34344dc7dcb 100644
> --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c
> +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c
> @@ -29,15 +29,7 @@ static int mtk_vcodec_vpu_set_ipi_register(struct mtk_vcodec_fw *fw, int id,
> mtk_vcodec_ipi_handler handler,
> const char *name, void *priv)
> {
> - /*
> - * The handler we receive takes a void * as its first argument. We
> - * cannot change this because it needs to be passed down to the rproc
> - * subsystem when SCP is used. VPU takes a const argument, which is
> - * more constrained, so the conversion below is safe.
> - */
> - ipi_handler_t handler_const = (ipi_handler_t)handler;
> -
> - return vpu_ipi_register(fw->pdev, id, handler_const, name, priv);
> + return vpu_ipi_register(fw->pdev, id, handler, name, priv);
> }
>
> static int mtk_vcodec_vpu_ipi_send(struct mtk_vcodec_fw *fw, int id, void *buf,
> diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c
> index 82e57ae983d55..a840dd2a48d0e 100644
> --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c
> @@ -97,7 +97,7 @@ static bool vpu_dec_check_ap_inst(struct mtk_vcodec_dec_dev *dec_dev, struct vde
> * This function runs in interrupt context and it means there's an IPI MSG
> * from VPU.
> */
> -static void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv)
> +static void vpu_dec_ipi_handler(const void *data, unsigned int len, void *priv)
> {
> struct mtk_vcodec_dec_dev *dec_dev;
> const struct vdec_vpu_ipi_ack *msg = data;
> diff --git a/drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c b/drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c
> index 84ad1cc6ad171..ea0c4a281d1a1 100644
> --- a/drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c
> @@ -57,7 +57,7 @@ static bool vpu_enc_check_ap_inst(struct mtk_vcodec_enc_dev *enc_dev, struct ven
> return ret;
> }
>
> -static void vpu_enc_ipi_handler(void *data, unsigned int len, void *priv)
> +static void vpu_enc_ipi_handler(const void *data, unsigned int len, void *priv)
> {
> struct mtk_vcodec_enc_dev *enc_dev;
> const struct venc_vpu_ipi_msg_common *msg = data;
> diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
> index a35409eda0cf2..b508136b416a8 100644
> --- a/drivers/remoteproc/mtk_scp.c
> +++ b/drivers/remoteproc/mtk_scp.c
> @@ -78,10 +78,10 @@ static void scp_wdt_handler(struct mtk_scp *scp, u32 scp_to_host)
> rproc_report_crash(scp_node->rproc, RPROC_WATCHDOG);
> }
>
> -static void scp_init_ipi_handler(void *data, unsigned int len, void *priv)
> +static void scp_init_ipi_handler(const void *data, unsigned int len, void *priv)
> {
> struct mtk_scp *scp = priv;
> - struct scp_run *run = data;
> + const struct scp_run *run = data;
>
> scp->run.signaled = run->signaled;
> strscpy(scp->run.fw_ver, run->fw_ver, SCP_FW_VER_LEN);
> diff --git a/include/linux/remoteproc/mtk_scp.h b/include/linux/remoteproc/mtk_scp.h
> index 7c2b7cc9fe6c1..84e579940b8e5 100644
> --- a/include/linux/remoteproc/mtk_scp.h
> +++ b/include/linux/remoteproc/mtk_scp.h
> @@ -8,7 +8,7 @@
>
> #include <linux/platform_device.h>
>
> -typedef void (*scp_ipi_handler_t) (void *data,
> +typedef void (*scp_ipi_handler_t) (const void *data,
> unsigned int len,
> void *priv);
> struct mtk_scp;
> diff --git a/include/linux/rpmsg/mtk_rpmsg.h b/include/linux/rpmsg/mtk_rpmsg.h
> index 363b60178040b..9d67507471fba 100644
> --- a/include/linux/rpmsg/mtk_rpmsg.h
> +++ b/include/linux/rpmsg/mtk_rpmsg.h
> @@ -9,7 +9,7 @@
> #include <linux/platform_device.h>
> #include <linux/remoteproc.h>
>
> -typedef void (*ipi_handler_t)(void *data, unsigned int len, void *priv);
> +typedef void (*ipi_handler_t)(const void *data, unsigned int len, void *priv);
>
> /*
> * struct mtk_rpmsg_info - IPI functions tied to the rpmsg device.
>
> --
> 2.44.0.rc0.258.g7320e95886-goog
>


--
Ricardo Ribalda

2024-02-27 11:17:48

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2 3/3] media: mediatek: vcodedc: Fix Wcast-function-type-strict warnings

Ricardo,

First of all, note the typo in theo subject line: vcodedc -> vcodec.

There is also a similar (but not identical!) patch from Arnd:

https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/

That patch and yours share the change to common/mtk_vcodec_fw_vpu.c but otherwise
they are different, which is a bit odd.

Can you take a look at Arnd's patch and see if you need to incorporate his changes
into your patch?

Regards,

Hans

On 26/02/2024 18:32, Ricardo Ribalda wrote:
> Building with LLVM=1 throws the following warning:
> drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c:38:32: warning: cast from 'mtk_vcodec_ipi_handler' (aka 'void (*)(void *, unsigned int, void *)') to 'ipi_handler_t' (aka 'void (*)(const void *, unsigned int, void *)') converts to incompatible function type [-Wcast-function-type-strict]
>
> Constify the types to avoid the warning.
>
> Signed-off-by: Ricardo Ribalda <[email protected]>
> ---
> drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c | 12 ++++++------
> .../media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h | 2 +-
> .../platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c | 10 +---------
> drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c | 2 +-
> drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c | 2 +-
> drivers/remoteproc/mtk_scp.c | 4 ++--
> include/linux/remoteproc/mtk_scp.h | 2 +-
> include/linux/rpmsg/mtk_rpmsg.h | 2 +-
> 8 files changed, 14 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c
> index 49fc2e9d45dd5..c4f1c49b9d52a 100644
> --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c
> +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c
> @@ -77,10 +77,10 @@ void mdp_vpu_shared_mem_free(struct mdp_vpu_dev *vpu)
> dma_free_wc(dev, vpu->config_size, vpu->config, vpu->config_addr);
> }
>
> -static void mdp_vpu_ipi_handle_init_ack(void *data, unsigned int len,
> +static void mdp_vpu_ipi_handle_init_ack(const void *data, unsigned int len,
> void *priv)
> {
> - struct mdp_ipi_init_msg *msg = (struct mdp_ipi_init_msg *)data;
> + const struct mdp_ipi_init_msg *msg = data;
> struct mdp_vpu_dev *vpu =
> (struct mdp_vpu_dev *)(unsigned long)msg->drv_data;
>
> @@ -91,10 +91,10 @@ static void mdp_vpu_ipi_handle_init_ack(void *data, unsigned int len,
> complete(&vpu->ipi_acked);
> }
>
> -static void mdp_vpu_ipi_handle_deinit_ack(void *data, unsigned int len,
> +static void mdp_vpu_ipi_handle_deinit_ack(const void *data, unsigned int len,
> void *priv)
> {
> - struct mdp_ipi_deinit_msg *msg = (struct mdp_ipi_deinit_msg *)data;
> + const struct mdp_ipi_deinit_msg *msg = data;
> struct mdp_vpu_dev *vpu =
> (struct mdp_vpu_dev *)(unsigned long)msg->drv_data;
>
> @@ -102,10 +102,10 @@ static void mdp_vpu_ipi_handle_deinit_ack(void *data, unsigned int len,
> complete(&vpu->ipi_acked);
> }
>
> -static void mdp_vpu_ipi_handle_frame_ack(void *data, unsigned int len,
> +static void mdp_vpu_ipi_handle_frame_ack(const void *data, unsigned int len,
> void *priv)
> {
> - struct img_sw_addr *addr = (struct img_sw_addr *)data;
> + const struct img_sw_addr *addr = data;
> struct img_ipi_frameparam *param =
> (struct img_ipi_frameparam *)(unsigned long)addr->va;
> struct mdp_vpu_dev *vpu =
> diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h
> index 300363a40158c..2561b99c95871 100644
> --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h
> +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h
> @@ -23,7 +23,7 @@ enum mtk_vcodec_fw_use {
>
> struct mtk_vcodec_fw;
>
> -typedef void (*mtk_vcodec_ipi_handler) (void *data,
> +typedef void (*mtk_vcodec_ipi_handler) (const void *data,
> unsigned int len, void *priv);
>
> struct mtk_vcodec_fw *mtk_vcodec_fw_select(void *priv, enum mtk_vcodec_fw_type type,
> diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c
> index 9f6e4b59455da..4c34344dc7dcb 100644
> --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c
> +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c
> @@ -29,15 +29,7 @@ static int mtk_vcodec_vpu_set_ipi_register(struct mtk_vcodec_fw *fw, int id,
> mtk_vcodec_ipi_handler handler,
> const char *name, void *priv)
> {
> - /*
> - * The handler we receive takes a void * as its first argument. We
> - * cannot change this because it needs to be passed down to the rproc
> - * subsystem when SCP is used. VPU takes a const argument, which is
> - * more constrained, so the conversion below is safe.
> - */
> - ipi_handler_t handler_const = (ipi_handler_t)handler;
> -
> - return vpu_ipi_register(fw->pdev, id, handler_const, name, priv);
> + return vpu_ipi_register(fw->pdev, id, handler, name, priv);
> }
>
> static int mtk_vcodec_vpu_ipi_send(struct mtk_vcodec_fw *fw, int id, void *buf,
> diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c
> index 82e57ae983d55..a840dd2a48d0e 100644
> --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c
> @@ -97,7 +97,7 @@ static bool vpu_dec_check_ap_inst(struct mtk_vcodec_dec_dev *dec_dev, struct vde
> * This function runs in interrupt context and it means there's an IPI MSG
> * from VPU.
> */
> -static void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv)
> +static void vpu_dec_ipi_handler(const void *data, unsigned int len, void *priv)
> {
> struct mtk_vcodec_dec_dev *dec_dev;
> const struct vdec_vpu_ipi_ack *msg = data;
> diff --git a/drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c b/drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c
> index 84ad1cc6ad171..ea0c4a281d1a1 100644
> --- a/drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c
> @@ -57,7 +57,7 @@ static bool vpu_enc_check_ap_inst(struct mtk_vcodec_enc_dev *enc_dev, struct ven
> return ret;
> }
>
> -static void vpu_enc_ipi_handler(void *data, unsigned int len, void *priv)
> +static void vpu_enc_ipi_handler(const void *data, unsigned int len, void *priv)
> {
> struct mtk_vcodec_enc_dev *enc_dev;
> const struct venc_vpu_ipi_msg_common *msg = data;
> diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
> index a35409eda0cf2..b508136b416a8 100644
> --- a/drivers/remoteproc/mtk_scp.c
> +++ b/drivers/remoteproc/mtk_scp.c
> @@ -78,10 +78,10 @@ static void scp_wdt_handler(struct mtk_scp *scp, u32 scp_to_host)
> rproc_report_crash(scp_node->rproc, RPROC_WATCHDOG);
> }
>
> -static void scp_init_ipi_handler(void *data, unsigned int len, void *priv)
> +static void scp_init_ipi_handler(const void *data, unsigned int len, void *priv)
> {
> struct mtk_scp *scp = priv;
> - struct scp_run *run = data;
> + const struct scp_run *run = data;
>
> scp->run.signaled = run->signaled;
> strscpy(scp->run.fw_ver, run->fw_ver, SCP_FW_VER_LEN);
> diff --git a/include/linux/remoteproc/mtk_scp.h b/include/linux/remoteproc/mtk_scp.h
> index 7c2b7cc9fe6c1..84e579940b8e5 100644
> --- a/include/linux/remoteproc/mtk_scp.h
> +++ b/include/linux/remoteproc/mtk_scp.h
> @@ -8,7 +8,7 @@
>
> #include <linux/platform_device.h>
>
> -typedef void (*scp_ipi_handler_t) (void *data,
> +typedef void (*scp_ipi_handler_t) (const void *data,
> unsigned int len,
> void *priv);
> struct mtk_scp;
> diff --git a/include/linux/rpmsg/mtk_rpmsg.h b/include/linux/rpmsg/mtk_rpmsg.h
> index 363b60178040b..9d67507471fba 100644
> --- a/include/linux/rpmsg/mtk_rpmsg.h
> +++ b/include/linux/rpmsg/mtk_rpmsg.h
> @@ -9,7 +9,7 @@
> #include <linux/platform_device.h>
> #include <linux/remoteproc.h>
>
> -typedef void (*ipi_handler_t)(void *data, unsigned int len, void *priv);
> +typedef void (*ipi_handler_t)(const void *data, unsigned int len, void *priv);
>
> /*
> * struct mtk_rpmsg_info - IPI functions tied to the rpmsg device.
>


2024-02-27 11:51:51

by Ricardo Ribalda

[permalink] [raw]
Subject: Re: [PATCH v2 3/3] media: mediatek: vcodedc: Fix Wcast-function-type-strict warnings

Hi Hans

On Tue, 27 Feb 2024 at 12:17, Hans Verkuil <[email protected]> wrote:
>
> Ricardo,
>
> First of all, note the typo in theo subject line: vcodedc -> vcodec.
>
> There is also a similar (but not identical!) patch from Arnd:
>
> https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
>
> That patch and yours share the change to common/mtk_vcodec_fw_vpu.c but otherwise
> they are different, which is a bit odd.
>
> Can you take a look at Arnd's patch and see if you need to incorporate his changes
> into your patch?

We went separate paths :), I tried to make everything const (and
therefore the remoteproc changes) and he removed the const.

His patch looks good to me. Shall I resend the series without this
patch or you can ignore 3/3 and take 1 and 2?

Thanks!

>
> Regards,
>
> Hans
>
> On 26/02/2024 18:32, Ricardo Ribalda wrote:
> > Building with LLVM=1 throws the following warning:
> > drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c:38:32: warning: cast from 'mtk_vcodec_ipi_handler' (aka 'void (*)(void *, unsigned int, void *)') to 'ipi_handler_t' (aka 'void (*)(const void *, unsigned int, void *)') converts to incompatible function type [-Wcast-function-type-strict]
> >
> > Constify the types to avoid the warning.
> >
> > Signed-off-by: Ricardo Ribalda <[email protected]>
> > ---
> > drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c | 12 ++++++------
> > .../media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h | 2 +-
> > .../platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c | 10 +---------
> > drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c | 2 +-
> > drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c | 2 +-
> > drivers/remoteproc/mtk_scp.c | 4 ++--
> > include/linux/remoteproc/mtk_scp.h | 2 +-
> > include/linux/rpmsg/mtk_rpmsg.h | 2 +-
> > 8 files changed, 14 insertions(+), 22 deletions(-)
> >
> > diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c
> > index 49fc2e9d45dd5..c4f1c49b9d52a 100644
> > --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c
> > +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-vpu.c
> > @@ -77,10 +77,10 @@ void mdp_vpu_shared_mem_free(struct mdp_vpu_dev *vpu)
> > dma_free_wc(dev, vpu->config_size, vpu->config, vpu->config_addr);
> > }
> >
> > -static void mdp_vpu_ipi_handle_init_ack(void *data, unsigned int len,
> > +static void mdp_vpu_ipi_handle_init_ack(const void *data, unsigned int len,
> > void *priv)
> > {
> > - struct mdp_ipi_init_msg *msg = (struct mdp_ipi_init_msg *)data;
> > + const struct mdp_ipi_init_msg *msg = data;
> > struct mdp_vpu_dev *vpu =
> > (struct mdp_vpu_dev *)(unsigned long)msg->drv_data;
> >
> > @@ -91,10 +91,10 @@ static void mdp_vpu_ipi_handle_init_ack(void *data, unsigned int len,
> > complete(&vpu->ipi_acked);
> > }
> >
> > -static void mdp_vpu_ipi_handle_deinit_ack(void *data, unsigned int len,
> > +static void mdp_vpu_ipi_handle_deinit_ack(const void *data, unsigned int len,
> > void *priv)
> > {
> > - struct mdp_ipi_deinit_msg *msg = (struct mdp_ipi_deinit_msg *)data;
> > + const struct mdp_ipi_deinit_msg *msg = data;
> > struct mdp_vpu_dev *vpu =
> > (struct mdp_vpu_dev *)(unsigned long)msg->drv_data;
> >
> > @@ -102,10 +102,10 @@ static void mdp_vpu_ipi_handle_deinit_ack(void *data, unsigned int len,
> > complete(&vpu->ipi_acked);
> > }
> >
> > -static void mdp_vpu_ipi_handle_frame_ack(void *data, unsigned int len,
> > +static void mdp_vpu_ipi_handle_frame_ack(const void *data, unsigned int len,
> > void *priv)
> > {
> > - struct img_sw_addr *addr = (struct img_sw_addr *)data;
> > + const struct img_sw_addr *addr = data;
> > struct img_ipi_frameparam *param =
> > (struct img_ipi_frameparam *)(unsigned long)addr->va;
> > struct mdp_vpu_dev *vpu =
> > diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h
> > index 300363a40158c..2561b99c95871 100644
> > --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h
> > +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw.h
> > @@ -23,7 +23,7 @@ enum mtk_vcodec_fw_use {
> >
> > struct mtk_vcodec_fw;
> >
> > -typedef void (*mtk_vcodec_ipi_handler) (void *data,
> > +typedef void (*mtk_vcodec_ipi_handler) (const void *data,
> > unsigned int len, void *priv);
> >
> > struct mtk_vcodec_fw *mtk_vcodec_fw_select(void *priv, enum mtk_vcodec_fw_type type,
> > diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c
> > index 9f6e4b59455da..4c34344dc7dcb 100644
> > --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c
> > +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vpu.c
> > @@ -29,15 +29,7 @@ static int mtk_vcodec_vpu_set_ipi_register(struct mtk_vcodec_fw *fw, int id,
> > mtk_vcodec_ipi_handler handler,
> > const char *name, void *priv)
> > {
> > - /*
> > - * The handler we receive takes a void * as its first argument. We
> > - * cannot change this because it needs to be passed down to the rproc
> > - * subsystem when SCP is used. VPU takes a const argument, which is
> > - * more constrained, so the conversion below is safe.
> > - */
> > - ipi_handler_t handler_const = (ipi_handler_t)handler;
> > -
> > - return vpu_ipi_register(fw->pdev, id, handler_const, name, priv);
> > + return vpu_ipi_register(fw->pdev, id, handler, name, priv);
> > }
> >
> > static int mtk_vcodec_vpu_ipi_send(struct mtk_vcodec_fw *fw, int id, void *buf,
> > diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_ifc b/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c
> > index 82e57ae983d55..a840dd2a48d0e 100644
> > --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c
> > +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c
> > @@ -97,7 +97,7 @@ static bool vpu_dec_check_ap_inst(struct mtk_vcodec_dec_dev *dec_dev, struct vde
> > * This function runs in interrupt context and it means there's an IPI MSG
> > * from VPU.
> > */
> > -static void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv)
> > +static void vpu_dec_ipi_handler(const void *data, unsigned int len, void *priv)
> > {
> > struct mtk_vcodec_dec_dev *dec_dev;
> > const struct vdec_vpu_ipi_ack *msg = data;
> > diff --git a/drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_ifc b/drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c
> > index 84ad1cc6ad171..ea0c4a281d1a1 100644
> > --- a/drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c
> > +++ b/drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c
> > @@ -57,7 +57,7 @@ static bool vpu_enc_check_ap_inst(struct mtk_vcodec_enc_dev *enc_dev, struct ven
> > return ret;
> > }
> >
> > -static void vpu_enc_ipi_handler(void *data, unsigned int len, void *priv)
> > +static void vpu_enc_ipi_handler(const void *data, unsigned int len, void *priv)
> > {
> > struct mtk_vcodec_enc_dev *enc_dev;
> > const struct venc_vpu_ipi_msg_common *msg = data;
> > diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
> > index a35409eda0cf2..b508136b416a8 100644
> > --- a/drivers/remoteproc/mtk_scp.c
> > +++ b/drivers/remoteproc/mtk_scp.c
> > @@ -78,10 +78,10 @@ static void scp_wdt_handler(struct mtk_scp *scp, u32 scp_to_host)
> > rproc_report_crash(scp_node->rproc, RPROC_WATCHDOG);
> > }
> >
> > -static void scp_init_ipi_handler(void *data, unsigned int len, void *priv)
> > +static void scp_init_ipi_handler(const void *data, unsigned int len, void *priv)
> > {
> > struct mtk_scp *scp = priv;
> > - struct scp_run *run = data;
> > + const struct scp_run *run = data;
> >
> > scp->run.signaled = run->signaled;
> > strscpy(scp->run.fw_ver, run->fw_ver, SCP_FW_VER_LEN);
> > diff --git a/include/linux/remoteproc/mtk_scp.h b/include/linux/remoteproc/mtk_scp.h
> > index 7c2b7cc9fe6c1..84e579940b8e5 100644
> > --- a/include/linux/remoteproc/mtk_scp.h
> > +++ b/include/linux/remoteproc/mtk_scp.h
> > @@ -8,7 +8,7 @@
> >
> > #include <linux/platform_device.h>
> >
> > -typedef void (*scp_ipi_handler_t) (void *data,
> > +typedef void (*scp_ipi_handler_t) (const void *data,
> > unsigned int len,
> > void *priv);
> > struct mtk_scp;
> > diff --git a/include/linux/rpmsg/mtk_rpmsg.h b/include/linux/rpmsg/mtk_rpmsg.h
> > index 363b60178040b..9d67507471fba 100644
> > --- a/include/linux/rpmsg/mtk_rpmsg.h
> > +++ b/include/linux/rpmsg/mtk_rpmsg.h
> > @@ -9,7 +9,7 @@
> > #include <linux/platform_device.h>
> > #include <linux/remoteproc.h>
> >
> > -typedef void (*ipi_handler_t)(void *data, unsigned int len, void *priv);
> > +typedef void (*ipi_handler_t)(const void *data, unsigned int len, void *priv);
> >
> > /*
> > * struct mtk_rpmsg_info - IPI functions tied to the rpmsg device.
> >
>


--
Ricardo Ribalda

2024-02-27 13:39:31

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH v2 3/3] media: mediatek: vcodedc: Fix Wcast-function-type-strict warnings

On Tue, Feb 27, 2024, at 12:35, Ricardo Ribalda wrote:
> On Tue, 27 Feb 2024 at 12:17, Hans Verkuil <[email protected]> wrote:
>>
>> Ricardo,
>>
>> First of all, note the typo in theo subject line: vcodedc -> vcodec.
>>
>> There is also a similar (but not identical!) patch from Arnd:
>>
>> https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
>>
>> That patch and yours share the change to common/mtk_vcodec_fw_vpu.c but otherwise
>> they are different, which is a bit odd.
>>
>> Can you take a look at Arnd's patch and see if you need to incorporate his changes
>> into your patch?
>
> We went separate paths :), I tried to make everything const (and
> therefore the remoteproc changes) and he removed the const.

I had the same patch 3 originally but there was still a
warning or a cast from const to non-const pointer, so I
went with the simpler approach that I posted.

Without that regression, your patch would be nicer, but I
think the version you sent has the same regression that
I ran into.

> His patch looks good to me. Shall I resend the series without this
> patch or you can ignore 3/3 and take 1 and 2?

I also sent your patches 1 and 2 with minor differences in
whitespace. Both of these are already in linux-next, so I think
you don't have to resend anything here.

I sent a whole lot of -Wcast-function-type-strict warning fixes
to address all randconfig builds on arm64, arm and x86, all but
three are now merged. Aside from the mediatek vcodec, the only
missing ones are

https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/

I also had one patch for s390 but none of the other architectures.
I think once Hans applies the vcodec patch, I'll resend the
last two patches together with a patch to enable the warning by
default.

Arnd

2024-02-28 07:55:10

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2 1/3] media: pci: sta2x11: Fix Wcast-function-type-strict warnings

On 26/02/2024 18:32, Ricardo Ribalda wrote:
> Building with LLVM=1 throws the following warning:
> drivers/media/pci/sta2x11/sta2x11_vip.c:1057:6: warning: cast from 'irqreturn_t (*)(int, struct sta2x11_vip *)' (aka 'enum irqreturn (*)(int, struct sta2x11_vip *)') to 'irq_handler_t' (aka 'enum irqreturn (*)(int, void *)') converts to incompatible function type [-Wcast-function-type-strict]
>
> Reviewed-by: Nathan Chancellor <[email protected]>
> Signed-off-by: Ricardo Ribalda <[email protected]>

Arnd's patch for this has already been merged:

https://lore.kernel.org/linux-media/[email protected]/

So I'm marking your patch as 'Obsolete' in patchwork.

Regards,

Hans

> ---
> drivers/media/pci/sta2x11/sta2x11_vip.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c b/drivers/media/pci/sta2x11/sta2x11_vip.c
> index e4cf9d63e926d..a6456673be3f6 100644
> --- a/drivers/media/pci/sta2x11/sta2x11_vip.c
> +++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
> @@ -757,7 +757,7 @@ static const struct video_device video_dev_template = {
> /**
> * vip_irq - interrupt routine
> * @irq: Number of interrupt ( not used, correct number is assumed )
> - * @vip: local data structure containing all information
> + * @data: local data structure containing all information
> *
> * check for both frame interrupts set ( top and bottom ).
> * check FIFO overflow, but limit number of log messages after open.
> @@ -767,8 +767,9 @@ static const struct video_device video_dev_template = {
> *
> * IRQ_HANDLED, interrupt done.
> */
> -static irqreturn_t vip_irq(int irq, struct sta2x11_vip *vip)
> +static irqreturn_t vip_irq(int irq, void *data)
> {
> + struct sta2x11_vip *vip = data;
> unsigned int status;
>
> status = reg_read(vip, DVP_ITS);
>


2024-02-28 08:01:35

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2 2/3] media: usb: pvrusb2: Fix Wcast-function-type-strict warnings

On 26/02/2024 18:32, Ricardo Ribalda wrote:
> Building with LLVM=1 throws the following warning:
> drivers/media/usb/pvrusb2/pvrusb2-context.c:110:6: warning: cast from 'void (*)(struct pvr2_context *)' to 'void (*)(void *)' converts to incompatible function type [-Wcast-function-type-strict]
> drivers/media/usb/pvrusb2/pvrusb2-v4l2.c:1070:30: warning: cast from 'void (*)(struct pvr2_v4l2_fh *)' to 'pvr2_stream_callback' (aka 'void (*)(void *)') converts to incompatible function type [-Wcast-function-type-strict] drivers/media/usb/pvrusb2/pvrusb2-dvb.c:152:6: warning: cast from 'void (*)(struct pvr2_dvb_adapter *)' to 'pvr2_stream_callback' (aka 'void (*)(void *)') converts to incompatible function type [-Wcast-function-type-strict]

This patch from Arnd has already been merged, superseding your patch:

https://lore.kernel.org/linux-media/[email protected]/

Marking your patch as Obsolete in patchwork.

Regards,

Hans

>
> Reviewed-by: Nathan Chancellor <[email protected]>
> Signed-off-by: Ricardo Ribalda <[email protected]>
> ---
> drivers/media/usb/pvrusb2/pvrusb2-context.c | 5 +++--
> drivers/media/usb/pvrusb2/pvrusb2-dvb.c | 7 ++++---
> drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 7 ++++---
> 3 files changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/media/usb/pvrusb2/pvrusb2-context.c b/drivers/media/usb/pvrusb2/pvrusb2-context.c
> index 1764674de98bc..16edabda191c4 100644
> --- a/drivers/media/usb/pvrusb2/pvrusb2-context.c
> +++ b/drivers/media/usb/pvrusb2/pvrusb2-context.c
> @@ -90,8 +90,9 @@ static void pvr2_context_destroy(struct pvr2_context *mp)
> }
>
>
> -static void pvr2_context_notify(struct pvr2_context *mp)
> +static void pvr2_context_notify(void *data)
> {
> + struct pvr2_context *mp = data;
> pvr2_context_set_notify(mp,!0);
> }
>
> @@ -107,7 +108,7 @@ static void pvr2_context_check(struct pvr2_context *mp)
> "pvr2_context %p (initialize)", mp);
> /* Finish hardware initialization */
> if (pvr2_hdw_initialize(mp->hdw,
> - (void (*)(void *))pvr2_context_notify,
> + pvr2_context_notify,
> mp)) {
> mp->video_stream.stream =
> pvr2_hdw_get_video_stream(mp->hdw);
> diff --git a/drivers/media/usb/pvrusb2/pvrusb2-dvb.c b/drivers/media/usb/pvrusb2/pvrusb2-dvb.c
> index 26811efe0fb58..8b9f1a09bd53d 100644
> --- a/drivers/media/usb/pvrusb2/pvrusb2-dvb.c
> +++ b/drivers/media/usb/pvrusb2/pvrusb2-dvb.c
> @@ -88,8 +88,9 @@ static int pvr2_dvb_feed_thread(void *data)
> return stat;
> }
>
> -static void pvr2_dvb_notify(struct pvr2_dvb_adapter *adap)
> +static void pvr2_dvb_notify(void *data)
> {
> + struct pvr2_dvb_adapter *adap = data;
> wake_up(&adap->buffer_wait_data);
> }
>
> @@ -148,8 +149,8 @@ static int pvr2_dvb_stream_do_start(struct pvr2_dvb_adapter *adap)
> if (!(adap->buffer_storage[idx])) return -ENOMEM;
> }
>
> - pvr2_stream_set_callback(pvr->video_stream.stream,
> - (pvr2_stream_callback) pvr2_dvb_notify, adap);
> + pvr2_stream_set_callback(pvr->video_stream.stream, pvr2_dvb_notify,
> + adap);
>
> ret = pvr2_stream_set_buffer_count(stream, PVR2_DVB_BUFFER_COUNT);
> if (ret < 0) return ret;
> diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
> index c04ab7258d645..590f80949bbfc 100644
> --- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
> +++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
> @@ -1032,9 +1032,10 @@ static int pvr2_v4l2_open(struct file *file)
> return 0;
> }
>
> -
> -static void pvr2_v4l2_notify(struct pvr2_v4l2_fh *fhp)
> +static void pvr2_v4l2_notify(void *data)
> {
> + struct pvr2_v4l2_fh *fhp = data;
> +
> wake_up(&fhp->wait_data);
> }
>
> @@ -1067,7 +1068,7 @@ static int pvr2_v4l2_iosetup(struct pvr2_v4l2_fh *fh)
>
> hdw = fh->channel.mc_head->hdw;
> sp = fh->pdi->stream->stream;
> - pvr2_stream_set_callback(sp,(pvr2_stream_callback)pvr2_v4l2_notify,fh);
> + pvr2_stream_set_callback(sp, pvr2_v4l2_notify, fh);
> pvr2_hdw_set_stream_type(hdw,fh->pdi->config);
> if ((ret = pvr2_hdw_set_streaming(hdw,!0)) < 0) return ret;
> return pvr2_ioread_set_enabled(fh->rhp,!0);
>