Skip to content

Commit

Permalink
powerpc/iommu: Move dev_has_iommu_table() to iommu.c
Browse files Browse the repository at this point in the history
Move function dev_has_iommu_table() to powerpc/kernel/iommu.c
as it is going to be used by machine specific iommu code as
well in subsequent patches.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/171923274748.1397.6274953248403106679.stgit@linux.ibm.com
  • Loading branch information
ShivaprasadGBhat authored and mpe committed Jun 28, 2024
1 parent 4ba2fdf commit 35146ea
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
6 changes: 6 additions & 0 deletions arch/powerpc/include/asm/iommu.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ extern long iommu_tce_xchg_no_kill(struct mm_struct *mm,
enum dma_data_direction *direction);
extern void iommu_tce_kill(struct iommu_table *tbl,
unsigned long entry, unsigned long pages);
int dev_has_iommu_table(struct device *dev, void *data);

#else
static inline void iommu_register_group(struct iommu_table_group *table_group,
Expand All @@ -235,6 +236,11 @@ static inline int iommu_add_device(struct iommu_table_group *table_group,
{
return 0;
}

static inline int dev_has_iommu_table(struct device *dev, void *data)
{
return 0;
}
#endif /* !CONFIG_IOMMU_API */

u64 dma_iommu_get_required_mask(struct device *dev);
Expand Down
16 changes: 0 additions & 16 deletions arch/powerpc/kernel/eeh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1273,22 +1273,6 @@ EXPORT_SYMBOL(eeh_dev_release);

#ifdef CONFIG_IOMMU_API

static int dev_has_iommu_table(struct device *dev, void *data)
{
struct pci_dev *pdev = to_pci_dev(dev);
struct pci_dev **ppdev = data;

if (!dev)
return 0;

if (device_iommu_mapped(dev)) {
*ppdev = pdev;
return 1;
}

return 0;
}

/**
* eeh_iommu_group_to_pe - Convert IOMMU group to EEH PE
* @group: IOMMU group
Expand Down
17 changes: 17 additions & 0 deletions arch/powerpc/kernel/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,23 @@ unsigned long iommu_direction_to_tce_perm(enum dma_data_direction dir)
EXPORT_SYMBOL_GPL(iommu_direction_to_tce_perm);

#ifdef CONFIG_IOMMU_API

int dev_has_iommu_table(struct device *dev, void *data)
{
struct pci_dev *pdev = to_pci_dev(dev);
struct pci_dev **ppdev = data;

if (!dev)
return 0;

if (device_iommu_mapped(dev)) {
*ppdev = pdev;
return 1;
}

return 0;
}

/*
* SPAPR TCE API
*/
Expand Down

0 comments on commit 35146ea

Please sign in to comment.