From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Client drivers may now pass hints to dmaengine drivers. GPI DMA's only
consumers (GENI SEs) need to pass a protocol (I2C, I3C, SPI, etc.) ID
to the DMA engine driver, for it to take different actions.
Currently, that's done through passing that ID through device tree,
with each Serial Engine expressed NUM_PROTOCOL times, resulting in
terrible dt-bindings that are full of useless copypasta.
To help get rid of that, accept the driver cookie instead, while
keeping backwards compatibility.
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
---
drivers/dma/qcom/gpi.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/dma/qcom/gpi.c b/drivers/dma/qcom/gpi.c
index 51d19494099dae09f4579ba8c3eddfa0487bf487..de9e564dc21b2230c9446dfb881135003721a750 100644
--- a/drivers/dma/qcom/gpi.c
+++ b/drivers/dma/qcom/gpi.c
@@ -17,6 +17,8 @@
#include "../dmaengine.h"
#include "../virt-dma.h"
+#include <linux/soc/qcom/geni-se.h>
+
#define TRE_TYPE_DMA 0x10
#define TRE_TYPE_IMMEDIATE_DMA 0x11
#define TRE_TYPE_GO 0x20
@@ -2109,15 +2111,19 @@ static int gpi_find_avail_gpii(struct gpi_dev *gpi_dev, u32 seid)
/* gpi_of_dma_xlate: open client requested channel */
static struct dma_chan *gpi_of_dma_xlate(struct of_phandle_args *args,
struct of_dma *of_dma,
- void *data)
+ void *proto)
{
struct gpi_dev *gpi_dev = (struct gpi_dev *)of_dma->of_dma_data;
u32 seid, chid;
int gpii;
struct gchan *gchan;
- if (args->args_count < 3) {
- dev_err(gpi_dev->dev, "gpii require minimum 2 args, client passed:%d args\n",
+ /* The protocol ID has been historically stored in the third cell */
+ if (!proto && args->args_count < 3)
+ return NULL;
+
+ if (args->args_count < 2) {
+ dev_err(gpi_dev->dev, "gpii requires minimum 2 args, client passed:%d args\n",
args->args_count);
return NULL;
}
@@ -2145,7 +2151,8 @@ static struct dma_chan *gpi_of_dma_xlate(struct of_phandle_args *args,
}
gchan->seid = seid;
- gchan->protocol = args->args[2];
+ /* The protocol ID is in the teens range, simply ignore the higher bits */
+ gchan->protocol = (u32)((u64)proto);
return dma_get_slave_channel(&gchan->vc.chan);
}
--
2.50.1
Hi Konrad, On Wed, 30 Jul 2025 at 11:35, Konrad Dybcio <konradybcio@kernel.org> wrote: > From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> > > Client drivers may now pass hints to dmaengine drivers. GPI DMA's only > consumers (GENI SEs) need to pass a protocol (I2C, I3C, SPI, etc.) ID > to the DMA engine driver, for it to take different actions. > > Currently, that's done through passing that ID through device tree, > with each Serial Engine expressed NUM_PROTOCOL times, resulting in > terrible dt-bindings that are full of useless copypasta. > > To help get rid of that, accept the driver cookie instead, while > keeping backwards compatibility. > > Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Thanks for your patch! > --- a/drivers/dma/qcom/gpi.c > +++ b/drivers/dma/qcom/gpi.c > @@ -2145,7 +2151,8 @@ static struct dma_chan *gpi_of_dma_xlate(struct of_phandle_args *args, > } > > gchan->seid = seid; > - gchan->protocol = args->args[2]; > + /* The protocol ID is in the teens range, simply ignore the higher bits */ > + gchan->protocol = (u32)((u64)proto); A single cast "(uintptr_t)" should be sufficient. Casing the pointer to u64 on 32-bit may trigger: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] > > return dma_get_slave_channel(&gchan->vc.chan); > } Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
On 7/30/25 1:32 PM, Geert Uytterhoeven wrote: > Hi Konrad, > > On Wed, 30 Jul 2025 at 11:35, Konrad Dybcio <konradybcio@kernel.org> wrote: >> From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> >> >> Client drivers may now pass hints to dmaengine drivers. GPI DMA's only >> consumers (GENI SEs) need to pass a protocol (I2C, I3C, SPI, etc.) ID >> to the DMA engine driver, for it to take different actions. >> >> Currently, that's done through passing that ID through device tree, >> with each Serial Engine expressed NUM_PROTOCOL times, resulting in >> terrible dt-bindings that are full of useless copypasta. >> >> To help get rid of that, accept the driver cookie instead, while >> keeping backwards compatibility. >> >> Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> > > Thanks for your patch! > >> --- a/drivers/dma/qcom/gpi.c >> +++ b/drivers/dma/qcom/gpi.c >> @@ -2145,7 +2151,8 @@ static struct dma_chan *gpi_of_dma_xlate(struct of_phandle_args *args, >> } >> >> gchan->seid = seid; >> - gchan->protocol = args->args[2]; >> + /* The protocol ID is in the teens range, simply ignore the higher bits */ >> + gchan->protocol = (u32)((u64)proto); > > A single cast "(uintptr_t)" should be sufficient. > Casing the pointer to u64 on 32-bit may trigger: > > warning: cast from pointer to integer of different size > [-Wpointer-to-int-cast] Good point, not compiling for 32-bit always ends up biting.. thanks Konrad
On Wed, Jul 30, 2025 at 01:32:58PM +0200, Geert Uytterhoeven wrote: > On Wed, 30 Jul 2025 at 11:35, Konrad Dybcio <konradybcio@kernel.org> wrote: ... > > + /* The protocol ID is in the teens range, simply ignore the higher bits */ > > + gchan->protocol = (u32)((u64)proto); > > A single cast "(uintptr_t)" should be sufficient. FWIW, this means (unsigned long) as Torvalds is quite against uintptr_t in the kernel. > Casing the pointer to u64 on 32-bit may trigger: > > warning: cast from pointer to integer of different size > [-Wpointer-to-int-cast] > > > return dma_get_slave_channel(&gchan->vc.chan); > > } -- With Best Regards, Andy Shevchenko
© 2016 - 2025 Red Hat, Inc.