drm.c (0301196b5719341ba98223eed9a0e6ea4eab615a) | drm.c (aacdf19849734d1be5e407932228ae101ba5b92f) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2012 Avionic Design GmbH 4 * Copyright (C) 2012-2016 NVIDIA CORPORATION. All rights reserved. 5 */ 6 7#include <linux/bitops.h> 8#include <linux/host1x.h> --- 1054 unchanged lines hidden (view full) --- 1063 mutex_lock(&tegra->clients_lock); 1064 list_del_init(&client->list); 1065 client->drm = NULL; 1066 mutex_unlock(&tegra->clients_lock); 1067 1068 return 0; 1069} 1070 | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2012 Avionic Design GmbH 4 * Copyright (C) 2012-2016 NVIDIA CORPORATION. All rights reserved. 5 */ 6 7#include <linux/bitops.h> 8#include <linux/host1x.h> --- 1054 unchanged lines hidden (view full) --- 1063 mutex_lock(&tegra->clients_lock); 1064 list_del_init(&client->list); 1065 client->drm = NULL; 1066 mutex_unlock(&tegra->clients_lock); 1067 1068 return 0; 1069} 1070 |
1071struct iommu_group *host1x_client_iommu_attach(struct host1x_client *client, 1072 bool shared) | 1071int host1x_client_iommu_attach(struct host1x_client *client, bool shared) |
1073{ 1074 struct drm_device *drm = dev_get_drvdata(client->parent); 1075 struct tegra_drm *tegra = drm->dev_private; 1076 struct iommu_group *group = NULL; 1077 int err; 1078 1079 if (tegra->domain) { 1080 group = iommu_group_get(client->dev); 1081 if (!group) { 1082 dev_err(client->dev, "failed to get IOMMU group\n"); | 1072{ 1073 struct drm_device *drm = dev_get_drvdata(client->parent); 1074 struct tegra_drm *tegra = drm->dev_private; 1075 struct iommu_group *group = NULL; 1076 int err; 1077 1078 if (tegra->domain) { 1079 group = iommu_group_get(client->dev); 1080 if (!group) { 1081 dev_err(client->dev, "failed to get IOMMU group\n"); |
1083 return ERR_PTR(-ENODEV); | 1082 return -ENODEV; |
1084 } 1085 1086 if (!shared || (shared && (group != tegra->group))) { 1087#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) 1088 if (client->dev->archdata.mapping) { 1089 struct dma_iommu_mapping *mapping = 1090 to_dma_iommu_mapping(client->dev); 1091 arm_iommu_detach_device(client->dev); 1092 arm_iommu_release_mapping(mapping); 1093 } 1094#endif 1095 err = iommu_attach_group(tegra->domain, group); 1096 if (err < 0) { 1097 iommu_group_put(group); | 1083 } 1084 1085 if (!shared || (shared && (group != tegra->group))) { 1086#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) 1087 if (client->dev->archdata.mapping) { 1088 struct dma_iommu_mapping *mapping = 1089 to_dma_iommu_mapping(client->dev); 1090 arm_iommu_detach_device(client->dev); 1091 arm_iommu_release_mapping(mapping); 1092 } 1093#endif 1094 err = iommu_attach_group(tegra->domain, group); 1095 if (err < 0) { 1096 iommu_group_put(group); |
1098 return ERR_PTR(err); | 1097 return err; |
1099 } 1100 1101 if (shared && !tegra->group) 1102 tegra->group = group; 1103 } 1104 } 1105 | 1098 } 1099 1100 if (shared && !tegra->group) 1101 tegra->group = group; 1102 } 1103 } 1104 |
1106 return group; | 1105 client->group = group; 1106 1107 return 0; |
1107} 1108 | 1108} 1109 |
1109void host1x_client_iommu_detach(struct host1x_client *client, 1110 struct iommu_group *group) | 1110void host1x_client_iommu_detach(struct host1x_client *client) |
1111{ 1112 struct drm_device *drm = dev_get_drvdata(client->parent); 1113 struct tegra_drm *tegra = drm->dev_private; 1114 | 1111{ 1112 struct drm_device *drm = dev_get_drvdata(client->parent); 1113 struct tegra_drm *tegra = drm->dev_private; 1114 |
1115 if (group) { 1116 if (group == tegra->group) { 1117 iommu_detach_group(tegra->domain, group); | 1115 if (client->group) { 1116 if (client->group == tegra->group) { 1117 iommu_detach_group(tegra->domain, client->group); |
1118 tegra->group = NULL; 1119 } 1120 | 1118 tegra->group = NULL; 1119 } 1120 |
1121 iommu_group_put(group); | 1121 iommu_group_put(client->group); |
1122 } 1123} 1124 1125void *tegra_drm_alloc(struct tegra_drm *tegra, size_t size, dma_addr_t *dma) 1126{ 1127 struct iova *alloc; 1128 void *virt; 1129 gfp_t gfp; --- 215 unchanged lines hidden --- | 1122 } 1123} 1124 1125void *tegra_drm_alloc(struct tegra_drm *tegra, size_t size, dma_addr_t *dma) 1126{ 1127 struct iova *alloc; 1128 void *virt; 1129 gfp_t gfp; --- 215 unchanged lines hidden --- |