This patchset fixes bug people found on hikey960 when allocating DMA
channels to peripherals such as SPI. It fails because the channel is
reserved and not accessible by kernel.
Patch 1, 2 and 3 add support to reserved channels for K3 DMA. Patch 4
includes a removal of axi_config who controls DMA secure/non-secure
access permission but is actually set in early stage by bootloader.
Guodong Xu (1):
arm64: dts: hi3660: update property name hisilicon,dma-min-chan
Li Yu (3):
dt-bindings: k3dma: add optional property hisilicon,dma-min-chan
k3dma: add support to reserved minimum channels
k3dma: delete axi_config
Documentation/devicetree/bindings/dma/k3dma.txt | 6 ++++++
arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 2 +-
drivers/dma/k3dma.c | 16 ++++++++--------
3 files changed, 15 insertions(+), 9 deletions(-)
--
2.17.1
From: Li Yu <[email protected]>
On k3 series of SoC, DMA controller reserves some channels for
other on-chip coprocessors. By reading property "hisilicon,dma-min-chan"
from dts node, kernel will not use these reserved channels.
As an example, on Hi3660, channel 0 is reserved for lpm3.
Refer to Documentation/devicetree/bindings/dma/k3dma.txt for more
information.
Signed-off-by: Li Yu <[email protected]>
Signed-off-by: Guodong Xu <[email protected]>
---
drivers/dma/k3dma.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c
index fa31cccbe04f..33efb541acb2 100644
--- a/drivers/dma/k3dma.c
+++ b/drivers/dma/k3dma.c
@@ -113,6 +113,7 @@ struct k3_dma_dev {
struct dma_pool *pool;
u32 dma_channels;
u32 dma_requests;
+ u32 dma_min_chan;
unsigned int irq;
};
@@ -309,7 +310,7 @@ static void k3_dma_tasklet(unsigned long arg)
/* check new channel request in d->chan_pending */
spin_lock_irq(&d->lock);
- for (pch = 0; pch < d->dma_channels; pch++) {
+ for (pch = d->dma_min_chan; pch < d->dma_channels; pch++) {
p = &d->phy[pch];
if (p->vchan == NULL && !list_empty(&d->chan_pending)) {
@@ -326,7 +327,7 @@ static void k3_dma_tasklet(unsigned long arg)
}
spin_unlock_irq(&d->lock);
- for (pch = 0; pch < d->dma_channels; pch++) {
+ for (pch = d->dma_min_chan; pch < d->dma_channels; pch++) {
if (pch_alloc & (1 << pch)) {
p = &d->phy[pch];
c = p->vchan;
@@ -825,6 +826,8 @@ static int k3_dma_probe(struct platform_device *op)
"dma-channels", &d->dma_channels);
of_property_read_u32((&op->dev)->of_node,
"dma-requests", &d->dma_requests);
+ of_property_read_u32((&op->dev)->of_node,
+ "hisilicon,dma-min-chan", &d->dma_min_chan);
}
d->clk = devm_clk_get(&op->dev, NULL);
@@ -848,12 +851,12 @@ static int k3_dma_probe(struct platform_device *op)
return -ENOMEM;
/* init phy channel */
- d->phy = devm_kcalloc(&op->dev,
- d->dma_channels, sizeof(struct k3_dma_phy), GFP_KERNEL);
+ d->phy = devm_kcalloc(&op->dev, (d->dma_channels - d->dma_min_chan),
+ sizeof(struct k3_dma_phy), GFP_KERNEL);
if (d->phy == NULL)
return -ENOMEM;
- for (i = 0; i < d->dma_channels; i++) {
+ for (i = d->dma_min_chan; i < d->dma_channels; i++) {
struct k3_dma_phy *p = &d->phy[i];
p->idx = i;
--
2.17.1
Update property name dma-min-chan to "hisilicon,dma-min-chan"
Signed-off-by: Guodong Xu <[email protected]>
---
arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
index 8d477dcbfa58..0cec26976eb6 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
@@ -537,7 +537,7 @@
#dma-cells = <1>;
dma-channels = <16>;
dma-requests = <32>;
- dma-min-chan = <1>;
+ hisilicon,dma-min-chan = <1>;
interrupts = <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&crg_ctrl HI3660_CLK_GATE_DMAC>;
dma-no-cci;
--
2.17.1
From: Li Yu <[email protected]>
Axi_config controls whether DMA resources can be accessed in non-secure
mode, such as linux kernel. The setting is actually done in
bootloader stage.
This patch removes axi_config from k3dma driver.
Signed-off-by: Li Yu <[email protected]>
Signed-off-by: Guodong Xu <[email protected]>
---
drivers/dma/k3dma.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c
index 33efb541acb2..4542e703ec85 100644
--- a/drivers/dma/k3dma.c
+++ b/drivers/dma/k3dma.c
@@ -52,8 +52,6 @@
#define CX_SRC 0x814
#define CX_DST 0x818
#define CX_CFG 0x81c
-#define AXI_CFG 0x820
-#define AXI_CFG_DEFAULT 0x201201
#define CX_LLI_CHAIN_EN 0x2
#define CX_CFG_EN 0x1
@@ -158,7 +156,6 @@ static void k3_dma_set_desc(struct k3_dma_phy *phy, struct k3_desc_hw *hw)
writel_relaxed(hw->count, phy->base + CX_CNT0);
writel_relaxed(hw->saddr, phy->base + CX_SRC);
writel_relaxed(hw->daddr, phy->base + CX_DST);
- writel_relaxed(AXI_CFG_DEFAULT, phy->base + AXI_CFG);
writel_relaxed(hw->config, phy->base + CX_CFG);
}
--
2.17.1
From: Li Yu <[email protected]>
Add optional property hisilicon,dma-min-chan for k3dma.
Signed-off-by: Li Yu <[email protected]>
Signed-off-by: Guodong Xu <[email protected]>
---
Documentation/devicetree/bindings/dma/k3dma.txt | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Documentation/devicetree/bindings/dma/k3dma.txt b/Documentation/devicetree/bindings/dma/k3dma.txt
index 4945aeac4dc4..f34202a80f3c 100644
--- a/Documentation/devicetree/bindings/dma/k3dma.txt
+++ b/Documentation/devicetree/bindings/dma/k3dma.txt
@@ -12,6 +12,11 @@ Required properties:
have specific request line
- clocks: clock required
+Optional properties:
+- hisilicon,dma-min-chan: the minimum DMA channel number which is usable
+ Default value is 0, but in some platform it is
+ configured 1, like in hi3660 platform
+
Example:
Controller:
@@ -21,6 +26,7 @@ Controller:
#dma-cells = <1>;
dma-channels = <16>;
dma-requests = <27>;
+ hisilicon,dma-min-chan = <1>;
interrupts = <0 12 4>;
clocks = <&pclk>;
};
--
2.17.1
On 06-07-18, 11:55, Guodong Xu wrote:
> From: Li Yu <[email protected]>
>
> Add optional property hisilicon,dma-min-chan for k3dma.
>
> Signed-off-by: Li Yu <[email protected]>
> Signed-off-by: Guodong Xu <[email protected]>
> ---
> Documentation/devicetree/bindings/dma/k3dma.txt | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/dma/k3dma.txt b/Documentation/devicetree/bindings/dma/k3dma.txt
> index 4945aeac4dc4..f34202a80f3c 100644
> --- a/Documentation/devicetree/bindings/dma/k3dma.txt
> +++ b/Documentation/devicetree/bindings/dma/k3dma.txt
> @@ -12,6 +12,11 @@ Required properties:
> have specific request line
> - clocks: clock required
>
> +Optional properties:
> +- hisilicon,dma-min-chan: the minimum DMA channel number which is usable
> + Default value is 0, but in some platform it is
> + configured 1, like in hi3660 platform
> +
> Example:
>
> Controller:
> @@ -21,6 +26,7 @@ Controller:
> #dma-cells = <1>;
> dma-channels = <16>;
> dma-requests = <27>;
> + hisilicon,dma-min-chan = <1>;
Am still expecting this to be a mask
--
~Vinod
On Mon, Jul 09, 2018 at 04:04:38PM +0530, Vinod wrote:
> On 06-07-18, 11:55, Guodong Xu wrote:
> > From: Li Yu <[email protected]>
> >
> > Add optional property hisilicon,dma-min-chan for k3dma.
> >
> > Signed-off-by: Li Yu <[email protected]>
> > Signed-off-by: Guodong Xu <[email protected]>
> > ---
> > Documentation/devicetree/bindings/dma/k3dma.txt | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/dma/k3dma.txt b/Documentation/devicetree/bindings/dma/k3dma.txt
> > index 4945aeac4dc4..f34202a80f3c 100644
> > --- a/Documentation/devicetree/bindings/dma/k3dma.txt
> > +++ b/Documentation/devicetree/bindings/dma/k3dma.txt
> > @@ -12,6 +12,11 @@ Required properties:
> > have specific request line
> > - clocks: clock required
> >
> > +Optional properties:
> > +- hisilicon,dma-min-chan: the minimum DMA channel number which is usable
> > + Default value is 0, but in some platform it is
> > + configured 1, like in hi3660 platform
> > +
> > Example:
> >
> > Controller:
> > @@ -21,6 +26,7 @@ Controller:
> > #dma-cells = <1>;
> > dma-channels = <16>;
> > dma-requests = <27>;
> > + hisilicon,dma-min-chan = <1>;
>
> Am still expecting this to be a mask
If so calling it 'min' doesn't make sense. And a mask should have 'mask'
in the name.
Rob