sun50i-iommu.c (5b167dea64a3fb72907e33f30211d4a5711076f1) sun50i-iommu.c (3529375e7777b0f9b77c53df9a7da122bd165ae7)
1// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2// Copyright (C) 2016-2018, Allwinner Technology CO., LTD.
3// Copyright (C) 2019-2020, Cerno
4
5#include <linux/bitfield.h>
6#include <linux/bug.h>
7#include <linux/clk.h>
8#include <linux/device.h>

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

662 pte = page_table[sun50i_iova_get_pte_index(iova)];
663 if (!sun50i_pte_is_page_valid(pte))
664 return 0;
665
666 return sun50i_pte_get_page_address(pte) +
667 sun50i_iova_get_page_offset(iova);
668}
669
1// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2// Copyright (C) 2016-2018, Allwinner Technology CO., LTD.
3// Copyright (C) 2019-2020, Cerno
4
5#include <linux/bitfield.h>
6#include <linux/bug.h>
7#include <linux/clk.h>
8#include <linux/device.h>

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

662 pte = page_table[sun50i_iova_get_pte_index(iova)];
663 if (!sun50i_pte_is_page_valid(pte))
664 return 0;
665
666 return sun50i_pte_get_page_address(pte) +
667 sun50i_iova_get_page_offset(iova);
668}
669
670static struct iommu_domain *sun50i_iommu_domain_alloc(unsigned type)
670static struct iommu_domain *
671sun50i_iommu_domain_alloc_paging(struct device *dev)
671{
672 struct sun50i_iommu_domain *sun50i_domain;
673
672{
673 struct sun50i_iommu_domain *sun50i_domain;
674
674 if (type != IOMMU_DOMAIN_DMA &&
675 type != IOMMU_DOMAIN_UNMANAGED)
676 return NULL;
677
678 sun50i_domain = kzalloc(sizeof(*sun50i_domain), GFP_KERNEL);
679 if (!sun50i_domain)
680 return NULL;
681
682 sun50i_domain->dt = (u32 *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
683 get_order(DT_SIZE));
684 if (!sun50i_domain->dt)
685 goto err_free_domain;

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

835
836 return iommu_fwspec_add_ids(dev, &id, 1);
837}
838
839static const struct iommu_ops sun50i_iommu_ops = {
840 .identity_domain = &sun50i_iommu_identity_domain,
841 .pgsize_bitmap = SZ_4K,
842 .device_group = sun50i_iommu_device_group,
675 sun50i_domain = kzalloc(sizeof(*sun50i_domain), GFP_KERNEL);
676 if (!sun50i_domain)
677 return NULL;
678
679 sun50i_domain->dt = (u32 *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
680 get_order(DT_SIZE));
681 if (!sun50i_domain->dt)
682 goto err_free_domain;

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

832
833 return iommu_fwspec_add_ids(dev, &id, 1);
834}
835
836static const struct iommu_ops sun50i_iommu_ops = {
837 .identity_domain = &sun50i_iommu_identity_domain,
838 .pgsize_bitmap = SZ_4K,
839 .device_group = sun50i_iommu_device_group,
843 .domain_alloc = sun50i_iommu_domain_alloc,
840 .domain_alloc_paging = sun50i_iommu_domain_alloc_paging,
844 .of_xlate = sun50i_iommu_of_xlate,
845 .probe_device = sun50i_iommu_probe_device,
846 .default_domain_ops = &(const struct iommu_domain_ops) {
847 .attach_dev = sun50i_iommu_attach_device,
848 .flush_iotlb_all = sun50i_iommu_flush_iotlb_all,
849 .iotlb_sync_map = sun50i_iommu_iotlb_sync_map,
850 .iotlb_sync = sun50i_iommu_iotlb_sync,
851 .iova_to_phys = sun50i_iommu_iova_to_phys,

--- 239 unchanged lines hidden ---
841 .of_xlate = sun50i_iommu_of_xlate,
842 .probe_device = sun50i_iommu_probe_device,
843 .default_domain_ops = &(const struct iommu_domain_ops) {
844 .attach_dev = sun50i_iommu_attach_device,
845 .flush_iotlb_all = sun50i_iommu_flush_iotlb_all,
846 .iotlb_sync_map = sun50i_iommu_iotlb_sync_map,
847 .iotlb_sync = sun50i_iommu_iotlb_sync,
848 .iova_to_phys = sun50i_iommu_iova_to_phys,

--- 239 unchanged lines hidden ---