{"push_id":1152201838,"size":1,"distinct_size":1,"ref":"refs/heads/real","head":"0f0671adbf356691e545db003fe50b8fe74a2116","before":"9da0b21ba185cac2f318e714e60d9876e21955c7","commits":[{"sha":"0f0671adbf356691e545db003fe50b8fe74a2116","author":{"name":"robcore","email":"a3b05a675e90e628f2d9df6520db16da9bff1bff@gmail.com"},"message":"From 73c8716e574473837cbedc74b10ee83fc2f51d66 Mon Sep 17 00:00:00 2001\nFrom: Ohad Ben-Cohen <ohad@wizery.com>\nDate: Mon, 21 May 2012 20:20:05 +0300\nSubject: [PATCH 0704/6902] iommu/core: pass a user-provided token to fault\n handlers\n\nSometimes a single IOMMU user may have to deal with several\ndifferent IOMMU devices (e.g. remoteproc).\n\nWhen an IOMMU fault happens, such users have to regain their\ncontext in order to deal with the fault.\n\nUsers can't use the private fields of neither the iommu_domain nor\nthe IOMMU device, because those are already used by the IOMMU core\nand low level driver (respectively).\n\nThis patch just simply allows users to pass a private token (most\nnotably their own context pointer) to iommu_set_fault_handler(),\nand then makes sure it is provided back to the users whenever\nan IOMMU fault happens.\n\nThe patch also adopts remoteproc to the new fault handling\ninterface, but the real functionality using this (recovery of\nremote processors) will only be added later in a subsequent patch\nset.\n\nCc: Fernando Guzman Lugo <fernando.lugo@ti.com>\nSigned-off-by: Ohad Ben-Cohen <ohad@wizery.com>\nSigned-off-by: Joerg Roedel <joerg.roedel@amd.com>\n[ohaugan@codeaurora.org: Resolved compilation and merge issues]\nSigned-off-by: Olav Haugan <ohaugan@codeaurora.org>\n\nConflicts:\n\tdrivers/video/msm/mdss/mdss_mdp.c\n\nChange-Id: I610966aeb936e0d026c6ef35a56453337e1b3c76\n---\n drivers/gpu/msm/kgsl_iommu.c         |  4 +-\n drivers/iommu/iommu.c                |  5 ++-\n drivers/remoteproc/remoteproc_core.c |  4 +-\n drivers/video/msm/mdss/mdss_mdp.c    | 75 ++++++++++++++++++++++++++++++++++++\n include/linux/iommu.h                | 10 +++--\n 5 files changed, 89 insertions(+), 9 deletions(-)\n\ndiff --git a/drivers/gpu/msm/kgsl_iommu.c b/drivers/gpu/msm/kgsl_iommu.c\nindex fe515c6..5f3450c 100644\n--- a/drivers/gpu/msm/kgsl_iommu.c\n+++ b/drivers/gpu/msm/kgsl_iommu.c\n@@ -282,7 +282,7 @@ static void _check_if_freed(struct kgsl_iommu_device *iommu_dev,\n }\n\n static int kgsl_iommu_fault_handler(struct iommu_domain *domain,\n-\tstruct device *dev, unsigned long addr, int flags)\n+\tstruct device *dev, unsigned long addr, int flags, void *token)\n {\n \tint ret = 0;\n \tstruct kgsl_mmu *mmu;\n@@ -643,7 +643,7 @@ void *kgsl_iommu_create_pagetable(void)\n \t\treturn NULL;\n \t} else {\n \t\tiommu_set_fault_handler(iommu_pt->domain,\n-\t\t\tkgsl_iommu_fault_handler);\n+\t\t\tkgsl_iommu_fault_handler, NULL);\n \t}\n\n \treturn iommu_pt;\ndiff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c\nindex ef69d91..88e44dd 100644\n--- a/drivers/iommu/iommu.c\n+++ b/drivers/iommu/iommu.c\n@@ -120,6 +120,7 @@ EXPORT_SYMBOL_GPL(iommu_present);\n  * iommu_set_fault_handler() - set a fault handler for an iommu domain\n  * @domain: iommu domain\n  * @handler: fault handler\n+ * @token: user data, will be passed back to the fault handler\n  *\n  * This function should be used by IOMMU users which want to be notified\n  * whenever an IOMMU fault happens.\n@@ -128,11 +129,13 @@ EXPORT_SYMBOL_GPL(iommu_present);\n  * error code otherwise.\n  */\n void iommu_set_fault_handler(struct iommu_domain *domain,\n-\t\t\t\t\tiommu_fault_handler_t handler)\n+\t\t\t\t\tiommu_fault_handler_t handler,\n+\t\t\t\t\tvoid *token)\n {\n \tBUG_ON(!domain);\n\n \tdomain->handler = handler;\n+\tdomain->handler_token = token;\n }\n EXPORT_SYMBOL_GPL(iommu_set_fault_handler);\n\ndiff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c\nindex e756a0d..289293a 100644\n--- a/drivers/remoteproc/remoteproc_core.c\n+++ b/drivers/remoteproc/remoteproc_core.c\n@@ -78,7 +78,7 @@ typedef int (*rproc_handle_resource_t)(struct rproc *rproc, void *, int avail);\n  * the recovery of the remote processor.\n  */\n static int rproc_iommu_fault(struct iommu_domain *domain, struct device *dev,\n-\t\tunsigned long iova, int flags)\n+\t\tunsigned long iova, int flags, void *token)\n {\n \tdev_err(dev, \"iommu fault: da 0x%lx flags 0x%x\\n\", iova, flags);\n\n@@ -117,7 +117,7 @@ static int rproc_enable_iommu(struct rproc *rproc)\n \t\treturn -ENOMEM;\n \t}\n\n-\tiommu_set_fault_handler(domain, rproc_iommu_fault);\n+\tiommu_set_fault_handler(domain, rproc_iommu_fault, rproc);\n\n \tret = iommu_attach_device(domain, dev);\n \tif (ret) {\ndiff --git a/drivers/video/msm/mdss/mdss_mdp.c b/drivers/video/msm/mdss/mdss_mdp.c\nindex 4bfbc9d..e4d4883 100644\n--- a/drivers/video/msm/mdss/mdss_mdp.c\n+++ b/drivers/video/msm/mdss/mdss_mdp.c\n@@ -580,6 +580,52 @@ error:\n \tfor (i = 0; i < MDSS_MAX_CLK; i++) {\n \t\tif (mdss_res->mdp_clk[i])\n \t\t\tclk_put(mdss_res->mdp_clk[i]);\n+}\n+\n+static int mdss_iommu_fault_handler(struct iommu_domain *domain,\n+\t\tstruct device *dev, unsigned long iova, int flags, void *token)\n+{\n+\tpr_err(\"MDP IOMMU page fault: iova 0x%lx\\n\", iova);\n+\treturn 0;\n+}\n+\n+int mdss_iommu_attach(struct mdss_data_type *mdata)\n+{\n+\tstruct iommu_domain *domain;\n+\tstruct mdss_iommu_map_type *iomap;\n+\tint i;\n+\n+\tif (mdata->iommu_attached) {\n+\t\tpr_warn(\"mdp iommu already attached\\n\");\n+\t\treturn 0;\n+\t}\n+\n+\tfor (i = 0; i < MDSS_IOMMU_MAX_DOMAIN; i++) {\n+\t\tiomap = mdata->iommu_map + i;\n+\n+\t\tdomain = msm_get_iommu_domain(iomap->domain_idx);\n+\t\tif (!domain) {\n+\t\t\tWARN(1, \"could not attach iommu client %s to ctx %s\\n\",\n+\t\t\t\tiomap->client_name, iomap->ctx_name);\n+\t\t\tcontinue;\n+\t\t}\n+\t\tiommu_attach_device(domain, iomap->ctx);\n+\t}\n+\n+\tmdata->iommu_attached = true;\n+\n+\treturn 0;\n+}\n+\n+int mdss_iommu_dettach(struct mdss_data_type *mdata)\n+{\n+\tstruct iommu_domain *domain;\n+\tstruct mdss_iommu_map_type *iomap;\n+\tint i;\n+\n+\tif (!mdata->iommu_attached) {\n+\t\tpr_warn(\"mdp iommu already dettached\\n\");\n+\t\treturn 0;\n \t}\n \tif (mdss_res->fs)\n \t\tregulator_put(mdss_res->fs);\n@@ -594,6 +640,35 @@ static struct msm_panel_common_pdata *mdss_mdp_populate_pdata(\n \tstruct device *dev)\n {\n \tstruct msm_panel_common_pdata *pdata;\n+\tstruct msm_iova_layout layout;\n+\tstruct iommu_domain *domain;\n+\tstruct mdss_iommu_map_type *iomap;\n+\tint i;\n+\n+\tif (mdata->iommu_map) {\n+\t\tpr_warn(\"iommu already initialized\\n\");\n+\t\treturn 0;\n+\t}\n+\n+\tfor (i = 0; i < MDSS_IOMMU_MAX_DOMAIN; i++) {\n+\t\tiomap = &mdss_iommu_map[i];\n+\n+\t\tlayout.client_name = iomap->client_name;\n+\t\tlayout.partitions = iomap->partitions;\n+\t\tlayout.npartitions = iomap->npartitions;\n+\t\tlayout.is_secure = (i == MDSS_IOMMU_DOMAIN_SECURE);\n+\n+\t\tiomap->domain_idx = msm_register_domain(&layout);\n+\t\tif (IS_ERR_VALUE(iomap->domain_idx))\n+\t\t\treturn -EINVAL;\n+\n+\t\tdomain = msm_get_iommu_domain(iomap->domain_idx);\n+\t\tif (!domain) {\n+\t\t\tpr_err(\"unable to get iommu domain(%d)\\n\",\n+\t\t\t\tiomap->domain_idx);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t\tiommu_set_fault_handler(domain, mdss_iommu_fault_handler, NULL);\n\n \tpdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);\n \tif (!pdata)\ndiff --git a/include/linux/iommu.h b/include/linux/iommu.h\nindex 95b15d6..dbe13ba 100644\n--- a/include/linux/iommu.h\n+++ b/include/linux/iommu.h\n@@ -37,12 +37,13 @@ struct iommu_domain;\n #define IOMMU_FAULT_WRITE\t0x1\n\n typedef int (*iommu_fault_handler_t)(struct iommu_domain *,\n-\t\t\t\tstruct device *, unsigned long, int);\n+\t\t\tstruct device *, unsigned long, int, void *);\n\n struct iommu_domain {\n \tstruct iommu_ops *ops;\n \tvoid *priv;\n \tiommu_fault_handler_t handler;\n+\tvoid *handler_token;\n };\n\n #define IOMMU_CAP_CACHE_COHERENCY\t0x1\n@@ -107,7 +108,7 @@ extern int iommu_domain_has_cap(struct iommu_domain *domain,\n \t\t\t\tunsigned long cap);\n extern phys_addr_t iommu_get_pt_base_addr(struct iommu_domain *domain);\n extern void iommu_set_fault_handler(struct iommu_domain *domain,\n-\t\t\t\t\tiommu_fault_handler_t handler);\n+\t\t\tiommu_fault_handler_t handler, void *token);\n extern int iommu_device_group(struct device *dev, unsigned int *groupid);\n\n /**\n@@ -144,7 +145,8 @@ static inline int report_iommu_fault(struct iommu_domain *domain,\n \t * invoke it.\n \t */\n \tif (domain->handler)\n-\t\tret = domain->handler(domain, dev, iova, flags);\n+\t\tret = domain->handler(domain, dev, iova, flags,\n+\t\t\t\t\t\tdomain->handler_token);\n\n \treturn ret;\n }\n@@ -221,7 +223,7 @@ static inline phys_addr_t iommu_get_pt_base_addr(struct iommu_domain *domain)\n }\n\n static inline void iommu_set_fault_handler(struct iommu_domain *domain,\n-\t\t\t\t\tiommu_fault_handler_t handler)\n+\t\t\t\tiommu_fault_handler_t handler, void *token)\n {\n }\n\n--\n2.8.1","distinct":true,"url":"https://api.github.com/repos/robcore/Hulk-Kernel-V2/commits/0f0671adbf356691e545db003fe50b8fe74a2116"}]}
{"actor":{"display_login":"robcore"}}