mbox series

[00/11] powerpv/powernv: Restore pnv_npu_try_dma_set_bypass()

Message ID 1572454800-17976-1-git-send-email-arbab@linux.ibm.com (mailing list archive)
Headers show
Series powerpv/powernv: Restore pnv_npu_try_dma_set_bypass() | expand

Message

Reza Arbab Oct. 30, 2019, 4:59 p.m. UTC
With recent kernels, TCE tables for NPU devices are no longer being
configured. That task was performed by pnv_npu_try_dma_set_bypass(), a
function that got swept away in recent overhauling of dma code.

Patches 1-4 here bring the lost function back and reintegrate it with
the updated generic iommu bypass infrastructure.

Patch 5 fixes a regression in behavior when a requested dma mask can not
be fulfilled.

Patches 6-8 are cleanup. I put these later in the set because they
aren't bisectable until after the restored code is wired back in.

Patches 9-11 refactor pnv_pci_ioda_iommu_bypass_supported(). It seems
wrong for a boolean *_supported() function to have side effects. They
reintroduce a pci controller based dma_set_mask() hook. If that's
undesirable, these last three patches can be dropped.

Reza Arbab (11):
  Revert "powerpc/powernv: Remove unused pnv_npu_try_dma_set_bypass()
    function"
  powerpc/powernv: Add pnv_ioda_pe_iommu_bypass_supported()
  powerpc/powernv/npu: Change pnv_npu_try_dma_set_bypass() argument
  powerpc/powernv/npu: Wire up pnv_npu_try_dma_set_bypass()
  powerpc/powernv: Return failure for some uses of dma_set_mask()
  powerpc/powernv: Remove intermediate variable
  powerpc/powernv/npu: Simplify pnv_npu_try_dma_set_bypass() loop
  powerpc/powernv: Replace open coded pnv_ioda_get_pe()s
  Revert "powerpc/pci: remove the dma_set_mask pci_controller ops
    methods"
  powerpc/powernv: Add pnv_phb3_iommu_bypass_supported()
  powerpc/powernv: Add pnv_pci_ioda_dma_set_mask()

 arch/powerpc/include/asm/pci-bridge.h     |   2 +
 arch/powerpc/kernel/dma-iommu.c           |  19 ++++--
 arch/powerpc/kernel/dma-mask.c            |   9 +++
 arch/powerpc/platforms/powernv/Kconfig    |   1 +
 arch/powerpc/platforms/powernv/npu-dma.c  | 106 +++++++++++++++++++++++++++---
 arch/powerpc/platforms/powernv/pci-ioda.c |  71 ++++++++++++--------
 arch/powerpc/platforms/powernv/pci.h      |  10 ++-
 7 files changed, 177 insertions(+), 41 deletions(-)

Comments

Christoph Hellwig Oct. 30, 2019, 5:53 p.m. UTC | #1
On Wed, Oct 30, 2019 at 11:59:49AM -0500, Reza Arbab wrote:
> With recent kernels, TCE tables for NPU devices are no longer being
> configured. That task was performed by pnv_npu_try_dma_set_bypass(), a
> function that got swept away in recent overhauling of dma code.
> 
> Patches 1-4 here bring the lost function back and reintegrate it with
> the updated generic iommu bypass infrastructure.
> 
> Patch 5 fixes a regression in behavior when a requested dma mask can not
> be fulfilled.
> 
> Patches 6-8 are cleanup. I put these later in the set because they
> aren't bisectable until after the restored code is wired back in.
> 
> Patches 9-11 refactor pnv_pci_ioda_iommu_bypass_supported(). It seems
> wrong for a boolean *_supported() function to have side effects. They
> reintroduce a pci controller based dma_set_mask() hook. If that's
> undesirable, these last three patches can be dropped.

How do you even use this code?  Nothing in the kernel even calls
dma_set_mask for NPU devices, as we only suport vfio pass through.
Reza Arbab Oct. 30, 2019, 6:08 p.m. UTC | #2
On Wed, Oct 30, 2019 at 06:53:41PM +0100, Christoph Hellwig wrote:
>How do you even use this code?  Nothing in the kernel even calls
>dma_set_mask for NPU devices, as we only suport vfio pass through.

You use it by calling dma_set_mask() for the *GPU* device. The purpose 
of pnv_npu_try_dma_set_bypass() is to then propagate the same bypass 
configuration to all the NPU devices associated with that GPU.
Christoph Hellwig Oct. 30, 2019, 6:13 p.m. UTC | #3
On Wed, Oct 30, 2019 at 01:08:51PM -0500, Reza Arbab wrote:
> On Wed, Oct 30, 2019 at 06:53:41PM +0100, Christoph Hellwig wrote:
>> How do you even use this code?  Nothing in the kernel even calls
>> dma_set_mask for NPU devices, as we only suport vfio pass through.
>
> You use it by calling dma_set_mask() for the *GPU* device. The purpose of 
> pnv_npu_try_dma_set_bypass() is to then propagate the same bypass 
> configuration to all the NPU devices associated with that GPU.

Which in-kernel driver, which PCI ID?
Reza Arbab Oct. 30, 2019, 6:32 p.m. UTC | #4
On Wed, Oct 30, 2019 at 07:13:59PM +0100, Christoph Hellwig wrote:
>On Wed, Oct 30, 2019 at 01:08:51PM -0500, Reza Arbab wrote:
>> On Wed, Oct 30, 2019 at 06:53:41PM +0100, Christoph Hellwig wrote:
>>> How do you even use this code?  Nothing in the kernel even calls
>>> dma_set_mask for NPU devices, as we only suport vfio pass through.
>>
>> You use it by calling dma_set_mask() for the *GPU* device. The purpose of
>> pnv_npu_try_dma_set_bypass() is to then propagate the same bypass
>> configuration to all the NPU devices associated with that GPU.
>
>Which in-kernel driver, which PCI ID?

Aha, it's this again. Didn't catch your meaning at first. Point taken.
Christoph Hellwig Oct. 30, 2019, 6:33 p.m. UTC | #5
On Wed, Oct 30, 2019 at 01:32:01PM -0500, Reza Arbab wrote:
> Aha, it's this again. Didn't catch your meaning at first. Point taken.

It's not _me_.  It that you (plural) keep ignoring how Linux development
works.