cregit-Linux how code gets into the kernel

Release 4.14 arch/powerpc/kernel/dma-swiotlb.c

/*
 * Contains routines needed to support swiotlb for ppc.
 *
 * Copyright (C) 2009-2010 Freescale Semiconductor, Inc.
 * Author: Becky Bruce
 *
 * This program is free software; you can redistribute  it and/or modify it
 * under  the terms of  the GNU General  Public License as published by the
 * Free Software Foundation;  either version 2 of the  License, or (at your
 * option) any later version.
 *
 */

#include <linux/dma-mapping.h>
#include <linux/memblock.h>
#include <linux/pfn.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/pci.h>

#include <asm/machdep.h>
#include <asm/swiotlb.h>
#include <asm/dma.h>


unsigned int ppc_swiotlb_enable;


static u64 swiotlb_powerpc_get_required(struct device *dev) { u64 end, mask, max_direct_dma_addr = dev->archdata.max_direct_dma_addr; end = memblock_end_of_DRAM(); if (max_direct_dma_addr && end > max_direct_dma_addr) end = max_direct_dma_addr; end += get_dma_offset(dev); mask = 1ULL << (fls64(end) - 1); mask += mask - 1; return mask; }

Contributors

PersonTokensPropCommitsCommitProp
Milton D. Miller II70100.00%1100.00%
Total70100.00%1100.00%

/* * At the moment, all platforms that use this code only require * swiotlb to be used if we're operating on HIGHMEM. Since * we don't ever call anything other than map_sg, unmap_sg, * map_page, and unmap_page on highmem, use normal dma_ops * for everything else. */ const struct dma_map_ops swiotlb_dma_ops = { .alloc = __dma_direct_alloc_coherent, .free = __dma_direct_free_coherent, .mmap = dma_direct_mmap_coherent, .map_sg = swiotlb_map_sg_attrs, .unmap_sg = swiotlb_unmap_sg_attrs, .dma_supported = swiotlb_dma_supported, .map_page = swiotlb_map_page, .unmap_page = swiotlb_unmap_page, .sync_single_for_cpu = swiotlb_sync_single_for_cpu, .sync_single_for_device = swiotlb_sync_single_for_device, .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, .sync_sg_for_device = swiotlb_sync_sg_for_device, .mapping_error = swiotlb_dma_mapping_error, .get_required_mask = swiotlb_powerpc_get_required, };
void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev) { struct pci_controller *hose; struct dev_archdata *sd; hose = pci_bus_to_host(pdev->bus); sd = &pdev->dev.archdata; sd->max_direct_dma_addr = hose->dma_window_base_cur + hose->dma_window_size; }

Contributors

PersonTokensPropCommitsCommitProp
FUJITA Tomonori50100.00%1100.00%
Total50100.00%1100.00%


static int ppc_swiotlb_bus_notify(struct notifier_block *nb, unsigned long action, void *data) { struct device *dev = data; struct dev_archdata *sd; /* We are only intereted in device addition */ if (action != BUS_NOTIFY_ADD_DEVICE) return 0; sd = &dev->archdata; sd->max_direct_dma_addr = 0; /* May need to bounce if the device can't address all of DRAM */ if ((dma_get_mask(dev) + 1) < memblock_end_of_DRAM()) set_dma_ops(dev, &swiotlb_dma_ops); return NOTIFY_DONE; }

Contributors

PersonTokensPropCommitsCommitProp
Becky Bruce5771.25%125.00%
FUJITA Tomonori1822.50%125.00%
Kumar Gala45.00%125.00%
Yinghai Lu11.25%125.00%
Total80100.00%4100.00%

static struct notifier_block ppc_swiotlb_plat_bus_notifier = { .notifier_call = ppc_swiotlb_bus_notify, .priority = 0, };
int __init swiotlb_setup_bus_notifier(void) { bus_register_notifier(&platform_bus_type, &ppc_swiotlb_plat_bus_notifier); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Becky Bruce20100.00%1100.00%
Total20100.00%1100.00%


void __init swiotlb_detect_4g(void) { if ((memblock_end_of_DRAM() - 1) > 0xffffffff) { ppc_swiotlb_enable = 1; #ifdef CONFIG_ZONE_DMA32 limit_zone_pfn(ZONE_DMA32, (1ULL << 32) >> PAGE_SHIFT); #endif } }

Contributors

PersonTokensPropCommitsCommitProp
Jia Hongtao2251.16%150.00%
Scott Wood2148.84%150.00%
Total43100.00%2100.00%


static int __init check_swiotlb_enabled(void) { if (ppc_swiotlb_enable) swiotlb_print_info(); else swiotlb_free(); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Jia Hongtao2295.65%150.00%
Daniel Axtens14.35%150.00%
Total23100.00%2100.00%

subsys_initcall(check_swiotlb_enabled);

Overall Contributors

PersonTokensPropCommitsCommitProp
Becky Bruce17441.63%16.25%
FUJITA Tomonori7918.90%425.00%
Milton D. Miller II7517.94%16.25%
Jia Hongtao4811.48%16.25%
Scott Wood215.02%16.25%
Kumar Gala51.20%16.25%
Marek Szyprowski51.20%16.25%
Michael Ellerman30.72%16.25%
Benjamin Herrenschmidt20.48%16.25%
Daniel Axtens20.48%16.25%
Andrzej Pietrasiewicz20.48%16.25%
Bart Van Assche10.24%16.25%
Yinghai Lu10.24%16.25%
Total418100.00%16100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.