mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 22:40:53 +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>
206 lines
5.7 KiB
C
206 lines
5.7 KiB
C
/* mvme147.c : the Linux/mvme147/lance ethernet driver
|
|
*
|
|
* Copyright (C) 05/1998 Peter Maydell <pmaydell@chiark.greenend.org.uk>
|
|
* Based on the Sun Lance driver and the NetBSD HP Lance driver
|
|
* Uses the generic 7990.c LANCE code.
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/types.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/ioport.h>
|
|
#include <linux/string.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/init.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/gfp.h>
|
|
/* Used for the temporal inet entries and routing */
|
|
#include <linux/socket.h>
|
|
#include <linux/route.h>
|
|
#include <linux/netdevice.h>
|
|
#include <linux/etherdevice.h>
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <asm/system.h>
|
|
#include <asm/io.h>
|
|
#include <asm/pgtable.h>
|
|
#include <asm/mvme147hw.h>
|
|
|
|
/* We have 16834 bytes of RAM for the init block and buffers. This places
|
|
* an upper limit on the number of buffers we can use. NetBSD uses 8 Rx
|
|
* buffers and 2 Tx buffers.
|
|
*/
|
|
#define LANCE_LOG_TX_BUFFERS 1
|
|
#define LANCE_LOG_RX_BUFFERS 3
|
|
|
|
#include "7990.h" /* use generic LANCE code */
|
|
|
|
/* Our private data structure */
|
|
struct m147lance_private {
|
|
struct lance_private lance;
|
|
unsigned long ram;
|
|
};
|
|
|
|
/* function prototypes... This is easy because all the grot is in the
|
|
* generic LANCE support. All we have to support is probing for boards,
|
|
* plus board-specific init, open and close actions.
|
|
* Oh, and we need to tell the generic code how to read and write LANCE registers...
|
|
*/
|
|
static int m147lance_open(struct net_device *dev);
|
|
static int m147lance_close(struct net_device *dev);
|
|
static void m147lance_writerap(struct lance_private *lp, unsigned short value);
|
|
static void m147lance_writerdp(struct lance_private *lp, unsigned short value);
|
|
static unsigned short m147lance_readrdp(struct lance_private *lp);
|
|
|
|
typedef void (*writerap_t)(void *, unsigned short);
|
|
typedef void (*writerdp_t)(void *, unsigned short);
|
|
typedef unsigned short (*readrdp_t)(void *);
|
|
|
|
static const struct net_device_ops lance_netdev_ops = {
|
|
.ndo_open = m147lance_open,
|
|
.ndo_stop = m147lance_close,
|
|
.ndo_start_xmit = lance_start_xmit,
|
|
.ndo_set_multicast_list = lance_set_multicast,
|
|
.ndo_tx_timeout = lance_tx_timeout,
|
|
.ndo_change_mtu = eth_change_mtu,
|
|
.ndo_validate_addr = eth_validate_addr,
|
|
.ndo_set_mac_address = eth_mac_addr,
|
|
};
|
|
|
|
/* Initialise the one and only on-board 7990 */
|
|
struct net_device * __init mvme147lance_probe(int unit)
|
|
{
|
|
struct net_device *dev;
|
|
static int called;
|
|
static const char name[] = "MVME147 LANCE";
|
|
struct m147lance_private *lp;
|
|
u_long *addr;
|
|
u_long address;
|
|
int err;
|
|
|
|
if (!MACH_IS_MVME147 || called)
|
|
return ERR_PTR(-ENODEV);
|
|
called++;
|
|
|
|
dev = alloc_etherdev(sizeof(struct m147lance_private));
|
|
if (!dev)
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
if (unit >= 0)
|
|
sprintf(dev->name, "eth%d", unit);
|
|
|
|
/* Fill the dev fields */
|
|
dev->base_addr = (unsigned long)MVME147_LANCE_BASE;
|
|
dev->netdev_ops = &lance_netdev_ops;
|
|
dev->dma = 0;
|
|
|
|
addr=(u_long *)ETHERNET_ADDRESS;
|
|
address = *addr;
|
|
dev->dev_addr[0]=0x08;
|
|
dev->dev_addr[1]=0x00;
|
|
dev->dev_addr[2]=0x3e;
|
|
address=address>>8;
|
|
dev->dev_addr[5]=address&0xff;
|
|
address=address>>8;
|
|
dev->dev_addr[4]=address&0xff;
|
|
address=address>>8;
|
|
dev->dev_addr[3]=address&0xff;
|
|
|
|
printk("%s: MVME147 at 0x%08lx, irq %d, "
|
|
"Hardware Address %pM\n",
|
|
dev->name, dev->base_addr, MVME147_LANCE_IRQ,
|
|
dev->dev_addr);
|
|
|
|
lp = netdev_priv(dev);
|
|
lp->ram = __get_dma_pages(GFP_ATOMIC, 3); /* 16K */
|
|
if (!lp->ram)
|
|
{
|
|
printk("%s: No memory for LANCE buffers\n", dev->name);
|
|
free_netdev(dev);
|
|
return ERR_PTR(-ENOMEM);
|
|
}
|
|
|
|
lp->lance.name = (char*)name; /* discards const, shut up gcc */
|
|
lp->lance.base = dev->base_addr;
|
|
lp->lance.init_block = (struct lance_init_block *)(lp->ram); /* CPU addr */
|
|
lp->lance.lance_init_block = (struct lance_init_block *)(lp->ram); /* LANCE addr of same RAM */
|
|
lp->lance.busmaster_regval = LE_C3_BSWP; /* we're bigendian */
|
|
lp->lance.irq = MVME147_LANCE_IRQ;
|
|
lp->lance.writerap = (writerap_t)m147lance_writerap;
|
|
lp->lance.writerdp = (writerdp_t)m147lance_writerdp;
|
|
lp->lance.readrdp = (readrdp_t)m147lance_readrdp;
|
|
lp->lance.lance_log_rx_bufs = LANCE_LOG_RX_BUFFERS;
|
|
lp->lance.lance_log_tx_bufs = LANCE_LOG_TX_BUFFERS;
|
|
lp->lance.rx_ring_mod_mask = RX_RING_MOD_MASK;
|
|
lp->lance.tx_ring_mod_mask = TX_RING_MOD_MASK;
|
|
|
|
err = register_netdev(dev);
|
|
if (err) {
|
|
free_pages(lp->ram, 3);
|
|
free_netdev(dev);
|
|
return ERR_PTR(err);
|
|
}
|
|
|
|
return dev;
|
|
}
|
|
|
|
static void m147lance_writerap(struct lance_private *lp, unsigned short value)
|
|
{
|
|
out_be16(lp->base + LANCE_RAP, value);
|
|
}
|
|
|
|
static void m147lance_writerdp(struct lance_private *lp, unsigned short value)
|
|
{
|
|
out_be16(lp->base + LANCE_RDP, value);
|
|
}
|
|
|
|
static unsigned short m147lance_readrdp(struct lance_private *lp)
|
|
{
|
|
return in_be16(lp->base + LANCE_RDP);
|
|
}
|
|
|
|
static int m147lance_open(struct net_device *dev)
|
|
{
|
|
int status;
|
|
|
|
status = lance_open(dev); /* call generic lance open code */
|
|
if (status)
|
|
return status;
|
|
/* enable interrupts at board level. */
|
|
m147_pcc->lan_cntrl=0; /* clear the interrupts (if any) */
|
|
m147_pcc->lan_cntrl=0x08 | 0x04; /* Enable irq 4 */
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int m147lance_close(struct net_device *dev)
|
|
{
|
|
/* disable interrupts at boardlevel */
|
|
m147_pcc->lan_cntrl=0x0; /* disable interrupts */
|
|
lance_close(dev);
|
|
return 0;
|
|
}
|
|
|
|
#ifdef MODULE
|
|
MODULE_LICENSE("GPL");
|
|
|
|
static struct net_device *dev_mvme147_lance;
|
|
int __init init_module(void)
|
|
{
|
|
dev_mvme147_lance = mvme147lance_probe(-1);
|
|
if (IS_ERR(dev_mvme147_lance))
|
|
return PTR_ERR(dev_mvme147_lance);
|
|
return 0;
|
|
}
|
|
|
|
void __exit cleanup_module(void)
|
|
{
|
|
struct m147lance_private *lp = netdev_priv(dev_mvme147_lance);
|
|
unregister_netdev(dev_mvme147_lance);
|
|
free_pages(lp->ram, 3);
|
|
free_netdev(dev_mvme147_lance);
|
|
}
|
|
|
|
#endif /* MODULE */
|