From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linuxarm@huawei.com, mauro.chehab@huawei.com,
Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
John Stultz <john.stultz@linaro.org>,
Manivannan Sadhasivam <mani@kernel.org>,
linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org
Subject: [PATCH 09/16] iommu: hisi_smmu_lpae: use the right code to get domain-priv data
Date: Mon, 17 Aug 2020 09:50:08 +0200 [thread overview]
Message-ID: <e7fc0440f55a82bee764940d2ed5e4c7821c11a4.1597650455.git.mchehab+huawei@kernel.org> (raw)
In-Reply-To: <cover.1597650455.git.mchehab+huawei@kernel.org>
The downstream code needed to use a priv data within the
domain struct. Change it to work like other iommu drivers:
use dev_iommu_priv_get() and dev_iommu_priv_set() instead.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
drivers/staging/hikey9xx/hisi_smmu.h | 17 ++++++++--
drivers/staging/hikey9xx/hisi_smmu_lpae.c | 38 +++++++++++++----------
2 files changed, 36 insertions(+), 19 deletions(-)
diff --git a/drivers/staging/hikey9xx/hisi_smmu.h b/drivers/staging/hikey9xx/hisi_smmu.h
index b2d32ec6cb84..290f2e11c3be 100644
--- a/drivers/staging/hikey9xx/hisi_smmu.h
+++ b/drivers/staging/hikey9xx/hisi_smmu.h
@@ -94,7 +94,7 @@ struct hisi_smmu_device_lpae {
struct iommu_device iommu;
};
-struct iommu_domain_data {
+struct hisi_smmu_domain_data {
unsigned int iova_start;
unsigned int iova_size;
phys_addr_t phy_pgd_base;
@@ -102,13 +102,24 @@ struct iommu_domain_data {
struct list_head list;
};
+struct hisi_smmu_domain {
+ struct iommu_domain domain;
+ struct hisi_smmu_domain_data *iommu_info;
+};
+
+static struct hisi_smmu_domain_data *to_smmu(struct iommu_domain *dom)
+{
+ struct hisi_smmu_domain *hisi_dom;
+
+ hisi_dom = container_of(dom, struct hisi_smmu_domain, domain);
+ return hisi_dom->iommu_info;
+}
+
struct hisi_map_tile_position_lpae {
struct scatterlist *sg;
unsigned long offset;
};
-extern struct hisi_smmu_device_lpae *hisi_smmu_dev;
-
static inline unsigned int smmu_pgd_none_lpae(smmu_pgd_t pgd)
{
return !(pgd ? pgd : 0);
diff --git a/drivers/staging/hikey9xx/hisi_smmu_lpae.c b/drivers/staging/hikey9xx/hisi_smmu_lpae.c
index a55b5a35b339..1fe57c10e745 100644
--- a/drivers/staging/hikey9xx/hisi_smmu_lpae.c
+++ b/drivers/staging/hikey9xx/hisi_smmu_lpae.c
@@ -28,7 +28,7 @@
#include <linux/bitops.h>
#include "hisi_smmu.h"
-struct hisi_smmu_device_lpae *hisi_smmu_dev;
+static struct hisi_smmu_device_lpae *hisi_smmu_dev;
/* transfer 64bit pte table pointer to struct page */
static pgtable_t smmu_pgd_to_pte_lpae(unsigned int ppte_table)
@@ -57,7 +57,7 @@ static pgtable_t smmu_pmd_to_pte_lpae(unsigned long ppte_table)
}
static int get_domain_data_lpae(struct device_node *np,
- struct iommu_domain_data *data)
+ struct hisi_smmu_domain_data *data)
{
unsigned long long align;
struct device_node *node = NULL;
@@ -103,14 +103,16 @@ static int get_domain_data_lpae(struct device_node *np,
static struct iommu_domain
*hisi_smmu_domain_alloc_lpae(unsigned int iommu_domain_type)
{
- struct iommu_domain *domain;
+ struct hisi_smmu_domain *hisi_dom;
if (iommu_domain_type != IOMMU_DOMAIN_UNMANAGED)
return NULL;
- domain = kzalloc(sizeof(*domain), GFP_KERNEL);
+ hisi_dom = kzalloc(sizeof(*hisi_dom), GFP_KERNEL);
- return domain;
+ pr_debug("%s: domain allocated\n", __func__);
+
+ return &hisi_dom->domain;
}
static void hisi_smmu_flush_pgtable_lpae(void *addr, size_t size)
@@ -336,13 +338,13 @@ static int hisi_smmu_map_lpae(struct iommu_domain *domain,
gfp_t gfp)
{
unsigned long max_iova;
- struct iommu_domain_data *data;
+ struct hisi_smmu_domain_data *data;
if (!domain) {
dbg("domain is null\n");
return -ENODEV;
}
- data = domain->priv;
+ data = to_smmu(domain);
max_iova = data->iova_start + data->iova_size;
if (iova < data->iova_start) {
dbg("iova failed: iova = 0x%lx, start = 0x%8x\n",
@@ -429,13 +431,13 @@ static size_t hisi_smmu_unmap_lpae(struct iommu_domain *domain,
{
unsigned long max_iova;
unsigned int ret;
- struct iommu_domain_data *data;
+ struct hisi_smmu_domain_data *data;
if (!domain) {
dbg("domain is null\n");
return -ENODEV;
}
- data = domain->priv;
+ data = to_smmu(domain);
/*calculate the max io virtual address */
max_iova = data->iova_start + data->iova_size;
/*check the iova */
@@ -490,28 +492,32 @@ static int hisi_attach_dev_lpae(struct iommu_domain *domain, struct device *dev)
{
struct device_node *np = dev->of_node;
int ret = 0;
- struct iommu_domain_data *iommu_info = NULL;
+ struct hisi_smmu_domain_data *iommu_info = NULL;
+ struct hisi_smmu_domain *hisi_dom;
iommu_info = kzalloc(sizeof(*iommu_info), GFP_KERNEL);
if (!iommu_info) {
- dbg("alloc iommu_domain_data fail\n");
+ dbg("alloc hisi_smmu_domain_data fail\n");
return -EINVAL;
}
list_add(&iommu_info->list, &hisi_smmu_dev->domain_list);
- domain->priv = iommu_info;
- ret = get_domain_data_lpae(np, domain->priv);
+
+ hisi_dom = container_of(domain, struct hisi_smmu_domain, domain);
+ hisi_dom->iommu_info = iommu_info;
+ dev_iommu_priv_set(dev, iommu_info);
+ ret = get_domain_data_lpae(np, iommu_info);
return ret;
}
static void hisi_detach_dev_lpae(struct iommu_domain *domain,
struct device *dev)
{
- struct iommu_domain_data *data;
+ struct hisi_smmu_domain_data *data;
- data = (struct iommu_domain_data *)domain->priv;
+ data = dev_iommu_priv_get(dev);
if (data) {
list_del(&data->list);
- domain->priv = NULL;
+ dev_iommu_priv_set(dev, NULL);
kfree(data);
} else {
dbg("%s:error! data entry has been delected\n", __func__);
--
2.26.2
next prev parent reply other threads:[~2020-08-17 7:51 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-17 7:49 [PATCH 00/16] IOMMU driver for Kirin 960/970 Mauro Carvalho Chehab
2020-08-17 7:50 ` [PATCH 01/16] iommu: add support for HiSilicon Kirin 960/970 iommu Mauro Carvalho Chehab
2020-08-17 7:50 ` [PATCH 02/16] iommu: hisilicon: remove default iommu_map_sg handler Mauro Carvalho Chehab
2020-08-17 7:50 ` [PATCH 03/16] iommu: hisilicon: map and unmap ops gained new arguments Mauro Carvalho Chehab
2020-08-17 7:50 ` [PATCH 04/16] iommu: hisi_smmu_lpae: rebase it to work with upstream Mauro Carvalho Chehab
2020-08-17 7:50 ` [PATCH 05/16] iommu: hisi_smmu: remove linux/hisi/hisi-iommu.h Mauro Carvalho Chehab
2020-08-17 7:50 ` [PATCH 06/16] iommu: hisilicon: cleanup its code style Mauro Carvalho Chehab
2020-08-17 7:50 ` [PATCH 07/16] iommu: hisi_smmu_lpae: get rid of IOMMU_SEC and IOMMU_DEVICE Mauro Carvalho Chehab
2020-08-17 7:50 ` [PATCH 08/16] iommu: get rid of map/unmap tile functions Mauro Carvalho Chehab
2020-08-17 7:50 ` Mauro Carvalho Chehab [this message]
2020-08-17 7:50 ` [PATCH 10/16] iommu: hisi_smmu_lpae: convert it to probe_device Mauro Carvalho Chehab
2020-08-17 7:50 ` [PATCH 11/16] iommu: add Hisilicon Kirin970 iommu at the building system Mauro Carvalho Chehab
2020-08-17 7:50 ` [PATCH 12/16] iommu: hisi_smmu_lpae: cleanup printk macros Mauro Carvalho Chehab
2020-08-17 7:50 ` [PATCH 13/16] iommu: hisi_smmu_lpae: make OF compatible more standard Mauro Carvalho Chehab
2020-08-17 7:50 ` [PATCH 14/16] dt: add an spec for the Kirin36x0 SMMU Mauro Carvalho Chehab
2020-08-17 7:50 ` [PATCH 15/16] dt: hi3670-hikey970.dts: load the SMMU driver on Hikey970 Mauro Carvalho Chehab
2020-08-17 7:50 ` [PATCH 16/16] staging: hikey9xx: add an item about the iommu driver Mauro Carvalho Chehab
2020-08-17 8:21 ` [PATCH 00/16] IOMMU driver for Kirin 960/970 Christoph Hellwig
2020-08-17 9:27 ` Mauro Carvalho Chehab
2020-08-17 9:31 ` Christoph Hellwig
2020-08-17 9:37 ` Greg Kroah-Hartman
2020-08-17 10:46 ` Mauro Carvalho Chehab
2020-08-17 10:53 ` Greg Kroah-Hartman
2020-08-17 12:59 ` Joerg Roedel
2020-08-18 14:47 ` Robin Murphy
2020-08-18 15:29 ` Mauro Carvalho Chehab
2020-08-18 16:26 ` Robin Murphy
2020-08-18 22:02 ` John Stultz
2020-08-19 10:12 ` Robin Murphy
2020-08-19 10:28 ` Mauro Carvalho Chehab
2020-08-19 11:33 ` Robin Murphy
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=e7fc0440f55a82bee764940d2ed5e4c7821c11a4.1597650455.git.mchehab+huawei@kernel.org \
--to=mchehab+huawei@kernel.org \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=mani@kernel.org \
--cc=mauro.chehab@huawei.com \
/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;
as well as URLs for NNTP newsgroup(s).