mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-30 12:46:40 +07:00
5a0e3ad6af
percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
203 lines
5.1 KiB
C
203 lines
5.1 KiB
C
/*
|
|
* ccio-rm-dma.c:
|
|
* DMA management routines for first generation cache-coherent machines.
|
|
* "Real Mode" operation refers to U2/Uturn chip operation. The chip
|
|
* can perform coherency checks w/o using the I/O MMU. That's all we
|
|
* need until support for more than 4GB phys mem is needed.
|
|
*
|
|
* This is the trivial case - basically what x86 does.
|
|
*
|
|
* Drawbacks of using Real Mode are:
|
|
* o outbound DMA is slower since one isn't using the prefetching
|
|
* U2 can do for outbound DMA.
|
|
* o Ability to do scatter/gather in HW is also lost.
|
|
* o only known to work with PCX-W processor. (eg C360)
|
|
* (PCX-U/U+ are not coherent with U2 in real mode.)
|
|
*
|
|
*
|
|
* 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.
|
|
*
|
|
*
|
|
* Original version/author:
|
|
* CVSROOT=:pserver:anonymous@198.186.203.37:/cvsroot/linux-parisc
|
|
* cvs -z3 co linux/arch/parisc/kernel/dma-rm.c
|
|
*
|
|
* (C) Copyright 2000 Philipp Rumpf <prumpf@tux.org>
|
|
*
|
|
*
|
|
* Adopted for The Puffin Group's parisc-linux port by Grant Grundler.
|
|
* (C) Copyright 2000 Grant Grundler <grundler@puffin.external.hp.com>
|
|
*
|
|
*/
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/init.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/string.h>
|
|
#include <linux/pci.h>
|
|
#include <linux/gfp.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <asm/io.h>
|
|
#include <asm/hardware.h>
|
|
#include <asm/page.h>
|
|
|
|
/* Only chose "ccio" since that's what HP-UX calls it....
|
|
** Make it easier for folks to migrate from one to the other :^)
|
|
*/
|
|
#define MODULE_NAME "ccio"
|
|
|
|
#define U2_IOA_RUNWAY 0x580
|
|
#define U2_BC_GSC 0x501
|
|
#define UTURN_IOA_RUNWAY 0x581
|
|
#define UTURN_BC_GSC 0x502
|
|
|
|
#define IS_U2(id) ( \
|
|
(((id)->hw_type == HPHW_IOA) && ((id)->hversion == U2_IOA_RUNWAY)) || \
|
|
(((id)->hw_type == HPHW_BCPORT) && ((id)->hversion == U2_BC_GSC)) \
|
|
)
|
|
|
|
#define IS_UTURN(id) ( \
|
|
(((id)->hw_type == HPHW_IOA) && ((id)->hversion == UTURN_IOA_RUNWAY)) || \
|
|
(((id)->hw_type == HPHW_BCPORT) && ((id)->hversion == UTURN_BC_GSC)) \
|
|
)
|
|
|
|
static int ccio_dma_supported( struct pci_dev *dev, u64 mask)
|
|
{
|
|
if (dev == NULL) {
|
|
printk(KERN_ERR MODULE_NAME ": EISA/ISA/et al not supported\n");
|
|
BUG();
|
|
return(0);
|
|
}
|
|
|
|
/* only support 32-bit devices (ie PCI/GSC) */
|
|
return((int) (mask >= 0xffffffffUL));
|
|
}
|
|
|
|
|
|
static void *ccio_alloc_consistent(struct pci_dev *dev, size_t size,
|
|
dma_addr_t *handle)
|
|
{
|
|
void *ret;
|
|
|
|
ret = (void *)__get_free_pages(GFP_ATOMIC, get_order(size));
|
|
|
|
if (ret != NULL) {
|
|
memset(ret, 0, size);
|
|
*handle = virt_to_phys(ret);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
static void ccio_free_consistent(struct pci_dev *dev, size_t size,
|
|
void *vaddr, dma_addr_t handle)
|
|
{
|
|
free_pages((unsigned long)vaddr, get_order(size));
|
|
}
|
|
|
|
static dma_addr_t ccio_map_single(struct pci_dev *dev, void *ptr, size_t size,
|
|
int direction)
|
|
{
|
|
return virt_to_phys(ptr);
|
|
}
|
|
|
|
static void ccio_unmap_single(struct pci_dev *dev, dma_addr_t dma_addr,
|
|
size_t size, int direction)
|
|
{
|
|
/* Nothing to do */
|
|
}
|
|
|
|
|
|
static int ccio_map_sg(struct pci_dev *dev, struct scatterlist *sglist, int nents, int direction)
|
|
{
|
|
int tmp = nents;
|
|
|
|
/* KISS: map each buffer separately. */
|
|
while (nents) {
|
|
sg_dma_address(sglist) = ccio_map_single(dev, sglist->address, sglist->length, direction);
|
|
sg_dma_len(sglist) = sglist->length;
|
|
nents--;
|
|
sglist++;
|
|
}
|
|
|
|
return tmp;
|
|
}
|
|
|
|
|
|
static void ccio_unmap_sg(struct pci_dev *dev, struct scatterlist *sglist, int nents, int direction)
|
|
{
|
|
#if 0
|
|
while (nents) {
|
|
ccio_unmap_single(dev, sg_dma_address(sglist), sg_dma_len(sglist), direction);
|
|
nents--;
|
|
sglist++;
|
|
}
|
|
return;
|
|
#else
|
|
/* Do nothing (copied from current ccio_unmap_single() :^) */
|
|
#endif
|
|
}
|
|
|
|
|
|
static struct pci_dma_ops ccio_ops = {
|
|
ccio_dma_supported,
|
|
ccio_alloc_consistent,
|
|
ccio_free_consistent,
|
|
ccio_map_single,
|
|
ccio_unmap_single,
|
|
ccio_map_sg,
|
|
ccio_unmap_sg,
|
|
NULL, /* dma_sync_single_for_cpu : NOP for U2 */
|
|
NULL, /* dma_sync_single_for_device : NOP for U2 */
|
|
NULL, /* dma_sync_sg_for_cpu : ditto */
|
|
NULL, /* dma_sync_sg_for_device : ditto */
|
|
};
|
|
|
|
|
|
/*
|
|
** Determine if u2 should claim this chip (return 0) or not (return 1).
|
|
** If so, initialize the chip and tell other partners in crime they
|
|
** have work to do.
|
|
*/
|
|
static int
|
|
ccio_probe(struct parisc_device *dev)
|
|
{
|
|
printk(KERN_INFO "%s found %s at 0x%lx\n", MODULE_NAME,
|
|
dev->id.hversion == U2_BC_GSC ? "U2" : "UTurn",
|
|
dev->hpa.start);
|
|
|
|
/*
|
|
** FIXME - should check U2 registers to verify it's really running
|
|
** in "Real Mode".
|
|
*/
|
|
|
|
#if 0
|
|
/* will need this for "Virtual Mode" operation */
|
|
ccio_hw_init(ccio_dev);
|
|
ccio_common_init(ccio_dev);
|
|
#endif
|
|
hppa_dma_ops = &ccio_ops;
|
|
return 0;
|
|
}
|
|
|
|
static struct parisc_device_id ccio_tbl[] = {
|
|
{ HPHW_BCPORT, HVERSION_REV_ANY_ID, U2_BC_GSC, 0xc },
|
|
{ HPHW_BCPORT, HVERSION_REV_ANY_ID, UTURN_BC_GSC, 0xc },
|
|
{ 0, }
|
|
};
|
|
|
|
static struct parisc_driver ccio_driver = {
|
|
.name = "U2/Uturn",
|
|
.id_table = ccio_tbl,
|
|
.probe = ccio_probe,
|
|
};
|
|
|
|
void __init ccio_init(void)
|
|
{
|
|
register_parisc_driver(&ccio_driver);
|
|
}
|