summaryrefslogtreecommitdiffstats
path: root/drivers/misc/mods/mods_pci.c
diff options
context:
space:
mode:
authorChris Dragan <kdragan@nvidia.com>2018-03-09 08:48:51 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2018-03-12 05:43:57 -0400
commit08dfb85451b4d67044a6c283abb97f7244037ac1 (patch)
tree0a7fe49b8f9c76ada20cde1c1d090201e4a42f4b /drivers/misc/mods/mods_pci.c
parent21dcba20fdc7235ed2260a31b437f259cfd11313 (diff)
misc: mods: update MODS driver from Perforce
Bug 2059566 Change-Id: I18513ad05258e3a4e0f17b8be126fc5a8626c1fa Signed-off-by: Chris Dragan <kdragan@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1672101 GVS: Gerrit_Virtual_Submit Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/misc/mods/mods_pci.c')
-rw-r--r--drivers/misc/mods/mods_pci.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/drivers/misc/mods/mods_pci.c b/drivers/misc/mods/mods_pci.c
index 9e1f5f90b..6a9b5a293 100644
--- a/drivers/misc/mods/mods_pci.c
+++ b/drivers/misc/mods/mods_pci.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * mods_pci.c - This file is part of NVIDIA MODS kernel driver. 2 * mods_pci.c - This file is part of NVIDIA MODS kernel driver.
3 * 3 *
4 * Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved. 4 * Copyright (c) 2008-2018, NVIDIA CORPORATION. All rights reserved.
5 * 5 *
6 * NVIDIA MODS kernel driver is free software: you can redistribute it and/or 6 * NVIDIA MODS kernel driver is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License, 7 * modify it under the terms of the GNU General Public License,
@@ -21,6 +21,9 @@
21 21
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/fs.h> 23#include <linux/fs.h>
24#if defined(MODS_HAS_DMA_OPS)
25#include <linux/dma-mapping.h>
26#endif
24 27
25/************************ 28/************************
26 * PCI HELPER FUNCTIONS * 29 * PCI HELPER FUNCTIONS *
@@ -837,3 +840,33 @@ int esc_mods_pci_unmap_resource(struct file *fp,
837 return OK; 840 return OK;
838#endif 841#endif
839} 842}
843
844int esc_mods_get_iommu_state(struct file *pfile,
845 struct MODS_GET_IOMMU_STATE *state)
846{
847#if !defined(CONFIG_SWIOTLB)
848 /* SW IOTLB turned off in the kernel, HW IOMMU active */
849 state->state = 1;
850#elif defined(MODS_HAS_DMA_OPS)
851
852 unsigned int devfn = PCI_DEVFN(state->pci_device.device,
853 state->pci_device.function);
854 struct pci_dev *dev = MODS_PCI_GET_SLOT(state->pci_device.domain,
855 state->pci_device.bus,
856 devfn);
857
858 const struct dma_map_ops *ops = get_dma_ops(&dev->dev);
859
860#if defined(MODS_HAS_NONCOH_DMA_OPS)
861 state->state = ops->map_sg != &noncoherent_swiotlb_dma_ops &&
862 ops->map_sg != &coherent_swiotlb_dma_ops;
863#else
864 state->state = ops->map_sg != swiotlb_map_sg_attrs;
865#endif
866#else
867 /* Old kernels, only x86 support, assume no IOMMU */
868 state->state = 0;
869#endif
870 return OK;
871}
872