Linux IOMMU Development
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Sam Protsenko <semen.protsenko@linaro.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Janghyuck Kim <janghyuck.kim@samsung.com>,
	Cho KyongHo <pullip.cho@samsung.com>,
	Daniel Mentz <danielmentz@google.com>,
	David Virag <virag.david003@gmail.com>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 7/7] iommu/exynos: Enable default VM instance on SysMMU v7
Date: Tue, 12 Jul 2022 17:53:42 +0200	[thread overview]
Message-ID: <a545127d-1d9d-79c9-e38a-0e9edd98df36@samsung.com> (raw)
In-Reply-To: <20220710230603.13526-8-semen.protsenko@linaro.org>

On 11.07.2022 01:06, Sam Protsenko wrote:
> In order to enable SysMMU v7 with VM register layout, at least the
> default VM instance (n=0) must be enabled, in addition to enabling the
> SysMMU itself. To do so, add corresponding write to MMU_CTRL_VM[0]
> register, before writing to MMU_CTRL register.
>
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
> Changes in v2:
>    - Extracted VM enabling code to the separate function
>    - Used new SysMMU read/write functions to access the registers
>
>   drivers/iommu/exynos-iommu.c | 24 ++++++++++++++++++++----
>   1 file changed, 20 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
> index 64bf3331064f..2b333e137f57 100644
> --- a/drivers/iommu/exynos-iommu.c
> +++ b/drivers/iommu/exynos-iommu.c
> @@ -135,6 +135,8 @@ static u32 lv2ent_offset(sysmmu_iova_t iova)
>   #define CFG_SYSSEL	(1 << 22) /* System MMU 3.2 only */
>   #define CFG_FLPDCACHE	(1 << 20) /* System MMU 3.2+ only */
>   
> +#define CTRL_VM_ENABLE			BIT(0)
> +#define CTRL_VM_FAULT_MODE_STALL	BIT(3)
>   #define CAPA0_CAPA1_EXIST		BIT(11)
>   #define CAPA1_VCR_ENABLED		BIT(14)
>   
> @@ -183,6 +185,7 @@ enum {
>   	IDX_FLUSH_END,
>   	IDX_INT_STATUS,
>   	IDX_INT_CLEAR,
> +	IDX_CTRL_VM,
>   	MAX_REG_IDX
>   };
>   
> @@ -196,22 +199,22 @@ static const unsigned int sysmmu_regs[MAX_REG_SET][MAX_REG_IDX] = {
>   	/* SysMMU v1..v3 */
>   	{
>   		0x00, 0x04, 0x08, 0x14, 0x0c, 0x10, 0x1, 0x1, 0x1,
> -		0x18, 0x1c,
> +		0x18, 0x1c, 0x1,
>   	},
>   	/* SysMMU v5 */
>   	{
>   		0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x20, 0x24,
> -		0x60, 0x64,
> +		0x60, 0x64, 0x1,
>   	},
>   	/* SysMMU v7: Default register set (non-VM) */
>   	{
>   		0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x20, 0x24,
> -		0x60, 0x64,
> +		0x60, 0x64, 0x1,
>   	},
>   	/* SysMMU v7: VM capable register set */
>   	{
>   		0x00, 0x04, 0x08, 0x800c, 0x8010, 0x8014, 0x8018, 0x8020,
> -		0x8024, 0x60, 0x64,
> +		0x8024, 0x60, 0x64, 0x8000,
>   	},
>   };
>   
> @@ -567,6 +570,18 @@ static void __sysmmu_init_config(struct sysmmu_drvdata *data)
>   	sysmmu_write(data, IDX_CFG, cfg);
>   }
>   
> +static void __sysmmu_enable_vid(struct sysmmu_drvdata *data)
> +{
> +	u32 ctrl;
> +
> +	if (MMU_MAJ_VER(data->version) < 7 || !data->has_vcr)
> +		return;
> +
> +	ctrl = sysmmu_read(data, IDX_CTRL_VM);
> +	ctrl |= CTRL_VM_ENABLE | CTRL_VM_FAULT_MODE_STALL;
> +	sysmmu_write(data, IDX_CTRL_VM, ctrl);
> +}
> +
>   static void __sysmmu_enable(struct sysmmu_drvdata *data)
>   {
>   	unsigned long flags;
> @@ -577,6 +592,7 @@ static void __sysmmu_enable(struct sysmmu_drvdata *data)
>   	sysmmu_write(data, IDX_CTRL, CTRL_BLOCK);
>   	__sysmmu_init_config(data);
>   	__sysmmu_set_ptbase(data, data->pgtable);
> +	__sysmmu_enable_vid(data);
>   	sysmmu_write(data, IDX_CTRL, CTRL_ENABLE);
>   	data->active = true;
>   	spin_unlock_irqrestore(&data->lock, flags);

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


      reply	other threads:[~2022-07-12 15:53 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-10 23:05 [PATCH v2 0/7] iommu/exynos: Add basic support for SysMMU v7 Sam Protsenko
2022-07-10 23:05 ` [PATCH v2 1/7] iommu/exynos: Reuse SysMMU constants for page size and order Sam Protsenko
2022-07-12 15:39   ` Marek Szyprowski
2022-07-12 16:19   ` Krzysztof Kozlowski
2022-07-10 23:05 ` [PATCH v2 2/7] iommu/exynos: Handle failed IOMMU device registration properly Sam Protsenko
2022-07-12 15:40   ` Marek Szyprowski
2022-07-12 16:20   ` Krzysztof Kozlowski
2022-07-10 23:05 ` [PATCH v2 3/7] iommu/exynos: Set correct dma mask for SysMMU v5+ Sam Protsenko
2022-07-12 16:21   ` Krzysztof Kozlowski
2022-07-10 23:06 ` [PATCH v2 4/7] iommu/exynos: Use lookup based approach to access registers Sam Protsenko
2022-07-12 15:43   ` Marek Szyprowski
2022-07-12 16:24   ` Robin Murphy
2022-07-14 13:11     ` Sam Protsenko
2022-07-12 16:52   ` Krzysztof Kozlowski
2022-07-14 13:15     ` Sam Protsenko
2022-07-10 23:06 ` [PATCH v2 5/7] iommu/exynos: Check if SysMMU v7 has VM registers Sam Protsenko
2022-07-12 15:47   ` Marek Szyprowski
2022-07-14 13:25     ` Sam Protsenko
2022-07-10 23:06 ` [PATCH v2 6/7] iommu/exynos: Add SysMMU v7 register sets Sam Protsenko
2022-07-12 17:00   ` Robin Murphy
2022-07-14 13:57     ` Sam Protsenko
2022-07-10 23:06 ` [PATCH v2 7/7] iommu/exynos: Enable default VM instance on SysMMU v7 Sam Protsenko
2022-07-12 15:53   ` Marek Szyprowski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a545127d-1d9d-79c9-e38a-0e9edd98df36@samsung.com \
    --to=m.szyprowski@samsung.com \
    --cc=danielmentz@google.com \
    --cc=iommu@lists.linux.dev \
    --cc=janghyuck.kim@samsung.com \
    --cc=joro@8bytes.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=pullip.cho@samsung.com \
    --cc=robin.murphy@arm.com \
    --cc=semen.protsenko@linaro.org \
    --cc=sumit.semwal@linaro.org \
    --cc=virag.david003@gmail.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox