All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Baolu Lu <baolu.lu@linux.intel.com>
To: Tomasz Jeznach <tjeznach@rivosinc.com>,
	Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Paul Walmsley <paul.walmsley@sifive.com>
Cc: baolu.lu@linux.intel.com, Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Anup Patel <apatel@ventanamicro.com>,
	Sunil V L <sunilvl@ventanamicro.com>,
	Nick Kossifidis <mick@ics.forth.gr>,
	Sebastien Boeuf <seb@rivosinc.com>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	devicetree@vger.kernel.org, iommu@lists.linux.dev,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux@rivosinc.com
Subject: Re: [PATCH v3 5/7] iommu/riscv: Device directory management.
Date: Thu, 2 May 2024 09:38:54 +0800	[thread overview]
Message-ID: <104358de-ea86-4e25-8942-ba285d6f317b@linux.intel.com> (raw)
In-Reply-To: <ce3b82a20db0b776685269674ce9b7a926d5680d.1714494653.git.tjeznach@rivosinc.com>

On 5/1/24 4:01 AM, Tomasz Jeznach wrote:
> @@ -128,6 +489,7 @@ void riscv_iommu_remove(struct riscv_iommu_device *iommu)
>   {
>   	iommu_device_unregister(&iommu->iommu);
>   	iommu_device_sysfs_remove(&iommu->iommu);
> +	riscv_iommu_iodir_set_mode(iommu, RISCV_IOMMU_DDTP_MODE_OFF);
>   }
>   
>   int riscv_iommu_init(struct riscv_iommu_device *iommu)
> @@ -138,12 +500,13 @@ int riscv_iommu_init(struct riscv_iommu_device *iommu)
>   	if (rc)
>   		return dev_err_probe(iommu->dev, rc, "unexpected device state\n");
>   
> -	/*
> -	 * Placeholder for a complete IOMMU device initialization.
> -	 * For now, only bare minimum: enable global identity mapping mode and register sysfs.
> -	 */
> -	riscv_iommu_writeq(iommu, RISCV_IOMMU_REG_DDTP,
> -			   FIELD_PREP(RISCV_IOMMU_DDTP_MODE, RISCV_IOMMU_DDTP_MODE_BARE));
> +	rc = riscv_iommu_iodir_alloc(iommu);
> +	if (rc)
> +		goto err_init;
> +
> +	rc = riscv_iommu_iodir_set_mode(iommu, RISCV_IOMMU_DDTP_MODE_MAX);
> +	if (rc)
> +		goto err_init;
>   
>   	rc = iommu_device_sysfs_add(&iommu->iommu, NULL, NULL, "riscv-iommu@%s",
>   				    dev_name(iommu->dev));

The device directory root page might be allocated in
riscv_iommu_iodir_alloc(),

+	if (!iommu->ddt_root) {
+		iommu->ddt_root = riscv_iommu_get_pages(iommu, 0);
+		iommu->ddt_phys = __pa(iommu->ddt_root);
+	}

But I didn't find any place to free it in the error paths. Did I
overlook anything?

Best regards,
baolu

WARNING: multiple messages have this Message-ID (diff)
From: Baolu Lu <baolu.lu@linux.intel.com>
To: Tomasz Jeznach <tjeznach@rivosinc.com>,
	Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Paul Walmsley <paul.walmsley@sifive.com>
Cc: Anup Patel <apatel@ventanamicro.com>,
	devicetree@vger.kernel.org, Conor Dooley <conor+dt@kernel.org>,
	Albert Ou <aou@eecs.berkeley.edu>,
	linux@rivosinc.com, linux-kernel@vger.kernel.org,
	Rob Herring <robh+dt@kernel.org>,
	Sebastien Boeuf <seb@rivosinc.com>,
	iommu@lists.linux.dev, Palmer Dabbelt <palmer@dabbelt.com>,
	Nick Kossifidis <mick@ics.forth.gr>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	linux-riscv@lists.infradead.org, baolu.lu@linux.intel.com
Subject: Re: [PATCH v3 5/7] iommu/riscv: Device directory management.
Date: Thu, 2 May 2024 09:38:54 +0800	[thread overview]
Message-ID: <104358de-ea86-4e25-8942-ba285d6f317b@linux.intel.com> (raw)
In-Reply-To: <ce3b82a20db0b776685269674ce9b7a926d5680d.1714494653.git.tjeznach@rivosinc.com>

On 5/1/24 4:01 AM, Tomasz Jeznach wrote:
> @@ -128,6 +489,7 @@ void riscv_iommu_remove(struct riscv_iommu_device *iommu)
>   {
>   	iommu_device_unregister(&iommu->iommu);
>   	iommu_device_sysfs_remove(&iommu->iommu);
> +	riscv_iommu_iodir_set_mode(iommu, RISCV_IOMMU_DDTP_MODE_OFF);
>   }
>   
>   int riscv_iommu_init(struct riscv_iommu_device *iommu)
> @@ -138,12 +500,13 @@ int riscv_iommu_init(struct riscv_iommu_device *iommu)
>   	if (rc)
>   		return dev_err_probe(iommu->dev, rc, "unexpected device state\n");
>   
> -	/*
> -	 * Placeholder for a complete IOMMU device initialization.
> -	 * For now, only bare minimum: enable global identity mapping mode and register sysfs.
> -	 */
> -	riscv_iommu_writeq(iommu, RISCV_IOMMU_REG_DDTP,
> -			   FIELD_PREP(RISCV_IOMMU_DDTP_MODE, RISCV_IOMMU_DDTP_MODE_BARE));
> +	rc = riscv_iommu_iodir_alloc(iommu);
> +	if (rc)
> +		goto err_init;
> +
> +	rc = riscv_iommu_iodir_set_mode(iommu, RISCV_IOMMU_DDTP_MODE_MAX);
> +	if (rc)
> +		goto err_init;
>   
>   	rc = iommu_device_sysfs_add(&iommu->iommu, NULL, NULL, "riscv-iommu@%s",
>   				    dev_name(iommu->dev));

