Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 2/9] crypto: Add Allwinner sun8i-ce Crypto Engine
From: Corentin Labbe @ 2019-09-09 13:19 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: mark.rutland, devicetree, herbert, linux-sunxi, linux,
	linux-kernel, wens, robh+dt, linux-crypto, davem,
	linux-arm-kernel
In-Reply-To: <20190909113837.vrnqdfgzhsiymfpm@flea>

On Mon, Sep 09, 2019 at 01:38:37PM +0200, Maxime Ripard wrote:
> On Sat, Sep 07, 2019 at 09:04:08PM +0200, Corentin Labbe wrote:
> > > Also, I'm not sure what is the point of having the clocks names be
> > > parameters there as well. It's constant across all the compatibles,
> > > the only thing that isn't is the number of clocks and the module clock
> > > rate. It's what you should have in there.
> >
> > Since the datasheet give some max frequency, I think I will add a
> > max_freq and add a check to verify if the clock is in the right
> > range
> 
> It's a bit pointless. What are you going to do if it's not correct?
> What are you trying to fix / report with this?

I thinked to print a warning.
If someone want to play with overclocking for example, the driver should said that probably some result could be invalid.

> 
> > > > +		}
> > > > +};
> > > > +
> > > > +static const struct ce_variant ce_h5_variant = {
> > > > +	.alg_cipher = { CE_ID_NOTSUPP, CE_ALG_AES, CE_ALG_DES, CE_ALG_3DES,
> > > > +		CE_ID_NOTSUPP,
> > > > +	},
> > > > +	.op_mode = { CE_ID_NOTSUPP, CE_OP_ECB, CE_OP_CBC
> > > > +	},
> > > > +	.intreg = CE_ISR,
> > > > +	.maxflow = 4,
> > > > +	.ce_clks = {
> > > > +		{ "ahb", 200000000 },
> > > > +		{ "mod", 300000000 },
> > > > +		}
> > > > +};
> > > > +
> > > > +static const struct ce_variant ce_h6_variant = {
> > > > +	.alg_cipher = { CE_ID_NOTSUPP, CE_ALG_AES, CE_ALG_DES, CE_ALG_3DES,
> > > > +		CE_ALG_RAES,
> > > > +	},
> > > > +	.op_mode = { CE_ID_NOTSUPP, CE_OP_ECB, CE_OP_CBC
> > > > +	},
> > > > +	.model = CE_v2,
> > >
> > > Can't that be derived from the version register and / or the
> > > compatible? This seems to be redundant with each.
> >
> > I could use the compatible, but I want to avoid a string comparison
> > on each request.
> 
> Well, this is specifically what this structure is for then, right? So
> instead of having the model, just add the information that you want
> there.
> 

ok, I will change to a "bool all_size_in_bytes"

> > > > +int sun8i_ce_get_engine_number(struct sun8i_ce_dev *ce)
> > > > +{
> > > > +	return atomic_inc_return(&ce->flow) % ce->variant->maxflow;
> > > > +}
> > >
> > > I'm not sure what this is supposed to be doing, but that mod there
> > > seems pretty dangerous.
> > >
> > > ...
> >
> > This mod do a round robin on each channel.
> > I dont see why it is dangerous.
> 
> Well, you're using the atomic API here which is most commonly used for
> refcounting, while you're using a mod.
> 
> Plus, while the increment is atomic, the modulo isn't, so you can end
> up in a case where you would be preempted between the
> atomic_inc_return and the mod, which is dangerous.
> 
> Again, I'm not sure what this function is doing (which is also a
> problem in itself). I guess you should just make it clearer what it
> does, and then we can discuss it properly.

Each request need to be assigned to a channel.
Each channel are identified by a number from 1 to 4.

So this function return the channel to use, 1 then 2 then 3 then 4 then 1...
Note that this is uncritical. If, due to anything, two request are assigned to the same channel, nothing will break.

> 
> > > > +			err = clk_set_rate(ce->ceclks[i], ce->variant->ce_clks[i].freq);
> > > > +			if (err)
> > > > +				dev_err(&pdev->dev, "Fail to set %s clk speed to %lu\n",
> > > > +					ce->variant->ce_clks[i].name,
> > > > +					ce->variant->ce_clks[i].freq);
> > > > +		} else {
> > > > +			dev_info(&pdev->dev, "%s run at %lu\n",
> > > > +				 ce->variant->ce_clks[i].name, cr);
> > >
> > > Ditto.
> > >
> > > > +		}
> > > > +		err = clk_prepare_enable(ce->ceclks[i]);
> > >
> > > Do you really need this right now though?
> >
> > Not sure to understand, why I shouldnt do it now ?
> > Does it is related to your pm_runtime remark below ?
> >
> > My feeling was to submit the driver without PM and convert it after.
> 
> runtime_pm would be pretty cheap to add though judging by what you're
> doing there.
> 

I will try to add runtime_pm

> > > > +		if (err) {
> > > > +			dev_err(&pdev->dev, "Cannot prepare_enable %s\n",
> > > > +				ce->variant->ce_clks[i].name);
> > > > +			return err;
> > > > +		}
> > > > +	}
> > > > +
> > > > +	/* Get Non Secure IRQ */
> > > > +	irq = platform_get_irq(pdev, 0);
> > > > +	if (irq < 0) {
> > > > +		dev_err(ce->dev, "Cannot get NS IRQ\n");
> > > > +		return irq;
> > > > +	}
> > > > +
> > > > +	err = devm_request_irq(&pdev->dev, irq, ce_irq_handler, 0,
> > > > +			       "sun8i-ce-ns", ce);
> > > > +	if (err < 0) {
> > > > +		dev_err(ce->dev, "Cannot request NS IRQ\n");
> > > > +		return err;
> > > > +	}
> > > > +
> > > > +	ce->reset = devm_reset_control_get_optional(&pdev->dev, "ahb");
> > > > +	if (IS_ERR(ce->reset)) {
> > > > +		if (PTR_ERR(ce->reset) == -EPROBE_DEFER)
> > > > +			return PTR_ERR(ce->reset);
> > > > +		dev_info(&pdev->dev, "No reset control found\n");
> > >
> > > It's not optional though.
> >
> > I dont understand why.
> 
> On all the SoCs, you need that reset line to be deasserted, otherwise
> the IP (and therefore the driver) will be non-functional. It's not an
> option to run without it.

Currently all the SoC have a reset, but nothing prevent a new SoC with CE without reset.
Anyway, I will made the reset mandatory for the moment.

> 
> > > > +		ce->reset = NULL;
> > > > +	}
> > > > +
> > > > +	err = reset_control_deassert(ce->reset);
> > > > +	if (err) {
> > > > +		dev_err(&pdev->dev, "Cannot deassert reset control\n");
> > > > +		goto error_clk;
> > > > +	}
> > >
> > > Again, you don't really need this at this moment. Using runtime_pm
> > > would make more sense.
> > >
> > > > +	v = readl(ce->base + CE_CTR);
> > > > +	v >>= 16;
> > > > +	v &= 0x07;
> > >
> > > This should be in a define
> > >
> >
> > Will fix.
> >
> > > > +	dev_info(&pdev->dev, "CE_NS Die ID %x\n", v);
> > >
> > > And if that really makes sense to print it, the error message should
> > > be made less cryptic.
> > >
> >
> > Will fix.
> >
> > > > +
> > > > +	ce->dev = &pdev->dev;
> > > > +	platform_set_drvdata(pdev, ce);
> > > > +
> > > > +	mutex_init(&ce->mlock);
> > > > +
> > > > +	ce->chanlist = devm_kcalloc(ce->dev, ce->variant->maxflow,
> > > > +				    sizeof(struct sun8i_ce_flow), GFP_KERNEL);
> > > > +	if (!ce->chanlist) {
> > > > +		err = -ENOMEM;
> > > > +		goto error_flow;
> > > > +	}
> > > > +
> > > > +	for (i = 0; i < ce->variant->maxflow; i++) {
> > > > +		init_completion(&ce->chanlist[i].complete);
> > > > +		mutex_init(&ce->chanlist[i].lock);
> > > > +
> > > > +		ce->chanlist[i].engine = crypto_engine_alloc_init(ce->dev, true);
> > > > +		if (!ce->chanlist[i].engine) {
> > > > +			dev_err(ce->dev, "Cannot allocate engine\n");
> > > > +			i--;
> > > > +			goto error_engine;
> > > > +		}
> > > > +		err = crypto_engine_start(ce->chanlist[i].engine);
> > > > +		if (err) {
> > > > +			dev_err(ce->dev, "Cannot start engine\n");
> > > > +			goto error_engine;
> > > > +		}
> > > > +		ce->chanlist[i].tl = dma_alloc_coherent(ce->dev,
> > > > +							sizeof(struct ce_task),
> > > > +							&ce->chanlist[i].t_phy,
> > > > +							GFP_KERNEL);
> > > > +		if (!ce->chanlist[i].tl) {
> > > > +			dev_err(ce->dev, "Cannot get DMA memory for task %d\n",
> > > > +				i);
> > > > +			err = -ENOMEM;
> > > > +			goto error_engine;
> > > > +		}
> > > > +	}
> > >
> > > All this initialization should be done before calling
> > > request_irq. You're using some of those fields in your handler.
> >
> > No interrupt could fire, since algorithms are still not registred.
> 
> That's not true. Spurious interrupts are a thing, the engine could
> have been left in a weird state by the bootloader / kexec / reboot
> with some pending interrupts, etc.
> 
> You have registered that handler already, you should expect it to be
> called at any point in time.
> 

Ok will fix.

Thanks for your review.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply

* Re: [PATCH 3/4] ARM: dts: omap3: bulk convert compatible to be explicitly ti,omap3430 or ti,omap3630 or ti,am3517
From: Adam Ford @ 2019-09-09 13:26 UTC (permalink / raw)
  To: H. Nikolaus Schaller
  Cc: Mark Rutland, devicetree, Discussions about the Letux Kernel,
	linux-pm, Tony Lindgren, Viresh Kumar, Rafael J. Wysocki,
	Linux Kernel Mailing List, Enric Balletbo i Serra, Rob Herring,
	André Roth, Benoît Cousson, kernel, Teresa Remmet,
	Javier Martinez Canillas, Linux-OMAP, arm-soc, Roger Quadros
In-Reply-To: <8f002b26667b91b0d13771e5a17535075e82b343.1567878413.git.hns@goldelico.com>

