Re: [PATCH 03/16] ASoC: SOF: ops: add readb/writeb helpers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 10/27/22 14:51, Nathan Chancellor wrote:
> Hi Pierre-Louis,
> 
> On Mon, Oct 24, 2022 at 11:52:57AM -0500, Pierre-Louis Bossart wrote:
>> These will be used to add more consistency in the SOF core and
>> drivers.
>>
>> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxxxxxxxx>
>> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@xxxxxxxxxxxxxxx>
>> Reviewed-by: Rander Wang <rander.wang@xxxxxxxxx>
>> Reviewed-by: Péter Ujfalusi <peter.ujfalusi@xxxxxxxxxxxxxxx>
> 
> This change is now in -next as commit 74fe0c4dcb41 ("ASoC: SOF: ops: add
> readb/writeb helpers"), where it breaks the build badly on at least
> ARCH=arm:
> 
> $ kmake ARCH=arm CROSS_COMPILE=arm-linux-gnu- allmodconfig sound/soc/sof/
> ...
> In file included from sound/soc/sof/sof-client.c:16:
> sound/soc/sof/ops.h: In function ‘snd_sof_dsp_writeb’:
> sound/soc/sof/ops.h:309:75: error: macro "writeb" passed 3 arguments, but takes just 2
>   309 |                 sof_ops(sdev)->writeb(sdev, sdev->bar[bar] + offset, value);
>       |                                                                           ^
> In file included from ./include/linux/io.h:13,
>                  from ./include/linux/irq.h:20,
>                  from ./include/asm-generic/hardirq.h:17,
>                  from ./arch/arm/include/asm/hardirq.h:10,
>                  from ./include/linux/hardirq.h:11,
>                  from ./include/linux/interrupt.h:11,
>                  from sound/soc/sof/ops.h:15:
> ./arch/arm/include/asm/io.h:288: note: macro "writeb" defined here
>   288 | #define writeb(v,c)             ({ __iowmb(); writeb_relaxed(v,c); })
>       |
> sound/soc/sof/ops.h:309:30: error: statement with no effect [-Werror=unused-value]
>   309 |                 sof_ops(sdev)->writeb(sdev, sdev->bar[bar] + offset, value);
>       |                              ^
> sound/soc/sof/ops.h: In function ‘snd_sof_dsp_readb’:
> sound/soc/sof/ops.h:336:74: error: macro "readb" passed 2 arguments, but takes just 1
>   336 |                 return sof_ops(sdev)->readb(sdev, sdev->bar[bar] + offset);
>       |                                                                          ^
> ./arch/arm/include/asm/io.h:284: note: macro "readb" defined here
>   284 | #define readb(c)                ({ u8  __v = readb_relaxed(c); __iormb(); __v; })
>       |
> sound/soc/sof/ops.h:336:37: error: returning ‘u8 (*)(struct snd_sof_dev *, void *)’ {aka ‘unsigned char (*)(struct snd_sof_dev *, void *)’} from a function with return type ‘u8’ {aka ‘unsigned char’} makes integer from pointer without a cast [-Werror=int-conversion]
>   336 |                 return sof_ops(sdev)->readb(sdev, sdev->bar[bar] + offset);
>       |                                     ^
> cc1: all warnings being treated as errors
> ...
> 
> I guess the preprocessor gets to these calls first and everything
> explodes from there. Perhaps these should be namespaced somehow?

Thanks for the report. We've had these patches for a while and always
compile for ARM, and didn't see any issues raised. Meh.

I don't have a strong appetite for changes in common parts, maybe it's
just simpler to use read8/write8 as callback names to avoid the
conflict, something like the patch attached (compile-tested only). In
hindsight it'd also be more consistent with the use of read64/write64
that was added earlier in SOF helpers.


diff --git a/sound/soc/sof/intel/hda-dsp.c b/sound/soc/sof/intel/hda-dsp.c
index 6d896ea31680..fd72e78d2da7 100644
--- a/sound/soc/sof/intel/hda-dsp.c
+++ b/sound/soc/sof/intel/hda-dsp.c
@@ -349,7 +349,7 @@ static int hda_dsp_wait_d0i3c_done(struct snd_sof_dev *sdev)
 {
 	int retry = HDA_DSP_REG_POLL_RETRY_COUNT;
 
-	while (snd_sof_dsp_readb(sdev, HDA_DSP_HDA_BAR, SOF_HDA_VS_D0I3C) & SOF_HDA_VS_D0I3C_CIP) {
+	while (snd_sof_dsp_read8(sdev, HDA_DSP_HDA_BAR, SOF_HDA_VS_D0I3C) & SOF_HDA_VS_D0I3C_CIP) {
 		if (!retry--)
 			return -ETIMEDOUT;
 		usleep_range(10, 15);
@@ -399,7 +399,7 @@ static int hda_dsp_update_d0i3c_register(struct snd_sof_dev *sdev, u8 value)
 		return ret;
 	}
 
-	reg = snd_sof_dsp_readb(sdev, HDA_DSP_HDA_BAR, SOF_HDA_VS_D0I3C);
+	reg = snd_sof_dsp_read8(sdev, HDA_DSP_HDA_BAR, SOF_HDA_VS_D0I3C);
 	trace_sof_intel_D0I3C_updated(sdev, reg);
 
 	return 0;
diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
index 79c32d948b2d..5831029b3128 100644
--- a/sound/soc/sof/intel/hda.c
+++ b/sound/soc/sof/intel/hda.c
@@ -636,7 +636,7 @@ void hda_ipc_irq_dump(struct snd_sof_dev *sdev)
 	intsts = snd_sof_dsp_read(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTSTS);
 	intctl = snd_sof_dsp_read(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTCTL);
 	ppsts = snd_sof_dsp_read(sdev, HDA_DSP_PP_BAR, SOF_HDA_REG_PP_PPSTS);
-	rirbsts = snd_sof_dsp_readb(sdev, HDA_DSP_HDA_BAR, AZX_REG_RIRBSTS);
+	rirbsts = snd_sof_dsp_read8(sdev, HDA_DSP_HDA_BAR, AZX_REG_RIRBSTS);
 
 	dev_err(sdev->dev, "hda irq intsts 0x%8.8x intlctl 0x%8.8x rirb %2.2x\n",
 		intsts, intctl, rirbsts);
diff --git a/sound/soc/sof/ops.h b/sound/soc/sof/ops.h
index 8cb93e7c0c67..aac558fc43ae 100644
--- a/sound/soc/sof/ops.h
+++ b/sound/soc/sof/ops.h
@@ -302,11 +302,11 @@ static inline int snd_sof_debugfs_add_region_item(struct snd_sof_dev *sdev,
 }
 
 /* register IO */
-static inline void snd_sof_dsp_writeb(struct snd_sof_dev *sdev, u32 bar,
+static inline void snd_sof_dsp_write8(struct snd_sof_dev *sdev, u32 bar,
 				      u32 offset, u8 value)
 {
-	if (sof_ops(sdev)->writeb)
-		sof_ops(sdev)->writeb(sdev, sdev->bar[bar] + offset, value);
+	if (sof_ops(sdev)->write8)
+		sof_ops(sdev)->write8(sdev, sdev->bar[bar] + offset, value);
 	else
 		writeb(value,  sdev->bar[bar] + offset);
 }
@@ -329,11 +329,11 @@ static inline void snd_sof_dsp_write64(struct snd_sof_dev *sdev, u32 bar,
 		writeq(value, sdev->bar[bar] + offset);
 }
 
-static inline u8 snd_sof_dsp_readb(struct snd_sof_dev *sdev, u32 bar,
+static inline u8 snd_sof_dsp_read8(struct snd_sof_dev *sdev, u32 bar,
 				   u32 offset)
 {
-	if (sof_ops(sdev)->readb)
-		return sof_ops(sdev)->readb(sdev, sdev->bar[bar] + offset);
+	if (sof_ops(sdev)->read8)
+		return sof_ops(sdev)->read8(sdev, sdev->bar[bar] + offset);
 	else
 		return readb(sdev->bar[bar] + offset);
 }
@@ -361,10 +361,10 @@ static inline void snd_sof_dsp_updateb(struct snd_sof_dev *sdev, u32 bar,
 {
 	u8 reg;
 
-	reg = snd_sof_dsp_readb(sdev, bar, offset);
+	reg = snd_sof_dsp_read8(sdev, bar, offset);
 	reg &= ~mask;
 	reg |= value;
-	snd_sof_dsp_writeb(sdev, bar, offset, reg);
+	snd_sof_dsp_write8(sdev, bar, offset, reg);
 }
 
 /* block IO */
diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h
index d3ede97b6759..c67ec9a1394b 100644
--- a/sound/soc/sof/sof-priv.h
+++ b/sound/soc/sof/sof-priv.h
@@ -171,9 +171,9 @@ struct snd_sof_dsp_ops {
 	 * TODO: consider removing these operations and calling respective
 	 * implementations directly
 	 */
-	void (*writeb)(struct snd_sof_dev *sof_dev, void __iomem *addr,
+	void (*write8)(struct snd_sof_dev *sof_dev, void __iomem *addr,
 		       u8 value); /* optional */
-	u8 (*readb)(struct snd_sof_dev *sof_dev,
+	u8 (*read8)(struct snd_sof_dev *sof_dev,
 		    void __iomem *addr); /* optional */
 	void (*write)(struct snd_sof_dev *sof_dev, void __iomem *addr,
 		      u32 value); /* optional */

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux