Skip to content

Commit 72acd9d

Browse files
committed
iommu: Move iommu_fwspec to struct dev_iommu
Move the iommu_fwspec pointer in struct device into struct dev_iommu. This is a step in the effort to reduce the iommu related pointers in struct device to one. Signed-off-by: Joerg Roedel <[email protected]> Tested-by: Will Deacon <[email protected]> # arm-smmu Reviewed-by: Jean-Philippe Brucker <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 045a704 commit 72acd9d

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

drivers/iommu/iommu.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2405,6 +2405,9 @@ int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode,
24052405
if (fwspec)
24062406
return ops == fwspec->ops ? 0 : -EINVAL;
24072407

2408+
if (!dev_iommu_get(dev))
2409+
return -ENOMEM;
2410+
24082411
/* Preallocate for the overwhelmingly common case of 1 ID */
24092412
fwspec = kzalloc(struct_size(fwspec, ids, 1), GFP_KERNEL);
24102413
if (!fwspec)

include/linux/device.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ struct device_node;
4242
struct fwnode_handle;
4343
struct iommu_ops;
4444
struct iommu_group;
45-
struct iommu_fwspec;
4645
struct dev_pin_info;
4746
struct dev_iommu;
4847

@@ -513,7 +512,6 @@ struct dev_links_info {
513512
* gone away. This should be set by the allocator of the
514513
* device (i.e. the bus driver that discovered the device).
515514
* @iommu_group: IOMMU group the device belongs to.
516-
* @iommu_fwspec: IOMMU-specific properties supplied by firmware.
517515
* @iommu: Per device generic IOMMU runtime data
518516
*
519517
* @offline_disabled: If set, the device is permanently online.
@@ -613,7 +611,6 @@ struct device {
613611

614612
void (*release)(struct device *dev);
615613
struct iommu_group *iommu_group;
616-
struct iommu_fwspec *iommu_fwspec;
617614
struct dev_iommu *iommu;
618615

619616
bool offline_disabled:1;

include/linux/iommu.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,14 +368,15 @@ struct iommu_fault_param {
368368
* struct dev_iommu - Collection of per-device IOMMU data
369369
*
370370
* @fault_param: IOMMU detected device fault reporting data
371+
* @fwspec: IOMMU fwspec data
371372
*
372373
* TODO: migrate other per device data pointers under iommu_dev_data, e.g.
373374
* struct iommu_group *iommu_group;
374-
* struct iommu_fwspec *iommu_fwspec;
375375
*/
376376
struct dev_iommu {
377377
struct mutex lock;
378-
struct iommu_fault_param *fault_param;
378+
struct iommu_fault_param *fault_param;
379+
struct iommu_fwspec *fwspec;
379380
};
380381

381382
int iommu_device_register(struct iommu_device *iommu);
@@ -614,13 +615,16 @@ const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode);
614615

615616
static inline struct iommu_fwspec *dev_iommu_fwspec_get(struct device *dev)
616617
{
617-
return dev->iommu_fwspec;
618+
if (dev->iommu)
619+
return dev->iommu->fwspec;
620+
else
621+
return NULL;
618622
}
619623

620624
static inline void dev_iommu_fwspec_set(struct device *dev,
621625
struct iommu_fwspec *fwspec)
622626
{
623-
dev->iommu_fwspec = fwspec;
627+
dev->iommu->fwspec = fwspec;
624628
}
625629

626630
int iommu_probe_device(struct device *dev);

0 commit comments

Comments
 (0)