iommu.c (6c65fb318e8bbf21e939e651028b955324f1d873) iommu.c (bc7d12b91bd35477fd650c4d72b61239de9d9066)
1/*
2 * Copyright (C) 2007-2008 Advanced Micro Devices, Inc.
3 * Author: Joerg Roedel <jroedel@suse.de>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation.
8 *

--- 54 unchanged lines hidden (view full) ---

63
64struct iommu_group_attribute {
65 struct attribute attr;
66 ssize_t (*show)(struct iommu_group *group, char *buf);
67 ssize_t (*store)(struct iommu_group *group,
68 const char *buf, size_t count);
69};
70
1/*
2 * Copyright (C) 2007-2008 Advanced Micro Devices, Inc.
3 * Author: Joerg Roedel <jroedel@suse.de>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation.
8 *

--- 54 unchanged lines hidden (view full) ---

63
64struct iommu_group_attribute {
65 struct attribute attr;
66 ssize_t (*show)(struct iommu_group *group, char *buf);
67 ssize_t (*store)(struct iommu_group *group,
68 const char *buf, size_t count);
69};
70
71static const char * const iommu_group_resv_type_string[] = {
72 [IOMMU_RESV_DIRECT] = "direct",
73 [IOMMU_RESV_RESERVED] = "reserved",
74 [IOMMU_RESV_MSI] = "msi",
75};
76
71#define IOMMU_GROUP_ATTR(_name, _mode, _show, _store) \
72struct iommu_group_attribute iommu_group_attr_##_name = \
73 __ATTR(_name, _mode, _show, _store)
74
75#define to_iommu_group_attr(_attr) \
76 container_of(_attr, struct iommu_group_attribute, attr)
77#define to_iommu_group(_kobj) \
78 container_of(_kobj, struct iommu_group, kobj)

--- 147 unchanged lines hidden (view full) ---

226 if (ret)
227 break;
228 }
229 mutex_unlock(&group->mutex);
230 return ret;
231}
232EXPORT_SYMBOL_GPL(iommu_get_group_resv_regions);
233
77#define IOMMU_GROUP_ATTR(_name, _mode, _show, _store) \
78struct iommu_group_attribute iommu_group_attr_##_name = \
79 __ATTR(_name, _mode, _show, _store)
80
81#define to_iommu_group_attr(_attr) \
82 container_of(_attr, struct iommu_group_attribute, attr)
83#define to_iommu_group(_kobj) \
84 container_of(_kobj, struct iommu_group, kobj)

--- 147 unchanged lines hidden (view full) ---

232 if (ret)
233 break;
234 }
235 mutex_unlock(&group->mutex);
236 return ret;
237}
238EXPORT_SYMBOL_GPL(iommu_get_group_resv_regions);
239
240static ssize_t iommu_group_show_resv_regions(struct iommu_group *group,
241 char *buf)
242{
243 struct iommu_resv_region *region, *next;
244 struct list_head group_resv_regions;
245 char *str = buf;
246
247 INIT_LIST_HEAD(&group_resv_regions);
248 iommu_get_group_resv_regions(group, &group_resv_regions);
249
250 list_for_each_entry_safe(region, next, &group_resv_regions, list) {
251 str += sprintf(str, "0x%016llx 0x%016llx %s\n",
252 (long long int)region->start,
253 (long long int)(region->start +
254 region->length - 1),
255 iommu_group_resv_type_string[region->type]);
256 kfree(region);
257 }
258
259 return (str - buf);
260}
261
234static IOMMU_GROUP_ATTR(name, S_IRUGO, iommu_group_show_name, NULL);
235
262static IOMMU_GROUP_ATTR(name, S_IRUGO, iommu_group_show_name, NULL);
263
264static IOMMU_GROUP_ATTR(reserved_regions, 0444,
265 iommu_group_show_resv_regions, NULL);
266
236static void iommu_group_release(struct kobject *kobj)
237{
238 struct iommu_group *group = to_iommu_group(kobj);
239
240 pr_debug("Releasing group %d\n", group->id);
241
242 if (group->iommu_data_release)
243 group->iommu_data_release(group->iommu_data);

--- 61 unchanged lines hidden (view full) ---

305
306 /*
307 * The devices_kobj holds a reference on the group kobject, so
308 * as long as that exists so will the group. We can therefore
309 * use the devices_kobj for reference counting.
310 */
311 kobject_put(&group->kobj);
312
267static void iommu_group_release(struct kobject *kobj)
268{
269 struct iommu_group *group = to_iommu_group(kobj);
270
271 pr_debug("Releasing group %d\n", group->id);
272
273 if (group->iommu_data_release)
274 group->iommu_data_release(group->iommu_data);

--- 61 unchanged lines hidden (view full) ---

336
337 /*
338 * The devices_kobj holds a reference on the group kobject, so
339 * as long as that exists so will the group. We can therefore
340 * use the devices_kobj for reference counting.
341 */
342 kobject_put(&group->kobj);
343
344 ret = iommu_group_create_file(group,
345 &iommu_group_attr_reserved_regions);
346 if (ret)
347 return ERR_PTR(ret);
348
313 pr_debug("Allocated group %d\n", group->id);
314
315 return group;
316}
317EXPORT_SYMBOL_GPL(iommu_group_alloc);
318
319struct iommu_group *iommu_group_get_by_id(int id)
320{

--- 1525 unchanged lines hidden ---
349 pr_debug("Allocated group %d\n", group->id);
350
351 return group;
352}
353EXPORT_SYMBOL_GPL(iommu_group_alloc);
354
355struct iommu_group *iommu_group_get_by_id(int id)
356{

--- 1525 unchanged lines hidden ---