On Sat, Sep 7, 2019 at 12:47 PM H. Nikolaus Schaller <hns@goldelico.com> wrote:
>
> For the ti-cpufreq driver we need a clear separation between omap34 and omap36 families
> since they have different silicon revisions and efuses.
>
> So far ti,omap3630/ti,omap36xx is just an additional flag to ti,omap3 while omap34 has no
> required entry.
>
> Therefore we can not match omap34 boards properly.
>
> This needs to add ti,omap3430 and ti,omap3630 where it is missing.
>
> We also clean up some instances of missing ti,am3517 so that we can rely on
> seeing either one of:
>
> ti,am3517
> ti,omap3430
> ti,omap3630
>
> in addition to ti,omap3.
>
> We leave ti,omap34xx and ti,omap36xx untouched for compatibility.
>
> The script to do the conversion is:
>
> manually fix am3517_mt_ventoux.dts
> find arch/arm/boot/dts -name '*.dts*' -exec fgrep -q '"ti,omap34xx"' {} \; ! -exec fgrep -q '"ti,omap3430"' {} \; -exec sed -i '' 's/"ti,omap34xx"/"ti,omap3430", "ti,omap34xx"/' {} \;
> find arch/arm/boot/dts -name '*.dts*' -exec fgrep -q '"ti,omap36xx"' {} \; ! -exec fgrep -q '"ti,omap3630"' {} \; -exec sed -i '' 's/"ti,omap36xx"/"ti,omap3630", "ti,omap36xx"/' {} \;
> find arch/arm/boot/dts \( -name 'omap*.dts*' -o -name 'logic*.dts*' \) -exec fgrep -q '"ti,omap3"' {} \; ! -exec fgrep -q '"ti,omap3630"' {} \; ! -exec fgrep -q '"ti,omap36xx"' {} \; ! -exec fgrep -q '"ti,am3517"' {} \; ! -exec fgrep -q '"ti,omap34xx"' {} \; ! -exec fgrep -q '"ti,omap3430"' {} \; -exec sed -i '' 's/"ti,omap3"/"ti,omap3430", "ti,omap3"/' {} \;
>
> So if your out-of-tree omap3 board does not show any OPPs, please check
> the compatibility entry and update if needed.
>
> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
> Acked-by: Tony Lindgren <tony@atomide.com>
> ---
>  arch/arm/boot/dts/am3517_mt_ventoux.dts            | 2 +-
>  arch/arm/boot/dts/logicpd-som-lv-35xx-devkit.dts   | 2 +-
>  arch/arm/boot/dts/logicpd-torpedo-35xx-devkit.dts  | 2 +-
>  arch/arm/boot/dts/omap3-beagle-xm.dts              | 2 +-
>  arch/arm/boot/dts/omap3-beagle.dts                 | 2 +-
>  arch/arm/boot/dts/omap3-cm-t3530.dts               | 2 +-
>  arch/arm/boot/dts/omap3-cm-t3730.dts               | 2 +-
>  arch/arm/boot/dts/omap3-devkit8000-lcd43.dts       | 2 +-
>  arch/arm/boot/dts/omap3-devkit8000-lcd70.dts       | 2 +-
>  arch/arm/boot/dts/omap3-devkit8000.dts             | 2 +-
>  arch/arm/boot/dts/omap3-gta04.dtsi                 | 2 +-
>  arch/arm/boot/dts/omap3-ha-lcd.dts                 | 2 +-
>  arch/arm/boot/dts/omap3-ha.dts                     | 2 +-
>  arch/arm/boot/dts/omap3-igep0020-rev-f.dts         | 2 +-
>  arch/arm/boot/dts/omap3-igep0020.dts               | 2 +-
>  arch/arm/boot/dts/omap3-igep0030-rev-g.dts         | 2 +-
>  arch/arm/boot/dts/omap3-igep0030.dts               | 2 +-
>  arch/arm/boot/dts/omap3-ldp.dts                    | 2 +-
>  arch/arm/boot/dts/omap3-lilly-a83x.dtsi            | 2 +-
>  arch/arm/boot/dts/omap3-lilly-dbb056.dts           | 2 +-
>  arch/arm/boot/dts/omap3-n9.dts                     | 2 +-
>  arch/arm/boot/dts/omap3-n950.dts                   | 2 +-
>  arch/arm/boot/dts/omap3-overo-storm-alto35.dts     | 2 +-
>  arch/arm/boot/dts/omap3-overo-storm-chestnut43.dts | 2 +-
>  arch/arm/boot/dts/omap3-overo-storm-gallop43.dts   | 2 +-
>  arch/arm/boot/dts/omap3-overo-storm-palo35.dts     | 2 +-
>  arch/arm/boot/dts/omap3-overo-storm-palo43.dts     | 2 +-
>  arch/arm/boot/dts/omap3-overo-storm-summit.dts     | 2 +-
>  arch/arm/boot/dts/omap3-overo-storm-tobi.dts       | 2 +-
>  arch/arm/boot/dts/omap3-overo-storm-tobiduo.dts    | 2 +-
>  arch/arm/boot/dts/omap3-pandora-1ghz.dts           | 2 +-
>  arch/arm/boot/dts/omap3-sbc-t3530.dts              | 2 +-
>  arch/arm/boot/dts/omap3-sbc-t3730.dts              | 2 +-
>  arch/arm/boot/dts/omap3-sniper.dts                 | 2 +-
>  arch/arm/boot/dts/omap3-thunder.dts                | 2 +-
>  arch/arm/boot/dts/omap3-zoom3.dts                  | 2 +-
>  arch/arm/boot/dts/omap3430-sdp.dts                 | 2 +-
>  37 files changed, 37 insertions(+), 37 deletions(-)
>
> diff --git a/arch/arm/boot/dts/am3517_mt_ventoux.dts b/arch/arm/boot/dts/am3517_mt_ventoux.dts
> index e507e4ae0d88..e7d7124a34ba 100644
> --- a/arch/arm/boot/dts/am3517_mt_ventoux.dts
> +++ b/arch/arm/boot/dts/am3517_mt_ventoux.dts
> @@ -8,7 +8,7 @@
>
>  / {
>         model = "TeeJet Mt.Ventoux";
> -       compatible = "teejet,mt_ventoux", "ti,omap3";
> +       compatible = "teejet,mt_ventoux", "ti,am3517", "ti,omap3";
>
>         memory@80000000 {
>                 device_type = "memory";
> diff --git a/arch/arm/boot/dts/logicpd-som-lv-35xx-devkit.dts b/arch/arm/boot/dts/logicpd-som-lv-35xx-devkit.dts
> index f7a841a28865..2a0a98fe67f0 100644
> --- a/arch/arm/boot/dts/logicpd-som-lv-35xx-devkit.dts
> +++ b/arch/arm/boot/dts/logicpd-som-lv-35xx-devkit.dts
> @@ -9,5 +9,5 @@
>
>  / {
>         model = "LogicPD Zoom OMAP35xx SOM-LV Development Kit";
> -       compatible = "logicpd,dm3730-som-lv-devkit", "ti,omap3";
> +       compatible = "logicpd,dm3730-som-lv-devkit", "ti,omap3430", "ti,omap3";
>  };
> diff --git a/arch/arm/boot/dts/logicpd-torpedo-35xx-devkit.dts b/arch/arm/boot/dts/logicpd-torpedo-35xx-devkit.dts
> index 7675bc3fa868..57bae2aa910e 100644
> --- a/arch/arm/boot/dts/logicpd-torpedo-35xx-devkit.dts
> +++ b/arch/arm/boot/dts/logicpd-torpedo-35xx-devkit.dts
> @@ -9,5 +9,5 @@
>
>  / {
>         model = "LogicPD Zoom OMAP35xx Torpedo Development Kit";
> -       compatible = "logicpd,dm3730-torpedo-devkit", "ti,omap3";
> +       compatible = "logicpd,dm3730-torpedo-devkit", "ti,omap3430", "ti,omap3";
>  };

For both Logic PD OMAP35 kits,

Reviewed-by: Adam Ford <aford173@gmail.com>


> diff --git a/arch/arm/boot/dts/omap3-beagle-xm.dts b/arch/arm/boot/dts/omap3-beagle-xm.dts
> index 1aa99fc1487a..125ed933ca75 100644
> --- a/arch/arm/boot/dts/omap3-beagle-xm.dts
> +++ b/arch/arm/boot/dts/omap3-beagle-xm.dts
> @@ -8,7 +8,7 @@
>
>  / {
>         model = "TI OMAP3 BeagleBoard xM";
> -       compatible = "ti,omap3-beagle-xm", "ti,omap36xx", "ti,omap3";
> +       compatible = "ti,omap3-beagle-xm", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>
>         cpus {
>                 cpu@0 {
> diff --git a/arch/arm/boot/dts/omap3-beagle.dts b/arch/arm/boot/dts/omap3-beagle.dts
> index e3df3c166902..4ed3f93f5841 100644
> --- a/arch/arm/boot/dts/omap3-beagle.dts
> +++ b/arch/arm/boot/dts/omap3-beagle.dts
> @@ -8,7 +8,7 @@
>
>  / {
>         model = "TI OMAP3 BeagleBoard";
> -       compatible = "ti,omap3-beagle", "ti,omap3";
> +       compatible = "ti,omap3-beagle", "ti,omap3430", "ti,omap3";
>
>         cpus {
>                 cpu@0 {
> diff --git a/arch/arm/boot/dts/omap3-cm-t3530.dts b/arch/arm/boot/dts/omap3-cm-t3530.dts
> index 76e52c78cbb4..32dbaeaed147 100644
> --- a/arch/arm/boot/dts/omap3-cm-t3530.dts
> +++ b/arch/arm/boot/dts/omap3-cm-t3530.dts
> @@ -9,7 +9,7 @@
>
>  / {
>         model = "CompuLab CM-T3530";
> -       compatible = "compulab,omap3-cm-t3530", "ti,omap34xx", "ti,omap3";
> +       compatible = "compulab,omap3-cm-t3530", "ti,omap3430", "ti,omap34xx", "ti,omap3";
>
>         /* Regulator to trigger the reset signal of the Wifi module */
>         mmc2_sdio_reset: regulator-mmc2-sdio-reset {
> diff --git a/arch/arm/boot/dts/omap3-cm-t3730.dts b/arch/arm/boot/dts/omap3-cm-t3730.dts
> index 6e944dfa0f3d..683819bf0915 100644
> --- a/arch/arm/boot/dts/omap3-cm-t3730.dts
> +++ b/arch/arm/boot/dts/omap3-cm-t3730.dts
> @@ -9,7 +9,7 @@
>
>  / {
>         model = "CompuLab CM-T3730";
> -       compatible = "compulab,omap3-cm-t3730", "ti,omap36xx", "ti,omap3";
> +       compatible = "compulab,omap3-cm-t3730", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>
>         wl12xx_vmmc2: wl12xx_vmmc2 {
>                 compatible = "regulator-fixed";
> diff --git a/arch/arm/boot/dts/omap3-devkit8000-lcd43.dts b/arch/arm/boot/dts/omap3-devkit8000-lcd43.dts
> index a80fc60bc773..afed85078ad8 100644
> --- a/arch/arm/boot/dts/omap3-devkit8000-lcd43.dts
> +++ b/arch/arm/boot/dts/omap3-devkit8000-lcd43.dts
> @@ -11,7 +11,7 @@
>  #include "omap3-devkit8000-lcd-common.dtsi"
>  / {
>         model = "TimLL OMAP3 Devkit8000 with 4.3'' LCD panel";
> -       compatible = "timll,omap3-devkit8000", "ti,omap3";
> +       compatible = "timll,omap3-devkit8000", "ti,omap3430", "ti,omap3";
>
>         lcd0: display {
>                 panel-timing {
> diff --git a/arch/arm/boot/dts/omap3-devkit8000-lcd70.dts b/arch/arm/boot/dts/omap3-devkit8000-lcd70.dts
> index 0753776071f8..07c51a105c0d 100644
> --- a/arch/arm/boot/dts/omap3-devkit8000-lcd70.dts
> +++ b/arch/arm/boot/dts/omap3-devkit8000-lcd70.dts
> @@ -11,7 +11,7 @@
>  #include "omap3-devkit8000-lcd-common.dtsi"
>  / {
>         model = "TimLL OMAP3 Devkit8000 with 7.0'' LCD panel";
> -       compatible = "timll,omap3-devkit8000", "ti,omap3";
> +       compatible = "timll,omap3-devkit8000", "ti,omap3430", "ti,omap3";
>
>         lcd0: display {
>                 panel-timing {
> diff --git a/arch/arm/boot/dts/omap3-devkit8000.dts b/arch/arm/boot/dts/omap3-devkit8000.dts
> index faafc48d8f61..162d0726b008 100644
> --- a/arch/arm/boot/dts/omap3-devkit8000.dts
> +++ b/arch/arm/boot/dts/omap3-devkit8000.dts
> @@ -7,7 +7,7 @@
>  #include "omap3-devkit8000-common.dtsi"
>  / {
>         model = "TimLL OMAP3 Devkit8000";
> -       compatible = "timll,omap3-devkit8000", "ti,omap3";
> +       compatible = "timll,omap3-devkit8000", "ti,omap3430", "ti,omap3";
>
>         aliases {
>                 display1 = &dvi0;
> diff --git a/arch/arm/boot/dts/omap3-gta04.dtsi b/arch/arm/boot/dts/omap3-gta04.dtsi
> index b295f6fad2a5..25b6ed9203e1 100644
> --- a/arch/arm/boot/dts/omap3-gta04.dtsi
> +++ b/arch/arm/boot/dts/omap3-gta04.dtsi
> @@ -11,7 +11,7 @@
>
>  / {
>         model = "OMAP3 GTA04";
> -       compatible = "ti,omap3-gta04", "ti,omap36xx", "ti,omap3";
> +       compatible = "ti,omap3-gta04", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>
>         cpus {
>                 cpu@0 {
> diff --git a/arch/arm/boot/dts/omap3-ha-lcd.dts b/arch/arm/boot/dts/omap3-ha-lcd.dts
> index badb9b3c8897..c9ecbc45c8e2 100644
> --- a/arch/arm/boot/dts/omap3-ha-lcd.dts
> +++ b/arch/arm/boot/dts/omap3-ha-lcd.dts
> @@ -8,7 +8,7 @@
>
>  / {
>         model = "TI OMAP3 HEAD acoustics LCD-baseboard with TAO3530 SOM";
> -       compatible = "headacoustics,omap3-ha-lcd", "technexion,omap3-tao3530", "ti,omap34xx", "ti,omap3";
> +       compatible = "headacoustics,omap3-ha-lcd", "technexion,omap3-tao3530", "ti,omap3430", "ti,omap34xx", "ti,omap3";
>  };
>
>  &omap3_pmx_core {
> diff --git a/arch/arm/boot/dts/omap3-ha.dts b/arch/arm/boot/dts/omap3-ha.dts
> index a5365252bfbe..35c4e15abeb7 100644
> --- a/arch/arm/boot/dts/omap3-ha.dts
> +++ b/arch/arm/boot/dts/omap3-ha.dts
> @@ -8,7 +8,7 @@
>
>  / {
>         model = "TI OMAP3 HEAD acoustics baseboard with TAO3530 SOM";
> -       compatible = "headacoustics,omap3-ha", "technexion,omap3-tao3530", "ti,omap34xx", "ti,omap3";
> +       compatible = "headacoustics,omap3-ha", "technexion,omap3-tao3530", "ti,omap3430", "ti,omap34xx", "ti,omap3";
>  };
>
>  &omap3_pmx_core {
> diff --git a/arch/arm/boot/dts/omap3-igep0020-rev-f.dts b/arch/arm/boot/dts/omap3-igep0020-rev-f.dts
> index 03dcd05fb8a0..d134ce1cffc0 100644
> --- a/arch/arm/boot/dts/omap3-igep0020-rev-f.dts
> +++ b/arch/arm/boot/dts/omap3-igep0020-rev-f.dts
> @@ -10,7 +10,7 @@
>
>  / {
>         model = "IGEPv2 Rev. F (TI OMAP AM/DM37x)";
> -       compatible = "isee,omap3-igep0020-rev-f", "ti,omap36xx", "ti,omap3";
> +       compatible = "isee,omap3-igep0020-rev-f", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>
>         /* Regulator to trigger the WL_EN signal of the Wifi module */
>         lbep5clwmc_wlen: regulator-lbep5clwmc-wlen {
> diff --git a/arch/arm/boot/dts/omap3-igep0020.dts b/arch/arm/boot/dts/omap3-igep0020.dts
> index 6d0519e3dfd0..e341535a7162 100644
> --- a/arch/arm/boot/dts/omap3-igep0020.dts
> +++ b/arch/arm/boot/dts/omap3-igep0020.dts
> @@ -10,7 +10,7 @@
>
>  / {
>         model = "IGEPv2 Rev. C (TI OMAP AM/DM37x)";
> -       compatible = "isee,omap3-igep0020", "ti,omap36xx", "ti,omap3";
> +       compatible = "isee,omap3-igep0020", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>
>         vmmcsdio_fixed: fixedregulator-mmcsdio {
>                 compatible = "regulator-fixed";
> diff --git a/arch/arm/boot/dts/omap3-igep0030-rev-g.dts b/arch/arm/boot/dts/omap3-igep0030-rev-g.dts
> index 060acd1e803a..9ca1d0f61964 100644
> --- a/arch/arm/boot/dts/omap3-igep0030-rev-g.dts
> +++ b/arch/arm/boot/dts/omap3-igep0030-rev-g.dts
> @@ -10,7 +10,7 @@
>
>  / {
>         model = "IGEP COM MODULE Rev. G (TI OMAP AM/DM37x)";
> -       compatible = "isee,omap3-igep0030-rev-g", "ti,omap36xx", "ti,omap3";
> +       compatible = "isee,omap3-igep0030-rev-g", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>
>         /* Regulator to trigger the WL_EN signal of the Wifi module */
>         lbep5clwmc_wlen: regulator-lbep5clwmc-wlen {
> diff --git a/arch/arm/boot/dts/omap3-igep0030.dts b/arch/arm/boot/dts/omap3-igep0030.dts
> index 25170bd3c573..32f31035daa2 100644
> --- a/arch/arm/boot/dts/omap3-igep0030.dts
> +++ b/arch/arm/boot/dts/omap3-igep0030.dts
> @@ -10,7 +10,7 @@
>
>  / {
>         model = "IGEP COM MODULE Rev. E (TI OMAP AM/DM37x)";
> -       compatible = "isee,omap3-igep0030", "ti,omap36xx", "ti,omap3";
> +       compatible = "isee,omap3-igep0030", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>
>         vmmcsdio_fixed: fixedregulator-mmcsdio {
>                 compatible = "regulator-fixed";
> diff --git a/arch/arm/boot/dts/omap3-ldp.dts b/arch/arm/boot/dts/omap3-ldp.dts
> index 9a5fde2d9bce..ec9ba04ef43b 100644
> --- a/arch/arm/boot/dts/omap3-ldp.dts
> +++ b/arch/arm/boot/dts/omap3-ldp.dts
> @@ -10,7 +10,7 @@
>
>  / {
>         model = "TI OMAP3430 LDP (Zoom1 Labrador)";
> -       compatible = "ti,omap3-ldp", "ti,omap3";
> +       compatible = "ti,omap3-ldp", "ti,omap3430", "ti,omap3";
>
>         memory@80000000 {
>                 device_type = "memory";
> diff --git a/arch/arm/boot/dts/omap3-lilly-a83x.dtsi b/arch/arm/boot/dts/omap3-lilly-a83x.dtsi
> index c22833d4e568..73d477898ec2 100644
> --- a/arch/arm/boot/dts/omap3-lilly-a83x.dtsi
> +++ b/arch/arm/boot/dts/omap3-lilly-a83x.dtsi
> @@ -7,7 +7,7 @@
>
>  / {
>         model = "INCOstartec LILLY-A83X module (DM3730)";
> -       compatible = "incostartec,omap3-lilly-a83x", "ti,omap36xx", "ti,omap3";
> +       compatible = "incostartec,omap3-lilly-a83x", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>
>         chosen {
>                         bootargs = "console=ttyO0,115200n8 vt.global_cursor_default=0 consoleblank=0";
> diff --git a/arch/arm/boot/dts/omap3-lilly-dbb056.dts b/arch/arm/boot/dts/omap3-lilly-dbb056.dts
> index fec335400074..ecb4ef738e07 100644
> --- a/arch/arm/boot/dts/omap3-lilly-dbb056.dts
> +++ b/arch/arm/boot/dts/omap3-lilly-dbb056.dts
> @@ -8,7 +8,7 @@
>
>  / {
>         model = "INCOstartec LILLY-DBB056 (DM3730)";
> -       compatible = "incostartec,omap3-lilly-dbb056", "incostartec,omap3-lilly-a83x", "ti,omap36xx", "ti,omap3";
> +       compatible = "incostartec,omap3-lilly-dbb056", "incostartec,omap3-lilly-a83x", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>  };
>
>  &twl {
> diff --git a/arch/arm/boot/dts/omap3-n9.dts b/arch/arm/boot/dts/omap3-n9.dts
> index 74c0ff2350d3..2495a696cec6 100644
> --- a/arch/arm/boot/dts/omap3-n9.dts
> +++ b/arch/arm/boot/dts/omap3-n9.dts
> @@ -12,7 +12,7 @@
>
>  / {
>         model = "Nokia N9";
> -       compatible = "nokia,omap3-n9", "ti,omap36xx", "ti,omap3";
> +       compatible = "nokia,omap3-n9", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>  };
>
>  &i2c2 {
> diff --git a/arch/arm/boot/dts/omap3-n950.dts b/arch/arm/boot/dts/omap3-n950.dts
> index 9886bf8b90ab..31d47a1fad84 100644
> --- a/arch/arm/boot/dts/omap3-n950.dts
> +++ b/arch/arm/boot/dts/omap3-n950.dts
> @@ -12,7 +12,7 @@
>
>  / {
>         model = "Nokia N950";
> -       compatible = "nokia,omap3-n950", "ti,omap36xx", "ti,omap3";
> +       compatible = "nokia,omap3-n950", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>
>         keys {
>                 compatible = "gpio-keys";
> diff --git a/arch/arm/boot/dts/omap3-overo-storm-alto35.dts b/arch/arm/boot/dts/omap3-overo-storm-alto35.dts
> index 18338576c41d..7f04dfad8203 100644
> --- a/arch/arm/boot/dts/omap3-overo-storm-alto35.dts
> +++ b/arch/arm/boot/dts/omap3-overo-storm-alto35.dts
> @@ -14,5 +14,5 @@
>
>  / {
>         model = "OMAP36xx/AM37xx/DM37xx Gumstix Overo on Alto35";
> -       compatible = "gumstix,omap3-overo-alto35", "gumstix,omap3-overo", "ti,omap36xx", "ti,omap3";
> +       compatible = "gumstix,omap3-overo-alto35", "gumstix,omap3-overo", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>  };
> diff --git a/arch/arm/boot/dts/omap3-overo-storm-chestnut43.dts b/arch/arm/boot/dts/omap3-overo-storm-chestnut43.dts
> index f204c8af8281..bc5a04e03336 100644
> --- a/arch/arm/boot/dts/omap3-overo-storm-chestnut43.dts
> +++ b/arch/arm/boot/dts/omap3-overo-storm-chestnut43.dts
> @@ -14,7 +14,7 @@
>
>  / {
>         model = "OMAP36xx/AM37xx/DM37xx Gumstix Overo on Chestnut43";
> -       compatible = "gumstix,omap3-overo-chestnut43", "gumstix,omap3-overo", "ti,omap36xx", "ti,omap3";
> +       compatible = "gumstix,omap3-overo-chestnut43", "gumstix,omap3-overo", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>  };
>
>  &omap3_pmx_core2 {
> diff --git a/arch/arm/boot/dts/omap3-overo-storm-gallop43.dts b/arch/arm/boot/dts/omap3-overo-storm-gallop43.dts
> index c633f7cee68e..065c31cbf0e2 100644
> --- a/arch/arm/boot/dts/omap3-overo-storm-gallop43.dts
> +++ b/arch/arm/boot/dts/omap3-overo-storm-gallop43.dts
> @@ -14,7 +14,7 @@
>
>  / {
>         model = "OMAP36xx/AM37xx/DM37xx Gumstix Overo on Gallop43";
> -       compatible = "gumstix,omap3-overo-gallop43", "gumstix,omap3-overo", "ti,omap36xx", "ti,omap3";
> +       compatible = "gumstix,omap3-overo-gallop43", "gumstix,omap3-overo", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>  };
>
>  &omap3_pmx_core2 {
> diff --git a/arch/arm/boot/dts/omap3-overo-storm-palo35.dts b/arch/arm/boot/dts/omap3-overo-storm-palo35.dts
> index fb88ebc9858c..e38c1c51392c 100644
> --- a/arch/arm/boot/dts/omap3-overo-storm-palo35.dts
> +++ b/arch/arm/boot/dts/omap3-overo-storm-palo35.dts
> @@ -14,7 +14,7 @@
>
>  / {
>         model = "OMAP36xx/AM37xx/DM37xx Gumstix Overo on Palo35";
> -       compatible = "gumstix,omap3-overo-palo35", "gumstix,omap3-overo", "ti,omap36xx", "ti,omap3";
> +       compatible = "gumstix,omap3-overo-palo35", "gumstix,omap3-overo", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>  };
>
>  &omap3_pmx_core2 {
> diff --git a/arch/arm/boot/dts/omap3-overo-storm-palo43.dts b/arch/arm/boot/dts/omap3-overo-storm-palo43.dts
> index 76cca00d97b6..e6dc23159c4d 100644
> --- a/arch/arm/boot/dts/omap3-overo-storm-palo43.dts
> +++ b/arch/arm/boot/dts/omap3-overo-storm-palo43.dts
> @@ -14,7 +14,7 @@
>
>  / {
>         model = "OMAP36xx/AM37xx/DM37xx Gumstix Overo on Palo43";
> -       compatible = "gumstix,omap3-overo-palo43", "gumstix,omap3-overo", "ti,omap36xx", "ti,omap3";
> +       compatible = "gumstix,omap3-overo-palo43", "gumstix,omap3-overo", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>  };
>
>  &omap3_pmx_core2 {
> diff --git a/arch/arm/boot/dts/omap3-overo-storm-summit.dts b/arch/arm/boot/dts/omap3-overo-storm-summit.dts
> index cc081a9e4c1e..587c08ce282d 100644
> --- a/arch/arm/boot/dts/omap3-overo-storm-summit.dts
> +++ b/arch/arm/boot/dts/omap3-overo-storm-summit.dts
> @@ -14,7 +14,7 @@
>
>  / {
>         model = "OMAP36xx/AM37xx/DM37xx Gumstix Overo on Summit";
> -       compatible = "gumstix,omap3-overo-summit", "gumstix,omap3-overo", "ti,omap36xx", "ti,omap3";
> +       compatible = "gumstix,omap3-overo-summit", "gumstix,omap3-overo", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>  };
>
>  &omap3_pmx_core2 {
> diff --git a/arch/arm/boot/dts/omap3-overo-storm-tobi.dts b/arch/arm/boot/dts/omap3-overo-storm-tobi.dts
> index 1de41c0826e0..f57de6010994 100644
> --- a/arch/arm/boot/dts/omap3-overo-storm-tobi.dts
> +++ b/arch/arm/boot/dts/omap3-overo-storm-tobi.dts
> @@ -14,6 +14,6 @@
>
>  / {
>         model = "OMAP36xx/AM37xx/DM37xx Gumstix Overo on Tobi";
> -       compatible = "gumstix,omap3-overo-tobi", "gumstix,omap3-overo", "ti,omap36xx", "ti,omap3";
> +       compatible = "gumstix,omap3-overo-tobi", "gumstix,omap3-overo", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>  };
>
> diff --git a/arch/arm/boot/dts/omap3-overo-storm-tobiduo.dts b/arch/arm/boot/dts/omap3-overo-storm-tobiduo.dts
> index 9ed13118ed8e..281af6c113be 100644
> --- a/arch/arm/boot/dts/omap3-overo-storm-tobiduo.dts
> +++ b/arch/arm/boot/dts/omap3-overo-storm-tobiduo.dts
> @@ -14,5 +14,5 @@
>
>  / {
>         model = "OMAP36xx/AM37xx/DM37xx Gumstix Overo on TobiDuo";
> -       compatible = "gumstix,omap3-overo-tobiduo", "gumstix,omap3-overo", "ti,omap36xx", "ti,omap3";
> +       compatible = "gumstix,omap3-overo-tobiduo", "gumstix,omap3-overo", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>  };
> diff --git a/arch/arm/boot/dts/omap3-pandora-1ghz.dts b/arch/arm/boot/dts/omap3-pandora-1ghz.dts
> index 81b957f33c9f..ea509956d7ac 100644
> --- a/arch/arm/boot/dts/omap3-pandora-1ghz.dts
> +++ b/arch/arm/boot/dts/omap3-pandora-1ghz.dts
> @@ -16,7 +16,7 @@
>  / {
>         model = "Pandora Handheld Console 1GHz";
>
> -       compatible = "openpandora,omap3-pandora-1ghz", "ti,omap36xx", "ti,omap3";
> +       compatible = "openpandora,omap3-pandora-1ghz", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>  };
>
>  &omap3_pmx_core2 {
> diff --git a/arch/arm/boot/dts/omap3-sbc-t3530.dts b/arch/arm/boot/dts/omap3-sbc-t3530.dts
> index ae96002abb3b..24bf3fd86641 100644
> --- a/arch/arm/boot/dts/omap3-sbc-t3530.dts
> +++ b/arch/arm/boot/dts/omap3-sbc-t3530.dts
> @@ -8,7 +8,7 @@
>
>  / {
>         model = "CompuLab SBC-T3530 with CM-T3530";
> -       compatible = "compulab,omap3-sbc-t3530", "compulab,omap3-cm-t3530", "ti,omap34xx", "ti,omap3";
> +       compatible = "compulab,omap3-sbc-t3530", "compulab,omap3-cm-t3530", "ti,omap3430", "ti,omap34xx", "ti,omap3";
>
>         aliases {
>                 display0 = &dvi0;
> diff --git a/arch/arm/boot/dts/omap3-sbc-t3730.dts b/arch/arm/boot/dts/omap3-sbc-t3730.dts
> index 7de6df16fc17..eb3893b9535e 100644
> --- a/arch/arm/boot/dts/omap3-sbc-t3730.dts
> +++ b/arch/arm/boot/dts/omap3-sbc-t3730.dts
> @@ -8,7 +8,7 @@
>
>  / {
>         model = "CompuLab SBC-T3730 with CM-T3730";
> -       compatible = "compulab,omap3-sbc-t3730", "compulab,omap3-cm-t3730", "ti,omap36xx", "ti,omap3";
> +       compatible = "compulab,omap3-sbc-t3730", "compulab,omap3-cm-t3730", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>
>         aliases {
>                 display0 = &dvi0;
> diff --git a/arch/arm/boot/dts/omap3-sniper.dts b/arch/arm/boot/dts/omap3-sniper.dts
> index 40a87330e8c3..b6879cdc5c13 100644
> --- a/arch/arm/boot/dts/omap3-sniper.dts
> +++ b/arch/arm/boot/dts/omap3-sniper.dts
> @@ -9,7 +9,7 @@
>
>  / {
>         model = "LG Optimus Black";
> -       compatible = "lg,omap3-sniper", "ti,omap36xx", "ti,omap3";
> +       compatible = "lg,omap3-sniper", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>
>         cpus {
>                 cpu@0 {
> diff --git a/arch/arm/boot/dts/omap3-thunder.dts b/arch/arm/boot/dts/omap3-thunder.dts
> index 6276e7079b36..64221e3b3477 100644
> --- a/arch/arm/boot/dts/omap3-thunder.dts
> +++ b/arch/arm/boot/dts/omap3-thunder.dts
> @@ -8,7 +8,7 @@
>
>  / {
>         model = "TI OMAP3 Thunder baseboard with TAO3530 SOM";
> -       compatible = "technexion,omap3-thunder", "technexion,omap3-tao3530", "ti,omap34xx", "ti,omap3";
> +       compatible = "technexion,omap3-thunder", "technexion,omap3-tao3530", "ti,omap3430", "ti,omap34xx", "ti,omap3";
>  };
>
>  &omap3_pmx_core {
> diff --git a/arch/arm/boot/dts/omap3-zoom3.dts b/arch/arm/boot/dts/omap3-zoom3.dts
> index db3a2fe84e99..d240e39f2151 100644
> --- a/arch/arm/boot/dts/omap3-zoom3.dts
> +++ b/arch/arm/boot/dts/omap3-zoom3.dts
> @@ -9,7 +9,7 @@
>
>  / {
>         model = "TI Zoom3";
> -       compatible = "ti,omap3-zoom3", "ti,omap36xx", "ti,omap3";
> +       compatible = "ti,omap3-zoom3", "ti,omap3630", "ti,omap36xx", "ti,omap3";
>
>         cpus {
>                 cpu@0 {
> diff --git a/arch/arm/boot/dts/omap3430-sdp.dts b/arch/arm/boot/dts/omap3430-sdp.dts
> index 0abd61108a53..7bfde8aac7ae 100644
> --- a/arch/arm/boot/dts/omap3430-sdp.dts
> +++ b/arch/arm/boot/dts/omap3430-sdp.dts
> @@ -8,7 +8,7 @@
>
>  / {
>         model = "TI OMAP3430 SDP";
> -       compatible = "ti,omap3430-sdp", "ti,omap3";
> +       compatible = "ti,omap3430-sdp", "ti,omap3430", "ti,omap3";
>
>         memory@80000000 {
>                 device_type = "memory";
> --
> 2.19.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply

* Re: [PATCH v5 1/2] dt-bindings: mailbox: add binding doc for the ARM SMC/HVC mailbox
From: Andre Przywara @ 2019-09-09 13:32 UTC (permalink / raw)
  To: Jassi Brar
  Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, Peng Fan,
	f.fainelli@gmail.com, linux-kernel@vger.kernel.org,
	robh+dt@kernel.org, dl-linux-imx, sudeep.holla@arm.com,
	linux-arm-kernel@lists.infradead.org
In-Reply-To: <CABb+yY2t-oz6KqvCTsOJZqcMAUaR9Cbj014m7dCFXSBAMCojww@mail.gmail.com>

On Fri, 30 Aug 2019 03:12:29 -0500
Jassi Brar <jassisinghbrar@gmail.com> wrote:

Hi,

> On Fri, Aug 30, 2019 at 3:07 AM Peng Fan <peng.fan@nxp.com> wrote:
> >  
> > > Subject: Re: [PATCH v5 1/2] dt-bindings: mailbox: add binding doc for the ARM
> > > SMC/HVC mailbox
> > >
> > > On Fri, Aug 30, 2019 at 2:37 AM Peng Fan <peng.fan@nxp.com> wrote:  
> > > >
> > > > Hi Jassi,
> > > >  
> > > > > Subject: Re: [PATCH v5 1/2] dt-bindings: mailbox: add binding doc
> > > > > for the ARM SMC/HVC mailbox
> > > > >
> > > > > On Fri, Aug 30, 2019 at 1:28 AM Peng Fan <peng.fan@nxp.com> wrote:
> > > > >  
> > > > > > > > +examples:
> > > > > > > > +  - |
> > > > > > > > +    sram@910000 {
> > > > > > > > +      compatible = "mmio-sram";
> > > > > > > > +      reg = <0x0 0x93f000 0x0 0x1000>;
> > > > > > > > +      #address-cells = <1>;
> > > > > > > > +      #size-cells = <1>;
> > > > > > > > +      ranges = <0 0x0 0x93f000 0x1000>;
> > > > > > > > +
> > > > > > > > +      cpu_scp_lpri: scp-shmem@0 {
> > > > > > > > +        compatible = "arm,scmi-shmem";
> > > > > > > > +        reg = <0x0 0x200>;
> > > > > > > > +      };
> > > > > > > > +
> > > > > > > > +      cpu_scp_hpri: scp-shmem@200 {
> > > > > > > > +        compatible = "arm,scmi-shmem";
> > > > > > > > +        reg = <0x200 0x200>;
> > > > > > > > +      };
> > > > > > > > +    };
> > > > > > > > +
> > > > > > > > +    firmware {
> > > > > > > > +      smc_mbox: mailbox {
> > > > > > > > +        #mbox-cells = <1>;
> > > > > > > > +        compatible = "arm,smc-mbox";
> > > > > > > > +        method = "smc";
> > > > > > > > +        arm,num-chans = <0x2>;
> > > > > > > > +        transports = "mem";
> > > > > > > > +        /* Optional */
> > > > > > > > +        arm,func-ids = <0xc20000fe>, <0xc20000ff>;
> > > > > > > >  
> > > > > > > SMC/HVC is synchronously(block) running in "secure mode", i.e,
> > > > > > > there can only be one instance running platform wide. Right?  
> > > > > >
> > > > > > I think there could be channel for TEE, and channel for Linux.
> > > > > > For virtualization case, there could be dedicated channel for each VM.
> > > > > >  
> > > > > I am talking from Linux pov. Functions 0xfe and 0xff above, can't
> > > > > both be active at the same time, right?  
> > > >
> > > > If I get your point correctly,
> > > > On UP, both could not be active. On SMP, tx/rx could be both active,
> > > > anyway this depends on secure firmware and Linux firmware design.
> > > >
> > > > Do you have any suggestions about arm,func-ids here?
> > > >  
> > > I was thinking if this is just an instruction, why can't each channel be
> > > represented as a controller, i.e, have exactly one func-id per controller node.
> > > Define as many controllers as you need channels ?  
> >
> > I am ok, this could make driver code simpler. Something as below?
> >
> >     smc_tx_mbox: tx_mbox {
> >       #mbox-cells = <0>;
> >       compatible = "arm,smc-mbox";
> >       method = "smc";
> >       transports = "mem";
> >       arm,func-id = <0xc20000fe>;
> >     };
> >
> >     smc_rx_mbox: rx_mbox {
> >       #mbox-cells = <0>;
> >       compatible = "arm,smc-mbox";
> >       method = "smc";
> >       transports = "mem";
> >       arm,func-id = <0xc20000ff>;
> >     };
> >
> >     firmware {
> >       scmi {
> >         compatible = "arm,scmi";
> >         mboxes = <&smc_tx_mbox>, <&smc_rx_mbox 1>;
> >         mbox-names = "tx", "rx";
> >         shmem = <&cpu_scp_lpri>, <&cpu_scp_hpri>;
> >       };
> >     };
> >  
> Yes, the channel part is good.
> But I am not convinced by the need to have SCMI specific "transport" mode.

Why would this be SCMI specific and what is the problem with having this property?
By the very nature of the SMC/HVC call you would expect to also pass parameters in registers. However this limits the amount of data you can push, so the option of reverting to a memory based payload sounds very reasonable.
On the other hand *just* using memory complicates things, in case you have a very simple protocol. You would need a memory region shared between firmware and OS, which is not always easily possible on every platform. Also this doesn't scale easily with multiple mailboxes and channels. Passing parameters via registers is also naturally consistent, as there would be no races and no need for synchronisation with other cores or other users of the mailbox.

So I clearly see the benefit of specifying *both* ways of payload transport. Given that this driver should be protocol agnostic, it makes a lot of sense to introduce both methods *now*, so in the future users can just use the register method, without extending the binding in a incompatible way later (earlier kernels would have the driver, but wouldn't know how to deal with this parameter).

Cheers,
Andre.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply

* Re: [RFC] ARM: omap3: Enable HWMODS for HW Random Number Generator
From: Adam Ford @ 2019-09-09 13:37 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Mark Rutland, devicetree, Paul Walmsley, Aaro Koskinen,
	Russell King, Linux Kernel Mailing List, Tero Kristo, Rob Herring,
	Benoît Cousson, Pali Rohár, Linux-OMAP, Adam Ford,
	arm-soc
In-Reply-To: <CAHCN7xL0fbr=Sv+b=0AuGB1PPhAAFdAFLEd_iBM+ZMTkUw5sHQ@mail.gmail.com>

On Mon, Sep 9, 2019 at 7:13 AM Adam Ford <aford173@gmail.com> wrote:
>
> On Thu, Sep 5, 2019 at 6:04 PM Tony Lindgren <tony@atomide.com> wrote:
> >
> > Hi,
> >
> > * Adam Ford <aford173@gmail.com> [190828 15:01]:
> > > The datasheet for the AM3517 shows the RNG is connected to L4.
> > > It shows the module address for the RNG is 0x480A0000, and it
> > > matches the omap2.dtsi description.  Since the driver can support
> > > omap2 and omap4, it seems reasonable to assume the omap3 would
> > > use the same core for the RNG.
> > >
> > > This RFC, mimics much of the omap2 hwmods on the OMAP3. It
> > > also adds the necessary clock for driving the RNG.  Unfortunately,
> > > it appears non-functional.  If anyone has any suggestions on how
> > > to finish the hwmod (or port it to the newer l4 device tree
> > > format), feedback is requested.
> >
> > Yup I'll take the bait :) The patch below seems to do the trick
> > for me on dm3730 based on translating your patch to probe with
> > ti-sysc.
> >
> > Not sure about 34xx, it seems we're missing rng_clk? Care
> > to give it a try and attempt simlar patches for 34xx and
> > 3517?
> >
> > At least I'm not needing the "ti,no-reset-on-init" property
> > that your patch has a comment for. Maybe that's needed on
> > some other omap3.
> >
> > Oh and this needs to default to status = "disabled" for
> > HS devices like n900 as it needs to use the omap3-rom-rng.
> >
> > Regards,
> >
> > Tony
> >
> > 8< -----------------------
> > diff --git a/arch/arm/boot/dts/omap36xx.dtsi b/arch/arm/boot/dts/omap36xx.dtsi
> > --- a/arch/arm/boot/dts/omap36xx.dtsi
> > +++ b/arch/arm/boot/dts/omap36xx.dtsi
> > @@ -140,6 +140,29 @@
> >                         };
> >                 };
> >
> > +               rng_target: target-module@480a0000 {
> > +                       compatible = "ti,sysc-omap2", "ti,sysc";
> > +                       reg = <0x480a003c 0x4>,
> > +                             <0x480a0040 0x4>,
> > +                             <0x480a0044 0x4>;
> > +                       reg-names = "rev", "sysc", "syss";
> > +                       ti,sysc-mask = <(SYSC_OMAP2_AUTOIDLE)>;
> > +                       ti,sysc-sidle = <SYSC_IDLE_FORCE>,
> > +                                       <SYSC_IDLE_NO>;
> > +                       ti,syss-mask = <1>;
> > +                       clocks = <&rng_ick>;
> > +                       clock-names = "ick";
> > +                       #address-cells = <1>;
> > +                       #size-cells = <1>;
> > +                       ranges = <0 0x480a0000 0x2000>;
> > +
> > +                       rng: rng@0 {
> > +                               compatible = "ti,omap2-rng";
> > +                               reg = <0x0 0x2000>;
> > +                               interrupts = <52>;
> > +                       };
> > +               };
> > +

I applied this on 5.3 and it is working.  I assume the same is true in for-next.

Do you want to submit a formal patch?  I  can mark it as 'tested-by'
This really helps speed up the startup sequence on boards with sshd
because it delays for nearly 80 seconds waiting for entropy without
the hwrng.

adam
>
> Tony,
>
> Can you tell me what branch you're using?  I am not seeing the note
> below, so I am not exactly sure what version to base my testing.
>
> ada,
> >                 /*
> >                  * Note that the sysconfig register layout is a subset of the
> >                  * "ti,sysc-omap4" type register with just sidle and midle bits

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply

* Re: [RFC] ARM: omap3: Enable HWMODS for HW Random Number Generator
From: Pali Rohár @ 2019-09-09 13:40 UTC (permalink / raw)
  To: Adam Ford
  Cc: Mark Rutland, devicetree, Paul Walmsley, Aaro Koskinen,
	Tony Lindgren, Russell King, Linux Kernel Mailing List,
	Tero Kristo, Rob Herring, Benoît Cousson, Linux-OMAP,
	Adam Ford, arm-soc
In-Reply-To: <CAHCN7xL-Gfxe0qF5w7BUsHnyhcNNpmCnchdKErnmiqggXfsLWw@mail.gmail.com>

On Monday 09 September 2019 08:37:09 Adam Ford wrote:
> On Mon, Sep 9, 2019 at 7:13 AM Adam Ford <aford173@gmail.com> wrote:
> >
> > On Thu, Sep 5, 2019 at 6:04 PM Tony Lindgren <tony@atomide.com> wrote:
> > >
> > > Hi,
> > >
> > > * Adam Ford <aford173@gmail.com> [190828 15:01]:
> > > > The datasheet for the AM3517 shows the RNG is connected to L4.
> > > > It shows the module address for the RNG is 0x480A0000, and it
> > > > matches the omap2.dtsi description.  Since the driver can support
> > > > omap2 and omap4, it seems reasonable to assume the omap3 would
> > > > use the same core for the RNG.
> > > >
> > > > This RFC, mimics much of the omap2 hwmods on the OMAP3. It
> > > > also adds the necessary clock for driving the RNG.  Unfortunately,
> > > > it appears non-functional.  If anyone has any suggestions on how
> > > > to finish the hwmod (or port it to the newer l4 device tree
> > > > format), feedback is requested.
> > >
> > > Yup I'll take the bait :) The patch below seems to do the trick
> > > for me on dm3730 based on translating your patch to probe with
> > > ti-sysc.
> > >
> > > Not sure about 34xx, it seems we're missing rng_clk? Care
> > > to give it a try and attempt simlar patches for 34xx and
> > > 3517?
> > >
> > > At least I'm not needing the "ti,no-reset-on-init" property
> > > that your patch has a comment for. Maybe that's needed on
> > > some other omap3.
> > >
> > > Oh and this needs to default to status = "disabled" for
> > > HS devices like n900 as it needs to use the omap3-rom-rng.
> > >
> > > Regards,
> > >
> > > Tony
> > >
> > > 8< -----------------------
> > > diff --git a/arch/arm/boot/dts/omap36xx.dtsi b/arch/arm/boot/dts/omap36xx.dtsi
> > > --- a/arch/arm/boot/dts/omap36xx.dtsi
> > > +++ b/arch/arm/boot/dts/omap36xx.dtsi
> > > @@ -140,6 +140,29 @@
> > >                         };
> > >                 };
> > >
> > > +               rng_target: target-module@480a0000 {
> > > +                       compatible = "ti,sysc-omap2", "ti,sysc";
> > > +                       reg = <0x480a003c 0x4>,
> > > +                             <0x480a0040 0x4>,
> > > +                             <0x480a0044 0x4>;
> > > +                       reg-names = "rev", "sysc", "syss";
> > > +                       ti,sysc-mask = <(SYSC_OMAP2_AUTOIDLE)>;
> > > +                       ti,sysc-sidle = <SYSC_IDLE_FORCE>,
> > > +                                       <SYSC_IDLE_NO>;
> > > +                       ti,syss-mask = <1>;
> > > +                       clocks = <&rng_ick>;
> > > +                       clock-names = "ick";
> > > +                       #address-cells = <1>;
> > > +                       #size-cells = <1>;
> > > +                       ranges = <0 0x480a0000 0x2000>;
> > > +
> > > +                       rng: rng@0 {
> > > +                               compatible = "ti,omap2-rng";
> > > +                               reg = <0x0 0x2000>;
> > > +                               interrupts = <52>;
> > > +                       };
> > > +               };
> > > +
> 
> I applied this on 5.3 and it is working.  I assume the same is true in for-next.
> 
> Do you want to submit a formal patch?  I  can mark it as 'tested-by'
> This really helps speed up the startup sequence on boards with sshd
> because it delays for nearly 80 seconds waiting for entropy without
> the hwrng.

Hi! When applying a patch, could you please disable this rng for n900?

In omap3-n900.dts for rng should be status = "disabled" (as Tony already
wrote), similarly like for aes.

Thanks!

> adam
> >
> > Tony,
> >
> > Can you tell me what branch you're using?  I am not seeing the note
> > below, so I am not exactly sure what version to base my testing.
> >
> > ada,
> > >                 /*
> > >                  * Note that the sysconfig register layout is a subset of the
> > >                  * "ti,sysc-omap4" type register with just sidle and midle bits

-- 
Pali Rohár
pali.rohar@gmail.com

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply

* Re: [PATCH 2/3] soc: amazon: al-pos: Introduce Amazon's Annapurna Labs POS driver
From: Arnd Bergmann @ 2019-09-09 13:41 UTC (permalink / raw)
  To: Shenhar, Talel
  Cc: Mark Rutland, mjourdan, Catalin Marinas, Linus Walleij,
	linux-kernel@vger.kernel.org, jonnyc, Mauro Carvalho Chehab,
	ronenk, Will Deacon, Benjamin Herrenschmidt, DTML, Maxime Ripard,
	Rob Herring, Santosh Shilimkar, Thomas Gleixner, hanochu,
	Linux ARM, barakw, hhhawa, gregkh, paul.kocialkowski,
	Patrick Venture, Olof Johansson, David Miller, David Woodhouse
In-Reply-To: <98f0028e-5653-3116-fdaa-1385ecdf0289@amazon.com>

On Mon, Sep 9, 2019 at 1:13 PM Shenhar, Talel <talel@amazon.com> wrote:
> On 9/9/2019 12:44 PM, Arnd Bergmann wrote:
> > On Mon, Sep 9, 2019 at 11:14 AM Talel Shenhar <talel@amazon.com> wrote:

> >> +       writel_relaxed(0, pos->mmio_base + AL_POS_ERROR_LOG_1);
> > Why do you require _relaxed() accessors here? Please add a comment
> > explaining that, or use the regular readl()/writel().
>
> I don't think commenting is needed here as there is nothing special in
> this type of access.
>
> I don't see this is common to comment the use of the _relaxed accessors.

I usually mention it in driver reviews, but most authors revert back
to the normal accessors when there is no difference.

> This driver is for SoC using arm64 cpu.
>
> If one uses the non-relaxed version of readl while running on arm64, he
> shall cause read barrier, which is then doing dsm(ld).. This barrier is
> not needed here, so we spare the use of the more heavy readl in favor of
> the less "harmful" one.
>
> Let me know what you think.

If the barrier causes no harm, just leave it in to keep the code more
readable. Most developers don't need to know the difference between
the two, so using the less common interface just makes the reader
curious about why it was picked.

Avoiding the barrier can make a huge performance difference in a
hot code path, but the downside is that it can behave in unexpected
ways if the same code is run on a different CPU architecture that
does not have the exact same rules about what _relaxed() means.

In fact, replacing a 'readl()' with 'readl_relaxed() + rmb()' can lead
to slower rather than faster code when the explicit barrier is heavier
than the implied one (e.g. on x86), or readl_relaxed() does not skip
the barrier.

The general rule with kernel interfaces when you have two versions
that both do what you want is to pick the one with the shorter name.
See spin_lock()/spin_lock_irqsave(),  ioremap()/ioremap_nocache(),
or ktime_get()/ktime_get_clocktai_ts64(). (yes, there are also
exceptions)

    Arnd

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply

* Re: [PATCH 2/4] ARM: dts: replace opp-v1 tables by opp-v2 for omap34xx and omap36xx
From: Adam Ford @ 2019-09-09 13:43 UTC (permalink / raw)
  To: H. Nikolaus Schaller
  Cc: Mark Rutland, devicetree, Discussions about the Letux Kernel,
	linux-pm, Tony Lindgren, Viresh Kumar, Rafael J. Wysocki,
	Linux Kernel Mailing List, Enric Balletbo i Serra, Rob Herring,
	André Roth, Benoît Cousson, kernel, Teresa Remmet,
	Javier Martinez Canillas, Linux-OMAP, arm-soc, Roger Quadros
In-Reply-To: <784d0d08ee585fc436f15de4edb58b394d0f4452.1567878413.git.hns@goldelico.com>

On Sat, Sep 7, 2019 at 12:47 PM H. Nikolaus Schaller <hns@goldelico.com> wrote:
>
> In addition, move omap3 from whitelist to blacklist in cpufreq-dt-platdev
> in the same patch, because doing either first breaks operation and
> may make trouble in bisect.
>
> We also can remove opp-v1 table for omap3-n950-n9 since it is now
> automatically detected.
>
> We also fix a wrong OPP4 voltage for omap3430 which must be
> 0.6V + 54*12.5mV = 1275mV. Otherwise the twl4030 driver will reject
> this OPP.
>
thank you for your work on this.  I tested it on a a Logit PD DM3730
Torpedo + Wireless kit, and appears to operate normally, but i have
not tested it at temperature.

Tested-by: Adam Ford <aford173@gmail.com>

> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
> Acked-by: Tony Lindgren <tony@atomide.com>
> ---
>  arch/arm/boot/dts/omap3-n950-n9.dtsi |  7 ---
>  arch/arm/boot/dts/omap34xx.dtsi      | 65 ++++++++++++++++++++++++----
>  arch/arm/boot/dts/omap36xx.dtsi      | 53 +++++++++++++++++++----
>  drivers/cpufreq/cpufreq-dt-platdev.c |  2 +-
>  4 files changed, 102 insertions(+), 25 deletions(-)
>
> diff --git a/arch/arm/boot/dts/omap3-n950-n9.dtsi b/arch/arm/boot/dts/omap3-n950-n9.dtsi
> index 5441e9ffdbb4..e98b0c615f19 100644
> --- a/arch/arm/boot/dts/omap3-n950-n9.dtsi
> +++ b/arch/arm/boot/dts/omap3-n950-n9.dtsi
> @@ -11,13 +11,6 @@
>         cpus {
>                 cpu@0 {
>                         cpu0-supply = <&vcc>;
> -                       operating-points = <
> -                               /* kHz    uV */
> -                               300000  1012500
> -                               600000  1200000
> -                               800000  1325000
> -                               1000000 1375000
> -                       >;
>                 };
>         };
>
> diff --git a/arch/arm/boot/dts/omap34xx.dtsi b/arch/arm/boot/dts/omap34xx.dtsi
> index f572a477f74c..91154829f86a 100644
> --- a/arch/arm/boot/dts/omap34xx.dtsi
> +++ b/arch/arm/boot/dts/omap34xx.dtsi
> @@ -16,19 +16,66 @@
>  / {
>         cpus {
>                 cpu: cpu@0 {
> -                       /* OMAP343x/OMAP35xx variants OPP1-5 */
> -                       operating-points = <
> -                               /* kHz    uV */
> -                               125000   975000
> -                               250000  1075000
> -                               500000  1200000
> -                               550000  1270000
> -                               600000  1350000
> -                       >;
> +                       /* OMAP343x/OMAP35xx variants OPP1-6 */
> +                       operating-points-v2 = <&cpu0_opp_table>;
> +
>                         clock-latency = <300000>; /* From legacy driver */
>                 };
>         };
>
> +       /* see Documentation/devicetree/bindings/opp/opp.txt */
> +       cpu0_opp_table: opp-table {
> +               compatible = "operating-points-v2-ti-cpu";
> +               syscon = <&scm_conf>;
> +
> +               opp1-125000000 {
> +                       opp-hz = /bits/ 64 <125000000>;
> +                       /*
> +                        * we currently only select the max voltage from table
> +                        * Table 3-3 of the omap3530 Data sheet (SPRS507F).
> +                        * Format is: <target min max>
> +                        */
> +                       opp-microvolt = <975000 975000 975000>;
> +                       /*
> +                        * first value is silicon revision bit mask
> +                        * second one 720MHz Device Identification bit mask
> +                        */
> +                       opp-supported-hw = <0xffffffff 3>;
> +               };
> +
> +               opp2-250000000 {
> +                       opp-hz = /bits/ 64 <250000000>;
> +                       opp-microvolt = <1075000 1075000 1075000>;
> +                       opp-supported-hw = <0xffffffff 3>;
> +                       opp-suspend;
> +               };
> +
> +               opp3-500000000 {
> +                       opp-hz = /bits/ 64 <500000000>;
> +                       opp-microvolt = <1200000 1200000 1200000>;
> +                       opp-supported-hw = <0xffffffff 3>;
> +               };
> +
> +               opp4-550000000 {
> +                       opp-hz = /bits/ 64 <550000000>;
> +                       opp-microvolt = <1275000 1275000 1275000>;
> +                       opp-supported-hw = <0xffffffff 3>;
> +               };
> +
> +               opp5-600000000 {
> +                       opp-hz = /bits/ 64 <600000000>;
> +                       opp-microvolt = <1350000 1350000 1350000>;
> +                       opp-supported-hw = <0xffffffff 3>;
> +               };
> +
> +               opp6-720000000 {
> +                       opp-hz = /bits/ 64 <720000000>;
> +                       opp-microvolt = <1350000 1350000 1350000>;
> +                       /* only high-speed grade omap3530 devices */
> +                       opp-supported-hw = <0xffffffff 2>;
> +               };
> +       };
> +
>         ocp@68000000 {
>                 omap3_pmx_core2: pinmux@480025d8 {
>                         compatible = "ti,omap3-padconf", "pinctrl-single";
> diff --git a/arch/arm/boot/dts/omap36xx.dtsi b/arch/arm/boot/dts/omap36xx.dtsi
> index 6fb23ada1f64..44f25b0eb45b 100644
> --- a/arch/arm/boot/dts/omap36xx.dtsi
> +++ b/arch/arm/boot/dts/omap36xx.dtsi
> @@ -19,15 +19,52 @@
>         };
>
>         cpus {
> -               /* OMAP3630/OMAP37xx 'standard device' variants OPP50 to OPP130 */
> +               /* OMAP3630/OMAP37xx variants OPP50 to OPP130 and OPP1G */
>                 cpu: cpu@0 {
> -                       operating-points = <
> -                               /* kHz    uV */
> -                               300000  1012500
> -                               600000  1200000
> -                               800000  1325000
> -                       >;
> -                       clock-latency = <300000>; /* From legacy driver */
> +                       operating-points-v2 = <&cpu0_opp_table>;
> +
> +                       clock-latency = <300000>; /* From omap-cpufreq driver */
> +               };
> +       };
> +
> +       /* see Documentation/devicetree/bindings/opp/opp.txt */
> +       cpu0_opp_table: opp-table {
> +               compatible = "operating-points-v2-ti-cpu";
> +               syscon = <&scm_conf>;
> +
> +               opp50-300000000 {
> +                       opp-hz = /bits/ 64 <300000000>;
> +                       /*
> +                        * we currently only select the max voltage from table
> +                        * Table 4-19 of the DM3730 Data sheet (SPRS685B)
> +                        * Format is: <target min max>
> +                        */
> +                       opp-microvolt = <1012500 1012500 1012500>;
> +                       /*
> +                        * first value is silicon revision bit mask
> +                        * second one is "speed binned" bit mask
> +                        */
> +                       opp-supported-hw = <0xffffffff 3>;
> +                       opp-suspend;
> +               };
> +
> +               opp100-600000000 {
> +                       opp-hz = /bits/ 64 <600000000>;
> +                       opp-microvolt = <1200000 1200000 1200000>;
> +                       opp-supported-hw = <0xffffffff 3>;
> +               };
> +
> +               opp130-800000000 {
> +                       opp-hz = /bits/ 64 <800000000>;
> +                       opp-microvolt = <1325000 1325000 1325000>;
> +                       opp-supported-hw = <0xffffffff 3>;
> +               };
> +
> +               opp1g-1000000000 {
> +                       opp-hz = /bits/ 64 <1000000000>;
> +                       opp-microvolt = <1375000 1375000 1375000>;
> +                       /* only on am/dm37x with speed-binned bit set */
> +                       opp-supported-hw = <0xffffffff 2>;
>                 };
>         };
>
> diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c
> index 03dc4244ab00..68b7fc4225f8 100644
> --- a/drivers/cpufreq/cpufreq-dt-platdev.c
> +++ b/drivers/cpufreq/cpufreq-dt-platdev.c
> @@ -86,7 +86,6 @@ static const struct of_device_id whitelist[] __initconst = {
>         { .compatible = "st-ericsson,u9540", },
>
>         { .compatible = "ti,omap2", },
> -       { .compatible = "ti,omap3", },
>         { .compatible = "ti,omap4", },
>         { .compatible = "ti,omap5", },
>
> @@ -132,6 +131,7 @@ static const struct of_device_id blacklist[] __initconst = {
>         { .compatible = "ti,am33xx", },
>         { .compatible = "ti,am43", },
>         { .compatible = "ti,dra7", },
> +       { .compatible = "ti,omap3", },
>
>         { }
>  };
> --
> 2.19.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply

* Re: [PATCH 3/3] arm64: alpine: select AL_POS
From: Arnd Bergmann @ 2019-09-09 13:45 UTC (permalink / raw)
  To: Shenhar, Talel
  Cc: Mark Rutland, mjourdan, Catalin Marinas, Linus Walleij,
	linux-kernel@vger.kernel.org, jonnyc, Mauro Carvalho Chehab,
	ronenk, Will Deacon, Benjamin Herrenschmidt, DTML, Maxime Ripard,
	Rob Herring, Santosh Shilimkar, Thomas Gleixner, hanochu,
	Linux ARM, barakw, hhhawa, gregkh, paul.kocialkowski,
	Patrick Venture, Olof Johansson, David Miller, David Woodhouse
In-Reply-To: <ab512ced-d989-5c10-a550-2a4723d38e7e@amazon.com>

On Mon, Sep 9, 2019 at 12:17 PM Shenhar, Talel <talel@amazon.com> wrote:
> On 9/9/2019 12:40 PM, Arnd Bergmann wrote:
> > On Mon, Sep 9, 2019 at 11:14 AM Talel Shenhar <talel@amazon.com> wrote:
> >> diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
> >> index 4778c77..bd86b15 100644
> >> --- a/arch/arm64/Kconfig.platforms
> >> +++ b/arch/arm64/Kconfig.platforms
> >> @@ -25,6 +25,7 @@ config ARCH_SUNXI
> >>   config ARCH_ALPINE
> >>          bool "Annapurna Labs Alpine platform"
> >>          select ALPINE_MSI if PCI
> >> +       select AL_POS
> >>          help
> >>            This enables support for the Annapurna Labs Alpine
> >>            Soc family.
> > Generally I think this kind of thing should go into the defconfig
> > rather than being hard-selected. There might be users that
> > want to not enable the driver.
>
> The reason for selecting it is because this is a driver that we will
> always want for ARCH_ALPINE.

Can you put the exact requirement (other than "we want this")
in the changelog text then? It's still not clear to me what breaks
without this driver.

        Arnd

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply

* [PATCH 00/17] KVM/arm updates for 5.4
From: Marc Zyngier @ 2019-09-09 13:47 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Mark Rutland, kvm, Andre Przywara, Eric Auger, James Morse,
	Zenghui Yu, Alexandru Elisei, kvmarm, linux-arm-kernel

Paolo, Radim,

Here is the KVM/arm updates for 5.4: a new ITS translation cache
improving performance for interrupt injection of of assigned devices,
a couple of fixes to allow up to 512 vcpus, and a number of fixes and
other cleanups.

Please pull,

	M.

The following changes since commit d45331b00ddb179e291766617259261c112db872:

  Linux 5.3-rc4 (2019-08-11 13:26:41 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git tags/kvmarm-5.4

for you to fetch changes up to 92f35b751c71d14250a401246f2c792e3aa5b386:

  KVM: arm/arm64: vgic: Allow more than 256 vcpus for KVM_IRQ_LINE (2019-09-09 12:29:09 +0100)

----------------------------------------------------------------
KVM/arm updates for 5.4

- New ITS translation cache
- Allow up to 512 CPUs to be supported with GICv3 (for real this time)
- Now call kvm_arch_vcpu_blocking early in the blocking sequence
- Tidy-up device mappings in S2 when DIC is available
- Clean icache invalidation on VMID rollover
- General cleanup

----------------------------------------------------------------
Alexandru Elisei (1):
      KVM: arm/arm64: vgic: Make function comments match function declarations

Eric Auger (1):
      KVM: arm/arm64: vgic: Use a single IO device per redistributor

James Morse (1):
      arm64: KVM: Device mappings should be execute-never

Marc Zyngier (13):
      KVM: arm/arm64: vgic: Add LPI translation cache definition
      KVM: arm/arm64: vgic: Add __vgic_put_lpi_locked primitive
      KVM: arm/arm64: vgic-its: Add MSI-LPI translation cache invalidation
      KVM: arm/arm64: vgic-its: Invalidate MSI-LPI translation cache on specific commands
      KVM: arm/arm64: vgic-its: Invalidate MSI-LPI translation cache on disabling LPIs
      KVM: arm/arm64: vgic-its: Invalidate MSI-LPI translation cache on ITS disable
      KVM: arm/arm64: vgic-its: Invalidate MSI-LPI translation cache on vgic teardown
      KVM: arm/arm64: vgic-its: Cache successful MSI->LPI translation
      KVM: arm/arm64: vgic-its: Check the LPI translation cache on MSI injection
      KVM: arm/arm64: vgic-irqfd: Implement kvm_arch_set_irq_inatomic
      KVM: Call kvm_arch_vcpu_blocking early into the blocking sequence
      KVM: arm/arm64: vgic: Remove spurious semicolons
      KVM: arm/arm64: vgic: Allow more than 256 vcpus for KVM_IRQ_LINE

Mark Rutland (1):
      arm64/kvm: Remove VMID rollover I-cache maintenance

 Documentation/virt/kvm/api.txt        |  12 +-
 arch/arm/include/uapi/asm/kvm.h       |   4 +-
 arch/arm64/include/asm/pgtable-prot.h |   2 +-
 arch/arm64/include/uapi/asm/kvm.h     |   4 +-
 arch/arm64/kvm/hyp/tlb.c              |  14 ++-
 include/kvm/arm_vgic.h                |   4 +-
 include/uapi/linux/kvm.h              |   1 +
 virt/kvm/arm/arm.c                    |   2 +
 virt/kvm/arm/vgic/vgic-init.c         |   8 +-
 virt/kvm/arm/vgic/vgic-irqfd.c        |  36 +++++-
 virt/kvm/arm/vgic/vgic-its.c          | 207 ++++++++++++++++++++++++++++++++++
 virt/kvm/arm/vgic/vgic-mmio-v3.c      |  85 +++++---------
 virt/kvm/arm/vgic/vgic-v2.c           |   7 +-
 virt/kvm/arm/vgic/vgic-v3.c           |   7 +-
 virt/kvm/arm/vgic/vgic.c              |  26 +++--
 virt/kvm/arm/vgic/vgic.h              |   5 +
 virt/kvm/kvm_main.c                   |   7 +-
 17 files changed, 339 insertions(+), 92 deletions(-)

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply

* [PATCH 01/17] KVM: arm/arm64: vgic: Add LPI translation cache definition
From: Marc Zyngier @ 2019-09-09 13:47 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Mark Rutland, kvm, Andre Przywara, Eric Auger, James Morse,
	Zenghui Yu, Alexandru Elisei, kvmarm, linux-arm-kernel
In-Reply-To: <20190909134807.27978-1-maz@kernel.org>

Add the basic data structure that expresses an MSI to LPI
translation as well as the allocation/release hooks.

The size of the cache is arbitrarily defined as 16*nr_vcpus.

Tested-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 include/kvm/arm_vgic.h        |  3 +++
 virt/kvm/arm/vgic/vgic-init.c |  5 ++++
 virt/kvm/arm/vgic/vgic-its.c  | 49 +++++++++++++++++++++++++++++++++++
 virt/kvm/arm/vgic/vgic.h      |  2 ++
 4 files changed, 59 insertions(+)

diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
index 7a30524a80ee..ded50a30e2d5 100644
--- a/include/kvm/arm_vgic.h
+++ b/include/kvm/arm_vgic.h
@@ -249,6 +249,9 @@ struct vgic_dist {
 	struct list_head	lpi_list_head;
 	int			lpi_list_count;
 
+	/* LPI translation cache */
+	struct list_head	lpi_translation_cache;
+
 	/* used by vgic-debug */
 	struct vgic_state_iter *iter;
 
diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c
index bdbc297d06fb..80127ca9269f 100644
--- a/virt/kvm/arm/vgic/vgic-init.c
+++ b/virt/kvm/arm/vgic/vgic-init.c
@@ -53,6 +53,7 @@ void kvm_vgic_early_init(struct kvm *kvm)
 	struct vgic_dist *dist = &kvm->arch.vgic;
 
 	INIT_LIST_HEAD(&dist->lpi_list_head);
+	INIT_LIST_HEAD(&dist->lpi_translation_cache);
 	raw_spin_lock_init(&dist->lpi_list_lock);
 }
 
@@ -294,6 +295,7 @@ int vgic_init(struct kvm *kvm)
 	}
 
 	if (vgic_has_its(kvm)) {
+		vgic_lpi_translation_cache_init(kvm);
 		ret = vgic_v4_init(kvm);
 		if (ret)
 			goto out;
@@ -335,6 +337,9 @@ static void kvm_vgic_dist_destroy(struct kvm *kvm)
 		INIT_LIST_HEAD(&dist->rd_regions);
 	}
 
+	if (vgic_has_its(kvm))
+		vgic_lpi_translation_cache_destroy(kvm);
+
 	if (vgic_supports_direct_msis(kvm))
 		vgic_v4_teardown(kvm);
 }
diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
index 482036612adf..0e5c1519bbe2 100644
--- a/virt/kvm/arm/vgic/vgic-its.c
+++ b/virt/kvm/arm/vgic/vgic-its.c
@@ -138,6 +138,14 @@ struct its_ite {
 	u32 event_id;
 };
 
+struct vgic_translation_cache_entry {
+	struct list_head	entry;
+	phys_addr_t		db;
+	u32			devid;
+	u32			eventid;
+	struct vgic_irq		*irq;
+};
+
 /**
  * struct vgic_its_abi - ITS abi ops and settings
  * @cte_esz: collection table entry size
@@ -1657,6 +1665,45 @@ static int vgic_register_its_iodev(struct kvm *kvm, struct vgic_its *its,
 	return ret;
 }
 
+/* Default is 16 cached LPIs per vcpu */
+#define LPI_DEFAULT_PCPU_CACHE_SIZE	16
+
+void vgic_lpi_translation_cache_init(struct kvm *kvm)
+{
+	struct vgic_dist *dist = &kvm->arch.vgic;
+	unsigned int sz;
+	int i;
+
+	if (!list_empty(&dist->lpi_translation_cache))
+		return;
+
+	sz = atomic_read(&kvm->online_vcpus) * LPI_DEFAULT_PCPU_CACHE_SIZE;
+
+	for (i = 0; i < sz; i++) {
+		struct vgic_translation_cache_entry *cte;
+
+		/* An allocation failure is not fatal */
+		cte = kzalloc(sizeof(*cte), GFP_KERNEL);
+		if (WARN_ON(!cte))
+			break;
+
+		INIT_LIST_HEAD(&cte->entry);
+		list_add(&cte->entry, &dist->lpi_translation_cache);
+	}
+}
+
+void vgic_lpi_translation_cache_destroy(struct kvm *kvm)
+{
+	struct vgic_dist *dist = &kvm->arch.vgic;
+	struct vgic_translation_cache_entry *cte, *tmp;
+
+	list_for_each_entry_safe(cte, tmp,
+				 &dist->lpi_translation_cache, entry) {
+		list_del(&cte->entry);
+		kfree(cte);
+	}
+}
+
 #define INITIAL_BASER_VALUE						  \
 	(GIC_BASER_CACHEABILITY(GITS_BASER, INNER, RaWb)		| \
 	 GIC_BASER_CACHEABILITY(GITS_BASER, OUTER, SameAsInner)		| \
@@ -1685,6 +1732,8 @@ static int vgic_its_create(struct kvm_device *dev, u32 type)
 			kfree(its);
 			return ret;
 		}
+
+		vgic_lpi_translation_cache_init(dev->kvm);
 	}
 
 	mutex_init(&its->its_lock);
diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h
index 797e05004d80..a25b790ffa4e 100644
--- a/virt/kvm/arm/vgic/vgic.h
+++ b/virt/kvm/arm/vgic/vgic.h
@@ -307,6 +307,8 @@ int vgic_copy_lpi_list(struct kvm *kvm, struct kvm_vcpu *vcpu, u32 **intid_ptr);
 int vgic_its_resolve_lpi(struct kvm *kvm, struct vgic_its *its,
 			 u32 devid, u32 eventid, struct vgic_irq **irq);
 struct vgic_its *vgic_msi_to_its(struct kvm *kvm, struct kvm_msi *msi);
+void vgic_lpi_translation_cache_init(struct kvm *kvm);
+void vgic_lpi_translation_cache_destroy(struct kvm *kvm);
 
 bool vgic_supports_direct_msis(struct kvm *kvm);
 int vgic_v4_init(struct kvm *kvm);
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH 02/17] KVM: arm/arm64: vgic: Add __vgic_put_lpi_locked primitive
From: Marc Zyngier @ 2019-09-09 13:47 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Mark Rutland, kvm, Andre Przywara, Eric Auger, James Morse,
	Zenghui Yu, Alexandru Elisei, kvmarm, linux-arm-kernel
In-Reply-To: <20190909134807.27978-1-maz@kernel.org>

Our LPI translation cache needs to be able to drop the refcount
on an LPI whilst already holding the lpi_list_lock.

Let's add a new primitive for this.

Tested-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 virt/kvm/arm/vgic/vgic.c | 26 +++++++++++++++++---------
 virt/kvm/arm/vgic/vgic.h |  1 +
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c
index 13d4b38a94ec..846bb680fd45 100644
--- a/virt/kvm/arm/vgic/vgic.c
+++ b/virt/kvm/arm/vgic/vgic.c
@@ -119,6 +119,22 @@ static void vgic_irq_release(struct kref *ref)
 {
 }
 
+/*
+ * Drop the refcount on the LPI. Must be called with lpi_list_lock held.
+ */
+void __vgic_put_lpi_locked(struct kvm *kvm, struct vgic_irq *irq)
+{
+	struct vgic_dist *dist = &kvm->arch.vgic;
+
+	if (!kref_put(&irq->refcount, vgic_irq_release))
+		return;
+
+	list_del(&irq->lpi_list);
+	dist->lpi_list_count--;
+
+	kfree(irq);
+}
+
 void vgic_put_irq(struct kvm *kvm, struct vgic_irq *irq)
 {
 	struct vgic_dist *dist = &kvm->arch.vgic;
@@ -128,16 +144,8 @@ void vgic_put_irq(struct kvm *kvm, struct vgic_irq *irq)
 		return;
 
 	raw_spin_lock_irqsave(&dist->lpi_list_lock, flags);
-	if (!kref_put(&irq->refcount, vgic_irq_release)) {
-		raw_spin_unlock_irqrestore(&dist->lpi_list_lock, flags);
-		return;
-	};
-
-	list_del(&irq->lpi_list);
-	dist->lpi_list_count--;
+	__vgic_put_lpi_locked(kvm, irq);
 	raw_spin_unlock_irqrestore(&dist->lpi_list_lock, flags);
-
-	kfree(irq);
 }
 
 void vgic_flush_pending_lpis(struct kvm_vcpu *vcpu)
diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h
index a25b790ffa4e..8e9413e317b8 100644
--- a/virt/kvm/arm/vgic/vgic.h
+++ b/virt/kvm/arm/vgic/vgic.h
@@ -161,6 +161,7 @@ vgic_get_mmio_region(struct kvm_vcpu *vcpu, struct vgic_io_device *iodev,
 		     gpa_t addr, int len);
 struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu,
 			      u32 intid);
+void __vgic_put_lpi_locked(struct kvm *kvm, struct vgic_irq *irq);
 void vgic_put_irq(struct kvm *kvm, struct vgic_irq *irq);
 bool vgic_get_phys_line_level(struct vgic_irq *irq);
 void vgic_irq_set_phys_pending(struct vgic_irq *irq, bool pending);
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH 03/17] KVM: arm/arm64: vgic-its: Add MSI-LPI translation cache invalidation
From: Marc Zyngier @ 2019-09-09 13:47 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Mark Rutland, kvm, Andre Przywara, Eric Auger, James Morse,
	Zenghui Yu, Alexandru Elisei, kvmarm, linux-arm-kernel
In-Reply-To: <20190909134807.27978-1-maz@kernel.org>

There's a number of cases where we need to invalidate the caching
of translations, so let's add basic support for that.

Tested-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 virt/kvm/arm/vgic/vgic-its.c | 23 +++++++++++++++++++++++
 virt/kvm/arm/vgic/vgic.h     |  1 +
 2 files changed, 24 insertions(+)

diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
index 0e5c1519bbe2..cc6b5e49a312 100644
--- a/virt/kvm/arm/vgic/vgic-its.c
+++ b/virt/kvm/arm/vgic/vgic-its.c
@@ -535,6 +535,29 @@ static unsigned long vgic_mmio_read_its_idregs(struct kvm *kvm,
 	return 0;
 }
 
+void vgic_its_invalidate_cache(struct kvm *kvm)
+{
+	struct vgic_dist *dist = &kvm->arch.vgic;
+	struct vgic_translation_cache_entry *cte;
+	unsigned long flags;
+
+	raw_spin_lock_irqsave(&dist->lpi_list_lock, flags);
+
+	list_for_each_entry(cte, &dist->lpi_translation_cache, entry) {
+		/*
+		 * If we hit a NULL entry, there is nothing after this
+		 * point.
+		 */
+		if (!cte->irq)
+			break;
+
+		__vgic_put_lpi_locked(kvm, cte->irq);
+		cte->irq = NULL;
+	}
+
+	raw_spin_unlock_irqrestore(&dist->lpi_list_lock, flags);
+}
+
 int vgic_its_resolve_lpi(struct kvm *kvm, struct vgic_its *its,
 			 u32 devid, u32 eventid, struct vgic_irq **irq)
 {
diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h
index 8e9413e317b8..c7fb4da2ab3b 100644
--- a/virt/kvm/arm/vgic/vgic.h
+++ b/virt/kvm/arm/vgic/vgic.h
@@ -310,6 +310,7 @@ int vgic_its_resolve_lpi(struct kvm *kvm, struct vgic_its *its,
 struct vgic_its *vgic_msi_to_its(struct kvm *kvm, struct kvm_msi *msi);
 void vgic_lpi_translation_cache_init(struct kvm *kvm);
 void vgic_lpi_translation_cache_destroy(struct kvm *kvm);
+void vgic_its_invalidate_cache(struct kvm *kvm);
 
 bool vgic_supports_direct_msis(struct kvm *kvm);
 int vgic_v4_init(struct kvm *kvm);
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH 04/17] KVM: arm/arm64: vgic-its: Invalidate MSI-LPI translation cache on specific commands
From: Marc Zyngier @ 2019-09-09 13:47 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Mark Rutland, kvm, Andre Przywara, Eric Auger, James Morse,
	Zenghui Yu, Alexandru Elisei, kvmarm, linux-arm-kernel
In-Reply-To: <20190909134807.27978-1-maz@kernel.org>

The LPI translation cache needs to be discarded when an ITS command
may affect the translation of an LPI (DISCARD, MAPC and MAPD with V=0)
or the routing of an LPI to a redistributor with disabled LPIs (MOVI,
MOVALL).

We decide to perform a full invalidation of the cache, irrespective
of the LPI that is affected. Commands are supposed to be rare enough
that it doesn't matter.

Tested-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 virt/kvm/arm/vgic/vgic-its.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
index cc6b5e49a312..09a179820816 100644
--- a/virt/kvm/arm/vgic/vgic-its.c
+++ b/virt/kvm/arm/vgic/vgic-its.c
@@ -722,6 +722,8 @@ static int vgic_its_cmd_handle_discard(struct kvm *kvm, struct vgic_its *its,
 		 * don't bother here since we clear the ITTE anyway and the
 		 * pending state is a property of the ITTE struct.
 		 */
+		vgic_its_invalidate_cache(kvm);
+
 		its_free_ite(kvm, ite);
 		return 0;
 	}
@@ -757,6 +759,8 @@ static int vgic_its_cmd_handle_movi(struct kvm *kvm, struct vgic_its *its,
 	ite->collection = collection;
 	vcpu = kvm_get_vcpu(kvm, collection->target_addr);
 
+	vgic_its_invalidate_cache(kvm);
+
 	return update_affinity(ite->irq, vcpu);
 }
 
@@ -985,6 +989,8 @@ static void vgic_its_free_device(struct kvm *kvm, struct its_device *device)
 	list_for_each_entry_safe(ite, temp, &device->itt_head, ite_list)
 		its_free_ite(kvm, ite);
 
+	vgic_its_invalidate_cache(kvm);
+
 	list_del(&device->dev_list);
 	kfree(device);
 }
@@ -1090,6 +1096,7 @@ static int vgic_its_cmd_handle_mapc(struct kvm *kvm, struct vgic_its *its,
 
 	if (!valid) {
 		vgic_its_free_collection(its, coll_id);
+		vgic_its_invalidate_cache(kvm);
 	} else {
 		collection = find_collection(its, coll_id);
 
@@ -1238,6 +1245,8 @@ static int vgic_its_cmd_handle_movall(struct kvm *kvm, struct vgic_its *its,
 		vgic_put_irq(kvm, irq);
 	}
 
+	vgic_its_invalidate_cache(kvm);
+
 	kfree(intids);
 	return 0;
 }
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH 05/17] KVM: arm/arm64: vgic-its: Invalidate MSI-LPI translation cache on disabling LPIs
From: Marc Zyngier @ 2019-09-09 13:47 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Mark Rutland, kvm, Andre Przywara, Eric Auger, James Morse,
	Zenghui Yu, Alexandru Elisei, kvmarm, linux-arm-kernel
In-Reply-To: <20190909134807.27978-1-maz@kernel.org>

If a vcpu disables LPIs at its redistributor level, we need to make sure
we won't pend more interrupts. For this, we need to invalidate the LPI
translation cache.

Tested-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 virt/kvm/arm/vgic/vgic-mmio-v3.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c
index c45e2d7e942f..fdcfb7ae4491 100644
--- a/virt/kvm/arm/vgic/vgic-mmio-v3.c
+++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c
@@ -192,8 +192,10 @@ static void vgic_mmio_write_v3r_ctlr(struct kvm_vcpu *vcpu,
 
 	vgic_cpu->lpis_enabled = val & GICR_CTLR_ENABLE_LPIS;
 
-	if (was_enabled && !vgic_cpu->lpis_enabled)
+	if (was_enabled && !vgic_cpu->lpis_enabled) {
 		vgic_flush_pending_lpis(vcpu);
+		vgic_its_invalidate_cache(vcpu->kvm);
+	}
 
 	if (!was_enabled && vgic_cpu->lpis_enabled)
 		vgic_enable_lpis(vcpu);
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH 06/17] KVM: arm/arm64: vgic-its: Invalidate MSI-LPI translation cache on ITS disable
From: Marc Zyngier @ 2019-09-09 13:47 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Mark Rutland, kvm, Andre Przywara, Eric Auger, James Morse,
	Zenghui Yu, Alexandru Elisei, kvmarm, linux-arm-kernel
In-Reply-To: <20190909134807.27978-1-maz@kernel.org>

If an ITS gets disabled, we need to make sure that further interrupts
won't hit in the cache. For that, we invalidate the translation cache
when the ITS is disabled.

Tested-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 virt/kvm/arm/vgic/vgic-its.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
index 09a179820816..05406bd92ce9 100644
--- a/virt/kvm/arm/vgic/vgic-its.c
+++ b/virt/kvm/arm/vgic/vgic-its.c
@@ -1597,6 +1597,8 @@ static void vgic_mmio_write_its_ctlr(struct kvm *kvm, struct vgic_its *its,
 		goto out;
 
 	its->enabled = !!(val & GITS_CTLR_ENABLE);
+	if (!its->enabled)
+		vgic_its_invalidate_cache(kvm);
 
 	/*
 	 * Try to process any pending commands. This function bails out early
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH 07/17] KVM: arm/arm64: vgic-its: Invalidate MSI-LPI translation cache on vgic teardown
From: Marc Zyngier @ 2019-09-09 13:47 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Mark Rutland, kvm, Andre Przywara, Eric Auger, James Morse,
	Zenghui Yu, Alexandru Elisei, kvmarm, linux-arm-kernel
In-Reply-To: <20190909134807.27978-1-maz@kernel.org>

In order to avoid leaking vgic_irq structures on teardown, we need to
drop all references to LPIs before deallocating the cache itself.

This is done by invalidating the cache on vgic teardown.

Tested-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 virt/kvm/arm/vgic/vgic-its.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
index 05406bd92ce9..d3e90a9d0a7a 100644
--- a/virt/kvm/arm/vgic/vgic-its.c
+++ b/virt/kvm/arm/vgic/vgic-its.c
@@ -1731,6 +1731,8 @@ void vgic_lpi_translation_cache_destroy(struct kvm *kvm)
 	struct vgic_dist *dist = &kvm->arch.vgic;
 	struct vgic_translation_cache_entry *cte, *tmp;
 
+	vgic_its_invalidate_cache(kvm);
+
 	list_for_each_entry_safe(cte, tmp,
 				 &dist->lpi_translation_cache, entry) {
 		list_del(&cte->entry);
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH 08/17] KVM: arm/arm64: vgic-its: Cache successful MSI->LPI translation
From: Marc Zyngier @ 2019-09-09 13:47 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Mark Rutland, kvm, Andre Przywara, Eric Auger, James Morse,
	Zenghui Yu, Alexandru Elisei, kvmarm, linux-arm-kernel
In-Reply-To: <20190909134807.27978-1-maz@kernel.org>

On a successful translation, preserve the parameters in the LPI
translation cache. Each translation is reusing the last slot
in the list, naturally evicting the least recently used entry.

Tested-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 virt/kvm/arm/vgic/vgic-its.c | 86 ++++++++++++++++++++++++++++++++++++
 1 file changed, 86 insertions(+)

diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
index d3e90a9d0a7a..e61d3ea0ab40 100644
--- a/virt/kvm/arm/vgic/vgic-its.c
+++ b/virt/kvm/arm/vgic/vgic-its.c
@@ -535,6 +535,90 @@ static unsigned long vgic_mmio_read_its_idregs(struct kvm *kvm,
 	return 0;
 }
 
+static struct vgic_irq *__vgic_its_check_cache(struct vgic_dist *dist,
+					       phys_addr_t db,
+					       u32 devid, u32 eventid)
+{
+	struct vgic_translation_cache_entry *cte;
+
+	list_for_each_entry(cte, &dist->lpi_translation_cache, entry) {
+		/*
+		 * If we hit a NULL entry, there is nothing after this
+		 * point.
+		 */
+		if (!cte->irq)
+			break;
+
+		if (cte->db != db || cte->devid != devid ||
+		    cte->eventid != eventid)
+			continue;
+
+		/*
+		 * Move this entry to the head, as it is the most
+		 * recently used.
+		 */
+		if (!list_is_first(&cte->entry, &dist->lpi_translation_cache))
+			list_move(&cte->entry, &dist->lpi_translation_cache);
+
+		return cte->irq;
+	}
+
+	return NULL;
+}
+
+static void vgic_its_cache_translation(struct kvm *kvm, struct vgic_its *its,
+				       u32 devid, u32 eventid,
+				       struct vgic_irq *irq)
+{
+	struct vgic_dist *dist = &kvm->arch.vgic;
+	struct vgic_translation_cache_entry *cte;
+	unsigned long flags;
+	phys_addr_t db;
+
+	/* Do not cache a directly injected interrupt */
+	if (irq->hw)
+		return;
+
+	raw_spin_lock_irqsave(&dist->lpi_list_lock, flags);
+
+	if (unlikely(list_empty(&dist->lpi_translation_cache)))
+		goto out;
+
+	/*
+	 * We could have raced with another CPU caching the same
+	 * translation behind our back, so let's check it is not in
+	 * already
+	 */
+	db = its->vgic_its_base + GITS_TRANSLATER;
+	if (__vgic_its_check_cache(dist, db, devid, eventid))
+		goto out;
+
+	/* Always reuse the last entry (LRU policy) */
+	cte = list_last_entry(&dist->lpi_translation_cache,
+			      typeof(*cte), entry);
+
+	/*
+	 * Caching the translation implies having an extra reference
+	 * to the interrupt, so drop the potential reference on what
+	 * was in the cache, and increment it on the new interrupt.
+	 */
+	if (cte->irq)
+		__vgic_put_lpi_locked(kvm, cte->irq);
+
+	vgic_get_irq_kref(irq);
+
+	cte->db		= db;
+	cte->devid	= devid;
+	cte->eventid	= eventid;
+	cte->irq	= irq;
+
+	/* Move the new translation to the head of the list */
+	list_move(&cte->entry, &dist->lpi_translation_cache);
+
+out:
+	raw_spin_unlock_irqrestore(&dist->lpi_list_lock, flags);
+}
+
 void vgic_its_invalidate_cache(struct kvm *kvm)
 {
 	struct vgic_dist *dist = &kvm->arch.vgic;
@@ -578,6 +662,8 @@ int vgic_its_resolve_lpi(struct kvm *kvm, struct vgic_its *its,
 	if (!vcpu->arch.vgic_cpu.lpis_enabled)
 		return -EBUSY;
 
+	vgic_its_cache_translation(kvm, its, devid, eventid, ite->irq);
+
 	*irq = ite->irq;
 	return 0;
 }
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH 10/17] KVM: arm/arm64: vgic-irqfd: Implement kvm_arch_set_irq_inatomic
From: Marc Zyngier @ 2019-09-09 13:48 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Mark Rutland, kvm, Andre Przywara, Eric Auger, James Morse,
	Zenghui Yu, Alexandru Elisei, kvmarm, linux-arm-kernel
In-Reply-To: <20190909134807.27978-1-maz@kernel.org>

Now that we have a cache of MSI->LPI translations, it is pretty
easy to implement kvm_arch_set_irq_inatomic (this cache can be
parsed without sleeping).

Hopefully, this will improve some LPI-heavy workloads.

Tested-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 virt/kvm/arm/vgic/vgic-irqfd.c | 36 ++++++++++++++++++++++++++++------
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/virt/kvm/arm/vgic/vgic-irqfd.c b/virt/kvm/arm/vgic/vgic-irqfd.c
index c9304b88e720..d8cdfea5cc96 100644
--- a/virt/kvm/arm/vgic/vgic-irqfd.c
+++ b/virt/kvm/arm/vgic/vgic-irqfd.c
@@ -66,6 +66,15 @@ int kvm_set_routing_entry(struct kvm *kvm,
 	return r;
 }
 
+static void kvm_populate_msi(struct kvm_kernel_irq_routing_entry *e,
+			     struct kvm_msi *msi)
+{
+	msi->address_lo = e->msi.address_lo;
+	msi->address_hi = e->msi.address_hi;
+	msi->data = e->msi.data;
+	msi->flags = e->msi.flags;
+	msi->devid = e->msi.devid;
+}
 /**
  * kvm_set_msi: inject the MSI corresponding to the
  * MSI routing entry
@@ -79,21 +88,36 @@ int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
 {
 	struct kvm_msi msi;
 
-	msi.address_lo = e->msi.address_lo;
-	msi.address_hi = e->msi.address_hi;
-	msi.data = e->msi.data;
-	msi.flags = e->msi.flags;
-	msi.devid = e->msi.devid;
-
 	if (!vgic_has_its(kvm))
 		return -ENODEV;
 
 	if (!level)
 		return -1;
 
+	kvm_populate_msi(e, &msi);
 	return vgic_its_inject_msi(kvm, &msi);
 }
 
+/**
+ * kvm_arch_set_irq_inatomic: fast-path for irqfd injection
+ *
+ * Currently only direct MSI injection is supported.
+ */
+int kvm_arch_set_irq_inatomic(struct kvm_kernel_irq_routing_entry *e,
+			      struct kvm *kvm, int irq_source_id, int level,
+			      bool line_status)
+{
+	if (e->type == KVM_IRQ_ROUTING_MSI && vgic_has_its(kvm) && level) {
+		struct kvm_msi msi;
+
+		kvm_populate_msi(e, &msi);
+		if (!vgic_its_inject_cached_translation(kvm, &msi))
+			return 0;
+	}
+
+	return -EWOULDBLOCK;
+}
+
 int kvm_vgic_setup_default_irq_routing(struct kvm *kvm)
 {
 	struct kvm_irq_routing_entry *entries;
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH 09/17] KVM: arm/arm64: vgic-its: Check the LPI translation cache on MSI injection
From: Marc Zyngier @ 2019-09-09 13:47 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Mark Rutland, kvm, Andre Przywara, Eric Auger, James Morse,
	Zenghui Yu, Alexandru Elisei, kvmarm, linux-arm-kernel
In-Reply-To: <20190909134807.27978-1-maz@kernel.org>

When performing an MSI injection, let's first check if the translation
is already in the cache. If so, let's inject it quickly without
going through the whole translation process.

Tested-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 virt/kvm/arm/vgic/vgic-its.c | 36 ++++++++++++++++++++++++++++++++++++
 virt/kvm/arm/vgic/vgic.h     |  1 +
 2 files changed, 37 insertions(+)

diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
index e61d3ea0ab40..2be6b66b3856 100644
--- a/virt/kvm/arm/vgic/vgic-its.c
+++ b/virt/kvm/arm/vgic/vgic-its.c
@@ -566,6 +566,20 @@ static struct vgic_irq *__vgic_its_check_cache(struct vgic_dist *dist,
 	return NULL;
 }
 
+static struct vgic_irq *vgic_its_check_cache(struct kvm *kvm, phys_addr_t db,
+					     u32 devid, u32 eventid)
+{
+	struct vgic_dist *dist = &kvm->arch.vgic;
+	struct vgic_irq *irq;
+	unsigned long flags;
+
+	raw_spin_lock_irqsave(&dist->lpi_list_lock, flags);
+	irq = __vgic_its_check_cache(dist, db, devid, eventid);
+	raw_spin_unlock_irqrestore(&dist->lpi_list_lock, flags);
+
+	return irq;
+}
+
 static void vgic_its_cache_translation(struct kvm *kvm, struct vgic_its *its,
 				       u32 devid, u32 eventid,
 				       struct vgic_irq *irq)
@@ -725,6 +739,25 @@ static int vgic_its_trigger_msi(struct kvm *kvm, struct vgic_its *its,
 	return 0;
 }
 
+int vgic_its_inject_cached_translation(struct kvm *kvm, struct kvm_msi *msi)
+{
+	struct vgic_irq *irq;
+	unsigned long flags;
+	phys_addr_t db;
+
+	db = (u64)msi->address_hi << 32 | msi->address_lo;
+	irq = vgic_its_check_cache(kvm, db, msi->devid, msi->data);
+
+	if (!irq)
+		return -1;
+
+	raw_spin_lock_irqsave(&irq->irq_lock, flags);
+	irq->pending_latch = true;
+	vgic_queue_irq_unlock(kvm, irq, flags);
+
+	return 0;
+}
+
 /*
  * Queries the KVM IO bus framework to get the ITS pointer from the given
  * doorbell address.
@@ -736,6 +769,9 @@ int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi)
 	struct vgic_its *its;
 	int ret;
 
+	if (!vgic_its_inject_cached_translation(kvm, msi))
+		return 1;
+
 	its = vgic_msi_to_its(kvm, msi);
 	if (IS_ERR(its))
 		return PTR_ERR(its);
diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h
index c7fb4da2ab3b..83066a81b16a 100644
--- a/virt/kvm/arm/vgic/vgic.h
+++ b/virt/kvm/arm/vgic/vgic.h
@@ -308,6 +308,7 @@ int vgic_copy_lpi_list(struct kvm *kvm, struct kvm_vcpu *vcpu, u32 **intid_ptr);
 int vgic_its_resolve_lpi(struct kvm *kvm, struct vgic_its *its,
 			 u32 devid, u32 eventid, struct vgic_irq **irq);
 struct vgic_its *vgic_msi_to_its(struct kvm *kvm, struct kvm_msi *msi);
+int vgic_its_inject_cached_translation(struct kvm *kvm, struct kvm_msi *msi);
 void vgic_lpi_translation_cache_init(struct kvm *kvm);
 void vgic_lpi_translation_cache_destroy(struct kvm *kvm);
 void vgic_its_invalidate_cache(struct kvm *kvm);
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH 11/17] arm64/kvm: Remove VMID rollover I-cache maintenance
From: Marc Zyngier @ 2019-09-09 13:48 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Mark Rutland, kvm, Andre Przywara, Eric Auger, James Morse,
	Zenghui Yu, Alexandru Elisei, kvmarm, linux-arm-kernel
In-Reply-To: <20190909134807.27978-1-maz@kernel.org>

From: Mark Rutland <mark.rutland@arm.com>

For VPIPT I-caches, we need I-cache maintenance on VMID rollover to
avoid an ABA problem. Consider a single vCPU VM, with a pinned stage-2,
running with an idmap VA->IPA and idmap IPA->PA. If we don't do
maintenance on rollover:

        // VMID A
        Writes insn X to PA 0xF
        Invalidates PA 0xF (for VMID A)

        I$ contains [{A,F}->X]

        [VMID ROLLOVER]

        // VMID B
        Writes insn Y to PA 0xF
        Invalidates PA 0xF (for VMID B)

        I$ contains [{A,F}->X, {B,F}->Y]

        [VMID ROLLOVER]

        // VMID A
        I$ contains [{A,F}->X, {B,F}->Y]

        Unexpectedly hits stale I$ line {A,F}->X.

However, for PIPT and VIPT I-caches, the VMID doesn't affect lookup or
constrain maintenance. Given the VMID doesn't affect PIPT and VIPT
I-caches, and given VMID rollover is independent of changes to stage-2
mappings, I-cache maintenance cannot be necessary on VMID rollover for
PIPT or VIPT I-caches.

This patch removes the maintenance on rollover for VIPT and PIPT
I-caches. At the same time, the unnecessary colons are removed from the
asm statement to make it more legible.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Christoffer Dall <christoffer.dall@arm.com>
Reviewed-by: James Morse <james.morse@arm.com>
Cc: Julien Thierry <julien.thierry.kdev@gmail.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: kvmarm@lists.cs.columbia.edu
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 arch/arm64/kvm/hyp/tlb.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kvm/hyp/tlb.c b/arch/arm64/kvm/hyp/tlb.c
index d49a14497715..c466060b76d6 100644
--- a/arch/arm64/kvm/hyp/tlb.c
+++ b/arch/arm64/kvm/hyp/tlb.c
@@ -193,6 +193,18 @@ void __hyp_text __kvm_flush_vm_context(void)
 {
 	dsb(ishst);
 	__tlbi(alle1is);
-	asm volatile("ic ialluis" : : );
+
+	/*
+	 * VIPT and PIPT caches are not affected by VMID, so no maintenance
+	 * is necessary across a VMID rollover.
+	 *
+	 * VPIPT caches constrain lookup and maintenance to the active VMID,
+	 * so we need to invalidate lines with a stale VMID to avoid an ABA
+	 * race after multiple rollovers.
+	 *
+	 */
+	if (icache_is_vpipt())
+		asm volatile("ic ialluis");
+
 	dsb(ish);
 }
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH 12/17] KVM: arm/arm64: vgic: Make function comments match function declarations
From: Marc Zyngier @ 2019-09-09 13:48 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Mark Rutland, kvm, Andre Przywara, Eric Auger, James Morse,
	Zenghui Yu, Alexandru Elisei, kvmarm, linux-arm-kernel
In-Reply-To: <20190909134807.27978-1-maz@kernel.org>

From: Alexandru Elisei <alexandru.elisei@arm.com>

Since commit 503a62862e8f ("KVM: arm/arm64: vgic: Rely on the GIC driver to
parse the firmware tables"), the vgic_v{2,3}_probe functions stopped using
a DT node. Commit 909777324588 ("KVM: arm/arm64: vgic-new: vgic_init:
implement kvm_vgic_hyp_init") changed the functions again, and now they
require exactly one argument, a struct gic_kvm_info populated by the GIC
driver. Unfortunately the comments regressed and state that a DT node is
used instead. Change the function comments to reflect the current
prototypes.

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 virt/kvm/arm/vgic/vgic-v2.c | 7 ++++---
 virt/kvm/arm/vgic/vgic-v3.c | 7 ++++---
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/virt/kvm/arm/vgic/vgic-v2.c b/virt/kvm/arm/vgic/vgic-v2.c
index 96aab77d0471..e67945020b45 100644
--- a/virt/kvm/arm/vgic/vgic-v2.c
+++ b/virt/kvm/arm/vgic/vgic-v2.c
@@ -354,10 +354,11 @@ int vgic_v2_map_resources(struct kvm *kvm)
 DEFINE_STATIC_KEY_FALSE(vgic_v2_cpuif_trap);
 
 /**
- * vgic_v2_probe - probe for a GICv2 compatible interrupt controller in DT
- * @node:	pointer to the DT node
+ * vgic_v2_probe - probe for a VGICv2 compatible interrupt controller
+ * @info:	pointer to the GIC description
  *
- * Returns 0 if a GICv2 has been found, returns an error code otherwise
+ * Returns 0 if the VGICv2 has been probed successfully, returns an error code
+ * otherwise
  */
 int vgic_v2_probe(const struct gic_kvm_info *info)
 {
diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c
index 0c653a1e5215..30955d162a01 100644
--- a/virt/kvm/arm/vgic/vgic-v3.c
+++ b/virt/kvm/arm/vgic/vgic-v3.c
@@ -570,10 +570,11 @@ static int __init early_gicv4_enable(char *buf)
 early_param("kvm-arm.vgic_v4_enable", early_gicv4_enable);
 
 /**
- * vgic_v3_probe - probe for a GICv3 compatible interrupt controller in DT
- * @node:	pointer to the DT node
+ * vgic_v3_probe - probe for a VGICv3 compatible interrupt controller
+ * @info:	pointer to the GIC description
  *
- * Returns 0 if a GICv3 has been found, returns an error code otherwise
+ * Returns 0 if the VGICv3 has been probed successfully, returns an error code
+ * otherwise
  */
 int vgic_v3_probe(const struct gic_kvm_info *info)
 {
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH 13/17] KVM: Call kvm_arch_vcpu_blocking early into the blocking sequence
From: Marc Zyngier @ 2019-09-09 13:48 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Mark Rutland, kvm, Andre Przywara, Eric Auger, James Morse,
	Zenghui Yu, Alexandru Elisei, kvmarm, linux-arm-kernel
In-Reply-To: <20190909134807.27978-1-maz@kernel.org>

When a vpcu is about to block by calling kvm_vcpu_block, we call
back into the arch code to allow any form of synchronization that
may be required at this point (SVN stops the AVIC, ARM synchronises
the VMCR and enables GICv4 doorbells). But this synchronization
comes in quite late, as we've potentially waited for halt_poll_ns
to expire.

Instead, let's move kvm_arch_vcpu_blocking() to the beginning of
kvm_vcpu_block(), which on ARM has several benefits:

- VMCR gets synchronised early, meaning that any interrupt delivered
  during the polling window will be evaluated with the correct guest
  PMR
- GICv4 doorbells are enabled, which means that any guest interrupt
  directly injected during that window will be immediately recognised

Tang Nianyao ran some tests on a GICv4 machine to evaluate such
change, and reported up to a 10% improvement for netperf:

<quote>
	netperf result:
	D06 as server, intel 8180 server as client
	with change:
	package 512 bytes - 5500 Mbits/s
	package 64 bytes - 760 Mbits/s
	without change:
	package 512 bytes - 5000 Mbits/s
	package 64 bytes - 710 Mbits/s
</quote>

Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 virt/kvm/kvm_main.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index c6a91b044d8d..e6de3159e682 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2321,6 +2321,8 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
 	bool waited = false;
 	u64 block_ns;
 
+	kvm_arch_vcpu_blocking(vcpu);
+
 	start = cur = ktime_get();
 	if (vcpu->halt_poll_ns && !kvm_arch_no_poll(vcpu)) {
 		ktime_t stop = ktime_add_ns(ktime_get(), vcpu->halt_poll_ns);
@@ -2341,8 +2343,6 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
 		} while (single_task_running() && ktime_before(cur, stop));
 	}
 
-	kvm_arch_vcpu_blocking(vcpu);
-
 	for (;;) {
 		prepare_to_swait_exclusive(&vcpu->wq, &wait, TASK_INTERRUPTIBLE);
 
@@ -2355,9 +2355,8 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
 
 	finish_swait(&vcpu->wq, &wait);
 	cur = ktime_get();
-
-	kvm_arch_vcpu_unblocking(vcpu);
 out:
+	kvm_arch_vcpu_unblocking(vcpu);
 	block_ns = ktime_to_ns(cur) - ktime_to_ns(start);
 
 	if (!vcpu_valid_wakeup(vcpu))
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH 14/17] KVM: arm/arm64: vgic: Remove spurious semicolons
From: Marc Zyngier @ 2019-09-09 13:48 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Mark Rutland, kvm, Andre Przywara, Eric Auger, James Morse,
	Zenghui Yu, Alexandru Elisei, kvmarm, linux-arm-kernel
In-Reply-To: <20190909134807.27978-1-maz@kernel.org>

Detected by Coccinelle (and Will Deacon) using
scripts/coccinelle/misc/semicolon.cocci.

Reported-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 virt/kvm/arm/vgic/vgic-init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c
index 80127ca9269f..9175bfd83263 100644
--- a/virt/kvm/arm/vgic/vgic-init.c
+++ b/virt/kvm/arm/vgic/vgic-init.c
@@ -510,7 +510,7 @@ int kvm_vgic_hyp_init(void)
 		break;
 	default:
 		ret = -ENODEV;
-	};
+	}
 
 	if (ret)
 		return ret;
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH 15/17] KVM: arm/arm64: vgic: Use a single IO device per redistributor
From: Marc Zyngier @ 2019-09-09 13:48 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Mark Rutland, kvm, Andre Przywara, Eric Auger, James Morse,
	Zenghui Yu, Alexandru Elisei, kvmarm, linux-arm-kernel
In-Reply-To: <20190909134807.27978-1-maz@kernel.org>

From: Eric Auger <eric.auger@redhat.com>

At the moment we use 2 IO devices per GICv3 redistributor: one
one for the RD_base frame and one for the SGI_base frame.

Instead we can use a single IO device per redistributor (the 2
frames are contiguous). This saves slots on the KVM_MMIO_BUS
which is currently limited to NR_IOBUS_DEVS (1000).

This change allows to instantiate up to 512 redistributors and may
speed the guest boot with a large number of VCPUs.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 include/kvm/arm_vgic.h           |  1 -
 virt/kvm/arm/vgic/vgic-init.c    |  1 -
 virt/kvm/arm/vgic/vgic-mmio-v3.c | 81 ++++++++++----------------------
 3 files changed, 24 insertions(+), 59 deletions(-)

diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
index ded50a30e2d5..af4f09c02bf1 100644
--- a/include/kvm/arm_vgic.h
+++ b/include/kvm/arm_vgic.h
@@ -314,7 +314,6 @@ struct vgic_cpu {
 	 * parts of the redistributor.
 	 */
 	struct vgic_io_device	rd_iodev;
-	struct vgic_io_device	sgi_iodev;
 	struct vgic_redist_region *rdreg;
 
 	/* Contains the attributes and gpa of the LPI pending tables. */
diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c
index 9175bfd83263..958e2f0d2207 100644
--- a/virt/kvm/arm/vgic/vgic-init.c
+++ b/virt/kvm/arm/vgic/vgic-init.c
@@ -193,7 +193,6 @@ int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu)
 	int i;
 
 	vgic_cpu->rd_iodev.base_addr = VGIC_ADDR_UNDEF;
-	vgic_cpu->sgi_iodev.base_addr = VGIC_ADDR_UNDEF;
 
 	INIT_LIST_HEAD(&vgic_cpu->ap_list_head);
 	raw_spin_lock_init(&vgic_cpu->ap_list_lock);
diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c
index fdcfb7ae4491..7dfd15dbb308 100644
--- a/virt/kvm/arm/vgic/vgic-mmio-v3.c
+++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c
@@ -517,7 +517,8 @@ static const struct vgic_register_region vgic_v3_dist_registers[] = {
 		VGIC_ACCESS_32bit),
 };
 
-static const struct vgic_register_region vgic_v3_rdbase_registers[] = {
+static const struct vgic_register_region vgic_v3_rd_registers[] = {
+	/* RD_base registers */
 	REGISTER_DESC_WITH_LENGTH(GICR_CTLR,
 		vgic_mmio_read_v3r_ctlr, vgic_mmio_write_v3r_ctlr, 4,
 		VGIC_ACCESS_32bit),
@@ -542,44 +543,42 @@ static const struct vgic_register_region vgic_v3_rdbase_registers[] = {
 	REGISTER_DESC_WITH_LENGTH(GICR_IDREGS,
 		vgic_mmio_read_v3_idregs, vgic_mmio_write_wi, 48,
 		VGIC_ACCESS_32bit),
-};
-
-static const struct vgic_register_region vgic_v3_sgibase_registers[] = {
-	REGISTER_DESC_WITH_LENGTH(GICR_IGROUPR0,
+	/* SGI_base registers */
+	REGISTER_DESC_WITH_LENGTH(SZ_64K + GICR_IGROUPR0,
 		vgic_mmio_read_group, vgic_mmio_write_group, 4,
 		VGIC_ACCESS_32bit),
-	REGISTER_DESC_WITH_LENGTH(GICR_ISENABLER0,
+	REGISTER_DESC_WITH_LENGTH(SZ_64K + GICR_ISENABLER0,
 		vgic_mmio_read_enable, vgic_mmio_write_senable, 4,
 		VGIC_ACCESS_32bit),
-	REGISTER_DESC_WITH_LENGTH(GICR_ICENABLER0,
+	REGISTER_DESC_WITH_LENGTH(SZ_64K + GICR_ICENABLER0,
 		vgic_mmio_read_enable, vgic_mmio_write_cenable, 4,
 		VGIC_ACCESS_32bit),
-	REGISTER_DESC_WITH_LENGTH_UACCESS(GICR_ISPENDR0,
+	REGISTER_DESC_WITH_LENGTH_UACCESS(SZ_64K + GICR_ISPENDR0,
 		vgic_mmio_read_pending, vgic_mmio_write_spending,
 		vgic_v3_uaccess_read_pending, vgic_v3_uaccess_write_pending, 4,
 		VGIC_ACCESS_32bit),
-	REGISTER_DESC_WITH_LENGTH_UACCESS(GICR_ICPENDR0,
+	REGISTER_DESC_WITH_LENGTH_UACCESS(SZ_64K + GICR_ICPENDR0,
 		vgic_mmio_read_pending, vgic_mmio_write_cpending,
 		vgic_mmio_read_raz, vgic_mmio_uaccess_write_wi, 4,
 		VGIC_ACCESS_32bit),
-	REGISTER_DESC_WITH_LENGTH_UACCESS(GICR_ISACTIVER0,
+	REGISTER_DESC_WITH_LENGTH_UACCESS(SZ_64K + GICR_ISACTIVER0,
 		vgic_mmio_read_active, vgic_mmio_write_sactive,
 		NULL, vgic_mmio_uaccess_write_sactive,
 		4, VGIC_ACCESS_32bit),
-	REGISTER_DESC_WITH_LENGTH_UACCESS(GICR_ICACTIVER0,
+	REGISTER_DESC_WITH_LENGTH_UACCESS(SZ_64K + GICR_ICACTIVER0,
 		vgic_mmio_read_active, vgic_mmio_write_cactive,
 		NULL, vgic_mmio_uaccess_write_cactive,
 		4, VGIC_ACCESS_32bit),
-	REGISTER_DESC_WITH_LENGTH(GICR_IPRIORITYR0,
+	REGISTER_DESC_WITH_LENGTH(SZ_64K + GICR_IPRIORITYR0,
 		vgic_mmio_read_priority, vgic_mmio_write_priority, 32,
 		VGIC_ACCESS_32bit | VGIC_ACCESS_8bit),
-	REGISTER_DESC_WITH_LENGTH(GICR_ICFGR0,
+	REGISTER_DESC_WITH_LENGTH(SZ_64K + GICR_ICFGR0,
 		vgic_mmio_read_config, vgic_mmio_write_config, 8,
 		VGIC_ACCESS_32bit),
-	REGISTER_DESC_WITH_LENGTH(GICR_IGRPMODR0,
+	REGISTER_DESC_WITH_LENGTH(SZ_64K + GICR_IGRPMODR0,
 		vgic_mmio_read_raz, vgic_mmio_write_wi, 4,
 		VGIC_ACCESS_32bit),
-	REGISTER_DESC_WITH_LENGTH(GICR_NSACR,
+	REGISTER_DESC_WITH_LENGTH(SZ_64K + GICR_NSACR,
 		vgic_mmio_read_raz, vgic_mmio_write_wi, 4,
 		VGIC_ACCESS_32bit),
 };
@@ -609,9 +608,8 @@ int vgic_register_redist_iodev(struct kvm_vcpu *vcpu)
 	struct vgic_dist *vgic = &kvm->arch.vgic;
 	struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
 	struct vgic_io_device *rd_dev = &vcpu->arch.vgic_cpu.rd_iodev;
-	struct vgic_io_device *sgi_dev = &vcpu->arch.vgic_cpu.sgi_iodev;
 	struct vgic_redist_region *rdreg;
-	gpa_t rd_base, sgi_base;
+	gpa_t rd_base;
 	int ret;
 
 	if (!IS_VGIC_ADDR_UNDEF(vgic_cpu->rd_iodev.base_addr))
@@ -633,52 +631,31 @@ int vgic_register_redist_iodev(struct kvm_vcpu *vcpu)
 	vgic_cpu->rdreg = rdreg;
 
 	rd_base = rdreg->base + rdreg->free_index * KVM_VGIC_V3_REDIST_SIZE;
-	sgi_base = rd_base + SZ_64K;
 
 	kvm_iodevice_init(&rd_dev->dev, &kvm_io_gic_ops);
 	rd_dev->base_addr = rd_base;
 	rd_dev->iodev_type = IODEV_REDIST;
-	rd_dev->regions = vgic_v3_rdbase_registers;
-	rd_dev->nr_regions = ARRAY_SIZE(vgic_v3_rdbase_registers);
+	rd_dev->regions = vgic_v3_rd_registers;
+	rd_dev->nr_regions = ARRAY_SIZE(vgic_v3_rd_registers);
 	rd_dev->redist_vcpu = vcpu;
 
 	mutex_lock(&kvm->slots_lock);
 	ret = kvm_io_bus_register_dev(kvm, KVM_MMIO_BUS, rd_base,
-				      SZ_64K, &rd_dev->dev);
+				      2 * SZ_64K, &rd_dev->dev);
 	mutex_unlock(&kvm->slots_lock);
 
 	if (ret)
 		return ret;
 
-	kvm_iodevice_init(&sgi_dev->dev, &kvm_io_gic_ops);
-	sgi_dev->base_addr = sgi_base;
-	sgi_dev->iodev_type = IODEV_REDIST;
-	sgi_dev->regions = vgic_v3_sgibase_registers;
-	sgi_dev->nr_regions = ARRAY_SIZE(vgic_v3_sgibase_registers);
-	sgi_dev->redist_vcpu = vcpu;
-
-	mutex_lock(&kvm->slots_lock);
-	ret = kvm_io_bus_register_dev(kvm, KVM_MMIO_BUS, sgi_base,
-				      SZ_64K, &sgi_dev->dev);
-	if (ret) {
-		kvm_io_bus_unregister_dev(kvm, KVM_MMIO_BUS,
-					  &rd_dev->dev);
-		goto out;
-	}
-
 	rdreg->free_index++;
-out:
-	mutex_unlock(&kvm->slots_lock);
-	return ret;
+	return 0;
 }
 
 static void vgic_unregister_redist_iodev(struct kvm_vcpu *vcpu)
 {
 	struct vgic_io_device *rd_dev = &vcpu->arch.vgic_cpu.rd_iodev;
-	struct vgic_io_device *sgi_dev = &vcpu->arch.vgic_cpu.sgi_iodev;
 
 	kvm_io_bus_unregister_dev(vcpu->kvm, KVM_MMIO_BUS, &rd_dev->dev);
-	kvm_io_bus_unregister_dev(vcpu->kvm, KVM_MMIO_BUS, &sgi_dev->dev);
 }
 
 static int vgic_register_all_redist_iodevs(struct kvm *kvm)
@@ -828,8 +805,8 @@ int vgic_v3_has_attr_regs(struct kvm_device *dev, struct kvm_device_attr *attr)
 		iodev.base_addr = 0;
 		break;
 	case KVM_DEV_ARM_VGIC_GRP_REDIST_REGS:{
-		iodev.regions = vgic_v3_rdbase_registers;
-		iodev.nr_regions = ARRAY_SIZE(vgic_v3_rdbase_registers);
+		iodev.regions = vgic_v3_rd_registers;
+		iodev.nr_regions = ARRAY_SIZE(vgic_v3_rd_registers);
 		iodev.base_addr = 0;
 		break;
 	}
@@ -987,21 +964,11 @@ int vgic_v3_redist_uaccess(struct kvm_vcpu *vcpu, bool is_write,
 			   int offset, u32 *val)
 {
 	struct vgic_io_device rd_dev = {
-		.regions = vgic_v3_rdbase_registers,
-		.nr_regions = ARRAY_SIZE(vgic_v3_rdbase_registers),
+		.regions = vgic_v3_rd_registers,
+		.nr_regions = ARRAY_SIZE(vgic_v3_rd_registers),
 	};
 
-	struct vgic_io_device sgi_dev = {
-		.regions = vgic_v3_sgibase_registers,
-		.nr_regions = ARRAY_SIZE(vgic_v3_sgibase_registers),
-	};
-
-	/* SGI_base is the next 64K frame after RD_base */
-	if (offset >= SZ_64K)
-		return vgic_uaccess(vcpu, &sgi_dev, is_write, offset - SZ_64K,
-				    val);
-	else
-		return vgic_uaccess(vcpu, &rd_dev, is_write, offset, val);
+	return vgic_uaccess(vcpu, &rd_dev, is_write, offset, val);
 }
 
 int vgic_v3_line_level_info_uaccess(struct kvm_vcpu *vcpu, bool is_write,
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related

* [PATCH 16/17] arm64: KVM: Device mappings should be execute-never
From: Marc Zyngier @ 2019-09-09 13:48 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Mark Rutland, kvm, Andre Przywara, Eric Auger, James Morse,
	Zenghui Yu, Alexandru Elisei, kvmarm, linux-arm-kernel
In-Reply-To: <20190909134807.27978-1-maz@kernel.org>

From: James Morse <james.morse@arm.com>

Since commit 2f6ea23f63cca ("arm64: KVM: Avoid marking pages as XN in
Stage-2 if CTR_EL0.DIC is set"), KVM has stopped marking normal memory
as execute-never at stage2 when the system supports D->I Coherency at
the PoU. This avoids KVM taking a trap when the page is first executed,
in order to clean it to PoU.

The patch that added this change also wrapped PAGE_S2_DEVICE mappings
up in this too. The upshot is, if your CPU caches support DIC ...
you can execute devices.

Revert the PAGE_S2_DEVICE change so PTE_S2_XN is always used
directly.

Fixes: 2f6ea23f63cca ("arm64: KVM: Avoid marking pages as XN in Stage-2 if CTR_EL0.DIC is set")
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 arch/arm64/include/asm/pgtable-prot.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/pgtable-prot.h b/arch/arm64/include/asm/pgtable-prot.h
index 92d2e9f28f28..9a21b84536f2 100644
--- a/arch/arm64/include/asm/pgtable-prot.h
+++ b/arch/arm64/include/asm/pgtable-prot.h
@@ -77,7 +77,7 @@
 	})
 
 #define PAGE_S2			__pgprot(_PROT_DEFAULT | PAGE_S2_MEMATTR(NORMAL) | PTE_S2_RDONLY | PAGE_S2_XN)
-#define PAGE_S2_DEVICE		__pgprot(_PROT_DEFAULT | PAGE_S2_MEMATTR(DEVICE_nGnRE) | PTE_S2_RDONLY | PAGE_S2_XN)
+#define PAGE_S2_DEVICE		__pgprot(_PROT_DEFAULT | PAGE_S2_MEMATTR(DEVICE_nGnRE) | PTE_S2_RDONLY | PTE_S2_XN)
 
 #define PAGE_NONE		__pgprot(((_PAGE_DEFAULT) & ~PTE_VALID) | PTE_PROT_NONE | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_UXN)
 #define PAGE_SHARED		__pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_PXN | PTE_UXN | PTE_WRITE)
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox