diff mbox series

[3/3] arm64: dts: allwinner: h6: Add IOMMU

Message ID 54e22e25c2c13cb1b73cc7ecb645b5d62f325b63.1579696927.git-series.maxime@cerno.tech (mailing list archive)
State New, archived
Headers show
Series iommu: Add Allwinner H6 IOMMU driver | expand

Commit Message

Maxime Ripard Jan. 22, 2020, 12:44 p.m. UTC
Now that we have a driver for the IOMMU, let's start using it.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Jernej Škrabec Jan. 24, 2020, 8:54 p.m. UTC | #1
Hi!

Dne sreda, 22. januar 2020 ob 13:44:09 CET je Maxime Ripard napisal(a):
> Now that we have a driver for the IOMMU, let's start using it.
> 
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---
>  arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi index
> 29824081b43b..8608bcf1c52c 100644
> --- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> +++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> @@ -53,6 +53,7 @@
>  	de: display-engine {
>  		compatible = "allwinner,sun50i-h6-display-engine";
>  		allwinner,pipelines = <&mixer0>;
> +		iommus = <&iommu 0>;
>  		status = "disabled";
>  	};

Isn't iommu property of the mixer node? After all, mixer is the one which 
reads one or more framebuffers. Once second mixer is defined, would you put 
another iommu phandle here?

Best regards,
Jernej

> 
> @@ -122,6 +123,7 @@
>  				clock-names = "bus",
>  					      "mod";
>  				resets = <&display_clocks 
RST_MIXER0>;
> +				iommus = <&iommu 0>;
> 
>  				ports {
>  					#address-cells = <1>;
> @@ -345,6 +347,15 @@
>  			#interrupt-cells = <3>;
>  		};
> 
> +		iommu: iommu@30f0000 {
> +			compatible = "allwinner,sun50i-h6-iommu";
> +			reg = <0x030f0000 0x10000>;
> +			interrupts = <GIC_SPI 57 
IRQ_TYPE_LEVEL_HIGH>;
> +			clocks = <&ccu CLK_BUS_IOMMU>;
> +			resets = <&ccu RST_BUS_IOMMU>;
> +			#iommu-cells = <1>;
> +		};
> +
>  		mmc0: mmc@4020000 {
>  			compatible = "allwinner,sun50i-h6-mmc",
>  				     "allwinner,sun50i-a64-mmc";
Maxime Ripard Jan. 27, 2020, 2:23 p.m. UTC | #2
Hi Jernej,

On Fri, Jan 24, 2020 at 09:54:23PM +0100, Jernej Škrabec wrote:
> Dne sreda, 22. januar 2020 ob 13:44:09 CET je Maxime Ripard napisal(a):
> > Now that we have a driver for the IOMMU, let's start using it.
> >
> > Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> > ---
> >  arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi index
> > 29824081b43b..8608bcf1c52c 100644
> > --- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > +++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > @@ -53,6 +53,7 @@
> >  	de: display-engine {
> >  		compatible = "allwinner,sun50i-h6-display-engine";
> >  		allwinner,pipelines = <&mixer0>;
> > +		iommus = <&iommu 0>;
> >  		status = "disabled";
> >  	};
>
> Isn't iommu property of the mixer node? After all, mixer is the one which
> reads one or more framebuffers. Once second mixer is defined, would you put
> another iommu phandle here?

You're right. I added it during the early dev, and forgot to remove
it. Thanks!

Maxime
Jernej Škrabec Jan. 27, 2020, 7:04 p.m. UTC | #3
Hi!

Dne ponedeljek, 27. januar 2020 ob 15:23:39 CET je Maxime Ripard napisal(a):
> Hi Jernej,
> 
> On Fri, Jan 24, 2020 at 09:54:23PM +0100, Jernej Škrabec wrote:
> > Dne sreda, 22. januar 2020 ob 13:44:09 CET je Maxime Ripard napisal(a):
> > > Now that we have a driver for the IOMMU, let's start using it.
> > > 
> > > Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> > > ---
> > > 
> > >  arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 11 +++++++++++
> > >  1 file changed, 11 insertions(+)
> > > 
> > > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > > b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi index
> > > 29824081b43b..8608bcf1c52c 100644
> > > --- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > > +++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > > @@ -53,6 +53,7 @@
> > > 
> > >  	de: display-engine {
> > >  	
> > >  		compatible = "allwinner,sun50i-h6-display-engine";
> > >  		allwinner,pipelines = <&mixer0>;
> > > 
> > > +		iommus = <&iommu 0>;
> > > 
> > >  		status = "disabled";
> > >  	
> > >  	};
> > 
> > Isn't iommu property of the mixer node? After all, mixer is the one which
> > reads one or more framebuffers. Once second mixer is defined, would you
> > put
> > another iommu phandle here?
> 
> You're right. I added it during the early dev, and forgot to remove
> it. Thanks!

Remove it or move it? I guess enabling iommu support in each driver needs a 
bit more work than just referencing iommu node, right? At least in such case 
buffers don't need to be allocated by CMA, which sun4i-drm driver currently 
use.

I just take another look at BSP kernel and it seems that only one channel is 
used for whole display stack. That would mean that both mixers would have same 
iommu phandle, right? Confusingly enough, DE2 iommu channel seems to be for 
deinterlace core.

Best regards,
Jernej
Robin Murphy Jan. 28, 2020, 2:41 p.m. UTC | #4
On 27/01/2020 7:04 pm, Jernej Škrabec wrote:
> Hi!
> 
> Dne ponedeljek, 27. januar 2020 ob 15:23:39 CET je Maxime Ripard napisal(a):
>> Hi Jernej,
>>
>> On Fri, Jan 24, 2020 at 09:54:23PM +0100, Jernej Škrabec wrote:
>>> Dne sreda, 22. januar 2020 ob 13:44:09 CET je Maxime Ripard napisal(a):
>>>> Now that we have a driver for the IOMMU, let's start using it.
>>>>
>>>> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
>>>> ---
>>>>
>>>>   arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 11 +++++++++++
>>>>   1 file changed, 11 insertions(+)
>>>>
>>>> diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
>>>> b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi index
>>>> 29824081b43b..8608bcf1c52c 100644
>>>> --- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
>>>> +++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
>>>> @@ -53,6 +53,7 @@
>>>>
>>>>   	de: display-engine {
>>>>   	
>>>>   		compatible = "allwinner,sun50i-h6-display-engine";
>>>>   		allwinner,pipelines = <&mixer0>;
>>>>
>>>> +		iommus = <&iommu 0>;
>>>>
>>>>   		status = "disabled";
>>>>   	
>>>>   	};
>>>
>>> Isn't iommu property of the mixer node? After all, mixer is the one which
>>> reads one or more framebuffers. Once second mixer is defined, would you
>>> put
>>> another iommu phandle here?
>>
>> You're right. I added it during the early dev, and forgot to remove
>> it. Thanks!
> 
> Remove it or move it? I guess enabling iommu support in each driver needs a
> bit more work than just referencing iommu node, right? At least in such case
> buffers don't need to be allocated by CMA, which sun4i-drm driver currently
> use.

Note that the DRM "CMA" helpers are somewhat misnamed, since they're in 
fact based on the common DMA API, and thus transparent IOMMU-backed DMA 
ops will "just work" without the drivers having to care. Since all the 
display components behind the IOMMU will be in the same IOMMU group, 
they're guaranteed to always operate in the same address space as each 
other, so there should be no additional problems with buffer sharing 
(assuming the code doesn't have bugs that it's currently just getting 
away with).

> I just take another look at BSP kernel and it seems that only one channel is
> used for whole display stack. That would mean that both mixers would have same
> iommu phandle, right? Confusingly enough, DE2 iommu channel seems to be for
> deinterlace core.

That's also fine - as discussed on the driver thread there's no point 
trying to expose a distinction between devices at the API level, so the 
IDs are really only relevant to the driver internals touching the 
various enable registers (and even then only if you wanted to refine the 
current "just enable everything" approach).

Robin.
Maxime Ripard Jan. 29, 2020, 5:27 p.m. UTC | #5
Hi,

On Mon, Jan 27, 2020 at 08:04:02PM +0100, Jernej Škrabec wrote:
> Dne ponedeljek, 27. januar 2020 ob 15:23:39 CET je Maxime Ripard napisal(a):
> > Hi Jernej,
> >
> > On Fri, Jan 24, 2020 at 09:54:23PM +0100, Jernej Škrabec wrote:
> > > Dne sreda, 22. januar 2020 ob 13:44:09 CET je Maxime Ripard napisal(a):
> > > > Now that we have a driver for the IOMMU, let's start using it.
> > > >
> > > > Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> > > > ---
> > > >
> > > >  arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 11 +++++++++++
> > > >  1 file changed, 11 insertions(+)
> > > >
> > > > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > > > b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi index
> > > > 29824081b43b..8608bcf1c52c 100644
> > > > --- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > > > +++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > > > @@ -53,6 +53,7 @@
> > > >
> > > >  	de: display-engine {
> > > >
> > > >  		compatible = "allwinner,sun50i-h6-display-engine";
> > > >  		allwinner,pipelines = <&mixer0>;
> > > >
> > > > +		iommus = <&iommu 0>;
> > > >
> > > >  		status = "disabled";
> > > >
> > > >  	};
> > >
> > > Isn't iommu property of the mixer node? After all, mixer is the one which
> > > reads one or more framebuffers. Once second mixer is defined, would you
> > > put
> > > another iommu phandle here?
> >
> > You're right. I added it during the early dev, and forgot to remove
> > it. Thanks!
>
> Remove it or move it? I guess enabling iommu support in each driver needs a
> bit more work than just referencing iommu node, right? At least in such case
> buffers don't need to be allocated by CMA, which sun4i-drm driver currently
> use.
>
> I just take another look at BSP kernel and it seems that only one channel is
> used for whole display stack. That would mean that both mixers would have same
> iommu phandle, right? Confusingly enough, DE2 iommu channel seems to be for
> deinterlace core.

To add on Robin's answer, yeah, it looks like the display engine is
called DE (and I've checked that this is indeed the master 0), while
the deinterlace is called DE2 (and probably is the master 2).

Maxime
diff mbox series

Patch

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
index 29824081b43b..8608bcf1c52c 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
@@ -53,6 +53,7 @@ 
 	de: display-engine {
 		compatible = "allwinner,sun50i-h6-display-engine";
 		allwinner,pipelines = <&mixer0>;
+		iommus = <&iommu 0>;
 		status = "disabled";
 	};
 
@@ -122,6 +123,7 @@ 
 				clock-names = "bus",
 					      "mod";
 				resets = <&display_clocks RST_MIXER0>;
+				iommus = <&iommu 0>;
 
 				ports {
 					#address-cells = <1>;
@@ -345,6 +347,15 @@ 
 			#interrupt-cells = <3>;
 		};
 
+		iommu: iommu@30f0000 {
+			compatible = "allwinner,sun50i-h6-iommu";
+			reg = <0x030f0000 0x10000>;
+			interrupts = <GIC_SPI 57 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&ccu CLK_BUS_IOMMU>;
+			resets = <&ccu RST_BUS_IOMMU>;
+			#iommu-cells = <1>;
+		};
+
 		mmc0: mmc@4020000 {
 			compatible = "allwinner,sun50i-h6-mmc",
 				     "allwinner,sun50i-a64-mmc";