The device directory root page might be allocated in
riscv_iommu_iodir_alloc(),

+	if (!iommu->ddt_root) {
+		iommu->ddt_root = riscv_iommu_get_pages(iommu, 0);
+		iommu->ddt_phys = __pa(iommu->ddt_root);
+	}

But I didn't find any place to free it in the error paths. Did I
overlook anything?

Best regards,
baolu

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

  parent reply	other threads:[~2024-05-02  1:40 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-30 20:01 [PATCH v3 0/7] Linux RISC-V IOMMU Support Tomasz Jeznach
2024-04-30 20:01 ` Tomasz Jeznach
2024-04-30 20:01 ` [PATCH v3 1/7] dt-bindings: iommu: riscv: Add bindings for RISC-V IOMMU Tomasz Jeznach
2024-04-30 20:01   ` Tomasz Jeznach
2024-05-01  9:30   ` Conor Dooley
2024-05-01  9:30     ` Conor Dooley
2024-05-01 13:15   ` Rob Herring
2024-05-01 13:15     ` Rob Herring
2024-05-02  2:47     ` Tomasz Jeznach
2024-05-02  2:47       ` Tomasz Jeznach
2024-05-02 15:15       ` Conor Dooley
2024-05-02 15:15         ` Conor Dooley
2024-04-30 20:01 ` [PATCH v3 2/7] iommu/riscv: Add RISC-V IOMMU platform device driver Tomasz Jeznach
2024-04-30 20:01   ` Tomasz Jeznach
2024-05-01 10:26   ` Baolu Lu
2024-05-01 10:26     ` Baolu Lu
2024-05-01 14:20     ` Jason Gunthorpe
2024-05-01 14:20       ` Jason Gunthorpe
2024-05-02  2:23       ` Baolu Lu
2024-05-02  2:23         ` Baolu Lu
2024-05-02  2:44         ` Tomasz Jeznach
2024-05-02  2:44           ` Tomasz Jeznach
2024-04-30 20:01 ` [PATCH v3 3/7] iommu/riscv: Add RISC-V IOMMU PCIe " Tomasz Jeznach
2024-04-30 20:01   ` Tomasz Jeznach
2024-05-01 10:01   ` Baolu Lu
2024-05-01 10:01     ` Baolu Lu
2024-04-30 20:01 ` [PATCH v3 4/7] iommu/riscv: Enable IOMMU registration and device probe Tomasz Jeznach
2024-04-30 20:01   ` Tomasz Jeznach
2024-05-01  9:53   ` Baolu Lu
2024-05-01  9:53     ` Baolu Lu
2024-04-30 20:01 ` [PATCH v3 5/7] iommu/riscv: Device directory management Tomasz Jeznach
2024-04-30 20:01   ` Tomasz Jeznach
2024-05-01 14:57   ` Jason Gunthorpe
2024-05-01 14:57     ` Jason Gunthorpe
2024-05-02  1:38   ` Baolu Lu [this message]
2024-05-02  1:38     ` Baolu Lu
2024-05-02  1:57     ` Baolu Lu
2024-05-02  1:57       ` Baolu Lu
2024-05-02  2:06   ` Baolu Lu
2024-05-02  2:06     ` Baolu Lu
2024-04-30 20:01 ` [PATCH v3 6/7] iommu/riscv: Command and fault queue support Tomasz Jeznach
2024-04-30 20:01   ` Tomasz Jeznach
2024-05-02  3:51   ` Baolu Lu
2024-05-02  3:51     ` Baolu Lu
2024-04-30 20:01 ` [PATCH v3 7/7] iommu/riscv: Paging domain support Tomasz Jeznach
2024-04-30 20:01   ` Tomasz Jeznach
2024-05-01 14:56   ` Jason Gunthorpe
2024-05-01 14:56     ` Jason Gunthorpe
2024-05-03 17:44     ` Tomasz Jeznach
2024-05-03 17:44       ` Tomasz Jeznach
2024-05-03 18:10       ` Jason Gunthorpe
2024-05-03 18:10         ` Jason Gunthorpe
2024-05-03 19:44         ` Tomasz Jeznach
2024-05-03 19:44           ` Tomasz Jeznach
2024-05-05 15:46           ` Jason Gunthorpe
2024-05-05 15:46             ` Jason Gunthorpe
2024-05-07  2:22             ` Tomasz Jeznach
2024-05-07  2:22               ` Tomasz Jeznach
2024-05-07 16:51               ` Jason Gunthorpe
2024-05-07 16:51                 ` Jason Gunthorpe
2024-05-08 16:23                 ` Tomasz Jeznach
2024-05-08 16:23                   ` Tomasz Jeznach
2024-05-02  3:50   ` Baolu Lu
2024-05-02  3:50     ` Baolu Lu
2024-05-02  4:39     ` Tomasz Jeznach
2024-05-02  4:39       ` Tomasz Jeznach
2024-05-01 16:07 ` [PATCH v3 0/7] Linux RISC-V IOMMU Support Jason Gunthorpe
2024-05-01 16:07   ` Jason Gunthorpe

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=104358de-ea86-4e25-8942-ba285d6f317b@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=apatel@ventanamicro.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux@rivosinc.com \
    --cc=mick@ics.forth.gr \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=robh+dt@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=seb@rivosinc.com \
    --cc=sunilvl@ventanamicro.com \
    --cc=tjeznach@rivosinc.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.