diff --git a/[refs] b/[refs] index 62b71e3f56c6..0ccb77af2a1b 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: e403149c92a2a0643211debbbb0a9ec7cc04cff7 +refs/heads/master: 09f60f8f54c5e2391f0b7c38dccd7b00d83587ab diff --git a/trunk/Documentation/filesystems/9p.txt b/trunk/Documentation/filesystems/9p.txt index bf8080640eba..b90f537af35c 100644 --- a/trunk/Documentation/filesystems/9p.txt +++ b/trunk/Documentation/filesystems/9p.txt @@ -42,12 +42,10 @@ OPTIONS trans=name select an alternative transport. Valid options are currently: - unix - specifying a named pipe mount point - tcp - specifying a normal TCP/IP connection - fd - used passed file descriptors for connection + unix - specifying a named pipe mount point + tcp - specifying a normal TCP/IP connection + fd - used passed file descriptors for connection (see rfdno and wfdno) - virtio - connect to the next virtio channel available - (from lguest or KVM with trans_virtio module) uname=name user name to attempt mount as on the remote server. The server may override or ignore this value. Certain user diff --git a/trunk/Documentation/i386/boot.txt b/trunk/Documentation/i386/boot.txt index fc49b79bc1ab..2f75e750e4f5 100644 --- a/trunk/Documentation/i386/boot.txt +++ b/trunk/Documentation/i386/boot.txt @@ -785,41 +785,3 @@ IMPORTANT: All the hooks are required to preserve %esp, %ebp, %esi and After completing your hook, you should jump to the address that was in this field before your boot loader overwrote it (relocated, if appropriate.) - - -**** 32-bit BOOT PROTOCOL - -For machine with some new BIOS other than legacy BIOS, such as EFI, -LinuxBIOS, etc, and kexec, the 16-bit real mode setup code in kernel -based on legacy BIOS can not be used, so a 32-bit boot protocol needs -to be defined. - -In 32-bit boot protocol, the first step in loading a Linux kernel -should be to setup the boot parameters (struct boot_params, -traditionally known as "zero page"). The memory for struct boot_params -should be allocated and initialized to all zero. Then the setup header -from offset 0x01f1 of kernel image on should be loaded into struct -boot_params and examined. The end of setup header can be calculated as -follow: - - 0x0202 + byte value at offset 0x0201 - -In addition to read/modify/write the setup header of the struct -boot_params as that of 16-bit boot protocol, the boot loader should -also fill the additional fields of the struct boot_params as that -described in zero-page.txt. - -After setupping the struct boot_params, the boot loader can load the -32/64-bit kernel in the same way as that of 16-bit boot protocol. - -In 32-bit boot protocol, the kernel is started by jumping to the -32-bit kernel entry point, which is the start address of loaded -32/64-bit kernel. - -At entry, the CPU must be in 32-bit protected mode with paging -disabled; a GDT must be loaded with the descriptors for selectors -__BOOT_CS(0x10) and __BOOT_DS(0x18); both descriptors must be 4G flat -segment; __BOOS_CS must have execute/read permission, and __BOOT_DS -must have read/write permission; CS must be __BOOT_CS and DS, ES, SS -must be __BOOT_DS; interrupt must be disabled; %esi must hold the base -address of the struct boot_params; %ebp, %edi and %ebx must be zero. diff --git a/trunk/Documentation/i386/zero-page.txt b/trunk/Documentation/i386/zero-page.txt index 169ad423a3d1..6c0817c45683 100644 --- a/trunk/Documentation/i386/zero-page.txt +++ b/trunk/Documentation/i386/zero-page.txt @@ -1,31 +1,99 @@ -The additional fields in struct boot_params as a part of 32-bit boot -protocol of kernel. These should be filled by bootloader or 16-bit -real-mode setup code of the kernel. References/settings to it mainly -are in: +--------------------------------------------------------------------------- +!!!!!!!!!!!!!!!WARNING!!!!!!!! +The zero page is a kernel internal data structure, not a stable ABI. It might change +without warning and the kernel has no way to detect old version of it. +If you're writing some external code like a boot loader you should only use +the stable versioned real mode boot protocol described in boot.txt. Otherwise the kernel +might break you at any time. +!!!!!!!!!!!!!WARNING!!!!!!!!!!! +---------------------------------------------------------------------------- - include/asm-x86/bootparam.h +Summary of boot_params layout (kernel point of view) + ( collected by Hans Lermen and Martin Mares ) + +The contents of boot_params are used to pass parameters from the +16-bit realmode code of the kernel to the 32-bit part. References/settings +to it mainly are in: + arch/i386/boot/setup.S + arch/i386/boot/video.S + arch/i386/kernel/head.S + arch/i386/kernel/setup.c + -Offset Proto Name Meaning -/Size +Offset Type Description +------ ---- ----------- + 0 32 bytes struct screen_info, SCREEN_INFO + ATTENTION, overlaps the following !!! + 2 unsigned short EXT_MEM_K, extended memory size in Kb (from int 0x15) + 0x20 unsigned short CL_MAGIC, commandline magic number (=0xA33F) + 0x22 unsigned short CL_OFFSET, commandline offset + Address of commandline is calculated: + 0x90000 + contents of CL_OFFSET + (only taken, when CL_MAGIC = 0xA33F) + 0x40 20 bytes struct apm_bios_info, APM_BIOS_INFO + 0x60 16 bytes Intel SpeedStep (IST) BIOS support information + 0x80 16 bytes hd0-disk-parameter from intvector 0x41 + 0x90 16 bytes hd1-disk-parameter from intvector 0x46 -000/040 ALL screen_info Text mode or frame buffer information - (struct screen_info) -040/014 ALL apm_bios_info APM BIOS information (struct apm_bios_info) -060/010 ALL ist_info Intel SpeedStep (IST) BIOS support information - (struct ist_info) -080/010 ALL hd0_info hd0 disk parameter, OBSOLETE!! -090/010 ALL hd1_info hd1 disk parameter, OBSOLETE!! -0A0/010 ALL sys_desc_table System description table (struct sys_desc_table) -140/080 ALL edid_info Video mode setup (struct edid_info) -1C0/020 ALL efi_info EFI 32 information (struct efi_info) -1E0/004 ALL alk_mem_k Alternative mem check, in KB -1E4/004 ALL scratch Scratch field for the kernel setup code -1E8/001 ALL e820_entries Number of entries in e820_map (below) -1E9/001 ALL eddbuf_entries Number of entries in eddbuf (below) -1EA/001 ALL edd_mbr_sig_buf_entries Number of entries in edd_mbr_sig_buffer - (below) -290/040 ALL edd_mbr_sig_buffer EDD MBR signatures -2D0/A00 ALL e820_map E820 memory map table - (array of struct e820entry) -D00/1EC ALL eddbuf EDD data (array of struct edd_info) + 0xa0 16 bytes System description table truncated to 16 bytes. + ( struct sys_desc_table_struct ) + 0xb0 - 0x13f Free. Add more parameters here if you really need them. + 0x140- 0x1be EDID_INFO Video mode setup + +0x1c4 unsigned long EFI system table pointer +0x1c8 unsigned long EFI memory descriptor size +0x1cc unsigned long EFI memory descriptor version +0x1d0 unsigned long EFI memory descriptor map pointer +0x1d4 unsigned long EFI memory descriptor map size +0x1e0 unsigned long ALT_MEM_K, alternative mem check, in Kb +0x1e4 unsigned long Scratch field for the kernel setup code +0x1e8 char number of entries in E820MAP (below) +0x1e9 unsigned char number of entries in EDDBUF (below) +0x1ea unsigned char number of entries in EDD_MBR_SIG_BUFFER (below) +0x1f1 char size of setup.S, number of sectors +0x1f2 unsigned short MOUNT_ROOT_RDONLY (if !=0) +0x1f4 unsigned short size of compressed kernel-part in the + (b)zImage-file (in 16 byte units, rounded up) +0x1f6 unsigned short swap_dev (unused AFAIK) +0x1f8 unsigned short RAMDISK_FLAGS +0x1fa unsigned short VGA-Mode (old one) +0x1fc unsigned short ORIG_ROOT_DEV (high=Major, low=minor) +0x1ff char AUX_DEVICE_INFO + +0x200 short jump to start of setup code aka "reserved" field. +0x202 4 bytes Signature for SETUP-header, ="HdrS" +0x206 unsigned short Version number of header format + Current version is 0x0201... +0x208 8 bytes (used by setup.S for communication with boot loaders, + look there) +0x210 char LOADER_TYPE, = 0, old one + else it is set by the loader: + 0xTV: T=0 for LILO + 1 for Loadlin + 2 for bootsect-loader + 3 for SYSLINUX + 4 for ETHERBOOT + 5 for ELILO + 7 for GRuB + 8 for U-BOOT + 9 for Xen + V = version +0x211 char loadflags: + bit0 = 1: kernel is loaded high (bzImage) + bit7 = 1: Heap and pointer (see below) set by boot + loader. +0x212 unsigned short (setup.S) +0x214 unsigned long KERNEL_START, where the loader started the kernel +0x218 unsigned long INITRD_START, address of loaded ramdisk image +0x21c unsigned long INITRD_SIZE, size in bytes of ramdisk image +0x220 4 bytes (setup.S) +0x224 unsigned short setup.S heap end pointer +0x226 unsigned short zero_pad +0x228 unsigned long cmd_line_ptr +0x22c unsigned long ramdisk_max +0x230 16 bytes trampoline +0x290 - 0x2cf EDD_MBR_SIG_BUFFER (edd.S) +0x2d0 - 0xd00 E820MAP +0xd00 - 0xeff EDDBUF (edd.S) for disk signature read sector +0xd00 - 0xeeb EDDBUF (edd.S) for edd data diff --git a/trunk/Documentation/kernel-parameters.txt b/trunk/Documentation/kernel-parameters.txt index 33121d6c827c..b2361667839f 100644 --- a/trunk/Documentation/kernel-parameters.txt +++ b/trunk/Documentation/kernel-parameters.txt @@ -422,8 +422,7 @@ and is between 256 and 4096 characters. It is defined in the file hpet= [X86-32,HPET] option to control HPET usage Format: { enable (default) | disable | force } disable: disable HPET and use PIT instead - force: allow force enabled of undocumented chips (ICH4, - VIA, nVidia) + force: allow force enabled of undocumented chips (ICH4, VIA) com20020= [HW,NET] ARCnet - COM20020 chipset Format: @@ -586,6 +585,11 @@ and is between 256 and 4096 characters. It is defined in the file eata= [HW,SCSI] + ec_intr= [HW,ACPI] ACPI Embedded Controller interrupt mode + Format: + 0: polling mode + non-0: interrupt mode (default) + edd= [EDD] Format: {"of[f]" | "sk[ipmbr]"} See comment in arch/i386/boot/edd.S @@ -1439,8 +1443,7 @@ and is between 256 and 4096 characters. It is defined in the file Param: "schedule" - profile schedule points. Param: - step/bucket size as a power of 2 for statistical time based profiling. - Param: "sleep" - profile D-state sleeping (millisecs). - Requires CONFIG_SCHEDSTATS + Param: "sleep" - profile D-state sleeping (millisecs) Param: "kvm" - profile VM exits. processor.max_cstate= [HW,ACPI] diff --git a/trunk/Documentation/lguest/lguest.c b/trunk/Documentation/lguest/lguest.c index f2668390e8f7..5bdc37f81842 100644 --- a/trunk/Documentation/lguest/lguest.c +++ b/trunk/Documentation/lguest/lguest.c @@ -34,24 +34,25 @@ #include #include #include -#include "linux/lguest_launcher.h" -#include "linux/virtio_config.h" -#include "linux/virtio_net.h" -#include "linux/virtio_blk.h" -#include "linux/virtio_console.h" -#include "linux/virtio_ring.h" -#include "asm-x86/bootparam.h" -/*L:110 We can ignore the 38 include files we need for this program, but I do +/*L:110 We can ignore the 30 include files we need for this program, but I do * want to draw attention to the use of kernel-style types. * * As Linus said, "C is a Spartan language, and so should your naming be." I - * like these abbreviations, so we define them here. Note that u64 is always - * unsigned long long, which works on all Linux systems: this means that we can - * use %llu in printf for any u64. */ + * like these abbreviations and the header we need uses them, so we define them + * here. + */ typedef unsigned long long u64; typedef uint32_t u32; typedef uint16_t u16; typedef uint8_t u8; +#include "linux/lguest_launcher.h" +#include "linux/pci_ids.h" +#include "linux/virtio_config.h" +#include "linux/virtio_net.h" +#include "linux/virtio_blk.h" +#include "linux/virtio_console.h" +#include "linux/virtio_ring.h" +#include "asm-x86/bootparam.h" /*:*/ #define PAGE_PRESENT 0x7 /* Present, RW, Execute */ @@ -360,8 +361,8 @@ static unsigned long load_bzimage(int fd) } /*L:140 Loading the kernel is easy when it's a "vmlinux", but most kernels - * come wrapped up in the self-decompressing "bzImage" format. With a little - * work, we can load those, too. */ + * come wrapped up in the self-decompressing "bzImage" format. With some funky + * coding, we can load those, too. */ static unsigned long load_kernel(int fd) { Elf32_Ehdr hdr; @@ -464,7 +465,6 @@ static unsigned long setup_pagetables(unsigned long mem, * to know where it is. */ return to_guest_phys(pgdir); } -/*:*/ /* Simple routine to roll all the commandline arguments together with spaces * between them. */ @@ -481,9 +481,9 @@ static void concat(char *dst, char *args[]) dst[len] = '\0'; } -/*L:185 This is where we actually tell the kernel to initialize the Guest. We - * saw the arguments it expects when we looked at initialize() in lguest_user.c: - * the base of Guest "physical" memory, the top physical page to allow, the +/* This is where we actually tell the kernel to initialize the Guest. We saw + * the arguments it expects when we looked at initialize() in lguest_user.c: + * the base of guest "physical" memory, the top physical page to allow, the * top level pagetable and the entry point for the Guest. */ static int tell_kernel(unsigned long pgdir, unsigned long start) { @@ -513,14 +513,13 @@ static void add_device_fd(int fd) /*L:200 * The Waker. * - * With console, block and network devices, we can have lots of input which we - * need to process. We could try to tell the kernel what file descriptors to - * watch, but handing a file descriptor mask through to the kernel is fairly - * icky. + * With a console and network devices, we can have lots of input which we need + * to process. We could try to tell the kernel what file descriptors to watch, + * but handing a file descriptor mask through to the kernel is fairly icky. * * Instead, we fork off a process which watches the file descriptors and writes - * the LHREQ_BREAK command to the /dev/lguest file descriptor to tell the Host - * stop running the Guest. This causes the Launcher to return from the + * the LHREQ_BREAK command to the /dev/lguest filedescriptor to tell the Host + * loop to stop running the Guest. This causes it to return from the * /dev/lguest read with -EAGAIN, where it will write to /dev/lguest to reset * the LHREQ_BREAK and wake us up again. * @@ -546,9 +545,7 @@ static void wake_parent(int pipefd, int lguest_fd) if (read(pipefd, &fd, sizeof(fd)) == 0) exit(0); /* Otherwise it's telling us to change what file - * descriptors we're to listen to. Positive means - * listen to a new one, negative means stop - * listening. */ + * descriptors we're to listen to. */ if (fd >= 0) FD_SET(fd, &devices.infds); else @@ -563,7 +560,7 @@ static int setup_waker(int lguest_fd) { int pipefd[2], child; - /* We create a pipe to talk to the Waker, and also so it knows when the + /* We create a pipe to talk to the waker, and also so it knows when the * Launcher dies (and closes pipe). */ pipe(pipefd); child = fork(); @@ -571,8 +568,7 @@ static int setup_waker(int lguest_fd) err(1, "forking"); if (child == 0) { - /* We are the Waker: close the "writing" end of our copy of the - * pipe and start waiting for input. */ + /* Close the "writing" end of our copy of the pipe */ close(pipefd[1]); wake_parent(pipefd[0], lguest_fd); } @@ -583,12 +579,12 @@ static int setup_waker(int lguest_fd) return pipefd[1]; } -/* +/*L:210 * Device Handling. * - * When the Guest gives us a buffer, it sends an array of addresses and sizes. + * When the Guest sends DMA to us, it sends us an array of addresses and sizes. * We need to make sure it's not trying to reach into the Launcher itself, so - * we have a convenient routine which checks it and exits with an error message + * we have a convenient routine which check it and exits with an error message * if something funny is going on: */ static void *_check_pointer(unsigned long addr, unsigned int size, @@ -605,9 +601,7 @@ static void *_check_pointer(unsigned long addr, unsigned int size, /* A macro which transparently hands the line number to the real function. */ #define check_pointer(addr,size) _check_pointer(addr, size, __LINE__) -/* Each buffer in the virtqueues is actually a chain of descriptors. This - * function returns the next descriptor in the chain, or vq->vring.num if we're - * at the end. */ +/* This function returns the next descriptor in the chain, or vq->vring.num. */ static unsigned next_desc(struct virtqueue *vq, unsigned int i) { unsigned int next; @@ -686,14 +680,13 @@ static unsigned get_vq_desc(struct virtqueue *vq, return head; } -/* After we've used one of their buffers, we tell them about it. We'll then +/* Once we've used one of their buffers, we tell them about it. We'll then * want to send them an interrupt, using trigger_irq(). */ static void add_used(struct virtqueue *vq, unsigned int head, int len) { struct vring_used_elem *used; - /* The virtqueue contains a ring of used buffers. Get a pointer to the - * next entry in that used ring. */ + /* Get a pointer to the next entry in the used ring. */ used = &vq->vring.used->ring[vq->vring.used->idx % vq->vring.num]; used->id = head; used->len = len; @@ -707,7 +700,6 @@ static void trigger_irq(int fd, struct virtqueue *vq) { unsigned long buf[] = { LHREQ_IRQ, vq->config.irq }; - /* If they don't want an interrupt, don't send one. */ if (vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT) return; @@ -724,11 +716,8 @@ static void add_used_and_trigger(int fd, struct virtqueue *vq, trigger_irq(fd, vq); } -/* - * The Console - * - * Here is the input terminal setting we save, and the routine to restore them - * on exit so the user gets their terminal back. */ +/* Here is the input terminal setting we save, and the routine to restore them + * on exit so the user can see what they type next. */ static struct termios orig_term; static void restore_term(void) { @@ -829,10 +818,7 @@ static void handle_console_output(int fd, struct virtqueue *vq) } } -/* - * The Network - * - * Handling output for network is also simple: we get all the output buffers +/* Handling output for network is also simple: we get all the output buffers * and write them (ignoring the first element) to this device's file descriptor * (stdout). */ static void handle_net_output(int fd, struct virtqueue *vq) @@ -845,9 +831,8 @@ static void handle_net_output(int fd, struct virtqueue *vq) while ((head = get_vq_desc(vq, iov, &out, &in)) != vq->vring.num) { if (in) errx(1, "Input buffers in output queue?"); - /* Check header, but otherwise ignore it (we told the Guest we - * supported no features, so it shouldn't have anything - * interesting). */ + /* Check header, but otherwise ignore it (we said we supported + * no features). */ (void)convert(&iov[0], struct virtio_net_hdr); len = writev(vq->dev->fd, iov+1, out-1); add_used_and_trigger(fd, vq, head, len); @@ -898,8 +883,7 @@ static bool handle_tun_input(int fd, struct device *dev) return true; } -/*L:215 This is the callback attached to the network and console input - * virtqueues: it ensures we try again, in case we stopped console or net +/* This callback ensures we try again, in case we stopped console or net * delivery because Guest didn't have any buffers. */ static void enable_fd(int fd, struct virtqueue *vq) { @@ -935,7 +919,7 @@ static void handle_output(int fd, unsigned long addr) strnlen(from_guest_phys(addr), guest_limit - addr)); } -/* This is called when the Waker wakes us up: check for incoming file +/* This is called when the waker wakes us up: check for incoming file * descriptors. */ static void handle_input(int fd) { @@ -1002,7 +986,8 @@ static struct lguest_device_desc *new_dev_desc(u16 type) } /* Each device descriptor is followed by some configuration information. - * Each configuration field looks like: u8 type, u8 len, [... len bytes...]. + * The first byte is a "status" byte for the Guest to report what's happening. + * After that are fields: u8 type, u8 len, [... len bytes...]. * * This routine adds a new field to an existing device's descriptor. It only * works for the last device, but that's OK because that's how we use it. */ @@ -1059,17 +1044,14 @@ static void add_virtqueue(struct device *dev, unsigned int num_descs, /* Link virtqueue back to device. */ vq->dev = dev; - /* Set the routine to call when the Guest does something to this - * virtqueue. */ + /* Set up handler. */ vq->handle_output = handle_output; - - /* Set the "Don't Notify Me" flag if we don't have a handler */ if (!handle_output) vq->vring.used->flags = VRING_USED_F_NO_NOTIFY; } /* This routine does all the creation and setup of a new device, including - * calling new_dev_desc() to allocate the descriptor and device memory. */ + * caling new_dev_desc() to allocate the descriptor and device memory. */ static struct device *new_device(const char *name, u16 type, int fd, bool (*handle_input)(int, struct device *)) { @@ -1078,7 +1060,7 @@ static struct device *new_device(const char *name, u16 type, int fd, /* Append to device list. Prepending to a single-linked list is * easier, but the user expects the devices to be arranged on the bus * in command-line order. The first network device on the command line - * is eth0, the first block device /dev/vda, etc. */ + * is eth0, the first block device /dev/lgba, etc. */ *devices.lastdev = dev; dev->next = NULL; devices.lastdev = &dev->next; @@ -1122,7 +1104,7 @@ static void setup_console(void) /* The console needs two virtqueues: the input then the output. When * they put something the input queue, we make sure we're listening to * stdin. When they put something in the output queue, we write it to - * stdout. */ + * stdout. */ add_virtqueue(dev, VIRTQUEUE_NUM, enable_fd); add_virtqueue(dev, VIRTQUEUE_NUM, handle_console_output); @@ -1270,17 +1252,21 @@ static void setup_tun_net(const char *arg) verbose("attached to bridge: %s\n", br_name); } -/* Our block (disk) device should be really simple: the Guest asks for a block - * number and we read or write that position in the file. Unfortunately, that - * was amazingly slow: the Guest waits until the read is finished before - * running anything else, even if it could have been doing useful work. + +/* + * Block device. * - * We could use async I/O, except it's reputed to suck so hard that characters - * actually go missing from your code when you try to use it. + * Serving a block device is really easy: the Guest asks for a block number and + * we read or write that position in the file. + * + * Unfortunately, this is amazingly slow: the Guest waits until the read is + * finished before running anything else, even if it could be doing useful + * work. We could use async I/O, except it's reputed to suck so hard that + * characters actually go missing from your code when you try to use it. * * So we farm the I/O out to thread, and communicate with it via a pipe. */ -/* This hangs off device->priv. */ +/* This hangs off device->priv, with the data. */ struct vblk_info { /* The size of the file. */ @@ -1296,14 +1282,8 @@ struct vblk_info * Launcher triggers interrupt to Guest. */ int done_fd; }; -/*:*/ -/*L:210 - * The Disk - * - * Remember that the block device is handled by a separate I/O thread. We head - * straight into the core of that thread here: - */ +/* This is the core of the I/O thread. It returns true if it did something. */ static bool service_io(struct device *dev) { struct vblk_info *vblk = dev->priv; @@ -1314,14 +1294,10 @@ static bool service_io(struct device *dev) struct iovec iov[dev->vq->vring.num]; off64_t off; - /* See if there's a request waiting. If not, nothing to do. */ head = get_vq_desc(dev->vq, iov, &out_num, &in_num); if (head == dev->vq->vring.num) return false; - /* Every block request should contain at least one output buffer - * (detailing the location on disk and the type of request) and one - * input buffer (to hold the result). */ if (out_num == 0 || in_num == 0) errx(1, "Bad virtblk cmd %u out=%u in=%u", head, out_num, in_num); @@ -1330,15 +1306,10 @@ static bool service_io(struct device *dev) in = convert(&iov[out_num+in_num-1], struct virtio_blk_inhdr); off = out->sector * 512; - /* The block device implements "barriers", where the Guest indicates - * that it wants all previous writes to occur before this write. We - * don't have a way of asking our kernel to do a barrier, so we just - * synchronize all the data in the file. Pretty poor, no? */ + /* This is how we implement barriers. Pretty poor, no? */ if (out->type & VIRTIO_BLK_T_BARRIER) fdatasync(vblk->fd); - /* In general the virtio block driver is allowed to try SCSI commands. - * It'd be nice if we supported eject, for example, but we don't. */ if (out->type & VIRTIO_BLK_T_SCSI_CMD) { fprintf(stderr, "Scsi commands unsupported\n"); in->status = VIRTIO_BLK_S_UNSUPP; @@ -1404,7 +1375,7 @@ static int io_thread(void *_dev) /* When this read fails, it means Launcher died, so we follow. */ while (read(vblk->workpipe[0], &c, 1) == 1) { - /* We acknowledge each request immediately to reduce latency, + /* We acknowledge each request immediately, to reduce latency, * rather than waiting until we've done them all. I haven't * measured to see if it makes any difference. */ while (service_io(dev)) @@ -1413,14 +1384,12 @@ static int io_thread(void *_dev) return 0; } -/* Now we've seen the I/O thread, we return to the Launcher to see what happens - * when the thread tells us it's completed some I/O. */ +/* When the thread says some I/O is done, we interrupt the Guest. */ static bool handle_io_finish(int fd, struct device *dev) { char c; - /* If the I/O thread died, presumably it printed the error, so we - * simply exit. */ + /* If child died, presumably it printed message. */ if (read(dev->fd, &c, 1) != 1) exit(1); @@ -1429,7 +1398,7 @@ static bool handle_io_finish(int fd, struct device *dev) return true; } -/* When the Guest submits some I/O, we just need to wake the I/O thread. */ +/* When the Guest submits some I/O, we wake the I/O thread. */ static void handle_virtblk_output(int fd, struct virtqueue *vq) { struct vblk_info *vblk = vq->dev->priv; @@ -1441,7 +1410,7 @@ static void handle_virtblk_output(int fd, struct virtqueue *vq) exit(1); } -/*L:198 This actually sets up a virtual block device. */ +/* This creates a virtual block device. */ static void setup_block_file(const char *filename) { int p[2]; @@ -1457,7 +1426,7 @@ static void setup_block_file(const char *filename) /* The device responds to return from I/O thread. */ dev = new_device("block", VIRTIO_ID_BLOCK, p[0], handle_io_finish); - /* The device has one virtqueue, where the Guest places requests. */ + /* The device has a virtqueue. */ add_virtqueue(dev, VIRTQUEUE_NUM, handle_virtblk_output); /* Allocate the room for our own bookkeeping */ @@ -1479,8 +1448,7 @@ static void setup_block_file(const char *filename) /* The I/O thread writes to this end of the pipe when done. */ vblk->done_fd = p[1]; - /* This is the second pipe, which is how we tell the I/O thread about - * more work. */ + /* This is how we tell the I/O thread about more work. */ pipe(vblk->workpipe); /* Create stack for thread and run it */ @@ -1519,25 +1487,24 @@ static void __attribute__((noreturn)) run_guest(int lguest_fd) char reason[1024] = { 0 }; read(lguest_fd, reason, sizeof(reason)-1); errx(1, "%s", reason); - /* EAGAIN means the Waker wanted us to look at some input. + /* EAGAIN means the waker wanted us to look at some input. * Anything else means a bug or incompatible change. */ } else if (errno != EAGAIN) err(1, "Running guest failed"); - /* Service input, then unset the BREAK to release the Waker. */ + /* Service input, then unset the BREAK which releases + * the Waker. */ handle_input(lguest_fd); if (write(lguest_fd, args, sizeof(args)) < 0) err(1, "Resetting break"); } } /* - * This is the end of the Launcher. The good news: we are over halfway - * through! The bad news: the most fiendish part of the code still lies ahead - * of us. + * This is the end of the Launcher. * - * Are you ready? Take a deep breath and join me in the core of the Host, in - * "make Host". - :*/ + * But wait! We've seen I/O from the Launcher, and we've seen I/O from the + * Drivers. If we were to see the Host kernel I/O code, our understanding + * would be complete... :*/ static struct option opts[] = { { "verbose", 0, NULL, 'v' }, @@ -1560,7 +1527,7 @@ int main(int argc, char *argv[]) /* Memory, top-level pagetable, code startpoint and size of the * (optional) initrd. */ unsigned long mem = 0, pgdir, start, initrd_size = 0; - /* Two temporaries and the /dev/lguest file descriptor. */ + /* A temporary and the /dev/lguest file descriptor. */ int i, c, lguest_fd; /* The boot information for the Guest. */ struct boot_params *boot; @@ -1655,7 +1622,6 @@ int main(int argc, char *argv[]) /* The boot header contains a command line pointer: we put the command * line after the boot header. */ boot->hdr.cmd_line_ptr = to_guest_phys(boot + 1); - /* We use a simple helper to copy the arguments separated by spaces. */ concat((char *)(boot + 1), argv+optind+2); /* Boot protocol version: 2.07 supports the fields for lguest. */ diff --git a/trunk/Documentation/networking/00-INDEX b/trunk/Documentation/networking/00-INDEX index f5a5e6d3d541..153d84d281e6 100644 --- a/trunk/Documentation/networking/00-INDEX +++ b/trunk/Documentation/networking/00-INDEX @@ -80,6 +80,8 @@ multicast.txt - Behaviour of cards under Multicast ncsa-telnet - notes on how NCSA telnet (DOS) breaks with MTU discovery enabled. +net-modules.txt + - info and "insmod" parameters for all network driver modules. netdevices.txt - info on network device driver functions exported to the kernel. olympic.txt diff --git a/trunk/Documentation/networking/ip-sysctl.txt b/trunk/Documentation/networking/ip-sysctl.txt index 6f7872ba1def..747a5d15d529 100644 --- a/trunk/Documentation/networking/ip-sysctl.txt +++ b/trunk/Documentation/networking/ip-sysctl.txt @@ -184,14 +184,14 @@ tcp_frto - INTEGER F-RTO is an enhanced recovery algorithm for TCP retransmission timeouts. It is particularly beneficial in wireless environments where packet loss is typically due to random radio interference - rather than intermediate router congestion. F-RTO is sender-side + rather than intermediate router congestion. FRTO is sender-side only modification. Therefore it does not require any support from the peer, but in a typical case, however, where wireless link is the local access link and most of the data flows downlink, the - faraway servers should have F-RTO enabled to take advantage of it. + faraway servers should have FRTO enabled to take advantage of it. If set to 1, basic version is enabled. 2 enables SACK enhanced F-RTO if flow uses SACK. The basic version can be used also when - SACK is in use though scenario(s) with it exists where F-RTO + SACK is in use though scenario(s) with it exists where FRTO interacts badly with the packet counting of the SACK enabled TCP flow. diff --git a/trunk/Documentation/networking/net-modules.txt b/trunk/Documentation/networking/net-modules.txt new file mode 100644 index 000000000000..98c4392dd0fd --- /dev/null +++ b/trunk/Documentation/networking/net-modules.txt @@ -0,0 +1,315 @@ +Wed 2-Aug-95 + + Linux network driver modules + + Do not mistake this for "README.modules" at the top-level + directory! That document tells about modules in general, while + this one tells only about network device driver modules. + + This is a potpourri of INSMOD-time(*) configuration options + (if such exists) and their default values of various modules + in the Linux network drivers collection. + + Some modules have also hidden (= non-documented) tunable values. + The choice of not documenting them is based on general belief, that + the less the user needs to know, the better. (There are things that + driver developers can use, others should not confuse themselves.) + + In many cases it is highly preferred that insmod:ing is done + ONLY with defining an explicit address for the card, AND BY + NOT USING AUTO-PROBING! + + Now most cards have some explicitly defined base address that they + are compiled with (to avoid auto-probing, among other things). + If that compiled value does not match your actual configuration, + do use the "io=0xXXX" -parameter for the insmod, and give there + a value matching your environment. + + If you are adventurous, you can ask the driver to autoprobe + by using the "io=0" parameter, however it is a potentially dangerous + thing to do in a live system. (If you don't know where the + card is located, you can try autoprobing, and after possible + crash recovery, insmod with proper IO-address..) + + -------------------------- + (*) "INSMOD-time" means when you load module with + /sbin/insmod you can feed it optional parameters. + See "man insmod". + -------------------------- + + + 8390 based Network Modules (Paul Gortmaker, Nov 12, 1995) + -------------------------- + +(Includes: smc-ultra, ne, wd, 3c503, hp, hp-plus, e2100 and ac3200) + +The 8390 series of network drivers now support multiple card systems without +reloading the same module multiple times (memory efficient!) This is done by +specifying multiple comma separated values, such as: + + insmod 3c503.o io=0x280,0x300,0x330,0x350 xcvr=0,1,0,1 + +The above would have the one module controlling four 3c503 cards, with card 2 +and 4 using external transceivers. The "insmod" manual describes the usage +of comma separated value lists. + +It is *STRONGLY RECOMMENDED* that you supply "io=" instead of autoprobing. +If an "io=" argument is not supplied, then the ISA drivers will complain +about autoprobing being not recommended, and begrudgingly autoprobe for +a *SINGLE CARD ONLY* -- if you want to use multiple cards you *have* to +supply an "io=0xNNN,0xQQQ,..." argument. + +The ne module is an exception to the above. A NE2000 is essentially an +8390 chip, some bus glue and some RAM. Because of this, the ne probe is +more invasive than the rest, and so at boot we make sure the ne probe is +done last of all the 8390 cards (so that it won't trip over other 8390 based +cards) With modules we can't ensure that all other non-ne 8390 cards have +already been found. Because of this, the ne module REQUIRES an "io=0xNNN" +argument passed in via insmod. It will refuse to autoprobe. + +It is also worth noting that auto-IRQ probably isn't as reliable during +the flurry of interrupt activity on a running machine. Cards such as the +ne2000 that can't get the IRQ setting from an EEPROM or configuration +register are probably best supplied with an "irq=M" argument as well. + + +---------------------------------------------------------------------- +Card/Module List - Configurable Parameters and Default Values +---------------------------------------------------------------------- + +3c501.c: + io = 0x280 IO base address + irq = 5 IRQ + (Probes ports: 0x280, 0x300) + +3c503.c: + io = 0 (It will complain if you don't supply an "io=0xNNN") + irq = 0 (IRQ software selected by driver using autoIRQ) + xcvr = 0 (Use xcvr=1 to select external transceiver.) + (Probes ports: 0x300, 0x310, 0x330, 0x350, 0x250, 0x280, 0x2A0, 0x2E0) + +3c505.c: + io = 0 + irq = 0 + dma = 6 (not autoprobed) + (Probes ports: 0x300, 0x280, 0x310) + +3c507.c: + io = 0x300 + irq = 0 + (Probes ports: 0x300, 0x320, 0x340, 0x280) + +3c509.c: + io = 0 + irq = 0 + ( Module load-time probing Works reliably only on EISA, ISA ID-PROBE + IS NOT RELIABLE! Compile this driver statically into kernel for + now, if you need it auto-probing on an ISA-bus machine. ) + +8390.c: + (No public options, several other modules need this one) + +a2065.c: + Since this is a Zorro board, it supports full autoprobing, even for + multiple boards. (m68k/Amiga) + +ac3200.c: + io = 0 (Checks 0x1000 to 0x8fff in 0x1000 intervals) + irq = 0 (Read from config register) + (EISA probing..) + +apricot.c: + io = 0x300 (Can't be altered!) + irq = 10 + +arcnet.c: + io = 0 + irqnum = 0 + shmem = 0 + num = 0 + DO SET THESE MANUALLY AT INSMOD! + (When probing, looks at the following possible addresses: + Suggested ones: + 0x300, 0x2E0, 0x2F0, 0x2D0 + Other ones: + 0x200, 0x210, 0x220, 0x230, 0x240, 0x250, 0x260, 0x270, + 0x280, 0x290, 0x2A0, 0x2B0, 0x2C0, + 0x310, 0x320, 0x330, 0x340, 0x350, 0x360, 0x370, + 0x380, 0x390, 0x3A0, 0x3E0, 0x3F0 ) + +ariadne.c: + Since this is a Zorro board, it supports full autoprobing, even for + multiple boards. (m68k/Amiga) + +at1700.c: + io = 0x260 + irq = 0 + (Probes ports: 0x260, 0x280, 0x2A0, 0x240, 0x340, 0x320, 0x380, 0x300) + +atarilance.c: + Supports full autoprobing. (m68k/Atari) + +atp.c: *Not modularized* + (Probes ports: 0x378, 0x278, 0x3BC; + fixed IRQs: 5 and 7 ) + +cops.c: + io = 0x240 + irq = 5 + nodeid = 0 (AutoSelect = 0, NodeID 1-254 is hand selected.) + (Probes ports: 0x240, 0x340, 0x200, 0x210, 0x220, 0x230, 0x260, + 0x2A0, 0x300, 0x310, 0x320, 0x330, 0x350, 0x360) + +de4x5.c: + io = 0x000b + irq = 10 + is_not_dec = 0 -- For non-DEC card using DEC 21040/21041/21140 chip, set this to 1 + (EISA, and PCI probing) + +de600.c: + de600_debug = 0 + (On port 0x378, irq 7 -- lpt1; compile time configurable) + +de620.c: + bnc = 0, utp = 0 <-- Force media by setting either. + io = 0x378 (also compile-time configurable) + irq = 7 + +depca.c: + io = 0x200 + irq = 7 + (Probes ports: ISA: 0x300, 0x200; + EISA: 0x0c00 ) + +dummy.c: + No options + +e2100.c: + io = 0 (It will complain if you don't supply an "io=0xNNN") + irq = 0 (IRQ software selected by driver) + mem = 0 (Override default shared memory start of 0xd0000) + xcvr = 0 (Use xcvr=1 to select external transceiver.) + (Probes ports: 0x300, 0x280, 0x380, 0x220) + +eepro.c: + io = 0x200 + irq = 0 + (Probes ports: 0x200, 0x240, 0x280, 0x2C0, 0x300, 0x320, 0x340, 0x360) + +eexpress.c: + io = 0x300 + irq = 0 (IRQ value read from EEPROM) + (Probes ports: 0x300, 0x270, 0x320, 0x340) + +eql.c: + (No parameters) + +ewrk3.c: + io = 0x300 + irq = 5 + (With module no autoprobing! + On EISA-bus does EISA probing. + Static linkage probes ports on ISA bus: + 0x100, 0x120, 0x140, 0x160, 0x180, 0x1A0, 0x1C0, + 0x200, 0x220, 0x240, 0x260, 0x280, 0x2A0, 0x2C0, 0x2E0, + 0x300, 0x340, 0x360, 0x380, 0x3A0, 0x3C0) + +hp-plus.c: + io = 0 (It will complain if you don't supply an "io=0xNNN") + irq = 0 (IRQ read from configuration register) + (Probes ports: 0x200, 0x240, 0x280, 0x2C0, 0x300, 0x320, 0x340) + +hp.c: + io = 0 (It will complain if you don't supply an "io=0xNNN") + irq = 0 (IRQ software selected by driver using autoIRQ) + (Probes ports: 0x300, 0x320, 0x340, 0x280, 0x2C0, 0x200, 0x240) + +hp100.c: + hp100_port = 0 (IO-base address) + (Does EISA-probing, if on EISA-slot; + On ISA-bus probes all ports from 0x100 thru to 0x3E0 + in increments of 0x020) + +hydra.c: + Since this is a Zorro board, it supports full autoprobing, even for + multiple boards. (m68k/Amiga) + +ibmtr.c: + io = 0xa20, 0xa24 (autoprobed by default) + irq = 0 (driver cannot select irq - read from hardware) + mem = 0 (shared memory base set at 0xd0000 and not yet + able to override thru mem= parameter.) + +lance.c: *Not modularized* + (PCI, and ISA probing; "CONFIG_PCI" needed for PCI support) + (Probes ISA ports: 0x300, 0x320, 0x340, 0x360) + +loopback.c: *Static kernel component* + +ne.c: + io = 0 (Explicitly *requires* an "io=0xNNN" value) + irq = 0 (Tries to determine configured IRQ via autoIRQ) + (Probes ports: 0x300, 0x280, 0x320, 0x340, 0x360) + +net_init.c: *Static kernel component* + +ni52.c: *Not modularized* + (Probes ports: 0x300, 0x280, 0x360, 0x320, 0x340 + mems: 0xD0000, 0xD2000, 0xC8000, 0xCA000, + 0xD4000, 0xD6000, 0xD8000 ) + +ni65.c: *Not modularized* **16MB MEMORY BARRIER BUG** + (Probes ports: 0x300, 0x320, 0x340, 0x360) + +pi2.c: *Not modularized* (well, NON-STANDARD modularization!) + Only one card supported at this time. + (Probes ports: 0x380, 0x300, 0x320, 0x340, 0x360, 0x3A0) + +plip.c: + io = 0 + irq = 0 (by default, uses IRQ 5 for port at 0x3bc, IRQ 7 + for port at 0x378, and IRQ 2 for port at 0x278) + (Probes ports: 0x278, 0x378, 0x3bc) + +ppp.c: + No options (ppp-2.2+ has some, this is based on non-dynamic + version from ppp-2.1.2d) + +seeq8005.c: *Not modularized* + (Probes ports: 0x300, 0x320, 0x340, 0x360) + +skeleton.c: *Skeleton* + +slhc.c: + No configuration parameters + +slip.c: + slip_maxdev = 256 (default value from SL_NRUNIT on slip.h) + + +smc-ultra.c: + io = 0 (It will complain if you don't supply an "io=0xNNN") + irq = 0 (IRQ val. read from EEPROM) + (Probes ports: 0x200, 0x220, 0x240, 0x280, 0x300, 0x340, 0x380) + +tulip.c: *Partial modularization* + (init-time memory allocation makes problems..) + +tunnel.c: + No insmod parameters + +wavelan.c: + io = 0x390 (Settable, but change not recommended) + irq = 0 (Not honoured, if changed..) + +wd.c: + io = 0 (It will complain if you don't supply an "io=0xNNN") + irq = 0 (IRQ val. read from EEPROM, ancient cards use autoIRQ) + mem = 0 (Force shared-memory on address 0xC8000, or whatever..) + mem_end = 0 (Force non-std. mem. size via supplying mem_end val.) + (eg. for 32k WD8003EBT, use mem=0xd0000 mem_end=0xd8000) + (Probes ports: 0x300, 0x280, 0x380, 0x240) + +znet.c: *Not modularized* + (Only one device on Zenith Z-Note (notebook?) systems, + configuration information from (EE)PROM) diff --git a/trunk/Documentation/networking/tc-actions-env-rules.txt b/trunk/Documentation/networking/tc-actions-env-rules.txt deleted file mode 100644 index 01e716d185f4..000000000000 --- a/trunk/Documentation/networking/tc-actions-env-rules.txt +++ /dev/null @@ -1,29 +0,0 @@ - -The "enviromental" rules for authors of any new tc actions are: - -1) If you stealeth or borroweth any packet thou shalt be branching -from the righteous path and thou shalt cloneth. - -For example if your action queues a packet to be processed later -or intentionaly branches by redirecting a packet then you need to -clone the packet. -There are certain fields in the skb tc_verd that need to be reset so we -avoid loops etc. A few are generic enough so much so that skb_act_clone() -resets them for you. So invoke skb_act_clone() rather than skb_clone() - -2) If you munge any packet thou shalt call pskb_expand_head in the case -someone else is referencing the skb. After that you "own" the skb. -You must also tell us if it is ok to munge the packet (TC_OK2MUNGE), -this way any action downstream can stomp on the packet. - -3) dropping packets you dont own is a nono. You simply return -TC_ACT_SHOT to the caller and they will drop it. - -The "enviromental" rules for callers of actions (qdiscs etc) are: - -*) thou art responsible for freeing anything returned as being -TC_ACT_SHOT/STOLEN/QUEUED. If none of TC_ACT_SHOT/STOLEN/QUEUED is -returned then all is great and you dont need to do anything. - -Post on netdev if something is unclear. - diff --git a/trunk/Documentation/scsi/link_power_management_policy.txt b/trunk/Documentation/scsi/link_power_management_policy.txt deleted file mode 100644 index d18993d01884..000000000000 --- a/trunk/Documentation/scsi/link_power_management_policy.txt +++ /dev/null @@ -1,19 +0,0 @@ -This parameter allows the user to set the link (interface) power management. -There are 3 possible options: - -Value Effect ----------------------------------------------------------------------------- -min_power Tell the controller to try to make the link use the - least possible power when possible. This may - sacrifice some performance due to increased latency - when coming out of lower power states. - -max_performance Generally, this means no power management. Tell - the controller to have performance be a priority - over power management. - -medium_power Tell the controller to enter a lower power state - when possible, but do not enter the lowest power - state, thus improving latency over min_power setting. - - diff --git a/trunk/Documentation/scsi/sym53c8xx_2.txt b/trunk/Documentation/scsi/sym53c8xx_2.txt index 49ea5c58c6bc..3d9f06bb3d00 100644 --- a/trunk/Documentation/scsi/sym53c8xx_2.txt +++ b/trunk/Documentation/scsi/sym53c8xx_2.txt @@ -449,14 +449,25 @@ options as above. cmd_per_lun=#tags (#tags > 1) tagged command queuing enabled #tags will be truncated to the max queued commands configuration parameter. -10.2.2 Burst max +10.2.2 Detailed control of tagged commands + This option allows you to specify a command queue depth for each device + that supports tagged command queueing. + Example: + tag_ctrl=10/t2t3q16-t5q24/t1u2q32 + will set devices queue depth as follow: + - controller #0 target #2 and target #3 -> 16 commands, + - controller #0 target #5 -> 24 commands, + - controller #1 target #1 logical unit #2 -> 32 commands, + - all other logical units (all targets, all controllers) -> 10 commands. + +10.2.3 Burst max burst=0 burst disabled burst=255 get burst length from initial IO register settings. burst=#x burst enabled (1<<#x burst transfers max) #x is an integer value which is log base 2 of the burst transfers max. By default the driver uses the maximum value supported by the chip. -10.2.3 LED support +10.2.4 LED support led=1 enable LED support led=0 disable LED support Do not enable LED support if your scsi board does not use SDMS BIOS. @@ -549,9 +560,9 @@ Previously, the sym2 driver accepted arguments of the form sym53c8xx=tags:4,sync:10,debug:0x200 As a result of the new module parameters, this is no longer available. -Most of the options have remained the same, but tags has become -cmd_per_lun to reflect its different purposes. The sample above would -be specified as: +Most of the options have remained the same, but tags has split into +cmd_per_lun and tag_ctrl for its two different purposes. The sample above +would be specified as: modprobe sym53c8xx cmd_per_lun=4 sync=10 debug=0x200 or on the kernel boot line as: diff --git a/trunk/Documentation/watchdog/src/watchdog-simple.c b/trunk/Documentation/watchdog/src/watchdog-simple.c index 4cf72f3fa8e9..47801bc7e742 100644 --- a/trunk/Documentation/watchdog/src/watchdog-simple.c +++ b/trunk/Documentation/watchdog/src/watchdog-simple.c @@ -3,25 +3,15 @@ #include #include -int main(void) -{ +int main(int argc, const char *argv[]) { int fd = open("/dev/watchdog", O_WRONLY); - int ret = 0; if (fd == -1) { perror("watchdog"); - exit(EXIT_FAILURE); + exit(1); } while (1) { - ret = write(fd, "\0", 1); - if (ret != 1) { - ret = -1; - break; - } - ret = fsync(fd); - if (ret) - break; + write(fd, "\0", 1); + fsync(fd); sleep(10); } - close(fd); - return ret; } diff --git a/trunk/MAINTAINERS b/trunk/MAINTAINERS index 4a26f832b4b5..40245af2d0e3 100644 --- a/trunk/MAINTAINERS +++ b/trunk/MAINTAINERS @@ -136,6 +136,17 @@ M: ajk@iehk.rwth-aachen.de L: linux-hams@vger.kernel.org S: Maintained +8139CP 10/100 FAST ETHERNET DRIVER +P: Jeff Garzik +M: jgarzik@pobox.com +S: Maintained + +8139TOO 10/100 FAST ETHERNET DRIVER +P: Jeff Garzik +M: jgarzik@pobox.com +W: http://sourceforge.net/projects/gkernel/ +S: Maintained + 8169 10/100/1000 GIGABIT ETHERNET DRIVER P: Francois Romieu M: romieu@fr.zoreil.com @@ -216,7 +227,7 @@ P: Len Brown M: len.brown@intel.com M: lenb@kernel.org L: linux-acpi@vger.kernel.org -W: http://www.lesswatts.org/projects/acpi/ +W: http://acpi.sourceforge.net/ T: git kernel.org:/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6.git S: Supported @@ -235,8 +246,8 @@ W: http://acpi.sourceforge.net/ S: Supported ACPI FAN DRIVER -P: Len Brown -M: len.brown@intel.com +P: Konstantin A. Karasyov +M: konstantin.a.karasyov@intel.com L: linux-acpi@vger.kernel.org W: http://acpi.sourceforge.net/ S: Supported @@ -248,15 +259,15 @@ L: pcihpd-discuss@lists.sourceforge.net S: Supported ACPI THERMAL DRIVER -P: Len Brown -M: len.brown@intel.com +P: Konstantin A. Karasyov +M: konstantin.a.karasyov@intel.com L: linux-acpi@vger.kernel.org W: http://acpi.sourceforge.net/ S: Supported ACPI VIDEO DRIVER -P: Rui Zhang -M: rui.zhang@intel.com +P: Luming Yu +M: luming.yu@intel.com L: linux-acpi@vger.kernel.org W: http://acpi.sourceforge.net/ S: Supported @@ -314,12 +325,6 @@ M: Juergen Fischer L: linux-scsi@vger.kernel.org S: Maintained -AIC7XXX / AIC79XX SCSI DRIVER -P: Hannes Reinecke -M: hare@suse.de -L: linux-scsi@vger.kernel.org -S: Maintained - ALCATEL SPEEDTOUCH USB DRIVER P: Duncan Sands M: duncan.sands@free.fr @@ -1032,6 +1037,12 @@ M: kernel@wantstofly.org L: netdev@vger.kernel.org S: Maintained +CIRRUS LOGIC GENERIC FBDEV DRIVER +P: Jeff Garzik +M: jgarzik@pobox.com +L: linux-fbdev-devel@lists.sourceforge.net (subscribers-only) +S: Odd Fixes + CIRRUS LOGIC EP93XX OHCI USB HOST DRIVER P: Lennert Buytenhek M: kernel@wantstofly.org @@ -1952,6 +1963,12 @@ M: adaplas@gmail.com L: linux-fbdev-devel@lists.sourceforge.net (subscribers-only) S: Maintained +INTEL I8XX RANDOM NUMBER GENERATOR SUPPORT +P: Jeff Garzik +M: jgarzik@pobox.com +W: http://sourceforge.net/projects/gkernel/ +S: Maintained + INTEL IA32 MICROCODE UPDATE SUPPORT P: Tigran Aivazian M: tigran@aivazian.fsnet.co.uk @@ -2129,8 +2146,8 @@ S: Maintained JOURNALLING FLASH FILE SYSTEM V2 (JFFS2) P: David Woodhouse M: dwmw2@infradead.org -L: linux-mtd@lists.infradead.org -W: http://www.linux-mtd.infradead.org/doc/jffs2.html +L: jffs-dev@axis.com +W: http://sources.redhat.com/jffs2/ S: Maintained JFS FILESYSTEM @@ -2259,13 +2276,6 @@ L: legousb-devel@lists.sourceforge.net W: http://legousb.sourceforge.net/ S: Maintained -LGUEST -P: Rusty Russell -M: rusty@rustcorp.com.au -L: lguest@ozlabs.org -W: http://lguest.ozlabs.org/ -S: Maintained - LINUX FOR IBM pSERIES (RS/6000) P: Paul Mackerras M: paulus@au.ibm.com @@ -2449,15 +2459,13 @@ W: http://www.tazenda.demon.co.uk/phil/linux-hp S: Maintained MAC80211 -P: Michael Wu -M: flamingice@sourmilk.net -P: Johannes Berg -M: johannes@sipsolutions.net P: Jiri Benc M: jbenc@suse.cz +P: Michael Wu +M: flamingice@sourmilk.net L: linux-wireless@vger.kernel.org W: http://linuxwireless.org/ -T: git kernel.org:/pub/scm/linux/kernel/git/linville/wireless-2.6.git +T: git kernel.org:/pub/scm/linux/kernel/git/jbenc/mac80211.git S: Maintained MACVLAN DRIVER @@ -2687,6 +2695,8 @@ M: Paul.Clements@steeleye.com S: Maintained NETWORK DEVICE DRIVERS +P: Andrew Morton +M: akpm@linux-foundation.org P: Jeff Garzik M: jgarzik@pobox.com L: netdev@vger.kernel.org @@ -3238,8 +3248,6 @@ S: Supported S390 NETWORK DRIVERS P: Ursula Braun M: ubraun@linux.vnet.ibm.com -P: Frank Blaschka -M: blaschka@linux.vnet.ibm.com M: linux390@de.ibm.com L: linux-s390@vger.kernel.org W: http://www.ibm.com/developerworks/linux/linux390/ @@ -3472,14 +3480,12 @@ L: linux-pm@lists.linux-foundation.org S: Supported SUSPEND TO RAM: -P: Len Brown -M: len.brown@intel.com P: Pavel Machek M: pavel@suse.cz P: Rafael J. Wysocki M: rjw@sisk.pl L: linux-pm@lists.linux-foundation.org -S: Supported +S: Maintained SONIC NETWORK DRIVER P: Thomas Bogendoerfer @@ -4097,6 +4103,10 @@ M: hirofumi@mail.parknet.co.jp L: linux-kernel@vger.kernel.org S: Maintained +VIA 82Cxxx AUDIO DRIVER (old OSS driver) +P: Jeff Garzik +S: Odd fixes + VIA RHINE NETWORK DRIVER P: Roger Luethi M: rl@hellgate.ch @@ -4152,12 +4162,6 @@ W: http://linuxtv.org T: git kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb.git S: Maintained -VLAN (802.1Q) -P: Patrick McHardy -M: kaber@trash.net -L: netdev@vger.kernel.org -S: Maintained - VT1211 HARDWARE MONITOR DRIVER P: Juerg Haefliger M: juergh@gmail.com diff --git a/trunk/Makefile b/trunk/Makefile index 8816060cdf40..264f37b8b263 100644 --- a/trunk/Makefile +++ b/trunk/Makefile @@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 6 -SUBLEVEL = 24 -EXTRAVERSION = -rc1 +SUBLEVEL = 23 +EXTRAVERSION = NAME = Arr Matey! A Hairy Bilge Rat! # *DOCUMENTATION* @@ -196,9 +196,6 @@ CROSS_COMPILE ?= UTS_MACHINE := $(ARCH) SRCARCH := $(ARCH) -# for i386 and x86_64 we use SRCARCH equal to x86 -SRCARCH := $(if $(filter x86_64 i386,$(SRCARCH)),x86,$(SRCARCH)) - KCONFIG_CONFIG ?= .config # SHELL used by kbuild @@ -421,7 +418,7 @@ ifeq ($(config-targets),1) # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. # KBUILD_DEFCONFIG may point out an alternative default configuration # used for 'make defconfig' -include $(srctree)/arch/$(SRCARCH)/Makefile +include $(srctree)/arch/$(ARCH)/Makefile export KBUILD_DEFCONFIG config %config: scripts_basic outputmakefile FORCE @@ -500,7 +497,7 @@ else KBUILD_CFLAGS += -O2 endif -include $(srctree)/arch/$(SRCARCH)/Makefile +include $(srctree)/arch/$(ARCH)/Makefile ifdef CONFIG_FRAME_POINTER KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls diff --git a/trunk/arch/arm/mach-ixp2000/Kconfig b/trunk/arch/arm/mach-ixp2000/Kconfig index 08d2707f6ca8..86f53f8ccbf5 100644 --- a/trunk/arch/arm/mach-ixp2000/Kconfig +++ b/trunk/arch/arm/mach-ixp2000/Kconfig @@ -14,7 +14,7 @@ config ARCH_ENP2611 help Say 'Y' here if you want your kernel to support the Radisys ENP2611 PCI network processing card. For more information on - this card, see . + this card, see . config ARCH_IXDP2400 bool "Support Intel IXDP2400" diff --git a/trunk/arch/arm/mach-pxa/pxa300.c b/trunk/arch/arm/mach-pxa/pxa300.c index 7a34231f3172..5363b1322652 100644 --- a/trunk/arch/arm/mach-pxa/pxa300.c +++ b/trunk/arch/arm/mach-pxa/pxa300.c @@ -23,10 +23,8 @@ static struct pxa3xx_mfp_addr_map pxa300_mfp_addr_map[] __initdata = { MFP_ADDR_X(GPIO0, GPIO2, 0x00b4), MFP_ADDR_X(GPIO3, GPIO26, 0x027c), - MFP_ADDR_X(GPIO27, GPIO98, 0x0400), - MFP_ADDR_X(GPIO99, GPIO127, 0x0600), - MFP_ADDR_X(GPIO0_2, GPIO1_2, 0x0674), - MFP_ADDR_X(GPIO2_2, GPIO6_2, 0x02dc), + MFP_ADDR_X(GPIO27, GPIO127, 0x0400), + MFP_ADDR_X(GPIO0_2, GPIO6_2, 0x02ec), MFP_ADDR(nBE0, 0x0204), MFP_ADDR(nBE1, 0x0208), diff --git a/trunk/arch/arm/vfp/vfpdouble.c b/trunk/arch/arm/vfp/vfpdouble.c index 190a09ad18eb..74e89f8fb3ab 100644 --- a/trunk/arch/arm/vfp/vfpdouble.c +++ b/trunk/arch/arm/vfp/vfpdouble.c @@ -1132,7 +1132,7 @@ u32 vfp_double_cpdo(u32 inst, u32 fpscr) unsigned int vecitr, veclen, vecstride; struct op *fop; - vecstride = (1 + ((fpscr & FPSCR_STRIDE_MASK) == FPSCR_STRIDE_MASK)); + vecstride = (1 + ((fpscr & FPSCR_STRIDE_MASK) == FPSCR_STRIDE_MASK)) * 2; fop = (op == FOP_EXT) ? &fops_ext[FEXT_TO_IDX(inst)] : &fops[FOP_TO_IDX(op)]; @@ -1184,10 +1184,10 @@ u32 vfp_double_cpdo(u32 inst, u32 fpscr) * CHECK: It appears to be undefined whether we stop when * we encounter an exception. We continue. */ - dest = FREG_BANK(dest) + ((FREG_IDX(dest) + vecstride) & 3); - dn = FREG_BANK(dn) + ((FREG_IDX(dn) + vecstride) & 3); + dest = FREG_BANK(dest) + ((FREG_IDX(dest) + vecstride) & 6); + dn = FREG_BANK(dn) + ((FREG_IDX(dn) + vecstride) & 6); if (FREG_BANK(dm) != 0) - dm = FREG_BANK(dm) + ((FREG_IDX(dm) + vecstride) & 3); + dm = FREG_BANK(dm) + ((FREG_IDX(dm) + vecstride) & 6); } return exceptions; diff --git a/trunk/arch/arm/vfp/vfpmodule.c b/trunk/arch/arm/vfp/vfpmodule.c index b4e210df92f2..eea3f50743d5 100644 --- a/trunk/arch/arm/vfp/vfpmodule.c +++ b/trunk/arch/arm/vfp/vfpmodule.c @@ -229,7 +229,7 @@ void VFP9_bounce(u32 trigger, u32 fpexc, struct pt_regs *regs) /* * Enable access to the VFP so we can handle the bounce. */ - fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_FPV2|FPEXC_INV|FPEXC_UFC|FPEXC_OFC|FPEXC_IOC)); + fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_INV|FPEXC_UFC|FPEXC_IOC)); orig_fpscr = fpscr = fmrx(FPSCR); diff --git a/trunk/arch/blackfin/Kconfig b/trunk/arch/blackfin/Kconfig index 9f9de3e95826..7888551ed939 100644 --- a/trunk/arch/blackfin/Kconfig +++ b/trunk/arch/blackfin/Kconfig @@ -295,12 +295,6 @@ config PNAV10 help PNAV 1.0 board Support. -config H8606_HVSISTEMAS - bool "HV Sistemas H8606" - depends on (BF532) - help - HV Sistemas H8606 board support. - config GENERIC_BOARD bool "Custom" depends on (BF537 || BF536 \ @@ -323,8 +317,7 @@ config MEM_MT48LC64M4A2FB_7E config MEM_MT48LC16M16A2TG_75 bool depends on (BFIN533_EZKIT || BFIN561_EZKIT \ - || BFIN533_BLUETECHNIX_CM || BFIN537_BLUETECHNIX_CM \ - || H8606_HVSISTEMAS) + || BFIN533_BLUETECHNIX_CM || BFIN537_BLUETECHNIX_CM) default y config MEM_MT48LC32M8A2_75 @@ -373,7 +366,7 @@ config CLKIN_HZ int "Crystal Frequency in Hz" default "11059200" if BFIN533_STAMP default "27000000" if BFIN533_EZKIT - default "25000000" if (BFIN537_STAMP || BFIN527_EZKIT || H8606_HVSISTEMAS) + default "25000000" if (BFIN537_STAMP || BFIN527_EZKIT) default "30000000" if BFIN561_EZKIT default "24576000" if PNAV10 help @@ -411,7 +404,6 @@ config VCO_MULT default "20" if BFIN537_BLUETECHNIX_CM default "20" if BFIN561_BLUETECHNIX_CM default "20" if BFIN561_EZKIT - default "16" if H8606_HVSISTEMAS help This controls the frequency of the on-chip PLL. This can be between 1 and 64. PLL Frequency = (Crystal Frequency) * (this setting) @@ -448,7 +440,6 @@ config SCLK_DIV default 4 if BFIN537_BLUETECHNIX_CM default 4 if BFIN561_BLUETECHNIX_CM default 5 if BFIN561_EZKIT - default 3 if H8606_HVSISTEMAS help This sets the frequency of the system clock (including SDRAM or DDR). This can be between 1 and 15 @@ -501,13 +492,11 @@ config MEM_SIZE default 64 if BFIN561_EZKIT default 128 if BFIN533_STAMP default 64 if PNAV10 - default 32 if H8606_HVSISTEMAS config MEM_ADD_WIDTH int "SDRAM Memory Address Width" default 9 if BFIN533_EZKIT default 9 if BFIN561_EZKIT - default 9 if H8606_HVSISTEMAS default 10 if BFIN527_EZKIT default 10 if BFIN537_STAMP default 11 if BFIN533_STAMP diff --git a/trunk/arch/blackfin/configs/BF527-EZKIT_defconfig b/trunk/arch/blackfin/configs/BF527-EZKIT_defconfig index 1f6a93df6b32..df974e785ee2 100644 --- a/trunk/arch/blackfin/configs/BF527-EZKIT_defconfig +++ b/trunk/arch/blackfin/configs/BF527-EZKIT_defconfig @@ -244,7 +244,7 @@ CONFIG_CLKIN_HZ=25000000 # CONFIG_BFIN_KERNEL_CLOCK is not set CONFIG_MAX_VCO_HZ=600000000 CONFIG_MIN_VCO_HZ=50000000 -CONFIG_MAX_SCLK_HZ=133333333 +CONFIG_MAX_SCLK_HZ=133000000 CONFIG_MIN_SCLK_HZ=27000000 # diff --git a/trunk/arch/blackfin/configs/BF533-EZKIT_defconfig b/trunk/arch/blackfin/configs/BF533-EZKIT_defconfig index 9e9b420342d1..57f58d5cd47a 100644 --- a/trunk/arch/blackfin/configs/BF533-EZKIT_defconfig +++ b/trunk/arch/blackfin/configs/BF533-EZKIT_defconfig @@ -198,7 +198,7 @@ CONFIG_CLKIN_HZ=27000000 # CONFIG_BFIN_KERNEL_CLOCK is not set CONFIG_MAX_VCO_HZ=750000000 CONFIG_MIN_VCO_HZ=50000000 -CONFIG_MAX_SCLK_HZ=133333333 +CONFIG_MAX_SCLK_HZ=133000000 CONFIG_MIN_SCLK_HZ=27000000 # diff --git a/trunk/arch/blackfin/configs/BF533-STAMP_defconfig b/trunk/arch/blackfin/configs/BF533-STAMP_defconfig index f59ade980109..306302baff06 100644 --- a/trunk/arch/blackfin/configs/BF533-STAMP_defconfig +++ b/trunk/arch/blackfin/configs/BF533-STAMP_defconfig @@ -199,7 +199,7 @@ CONFIG_CLKIN_HZ=11059200 # CONFIG_BFIN_KERNEL_CLOCK is not set CONFIG_MAX_VCO_HZ=750000000 CONFIG_MIN_VCO_HZ=50000000 -CONFIG_MAX_SCLK_HZ=133333333 +CONFIG_MAX_SCLK_HZ=133000000 CONFIG_MIN_SCLK_HZ=27000000 # diff --git a/trunk/arch/blackfin/configs/BF537-STAMP_defconfig b/trunk/arch/blackfin/configs/BF537-STAMP_defconfig index 07eb63dc25e0..828b604438eb 100644 --- a/trunk/arch/blackfin/configs/BF537-STAMP_defconfig +++ b/trunk/arch/blackfin/configs/BF537-STAMP_defconfig @@ -206,7 +206,7 @@ CONFIG_CLKIN_HZ=25000000 # CONFIG_BFIN_KERNEL_CLOCK is not set CONFIG_MAX_VCO_HZ=600000000 CONFIG_MIN_VCO_HZ=50000000 -CONFIG_MAX_SCLK_HZ=133333333 +CONFIG_MAX_SCLK_HZ=133000000 CONFIG_MIN_SCLK_HZ=27000000 # diff --git a/trunk/arch/blackfin/configs/BF548-EZKIT_defconfig b/trunk/arch/blackfin/configs/BF548-EZKIT_defconfig index 0dd3d2253dc2..d8569888a1c8 100644 --- a/trunk/arch/blackfin/configs/BF548-EZKIT_defconfig +++ b/trunk/arch/blackfin/configs/BF548-EZKIT_defconfig @@ -1,7 +1,6 @@ # # Automatically generated make config: don't edit -# Linux kernel version: 2.6.22.10 -# Sat Oct 27 02:34:07 2007 +# Linux kernel version: 2.6.22.6 # # CONFIG_MMU is not set # CONFIG_FPU is not set @@ -65,6 +64,7 @@ CONFIG_FUTEX=y CONFIG_ANON_INODES=y CONFIG_EPOLL=y CONFIG_SIGNALFD=y +CONFIG_TIMERFD=y CONFIG_EVENTFD=y CONFIG_VM_EVENT_COUNTERS=y CONFIG_BIG_ORDER_ALLOC_NOFAIL_MAGIC=3 @@ -117,9 +117,6 @@ CONFIG_PREEMPT_VOLUNTARY=y # # Processor and Board Settings # -# CONFIG_BF522 is not set -# CONFIG_BF525 is not set -# CONFIG_BF527 is not set # CONFIG_BF531 is not set # CONFIG_BF532 is not set # CONFIG_BF533 is not set @@ -132,7 +129,6 @@ CONFIG_PREEMPT_VOLUNTARY=y CONFIG_BF549=y # CONFIG_BF561 is not set CONFIG_BF_REV_0_0=y -# CONFIG_BF_REV_0_1 is not set # CONFIG_BF_REV_0_2 is not set # CONFIG_BF_REV_0_3 is not set # CONFIG_BF_REV_0_4 is not set @@ -141,7 +137,6 @@ CONFIG_BF_REV_0_0=y # CONFIG_BF_REV_NONE is not set CONFIG_BF54x=y CONFIG_BFIN_SINGLE_CORE=y -# CONFIG_BFIN527_EZKIT is not set # CONFIG_BFIN533_EZKIT is not set # CONFIG_BFIN533_STAMP is not set # CONFIG_BFIN537_STAMP is not set @@ -152,23 +147,8 @@ CONFIG_BFIN548_EZKIT=y # CONFIG_BFIN561_EZKIT is not set # CONFIG_BFIN561_TEPLA is not set # CONFIG_PNAV10 is not set -# CONFIG_H8606_HVSISTEMAS is not set # CONFIG_GENERIC_BOARD is not set CONFIG_IRQ_PLL_WAKEUP=7 -CONFIG_IRQ_RTC=8 -CONFIG_IRQ_SPORT0_RX=9 -CONFIG_IRQ_SPORT0_TX=9 -CONFIG_IRQ_SPORT1_RX=9 -CONFIG_IRQ_SPORT1_TX=9 -CONFIG_IRQ_UART0_RX=10 -CONFIG_IRQ_UART0_TX=10 -CONFIG_IRQ_UART1_RX=10 -CONFIG_IRQ_UART1_TX=10 -CONFIG_IRQ_CNT=8 -CONFIG_IRQ_USB_INT0=11 -CONFIG_IRQ_USB_INT1=11 -CONFIG_IRQ_USB_INT2=11 -CONFIG_IRQ_USB_DMA=11 CONFIG_IRQ_TIMER0=11 CONFIG_IRQ_TIMER1=11 CONFIG_IRQ_TIMER2=11 @@ -180,6 +160,15 @@ CONFIG_IRQ_TIMER7=11 CONFIG_IRQ_TIMER8=11 CONFIG_IRQ_TIMER9=11 CONFIG_IRQ_TIMER10=11 +CONFIG_IRQ_RTC=8 +CONFIG_IRQ_SPORT0_RX=9 +CONFIG_IRQ_SPORT0_TX=9 +CONFIG_IRQ_SPORT1_RX=9 +CONFIG_IRQ_SPORT1_TX=9 +CONFIG_IRQ_UART0_RX=10 +CONFIG_IRQ_UART0_TX=10 +CONFIG_IRQ_UART1_RX=10 +CONFIG_IRQ_UART1_TX=10 # # BF548 Specific Configuration @@ -247,11 +236,16 @@ CONFIG_IRQ_PIXC_IN0=8 CONFIG_IRQ_PIXC_IN1=8 CONFIG_IRQ_PIXC_OUT=8 CONFIG_IRQ_SDH=8 +CONFIG_IRQ_CNT=8 CONFIG_IRQ_KEY=8 CONFIG_IRQ_CAN1_RX=11 CONFIG_IRQ_CAN1_TX=11 CONFIG_IRQ_SDH_MASK0=11 CONFIG_IRQ_SDH_MASK1=11 +CONFIG_IRQ_USB_INT0=11 +CONFIG_IRQ_USB_INT1=11 +CONFIG_IRQ_USB_INT2=11 +CONFIG_IRQ_USB_DMA=11 CONFIG_IRQ_OTPSEC=11 CONFIG_IRQ_PINT2=11 CONFIG_IRQ_PINT3=11 @@ -279,9 +273,9 @@ CONFIG_PINT3_ASSIGN=0x02020303 # CONFIG_CLKIN_HZ=25000000 # CONFIG_BFIN_KERNEL_CLOCK is not set -CONFIG_MAX_VCO_HZ=533333333 +CONFIG_MAX_VCO_HZ=533000000 CONFIG_MIN_VCO_HZ=50000000 -CONFIG_MAX_SCLK_HZ=133333333 +CONFIG_MAX_SCLK_HZ=133000000 CONFIG_MIN_SCLK_HZ=27000000 # @@ -338,10 +332,9 @@ CONFIG_SPLIT_PTLOCK_CPUS=4 # CONFIG_RESOURCES_64BIT is not set CONFIG_ZONE_DMA_FLAG=1 CONFIG_LARGE_ALLOCS=y -# CONFIG_BFIN_GPTIMERS is not set CONFIG_BFIN_DMA_5XX=y -CONFIG_DMA_UNCACHED_2M=y -# CONFIG_DMA_UNCACHED_1M is not set +# CONFIG_DMA_UNCACHED_2M is not set +CONFIG_DMA_UNCACHED_1M=y # CONFIG_DMA_UNCACHED_NONE is not set # @@ -360,7 +353,7 @@ CONFIG_L1_MAX_PIECE=16 # # -# EBIU_AMGCTL Global Control +# EBIU_AMBCTL Global Control # CONFIG_C_AMCKEN=y # CONFIG_C_AMBEN is not set @@ -729,7 +722,7 @@ CONFIG_NETDEV_10000=y # # Input device support # -CONFIG_INPUT=m +CONFIG_INPUT=y # CONFIG_INPUT_FF_MEMLESS is not set # CONFIG_INPUT_POLLDEV is not set @@ -738,39 +731,18 @@ CONFIG_INPUT=m # # CONFIG_INPUT_MOUSEDEV is not set # CONFIG_INPUT_JOYDEV is not set -CONFIG_INPUT_TSDEV=m -CONFIG_INPUT_TSDEV_SCREEN_X=240 -CONFIG_INPUT_TSDEV_SCREEN_Y=320 -CONFIG_INPUT_EVDEV=m -CONFIG_INPUT_EVBUG=m +# CONFIG_INPUT_TSDEV is not set +# CONFIG_INPUT_EVDEV is not set +# CONFIG_INPUT_EVBUG is not set # # Input Device Drivers # -CONFIG_INPUT_KEYBOARD=y -# CONFIG_KEYBOARD_ATKBD is not set -# CONFIG_KEYBOARD_SUNKBD is not set -# CONFIG_KEYBOARD_LKKBD is not set -# CONFIG_KEYBOARD_XTKBD is not set -# CONFIG_KEYBOARD_NEWTON is not set -# CONFIG_KEYBOARD_STOWAWAY is not set -# CONFIG_KEYBOARD_GPIO is not set -CONFIG_KEYBOARD_BFIN=m +# CONFIG_INPUT_KEYBOARD is not set # CONFIG_INPUT_MOUSE is not set # CONFIG_INPUT_JOYSTICK is not set # CONFIG_INPUT_TABLET is not set -CONFIG_INPUT_TOUCHSCREEN=y -# CONFIG_TOUCHSCREEN_ADS7846 is not set -CONFIG_TOUCHSCREEN_AD7877=m -# CONFIG_TOUCHSCREEN_GUNZE is not set -# CONFIG_TOUCHSCREEN_ELO is not set -# CONFIG_TOUCHSCREEN_MTOUCH is not set -# CONFIG_TOUCHSCREEN_MK712 is not set -# CONFIG_TOUCHSCREEN_PENMOUNT is not set -# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set -# CONFIG_TOUCHSCREEN_TOUCHWIN is not set -# CONFIG_TOUCHSCREEN_UCB1400 is not set -# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set +# CONFIG_INPUT_TOUCHSCREEN is not set CONFIG_INPUT_MISC=y # CONFIG_INPUT_ATI_REMOTE is not set # CONFIG_INPUT_ATI_REMOTE2 is not set @@ -792,9 +764,9 @@ CONFIG_INPUT_MISC=y # # CONFIG_AD9960 is not set # CONFIG_SPI_ADC_BF533 is not set -# CONFIG_BF5xx_PFLAGS is not set +# CONFIG_BFIN_PFLAGS is not set # CONFIG_BF5xx_PPIFCD is not set -# CONFIG_BFIN_SIMPLE_TIMER is not set +# CONFIG_BF5xx_TIMERS is not set # CONFIG_BF5xx_PPI is not set # CONFIG_BFIN_SPORT is not set # CONFIG_BFIN_TIMER_LATENCY is not set @@ -986,92 +958,17 @@ CONFIG_DAB=y # # CONFIG_DISPLAY_SUPPORT is not set # CONFIG_VGASTATE is not set -CONFIG_FB=m -CONFIG_FIRMWARE_EDID=y -# CONFIG_FB_DDC is not set -CONFIG_FB_CFB_FILLRECT=m -CONFIG_FB_CFB_COPYAREA=m -CONFIG_FB_CFB_IMAGEBLIT=m -# CONFIG_FB_SYS_FILLRECT is not set -# CONFIG_FB_SYS_COPYAREA is not set -# CONFIG_FB_SYS_IMAGEBLIT is not set -# CONFIG_FB_SYS_FOPS is not set -CONFIG_FB_DEFERRED_IO=y -# CONFIG_FB_SVGALIB is not set -# CONFIG_FB_MACMODES is not set -# CONFIG_FB_BACKLIGHT is not set -# CONFIG_FB_MODE_HELPERS is not set -# CONFIG_FB_TILEBLITTING is not set - -# -# Frame buffer hardware drivers -# -# CONFIG_FB_BFIN_7171 is not set -# CONFIG_FB_BFIN_7393 is not set -CONFIG_FB_BF54X_LQ043=m -# CONFIG_FB_BFIN_T350MCQB is not set -# CONFIG_FB_S1D13XXX is not set -# CONFIG_FB_VIRTUAL is not set -# CONFIG_LOGO is not set +# CONFIG_FB is not set # # Sound # -CONFIG_SOUND=y - -# -# Advanced Linux Sound Architecture -# -CONFIG_SND=y -CONFIG_SND_TIMER=y -CONFIG_SND_PCM=y -# CONFIG_SND_SEQUENCER is not set -CONFIG_SND_OSSEMUL=y -CONFIG_SND_MIXER_OSS=y -CONFIG_SND_PCM_OSS=y -CONFIG_SND_PCM_OSS_PLUGINS=y -# CONFIG_SND_DYNAMIC_MINORS is not set -CONFIG_SND_SUPPORT_OLD_API=y -CONFIG_SND_VERBOSE_PROCFS=y -# CONFIG_SND_VERBOSE_PRINTK is not set -# CONFIG_SND_DEBUG is not set - -# -# Generic devices -# -# CONFIG_SND_DUMMY is not set -# CONFIG_SND_MTPAV is not set -# CONFIG_SND_SERIAL_U16550 is not set -# CONFIG_SND_MPU401 is not set - -# -# ALSA Blackfin devices -# -# CONFIG_SND_BLACKFIN_AD1836 is not set -# CONFIG_SND_BFIN_AD73311 is not set - -# -# System on Chip audio support -# -CONFIG_SND_SOC_AC97_BUS=y -CONFIG_SND_SOC=y -CONFIG_SND_BF5XX_SOC=y -CONFIG_SND_BF5XX_SOC_AC97=y -CONFIG_SND_BF5XX_SOC_BF548_EZKIT=y -CONFIG_SND_BF5XX_SPORT_NUM=0 -# CONFIG_SND_BF5XX_HAVE_COLD_RESET is not set -CONFIG_SND_SOC_AD1980=y - -# -# Open Sound System -# -# CONFIG_SOUND_PRIME is not set -CONFIG_AC97_BUS=y +# CONFIG_SOUND is not set # # HID Devices # -CONFIG_HID=m +CONFIG_HID=y # CONFIG_HID_DEBUG is not set # @@ -1204,13 +1101,8 @@ CONFIG_EXT2_FS=y CONFIG_EXT2_FS_XATTR=y # CONFIG_EXT2_FS_POSIX_ACL is not set # CONFIG_EXT2_FS_SECURITY is not set -CONFIG_EXT3_FS=y -CONFIG_EXT3_FS_XATTR=y -# CONFIG_EXT3_FS_POSIX_ACL is not set -# CONFIG_EXT3_FS_SECURITY is not set +# CONFIG_EXT3_FS is not set # CONFIG_EXT4DEV_FS is not set -CONFIG_JBD=y -# CONFIG_JBD_DEBUG is not set CONFIG_FS_MBCACHE=y # CONFIG_REISERFS_FS is not set # CONFIG_JFS_FS is not set @@ -1231,22 +1123,15 @@ CONFIG_DNOTIFY=y # # CD-ROM/DVD Filesystems # -CONFIG_ISO9660_FS=m -CONFIG_JOLIET=y -CONFIG_ZISOFS=y +# CONFIG_ISO9660_FS is not set # CONFIG_UDF_FS is not set # # DOS/FAT/NT Filesystems # -CONFIG_FAT_FS=m -CONFIG_MSDOS_FS=m -CONFIG_VFAT_FS=m -CONFIG_FAT_DEFAULT_CODEPAGE=437 -CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" -CONFIG_NTFS_FS=m -# CONFIG_NTFS_DEBUG is not set -CONFIG_NTFS_RW=y +# CONFIG_MSDOS_FS is not set +# CONFIG_VFAT_FS is not set +# CONFIG_NTFS_FS is not set # # Pseudo filesystems @@ -1298,33 +1183,10 @@ CONFIG_JFFS2_RTIME=y # # Network File Systems # -CONFIG_NFS_FS=m -CONFIG_NFS_V3=y -# CONFIG_NFS_V3_ACL is not set -# CONFIG_NFS_V4 is not set -# CONFIG_NFS_DIRECTIO is not set -CONFIG_NFSD=m -CONFIG_NFSD_V3=y -# CONFIG_NFSD_V3_ACL is not set -# CONFIG_NFSD_V4 is not set -CONFIG_NFSD_TCP=y -CONFIG_LOCKD=m -CONFIG_LOCKD_V4=y -CONFIG_EXPORTFS=m -CONFIG_NFS_COMMON=y -CONFIG_SUNRPC=m -# CONFIG_SUNRPC_BIND34 is not set -# CONFIG_RPCSEC_GSS_KRB5 is not set -# CONFIG_RPCSEC_GSS_SPKM3 is not set -CONFIG_SMB_FS=m -CONFIG_SMB_NLS_DEFAULT=y -CONFIG_SMB_NLS_REMOTE="cp437" -CONFIG_CIFS=y -# CONFIG_CIFS_STATS is not set -# CONFIG_CIFS_WEAK_PW_HASH is not set -# CONFIG_CIFS_XATTR is not set -# CONFIG_CIFS_DEBUG2 is not set -# CONFIG_CIFS_EXPERIMENTAL is not set +# CONFIG_NFS_FS is not set +# CONFIG_NFSD is not set +# CONFIG_SMB_FS is not set +# CONFIG_CIFS is not set # CONFIG_NCP_FS is not set # CONFIG_CODA_FS is not set # CONFIG_AFS_FS is not set @@ -1333,68 +1195,13 @@ CONFIG_CIFS=y # # Partition Types # -CONFIG_PARTITION_ADVANCED=y -# CONFIG_ACORN_PARTITION is not set -# CONFIG_OSF_PARTITION is not set -# CONFIG_AMIGA_PARTITION is not set -# CONFIG_ATARI_PARTITION is not set -# CONFIG_MAC_PARTITION is not set +# CONFIG_PARTITION_ADVANCED is not set CONFIG_MSDOS_PARTITION=y -# CONFIG_BSD_DISKLABEL is not set -# CONFIG_MINIX_SUBPARTITION is not set -# CONFIG_SOLARIS_X86_PARTITION is not set -# CONFIG_UNIXWARE_DISKLABEL is not set -# CONFIG_LDM_PARTITION is not set -# CONFIG_SGI_PARTITION is not set -# CONFIG_ULTRIX_PARTITION is not set -# CONFIG_SUN_PARTITION is not set -# CONFIG_KARMA_PARTITION is not set -# CONFIG_EFI_PARTITION is not set -# CONFIG_SYSV68_PARTITION is not set # # Native Language Support # -CONFIG_NLS=y -CONFIG_NLS_DEFAULT="iso8859-1" -CONFIG_NLS_CODEPAGE_437=m -CONFIG_NLS_CODEPAGE_737=m -CONFIG_NLS_CODEPAGE_775=m -CONFIG_NLS_CODEPAGE_850=m -CONFIG_NLS_CODEPAGE_852=m -CONFIG_NLS_CODEPAGE_855=m -CONFIG_NLS_CODEPAGE_857=m -CONFIG_NLS_CODEPAGE_860=m -CONFIG_NLS_CODEPAGE_861=m -CONFIG_NLS_CODEPAGE_862=m -CONFIG_NLS_CODEPAGE_863=m -CONFIG_NLS_CODEPAGE_864=m -CONFIG_NLS_CODEPAGE_865=m -CONFIG_NLS_CODEPAGE_866=m -CONFIG_NLS_CODEPAGE_869=m -CONFIG_NLS_CODEPAGE_936=m -CONFIG_NLS_CODEPAGE_950=m -CONFIG_NLS_CODEPAGE_932=m -CONFIG_NLS_CODEPAGE_949=m -CONFIG_NLS_CODEPAGE_874=m -CONFIG_NLS_ISO8859_8=m -CONFIG_NLS_CODEPAGE_1250=m -CONFIG_NLS_CODEPAGE_1251=m -CONFIG_NLS_ASCII=m -CONFIG_NLS_ISO8859_1=m -CONFIG_NLS_ISO8859_2=m -CONFIG_NLS_ISO8859_3=m -CONFIG_NLS_ISO8859_4=m -CONFIG_NLS_ISO8859_5=m -CONFIG_NLS_ISO8859_6=m -CONFIG_NLS_ISO8859_7=m -CONFIG_NLS_ISO8859_9=m -CONFIG_NLS_ISO8859_13=m -CONFIG_NLS_ISO8859_14=m -CONFIG_NLS_ISO8859_15=m -CONFIG_NLS_KOI8_R=m -CONFIG_NLS_KOI8_U=m -CONFIG_NLS_UTF8=m +# CONFIG_NLS is not set # # Distributed Lock Manager diff --git a/trunk/arch/blackfin/configs/BF561-EZKIT_defconfig b/trunk/arch/blackfin/configs/BF561-EZKIT_defconfig index 277d72dac0f9..85e647f87759 100644 --- a/trunk/arch/blackfin/configs/BF561-EZKIT_defconfig +++ b/trunk/arch/blackfin/configs/BF561-EZKIT_defconfig @@ -243,7 +243,7 @@ CONFIG_CLKIN_HZ=30000000 # CONFIG_BFIN_KERNEL_CLOCK is not set CONFIG_MAX_VCO_HZ=600000000 CONFIG_MIN_VCO_HZ=50000000 -CONFIG_MAX_SCLK_HZ=133333333 +CONFIG_MAX_SCLK_HZ=133000000 CONFIG_MIN_SCLK_HZ=27000000 # diff --git a/trunk/arch/blackfin/configs/PNAV-10_defconfig b/trunk/arch/blackfin/configs/PNAV-10_defconfig index 3d403e0b82c2..15e36aaf2186 100644 --- a/trunk/arch/blackfin/configs/PNAV-10_defconfig +++ b/trunk/arch/blackfin/configs/PNAV-10_defconfig @@ -204,7 +204,7 @@ CONFIG_CLKIN_HZ=24576000 # CONFIG_BFIN_KERNEL_CLOCK is not set CONFIG_MAX_VCO_HZ=600000000 CONFIG_MIN_VCO_HZ=50000000 -CONFIG_MAX_SCLK_HZ=133333333 +CONFIG_MAX_SCLK_HZ=133000000 CONFIG_MIN_SCLK_HZ=27000000 # diff --git a/trunk/arch/blackfin/kernel/dma-mapping.c b/trunk/arch/blackfin/kernel/dma-mapping.c index d6b61d56b656..a16cb03c5291 100644 --- a/trunk/arch/blackfin/kernel/dma-mapping.c +++ b/trunk/arch/blackfin/kernel/dma-mapping.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include diff --git a/trunk/arch/blackfin/kernel/entry.S b/trunk/arch/blackfin/kernel/entry.S index 65f4e67a65c4..65c5ba4260b0 100644 --- a/trunk/arch/blackfin/kernel/entry.S +++ b/trunk/arch/blackfin/kernel/entry.S @@ -54,11 +54,9 @@ ENTRY(_ret_from_fork) [sp + PT_IPEND] = r0; /* do a 'fake' RTI by jumping to [RETI] * to avoid clearing supervisor mode in child - */ - r0 = [sp + PT_PC]; - [sp + PT_P0] = r0; - + */ RESTORE_ALL_SYS + p0 = reti; jump (p0); ENDPROC(_ret_from_fork) diff --git a/trunk/arch/blackfin/kernel/fixed_code.S b/trunk/arch/blackfin/kernel/fixed_code.S index 90262691b11a..d8b1ebc70996 100644 --- a/trunk/arch/blackfin/kernel/fixed_code.S +++ b/trunk/arch/blackfin/kernel/fixed_code.S @@ -129,18 +129,4 @@ ENTRY(_atomic_xor32) rts; ENDPROC (_atomic_ior32) -.align 16 - /* - * safe_user_instruction - * Four NOPS are enough to allow the pipeline to speculativily load - * execute anything it wants. After that, things have gone bad, and - * we are stuck - so panic. Since we might be in user space, we can't - * call panic, so just cause a unhandled exception, this should cause - * a dump of the trace buffer so we can tell were we are, and a reboot - */ -ENTRY(_safe_user_instruction) - NOP; NOP; NOP; NOP; - EXCPT 0x4; -ENDPROC(_safe_user_instruction) - ENTRY(_fixed_code_end) diff --git a/trunk/arch/blackfin/kernel/gptimers.c b/trunk/arch/blackfin/kernel/gptimers.c index 5cf4bdb1df3b..cb7ba9bfc79c 100644 --- a/trunk/arch/blackfin/kernel/gptimers.c +++ b/trunk/arch/blackfin/kernel/gptimers.c @@ -20,7 +20,8 @@ #else # define tassert(expr) \ if (!(expr)) \ - printk(KERN_DEBUG "%s:%s:%i: Assertion failed: " #expr "\n", __FILE__, __func__, __LINE__); + printk(KERN_DEBUG "%s:%s:%i: Assertion failed: " #expr "\n", \ + __FILE__, __func__, __LINE__); #endif #define BFIN_TIMER_NUM_GROUP (BFIN_TIMER_OCTET(MAX_BLACKFIN_GPTIMERS - 1) + 1) @@ -69,7 +70,7 @@ static volatile GPTIMER_group_regs *const group_regs[BFIN_TIMER_NUM_GROUP] = #endif }; -static uint32_t const trun_mask[MAX_BLACKFIN_GPTIMERS] = +static uint32_t const dis_mask[MAX_BLACKFIN_GPTIMERS] = { TIMER_STATUS_TRUN0, TIMER_STATUS_TRUN1, @@ -89,27 +90,7 @@ static uint32_t const trun_mask[MAX_BLACKFIN_GPTIMERS] = #endif }; -static uint32_t const tovf_mask[MAX_BLACKFIN_GPTIMERS] = -{ - TIMER_STATUS_TOVF0, - TIMER_STATUS_TOVF1, - TIMER_STATUS_TOVF2, -#if (MAX_BLACKFIN_GPTIMERS > 3) - TIMER_STATUS_TOVF3, - TIMER_STATUS_TOVF4, - TIMER_STATUS_TOVF5, - TIMER_STATUS_TOVF6, - TIMER_STATUS_TOVF7, -#endif -#if (MAX_BLACKFIN_GPTIMERS > 8) - TIMER_STATUS_TOVF8, - TIMER_STATUS_TOVF9, - TIMER_STATUS_TOVF10, - TIMER_STATUS_TOVF11, -#endif -}; - -static uint32_t const timil_mask[MAX_BLACKFIN_GPTIMERS] = +static uint32_t const irq_mask[MAX_BLACKFIN_GPTIMERS] = { TIMER_STATUS_TIMIL0, TIMER_STATUS_TIMIL1, @@ -184,31 +165,17 @@ EXPORT_SYMBOL(set_gptimer_status); uint16_t get_gptimer_intr(int timer_id) { tassert(timer_id < MAX_BLACKFIN_GPTIMERS); - return (group_regs[BFIN_TIMER_OCTET(timer_id)]->status & timil_mask[timer_id]) ? 1 : 0; + return (group_regs[BFIN_TIMER_OCTET(timer_id)]->status & irq_mask[timer_id]) ? 1 : 0; } EXPORT_SYMBOL(get_gptimer_intr); void clear_gptimer_intr(int timer_id) { tassert(timer_id < MAX_BLACKFIN_GPTIMERS); - group_regs[BFIN_TIMER_OCTET(timer_id)]->status = timil_mask[timer_id]; + group_regs[BFIN_TIMER_OCTET(timer_id)]->status = irq_mask[timer_id]; } EXPORT_SYMBOL(clear_gptimer_intr); -uint16_t get_gptimer_over(int timer_id) -{ - tassert(timer_id < MAX_BLACKFIN_GPTIMERS); - return (group_regs[BFIN_TIMER_OCTET(timer_id)]->status & tovf_mask[timer_id]) ? 1 : 0; -} -EXPORT_SYMBOL(get_gptimer_over); - -void clear_gptimer_over(int timer_id) -{ - tassert(timer_id < MAX_BLACKFIN_GPTIMERS); - group_regs[BFIN_TIMER_OCTET(timer_id)]->status = tovf_mask[timer_id]; -} -EXPORT_SYMBOL(clear_gptimer_over); - void set_gptimer_config(int timer_id, uint16_t config) { tassert(timer_id < MAX_BLACKFIN_GPTIMERS); @@ -247,7 +214,7 @@ void disable_gptimers(uint16_t mask) } for (i = 0; i < MAX_BLACKFIN_GPTIMERS; ++i) if (mask & (1 << i)) - group_regs[BFIN_TIMER_OCTET(i)]->status |= trun_mask[i]; + group_regs[BFIN_TIMER_OCTET(i)]->status |= dis_mask[i]; SSYNC(); } EXPORT_SYMBOL(disable_gptimers); diff --git a/trunk/arch/blackfin/kernel/setup.c b/trunk/arch/blackfin/kernel/setup.c index 934234f43839..f1b059e5a06c 100644 --- a/trunk/arch/blackfin/kernel/setup.c +++ b/trunk/arch/blackfin/kernel/setup.c @@ -316,15 +316,6 @@ void __init setup_arch(char **cmdline_p) init_leds(); - _bfin_swrst = bfin_read_SWRST(); - - if (_bfin_swrst & RESET_DOUBLE) - printk(KERN_INFO "Recovering from Double Fault event\n"); - else if (_bfin_swrst & RESET_WDOG) - printk(KERN_INFO "Recovering from Watchdog event\n"); - else if (_bfin_swrst & RESET_SOFTWARE) - printk(KERN_NOTICE "Reset caused by Software reset\n"); - printk(KERN_INFO "Blackfin support (C) 2004-2007 Analog Devices, Inc.\n"); if (bfin_compiled_revid() == 0xffff) printk(KERN_INFO "Compiled for ADSP-%s Rev any\n", CPU); @@ -411,6 +402,8 @@ void __init setup_arch(char **cmdline_p) if (l1_length > L1_DATA_A_LENGTH) panic("L1 data memory overflow\n"); + _bfin_swrst = bfin_read_SWRST(); + /* Copy atomic sequences to their fixed location, and sanity check that these locations are the ones that we advertise to userspace. */ memcpy((void *)FIXED_CODE_START, &fixed_code_start, @@ -431,8 +424,6 @@ void __init setup_arch(char **cmdline_p) != ATOMIC_AND32 - FIXED_CODE_START); BUG_ON((char *)&atomic_xor32 - (char *)&fixed_code_start != ATOMIC_XOR32 - FIXED_CODE_START); - BUG_ON((char *)&safe_user_instruction - (char *)&fixed_code_start - != SAFE_USER_INSTRUCTION - FIXED_CODE_START); init_exception_vectors(); bf53x_cache_init(); diff --git a/trunk/arch/blackfin/kernel/traps.c b/trunk/arch/blackfin/kernel/traps.c index cfa05436c972..afd044e78af6 100644 --- a/trunk/arch/blackfin/kernel/traps.c +++ b/trunk/arch/blackfin/kernel/traps.c @@ -37,24 +37,10 @@ #include #include #include -#include #ifdef CONFIG_KGDB # include # include - -# define CHK_DEBUGGER_TRAP() \ - do { \ - CHK_DEBUGGER(trapnr, sig, info.si_code, fp, ); \ - } while (0) -# define CHK_DEBUGGER_TRAP_MAYBE() \ - do { \ - if (kgdb_connected) \ - CHK_DEBUGGER_TRAP(); \ - } while (0) -#else -# define CHK_DEBUGGER_TRAP() do { } while (0) -# define CHK_DEBUGGER_TRAP_MAYBE() do { } while (0) #endif /* Initiate the event table handler */ @@ -67,13 +53,13 @@ void __init trap_init(void) int kstack_depth_to_print = 48; -static void decode_address(char *buf, unsigned long address) +#ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON +static int printk_address(unsigned long address) { struct vm_list_struct *vml; struct task_struct *p; struct mm_struct *mm; - unsigned long flags, offset; - unsigned int in_exception = bfin_read_IPEND() & 0x10; + unsigned long offset; #ifdef CONFIG_KALLSYMS unsigned long symsize; @@ -89,33 +75,20 @@ static void decode_address(char *buf, unsigned long address) /* yeah! kernel space! */ if (!modname) modname = delim = ""; - sprintf(buf, "<0x%p> { %s%s%s%s + 0x%lx }", + return printk("<0x%p> { %s%s%s%s + 0x%lx }", (void *)address, delim, modname, delim, symname, (unsigned long)offset); - return; } #endif - /* Problem in fixed code section? */ - if (address >= FIXED_CODE_START && address < FIXED_CODE_END) { - sprintf(buf, "<0x%p> /* Maybe fixed code section */", (void *)address); - return; - } - - /* Problem somewhere before the kernel start address */ - if (address < CONFIG_BOOT_LOAD) { - sprintf(buf, "<0x%p> /* Maybe null pointer? */", (void *)address); - return; - } - /* looks like we're off in user-land, so let's walk all the * mappings of all our processes and see if we can't be a whee * bit more specific */ - write_lock_irqsave(&tasklist_lock, flags); + write_lock_irq(&tasklist_lock); for_each_process(p) { - mm = (in_exception ? p->mm : get_task_mm(p)); + mm = get_task_mm(p); if (!mm) continue; @@ -144,30 +117,25 @@ static void decode_address(char *buf, unsigned long address) else offset = (address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT); - sprintf(buf, "<0x%p> [ %s + 0x%lx ]", - (void *)address, name, offset); - if (!in_exception) - mmput(mm); - goto done; + write_unlock_irq(&tasklist_lock); + mmput(mm); + return printk("<0x%p> [ %s + 0x%lx ]", + (void *)address, name, offset); } vml = vml->next; } - if (!in_exception) - mmput(mm); + mmput(mm); } + write_unlock_irq(&tasklist_lock); /* we were unable to find this address anywhere */ - sprintf(buf, "[<0x%p>]", (void *)address); - -done: - write_unlock_irqrestore(&tasklist_lock, flags); + return printk("[<0x%p>]", (void *)address); } +#endif asmlinkage void double_fault_c(struct pt_regs *fp) { - console_verbose(); - oops_in_progress = 1; printk(KERN_EMERG "\n" KERN_EMERG "Double Fault\n"); dump_bfin_regs(fp, (void *)fp->retx); panic("Double Fault - unrecoverable event\n"); @@ -183,29 +151,22 @@ asmlinkage void trap_c(struct pt_regs *fp) siginfo_t info; unsigned long trapnr = fp->seqstat & SEQSTAT_EXCAUSE; - trace_buffer_save(j); - - /* Important - be very careful dereferncing pointers - will lead to - * double faults if the stack has become corrupt - */ - - /* If the fault was caused by a kernel thread, or interrupt handler - * we will kernel panic, so the system reboots. - * If KGDB is enabled, don't set this for kernel breakpoints - */ - if ((bfin_read_IPEND() & 0xFFC0) #ifdef CONFIG_KGDB - && trapnr != VEC_EXCPT02 +# define CHK_DEBUGGER_TRAP() \ + do { \ + CHK_DEBUGGER(trapnr, sig, info.si_code, fp, ); \ + } while (0) +# define CHK_DEBUGGER_TRAP_MAYBE() \ + do { \ + if (kgdb_connected) \ + CHK_DEBUGGER_TRAP(); \ + } while (0) +#else +# define CHK_DEBUGGER_TRAP() do { } while (0) +# define CHK_DEBUGGER_TRAP_MAYBE() do { } while (0) #endif - ){ - console_verbose(); - oops_in_progress = 1; - } else if (current) { - if (current->mm == NULL) { - console_verbose(); - oops_in_progress = 1; - } - } + + trace_buffer_save(j); /* trap_c() will be called for exceptions. During exceptions * processing, the pc value should be set with retx value. @@ -250,7 +211,7 @@ asmlinkage void trap_c(struct pt_regs *fp) case VEC_EXCPT03: info.si_code = SEGV_STACKFLOW; sig = SIGSEGV; - printk(KERN_NOTICE EXC_0x03); + printk(KERN_EMERG EXC_0x03); CHK_DEBUGGER_TRAP(); break; /* 0x04 - User Defined, Caught by default */ @@ -279,7 +240,7 @@ asmlinkage void trap_c(struct pt_regs *fp) case VEC_OVFLOW: info.si_code = TRAP_TRACEFLOW; sig = SIGTRAP; - printk(KERN_NOTICE EXC_0x11); + printk(KERN_EMERG EXC_0x11); CHK_DEBUGGER_TRAP(); break; /* 0x12 - Reserved, Caught by default */ @@ -301,14 +262,14 @@ asmlinkage void trap_c(struct pt_regs *fp) case VEC_UNDEF_I: info.si_code = ILL_ILLOPC; sig = SIGILL; - printk(KERN_NOTICE EXC_0x21); + printk(KERN_EMERG EXC_0x21); CHK_DEBUGGER_TRAP(); break; /* 0x22 - Illegal Instruction Combination, handled here */ case VEC_ILGAL_I: info.si_code = ILL_ILLPARAOP; sig = SIGILL; - printk(KERN_NOTICE EXC_0x22); + printk(KERN_EMERG EXC_0x22); CHK_DEBUGGER_TRAP(); break; /* 0x23 - Data CPLB Protection Violation, @@ -316,21 +277,21 @@ asmlinkage void trap_c(struct pt_regs *fp) case VEC_CPLB_VL: info.si_code = ILL_CPLB_VI; sig = SIGILL; - printk(KERN_NOTICE EXC_0x23); + printk(KERN_EMERG EXC_0x23); CHK_DEBUGGER_TRAP(); break; /* 0x24 - Data access misaligned, handled here */ case VEC_MISALI_D: info.si_code = BUS_ADRALN; sig = SIGBUS; - printk(KERN_NOTICE EXC_0x24); + printk(KERN_EMERG EXC_0x24); CHK_DEBUGGER_TRAP(); break; /* 0x25 - Unrecoverable Event, handled here */ case VEC_UNCOV: info.si_code = ILL_ILLEXCPT; sig = SIGILL; - printk(KERN_NOTICE EXC_0x25); + printk(KERN_EMERG EXC_0x25); CHK_DEBUGGER_TRAP(); break; /* 0x26 - Data CPLB Miss, normal case is handled in _cplb_hdr, @@ -338,7 +299,7 @@ asmlinkage void trap_c(struct pt_regs *fp) case VEC_CPLB_M: info.si_code = BUS_ADRALN; sig = SIGBUS; - printk(KERN_NOTICE EXC_0x26); + printk(KERN_EMERG EXC_0x26); CHK_DEBUGGER_TRAP(); break; /* 0x27 - Data CPLB Multiple Hits - Linux Trap Zero, handled here */ @@ -346,10 +307,11 @@ asmlinkage void trap_c(struct pt_regs *fp) info.si_code = ILL_CPLB_MULHIT; #ifdef CONFIG_DEBUG_HUNT_FOR_ZERO sig = SIGSEGV; - printk(KERN_NOTICE "NULL pointer access (probably)\n"); + printk(KERN_EMERG "\n" + KERN_EMERG "NULL pointer access (probably)\n"); #else sig = SIGILL; - printk(KERN_NOTICE EXC_0x27); + printk(KERN_EMERG EXC_0x27); #endif CHK_DEBUGGER_TRAP(); break; @@ -369,7 +331,7 @@ asmlinkage void trap_c(struct pt_regs *fp) case VEC_ISTRU_VL: /* ADSP-BF535 only (MH) */ info.si_code = BUS_OPFETCH; sig = SIGBUS; - printk(KERN_NOTICE "BF535: VEC_ISTRU_VL\n"); + printk(KERN_EMERG "BF535: VEC_ISTRU_VL\n"); CHK_DEBUGGER_TRAP(); break; #else @@ -379,7 +341,7 @@ asmlinkage void trap_c(struct pt_regs *fp) case VEC_MISALI_I: info.si_code = BUS_ADRALN; sig = SIGBUS; - printk(KERN_NOTICE EXC_0x2A); + printk(KERN_EMERG EXC_0x2A); CHK_DEBUGGER_TRAP(); break; /* 0x2B - Instruction CPLB protection Violation, @@ -387,14 +349,14 @@ asmlinkage void trap_c(struct pt_regs *fp) case VEC_CPLB_I_VL: info.si_code = ILL_CPLB_VI; sig = SIGILL; - printk(KERN_NOTICE EXC_0x2B); + printk(KERN_EMERG EXC_0x2B); CHK_DEBUGGER_TRAP(); break; /* 0x2C - Instruction CPLB miss, handled in _cplb_hdr */ case VEC_CPLB_I_M: info.si_code = ILL_CPLB_MISS; sig = SIGBUS; - printk(KERN_NOTICE EXC_0x2C); + printk(KERN_EMERG EXC_0x2C); CHK_DEBUGGER_TRAP(); break; /* 0x2D - Instruction CPLB Multiple Hits, handled here */ @@ -402,10 +364,10 @@ asmlinkage void trap_c(struct pt_regs *fp) info.si_code = ILL_CPLB_MULHIT; #ifdef CONFIG_DEBUG_HUNT_FOR_ZERO sig = SIGSEGV; - printk(KERN_NOTICE "Jump to address 0 - 0x0fff\n"); + printk(KERN_EMERG "\n\nJump to address 0 - 0x0fff\n"); #else sig = SIGILL; - printk(KERN_NOTICE EXC_0x2D); + printk(KERN_EMERG EXC_0x2D); #endif CHK_DEBUGGER_TRAP(); break; @@ -413,7 +375,7 @@ asmlinkage void trap_c(struct pt_regs *fp) case VEC_ILL_RES: info.si_code = ILL_PRVOPC; sig = SIGILL; - printk(KERN_NOTICE EXC_0x2E); + printk(KERN_EMERG EXC_0x2E); CHK_DEBUGGER_TRAP(); break; /* 0x2F - Reserved, Caught by default */ @@ -442,40 +404,38 @@ asmlinkage void trap_c(struct pt_regs *fp) break; } - BUG_ON(sig == 0); - - if (sig != SIGTRAP) { + if (sig != 0 && sig != SIGTRAP) { unsigned long stack; dump_bfin_regs(fp, (void *)fp->retx); - - /* Print out the trace buffer if it makes sense */ -#ifndef CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE - if (trapnr == VEC_CPLB_I_M || trapnr == VEC_CPLB_M) - printk(KERN_NOTICE "No trace since you do not have " - "CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE enabled\n" - KERN_NOTICE "\n"); - else -#endif - dump_bfin_trace_buffer(); + dump_bfin_trace_buffer(); show_stack(current, &stack); - if (oops_in_progress) { -#ifndef CONFIG_ACCESS_CHECK - printk(KERN_EMERG "Hey - dork - please turn on " - "CONFIG_ACCESS_CHECK\n"); -#endif + if (current->mm == NULL) panic("Kernel exception"); - } - - /* Ensure that bad return addresses don't end up in an infinite - * loop, due to speculative loads/reads - */ - fp->pc = SAFE_USER_INSTRUCTION; } info.si_signo = sig; info.si_errno = 0; info.si_addr = (void *)fp->pc; force_sig_info(sig, &info, current); + /* if the address that we are about to return to is not valid, set it + * to a valid address, if we have a current application or panic + */ + if (!(fp->pc <= physical_mem_end +#if L1_CODE_LENGTH != 0 + || (fp->pc >= L1_CODE_START && + fp->pc <= (L1_CODE_START + L1_CODE_LENGTH)) +#endif + )) { + if (current->mm) { + fp->pc = current->mm->start_code; + } else { + printk(KERN_EMERG + "I can't return to memory that doesn't exist" + " - bad things happen\n"); + panic("Help - I've fallen and can't get up\n"); + } + } + trace_buffer_restore(j); return; } @@ -488,21 +448,21 @@ void dump_bfin_trace_buffer(void) { #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON int tflags, i = 0; - char buf[150]; #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND int j, index; #endif trace_buffer_save(tflags); - printk(KERN_NOTICE "Hardware Trace:\n"); + printk(KERN_EMERG "Hardware Trace:\n"); if (likely(bfin_read_TBUFSTAT() & TBUFCNT)) { for (; bfin_read_TBUFSTAT() & TBUFCNT; i++) { - decode_address(buf, (unsigned long)bfin_read_TBUF()); - printk(KERN_NOTICE "%4i Target : %s\n", i, buf); - decode_address(buf, (unsigned long)bfin_read_TBUF()); - printk(KERN_NOTICE " Source : %s\n", buf); + printk(KERN_EMERG "%4i Target : ", i); + printk_address((unsigned long)bfin_read_TBUF()); + printk("\n" KERN_EMERG " Source : "); + printk_address((unsigned long)bfin_read_TBUF()); + printk("\n"); } } @@ -514,16 +474,17 @@ void dump_bfin_trace_buffer(void) j = (1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 128; while (j) { - decode_address(buf, software_trace_buff[index]); - printk(KERN_NOTICE "%4i Target : %s\n", i, buf); + printk(KERN_EMERG "%4i Target : ", i); + printk_address(software_trace_buff[index]); index -= 1; if (index < 0 ) index = EXPAND_LEN; - decode_address(buf, software_trace_buff[index]); - printk(KERN_NOTICE " Source : %s\n", buf); + printk("\n" KERN_EMERG " Source : "); + printk_address(software_trace_buff[index]); index -= 1; if (index < 0) index = EXPAND_LEN; + printk("\n"); j--; i++; } @@ -538,7 +499,10 @@ static void show_trace(struct task_struct *tsk, unsigned long *sp) { unsigned long addr; - printk(KERN_NOTICE "\n" KERN_NOTICE "Call Trace:\n"); + printk("\nCall Trace:"); +#ifdef CONFIG_KALLSYMS + printk("\n"); +#endif while (!kstack_end(sp)) { addr = *sp++; @@ -554,7 +518,7 @@ static void show_trace(struct task_struct *tsk, unsigned long *sp) print_ip_sym(addr); } - printk(KERN_NOTICE "\n"); + printk("\n"); } void show_stack(struct task_struct *task, unsigned long *stack) @@ -576,15 +540,14 @@ void show_stack(struct task_struct *task, unsigned long *stack) addr = (unsigned long)stack; endstack = (unsigned long *)PAGE_ALIGN(addr); - printk(KERN_NOTICE "Stack from %08lx:", (unsigned long)stack); + printk(KERN_EMERG "Stack from %08lx:", (unsigned long)stack); for (i = 0; i < kstack_depth_to_print; i++) { if (stack + 1 > endstack) break; if (i % 8 == 0) - printk("\n" KERN_NOTICE " "); + printk("\n" KERN_EMERG " "); printk(" %08lx", *stack++); } - printk("\n"); show_trace(task, stack); } @@ -605,34 +568,33 @@ EXPORT_SYMBOL(dump_stack); void dump_bfin_regs(struct pt_regs *fp, void *retaddr) { - char buf [150]; - - if (!oops_in_progress) { - if (current->pid && current->mm) { - printk(KERN_NOTICE "\n" KERN_NOTICE "CURRENT PROCESS:\n"); - printk(KERN_NOTICE "COMM=%s PID=%d\n", - current->comm, current->pid); - - printk(KERN_NOTICE "TEXT = 0x%p-0x%p DATA = 0x%p-0x%p\n" - KERN_NOTICE "BSS = 0x%p-0x%p USER-STACK = 0x%p\n" - KERN_NOTICE "\n", - (void *)current->mm->start_code, - (void *)current->mm->end_code, - (void *)current->mm->start_data, - (void *)current->mm->end_data, - (void *)current->mm->end_data, - (void *)current->mm->brk, - (void *)current->mm->start_stack); - } else { - printk (KERN_NOTICE "\n" KERN_NOTICE - "No Valid pid - Either things are really messed up," - " or you are in the kernel\n"); - } + if (current->pid) { + printk(KERN_EMERG "\n" KERN_EMERG "CURRENT PROCESS:\n" + KERN_EMERG "\n"); + printk(KERN_EMERG "COMM=%s PID=%d\n", + current->comm, current->pid); } else { - printk(KERN_NOTICE "Kernel or interrupt exception\n"); + printk + (KERN_EMERG "\n" KERN_EMERG + "No Valid pid - Either things are really messed up," + " or you are in the kernel\n"); + } + + if (current->mm) { + printk(KERN_EMERG "TEXT = 0x%p-0x%p DATA = 0x%p-0x%p\n" + KERN_EMERG "BSS = 0x%p-0x%p USER-STACK = 0x%p\n" + KERN_EMERG "\n", + (void *)current->mm->start_code, + (void *)current->mm->end_code, + (void *)current->mm->start_data, + (void *)current->mm->end_data, + (void *)current->mm->end_data, + (void *)current->mm->brk, + (void *)current->mm->start_stack); } - if (retaddr >= (void *)FIXED_CODE_START && retaddr < (void *)physical_mem_end + printk(KERN_EMERG "return address: [0x%p]; contents of:", retaddr); + if (retaddr != 0 && retaddr <= (void *)physical_mem_end #if L1_CODE_LENGTH != 0 /* FIXME: Copy the code out of L1 Instruction SRAM through dma memcpy. */ @@ -642,20 +604,18 @@ void dump_bfin_regs(struct pt_regs *fp, void *retaddr) ) { int i = ((unsigned int)retaddr & 0xFFFFFFF0) - 32; unsigned short x = 0; - printk(KERN_NOTICE "return address: [0x%p]; contents of:", retaddr); for (; i < ((unsigned int)retaddr & 0xFFFFFFF0) + 32; i += 2) { if (!(i & 0xF)) - printk("\n" KERN_NOTICE "0x%08x: ", i); + printk("\n" KERN_EMERG "0x%08x: ", i); if (get_user(x, (unsigned short *)i)) break; #ifndef CONFIG_DEBUG_HWERR /* If one of the last few instructions was a STI * it is likely that the error occured awhile ago - * and we just noticed. This only happens in kernel - * context, which should mean an oops is happening + * and we just noticed */ - if (oops_in_progress && x >= 0x0040 && x <= 0x0047 && i <= 0) + if (x >= 0x0040 && x <= 0x0047 && i <= 0) panic("\n\nWARNING : You should reconfigure" " the kernel to turn on\n" " 'Hardware error interrupt" @@ -668,60 +628,56 @@ void dump_bfin_regs(struct pt_regs *fp, void *retaddr) else printk(" %04x ", x); } - printk("\n"); + printk("\n" KERN_EMERG "\n"); } else - printk("\n" KERN_NOTICE + printk(KERN_EMERG "Cannot look at the [PC] for it is" - " in unreadable memory - sorry\n"); - - printk(KERN_NOTICE "\n" KERN_NOTICE "SEQUENCER STATUS:\n"); - printk(KERN_NOTICE " SEQSTAT: %08lx IPEND: %04lx SYSCFG: %04lx\n", - (long)fp->seqstat, fp->ipend, fp->syscfg); + "in unreadable L1 SRAM - sorry\n"); - decode_address(buf, fp->rete); - printk(KERN_NOTICE " RETE: %s\n", buf); - decode_address(buf, fp->retn); - printk(KERN_NOTICE " RETN: %s\n", buf); - decode_address(buf, fp->retx); - printk(KERN_NOTICE " RETX: %s\n", buf); - decode_address(buf, fp->rets); - printk(KERN_NOTICE " RETS: %s\n", buf); - if ((long)fp->seqstat & SEQSTAT_EXCAUSE) { - decode_address(buf, bfin_read_DCPLB_FAULT_ADDR()); - printk(KERN_NOTICE "DCPLB_FAULT_ADDR: %s\n", buf); - decode_address(buf, bfin_read_ICPLB_FAULT_ADDR()); - printk(KERN_NOTICE "ICPLB_FAULT_ADDR: %s\n", buf); - } - - printk(KERN_NOTICE "\n" KERN_NOTICE "PROCESSOR STATE:\n"); - printk(KERN_NOTICE " R0 : %08lx R1 : %08lx R2 : %08lx R3 : %08lx\n", + printk(KERN_EMERG + "RETE: %08lx RETN: %08lx RETX: %08lx RETS: %08lx\n", + fp->rete, fp->retn, fp->retx, fp->rets); + printk(KERN_EMERG "IPEND: %04lx SYSCFG: %04lx\n", + fp->ipend, fp->syscfg); + printk(KERN_EMERG "SEQSTAT: %08lx SP: %08lx\n", + (long)fp->seqstat, (long)fp); + printk(KERN_EMERG "R0: %08lx R1: %08lx R2: %08lx R3: %08lx\n", fp->r0, fp->r1, fp->r2, fp->r3); - printk(KERN_NOTICE " R4 : %08lx R5 : %08lx R6 : %08lx R7 : %08lx\n", + printk(KERN_EMERG "R4: %08lx R5: %08lx R6: %08lx R7: %08lx\n", fp->r4, fp->r5, fp->r6, fp->r7); - printk(KERN_NOTICE " P0 : %08lx P1 : %08lx P2 : %08lx P3 : %08lx\n", + printk(KERN_EMERG "P0: %08lx P1: %08lx P2: %08lx P3: %08lx\n", fp->p0, fp->p1, fp->p2, fp->p3); - printk(KERN_NOTICE " P4 : %08lx P5 : %08lx FP : %08lx SP : %08lx\n", - fp->p4, fp->p5, fp->fp, (long)fp); - printk(KERN_NOTICE " LB0: %08lx LT0: %08lx LC0: %08lx\n", + printk(KERN_EMERG + "P4: %08lx P5: %08lx FP: %08lx\n", + fp->p4, fp->p5, fp->fp); + printk(KERN_EMERG + "A0.w: %08lx A0.x: %08lx A1.w: %08lx A1.x: %08lx\n", + fp->a0w, fp->a0x, fp->a1w, fp->a1x); + + printk(KERN_EMERG "LB0: %08lx LT0: %08lx LC0: %08lx\n", fp->lb0, fp->lt0, fp->lc0); - printk(KERN_NOTICE " LB1: %08lx LT1: %08lx LC1: %08lx\n", + printk(KERN_EMERG "LB1: %08lx LT1: %08lx LC1: %08lx\n", fp->lb1, fp->lt1, fp->lc1); - printk(KERN_NOTICE " B0 : %08lx L0 : %08lx M0 : %08lx I0 : %08lx\n", + printk(KERN_EMERG "B0: %08lx L0: %08lx M0: %08lx I0: %08lx\n", fp->b0, fp->l0, fp->m0, fp->i0); - printk(KERN_NOTICE " B1 : %08lx L1 : %08lx M1 : %08lx I1 : %08lx\n", + printk(KERN_EMERG "B1: %08lx L1: %08lx M1: %08lx I1: %08lx\n", fp->b1, fp->l1, fp->m1, fp->i1); - printk(KERN_NOTICE " B2 : %08lx L2 : %08lx M2 : %08lx I2 : %08lx\n", + printk(KERN_EMERG "B2: %08lx L2: %08lx M2: %08lx I2: %08lx\n", fp->b2, fp->l2, fp->m2, fp->i2); - printk(KERN_NOTICE " B3 : %08lx L3 : %08lx M3 : %08lx I3 : %08lx\n", + printk(KERN_EMERG "B3: %08lx L3: %08lx M3: %08lx I3: %08lx\n", fp->b3, fp->l3, fp->m3, fp->i3); - printk(KERN_NOTICE "A0.w: %08lx A0.x: %08lx A1.w: %08lx A1.x: %08lx\n", - fp->a0w, fp->a0x, fp->a1w, fp->a1x); - printk(KERN_NOTICE "USP : %08lx ASTAT: %08lx\n", + printk(KERN_EMERG "\n" KERN_EMERG "USP: %08lx ASTAT: %08lx\n", rdusp(), fp->astat); + if ((long)fp->seqstat & SEQSTAT_EXCAUSE) { + printk(KERN_EMERG "DCPLB_FAULT_ADDR=%p\n", + (void *)bfin_read_DCPLB_FAULT_ADDR()); + printk(KERN_EMERG "ICPLB_FAULT_ADDR=%p\n", + (void *)bfin_read_ICPLB_FAULT_ADDR()); + } - printk(KERN_NOTICE "\n"); + printk("\n\n"); } #ifdef CONFIG_SYS_BFIN_SPINLOCK_L1 @@ -796,8 +752,6 @@ void panic_cplb_error(int cplb_panic, struct pt_regs *fp) break; } - oops_in_progress = 1; - printk(KERN_EMERG "DCPLB_FAULT_ADDR=%p\n", (void *)bfin_read_DCPLB_FAULT_ADDR()); printk(KERN_EMERG "ICPLB_FAULT_ADDR=%p\n", (void *)bfin_read_ICPLB_FAULT_ADDR()); dump_bfin_regs(fp, (void *)fp->retx); diff --git a/trunk/arch/blackfin/kernel/vmlinux.lds.S b/trunk/arch/blackfin/kernel/vmlinux.lds.S index 9b75bc83c71f..eec43674a465 100644 --- a/trunk/arch/blackfin/kernel/vmlinux.lds.S +++ b/trunk/arch/blackfin/kernel/vmlinux.lds.S @@ -172,14 +172,9 @@ SECTIONS __ebss_b_l1 = .; } - /* Force trailing alignment of our init section so that when we - * free our init memory, we don't leave behind a partial page. - */ - . = LOADADDR(.data_b_l1) + SIZEOF(.data_b_l1); - . = ALIGN(PAGE_SIZE); - ___init_end = .; - - .bss : + ___init_end = LOADADDR(.data_b_l1) + SIZEOF(.data_b_l1); + + .bss LOADADDR(.data_b_l1) + SIZEOF(.data_b_l1) : { . = ALIGN(4); ___bss_start = .; diff --git a/trunk/arch/blackfin/mach-bf527/boards/ezkit.c b/trunk/arch/blackfin/mach-bf527/boards/ezkit.c index bf1bedcc8868..3e884f3a8182 100644 --- a/trunk/arch/blackfin/mach-bf527/boards/ezkit.c +++ b/trunk/arch/blackfin/mach-bf527/boards/ezkit.c @@ -41,11 +41,9 @@ #include #include #include -#include #include #include #include -#include #include /* @@ -104,53 +102,6 @@ void __exit bfin_isp1761_exit(void) arch_initcall(bfin_isp1761_init); #endif -#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) -static struct mtd_partition partition_info[] = { - { - .name = "Linux Kernel", - .offset = 0, - .size = 4 * SIZE_1M, - }, - { - .name = "File System", - .offset = 4 * SIZE_1M, - .size = (256 - 4) * SIZE_1M, - }, -}; - -static struct bf5xx_nand_platform bf5xx_nand_platform = { - .page_size = NFC_PG_SIZE_256, - .data_width = NFC_NWIDTH_8, - .partitions = partition_info, - .nr_partitions = ARRAY_SIZE(partition_info), - .rd_dly = 3, - .wr_dly = 3, -}; - -static struct resource bf5xx_nand_resources[] = { - { - .start = NFC_CTL, - .end = NFC_DATA_RD + 2, - .flags = IORESOURCE_MEM, - }, - { - .start = CH_NFC, - .end = CH_NFC, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device bf5xx_nand_device = { - .name = "bf5xx-nand", - .id = 0, - .num_resources = ARRAY_SIZE(bf5xx_nand_resources), - .resource = bf5xx_nand_resources, - .dev = { - .platform_data = &bf5xx_nand_platform, - }, -}; -#endif - #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE) static struct resource bfin_pcmcia_cf_resources[] = { { @@ -699,10 +650,6 @@ static struct platform_device bfin_pata_device = { #endif static struct platform_device *stamp_devices[] __initdata = { -#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) - &bf5xx_nand_device, -#endif - #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE) &bfin_pcmcia_cf_device, #endif diff --git a/trunk/arch/blackfin/mach-bf533/boards/H8606.c b/trunk/arch/blackfin/mach-bf533/boards/H8606.c deleted file mode 100644 index b941550f9568..000000000000 --- a/trunk/arch/blackfin/mach-bf533/boards/H8606.c +++ /dev/null @@ -1,345 +0,0 @@ -/* - * File: arch/blackfin/mach-bf533/H8606.c - * Based on: arch/blackfin/mach-bf533/stamp.c - * Author: Javier Herrero - * - * Created: 2007 - * Description: Board Info File for the HV Sistemas H8606 board - * - * Modified: - * Copyright 2005 National ICT Australia (NICTA) - * Copyright 2004-2006 Analog Devices Inc - * Copyright 2007 HV Sistemas S.L. - * - * Bugs: Enter bugs at http://blackfin.uclinux.org/ - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include -#include -#include -#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) -#include -#endif -#include -#include -#include -#include -#include - -/* - * Name the Board for the /proc/cpuinfo - */ -const char bfin_board_name[] = "HV Sistemas H8606"; - -#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_BFIN_MODULE) -static struct platform_device rtc_device = { - .name = "rtc-bfin", - .id = -1, -}; -#endif - -/* -* Driver needs to know address, irq and flag pin. - */ - #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) -static struct resource dm9000_resources[] = { - [0] = { - .start = 0x20300000, - .end = 0x20300000 + 8, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = IRQ_PF10, - .end = IRQ_PF10, - .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE), - }, -}; - -static struct platform_device dm9000_device = { - .id = 0, - .name = "dm9000", - .resource = dm9000_resources, - .num_resources = ARRAY_SIZE(dm9000_resources), -}; -#endif - -#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) -static struct resource smc91x_resources[] = { - { - .name = "smc91x-regs", - .start = 0x20300300, - .end = 0x20300300 + 16, - .flags = IORESOURCE_MEM, - }, { - .start = IRQ_PROG_INTB, - .end = IRQ_PROG_INTB, - .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, - }, { - /* - * denotes the flag pin and is used directly if - * CONFIG_IRQCHIP_DEMUX_GPIO is defined. - */ - .start = IRQ_PF7, - .end = IRQ_PF7, - .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, - }, -}; - -static struct platform_device smc91x_device = { - .name = "smc91x", - .id = 0, - .num_resources = ARRAY_SIZE(smc91x_resources), - .resource = smc91x_resources, -}; -#endif - -#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) -static struct resource net2272_bfin_resources[] = { - { - .start = 0x20300000, - .end = 0x20300000 + 0x100, - .flags = IORESOURCE_MEM, - }, { - .start = IRQ_PF10, - .end = IRQ_PF10, - .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, - }, -}; - -static struct platform_device net2272_bfin_device = { - .name = "net2272", - .id = -1, - .num_resources = ARRAY_SIZE(net2272_bfin_resources), - .resource = net2272_bfin_resources, -}; -#endif - -#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE) -/* all SPI peripherals info goes here */ - -#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) -static struct mtd_partition bfin_spi_flash_partitions[] = { - { - .name = "bootloader", - .size = 0x00060000, - .offset = 0, - .mask_flags = MTD_CAP_ROM - }, { - .name = "kernel", - .size = 0x100000, - .offset = 0x60000 - }, { - .name = "file system", - .size = 0x6a0000, - .offset = 0x00160000, - } -}; - -static struct flash_platform_data bfin_spi_flash_data = { - .name = "m25p80", - .parts = bfin_spi_flash_partitions, - .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions), - .type = "m25p64", -}; - -/* SPI flash chip (m25p64) */ -static struct bfin5xx_spi_chip spi_flash_chip_info = { - .enable_dma = 0, /* use dma transfer with this chip*/ - .bits_per_word = 8, -}; -#endif - -#if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE) -/* SPI ADC chip */ -static struct bfin5xx_spi_chip spi_adc_chip_info = { - .ctl_reg = 0x1000, - .enable_dma = 1, /* use dma transfer with this chip*/ - .bits_per_word = 16, -}; -#endif - -#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE) -static struct bfin5xx_spi_chip ad1836_spi_chip_info = { - .ctl_reg = 0x1000, - .enable_dma = 0, - .bits_per_word = 16, -}; -#endif - -#if defined(CONFIG_PBX) -static struct bfin5xx_spi_chip spi_si3xxx_chip_info = { - .ctl_reg = 0x1c04, - .enable_dma = 0, - .bits_per_word = 8, - .cs_change_per_word = 1, -}; -#endif - -/* Notice: for blackfin, the speed_hz is the value of register - * SPI_BAUD, not the real baudrate */ -static struct spi_board_info bfin_spi_board_info[] __initdata = { -#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) - { - /* the modalias must be the same as spi device driver name */ - .modalias = "m25p80", /* Name of spi_driver for this device */ - /* this value is the baudrate divisor */ - .max_speed_hz = 50000000, /* actual baudrate is SCLK/(2xspeed_hz) */ - .bus_num = 0, /* Framework bus number */ - .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/ - .platform_data = &bfin_spi_flash_data, - .controller_data = &spi_flash_chip_info, - .mode = SPI_MODE_3, - }, -#endif - -#if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE) - { - .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */ - .max_speed_hz = 4, /* actual baudrate is SCLK/(2xspeed_hz) */ - .bus_num = 1, /* Framework bus number */ - .chip_select = 1, /* Framework chip select. */ - .platform_data = NULL, /* No spi_driver specific config */ - .controller_data = &spi_adc_chip_info, - }, -#endif - -#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE) - { - .modalias = "ad1836-spi", - .max_speed_hz = 16, - .bus_num = 1, - .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT, - .controller_data = &ad1836_spi_chip_info, - }, -#endif - -#if defined(CONFIG_PBX) - { - .modalias = "fxs-spi", - .max_speed_hz = 4, - .bus_num = 1, - .chip_select = 3, - .controller_data = &spi_si3xxx_chip_info, - }, - - { - .modalias = "fxo-spi", - .max_speed_hz = 4, - .bus_num = 1, - .chip_select = 2, - .controller_data = &spi_si3xxx_chip_info, - }, -#endif -}; - -/* SPI (0) */ -static struct resource bfin_spi0_resource[] = { - [0] = { - .start = SPI0_REGBASE, - .end = SPI0_REGBASE + 0xFF, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = CH_SPI, - .end = CH_SPI, - .flags = IORESOURCE_IRQ, - } -}; - - -/* SPI controller data */ -static struct bfin5xx_spi_master bfin_spi0_info = { - .num_chipselect = 8, - .enable_dma = 1, /* master has the ability to do dma transfer */ -}; - -static struct platform_device bfin_spi0_device = { - .name = "bfin-spi", - .id = 0, /* Bus number */ - .num_resources = ARRAY_SIZE(bfin_spi0_resource), - .resource = bfin_spi0_resource, - .dev = { - .platform_data = &bfin_spi0_info, /* Passed to driver */ - }, -}; -#endif /* spi master and devices */ - -#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE) -static struct platform_device bfin_fb_device = { - .name = "bf537-fb", -}; -#endif - -#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) -static struct resource bfin_uart_resources[] = { - { - .start = 0xFFC00400, - .end = 0xFFC004FF, - .flags = IORESOURCE_MEM, - }, -}; - -static struct platform_device bfin_uart_device = { - .name = "bfin-uart", - .id = 1, - .num_resources = ARRAY_SIZE(bfin_uart_resources), - .resource = bfin_uart_resources, -}; -#endif - -static struct platform_device *stamp_devices[] __initdata = { -#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) - &rtc_device, -#endif - -#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) - &dm9000_device, -#endif - -#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) - &smc91x_device, -#endif - -#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) - &net2272_bfin_device, -#endif - -#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE) - &bfin_spi0_device, -#endif - -#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) - &bfin_uart_device, -#endif -}; - -static int __init H8606_init(void) -{ - printk(KERN_INFO "HV Sistemas H8606 board support by http://www.hvsistemas.com\n"); - printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__); - platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices)); -#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE) - spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info)); -#endif - return 0; -} - -arch_initcall(H8606_init); \ No newline at end of file diff --git a/trunk/arch/blackfin/mach-bf533/boards/Makefile b/trunk/arch/blackfin/mach-bf533/boards/Makefile index 2452b456ccbd..12a631ab389d 100644 --- a/trunk/arch/blackfin/mach-bf533/boards/Makefile +++ b/trunk/arch/blackfin/mach-bf533/boards/Makefile @@ -6,4 +6,3 @@ obj-$(CONFIG_GENERIC_BOARD) += generic_board.o obj-$(CONFIG_BFIN533_STAMP) += stamp.o obj-$(CONFIG_BFIN533_EZKIT) += ezkit.o obj-$(CONFIG_BFIN533_BLUETECHNIX_CM) += cm_bf533.o -obj-$(CONFIG_H8606_HVSISTEMAS) += H8606.o diff --git a/trunk/arch/blackfin/mach-bf533/boards/cm_bf533.c b/trunk/arch/blackfin/mach-bf533/boards/cm_bf533.c index a863522a4467..1c5a86adfab7 100644 --- a/trunk/arch/blackfin/mach-bf533/boards/cm_bf533.c +++ b/trunk/arch/blackfin/mach-bf533/boards/cm_bf533.c @@ -46,7 +46,7 @@ const char bfin_board_name[] = "Bluetechnix CM BF533"; #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE) /* all SPI peripherals info goes here */ -#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) + static struct mtd_partition bfin_spi_flash_partitions[] = { { .name = "bootloader", @@ -76,15 +76,12 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = { .enable_dma = 0, /* use dma transfer with this chip*/ .bits_per_word = 8, }; -#endif /* SPI ADC chip */ -#if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE) static struct bfin5xx_spi_chip spi_adc_chip_info = { .enable_dma = 1, /* use dma transfer with this chip*/ .bits_per_word = 16, }; -#endif #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE) static struct bfin5xx_spi_chip ad1836_spi_chip_info = { @@ -93,15 +90,7 @@ static struct bfin5xx_spi_chip ad1836_spi_chip_info = { }; #endif -#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE) -static struct bfin5xx_spi_chip spi_mmc_chip_info = { - .enable_dma = 1, - .bits_per_word = 8, -}; -#endif - static struct spi_board_info bfin_spi_board_info[] __initdata = { -#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) { /* the modalias must be the same as spi device driver name */ .modalias = "m25p80", /* Name of spi_driver for this device */ @@ -111,11 +100,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = { .platform_data = &bfin_spi_flash_data, .controller_data = &spi_flash_chip_info, .mode = SPI_MODE_3, - }, -#endif - -#if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE) - { + }, { .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */ .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */ .bus_num = 0, /* Framework bus number */ @@ -123,8 +108,6 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = { .platform_data = NULL, /* No spi_driver specific config */ .controller_data = &spi_adc_chip_info, }, -#endif - #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE) { .modalias = "ad1836-spi", @@ -134,27 +117,6 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = { .controller_data = &ad1836_spi_chip_info, }, #endif - -#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE) - { - .modalias = "spi_mmc_dummy", - .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */ - .bus_num = 0, - .chip_select = 0, - .platform_data = NULL, - .controller_data = &spi_mmc_chip_info, - .mode = SPI_MODE_3, - }, - { - .modalias = "spi_mmc", - .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */ - .bus_num = 0, - .chip_select = CONFIG_SPI_MMC_CS_CHAN, - .platform_data = NULL, - .controller_data = &spi_mmc_chip_info, - .mode = SPI_MODE_3, - }, -#endif }; /* SPI (0) */ diff --git a/trunk/arch/blackfin/mach-bf533/boards/stamp.c b/trunk/arch/blackfin/mach-bf533/boards/stamp.c index 62ffa500420f..f84be4eabfd1 100644 --- a/trunk/arch/blackfin/mach-bf533/boards/stamp.c +++ b/trunk/arch/blackfin/mach-bf533/boards/stamp.c @@ -218,7 +218,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = { #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE) { .modalias = "spi_mmc_dummy", - .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ + .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */ .bus_num = 0, .chip_select = 0, .platform_data = NULL, @@ -227,7 +227,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = { }, { .modalias = "spi_mmc", - .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ + .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */ .bus_num = 0, .chip_select = CONFIG_SPI_MMC_CS_CHAN, .platform_data = NULL, diff --git a/trunk/arch/blackfin/mach-bf537/boards/cm_bf537.c b/trunk/arch/blackfin/mach-bf537/boards/cm_bf537.c index 2915931045e3..52e2320307de 100644 --- a/trunk/arch/blackfin/mach-bf537/boards/cm_bf537.c +++ b/trunk/arch/blackfin/mach-bf537/boards/cm_bf537.c @@ -281,8 +281,8 @@ static struct resource net2272_bfin_resources[] = { .end = 0x20200000 + 0x100, .flags = IORESOURCE_MEM, }, { - .start = IRQ_PH14, - .end = IRQ_PH14, + .start = IRQ_PF7, + .end = IRQ_PF7, .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, }, }; diff --git a/trunk/arch/blackfin/mach-bf537/boards/stamp.c b/trunk/arch/blackfin/mach-bf537/boards/stamp.c index 5f7b91fbafe8..cc41f6c2ef4f 100644 --- a/trunk/arch/blackfin/mach-bf537/boards/stamp.c +++ b/trunk/arch/blackfin/mach-bf537/boards/stamp.c @@ -450,7 +450,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = { #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE) { .modalias = "spi_mmc_dummy", - .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ + .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */ .bus_num = 0, .chip_select = 0, .platform_data = NULL, @@ -459,7 +459,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = { }, { .modalias = "spi_mmc", - .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ + .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */ .bus_num = 0, .chip_select = CONFIG_SPI_MMC_CS_CHAN, .platform_data = NULL, @@ -612,7 +612,7 @@ static struct platform_device bfin_sport1_uart_device = { static struct pata_platform_info bfin_pata_platform_data = { .ioport_shift = 1, - .irq_flags = IRQF_TRIGGER_HIGH | IRQF_DISABLED, + .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED, }; static struct resource bfin_pata_resources[] = { diff --git a/trunk/arch/blackfin/mach-common/entry.S b/trunk/arch/blackfin/mach-common/entry.S index 1b13fa470977..e3ad5802868a 100644 --- a/trunk/arch/blackfin/mach-common/entry.S +++ b/trunk/arch/blackfin/mach-common/entry.S @@ -917,7 +917,7 @@ ENTRY(_ex_table) .long _ex_soft_bp /* 0x01 - User Defined - Software breakpoint */ .long _ex_replaceable /* 0x02 - User Defined */ .long _ex_trap_c /* 0x03 - User Defined - userspace stack overflow */ - .long _ex_trap_c /* 0x04 - User Defined - dump trace buffer */ + .long _ex_replaceable /* 0x04 - User Defined */ .long _ex_replaceable /* 0x05 - User Defined */ .long _ex_replaceable /* 0x06 - User Defined */ .long _ex_replaceable /* 0x07 - User Defined */ diff --git a/trunk/arch/frv/mb93090-mb00/pci-dma.c b/trunk/arch/frv/mb93090-mb00/pci-dma.c index 662f7b12d005..671ce1e8434f 100644 --- a/trunk/arch/frv/mb93090-mb00/pci-dma.c +++ b/trunk/arch/frv/mb93090-mb00/pci-dma.c @@ -15,7 +15,6 @@ #include #include #include -#include #include void *dma_alloc_coherent(struct device *hwdev, size_t size, dma_addr_t *dma_handle, gfp_t gfp) @@ -87,7 +86,7 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, dampr2 = __get_DAMPR(2); for (i = 0; i < nents; i++) { - vaddr = kmap_atomic(sg_page(&sg[i]), __KM_CACHE); + vaddr = kmap_atomic(sg[i].page, __KM_CACHE); frv_dcache_writeback((unsigned long) vaddr, (unsigned long) vaddr + PAGE_SIZE); diff --git a/trunk/arch/h8300/Kconfig b/trunk/arch/h8300/Kconfig index ff6a8712bd6d..e2e9f57abe2e 100644 --- a/trunk/arch/h8300/Kconfig +++ b/trunk/arch/h8300/Kconfig @@ -1,6 +1,6 @@ # # For a description of the syntax of this configuration file, -# see Documentation/kbuild/kconfig-language.txt. +# see Documentation/kbuild/config-language.txt. # mainmenu "uClinux/h8300 (w/o MMU) Kernel Configuration" diff --git a/trunk/arch/i386/.gitignore b/trunk/arch/i386/.gitignore new file mode 100644 index 000000000000..36ef4c374d25 --- /dev/null +++ b/trunk/arch/i386/.gitignore @@ -0,0 +1 @@ +boot diff --git a/trunk/arch/x86/Kconfig.i386 b/trunk/arch/i386/Kconfig similarity index 99% rename from trunk/arch/x86/Kconfig.i386 rename to trunk/arch/i386/Kconfig index 7331efe891a7..5bed8be34ba5 100644 --- a/trunk/arch/x86/Kconfig.i386 +++ b/trunk/arch/i386/Kconfig @@ -287,7 +287,7 @@ config ES7000_CLUSTERED_APIC default y depends on SMP && X86_ES7000 && MPENTIUMIII -source "arch/x86/Kconfig.cpu" +source "arch/i386/Kconfig.cpu" config HPET_TIMER bool "HPET Timer Support" @@ -1270,9 +1270,7 @@ source "drivers/Kconfig" source "fs/Kconfig" -source "kernel/Kconfig.instrumentation" - -source "arch/x86/Kconfig.debug" +source "arch/i386/Kconfig.debug" source "security/Kconfig" diff --git a/trunk/arch/x86/Kconfig.cpu b/trunk/arch/i386/Kconfig.cpu similarity index 100% rename from trunk/arch/x86/Kconfig.cpu rename to trunk/arch/i386/Kconfig.cpu diff --git a/trunk/arch/x86/Kconfig.debug b/trunk/arch/i386/Kconfig.debug similarity index 64% rename from trunk/arch/x86/Kconfig.debug rename to trunk/arch/i386/Kconfig.debug index 761ca7b5f120..f03531eacdfb 100644 --- a/trunk/arch/x86/Kconfig.debug +++ b/trunk/arch/i386/Kconfig.debug @@ -1,12 +1,13 @@ menu "Kernel hacking" config TRACE_IRQFLAGS_SUPPORT - def_bool y + bool + default y source "lib/Kconfig.debug" config EARLY_PRINTK - bool "Early printk" if EMBEDDED && DEBUG_KERNEL && X86_32 + bool "Early printk" if EMBEDDED && DEBUG_KERNEL default y help Write kernel log output directly into the VGA buffer or to a serial @@ -36,12 +37,10 @@ config DEBUG_STACK_USAGE comment "Page alloc debug is incompatible with Software Suspend on i386" depends on DEBUG_KERNEL && HIBERNATION - depends on X86_32 config DEBUG_PAGEALLOC bool "Debug page memory allocations" depends on DEBUG_KERNEL && !HIBERNATION && !HUGETLBFS - depends on X86_32 help Unmap pages from the kernel linear mapping after free_pages(). This results in a large slowdown, but helps to find certain types @@ -60,7 +59,6 @@ config DEBUG_RODATA config 4KSTACKS bool "Use 4Kb for kernel stacks instead of 8Kb" depends on DEBUG_KERNEL - depends on X86_32 help If you say Y here the kernel will use a 4Kb stacksize for the kernel stack attached to each process/thread. This facilitates @@ -69,47 +67,22 @@ config 4KSTACKS will also use IRQ stacks to compensate for the reduced stackspace. config X86_FIND_SMP_CONFIG - def_bool y + bool depends on X86_LOCAL_APIC || X86_VOYAGER - depends on X86_32 + default y config X86_MPPARSE - def_bool y + bool depends on X86_LOCAL_APIC && !X86_VISWS - depends on X86_32 + default y config DOUBLEFAULT default y bool "Enable doublefault exception handler" if EMBEDDED - depends on X86_32 - help - This option allows trapping of rare doublefault exceptions that - would otherwise cause a system to silently reboot. Disabling this - option saves about 4k and might cause you much additional grey - hair. - -config IOMMU_DEBUG - bool "Enable IOMMU debugging" - depends on GART_IOMMU && DEBUG_KERNEL - depends on X86_64 - help - Force the IOMMU to on even when you have less than 4GB of - memory and add debugging code. On overflow always panic. And - allow to enable IOMMU leak tracing. Can be disabled at boot - time with iommu=noforce. This will also enable scatter gather - list merging. Currently not recommended for production - code. When you use it make sure you have a big enough - IOMMU/AGP aperture. Most of the options enabled by this can - be set more finegrained using the iommu= command line - options. See Documentation/x86_64/boot-options.txt for more - details. - -config IOMMU_LEAK - bool "IOMMU leak tracing" - depends on DEBUG_KERNEL - depends on IOMMU_DEBUG help - Add a simple leak tracer to the IOMMU code. This is useful when you - are debugging a buggy device driver that leaks IOMMU mappings. + This option allows trapping of rare doublefault exceptions that + would otherwise cause a system to silently reboot. Disabling this + option saves about 4k and might cause you much additional grey + hair. endmenu diff --git a/trunk/arch/x86/Makefile_32 b/trunk/arch/i386/Makefile similarity index 96% rename from trunk/arch/x86/Makefile_32 rename to trunk/arch/i386/Makefile index 346ac0766875..b81cb64d48e5 100644 --- a/trunk/arch/x86/Makefile_32 +++ b/trunk/arch/i386/Makefile @@ -1,5 +1,5 @@ # -# i386 Makefile +# i386/Makefile # # This file is included by the global makefile so that you can add your own # architecture-specific flags and dependencies. Remember to do have actions @@ -17,11 +17,8 @@ # 20050320 Kianusch Sayah Karadji # Added support for GEODE CPU -# BITS is used as extension for files which are available in a 32 bit -# and a 64 bit version to simplify shared Makefiles. -# e.g.: obj-y += foo_$(BITS).o -BITS := 32 -export BITS +# Fill in SRCARCH +SRCARCH := x86 HAS_BIARCH := $(call cc-option-yn, -m32) ifeq ($(HAS_BIARCH),y) @@ -43,7 +40,7 @@ KBUILD_CFLAGS += -pipe -msoft-float -mregparm=3 -freg-struct-return KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2) # CPU-specific tuning. Anything which can be shared with UML should go here. -include $(srctree)/arch/x86/Makefile_32.cpu +include $(srctree)/arch/i386/Makefile.cpu # temporary until string.h is fixed cflags-y += -ffreestanding diff --git a/trunk/arch/x86/Makefile_32.cpu b/trunk/arch/i386/Makefile.cpu similarity index 100% rename from trunk/arch/x86/Makefile_32.cpu rename to trunk/arch/i386/Makefile.cpu diff --git a/trunk/arch/x86/configs/i386_defconfig b/trunk/arch/i386/defconfig similarity index 100% rename from trunk/arch/x86/configs/i386_defconfig rename to trunk/arch/i386/defconfig diff --git a/trunk/arch/ia64/configs/sn2_defconfig b/trunk/arch/ia64/configs/sn2_defconfig index 7f6b2377d13f..75fd90dc76a3 100644 --- a/trunk/arch/ia64/configs/sn2_defconfig +++ b/trunk/arch/ia64/configs/sn2_defconfig @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit -# Linux kernel version: 2.6.23 -# Thu Oct 18 16:03:40 2007 +# Linux kernel version: 2.6.23-rc6 +# Tue Sep 18 11:24:01 2007 # CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" @@ -28,8 +28,6 @@ CONFIG_TASK_IO_ACCOUNTING=y CONFIG_LOG_BUF_SHIFT=20 CONFIG_CGROUPS=y CONFIG_CPUSETS=y -CONFIG_FAIR_GROUP_SCHED=y -CONFIG_FAIR_USER_SCHED=y CONFIG_SYSFS_DEPRECATED=y CONFIG_RELAY=y CONFIG_BLK_DEV_INITRD=y @@ -50,6 +48,7 @@ CONFIG_FUTEX=y CONFIG_ANON_INODES=y CONFIG_EPOLL=y CONFIG_SIGNALFD=y +CONFIG_TIMERFD=y CONFIG_EVENTFD=y CONFIG_SHMEM=y CONFIG_VM_EVENT_COUNTERS=y @@ -70,7 +69,6 @@ CONFIG_STOP_MACHINE=y CONFIG_BLOCK=y # CONFIG_BLK_DEV_IO_TRACE is not set CONFIG_BLK_DEV_BSG=y -CONFIG_BLOCK_COMPAT=y # # IO Schedulers @@ -95,7 +93,6 @@ CONFIG_MMU=y CONFIG_RWSEM_XCHGADD_ALGORITHM=y # CONFIG_ARCH_HAS_ILOG2_U32 is not set # CONFIG_ARCH_HAS_ILOG2_U64 is not set -CONFIG_HUGETLB_PAGE_SIZE_VARIABLE=y CONFIG_GENERIC_FIND_NEXT_BIT=y CONFIG_GENERIC_CALIBRATE_DELAY=y CONFIG_GENERIC_TIME=y @@ -116,10 +113,10 @@ CONFIG_IA64_SGI_SN2=y CONFIG_MCKINLEY=y # CONFIG_IA64_PAGE_SIZE_4KB is not set # CONFIG_IA64_PAGE_SIZE_8KB is not set -# CONFIG_IA64_PAGE_SIZE_16KB is not set -CONFIG_IA64_PAGE_SIZE_64KB=y -CONFIG_PGTABLE_3=y -# CONFIG_PGTABLE_4 is not set +CONFIG_IA64_PAGE_SIZE_16KB=y +# CONFIG_IA64_PAGE_SIZE_64KB is not set +# CONFIG_PGTABLE_3 is not set +CONFIG_PGTABLE_4=y # CONFIG_HZ_100 is not set CONFIG_HZ_250=y # CONFIG_HZ_300 is not set @@ -134,7 +131,6 @@ CONFIG_SMP=y CONFIG_NR_CPUS=1024 # CONFIG_HOTPLUG_CPU is not set CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y -CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE=y CONFIG_SCHED_SMT=y CONFIG_PREEMPT_NONE=y # CONFIG_PREEMPT_VOLUNTARY is not set @@ -148,7 +144,6 @@ CONFIG_DISCONTIGMEM=y CONFIG_FLAT_NODE_MEM_MAP=y CONFIG_NEED_MULTIPLE_NODES=y # CONFIG_SPARSEMEM_STATIC is not set -CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y CONFIG_SPLIT_PTLOCK_CPUS=4 CONFIG_MIGRATION=y CONFIG_RESOURCES_64BIT=y @@ -176,7 +171,6 @@ CONFIG_IA64_PALINFO=y CONFIG_IA64_MC_ERR_INJECT=y CONFIG_SGI_SN=y # CONFIG_IA64_ESI is not set -# CONFIG_IA64_HP_AML_NFW is not set # # SN Devices @@ -226,6 +220,7 @@ CONFIG_PCI_DOMAINS=y CONFIG_PCI_SYSCALL=y CONFIG_PCIEPORTBUS=y CONFIG_HOTPLUG_PCI_PCIE=y +# CONFIG_HOTPLUG_PCI_PCIE_POLL_EVENT_MODE is not set CONFIG_PCIEAER=y CONFIG_ARCH_SUPPORTS_MSI=y # CONFIG_PCI_MSI is not set @@ -236,6 +231,10 @@ CONFIG_HOTPLUG_PCI=y # CONFIG_HOTPLUG_PCI_CPCI is not set # CONFIG_HOTPLUG_PCI_SHPC is not set CONFIG_HOTPLUG_PCI_SGI=y + +# +# PCCARD (PCMCIA/CardBus) support +# # CONFIG_PCCARD is not set # @@ -272,7 +271,6 @@ CONFIG_INET_TUNNEL=m CONFIG_INET_XFRM_MODE_TRANSPORT=y CONFIG_INET_XFRM_MODE_TUNNEL=y CONFIG_INET_XFRM_MODE_BEET=y -CONFIG_INET_LRO=y CONFIG_INET_DIAG=m CONFIG_INET_TCP_DIAG=m # CONFIG_TCP_CONG_ADVANCED is not set @@ -344,7 +342,6 @@ CONFIG_IPV6_SIT=m # # Generic Driver Options # -CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" CONFIG_STANDALONE=y CONFIG_PREVENT_FIRMWARE_BUILD=y CONFIG_FW_LOADER=y @@ -405,12 +402,7 @@ CONFIG_IDE_PROC_FS=y # IDE chipset support/bugfixes # CONFIG_IDE_GENERIC=y -# CONFIG_BLK_DEV_PLATFORM is not set # CONFIG_BLK_DEV_IDEPNP is not set - -# -# PCI IDE chipsets support -# CONFIG_BLK_DEV_IDEPCI=y CONFIG_IDEPCI_SHARE_IRQ=y CONFIG_IDEPCI_PCIBUS_ORDER=y @@ -418,6 +410,8 @@ CONFIG_IDEPCI_PCIBUS_ORDER=y # CONFIG_BLK_DEV_GENERIC is not set # CONFIG_BLK_DEV_OPTI621 is not set CONFIG_BLK_DEV_IDEDMA_PCI=y +# CONFIG_BLK_DEV_IDEDMA_FORCED is not set +# CONFIG_IDEDMA_ONLYDISK is not set # CONFIG_BLK_DEV_AEC62XX is not set # CONFIG_BLK_DEV_ALI15X3 is not set # CONFIG_BLK_DEV_AMD74XX is not set @@ -445,6 +439,7 @@ CONFIG_BLK_DEV_SGIIOC4=y # CONFIG_BLK_DEV_TC86C001 is not set # CONFIG_IDE_ARM is not set CONFIG_BLK_DEV_IDEDMA=y +# CONFIG_IDEDMA_IVB is not set # CONFIG_BLK_DEV_HD is not set # @@ -487,7 +482,6 @@ CONFIG_SCSI_SAS_ATTRS=y CONFIG_SCSI_SAS_LIBSAS=y # CONFIG_SCSI_SAS_ATA is not set # CONFIG_SCSI_SAS_LIBSAS_DEBUG is not set -CONFIG_SCSI_SRP_ATTRS=y CONFIG_SCSI_LOWLEVEL=y CONFIG_ISCSI_TCP=m # CONFIG_BLK_DEV_3W_XXXX_RAID is not set @@ -498,7 +492,6 @@ CONFIG_ISCSI_TCP=m # CONFIG_SCSI_AIC7XXX_OLD is not set # CONFIG_SCSI_AIC79XX is not set # CONFIG_SCSI_AIC94XX is not set -# CONFIG_SCSI_ADVANSYS is not set # CONFIG_SCSI_ARCMSR is not set # CONFIG_MEGARAID_NEWGEN is not set # CONFIG_MEGARAID_LEGACY is not set @@ -539,7 +532,6 @@ CONFIG_ATA_ACPI=y # CONFIG_SATA_VIA is not set CONFIG_SATA_VITESSE=y # CONFIG_SATA_INIC162X is not set -# CONFIG_PATA_ACPI is not set # CONFIG_PATA_ALI is not set # CONFIG_PATA_AMD is not set # CONFIG_PATA_ARTOP is not set @@ -564,7 +556,6 @@ CONFIG_SATA_VITESSE=y # CONFIG_PATA_OLDPIIX is not set # CONFIG_PATA_NETCELL is not set # CONFIG_PATA_NS87410 is not set -# CONFIG_PATA_NS87415 is not set # CONFIG_PATA_OPTI is not set # CONFIG_PATA_OPTIDMA is not set # CONFIG_PATA_PDC_OLD is not set @@ -597,6 +588,10 @@ CONFIG_DM_MULTIPATH=m CONFIG_DM_MULTIPATH_EMC=m # CONFIG_DM_MULTIPATH_RDAC is not set # CONFIG_DM_DELAY is not set + +# +# Fusion MPT device support +# CONFIG_FUSION=y CONFIG_FUSION_SPI=y CONFIG_FUSION_FC=y @@ -618,16 +613,13 @@ CONFIG_NETDEVICES=y # CONFIG_MACVLAN is not set # CONFIG_EQUALIZER is not set # CONFIG_TUN is not set -# CONFIG_VETH is not set # CONFIG_NET_SB1000 is not set -# CONFIG_IP1000 is not set # CONFIG_ARCNET is not set # CONFIG_NET_ETHERNET is not set CONFIG_NETDEV_1000=y # CONFIG_ACENIC is not set # CONFIG_DL2K is not set # CONFIG_E1000 is not set -# CONFIG_E1000E is not set # CONFIG_NS83820 is not set # CONFIG_HAMACHI is not set # CONFIG_YELLOWFIN is not set @@ -646,15 +638,12 @@ CONFIG_CHELSIO_T1=m CONFIG_CHELSIO_T1_1G=y # CONFIG_CHELSIO_T1_NAPI is not set CONFIG_CHELSIO_T3=m -CONFIG_IXGBE=m # CONFIG_IXGB is not set CONFIG_S2IO=m # CONFIG_S2IO_NAPI is not set # CONFIG_MYRI10GE is not set # CONFIG_NETXEN_NIC is not set -# CONFIG_NIU is not set # CONFIG_MLX4_CORE is not set -# CONFIG_TEHUTI is not set # CONFIG_TR is not set # @@ -680,7 +669,6 @@ CONFIG_S2IO=m # CONFIG_NET_FC is not set # CONFIG_SHAPER is not set CONFIG_NETCONSOLE=y -# CONFIG_NETCONSOLE_DYNAMIC is not set CONFIG_NETPOLL=y # CONFIG_NETPOLL_TRAP is not set CONFIG_NET_POLL_CONTROLLER=y @@ -702,6 +690,7 @@ CONFIG_INPUT_MOUSEDEV=y CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 # CONFIG_INPUT_JOYDEV is not set +# CONFIG_INPUT_TSDEV is not set # CONFIG_INPUT_EVDEV is not set # CONFIG_INPUT_EVBUG is not set @@ -725,7 +714,6 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 # Character devices # CONFIG_VT=y -# CONFIG_VT_UNICODE is not set CONFIG_VT_CONSOLE=y CONFIG_HW_CONSOLE=y # CONFIG_VT_HW_CONSOLE_BINDING is not set @@ -772,6 +760,9 @@ CONFIG_LEGACY_PTY_COUNT=256 CONFIG_EFI_RTC=y # CONFIG_R3964 is not set # CONFIG_APPLICOM is not set +CONFIG_AGP=y +CONFIG_AGP_SGI_TIOCA=y +# CONFIG_DRM is not set CONFIG_RAW_DRIVER=m CONFIG_MAX_RAW_DEVS=256 # CONFIG_HPET is not set @@ -790,12 +781,6 @@ CONFIG_DEVPORT=y # CONFIG_POWER_SUPPLY is not set # CONFIG_HWMON is not set -# -# Sonics Silicon Backplane -# -CONFIG_SSB_POSSIBLE=y -# CONFIG_SSB is not set - # # Multifunction device drivers # @@ -811,18 +796,15 @@ CONFIG_SSB_POSSIBLE=y # # Graphics support # -CONFIG_AGP=y -CONFIG_AGP_SGI_TIOCA=y -# CONFIG_DRM is not set -# CONFIG_VGASTATE is not set -CONFIG_VIDEO_OUTPUT_CONTROL=m -# CONFIG_FB is not set # CONFIG_BACKLIGHT_LCD_SUPPORT is not set # # Display device support # # CONFIG_DISPLAY_SUPPORT is not set +# CONFIG_VGASTATE is not set +CONFIG_VIDEO_OUTPUT_CONTROL=m +# CONFIG_FB is not set # # Console display driver support @@ -838,7 +820,6 @@ CONFIG_DUMMY_CONSOLE=y CONFIG_HID_SUPPORT=y CONFIG_HID=y CONFIG_HID_DEBUG=y -# CONFIG_HIDRAW is not set # # USB Input Devices @@ -969,6 +950,19 @@ CONFIG_INFINIBAND_SRP=m # CONFIG_INFINIBAND_ISER is not set # CONFIG_RTC_CLASS is not set +# +# DMA Engine support +# +# CONFIG_DMA_ENGINE is not set + +# +# DMA Clients +# + +# +# DMA Devices +# + # # Userspace I/O # @@ -1011,8 +1005,6 @@ CONFIG_XFS_RT=y CONFIG_INOTIFY=y CONFIG_INOTIFY_USER=y CONFIG_QUOTA=y -CONFIG_QUOTA_NETLINK_INTERFACE=y -CONFIG_PRINT_QUOTA_WARNING=y # CONFIG_QFMT_V1 is not set # CONFIG_QFMT_V2 is not set CONFIG_QUOTACTL=y @@ -1051,6 +1043,7 @@ CONFIG_TMPFS=y # CONFIG_TMPFS_POSIX_ACL is not set CONFIG_HUGETLBFS=y CONFIG_HUGETLB_PAGE=y +CONFIG_RAMFS=y # CONFIG_CONFIGFS_FS is not set # @@ -1069,7 +1062,10 @@ CONFIG_HUGETLB_PAGE=y # CONFIG_QNX4FS_FS is not set # CONFIG_SYSV_FS is not set # CONFIG_UFS_FS is not set -CONFIG_NETWORK_FILESYSTEMS=y + +# +# Network File Systems +# CONFIG_NFS_FS=m CONFIG_NFS_V3=y # CONFIG_NFS_V3_ACL is not set @@ -1086,7 +1082,6 @@ CONFIG_EXPORTFS=m CONFIG_NFS_COMMON=y CONFIG_SUNRPC=m CONFIG_SUNRPC_GSS=m -CONFIG_SUNRPC_XPRT_RDMA=m # CONFIG_SUNRPC_BIND34 is not set CONFIG_RPCSEC_GSS_KRB5=m # CONFIG_RPCSEC_GSS_SPKM3 is not set @@ -1123,6 +1118,10 @@ CONFIG_SGI_PARTITION=y # CONFIG_KARMA_PARTITION is not set CONFIG_EFI_PARTITION=y # CONFIG_SYSV68_PARTITION is not set + +# +# Native Language Support +# CONFIG_NLS=y CONFIG_NLS_DEFAULT="iso8859-1" CONFIG_NLS_CODEPAGE_437=y @@ -1163,6 +1162,10 @@ CONFIG_NLS_ISO8859_1=y # CONFIG_NLS_KOI8_R is not set # CONFIG_NLS_KOI8_U is not set CONFIG_NLS_UTF8=y + +# +# Distributed Lock Manager +# # CONFIG_DLM is not set # @@ -1220,7 +1223,6 @@ CONFIG_DEBUG_INFO=y # CONFIG_DEBUG_VM is not set # CONFIG_DEBUG_LIST is not set CONFIG_FORCED_INLINING=y -# CONFIG_BOOT_PRINTK_DELAY is not set # CONFIG_RCU_TORTURE_TEST is not set # CONFIG_FAULT_INJECTION is not set CONFIG_IA64_GRANULE_16MB=y @@ -1236,7 +1238,6 @@ CONFIG_SYSVIPC_COMPAT=y # # CONFIG_KEYS is not set # CONFIG_SECURITY is not set -# CONFIG_SECURITY_FILE_CAPABILITIES is not set CONFIG_XOR_BLOCKS=y CONFIG_ASYNC_CORE=y CONFIG_ASYNC_MEMCPY=y @@ -1261,7 +1262,6 @@ CONFIG_CRYPTO_ECB=m CONFIG_CRYPTO_CBC=m CONFIG_CRYPTO_PCBC=m # CONFIG_CRYPTO_LRW is not set -# CONFIG_CRYPTO_XTS is not set # CONFIG_CRYPTO_CRYPTD is not set CONFIG_CRYPTO_DES=m # CONFIG_CRYPTO_FCRYPT is not set @@ -1275,11 +1275,9 @@ CONFIG_CRYPTO_DES=m # CONFIG_CRYPTO_ARC4 is not set # CONFIG_CRYPTO_KHAZAD is not set # CONFIG_CRYPTO_ANUBIS is not set -# CONFIG_CRYPTO_SEED is not set CONFIG_CRYPTO_DEFLATE=m # CONFIG_CRYPTO_MICHAEL_MIC is not set CONFIG_CRYPTO_CRC32C=m # CONFIG_CRYPTO_CAMELLIA is not set # CONFIG_CRYPTO_TEST is not set -# CONFIG_CRYPTO_AUTHENC is not set # CONFIG_CRYPTO_HW is not set diff --git a/trunk/arch/ia64/kernel/efi.c b/trunk/arch/ia64/kernel/efi.c index 6216eba2e38f..3f7ea13358e9 100644 --- a/trunk/arch/ia64/kernel/efi.c +++ b/trunk/arch/ia64/kernel/efi.c @@ -1231,7 +1231,7 @@ kdump_find_rsvd_region (unsigned long size, #ifdef CONFIG_PROC_VMCORE /* locate the size find a the descriptor at a certain address */ -unsigned long __init +unsigned long vmcore_find_descriptor_size (unsigned long address) { void *efi_map_start, *efi_map_end, *p; diff --git a/trunk/arch/ia64/kernel/gate.lds.S b/trunk/arch/ia64/kernel/gate.lds.S index 454d7a7dfa9d..44817d97ab43 100644 --- a/trunk/arch/ia64/kernel/gate.lds.S +++ b/trunk/arch/ia64/kernel/gate.lds.S @@ -20,8 +20,6 @@ SECTIONS .gnu.version_d : { *(.gnu.version_d) } .gnu.version_r : { *(.gnu.version_r) } - .note : { *(.note*) } :readable :note - .dynamic : { *(.dynamic) } :readable :dynamic /* @@ -85,7 +83,6 @@ PHDRS epc PT_LOAD FILEHDR PHDRS FLAGS(1); /* PF_X */ #endif dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ - note PT_NOTE FLAGS(4); /* PF_R */ unwind PT_IA_64_UNWIND; } diff --git a/trunk/arch/ia64/kernel/msi_ia64.c b/trunk/arch/ia64/kernel/msi_ia64.c index e86d02959794..2fdbd5c3f213 100644 --- a/trunk/arch/ia64/kernel/msi_ia64.c +++ b/trunk/arch/ia64/kernel/msi_ia64.c @@ -109,7 +109,7 @@ int ia64_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc) write_msi_msg(irq, &msg); set_irq_chip_and_handler(irq, &ia64_msi_chip, handle_edge_irq); - return 0; + return irq; } void ia64_teardown_msi_irq(unsigned int irq) diff --git a/trunk/arch/ia64/kernel/setup.c b/trunk/arch/ia64/kernel/setup.c index 2b3751eef5ce..ae6c3c02e117 100644 --- a/trunk/arch/ia64/kernel/setup.c +++ b/trunk/arch/ia64/kernel/setup.c @@ -417,6 +417,34 @@ mark_bsp_online (void) #endif } +#ifdef CONFIG_SMP +static void __init +check_for_logical_procs (void) +{ + pal_logical_to_physical_t info; + s64 status; + + status = ia64_pal_logical_to_phys(0, &info); + if (status == -1) { + printk(KERN_INFO "No logical to physical processor mapping " + "available\n"); + return; + } + if (status) { + printk(KERN_ERR "ia64_pal_logical_to_phys failed with %ld\n", + status); + return; + } + /* + * Total number of siblings that BSP has. Though not all of them + * may have booted successfully. The correct number of siblings + * booted is in info.overview_num_log. + */ + smp_num_siblings = info.overview_tpc; + smp_num_cpucores = info.overview_cpp; +} +#endif + static __initdata int nomca; static __init int setup_nomca(char *s) { @@ -512,6 +540,15 @@ setup_arch (char **cmdline_p) #ifdef CONFIG_SMP cpu_physical_id(0) = hard_smp_processor_id(); + check_for_logical_procs(); + if (smp_num_cpucores > 1) + printk(KERN_INFO + "cpu package is Multi-Core capable: number of cores=%d\n", + smp_num_cpucores); + if (smp_num_siblings > 1) + printk(KERN_INFO + "cpu package is Multi-Threading capable: number of siblings=%d\n", + smp_num_siblings); #endif cpu_init(); /* initialize the bootstrap CPU */ @@ -624,13 +661,12 @@ show_cpuinfo (struct seq_file *m, void *v) lpj*HZ/500000, (lpj*HZ/5000) % 100); #ifdef CONFIG_SMP seq_printf(m, "siblings : %u\n", cpus_weight(cpu_core_map[cpunum])); - if (c->socket_id != -1) - seq_printf(m, "physical id: %u\n", c->socket_id); if (c->threads_per_core > 1 || c->cores_per_socket > 1) seq_printf(m, - "core id : %u\n" - "thread id : %u\n", - c->core_id, c->thread_id); + "physical id: %u\n" + "core id : %u\n" + "thread id : %u\n", + c->socket_id, c->core_id, c->thread_id); #endif seq_printf(m,"\n"); @@ -742,9 +778,6 @@ identify_cpu (struct cpuinfo_ia64 *c) c->socket_id = -1; identify_siblings(c); - - if (c->threads_per_core > smp_num_siblings) - smp_num_siblings = c->threads_per_core; #endif c->ppn = cpuid.field.ppn; c->number = cpuid.field.number; diff --git a/trunk/arch/ia64/kernel/smpboot.c b/trunk/arch/ia64/kernel/smpboot.c index f0fc4d8465ad..c57dbce25c12 100644 --- a/trunk/arch/ia64/kernel/smpboot.c +++ b/trunk/arch/ia64/kernel/smpboot.c @@ -142,6 +142,7 @@ DEFINE_PER_CPU_SHARED_ALIGNED(cpumask_t, cpu_sibling_map); EXPORT_PER_CPU_SYMBOL(cpu_sibling_map); int smp_num_siblings = 1; +int smp_num_cpucores = 1; /* which logical CPU number maps to which CPU (physical APIC ID) */ volatile int ia64_cpu_to_sapicid[NR_CPUS]; @@ -885,17 +886,13 @@ identify_siblings(struct cpuinfo_ia64 *c) u16 pltid; pal_logical_to_physical_t info; - if ((status = ia64_pal_logical_to_phys(-1, &info)) != PAL_STATUS_SUCCESS) { - if (status != PAL_STATUS_UNIMPLEMENTED) { - printk(KERN_ERR - "ia64_pal_logical_to_phys failed with %ld\n", - status); - return; - } + if (smp_num_cpucores == 1 && smp_num_siblings == 1) + return; - info.overview_ppid = 0; - info.overview_cpp = 1; - info.overview_tpc = 1; + if ((status = ia64_pal_logical_to_phys(-1, &info)) != PAL_STATUS_SUCCESS) { + printk(KERN_ERR "ia64_pal_logical_to_phys failed with %ld\n", + status); + return; } if ((status = ia64_sal_physical_id_info(&pltid)) != PAL_STATUS_SUCCESS) { printk(KERN_ERR "ia64_sal_pltid failed with %ld\n", status); @@ -903,10 +900,6 @@ identify_siblings(struct cpuinfo_ia64 *c) } c->socket_id = (pltid << 8) | info.overview_ppid; - - if (info.overview_cpp == 1 && info.overview_tpc == 1) - return; - c->cores_per_socket = info.overview_cpp; c->threads_per_core = info.overview_tpc; c->num_log = info.overview_num_log; diff --git a/trunk/arch/ia64/mm/init.c b/trunk/arch/ia64/mm/init.c index 25aef6211a54..c6c19bf11bec 100644 --- a/trunk/arch/ia64/mm/init.c +++ b/trunk/arch/ia64/mm/init.c @@ -472,7 +472,7 @@ struct memmap_init_callback_data { unsigned long zone; }; -static int __meminit +static int virtual_memmap_init (u64 start, u64 end, void *arg) { struct memmap_init_callback_data *args; @@ -503,7 +503,7 @@ virtual_memmap_init (u64 start, u64 end, void *arg) return 0; } -void __meminit +void memmap_init (unsigned long size, int nid, unsigned long zone, unsigned long start_pfn) { diff --git a/trunk/arch/ia64/scripts/check-segrel.lds b/trunk/arch/ia64/scripts/check-segrel.lds index 85a0d54fb5ab..1c2f13e181d0 100644 --- a/trunk/arch/ia64/scripts/check-segrel.lds +++ b/trunk/arch/ia64/scripts/check-segrel.lds @@ -1,7 +1,6 @@ SECTIONS { . = SIZEOF_HEADERS; .rodata : { *(.rodata) } :ro - .note : { *(.note*) } . = 0xa0000; .data : { *(.data) } :dat /DISCARD/ : { *(*) } diff --git a/trunk/arch/ia64/sn/kernel/mca.c b/trunk/arch/ia64/sn/kernel/mca.c index 868c9aa64fe2..3db62f24596c 100644 --- a/trunk/arch/ia64/sn/kernel/mca.c +++ b/trunk/arch/ia64/sn/kernel/mca.c @@ -98,7 +98,6 @@ sn_platform_plat_specific_err_print(const u8 * sect_header, u8 ** oemdata, while (*sn_oemdata_size > sn_oemdata_bufsize) { u8 *newbuf = vmalloc(*sn_oemdata_size); if (!newbuf) { - mutex_unlock(&sn_oemdata_mutex); printk(KERN_ERR "%s: unable to extend sn_oemdata\n", __FUNCTION__); return 1; diff --git a/trunk/arch/m68k/kernel/dma.c b/trunk/arch/m68k/kernel/dma.c index 6f8c080dd9f9..ef490e1ce600 100644 --- a/trunk/arch/m68k/kernel/dma.c +++ b/trunk/arch/m68k/kernel/dma.c @@ -9,10 +9,10 @@ #include #include #include -#include #include #include +#include void *dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t flag) diff --git a/trunk/arch/m68knommu/kernel/setup.c b/trunk/arch/m68knommu/kernel/setup.c index 332345d7675d..74bf94948ec2 100644 --- a/trunk/arch/m68knommu/kernel/setup.c +++ b/trunk/arch/m68knommu/kernel/setup.c @@ -43,8 +43,11 @@ EXPORT_SYMBOL(memory_end); char __initdata command_line[COMMAND_LINE_SIZE]; /* machine dependent timer functions */ +void (*mach_sched_init)(irq_handler_t handler); +void (*mach_tick)(void); void (*mach_gettod)(int*, int*, int*, int*, int*, int*); int (*mach_set_clock_mmss)(unsigned long); +unsigned long (*mach_gettimeoffset)(void); /* machine dependent reboot functions */ void (*mach_reset)(void); @@ -113,7 +116,7 @@ void (*mach_power_off)(void); extern int _stext, _etext, _sdata, _edata, _sbss, _ebss, _end; extern int _ramstart, _ramend; -void __init setup_arch(char **cmdline_p) +void setup_arch(char **cmdline_p) { int bootmap_size; diff --git a/trunk/arch/m68knommu/mm/init.c b/trunk/arch/m68knommu/mm/init.c index 22e2a0d02b81..06e538d1be3a 100644 --- a/trunk/arch/m68knommu/mm/init.c +++ b/trunk/arch/m68knommu/mm/init.c @@ -98,7 +98,7 @@ extern unsigned long memory_end; * The parameters are pointers to where to stick the starting and ending * addresses of available kernel virtual memory. */ -void __init paging_init(void) +void paging_init(void) { /* * Make sure start_mem is page aligned, otherwise bootmem and @@ -147,7 +147,7 @@ void __init paging_init(void) } } -void __init mem_init(void) +void mem_init(void) { int codek = 0, datak = 0, initk = 0; unsigned long tmp; diff --git a/trunk/arch/m68knommu/platform/68328/config.c b/trunk/arch/m68knommu/platform/68328/config.c index a7bd21deb00f..e5c537d14dfb 100644 --- a/trunk/arch/m68knommu/platform/68328/config.c +++ b/trunk/arch/m68knommu/platform/68328/config.c @@ -15,14 +15,28 @@ /***************************************************************************/ +#include +#include #include #include +#include +#include +#include +#include +#include + +#include #include +#include +#include #include #include /***************************************************************************/ +void m68328_timer_init(irq_handler_t timer_routine); +void m68328_timer_tick(void); +unsigned long m68328_timer_gettimeoffset(void); void m68328_timer_gettod(int *year, int *mon, int *day, int *hour, int *min, int *sec); /***************************************************************************/ @@ -45,8 +59,14 @@ void config_BSP(char *command, int len) printk(KERN_INFO "68328 support Kenneth Albanowski \n"); printk(KERN_INFO "68328/Pilot support Bernhard Kuhn \n"); - mach_gettod = m68328_timer_gettod; - mach_reset = m68328_reset; + mach_sched_init = m68328_timer_init; + mach_tick = m68328_timer_tick; + mach_gettimeoffset = m68328_timer_gettimeoffset; + mach_gettod = m68328_timer_gettod; + mach_hwclk = NULL; + mach_set_clock_mmss = NULL; + mach_reset = m68328_reset; + *command = '\0'; } /***************************************************************************/ diff --git a/trunk/arch/m68knommu/platform/68328/timers.c b/trunk/arch/m68knommu/platform/68328/timers.c index 04cbc661d4bd..0396476f955d 100644 --- a/trunk/arch/m68knommu/platform/68328/timers.c +++ b/trunk/arch/m68knommu/platform/68328/timers.c @@ -53,28 +53,18 @@ /***************************************************************************/ -static irqreturn_t hw_tick(int irq, void *dummy) -{ - /* Reset Timer1 */ - TSTAT &= 0; - - return arch_timer_interrupt(irq, dummy); -} - -/***************************************************************************/ - static struct irqaction m68328_timer_irq = { - .name = "timer", - .flags = IRQF_DISABLED | IRQF_TIMER, - .handler = hw_tick, + .name = "timer", + .flags = IRQF_DISABLED | IRQF_TIMER, }; -void hw_timer_init(void) +void m68328_timer_init(irq_handler_t timer_routine) { /* disable timer 1 */ TCTL = 0; /* set ISR */ + m68328_timer_irq.handler = timer_routine; setup_irq(TMR_IRQ_NUM, &m68328_timer_irq); /* Restart mode, Enable int, Set clock source */ @@ -88,7 +78,14 @@ void hw_timer_init(void) /***************************************************************************/ -unsigned long hw_timer_offset(void) +void m68328_timer_tick(void) +{ + /* Reset Timer1 */ + TSTAT &= 0; +} +/***************************************************************************/ + +unsigned long m68328_timer_gettimeoffset(void) { unsigned long ticks = TCN, offset = 0; diff --git a/trunk/arch/m68knommu/platform/68360/config.c b/trunk/arch/m68knommu/platform/68360/config.c index 2b3196af811f..155b72fe2607 100644 --- a/trunk/arch/m68knommu/platform/68360/config.c +++ b/trunk/arch/m68knommu/platform/68360/config.c @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include #include @@ -38,6 +40,8 @@ extern void m360_cpm_reset(void); unsigned long int system_clock; +void M68360_init_IRQ(void); + extern QUICC *pquicc; /* TODO DON"T Hard Code this */ @@ -45,24 +49,14 @@ extern QUICC *pquicc; // unsigned int system_clock = 33000000l; extern unsigned long int system_clock; //In kernel setup.c - -static irqreturn_t hw_tick(int irq, void *dummy) -{ - /* Reset Timer1 */ - /* TSTAT &= 0; */ - - pquicc->timer_ter1 = 0x0002; /* clear timer event */ - - return arch_timer_interrupt(irq, dummy); -} +extern void config_M68360_irq(void); static struct irqaction m68360_timer_irq = { - .name = "timer", - .flags = IRQF_DISABLED | IRQF_TIMER, - .handler = hw_tick, + .name = "timer", + .flags = IRQF_DISABLED | IRQF_TIMER, }; -void hw_timer_init(void) +void BSP_sched_init(irq_handler_t timer_routine) { unsigned char prescaler; unsigned short tgcr_save; @@ -96,6 +90,7 @@ void hw_timer_init(void) pquicc->timer_ter1 = 0x0003; /* clear timer events */ /* enable timer 1 interrupt in CIMR */ + m68360_timer_irq.handler = timer_routine; setup_irq(CPMVEC_TIMER1, &m68360_timer_irq); /* Start timer 1: */ @@ -103,7 +98,16 @@ void hw_timer_init(void) pquicc->timer_tgcr = tgcr_save; } -unsigned long hw_timer_offset(void) + +void BSP_tick(void) +{ + /* Reset Timer1 */ + /* TSTAT &= 0; */ + + pquicc->timer_ter1 = 0x0002; /* clear timer event */ +} + +unsigned long BSP_gettimeoffset (void) { return 0; } @@ -113,7 +117,17 @@ void BSP_gettod (int *yearp, int *monp, int *dayp, { } -int BSP_set_clock_mmss(unsigned long nowtime) +int BSP_hwclk(int op, struct rtc_time *t) +{ + if (!op) { + /* read */ + } else { + /* write */ + } + return 0; +} + +int BSP_set_clock_mmss (unsigned long nowtime) { #if 0 short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60; @@ -186,6 +200,11 @@ void config_BSP(char *command, int len) scc1_hwaddr = "\00\01\02\03\04\05"; #endif + mach_sched_init = BSP_sched_init; + mach_tick = BSP_tick; + mach_gettimeoffset = BSP_gettimeoffset; mach_gettod = BSP_gettod; + mach_hwclk = NULL; + mach_set_clock_mmss = NULL; mach_reset = BSP_reset; } diff --git a/trunk/arch/m68knommu/platform/68EZ328/config.c b/trunk/arch/m68knommu/platform/68EZ328/config.c index 1be1a16f6896..ab36551fc969 100644 --- a/trunk/arch/m68knommu/platform/68EZ328/config.c +++ b/trunk/arch/m68knommu/platform/68EZ328/config.c @@ -13,8 +13,15 @@ /***************************************************************************/ +#include #include #include +#include +#include +#include +#include + +#include #include #include #include @@ -25,6 +32,9 @@ /***************************************************************************/ +void m68328_timer_init(irq_handler_t timer_routine); +void m68328_timer_tick(void); +unsigned long m68328_timer_gettimeoffset(void); void m68328_timer_gettod(int *year, int *mon, int *day, int *hour, int *min, int *sec); /***************************************************************************/ @@ -69,8 +79,13 @@ void config_BSP(char *command, int len) else command[0] = 0; #endif - mach_gettod = m68328_timer_gettod; - mach_reset = m68ez328_reset; + mach_sched_init = m68328_timer_init; + mach_tick = m68328_timer_tick; + mach_gettimeoffset = m68328_timer_gettimeoffset; + mach_gettod = m68328_timer_gettod; + mach_hwclk = NULL; + mach_set_clock_mmss = NULL; + mach_reset = m68ez328_reset; } /***************************************************************************/ diff --git a/trunk/arch/m68knommu/platform/68VZ328/config.c b/trunk/arch/m68knommu/platform/68VZ328/config.c index fc5c63054e98..79dced929c97 100644 --- a/trunk/arch/m68knommu/platform/68VZ328/config.c +++ b/trunk/arch/m68knommu/platform/68VZ328/config.c @@ -16,13 +16,17 @@ #include #include +#include +#include +#include #include #include #include -#include +#include #include #include +#include #include #include #include @@ -33,6 +37,9 @@ /***************************************************************************/ +void m68328_timer_init(irq_handler_t timer_routine); +void m68328_timer_tick(void); +unsigned long m68328_timer_gettimeoffset(void); void m68328_timer_gettod(int *year, int *mon, int *day, int *hour, int *min, int *sec); /***************************************************************************/ @@ -186,6 +193,9 @@ void config_BSP(char *command, int size) init_hardware(command, size); + mach_sched_init = (void *) m68328_timer_init; + mach_tick = m68328_timer_tick; + mach_gettimeoffset = m68328_timer_gettimeoffset; mach_gettod = m68328_timer_gettod; mach_reset = m68vz328_reset; } diff --git a/trunk/arch/mips/Kconfig b/trunk/arch/mips/Kconfig index 97da953eb5d0..61262c5f9c62 100644 --- a/trunk/arch/mips/Kconfig +++ b/trunk/arch/mips/Kconfig @@ -583,7 +583,6 @@ config SNI_RM config TOSHIBA_JMR3927 bool "Toshiba JMR-TX3927 board" - select CEVT_TXX9 select DMA_NONCOHERENT select HW_HAS_PCI select MIPS_TX3927 @@ -598,7 +597,6 @@ config TOSHIBA_JMR3927 config TOSHIBA_RBTX4927 bool "Toshiba RBTX49[23]7 board" select CEVT_R4K - select CEVT_TXX9 select DMA_NONCOHERENT select HAS_TXX9_SERIAL select HW_HAS_PCI @@ -620,7 +618,6 @@ config TOSHIBA_RBTX4927 config TOSHIBA_RBTX4938 bool "Toshiba RBTX4938 board" select CEVT_R4K - select CEVT_TXX9 select DMA_NONCOHERENT select HAS_TXX9_SERIAL select HW_HAS_PCI @@ -739,9 +736,6 @@ config CEVT_GT641XX config CEVT_R4K bool -config CEVT_TXX9 - bool - config CFE bool diff --git a/trunk/arch/mips/au1000/common/irq.c b/trunk/arch/mips/au1000/common/irq.c index ddfb7f0a17a6..59e932a928d2 100644 --- a/trunk/arch/mips/au1000/common/irq.c +++ b/trunk/arch/mips/au1000/common/irq.c @@ -318,6 +318,38 @@ static struct irq_chip level_irq_type = { .end = end_irq, }; +#ifdef CONFIG_PM +void startup_match20_interrupt(irq_handler_t handler) +{ + struct irq_desc *desc = &irq_desc[AU1000_TOY_MATCH2_INT]; + + static struct irqaction action; + memset(&action, 0, sizeof(struct irqaction)); + + /* + * This is a big problem.... since we didn't use request_irq + * when kernel/irq.c calls probe_irq_xxx this interrupt will + * be probed for usage. This will end up disabling the device :( + * Give it a bogus "action" pointer -- this will keep it from + * getting auto-probed! + * + * By setting the status to match that of request_irq() we + * can avoid it. --cgray + */ + action.dev_id = handler; + action.flags = IRQF_DISABLED; + cpus_clear(action.mask); + action.name = "Au1xxx TOY"; + action.handler = handler; + action.next = NULL; + + desc->action = &action; + desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT | IRQ_WAITING | IRQ_INPROGRESS); + + local_enable_irq(AU1000_TOY_MATCH2_INT); +} +#endif + static void __init setup_local_irq(unsigned int irq_nr, int type, int int_req) { unsigned int bit = irq_nr - AU1000_INTC0_INT_BASE; diff --git a/trunk/arch/mips/au1000/common/time.c b/trunk/arch/mips/au1000/common/time.c index f113b512d7b1..2556399708ba 100644 --- a/trunk/arch/mips/au1000/common/time.c +++ b/trunk/arch/mips/au1000/common/time.c @@ -67,7 +67,7 @@ static DEFINE_SPINLOCK(time_lock); unsigned long wtimer; #ifdef CONFIG_PM -static irqreturn_t counter0_irq(int irq, void *dev_id) +irqreturn_t counter0_irq(int irq, void *dev_id) { unsigned long pc0; int time_elapsed; @@ -117,13 +117,6 @@ static irqreturn_t counter0_irq(int irq, void *dev_id) return IRQ_HANDLED; } -struct irqaction counter0_action = { - .handler = counter0_irq, - .flags = IRQF_DISABLED, - .name = "alchemy-toy", - .dev_id = NULL, -}; - /* When we wakeup from sleep, we have to "catch up" on all of the * timer ticks we have missed. */ @@ -228,7 +221,7 @@ unsigned long cal_r4koff(void) return (cpu_speed / HZ); } -void __init plat_time_init(void) +void __init plat_timer_setup(struct irqaction *irq) { unsigned int est_freq; @@ -262,10 +255,15 @@ void __init plat_time_init(void) * we do this. */ if (no_au1xxx_32khz) { + unsigned int c0_status; + printk("WARNING: no 32KHz clock found.\n"); - /* Ensure we get CPO_COUNTER interrupts. */ - set_c0_status(IE_IRQ5); + /* Ensure we get CPO_COUNTER interrupts. + */ + c0_status = read_c0_status(); + c0_status |= IE_IRQ5; + write_c0_status(c0_status); } else { while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C0S); @@ -282,7 +280,7 @@ void __init plat_time_init(void) au_writel(last_match20 + MATCH20_INC, SYS_TOYMATCH2); au_sync(); while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20); - setup_irq(AU1000_TOY_MATCH2_INT, &counter0_action); + startup_match20_interrupt(counter0_irq); /* We can use the real 'wait' instruction. */ diff --git a/trunk/arch/mips/au1000/mtx-1/Makefile b/trunk/arch/mips/au1000/mtx-1/Makefile index afa7007d67f7..764bf9f7e281 100644 --- a/trunk/arch/mips/au1000/mtx-1/Makefile +++ b/trunk/arch/mips/au1000/mtx-1/Makefile @@ -8,4 +8,3 @@ # lib-y := init.o board_setup.o irqmap.o -obj-y := platform.o diff --git a/trunk/arch/mips/au1000/mtx-1/platform.c b/trunk/arch/mips/au1000/mtx-1/platform.c deleted file mode 100644 index 01ebff677978..000000000000 --- a/trunk/arch/mips/au1000/mtx-1/platform.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * MTX-1 platform devices registration - * - * Copyright (C) 2007, Florian Fainelli - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include - -#include - -static struct resource mtx1_wdt_res[] = { - [0] = { - .start = 15, - .end = 15, - .name = "mtx1-wdt-gpio", - .flags = IORESOURCE_IRQ, - } -}; - -static struct resource mtx1_sys_btn[] = { - [0] = { - .start = 7, - .end = 7, - .name = "mtx1-sys-btn-gpio", - .flags = IORESOURCE_IRQ, - } -}; - -static struct platform_device mtx1_wdt = { - .name = "mtx1-wdt", - .id = 0, - .num_resources = ARRAY_SIZE(mtx1_wdt_res), - .resource = mtx1_wdt_res, -}; - -static struct gpio_led default_leds[] = { - { - .name = "mtx1:green", - .gpio = 211, - }, { - .name = "mtx1:red", - .gpio = 212, - }, -}; - -static struct gpio_led_platform_data mtx1_led_data = { - .num_leds = ARRAY_SIZE(default_leds), - .leds = default_leds, -}; - -static struct platform_device mtx1_gpio_leds = { - .name = "leds-gpio", - .id = -1, - .dev = { - .platform_data = &mtx1_led_data, - } -}; - -static struct __initdata platform_device * mtx1_devs[] = { - &mtx1_gpio_leds, - &mtx1_wdt -}; - -static int __init mtx1_register_devices(void) -{ - return platform_add_devices(mtx1_devs, ARRAY_SIZE(mtx1_devs)); -} - -arch_initcall(mtx1_register_devices); diff --git a/trunk/arch/mips/basler/excite/excite_setup.c b/trunk/arch/mips/basler/excite/excite_setup.c index 24378b9223f9..404ca9284b30 100644 --- a/trunk/arch/mips/basler/excite/excite_setup.c +++ b/trunk/arch/mips/basler/excite/excite_setup.c @@ -68,23 +68,24 @@ DEFINE_SPINLOCK(titan_lock); int titan_irqflags; -/* - * The eXcite platform uses the alternate timer interrupt - * - * Fixme: At the time of this writing cevt-r4k.c doesn't yet know about how - * to handle the alternate timer interrupt of the RM9000. - */ void __init plat_time_init(void) { const u32 modebit5 = ocd_readl(0x00e4); - unsigned int mult = ((modebit5 >> 11) & 0x1f) + 2, - unsigned int div = ((modebit5 >> 16) & 0x1f) + 2; + unsigned int + mult = ((modebit5 >> 11) & 0x1f) + 2, + div = ((modebit5 >> 16) & 0x1f) + 2; - if (div == 33) - div = 1; + if (div == 33) div = 1; mips_hpt_frequency = EXCITE_CPU_EXT_CLOCK * mult / div / 2; } +void __init plat_timer_setup(struct irqaction *irq) +{ + /* The eXcite platform uses the alternate timer interrupt */ + set_c0_intcontrol(0x80); + setup_irq(TIMER_IRQ, irq); +} + static int __init excite_init_console(void) { #if defined(CONFIG_SERIAL_8250) diff --git a/trunk/arch/mips/configs/db1000_defconfig b/trunk/arch/mips/configs/db1000_defconfig index 5a8b7acb7dd7..885b633647e9 100644 --- a/trunk/arch/mips/configs/db1000_defconfig +++ b/trunk/arch/mips/configs/db1000_defconfig @@ -738,6 +738,7 @@ CONFIG_HW_CONSOLE=y CONFIG_VT_HW_CONSOLE_BINDING=y # CONFIG_SERIAL_NONSTANDARD is not set # CONFIG_AU1X00_GPIO is not set +# CONFIG_TS_AU1X00_ADS7846 is not set # # Serial drivers diff --git a/trunk/arch/mips/configs/db1100_defconfig b/trunk/arch/mips/configs/db1100_defconfig index d4ed90bca269..e3c3a07e8a7c 100644 --- a/trunk/arch/mips/configs/db1100_defconfig +++ b/trunk/arch/mips/configs/db1100_defconfig @@ -714,6 +714,7 @@ CONFIG_HW_CONSOLE=y CONFIG_VT_HW_CONSOLE_BINDING=y # CONFIG_SERIAL_NONSTANDARD is not set # CONFIG_AU1X00_GPIO is not set +# CONFIG_TS_AU1X00_ADS7846 is not set # # Serial drivers diff --git a/trunk/arch/mips/configs/db1200_defconfig b/trunk/arch/mips/configs/db1200_defconfig index a055657e6983..9aa7c3ebfa3f 100644 --- a/trunk/arch/mips/configs/db1200_defconfig +++ b/trunk/arch/mips/configs/db1200_defconfig @@ -775,6 +775,7 @@ CONFIG_HW_CONSOLE=y CONFIG_VT_HW_CONSOLE_BINDING=y # CONFIG_SERIAL_NONSTANDARD is not set # CONFIG_AU1X00_GPIO is not set +# CONFIG_TS_AU1X00_ADS7846 is not set # # Serial drivers diff --git a/trunk/arch/mips/configs/db1500_defconfig b/trunk/arch/mips/configs/db1500_defconfig index 0ad08cf446ec..99240668bca1 100644 --- a/trunk/arch/mips/configs/db1500_defconfig +++ b/trunk/arch/mips/configs/db1500_defconfig @@ -811,6 +811,7 @@ CONFIG_SERIO_RAW=m # CONFIG_VT is not set # CONFIG_SERIAL_NONSTANDARD is not set # CONFIG_AU1X00_GPIO is not set +# CONFIG_TS_AU1X00_ADS7846 is not set # # Serial drivers diff --git a/trunk/arch/mips/configs/db1550_defconfig b/trunk/arch/mips/configs/db1550_defconfig index 057c7d429c80..19992f76c60d 100644 --- a/trunk/arch/mips/configs/db1550_defconfig +++ b/trunk/arch/mips/configs/db1550_defconfig @@ -856,6 +856,7 @@ CONFIG_SERIO_RAW=m # CONFIG_VT is not set # CONFIG_SERIAL_NONSTANDARD is not set # CONFIG_AU1X00_GPIO is not set +# CONFIG_TS_AU1X00_ADS7846 is not set # # Serial drivers diff --git a/trunk/arch/mips/configs/pb1100_defconfig b/trunk/arch/mips/configs/pb1100_defconfig index 703d28db05b9..d53fa8f8e099 100644 --- a/trunk/arch/mips/configs/pb1100_defconfig +++ b/trunk/arch/mips/configs/pb1100_defconfig @@ -731,6 +731,7 @@ CONFIG_HW_CONSOLE=y CONFIG_VT_HW_CONSOLE_BINDING=y # CONFIG_SERIAL_NONSTANDARD is not set # CONFIG_AU1X00_GPIO is not set +# CONFIG_TS_AU1X00_ADS7846 is not set # # Serial drivers diff --git a/trunk/arch/mips/configs/pb1500_defconfig b/trunk/arch/mips/configs/pb1500_defconfig index 82f0c5cee0dc..dc4aa0c66847 100644 --- a/trunk/arch/mips/configs/pb1500_defconfig +++ b/trunk/arch/mips/configs/pb1500_defconfig @@ -849,6 +849,7 @@ CONFIG_SERIO_RAW=m # CONFIG_VT is not set # CONFIG_SERIAL_NONSTANDARD is not set # CONFIG_AU1X00_GPIO is not set +# CONFIG_TS_AU1X00_ADS7846 is not set # # Serial drivers diff --git a/trunk/arch/mips/configs/pb1550_defconfig b/trunk/arch/mips/configs/pb1550_defconfig index 147a4fc7fdd8..24428e13002b 100644 --- a/trunk/arch/mips/configs/pb1550_defconfig +++ b/trunk/arch/mips/configs/pb1550_defconfig @@ -842,6 +842,7 @@ CONFIG_SERIO_RAW=m # CONFIG_VT is not set # CONFIG_SERIAL_NONSTANDARD is not set # CONFIG_AU1X00_GPIO is not set +# CONFIG_TS_AU1X00_ADS7846 is not set # # Serial drivers diff --git a/trunk/arch/mips/configs/sb1250-swarm_defconfig b/trunk/arch/mips/configs/sb1250-swarm_defconfig index c2798229cbfb..49dfcef2518c 100644 --- a/trunk/arch/mips/configs/sb1250-swarm_defconfig +++ b/trunk/arch/mips/configs/sb1250-swarm_defconfig @@ -468,7 +468,7 @@ CONFIG_BLK_DEV_IDEFLOPPY=y # CONFIG_IDE_GENERIC=y # CONFIG_BLK_DEV_IDEPCI is not set -CONFIG_BLK_DEV_IDE_SWARM=y +# CONFIG_BLK_DEV_IDE_SWARM is not set # CONFIG_IDE_ARM is not set # CONFIG_BLK_DEV_IDEDMA is not set # CONFIG_IDEDMA_AUTO is not set diff --git a/trunk/arch/mips/gt64120/wrppmc/time.c b/trunk/arch/mips/gt64120/wrppmc/time.c index 668dbd5f12c5..b207e7f1417a 100644 --- a/trunk/arch/mips/gt64120/wrppmc/time.c +++ b/trunk/arch/mips/gt64120/wrppmc/time.c @@ -19,6 +19,12 @@ #define WRPPMC_CPU_CLK_FREQ 40000000 /* 40MHZ */ +void __init plat_timer_setup(struct irqaction *irq) +{ + /* Install ISR for timer interrupt */ + setup_irq(WRPPMC_MIPS_TIMER_IRQ, irq); +} + /* * Estimate CPU frequency. Sets mips_hpt_frequency as a side-effect * diff --git a/trunk/arch/mips/jmr3927/rbhma3100/setup.c b/trunk/arch/mips/jmr3927/rbhma3100/setup.c index 06e01c8f4e3a..edb9e59248ec 100644 --- a/trunk/arch/mips/jmr3927/rbhma3100/setup.c +++ b/trunk/arch/mips/jmr3927/rbhma3100/setup.c @@ -27,13 +27,17 @@ * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org) */ +#include #include #include #include #include +#include #include #include +#include #include +#include /* for HZ */ #include #include #include @@ -44,13 +48,17 @@ #endif #include -#include +#include #include #include #include extern void puts(const char *cp); +/* Tick Timer divider */ +#define JMR3927_TIMER_CCD 0 /* 1/2 */ +#define JMR3927_TIMER_CLK (JMR3927_IMCLK / (2 << JMR3927_TIMER_CCD)) + /* don't enable - see errata */ static int jmr3927_ccfg_toeon; @@ -85,12 +93,66 @@ static void jmr3927_machine_power_off(void) while (1); } +static cycle_t jmr3927_hpt_read(void) +{ + /* We assume this function is called xtime_lock held. */ + return jiffies * (JMR3927_TIMER_CLK / HZ) + jmr3927_tmrptr->trr; +} + +static void jmr3927_set_mode(enum clock_event_mode mode, + struct clock_event_device *evt) +{ + /* Nothing to do here */ +} + +struct clock_event_device jmr3927_clock_event_device = { + .name = "MIPS", + .features = CLOCK_EVT_FEAT_PERIODIC, + .shift = 32, + .rating = 300, + .cpumask = CPU_MASK_CPU0, + .irq = JMR3927_IRQ_TICK, + .set_mode = jmr3927_set_mode, +}; + +static irqreturn_t jmr3927_timer_interrupt(int irq, void *dev_id) +{ + struct clock_event_device *cd = &jmr3927_clock_event_device; + + jmr3927_tmrptr->tisr = 0; /* ack interrupt */ + + cd->event_handler(cd); + + return IRQ_HANDLED; +} + +static struct irqaction jmr3927_timer_irqaction = { + .handler = jmr3927_timer_interrupt, + .flags = IRQF_DISABLED | IRQF_PERCPU, + .name = "jmr3927-timer", +}; + void __init plat_time_init(void) { - txx9_clockevent_init(TX3927_TMR_REG(0), - TXX9_IRQ_BASE + JMR3927_IRQ_IRC_TMR(0), - JMR3927_IMCLK); - txx9_clocksource_init(TX3927_TMR_REG(1), JMR3927_IMCLK); + struct clock_event_device *cd; + + clocksource_mips.read = jmr3927_hpt_read; + mips_hpt_frequency = JMR3927_TIMER_CLK; + + jmr3927_tmrptr->cpra = JMR3927_TIMER_CLK / HZ; + jmr3927_tmrptr->itmr = TXx927_TMTITMR_TIIE | TXx927_TMTITMR_TZCE; + jmr3927_tmrptr->ccdr = JMR3927_TIMER_CCD; + jmr3927_tmrptr->tcr = + TXx927_TMTCR_TCE | TXx927_TMTCR_CCDE | TXx927_TMTCR_TMODE_ITVL; + + cd = &jmr3927_clock_event_device; + /* Calculate the min / max delta */ + cd->mult = div_sc((unsigned long) JMR3927_IMCLK, NSEC_PER_SEC, 32); + cd->max_delta_ns = clockevent_delta2ns(0x7fffffff, cd); + cd->min_delta_ns = clockevent_delta2ns(0x300, cd); + clockevents_register_device(cd); + + setup_irq(JMR3927_IRQ_TICK, &jmr3927_timer_irqaction); } #define DO_WRITE_THROUGH @@ -255,8 +317,15 @@ static void __init tx3927_setup(void) tx3927_ccfgptr->ccfg, tx3927_ccfgptr->pcfg); /* TMR */ - for (i = 0; i < TX3927_NR_TMR; i++) - txx9_tmr_init(TX3927_TMR_REG(i)); + /* disable all timers */ + for (i = 0; i < TX3927_NR_TMR; i++) { + tx3927_tmrptr(i)->tcr = TXx927_TMTCR_CRE; + tx3927_tmrptr(i)->tisr = 0; + tx3927_tmrptr(i)->cpra = 0xffffffff; + tx3927_tmrptr(i)->itmr = 0; + tx3927_tmrptr(i)->ccdr = 0; + tx3927_tmrptr(i)->pgmr = 0; + } /* DMA */ tx3927_dmaptr->mcr = 0; diff --git a/trunk/arch/mips/kernel/Makefile b/trunk/arch/mips/kernel/Makefile index 3196509a28d5..d7745c8976f6 100644 --- a/trunk/arch/mips/kernel/Makefile +++ b/trunk/arch/mips/kernel/Makefile @@ -10,7 +10,6 @@ obj-y += cpu-probe.o branch.o entry.o genex.o irq.o process.o \ obj-$(CONFIG_CEVT_R4K) += cevt-r4k.o obj-$(CONFIG_CEVT_GT641XX) += cevt-gt641xx.o -obj-$(CONFIG_CEVT_TXX9) += cevt-txx9.o binfmt_irix-objs := irixelf.o irixinv.o irixioctl.o irixsig.o \ irix5sys.o sysirix.o diff --git a/trunk/arch/mips/kernel/cevt-gt641xx.c b/trunk/arch/mips/kernel/cevt-gt641xx.c index c36772631fe0..4c651b2680f9 100644 --- a/trunk/arch/mips/kernel/cevt-gt641xx.c +++ b/trunk/arch/mips/kernel/cevt-gt641xx.c @@ -49,9 +49,10 @@ int gt641xx_timer0_state(void) static int gt641xx_timer0_set_next_event(unsigned long delta, struct clock_event_device *evt) { + unsigned long flags; u32 ctrl; - spin_lock(>641xx_timer_lock); + spin_lock_irqsave(>641xx_timer_lock, flags); ctrl = GT_READ(GT_TC_CONTROL_OFS); ctrl &= ~(GT_TC_CONTROL_ENTC0_MSK | GT_TC_CONTROL_SELTC0_MSK); @@ -60,7 +61,7 @@ static int gt641xx_timer0_set_next_event(unsigned long delta, GT_WRITE(GT_TC0_OFS, delta); GT_WRITE(GT_TC_CONTROL_OFS, ctrl); - spin_unlock(>641xx_timer_lock); + spin_unlock_irqrestore(>641xx_timer_lock, flags); return 0; } @@ -68,9 +69,10 @@ static int gt641xx_timer0_set_next_event(unsigned long delta, static void gt641xx_timer0_set_mode(enum clock_event_mode mode, struct clock_event_device *evt) { + unsigned long flags; u32 ctrl; - spin_lock(>641xx_timer_lock); + spin_lock_irqsave(>641xx_timer_lock, flags); ctrl = GT_READ(GT_TC_CONTROL_OFS); ctrl &= ~(GT_TC_CONTROL_ENTC0_MSK | GT_TC_CONTROL_SELTC0_MSK); @@ -88,7 +90,7 @@ static void gt641xx_timer0_set_mode(enum clock_event_mode mode, GT_WRITE(GT_TC_CONTROL_OFS, ctrl); - spin_unlock(>641xx_timer_lock); + spin_unlock_irqrestore(>641xx_timer_lock, flags); } static void gt641xx_timer0_event_handler(struct clock_event_device *dev) @@ -131,9 +133,9 @@ static int __init gt641xx_timer0_clockevent_init(void) cd = >641xx_timer0_clockevent; cd->rating = 200 + gt641xx_base_clock / 10000000; - clockevent_set_clock(cd, gt641xx_base_clock); cd->max_delta_ns = clockevent_delta2ns(0x7fffffff, cd); cd->min_delta_ns = clockevent_delta2ns(0x300, cd); + clockevent_set_clock(cd, gt641xx_base_clock); clockevents_register_device(>641xx_timer0_clockevent); diff --git a/trunk/arch/mips/kernel/cevt-r4k.c b/trunk/arch/mips/kernel/cevt-r4k.c index bab935a3d74b..ae2984fff580 100644 --- a/trunk/arch/mips/kernel/cevt-r4k.c +++ b/trunk/arch/mips/kernel/cevt-r4k.c @@ -28,7 +28,7 @@ static int mips_next_event(unsigned long delta, cnt = read_c0_count(); cnt += delta; write_c0_compare(cnt); - res = ((int)(read_c0_count() - cnt) > 0) ? -ETIME : 0; + res = ((long)(read_c0_count() - cnt ) > 0) ? -ETIME : 0; #ifdef CONFIG_MIPS_MT_SMTC evpe(vpflags); local_irq_restore(flags); @@ -179,7 +179,7 @@ static int c0_compare_int_pending(void) static int c0_compare_int_usable(void) { - unsigned int delta; + const unsigned int delta = 0x300000; unsigned int cnt; /* @@ -192,17 +192,11 @@ static int c0_compare_int_usable(void) return 0; } - for (delta = 0x10; delta <= 0x400000; delta <<= 1) { - cnt = read_c0_count(); - cnt += delta; - write_c0_compare(cnt); - irq_disable_hazard(); - if ((int)(read_c0_count() - cnt) < 0) - break; - /* increase delta if the timer was already expired */ - } + cnt = read_c0_count(); + cnt += delta; + write_c0_compare(cnt); - while ((int)(read_c0_count() - cnt) <= 0) + while ((long)(read_c0_count() - cnt) <= 0) ; /* Wait for expiry */ if (!c0_compare_int_pending()) @@ -224,9 +218,9 @@ void __cpuinit mips_clockevent_init(void) uint64_t mips_freq = mips_hpt_frequency; unsigned int cpu = smp_processor_id(); struct clock_event_device *cd; - unsigned int irq; + unsigned int irq = MIPS_CPU_IRQ_BASE + 7; - if (!cpu_has_counter || !mips_hpt_frequency) + if (!cpu_has_counter) return; #ifdef CONFIG_MIPS_MT_SMTC @@ -243,15 +237,6 @@ void __cpuinit mips_clockevent_init(void) if (!c0_compare_int_usable()) return; - /* - * With vectored interrupts things are getting platform specific. - * get_c0_compare_int is a hook to allow a platform to return the - * interrupt number of it's liking. - */ - irq = MIPS_CPU_IRQ_BASE + cp0_compare_irq; - if (get_c0_compare_int) - irq = get_c0_compare_int(); - cd = &per_cpu(mips_clockevent_device, cpu); cd->name = "MIPS"; @@ -276,15 +261,13 @@ void __cpuinit mips_clockevent_init(void) clockevents_register_device(cd); - if (!cp0_timer_irq_installed) - return; - - cp0_timer_irq_installed = 1; - + if (!cp0_timer_irq_installed) { #ifdef CONFIG_MIPS_MT_SMTC #define CPUCTR_IMASKBIT (0x100 << cp0_compare_irq) - setup_irq_smtc(irq, &c0_compare_irqaction, CPUCTR_IMASKBIT); + setup_irq_smtc(irq, &c0_compare_irqaction, CPUCTR_IMASKBIT); #else - setup_irq(irq, &c0_compare_irqaction); -#endif + setup_irq(irq, &c0_compare_irqaction); +#endif /* CONFIG_MIPS_MT_SMTC */ + cp0_timer_irq_installed = 1; + } } diff --git a/trunk/arch/mips/kernel/cevt-txx9.c b/trunk/arch/mips/kernel/cevt-txx9.c deleted file mode 100644 index 795cb8fb0d74..000000000000 --- a/trunk/arch/mips/kernel/cevt-txx9.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file "COPYING" in the main directory of this archive - * for more details. - * - * Based on linux/arch/mips/kernel/cevt-r4k.c, - * linux/arch/mips/jmr3927/rbhma3100/setup.c - * - * Copyright 2001 MontaVista Software Inc. - * Copyright (C) 2000-2001 Toshiba Corporation - * Copyright (C) 2007 MIPS Technologies, Inc. - * Copyright (C) 2007 Ralf Baechle - */ -#include -#include -#include -#include - -#define TCR_BASE (TXx9_TMTCR_CCDE | TXx9_TMTCR_CRE | TXx9_TMTCR_TMODE_ITVL) -#define TIMER_CCD 0 /* 1/2 */ -#define TIMER_CLK(imclk) ((imclk) / (2 << TIMER_CCD)) - -static struct txx9_tmr_reg __iomem *txx9_cs_tmrptr; - -static cycle_t txx9_cs_read(void) -{ - return __raw_readl(&txx9_cs_tmrptr->trr); -} - -/* Use 1 bit smaller width to use full bits in that width */ -#define TXX9_CLOCKSOURCE_BITS (TXX9_TIMER_BITS - 1) - -static struct clocksource txx9_clocksource = { - .name = "TXx9", - .rating = 200, - .read = txx9_cs_read, - .mask = CLOCKSOURCE_MASK(TXX9_CLOCKSOURCE_BITS), - .flags = CLOCK_SOURCE_IS_CONTINUOUS, -}; - -void __init txx9_clocksource_init(unsigned long baseaddr, - unsigned int imbusclk) -{ - struct txx9_tmr_reg __iomem *tmrptr; - - clocksource_set_clock(&txx9_clocksource, TIMER_CLK(imbusclk)); - clocksource_register(&txx9_clocksource); - - tmrptr = ioremap(baseaddr, sizeof(struct txx9_tmr_reg)); - __raw_writel(TCR_BASE, &tmrptr->tcr); - __raw_writel(0, &tmrptr->tisr); - __raw_writel(TIMER_CCD, &tmrptr->ccdr); - __raw_writel(TXx9_TMITMR_TZCE, &tmrptr->itmr); - __raw_writel(1 << TXX9_CLOCKSOURCE_BITS, &tmrptr->cpra); - __raw_writel(TCR_BASE | TXx9_TMTCR_TCE, &tmrptr->tcr); - txx9_cs_tmrptr = tmrptr; -} - -static struct txx9_tmr_reg __iomem *txx9_tmrptr; - -static void txx9tmr_stop_and_clear(struct txx9_tmr_reg __iomem *tmrptr) -{ - /* stop and reset counter */ - __raw_writel(TCR_BASE, &tmrptr->tcr); - /* clear pending interrupt */ - __raw_writel(0, &tmrptr->tisr); -} - -static void txx9tmr_set_mode(enum clock_event_mode mode, - struct clock_event_device *evt) -{ - struct txx9_tmr_reg __iomem *tmrptr = txx9_tmrptr; - - txx9tmr_stop_and_clear(tmrptr); - switch (mode) { - case CLOCK_EVT_MODE_PERIODIC: - __raw_writel(TXx9_TMITMR_TIIE | TXx9_TMITMR_TZCE, - &tmrptr->itmr); - /* start timer */ - __raw_writel(((u64)(NSEC_PER_SEC / HZ) * evt->mult) >> - evt->shift, - &tmrptr->cpra); - __raw_writel(TCR_BASE | TXx9_TMTCR_TCE, &tmrptr->tcr); - break; - case CLOCK_EVT_MODE_SHUTDOWN: - case CLOCK_EVT_MODE_UNUSED: - __raw_writel(0, &tmrptr->itmr); - break; - case CLOCK_EVT_MODE_ONESHOT: - __raw_writel(TXx9_TMITMR_TIIE, &tmrptr->itmr); - break; - case CLOCK_EVT_MODE_RESUME: - __raw_writel(TIMER_CCD, &tmrptr->ccdr); - __raw_writel(0, &tmrptr->itmr); - break; - } -} - -static int txx9tmr_set_next_event(unsigned long delta, - struct clock_event_device *evt) -{ - struct txx9_tmr_reg __iomem *tmrptr = txx9_tmrptr; - - txx9tmr_stop_and_clear(tmrptr); - /* start timer */ - __raw_writel(delta, &tmrptr->cpra); - __raw_writel(TCR_BASE | TXx9_TMTCR_TCE, &tmrptr->tcr); - return 0; -} - -static struct clock_event_device txx9tmr_clock_event_device = { - .name = "TXx9", - .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, - .rating = 200, - .cpumask = CPU_MASK_CPU0, - .set_mode = txx9tmr_set_mode, - .set_next_event = txx9tmr_set_next_event, -}; - -static irqreturn_t txx9tmr_interrupt(int irq, void *dev_id) -{ - struct clock_event_device *cd = &txx9tmr_clock_event_device; - struct txx9_tmr_reg __iomem *tmrptr = txx9_tmrptr; - - __raw_writel(0, &tmrptr->tisr); /* ack interrupt */ - cd->event_handler(cd); - return IRQ_HANDLED; -} - -static struct irqaction txx9tmr_irq = { - .handler = txx9tmr_interrupt, - .flags = IRQF_DISABLED | IRQF_PERCPU, - .name = "txx9tmr", -}; - -void __init txx9_clockevent_init(unsigned long baseaddr, int irq, - unsigned int imbusclk) -{ - struct clock_event_device *cd = &txx9tmr_clock_event_device; - struct txx9_tmr_reg __iomem *tmrptr; - - tmrptr = ioremap(baseaddr, sizeof(struct txx9_tmr_reg)); - txx9tmr_stop_and_clear(tmrptr); - __raw_writel(TIMER_CCD, &tmrptr->ccdr); - __raw_writel(0, &tmrptr->itmr); - txx9_tmrptr = tmrptr; - - clockevent_set_clock(cd, TIMER_CLK(imbusclk)); - cd->max_delta_ns = - clockevent_delta2ns(0xffffffff >> (32 - TXX9_TIMER_BITS), cd); - cd->min_delta_ns = clockevent_delta2ns(0xf, cd); - cd->irq = irq; - clockevents_register_device(cd); - setup_irq(irq, &txx9tmr_irq); - printk(KERN_INFO "TXx9: clockevent device at 0x%lx, irq %d\n", - baseaddr, irq); -} - -void __init txx9_tmr_init(unsigned long baseaddr) -{ - struct txx9_tmr_reg __iomem *tmrptr; - - tmrptr = ioremap(baseaddr, sizeof(struct txx9_tmr_reg)); - __raw_writel(TXx9_TMTCR_CRE, &tmrptr->tcr); - __raw_writel(0, &tmrptr->tisr); - __raw_writel(0xffffffff, &tmrptr->cpra); - __raw_writel(0, &tmrptr->itmr); - __raw_writel(0, &tmrptr->ccdr); - __raw_writel(0, &tmrptr->pgmr); - iounmap(tmrptr); -} diff --git a/trunk/arch/mips/kernel/irixsig.c b/trunk/arch/mips/kernel/irixsig.c index 33506ff25910..a0a91056fda7 100644 --- a/trunk/arch/mips/kernel/irixsig.c +++ b/trunk/arch/mips/kernel/irixsig.c @@ -24,12 +24,8 @@ #define _BLOCKABLE (~(_S(SIGKILL) | _S(SIGSTOP))) -#define _IRIX_NSIG 128 -#define _IRIX_NSIG_BPW BITS_PER_LONG -#define _IRIX_NSIG_WORDS (_IRIX_NSIG / _IRIX_NSIG_BPW) - typedef struct { - unsigned long sig[_IRIX_NSIG_WORDS]; + unsigned long sig[4]; } irix_sigset_t; struct sigctx_irix5 { @@ -531,7 +527,7 @@ asmlinkage int irix_sigpoll_sys(unsigned long __user *set, expire = schedule_timeout_interruptible(expire); - for (i=0; i < _IRIX_NSIG_WORDS; i++) + for (i=0; i<=4; i++) tmp |= (current->pending.signal.sig[i] & kset.sig[i]); if (tmp) diff --git a/trunk/arch/mips/kernel/ptrace.c b/trunk/arch/mips/kernel/ptrace.c index 35234b92b9a5..999f7853de26 100644 --- a/trunk/arch/mips/kernel/ptrace.c +++ b/trunk/arch/mips/kernel/ptrace.c @@ -65,13 +65,13 @@ int ptrace_getregs(struct task_struct *child, __s64 __user *data) regs = task_pt_regs(child); for (i = 0; i < 32; i++) - __put_user((long)regs->regs[i], data + i); - __put_user((long)regs->lo, data + EF_LO - EF_R0); - __put_user((long)regs->hi, data + EF_HI - EF_R0); - __put_user((long)regs->cp0_epc, data + EF_CP0_EPC - EF_R0); - __put_user((long)regs->cp0_badvaddr, data + EF_CP0_BADVADDR - EF_R0); - __put_user((long)regs->cp0_status, data + EF_CP0_STATUS - EF_R0); - __put_user((long)regs->cp0_cause, data + EF_CP0_CAUSE - EF_R0); + __put_user(regs->regs[i], data + i); + __put_user(regs->lo, data + EF_LO - EF_R0); + __put_user(regs->hi, data + EF_HI - EF_R0); + __put_user(regs->cp0_epc, data + EF_CP0_EPC - EF_R0); + __put_user(regs->cp0_badvaddr, data + EF_CP0_BADVADDR - EF_R0); + __put_user(regs->cp0_status, data + EF_CP0_STATUS - EF_R0); + __put_user(regs->cp0_cause, data + EF_CP0_CAUSE - EF_R0); return 0; } @@ -390,11 +390,11 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) } case PTRACE_GETREGS: - ret = ptrace_getregs(child, (__s64 __user *) data); + ret = ptrace_getregs(child, (__u64 __user *) data); break; case PTRACE_SETREGS: - ret = ptrace_setregs(child, (__s64 __user *) data); + ret = ptrace_setregs(child, (__u64 __user *) data); break; case PTRACE_GETFPREGS: diff --git a/trunk/arch/mips/kernel/ptrace32.c b/trunk/arch/mips/kernel/ptrace32.c index 76818be6ba7c..f2bffed94fa3 100644 --- a/trunk/arch/mips/kernel/ptrace32.c +++ b/trunk/arch/mips/kernel/ptrace32.c @@ -346,11 +346,11 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data) } case PTRACE_GETREGS: - ret = ptrace_getregs(child, (__s64 __user *) (__u64) data); + ret = ptrace_getregs(child, (__u64 __user *) (__u64) data); break; case PTRACE_SETREGS: - ret = ptrace_setregs(child, (__s64 __user *) (__u64) data); + ret = ptrace_setregs(child, (__u64 __user *) (__u64) data); break; case PTRACE_GETFPREGS: diff --git a/trunk/arch/mips/kernel/smtc.c b/trunk/arch/mips/kernel/smtc.c index 9c92d42996cb..a8c1a698d588 100644 --- a/trunk/arch/mips/kernel/smtc.c +++ b/trunk/arch/mips/kernel/smtc.c @@ -88,19 +88,11 @@ unsigned int smtc_status = 0; /* Boot command line configuration overrides */ -static int vpe0limit; static int ipibuffers = 0; static int nostlb = 0; static int asidmask = 0; unsigned long smtc_asid_mask = 0xff; -static int __init vpe0tcs(char *str) -{ - get_option(&str, &vpe0limit); - - return 1; -} - static int __init ipibufs(char *str) { get_option(&str, &ipibuffers); @@ -133,7 +125,6 @@ static int __init asidmask_set(char *str) return 1; } -__setup("vpe0tcs=", vpe0tcs); __setup("ipibufs=", ipibufs); __setup("nostlb", stlb_disable); __setup("asidmask=", asidmask_set); @@ -349,7 +340,7 @@ static void smtc_tc_setup(int vpe, int tc, int cpu) void mipsmt_prepare_cpus(void) { - int i, vpe, tc, ntc, nvpe, tcpervpe[NR_CPUS], slop, cpu; + int i, vpe, tc, ntc, nvpe, tcpervpe, slop, cpu; unsigned long flags; unsigned long val; int nipi; @@ -410,39 +401,8 @@ void mipsmt_prepare_cpus(void) ntc = NR_CPUS; if (tclimit > 0 && ntc > tclimit) ntc = tclimit; - slop = ntc % nvpe; - for (i = 0; i < nvpe; i++) { - tcpervpe[i] = ntc / nvpe; - if (slop) { - if((slop - i) > 0) tcpervpe[i]++; - } - } - /* Handle command line override for VPE0 */ - if (vpe0limit > ntc) vpe0limit = ntc; - if (vpe0limit > 0) { - int slopslop; - if (vpe0limit < tcpervpe[0]) { - /* Reducing TC count - distribute to others */ - slop = tcpervpe[0] - vpe0limit; - slopslop = slop % (nvpe - 1); - tcpervpe[0] = vpe0limit; - for (i = 1; i < nvpe; i++) { - tcpervpe[i] += slop / (nvpe - 1); - if(slopslop && ((slopslop - (i - 1) > 0))) - tcpervpe[i]++; - } - } else if (vpe0limit > tcpervpe[0]) { - /* Increasing TC count - steal from others */ - slop = vpe0limit - tcpervpe[0]; - slopslop = slop % (nvpe - 1); - tcpervpe[0] = vpe0limit; - for (i = 1; i < nvpe; i++) { - tcpervpe[i] -= slop / (nvpe - 1); - if(slopslop && ((slopslop - (i - 1) > 0))) - tcpervpe[i]--; - } - } - } + tcpervpe = ntc / nvpe; + slop = ntc % nvpe; /* Residual TCs, < NVPE */ /* Set up shared TLB */ smtc_configure_tlb(); @@ -456,7 +416,7 @@ void mipsmt_prepare_cpus(void) if (vpe != 0) printk(", "); printk("VPE %d: TC", vpe); - for (i = 0; i < tcpervpe[vpe]; i++) { + for (i = 0; i < tcpervpe; i++) { /* * TC 0 is bound to VPE 0 at reset, * and is presumably executing this @@ -469,6 +429,15 @@ void mipsmt_prepare_cpus(void) printk(" %d", tc); tc++; } + if (slop) { + if (tc != 0) { + smtc_tc_setup(vpe, tc, cpu); + cpu++; + } + printk(" %d", tc); + tc++; + slop--; + } if (vpe != 0) { /* * Clear any stale software interrupts from VPE's Cause diff --git a/trunk/arch/mips/kernel/syscall.c b/trunk/arch/mips/kernel/syscall.c index af1bdc897488..b95fe93dd646 100644 --- a/trunk/arch/mips/kernel/syscall.c +++ b/trunk/arch/mips/kernel/syscall.c @@ -73,14 +73,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, task_size = STACK_TOP; - if (len > task_size) - return -ENOMEM; - if (flags & MAP_FIXED) { - /* Even MAP_FIXED mappings must reside within task_size. */ - if (task_size - len < addr) - return -EINVAL; - /* * We do not accept a shared mapping if it would violate * cache aliasing constraints. @@ -90,6 +83,8 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, return addr; } + if (len > task_size) + return -ENOMEM; do_color_align = 0; if (filp || (flags & MAP_SHARED)) do_color_align = 1; diff --git a/trunk/arch/mips/kernel/time.c b/trunk/arch/mips/kernel/time.c index 27228f583dae..6c6849a8f136 100644 --- a/trunk/arch/mips/kernel/time.c +++ b/trunk/arch/mips/kernel/time.c @@ -11,7 +11,6 @@ * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ -#include #include #include #include @@ -116,6 +115,10 @@ EXPORT_SYMBOL(perf_irq); * (only needed if you intended to use cpu counter as timer interrupt * source) * 2) calculate a couple of cached variables for later usage + * 3) plat_timer_setup() - + * a) (optional) over-write any choices made above by time_init(). + * b) machine specific code should setup the timer irqaction. + * c) enable the timer interrupt */ unsigned int mips_hpt_frequency; @@ -218,18 +221,8 @@ void __init __weak plat_time_init(void) { } -/* - * This function exists in order to cause an error due to a duplicate - * definition if platform code should have its own implementation. The hook - * to use instead is plat_time_init. plat_time_init does not receive the - * irqaction pointer argument anymore. This is because any function which - * initializes an interrupt timer now takes care of its own request_irq rsp. - * setup_irq calls and each clock_event_device should use its own - * struct irqrequest. - */ -void __init plat_timer_setup(struct irqaction *irq) +void __init __weak plat_timer_setup(struct irqaction *irq) { - BUG(); } void __init time_init(void) diff --git a/trunk/arch/mips/kernel/vmlinux.lds.S b/trunk/arch/mips/kernel/vmlinux.lds.S index 5fc2398bdb76..2781cff1485e 100644 --- a/trunk/arch/mips/kernel/vmlinux.lds.S +++ b/trunk/arch/mips/kernel/vmlinux.lds.S @@ -63,23 +63,21 @@ SECTIONS /* writeable */ .data : { /* Data */ - . = . + DATAOFFSET; /* for CONFIG_MAPPED_KERNEL */ - /* - * This ALIGN is needed as a workaround for a bug a - * gcc bug upto 4.1 which limits the maximum alignment - * to at most 32kB and results in the following - * warning: - * - * CC arch/mips/kernel/init_task.o - * arch/mips/kernel/init_task.c:30: warning: alignment - * of ‘init_thread_union’ is greater than maximum - * object file alignment. Using 32768 - */ - . = ALIGN(_PAGE_SIZE); - *(.data.init_task) - - DATA_DATA - CONSTRUCTORS + . = . + DATAOFFSET; /* for CONFIG_MAPPED_KERNEL */ + /* + * This ALIGN is needed as a workaround for a bug a gcc bug upto 4.1 which + * limits the maximum alignment to at most 32kB and results in the following + * warning: + * + * CC arch/mips/kernel/init_task.o + * arch/mips/kernel/init_task.c:30: warning: alignment of ‘init_thread_union’ + * is greater than maximum object file alignment. Using 32768 + */ + . = ALIGN(_PAGE_SIZE); + *(.data.init_task) + + DATA_DATA + CONSTRUCTORS } _gp = . + 0x8000; .lit8 : { diff --git a/trunk/arch/mips/kernel/vpe.c b/trunk/arch/mips/kernel/vpe.c index 436a64ff3989..df8cbe4c7c0d 100644 --- a/trunk/arch/mips/kernel/vpe.c +++ b/trunk/arch/mips/kernel/vpe.c @@ -942,8 +942,8 @@ static int vpe_elfload(struct vpe * v) if (phdr->p_type != PT_LOAD) continue; - memcpy((void *)phdr->p_paddr, (char *)hdr + phdr->p_offset, phdr->p_filesz); - memset((void *)phdr->p_paddr + phdr->p_filesz, 0, phdr->p_memsz - phdr->p_filesz); + memcpy((void *)phdr->p_vaddr, (char *)hdr + phdr->p_offset, phdr->p_filesz); + memset((void *)phdr->p_vaddr + phdr->p_filesz, 0, phdr->p_memsz - phdr->p_filesz); phdr++; } diff --git a/trunk/arch/mips/lasat/setup.c b/trunk/arch/mips/lasat/setup.c index e072da4ff3b3..54827d0174bf 100644 --- a/trunk/arch/mips/lasat/setup.c +++ b/trunk/arch/mips/lasat/setup.c @@ -117,11 +117,14 @@ static struct notifier_block lasat_panic_block[] = } }; -void __init plat_time_init(void) +void plat_time_init(void) { mips_hpt_frequency = lasat_board_info.li_cpu_hz / 2; +} - change_c0_status(ST0_IM, IE_IRQ0); +void __init plat_timer_setup(struct irqaction *irq) +{ + change_c0_status(ST0_IM, IE_IRQ0 | IE_IRQ5); } void __init plat_mem_setup(void) diff --git a/trunk/arch/mips/mips-boards/generic/time.c b/trunk/arch/mips/mips-boards/generic/time.c index f02ce6308e51..9d6243a8c15a 100644 --- a/trunk/arch/mips/mips-boards/generic/time.c +++ b/trunk/arch/mips/mips-boards/generic/time.c @@ -127,6 +127,26 @@ unsigned long read_persistent_clock(void) return mc146818_get_cmos_time(); } +void __init plat_time_init(void) +{ + unsigned int est_freq; + + /* Set Data mode - binary. */ + CMOS_WRITE(CMOS_READ(RTC_CONTROL) | RTC_DM_BINARY, RTC_CONTROL); + + est_freq = estimate_cpu_frequency(); + + printk("CPU frequency %d.%02d MHz\n", est_freq/1000000, + (est_freq%1000000)*100/1000000); + + cpu_khz = est_freq / 1000; + + mips_scroll_message(); +#ifdef CONFIG_I8253 /* Only Malta has a PIT */ + setup_pit_timer(); +#endif +} + void __init plat_perf_setup(void) { cp0_perfcount_irq = -1; @@ -146,13 +166,14 @@ void __init plat_perf_setup(void) } } -unsigned int __init get_c0_compare_int(void) +void __init plat_timer_setup(struct irqaction *irq) { #ifdef MSC01E_INT_BASE if (cpu_has_veic) { set_vi_handler(MSC01E_INT_CPUCTR, mips_timer_dispatch); mips_cpu_timer_irq = MSC01E_INT_BASE + MSC01E_INT_CPUCTR; - } else + } + else #endif { if (cpu_has_vint) @@ -160,26 +181,13 @@ unsigned int __init get_c0_compare_int(void) mips_cpu_timer_irq = MIPS_CPU_IRQ_BASE + cp0_compare_irq; } - return mips_cpu_timer_irq; -} - -void __init plat_time_init(void) -{ - unsigned int est_freq; - - /* Set Data mode - binary. */ - CMOS_WRITE(CMOS_READ(RTC_CONTROL) | RTC_DM_BINARY, RTC_CONTROL); - - est_freq = estimate_cpu_frequency(); - - printk("CPU frequency %d.%02d MHz\n", est_freq/1000000, - (est_freq%1000000)*100/1000000); - - cpu_khz = est_freq / 1000; - - mips_scroll_message(); -#ifdef CONFIG_I8253 /* Only Malta has a PIT */ - setup_pit_timer(); +#ifdef CONFIG_MIPS_MT_SMTC + setup_irq_smtc(mips_cpu_timer_irq, irq, 0x100 << cp0_compare_irq); +#else + setup_irq(mips_cpu_timer_irq, irq); +#endif /* CONFIG_MIPS_MT_SMTC */ +#ifdef CONFIG_SMP + set_irq_handler(mips_cpu_timer_irq, handle_percpu_irq); #endif plat_perf_setup(); diff --git a/trunk/arch/mips/mipssim/sim_time.c b/trunk/arch/mips/mipssim/sim_time.c index bfaafa38846f..e7fa0d1078a3 100644 --- a/trunk/arch/mips/mipssim/sim_time.c +++ b/trunk/arch/mips/mipssim/sim_time.c @@ -75,6 +75,25 @@ static unsigned int __init estimate_cpu_frequency(void) return count; } +void __init plat_time_init(void) +{ + unsigned int est_freq, flags; + + local_irq_save(flags); + + /* Set Data mode - binary. */ + CMOS_WRITE(CMOS_READ(RTC_CONTROL) | RTC_DM_BINARY, RTC_CONTROL); + + est_freq = estimate_cpu_frequency(); + + printk(KERN_INFO "CPU frequency %d.%02d MHz\n", est_freq / 1000000, + (est_freq % 1000000) * 100 / 1000000); + + cpu_khz = est_freq / 1000; + + local_irq_restore(flags); +} + static int mips_cpu_timer_irq; static void mips_timer_dispatch(void) @@ -83,37 +102,26 @@ static void mips_timer_dispatch(void) } -unsigned __init get_c0_compare_int(void) +void __init plat_timer_setup(struct irqaction *irq) { -#ifdef MSC01E_INT_BASE if (cpu_has_veic) { set_vi_handler(MSC01E_INT_CPUCTR, mips_timer_dispatch); mips_cpu_timer_irq = MSC01E_INT_BASE + MSC01E_INT_CPUCTR; } else { -#endif if (cpu_has_vint) set_vi_handler(cp0_compare_irq, mips_timer_dispatch); mips_cpu_timer_irq = MIPS_CPU_IRQ_BASE + cp0_compare_irq; } - return mips_cpu_timer_irq; -} - -void __init plat_time_init(void) -{ - unsigned int est_freq, flags; - - local_irq_save(flags); - - /* Set Data mode - binary. */ - CMOS_WRITE(CMOS_READ(RTC_CONTROL) | RTC_DM_BINARY, RTC_CONTROL); + /* we are using the cpu counter for timer interrupts */ + setup_irq(mips_cpu_timer_irq, irq); - est_freq = estimate_cpu_frequency(); - - printk(KERN_INFO "CPU frequency %d.%02d MHz\n", est_freq / 1000000, - (est_freq % 1000000) * 100 / 1000000); - - cpu_khz = est_freq / 1000; - - local_irq_restore(flags); +#ifdef CONFIG_SMP + /* irq_desc(riptor) is a global resource, when the interrupt overlaps + on seperate cpu's the first one tries to handle the second interrupt. + The effect is that the int remains disabled on the second cpu. + Mark the interrupt with IRQ_PER_CPU to avoid any confusion */ + irq_desc[mips_cpu_timer_irq].flags |= IRQ_PER_CPU; + set_irq_handler(mips_cpu_timer_irq, handle_percpu_irq); +#endif } diff --git a/trunk/arch/mips/mm/c-r3k.c b/trunk/arch/mips/mm/c-r3k.c index 562abb77d1d5..c55312f6fd3a 100644 --- a/trunk/arch/mips/mm/c-r3k.c +++ b/trunk/arch/mips/mm/c-r3k.c @@ -7,7 +7,7 @@ * Tx39XX R4k style caches added. HK * Copyright (C) 1998, 1999, 2000 Harald Koerfgen * Copyright (C) 1998 Gleb Raiko & Vladimir Roganov - * Copyright (C) 2001, 2004, 2007 Maciej W. Rozycki + * Copyright (C) 2001, 2004 Maciej W. Rozycki */ #include #include @@ -26,6 +26,8 @@ static unsigned long icache_size, dcache_size; /* Size in bytes */ static unsigned long icache_lsize, dcache_lsize; /* Size in bytes */ +#undef DEBUG_CACHE + unsigned long __init r3k_cache_size(unsigned long ca_flags) { unsigned long flags, status, dummy, size; @@ -215,6 +217,26 @@ static void r3k_flush_dcache_range(unsigned long start, unsigned long end) write_c0_status(flags); } +static inline unsigned long get_phys_page(unsigned long addr, + struct mm_struct *mm) +{ + pgd_t *pgd; + pud_t *pud; + pmd_t *pmd; + pte_t *pte; + unsigned long physpage; + + pgd = pgd_offset(mm, addr); + pud = pud_offset(pgd, addr); + pmd = pmd_offset(pud, addr); + pte = pte_offset(pmd, addr); + + if ((physpage = pte_val(*pte)) & _PAGE_VALID) + return KSEG0ADDR(physpage & PAGE_MASK); + + return 0; +} + static inline void r3k_flush_cache_all(void) { } @@ -230,40 +252,12 @@ static void r3k_flush_cache_mm(struct mm_struct *mm) } static void r3k_flush_cache_range(struct vm_area_struct *vma, - unsigned long start, unsigned long end) + unsigned long start, unsigned long end) { } -static void r3k_flush_cache_page(struct vm_area_struct *vma, - unsigned long addr, unsigned long pfn) +static void r3k_flush_cache_page(struct vm_area_struct *vma, unsigned long page, unsigned long pfn) { - unsigned long kaddr = KSEG0ADDR(pfn << PAGE_SHIFT); - int exec = vma->vm_flags & VM_EXEC; - struct mm_struct *mm = vma->vm_mm; - pgd_t *pgdp; - pud_t *pudp; - pmd_t *pmdp; - pte_t *ptep; - - pr_debug("cpage[%08lx,%08lx]\n", - cpu_context(smp_processor_id(), mm), addr); - - /* No ASID => no such page in the cache. */ - if (cpu_context(smp_processor_id(), mm) == 0) - return; - - pgdp = pgd_offset(mm, addr); - pudp = pud_offset(pgdp, addr); - pmdp = pmd_offset(pudp, addr); - ptep = pte_offset(pmdp, addr); - - /* Invalid => no such page in the cache. */ - if (!(pte_val(*ptep) & _PAGE_PRESENT)) - return; - - r3k_flush_dcache_range(kaddr, kaddr + PAGE_SIZE); - if (exec) - r3k_flush_icache_range(kaddr, kaddr + PAGE_SIZE); } static void local_r3k_flush_data_cache_page(void *addr) @@ -278,7 +272,9 @@ static void r3k_flush_cache_sigtramp(unsigned long addr) { unsigned long flags; - pr_debug("csigtramp[%08lx]\n", addr); +#ifdef DEBUG_CACHE + printk("csigtramp[%08lx]", addr); +#endif flags = read_c0_status(); diff --git a/trunk/arch/mips/mm/c-r4k.c b/trunk/arch/mips/mm/c-r4k.c index 6806d58211b2..d7088331fb0f 100644 --- a/trunk/arch/mips/mm/c-r4k.c +++ b/trunk/arch/mips/mm/c-r4k.c @@ -345,26 +345,11 @@ static void r4k___flush_cache_all(void) r4k_on_each_cpu(local_r4k___flush_cache_all, NULL, 1, 1); } -static inline int has_valid_asid(const struct mm_struct *mm) -{ -#if defined(CONFIG_MIPS_MT_SMP) || defined(CONFIG_MIPS_MT_SMTC) - int i; - - for_each_online_cpu(i) - if (cpu_context(i, mm)) - return 1; - - return 0; -#else - return cpu_context(smp_processor_id(), mm); -#endif -} - static inline void local_r4k_flush_cache_range(void * args) { struct vm_area_struct *vma = args; - if (!(has_valid_asid(vma->vm_mm))) + if (!(cpu_context(smp_processor_id(), vma->vm_mm))) return; r4k_blast_dcache(); @@ -383,7 +368,7 @@ static inline void local_r4k_flush_cache_mm(void * args) { struct mm_struct *mm = args; - if (!has_valid_asid(mm)) + if (!cpu_context(smp_processor_id(), mm)) return; /* @@ -435,7 +420,7 @@ static inline void local_r4k_flush_cache_page(void *args) * If ownes no valid ASID yet, cannot possibly have gotten * this page into the cache. */ - if (!has_valid_asid(mm)) + if (cpu_context(smp_processor_id(), mm) == 0) return; addr &= PAGE_MASK; diff --git a/trunk/arch/mips/mm/dma-default.c b/trunk/arch/mips/mm/dma-default.c index 33519ce49540..b1b40527658b 100644 --- a/trunk/arch/mips/mm/dma-default.c +++ b/trunk/arch/mips/mm/dma-default.c @@ -12,8 +12,8 @@ #include #include #include -#include #include +#include #include #include diff --git a/trunk/arch/mips/pci/fixup-pmcmsp.c b/trunk/arch/mips/pci/fixup-pmcmsp.c index 65735b1b7665..00261211dbfa 100644 --- a/trunk/arch/mips/pci/fixup-pmcmsp.c +++ b/trunk/arch/mips/pci/fixup-pmcmsp.c @@ -202,7 +202,7 @@ int pcibios_plat_dev_init(struct pci_dev *dev) * RETURNS: IRQ number * ****************************************************************************/ -int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) +int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) { #if !defined(CONFIG_PMC_MSP7120_GW) && !defined(CONFIG_PMC_MSP7120_EVAL) printk(KERN_WARNING "PCI: unknown board, no PCI IRQs assigned.\n"); diff --git a/trunk/arch/mips/pci/fixup-tb0219.c b/trunk/arch/mips/pci/fixup-tb0219.c index ed87733f6796..720a2b720c5c 100644 --- a/trunk/arch/mips/pci/fixup-tb0219.c +++ b/trunk/arch/mips/pci/fixup-tb0219.c @@ -2,7 +2,7 @@ * fixup-tb0219.c, The TANBAC TB0219 specific PCI fixups. * * Copyright (C) 2003 Megasolution Inc. - * Copyright (C) 2004-2005 Yoichi Yuasa + * Copyright (C) 2004 Yoichi Yuasa * * 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 diff --git a/trunk/arch/mips/pci/ops-pmcmsp.c b/trunk/arch/mips/pci/ops-pmcmsp.c index 109c95ca698b..059eade96f2e 100644 --- a/trunk/arch/mips/pci/ops-pmcmsp.c +++ b/trunk/arch/mips/pci/ops-pmcmsp.c @@ -404,7 +404,7 @@ int msp_pcibios_config_access(unsigned char access_type, if (pciirqflag == 0) { request_irq(MSP_INT_PCI,/* Hardcoded internal MSP7120 wiring */ bpci_interrupt, - IRQF_SHARED | IRQF_DISABLED, + SA_SHIRQ | SA_INTERRUPT, "PMC MSP PCI Host", preg); pciirqflag = ~0; diff --git a/trunk/arch/mips/pmc-sierra/msp71xx/msp_serial.c b/trunk/arch/mips/pmc-sierra/msp71xx/msp_serial.c index 9de34302e5f4..15e7b8000b4c 100644 --- a/trunk/arch/mips/pmc-sierra/msp71xx/msp_serial.c +++ b/trunk/arch/mips/pmc-sierra/msp71xx/msp_serial.c @@ -122,7 +122,7 @@ void __init msp_serial_setup(void) up.uartclk = uartclk; up.regshift = 2; up.iotype = UPIO_DWAPB; /* UPIO_MEM like */ - up.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST; + up.flags = STD_COM_FLAGS; up.type = PORT_16550A; up.line = 0; up.private_data = (void*)UART0_STATUS_REG; diff --git a/trunk/arch/mips/sgi-ip27/ip27-timer.c b/trunk/arch/mips/sgi-ip27/ip27-timer.c index dc59c3b708ed..f5dccf01da11 100644 --- a/trunk/arch/mips/sgi-ip27/ip27-timer.c +++ b/trunk/arch/mips/sgi-ip27/ip27-timer.c @@ -131,12 +131,12 @@ static struct irq_chip rt_irq_type = { static int rt_next_event(unsigned long delta, struct clock_event_device *evt) { unsigned int cpu = smp_processor_id(); - int slice putoslice(cpu); + int slice = cputoslice(cpu) == 0; unsigned long cnt; cnt = LOCAL_HUB_L(PI_RT_COUNT); cnt += delta; - LOCAL_HUB_S(PI_RT_COMPARE_A + PI_COUNT_OFFSET * slice, cnt); + LOCAL_HUB_S(slice ? PI_RT_COMPARE_A : PI_RT_COMPARE_B, cnt); return LOCAL_HUB_L(PI_RT_COUNT) >= cnt ? -ETIME : 0; } @@ -164,12 +164,9 @@ static irqreturn_t hub_rt_counter_handler(int irq, void *dev_id) { struct clock_event_device *cd = dev_id; unsigned int cpu = smp_processor_id(); - int slice = cputoslice(cpu); + int slice = cputoslice(cpu) == 0; - /* - * Ack - */ - LOCAL_HUB_S(PI_RT_PEND_A + PI_COUNT_OFFSET * slice, cnt); + LOCAL_HUB_S(slice ? PI_RT_PEND_A : PI_RT_PEND_B, 0); /* Ack */ cd->event_handler(cd); return IRQ_HANDLED; diff --git a/trunk/arch/mips/sgi-ip32/ip32-irq.c b/trunk/arch/mips/sgi-ip32/ip32-irq.c index aab17ddd2f30..7e8094f617bf 100644 --- a/trunk/arch/mips/sgi-ip32/ip32-irq.c +++ b/trunk/arch/mips/sgi-ip32/ip32-irq.c @@ -40,6 +40,13 @@ static void inline flush_mace_bus(void) mace->perif.ctrl.misc; } +#undef DEBUG_IRQ +#ifdef DEBUG_IRQ +#define DBG(x...) printk(x) +#else +#define DBG(x...) +#endif + /* * O2 irq map * @@ -118,7 +125,6 @@ struct irqaction memerr_irq = { .mask = CPU_MASK_NONE, .name = "CRIME memory error", }; - struct irqaction cpuerr_irq = { .handler = crime_cpuerr_intr, .flags = IRQF_DISABLED, @@ -133,70 +139,46 @@ struct irqaction cpuerr_irq = { static uint64_t crime_mask; -static inline void crime_enable_irq(unsigned int irq) +static void enable_crime_irq(unsigned int irq) { - unsigned int bit = irq - CRIME_IRQ_BASE; - - crime_mask |= 1 << bit; + crime_mask |= 1 << (irq - 1); crime->imask = crime_mask; } -static inline void crime_disable_irq(unsigned int irq) +static void disable_crime_irq(unsigned int irq) { - unsigned int bit = irq - CRIME_IRQ_BASE; - - crime_mask &= ~(1 << bit); + crime_mask &= ~(1 << (irq - 1)); crime->imask = crime_mask; flush_crime_bus(); } -static void crime_level_mask_and_ack_irq(unsigned int irq) -{ - crime_disable_irq(irq); -} - -static void crime_level_end_irq(unsigned int irq) -{ - if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) - crime_enable_irq(irq); -} - -static struct irq_chip crime_level_interrupt = { - .name = "IP32 CRIME", - .ack = crime_level_mask_and_ack_irq, - .mask = crime_disable_irq, - .mask_ack = crime_level_mask_and_ack_irq, - .unmask = crime_enable_irq, - .end = crime_level_end_irq, -}; - -static void crime_edge_mask_and_ack_irq(unsigned int irq) +static void mask_and_ack_crime_irq(unsigned int irq) { - unsigned int bit = irq - CRIME_IRQ_BASE; - uint64_t crime_int; - /* Edge triggered interrupts must be cleared. */ - - crime_int = crime->hard_int; - crime_int &= ~(1 << bit); - crime->hard_int = crime_int; - - crime_disable_irq(irq); + if ((irq >= CRIME_GBE0_IRQ && irq <= CRIME_GBE3_IRQ) + || (irq >= CRIME_RE_EMPTY_E_IRQ && irq <= CRIME_RE_IDLE_E_IRQ) + || (irq >= CRIME_SOFT0_IRQ && irq <= CRIME_SOFT2_IRQ)) { + uint64_t crime_int; + crime_int = crime->hard_int; + crime_int &= ~(1 << (irq - 1)); + crime->hard_int = crime_int; + } + disable_crime_irq(irq); } -static void crime_edge_end_irq(unsigned int irq) +static void end_crime_irq(unsigned int irq) { if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) - crime_enable_irq(irq); + enable_crime_irq(irq); } -static struct irq_chip crime_edge_interrupt = { - .name = "IP32 CRIME", - .ack = crime_edge_mask_and_ack_irq, - .mask = crime_disable_irq, - .mask_ack = crime_edge_mask_and_ack_irq, - .unmask = crime_enable_irq, - .end = crime_edge_end_irq, +static struct irq_chip ip32_crime_interrupt = { + .name = "IP32 CRIME", + .ack = mask_and_ack_crime_irq, + .mask = disable_crime_irq, + .mask_ack = mask_and_ack_crime_irq, + .unmask = enable_crime_irq, + .end = end_crime_irq, }; /* @@ -283,7 +265,7 @@ static void enable_maceisa_irq(unsigned int irq) { unsigned int crime_int = 0; - pr_debug("maceisa enable: %u\n", irq); + DBG("maceisa enable: %u\n", irq); switch (irq) { case MACEISA_AUDIO_SW_IRQ ... MACEISA_AUDIO3_MERR_IRQ: @@ -296,7 +278,7 @@ static void enable_maceisa_irq(unsigned int irq) crime_int = MACE_SUPERIO_INT; break; } - pr_debug("crime_int %08x enabled\n", crime_int); + DBG("crime_int %08x enabled\n", crime_int); crime_mask |= crime_int; crime->imask = crime_mask; maceisa_mask |= 1 << (irq - 33); @@ -308,11 +290,11 @@ static void disable_maceisa_irq(unsigned int irq) unsigned int crime_int = 0; maceisa_mask &= ~(1 << (irq - 33)); - if (!(maceisa_mask & MACEISA_AUDIO_INT)) + if(!(maceisa_mask & MACEISA_AUDIO_INT)) crime_int |= MACE_AUDIO_INT; - if (!(maceisa_mask & MACEISA_MISC_INT)) + if(!(maceisa_mask & MACEISA_MISC_INT)) crime_int |= MACE_MISC_INT; - if (!(maceisa_mask & MACEISA_SUPERIO_INT)) + if(!(maceisa_mask & MACEISA_SUPERIO_INT)) crime_int |= MACE_SUPERIO_INT; crime_mask &= ~crime_int; crime->imask = crime_mask; @@ -345,12 +327,12 @@ static void end_maceisa_irq(unsigned irq) } static struct irq_chip ip32_maceisa_interrupt = { - .name = "IP32 MACE ISA", - .ack = mask_and_ack_maceisa_irq, - .mask = disable_maceisa_irq, - .mask_ack = mask_and_ack_maceisa_irq, - .unmask = enable_maceisa_irq, - .end = end_maceisa_irq, + .name = "IP32 MACE ISA", + .ack = mask_and_ack_maceisa_irq, + .mask = disable_maceisa_irq, + .mask_ack = mask_and_ack_maceisa_irq, + .unmask = enable_maceisa_irq, + .end = end_maceisa_irq, }; /* This is used for regular non-ISA, non-PCI MACE interrupts. That means @@ -429,7 +411,7 @@ static void ip32_irq0(void) irq = __ffs(mace_int & maceisa_mask) + MACEISA_AUDIO_SW_IRQ; } - pr_debug("*irq %u*\n", irq); + DBG("*irq %u*\n", irq); do_IRQ(irq); } @@ -490,31 +472,23 @@ void __init arch_init_irq(void) mips_cpu_irq_init(); for (irq = MIPS_CPU_IRQ_BASE + 8; irq <= IP32_IRQ_MAX; irq++) { + struct irq_chip *chip; + switch (irq) { case MACE_VID_IN1_IRQ ... MACE_PCI_BRIDGE_IRQ: - set_irq_chip(irq, &ip32_mace_interrupt); + chip = &ip32_mace_interrupt; break; case MACEPCI_SCSI0_IRQ ... MACEPCI_SHARED2_IRQ: - set_irq_chip(irq, &ip32_macepci_interrupt); - break; - case CRIME_GBE0_IRQ ... CRIME_GBE3_IRQ: - set_irq_chip(irq, &crime_edge_interrupt); - break; - case CRIME_CPUERR_IRQ: - case CRIME_MEMERR_IRQ: - set_irq_chip(irq, &crime_level_interrupt); + chip = &ip32_macepci_interrupt; break; - case CRIME_RE_EMPTY_E_IRQ ... CRIME_RE_IDLE_E_IRQ: - case CRIME_SOFT0_IRQ ... CRIME_SOFT2_IRQ: - set_irq_chip(irq, &crime_edge_interrupt); - break; - case CRIME_VICE_IRQ: - set_irq_chip(irq, &crime_edge_interrupt); + case CRIME_GBE0_IRQ ... CRIME_VICE_IRQ: + chip = &ip32_crime_interrupt; break; default: - set_irq_chip(irq, &ip32_maceisa_interrupt); - break; + chip = &ip32_maceisa_interrupt; } + + set_irq_chip(irq, chip); } setup_irq(CRIME_MEMERR_IRQ, &memerr_irq); setup_irq(CRIME_CPUERR_IRQ, &cpuerr_irq); diff --git a/trunk/arch/mips/sibyte/bcm1480/irq.c b/trunk/arch/mips/sibyte/bcm1480/irq.c index 61790c4bfb60..10299bafeab7 100644 --- a/trunk/arch/mips/sibyte/bcm1480/irq.c +++ b/trunk/arch/mips/sibyte/bcm1480/irq.c @@ -280,6 +280,27 @@ static struct irqaction bcm1480_dummy_action = { .dev_id = 0 }; +int bcm1480_steal_irq(int irq) +{ + struct irq_desc *desc = irq_desc + irq; + unsigned long flags; + int retval = 0; + + if (irq >= BCM1480_NR_IRQS) + return -EINVAL; + + spin_lock_irqsave(&desc->lock, flags); + /* Don't allow sharing at all for these */ + if (desc->action != NULL) + retval = -EBUSY; + else { + desc->action = &bcm1480_dummy_action; + desc->depth = 0; + } + spin_unlock_irqrestore(&desc->lock, flags); + return 0; +} + /* * init_IRQ is called early in the boot sequence from init/main.c. It * is responsible for setting up the interrupt mapper and installing the @@ -365,6 +386,8 @@ void __init arch_init_irq(void) __raw_writeq(tmp, IOADDR(A_BCM1480_IMR_REGISTER(cpu, R_BCM1480_IMR_INTERRUPT_MASK_L))); } + bcm1480_steal_irq(K_BCM1480_INT_MBOX_0_0); + /* * Note that the timer interrupts are also mapped, but this is * done in bcm1480_time_init(). Also, the profiling driver @@ -388,6 +411,7 @@ void __init arch_init_irq(void) /* QQQ FIXME */ __raw_writeq(M_DUART_IMR_BRK, IO_SPACE_BASE + A_DUART_IMRREG(kgdb_port)); + bcm1480_steal_irq(kgdb_irq); __raw_writeq(IMR_IP6_VAL, IO_SPACE_BASE + A_BCM1480_IMR_REGISTER(0, R_BCM1480_IMR_INTERRUPT_MAP_BASE_H) + (kgdb_irq<<3)); diff --git a/trunk/arch/mips/sibyte/bcm1480/time.c b/trunk/arch/mips/sibyte/bcm1480/time.c index bbf19bfabccb..610f0253954d 100644 --- a/trunk/arch/mips/sibyte/bcm1480/time.c +++ b/trunk/arch/mips/sibyte/bcm1480/time.c @@ -37,6 +37,8 @@ #define IMR_IP3_VAL K_BCM1480_INT_MAP_I1 #define IMR_IP4_VAL K_BCM1480_INT_MAP_I2 +extern int bcm1480_steal_irq(int irq); + /* * The general purpose timer ticks at 1MHz independent if * the rest of the system @@ -119,7 +121,7 @@ void __cpuinit sb1480_clockevent_init(void) sprintf(name, "bcm1480-counter %d", cpu); cd->name = name; cd->features = CLOCK_EVT_FEAT_PERIODIC | - CLOCK_EVT_FEAT_ONESHOT; + CLOCK_EVT_MODE_ONESHOT; clockevent_set_clock(cd, V_SCD_TIMER_FREQ); cd->max_delta_ns = clockevent_delta2ns(0x7fffff, cd); cd->min_delta_ns = clockevent_delta2ns(1, cd); @@ -140,6 +142,7 @@ void __cpuinit sb1480_clockevent_init(void) R_BCM1480_IMR_INTERRUPT_MAP_BASE_H) + (irq << 3))); bcm1480_unmask_irq(cpu, irq); + bcm1480_steal_irq(irq); action->handler = sibyte_counter_handler; action->flags = IRQF_DISABLED | IRQF_PERCPU; diff --git a/trunk/arch/mips/sibyte/sb1250/irq.c b/trunk/arch/mips/sibyte/sb1250/irq.c index 52d18fc91f32..53780a179d1d 100644 --- a/trunk/arch/mips/sibyte/sb1250/irq.c +++ b/trunk/arch/mips/sibyte/sb1250/irq.c @@ -250,6 +250,27 @@ static struct irqaction sb1250_dummy_action = { .dev_id = 0 }; +int sb1250_steal_irq(int irq) +{ + struct irq_desc *desc = irq_desc + irq; + unsigned long flags; + int retval = 0; + + if (irq >= SB1250_NR_IRQS) + return -EINVAL; + + spin_lock_irqsave(&desc->lock, flags); + /* Don't allow sharing at all for these */ + if (desc->action != NULL) + retval = -EBUSY; + else { + desc->action = &sb1250_dummy_action; + desc->depth = 0; + } + spin_unlock_irqrestore(&desc->lock, flags); + return 0; +} + /* * arch_init_irq is called early in the boot sequence from init/main.c via * init_IRQ. It is responsible for setting up the interrupt mapper and @@ -321,6 +342,8 @@ void __init arch_init_irq(void) __raw_writeq(tmp, IOADDR(A_IMR_REGISTER(0, R_IMR_INTERRUPT_MASK))); __raw_writeq(tmp, IOADDR(A_IMR_REGISTER(1, R_IMR_INTERRUPT_MASK))); + sb1250_steal_irq(K_INT_MBOX_0); + /* * Note that the timer interrupts are also mapped, but this is * done in sb1250_time_init(). Also, the profiling driver @@ -344,6 +367,7 @@ void __init arch_init_irq(void) __raw_writeq(M_DUART_IMR_BRK, IOADDR(A_DUART_IMRREG(kgdb_port))); + sb1250_steal_irq(kgdb_irq); __raw_writeq(IMR_IP6_VAL, IOADDR(A_IMR_REGISTER(0, R_IMR_INTERRUPT_MAP_BASE) + diff --git a/trunk/arch/mips/sibyte/sb1250/time.c b/trunk/arch/mips/sibyte/sb1250/time.c index 95ad34e3fbac..a41e908bc218 100644 --- a/trunk/arch/mips/sibyte/sb1250/time.c +++ b/trunk/arch/mips/sibyte/sb1250/time.c @@ -50,6 +50,8 @@ #define SB1250_HPT_VALUE M_SCD_TIMER_CNT /* max value */ +extern int sb1250_steal_irq(int irq); + /* * The general purpose timer ticks at 1 Mhz independent if * the rest of the system @@ -137,7 +139,7 @@ void __cpuinit sb1250_clockevent_init(void) sprintf(name, "bcm1480-counter %d", cpu); cd->name = name; cd->features = CLOCK_EVT_FEAT_PERIODIC | - CLOCK_EVT_FEAT_ONESHOT; + CLOCK_EVT_MODE_ONESHOT; clockevent_set_clock(cd, V_SCD_TIMER_FREQ); cd->max_delta_ns = clockevent_delta2ns(0x7fffff, cd); cd->min_delta_ns = clockevent_delta2ns(1, cd); @@ -157,6 +159,7 @@ void __cpuinit sb1250_clockevent_init(void) cd->cpumask = cpumask_of_cpu(0); sb1250_unmask_irq(cpu, irq); + sb1250_steal_irq(irq); action->handler = sibyte_counter_handler; action->flags = IRQF_DISABLED | IRQF_PERCPU; diff --git a/trunk/arch/mips/sni/time.c b/trunk/arch/mips/sni/time.c index 60bc62ef0935..0910b35cb71f 100644 --- a/trunk/arch/mips/sni/time.c +++ b/trunk/arch/mips/sni/time.c @@ -11,78 +11,27 @@ #define SNI_COUNTER2_DIV 64 #define SNI_COUNTER0_DIV ((SNI_CLOCK_TICK_RATE / SNI_COUNTER2_DIV) / HZ) -static void a20r_set_mode(enum clock_event_mode mode, - struct clock_event_device *evt) +static void sni_a20r_timer_ack(void) { - switch (mode) { - case CLOCK_EVT_MODE_PERIODIC: - *(volatile u8 *)(A20R_PT_CLOCK_BASE + 12) = 0x34; - wmb(); - *(volatile u8 *)(A20R_PT_CLOCK_BASE + 0) = SNI_COUNTER0_DIV; - wmb(); - *(volatile u8 *)(A20R_PT_CLOCK_BASE + 0) = SNI_COUNTER0_DIV >> 8; - wmb(); - - *(volatile u8 *)(A20R_PT_CLOCK_BASE + 12) = 0xb4; - wmb(); - *(volatile u8 *)(A20R_PT_CLOCK_BASE + 8) = SNI_COUNTER2_DIV; - wmb(); - *(volatile u8 *)(A20R_PT_CLOCK_BASE + 8) = SNI_COUNTER2_DIV >> 8; - wmb(); - - break; - case CLOCK_EVT_MODE_ONESHOT: - case CLOCK_EVT_MODE_UNUSED: - case CLOCK_EVT_MODE_SHUTDOWN: - break; - case CLOCK_EVT_MODE_RESUME: - break; - } + *(volatile u8 *)A20R_PT_TIM0_ACK = 0x0; wmb(); } -static struct clock_event_device a20r_clockevent_device = { - .name = "a20r-timer", - .features = CLOCK_EVT_FEAT_PERIODIC, - - /* .mult, .shift, .max_delta_ns and .min_delta_ns left uninitialized */ - - .rating = 300, - .irq = SNI_A20R_IRQ_TIMER, - .set_mode = a20r_set_mode, -}; - -static irqreturn_t a20r_interrupt(int irq, void *dev_id) -{ - struct clock_event_device *cd = dev_id; - - *(volatile u8 *)A20R_PT_TIM0_ACK = 0; - wmb(); - - cd->event_handler(cd); - - return IRQ_HANDLED; -} - -static struct irqaction a20r_irqaction = { - .handler = a20r_interrupt, - .flags = IRQF_DISABLED | IRQF_PERCPU, - .name = "a20r-timer", -}; - /* * a20r platform uses 2 counters to divide the input frequency. * Counter 2 output is connected to Counter 0 & 1 input. */ -static void __init sni_a20r_timer_setup(void) +static void __init sni_a20r_timer_setup(struct irqaction *irq) { - struct clock_event_device *cd = &a20r_clockevent_device; - struct irqaction *action = &a20r_irqaction; - unsigned int cpu = smp_processor_id(); + *(volatile u8 *)(A20R_PT_CLOCK_BASE + 12) = 0x34; wmb(); + *(volatile u8 *)(A20R_PT_CLOCK_BASE + 0) = (SNI_COUNTER0_DIV) & 0xff; wmb(); + *(volatile u8 *)(A20R_PT_CLOCK_BASE + 0) = (SNI_COUNTER0_DIV >> 8) & 0xff; wmb(); - cd->cpumask = cpumask_of_cpu(cpu); + *(volatile u8 *)(A20R_PT_CLOCK_BASE + 12) = 0xb4; wmb(); + *(volatile u8 *)(A20R_PT_CLOCK_BASE + 8) = (SNI_COUNTER2_DIV) & 0xff; wmb(); + *(volatile u8 *)(A20R_PT_CLOCK_BASE + 8) = (SNI_COUNTER2_DIV >> 8) & 0xff; wmb(); - action->dev_id = cd; - setup_irq(SNI_A20R_IRQ_TIMER, &a20r_irqaction); + setup_irq(SNI_A20R_IRQ_TIMER, irq); + mips_timer_ack = sni_a20r_timer_ack; } #define SNI_8254_TICK_RATE 1193182UL @@ -170,14 +119,17 @@ void __init plat_time_init(void) mips_hpt_frequency = r4k_tick * HZ; setup_pit_timer(); +} +void __init plat_timer_setup(struct irqaction *irq) +{ switch (sni_brd_type) { case SNI_BRD_10: case SNI_BRD_10NEW: case SNI_BRD_TOWER_OASIC: case SNI_BRD_MINITOWER: - sni_a20r_timer_setup(); - break; + sni_a20r_timer_setup(irq); + break; } } diff --git a/trunk/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c b/trunk/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c index 0299595ce1c4..c7470fba6180 100644 --- a/trunk/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c +++ b/trunk/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c @@ -63,7 +63,6 @@ #include #include #include -#include #include #include #ifdef CONFIG_TOSHIBA_FPCIB0 @@ -94,6 +93,7 @@ #define TOSHIBA_RBTX4927_SETUP_EFWFU ( 1 << 3 ) #define TOSHIBA_RBTX4927_SETUP_SETUP ( 1 << 4 ) +#define TOSHIBA_RBTX4927_SETUP_TIME_INIT ( 1 << 5 ) #define TOSHIBA_RBTX4927_SETUP_PCIBIOS ( 1 << 7 ) #define TOSHIBA_RBTX4927_SETUP_PCI1 ( 1 << 8 ) #define TOSHIBA_RBTX4927_SETUP_PCI2 ( 1 << 9 ) @@ -130,6 +130,7 @@ extern void toshiba_rbtx4927_power_off(void); int tx4927_using_backplane = 0; +extern void gt64120_time_init(void); extern void toshiba_rbtx4927_irq_setup(void); char *prom_getcmdline(void); @@ -720,7 +721,6 @@ void toshiba_rbtx4927_power_off(void) void __init toshiba_rbtx4927_setup(void) { - int i; u32 cp0_config; char *argptr; @@ -764,9 +764,6 @@ void __init toshiba_rbtx4927_setup(void) _machine_halt = toshiba_rbtx4927_halt; pm_power_off = toshiba_rbtx4927_power_off; - for (i = 0; i < TX4927_NR_TMR; i++) - txx9_tmr_init(TX4927_TMR_REG(0) & 0xfffffffffULL); - #ifdef CONFIG_PCI /* PCIC */ @@ -895,6 +892,7 @@ void __init toshiba_rbtx4927_setup(void) #ifdef CONFIG_SERIAL_TXX9 { extern int early_serial_txx9_setup(struct uart_port *port); + int i; struct uart_port req; for(i = 0; i < 2; i++) { memset(&req, 0, sizeof(req)); @@ -939,11 +937,12 @@ void __init toshiba_rbtx4927_setup(void) void __init toshiba_rbtx4927_time_init(void) { + TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT, "-\n"); + mips_hpt_frequency = tx4927_cpu_clock / 2; - if (tx4927_ccfgptr->ccfg & TX4927_CCFG_TINTDIS) - txx9_clockevent_init(TX4927_TMR_REG(0) & 0xfffffffffULL, - TXX9_IRQ_BASE + 17, - 50000000); + + TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT, "+\n"); + } static int __init toshiba_rbtx4927_rtc_init(void) diff --git a/trunk/arch/mips/tx4938/toshiba_rbtx4938/setup.c b/trunk/arch/mips/tx4938/toshiba_rbtx4938/setup.c index 4a8152375efe..ceecaf498957 100644 --- a/trunk/arch/mips/tx4938/toshiba_rbtx4938/setup.c +++ b/trunk/arch/mips/tx4938/toshiba_rbtx4938/setup.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -774,8 +773,15 @@ void __init tx4938_board_setup(void) } /* TMR */ - for (i = 0; i < TX4938_NR_TMR; i++) - txx9_tmr_init(TX4938_TMR_REG(i) & 0xfffffffffULL); + /* disable all timers */ + for (i = 0; i < TX4938_NR_TMR; i++) { + tx4938_tmrptr(i)->tcr = 0x00000020; + tx4938_tmrptr(i)->tisr = 0; + tx4938_tmrptr(i)->cpra = 0xffffffff; + tx4938_tmrptr(i)->itmr = 0; + tx4938_tmrptr(i)->ccdr = 0; + tx4938_tmrptr(i)->pgmr = 0; + } /* enable DMA */ TX4938_WR64(0xff1fb150, TX4938_DMA_MCR_MSTEN); @@ -846,13 +852,12 @@ void tx4938_report_pcic_status(void) #endif /* CONFIG_PCI */ +/* We use onchip r4k counter or TMR timer as our system wide timer + * interrupt running at 100HZ. */ + void __init plat_time_init(void) { mips_hpt_frequency = txx9_cpu_clock / 2; - if (tx4938_ccfgptr->ccfg & TX4938_CCFG_TINTDIS) - txx9_clockevent_init(TX4938_TMR_REG(0) & 0xfffffffffULL, - TXX9_IRQ_BASE + TX4938_IR_TMR(0), - txx9_gbus_clock / 2); } void __init toshiba_rbtx4938_setup(void) diff --git a/trunk/arch/s390/Kconfig b/trunk/arch/s390/Kconfig index 1330061020ab..4ec716d8c1a6 100644 --- a/trunk/arch/s390/Kconfig +++ b/trunk/arch/s390/Kconfig @@ -513,7 +513,7 @@ config ZFCPDUMP default n help Select this option if you want to build an zfcpdump enabled kernel. - Refer to for more details on this. + Refer to "Documentation/s390/zfcpdump.txt" for more details on this. endmenu diff --git a/trunk/arch/sh64/Kconfig b/trunk/arch/sh64/Kconfig index 6884d5a518ad..ba204bac49df 100644 --- a/trunk/arch/sh64/Kconfig +++ b/trunk/arch/sh64/Kconfig @@ -1,6 +1,6 @@ # # For a description of the syntax of this configuration file, -# see Documentation/kbuild/kconfig-language.txt. +# see Documentation/kbuild/config-language.txt. # mainmenu "Linux/SH64 Kernel Configuration" diff --git a/trunk/arch/sparc/kernel/irq.c b/trunk/arch/sparc/kernel/irq.c index e1e24f31aa54..722d67d32961 100644 --- a/trunk/arch/sparc/kernel/irq.c +++ b/trunk/arch/sparc/kernel/irq.c @@ -479,7 +479,7 @@ EXPORT_SYMBOL(pdma_areasize); extern void floppy_hardint(void); -static irq_handler_t floppy_irq_handler; +static irqreturn_t (*floppy_irq_handler)(int irq, void *dev_id); void sparc_floppy_irq(int irq, void *dev_id, struct pt_regs *regs) { @@ -500,7 +500,7 @@ void sparc_floppy_irq(int irq, void *dev_id, struct pt_regs *regs) } int sparc_floppy_request_irq(int irq, unsigned long flags, - irq_handler_t irq_handler) + irqreturn_t (*irq_handler)(int irq, void *)) { floppy_irq_handler = irq_handler; return request_fast_irq(irq, floppy_hardint, flags, "floppy"); diff --git a/trunk/arch/sparc/kernel/pcic.c b/trunk/arch/sparc/kernel/pcic.c index f2d432edc92d..f2eae457fc9a 100644 --- a/trunk/arch/sparc/kernel/pcic.c +++ b/trunk/arch/sparc/kernel/pcic.c @@ -753,7 +753,7 @@ void __init pci_time_init(void) local_irq_enable(); } -static inline unsigned long do_gettimeoffset(void) +static __inline__ unsigned long do_gettimeoffset(void) { /* * We divide all by 100 diff --git a/trunk/arch/sparc/kernel/process.c b/trunk/arch/sparc/kernel/process.c index 77460e316a03..33f7a3ddb104 100644 --- a/trunk/arch/sparc/kernel/process.c +++ b/trunk/arch/sparc/kernel/process.c @@ -1,6 +1,7 @@ -/* linux/arch/sparc/kernel/process.c +/* $Id: process.c,v 1.161 2002/01/23 11:27:32 davem Exp $ + * linux/arch/sparc/kernel/process.c * - * Copyright (C) 1995 David S. Miller (davem@davemloft.net) + * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be) */ @@ -396,7 +397,7 @@ void flush_thread(void) } } -static inline struct sparc_stackf __user * +static __inline__ struct sparc_stackf __user * clone_stackframe(struct sparc_stackf __user *dst, struct sparc_stackf __user *src) { diff --git a/trunk/arch/sparc/kernel/time.c b/trunk/arch/sparc/kernel/time.c index 45cb7c5286d7..4bf78a5e8e0f 100644 --- a/trunk/arch/sparc/kernel/time.c +++ b/trunk/arch/sparc/kernel/time.c @@ -1,6 +1,7 @@ -/* linux/arch/sparc/kernel/time.c +/* $Id: time.c,v 1.60 2002/01/23 14:33:55 davem Exp $ + * linux/arch/sparc/kernel/time.c * - * Copyright (C) 1995 David S. Miller (davem@davemloft.net) + * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) * Copyright (C) 1996 Thomas K. Dyas (tdyas@eden.rutgers.edu) * * Chris Davis (cdavis@cois.on.ca) 03/27/1998 @@ -209,7 +210,7 @@ static void __devinit kick_start_clock(void) } /* Return nonzero if the clock chip battery is low. */ -static inline int has_low_battery(void) +static __inline__ int has_low_battery(void) { struct mostek48t02 *regs = (struct mostek48t02 *)mstk48t02_regs; unsigned char data1, data2; @@ -251,7 +252,7 @@ static void __devinit mostek_set_system_time(void) } /* Probe for the real time clock chip on Sun4 */ -static inline void sun4_clock_probe(void) +static __inline__ void sun4_clock_probe(void) { #ifdef CONFIG_SUN4 int temp; diff --git a/trunk/arch/sparc/mm/btfixup.c b/trunk/arch/sparc/mm/btfixup.c index a312d127d47a..ec4231c2855a 100644 --- a/trunk/arch/sparc/mm/btfixup.c +++ b/trunk/arch/sparc/mm/btfixup.c @@ -1,4 +1,5 @@ -/* btfixup.c: Boot time code fixup and relocator, so that +/* $Id: btfixup.c,v 1.10 2000/05/09 17:40:13 davem Exp $ + * btfixup.c: Boot time code fixup and relocator, so that * we can get rid of most indirect calls to achieve single * image sun4c and srmmu kernel. * @@ -68,7 +69,7 @@ static void __init set_addr(unsigned int *addr, unsigned int q1, int fmangled, u } } #else -static inline void set_addr(unsigned int *addr, unsigned int q1, int fmangled, unsigned int value) +static __inline__ void set_addr(unsigned int *addr, unsigned int q1, int fmangled, unsigned int value) { *addr = value; } diff --git a/trunk/arch/sparc/mm/io-unit.c b/trunk/arch/sparc/mm/io-unit.c index b86dfce8eee4..1666087c5b80 100644 --- a/trunk/arch/sparc/mm/io-unit.c +++ b/trunk/arch/sparc/mm/io-unit.c @@ -144,7 +144,7 @@ static void iounit_get_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus spin_lock_irqsave(&iounit->lock, flags); while (sz != 0) { --sz; - sg->dvma_address = iounit_get_area(iounit, (unsigned long) sg_virt(sg), sg->length); + sg->dvma_address = iounit_get_area(iounit, sg_virt(sg), sg->length); sg->dvma_length = sg->length; sg = sg_next(sg); } diff --git a/trunk/arch/sparc/mm/sun4c.c b/trunk/arch/sparc/mm/sun4c.c index 0729305f2f59..a2cc141291c7 100644 --- a/trunk/arch/sparc/mm/sun4c.c +++ b/trunk/arch/sparc/mm/sun4c.c @@ -1,6 +1,7 @@ -/* sun4c.c: Doing in software what should be done in hardware. +/* $Id: sun4c.c,v 1.212 2001/12/21 04:56:15 davem Exp $ + * sun4c.c: Doing in software what should be done in hardware. * - * Copyright (C) 1996 David S. Miller (davem@davemloft.net) + * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be) * Copyright (C) 1996 Andrew Tridgell (Andrew.Tridgell@anu.edu.au) * Copyright (C) 1997-2000 Anton Blanchard (anton@samba.org) @@ -718,7 +719,7 @@ static void add_ring(struct sun4c_mmu_ring *ring, ring->num_entries++; } -static inline void add_lru(struct sun4c_mmu_entry *entry) +static __inline__ void add_lru(struct sun4c_mmu_entry *entry) { struct sun4c_mmu_ring *ring = &sun4c_ulru_ring; struct sun4c_mmu_entry *head = &ring->ringhd; @@ -745,7 +746,7 @@ static void add_ring_ordered(struct sun4c_mmu_ring *ring, add_lru(entry); } -static inline void remove_ring(struct sun4c_mmu_ring *ring, +static __inline__ void remove_ring(struct sun4c_mmu_ring *ring, struct sun4c_mmu_entry *entry) { struct sun4c_mmu_entry *next = entry->next; @@ -1835,7 +1836,7 @@ static unsigned long sun4c_pte_to_pgoff(pte_t pte) } -static inline unsigned long sun4c_pmd_page_v(pmd_t pmd) +static __inline__ unsigned long sun4c_pmd_page_v(pmd_t pmd) { return (pmd_val(pmd) & PAGE_MASK); } @@ -1921,7 +1922,7 @@ static void sun4c_free_pgd_fast(pgd_t *pgd) } -static inline pte_t * +static __inline__ pte_t * sun4c_pte_alloc_one_fast(struct mm_struct *mm, unsigned long address) { unsigned long *ret; @@ -1955,7 +1956,7 @@ static struct page *sun4c_pte_alloc_one(struct mm_struct *mm, unsigned long addr return virt_to_page(pte); } -static inline void sun4c_free_pte_fast(pte_t *pte) +static __inline__ void sun4c_free_pte_fast(pte_t *pte) { *(unsigned long *)pte = (unsigned long) pte_quicklist; pte_quicklist = (unsigned long *) pte; diff --git a/trunk/arch/sparc64/Kconfig b/trunk/arch/sparc64/Kconfig index bd59ab0760b3..03c4e5c1b94a 100644 --- a/trunk/arch/sparc64/Kconfig +++ b/trunk/arch/sparc64/Kconfig @@ -460,6 +460,8 @@ source "drivers/Kconfig" source "drivers/sbus/char/Kconfig" +source "drivers/fc4/Kconfig" + source "fs/Kconfig" source "kernel/Kconfig.instrumentation" diff --git a/trunk/arch/sparc64/kernel/binfmt_elf32.c b/trunk/arch/sparc64/kernel/binfmt_elf32.c index 1587a29a4b0e..9ad84ff10a17 100644 --- a/trunk/arch/sparc64/kernel/binfmt_elf32.c +++ b/trunk/arch/sparc64/kernel/binfmt_elf32.c @@ -1,7 +1,7 @@ /* * binfmt_elf32.c: Support 32-bit Sparc ELF binaries on Ultra. * - * Copyright (C) 1995, 1996, 1997, 1998 David S. Miller (davem@davemloft.net) + * Copyright (C) 1995, 1996, 1997, 1998 David S. Miller (davem@redhat.com) * Copyright (C) 1995, 1996, 1997, 1998 Jakub Jelinek (jj@ultra.linux.cz) */ @@ -133,7 +133,7 @@ struct elf_prpsinfo32 #undef cputime_to_timeval #define cputime_to_timeval cputime_to_compat_timeval -static inline void +static __inline__ void cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value) { unsigned long jiffies = cputime_to_jiffies(cputime); diff --git a/trunk/arch/sparc64/kernel/central.c b/trunk/arch/sparc64/kernel/central.c index b61b8dfb09cf..8230099f0d8a 100644 --- a/trunk/arch/sparc64/kernel/central.c +++ b/trunk/arch/sparc64/kernel/central.c @@ -1,6 +1,7 @@ -/* central.c: Central FHC driver for Sunfire/Starfire/Wildfire. +/* $Id: central.c,v 1.15 2001/12/19 00:29:51 davem Exp $ + * central.c: Central FHC driver for Sunfire/Starfire/Wildfire. * - * Copyright (C) 1997, 1999 David S. Miller (davem@davemloft.net) + * Copyright (C) 1997, 1999 David S. Miller (davem@redhat.com) */ #include @@ -384,7 +385,7 @@ void __init central_probe(void) init_all_fhc_hw(); } -static inline void fhc_ledblink(struct linux_fhc *fhc, int on) +static __inline__ void fhc_ledblink(struct linux_fhc *fhc, int on) { u32 tmp; @@ -401,7 +402,7 @@ static inline void fhc_ledblink(struct linux_fhc *fhc, int on) upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_CTRL); } -static inline void central_ledblink(struct linux_central *central, int on) +static __inline__ void central_ledblink(struct linux_central *central, int on) { u8 tmp; diff --git a/trunk/arch/sparc64/kernel/iommu_common.c b/trunk/arch/sparc64/kernel/iommu_common.c index efd5dff85f60..b70324e0d83d 100644 --- a/trunk/arch/sparc64/kernel/iommu_common.c +++ b/trunk/arch/sparc64/kernel/iommu_common.c @@ -234,7 +234,7 @@ unsigned long prepare_sg(struct scatterlist *sg, int nents) dma_sg->dma_length = dent_len; if (dma_sg != sg) { - dma_sg = sg_next(dma_sg); + dma_sg = next_sg(dma_sg); dma_sg->dma_length = 0; } diff --git a/trunk/arch/sparc64/kernel/ldc.c b/trunk/arch/sparc64/kernel/ldc.c index 217478a94128..c8313cb60f0a 100644 --- a/trunk/arch/sparc64/kernel/ldc.c +++ b/trunk/arch/sparc64/kernel/ldc.c @@ -2121,7 +2121,7 @@ int ldc_map_sg(struct ldc_channel *lp, state.nc = 0; for (i = 0; i < num_sg; i++) - fill_cookies(&state, page_to_pfn(sg_page(&sg[i])) << PAGE_SHIFT, + fill_cookies(&state, page_to_pfn(sg[i].page) << PAGE_SHIFT, sg[i].offset, sg[i].length); return state.nc; diff --git a/trunk/arch/sparc64/kernel/semaphore.c b/trunk/arch/sparc64/kernel/semaphore.c index 9974a6899551..a809e63f03ef 100644 --- a/trunk/arch/sparc64/kernel/semaphore.c +++ b/trunk/arch/sparc64/kernel/semaphore.c @@ -1,4 +1,5 @@ -/* semaphore.c: Sparc64 semaphore implementation. +/* $Id: semaphore.c,v 1.9 2001/11/18 00:12:56 davem Exp $ + * semaphore.c: Sparc64 semaphore implementation. * * This is basically the PPC semaphore scheme ported to use * the sparc64 atomic instructions, so see the PPC code for @@ -18,7 +19,7 @@ * sem->count = tmp; * return old_count; */ -static inline int __sem_update_count(struct semaphore *sem, int incr) +static __inline__ int __sem_update_count(struct semaphore *sem, int incr) { int old_count, tmp; diff --git a/trunk/arch/sparc64/kernel/smp.c b/trunk/arch/sparc64/kernel/smp.c index 7cd8d94df0dc..407d74a8a542 100644 --- a/trunk/arch/sparc64/kernel/smp.c +++ b/trunk/arch/sparc64/kernel/smp.c @@ -459,7 +459,7 @@ static void spitfire_xcall_helper(u64 data0, u64 data1, u64 data2, u64 pstate, u } } -static inline void spitfire_xcall_deliver(u64 data0, u64 data1, u64 data2, cpumask_t mask) +static __inline__ void spitfire_xcall_deliver(u64 data0, u64 data1, u64 data2, cpumask_t mask) { u64 pstate; int i; @@ -906,7 +906,7 @@ extern atomic_t dcpage_flushes; extern atomic_t dcpage_flushes_xcall; #endif -static inline void __local_flush_dcache_page(struct page *page) +static __inline__ void __local_flush_dcache_page(struct page *page) { #ifdef DCACHE_ALIASING_POSSIBLE __flush_dcache_page(page_address(page), diff --git a/trunk/arch/sparc64/kernel/sys_sparc.c b/trunk/arch/sparc64/kernel/sys_sparc.c index c56573a10eee..560cb1edb1d0 100644 --- a/trunk/arch/sparc64/kernel/sys_sparc.c +++ b/trunk/arch/sparc64/kernel/sys_sparc.c @@ -318,7 +318,7 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u if (flags & MAP_FIXED) { /* Ok, don't mess with it. */ - return get_unmapped_area(NULL, orig_addr, len, pgoff, flags); + return get_unmapped_area(NULL, addr, len, pgoff, flags); } flags &= ~MAP_SHARED; diff --git a/trunk/arch/sparc64/kernel/traps.c b/trunk/arch/sparc64/kernel/traps.c index 04998388259f..e9c7e4f07abf 100644 --- a/trunk/arch/sparc64/kernel/traps.c +++ b/trunk/arch/sparc64/kernel/traps.c @@ -1,6 +1,7 @@ -/* arch/sparc64/kernel/traps.c +/* $Id: traps.c,v 1.85 2002/02/09 19:49:31 davem Exp $ + * arch/sparc64/kernel/traps.c * - * Copyright (C) 1995,1997 David S. Miller (davem@davemloft.net) + * Copyright (C) 1995,1997 David S. Miller (davem@caip.rutgers.edu) * Copyright (C) 1997,1999,2000 Jakub Jelinek (jakub@redhat.com) */ @@ -764,7 +765,7 @@ static unsigned long cheetah_afsr_errors; */ struct cheetah_err_info *cheetah_error_log; -static inline struct cheetah_err_info *cheetah_get_error_log(unsigned long afsr) +static __inline__ struct cheetah_err_info *cheetah_get_error_log(unsigned long afsr) { struct cheetah_err_info *p; int cpu = smp_processor_id(); @@ -1084,7 +1085,7 @@ static unsigned char cheetah_mtag_syntab[] = { }; /* Return the highest priority error conditon mentioned. */ -static inline unsigned long cheetah_get_hipri(unsigned long afsr) +static __inline__ unsigned long cheetah_get_hipri(unsigned long afsr) { unsigned long tmp = 0; int i; diff --git a/trunk/arch/sparc64/mm/init.c b/trunk/arch/sparc64/mm/init.c index e18ccf85224f..100c4456ed1e 100644 --- a/trunk/arch/sparc64/mm/init.c +++ b/trunk/arch/sparc64/mm/init.c @@ -201,7 +201,7 @@ inline void flush_dcache_page_impl(struct page *page) #define dcache_dirty_cpu(page) \ (((page)->flags >> PG_dcache_cpu_shift) & PG_dcache_cpu_mask) -static inline void set_dcache_dirty(struct page *page, int this_cpu) +static __inline__ void set_dcache_dirty(struct page *page, int this_cpu) { unsigned long mask = this_cpu; unsigned long non_cpu_bits; @@ -223,7 +223,7 @@ static inline void set_dcache_dirty(struct page *page, int this_cpu) : "g1", "g7"); } -static inline void clear_dcache_dirty_cpu(struct page *page, unsigned long cpu) +static __inline__ void clear_dcache_dirty_cpu(struct page *page, unsigned long cpu) { unsigned long mask = (1UL << PG_dcache_dirty); diff --git a/trunk/arch/sparc64/prom/console.c b/trunk/arch/sparc64/prom/console.c index e1c3fc87484d..3fafa9a8b50b 100644 --- a/trunk/arch/sparc64/prom/console.c +++ b/trunk/arch/sparc64/prom/console.c @@ -1,7 +1,8 @@ -/* console.c: Routines that deal with sending and receiving IO +/* $Id: console.c,v 1.9 1997/10/29 07:41:43 ecd Exp $ + * console.c: Routines that deal with sending and receiving IO * to/from the current console device using the PROM. * - * Copyright (C) 1995 David S. Miller (davem@davemloft.net) + * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz) */ @@ -18,7 +19,7 @@ extern int prom_stdin, prom_stdout; /* Non blocking get character from console input device, returns -1 * if no input was taken. This can be used for polling. */ -inline int +__inline__ int prom_nbgetchar(void) { char inc; @@ -34,7 +35,7 @@ prom_nbgetchar(void) /* Non blocking put character to console device, returns -1 if * unsuccessful. */ -inline int +__inline__ int prom_nbputchar(char c) { char outc; diff --git a/trunk/arch/sparc64/prom/tree.c b/trunk/arch/sparc64/prom/tree.c index a99ccd7fb1b0..b2c5b12c9818 100644 --- a/trunk/arch/sparc64/prom/tree.c +++ b/trunk/arch/sparc64/prom/tree.c @@ -18,12 +18,14 @@ /* Return the child of node 'node' or zero if no this node has no * direct descendent. */ -inline int __prom_getchild(int node) +__inline__ int +__prom_getchild(int node) { return p1275_cmd ("child", P1275_INOUT(1, 1), node); } -inline int prom_getchild(int node) +__inline__ int +prom_getchild(int node) { int cnode; @@ -33,7 +35,8 @@ inline int prom_getchild(int node) return (int)cnode; } -inline int prom_getparent(int node) +__inline__ int +prom_getparent(int node) { int cnode; @@ -46,12 +49,14 @@ inline int prom_getparent(int node) /* Return the next sibling of node 'node' or zero if no more siblings * at this level of depth in the tree. */ -inline int __prom_getsibling(int node) +__inline__ int +__prom_getsibling(int node) { return p1275_cmd(prom_peer_name, P1275_INOUT(1, 1), node); } -inline int prom_getsibling(int node) +__inline__ int +prom_getsibling(int node) { int sibnode; @@ -67,7 +72,8 @@ inline int prom_getsibling(int node) /* Return the length in bytes of property 'prop' at node 'node'. * Return -1 on error. */ -inline int prom_getproplen(int node, const char *prop) +__inline__ int +prom_getproplen(int node, const char *prop) { if((!node) || (!prop)) return -1; return p1275_cmd ("getproplen", @@ -80,8 +86,8 @@ inline int prom_getproplen(int node, const char *prop) * 'buffer' which has a size of 'bufsize'. If the acquisition * was successful the length will be returned, else -1 is returned. */ -inline int prom_getproperty(int node, const char *prop, - char *buffer, int bufsize) +__inline__ int +prom_getproperty(int node, const char *prop, char *buffer, int bufsize) { int plen; @@ -101,7 +107,8 @@ inline int prom_getproperty(int node, const char *prop, /* Acquire an integer property and return its value. Returns -1 * on failure. */ -inline int prom_getint(int node, const char *prop) +__inline__ int +prom_getint(int node, const char *prop) { int intprop; @@ -115,7 +122,8 @@ inline int prom_getint(int node, const char *prop) * integer. */ -int prom_getintdefault(int node, const char *property, int deflt) +int +prom_getintdefault(int node, const char *property, int deflt) { int retval; @@ -126,7 +134,8 @@ int prom_getintdefault(int node, const char *property, int deflt) } /* Acquire a boolean property, 1=TRUE 0=FALSE. */ -int prom_getbool(int node, const char *prop) +int +prom_getbool(int node, const char *prop) { int retval; @@ -139,7 +148,8 @@ int prom_getbool(int node, const char *prop) * string on error. The char pointer is the user supplied string * buffer. */ -void prom_getstring(int node, const char *prop, char *user_buf, int ubuf_size) +void +prom_getstring(int node, const char *prop, char *user_buf, int ubuf_size) { int len; @@ -153,7 +163,8 @@ void prom_getstring(int node, const char *prop, char *user_buf, int ubuf_size) /* Does the device at node 'node' have name 'name'? * YES = 1 NO = 0 */ -int prom_nodematch(int node, const char *name) +int +prom_nodematch(int node, const char *name) { char namebuf[128]; prom_getproperty(node, "name", namebuf, sizeof(namebuf)); @@ -164,7 +175,8 @@ int prom_nodematch(int node, const char *name) /* Search siblings at 'node_start' for a node with name * 'nodename'. Return node if successful, zero if not. */ -int prom_searchsiblings(int node_start, const char *nodename) +int +prom_searchsiblings(int node_start, const char *nodename) { int thisnode, error; @@ -185,7 +197,8 @@ int prom_searchsiblings(int node_start, const char *nodename) /* Return the first property type for node 'node'. * buffer should be at least 32B in length */ -inline char *prom_firstprop(int node, char *buffer) +__inline__ char * +prom_firstprop(int node, char *buffer) { *buffer = 0; if(node == -1) return buffer; @@ -199,7 +212,8 @@ inline char *prom_firstprop(int node, char *buffer) * at node 'node' . Returns NULL string if no more * property types for this node. */ -inline char *prom_nextprop(int node, const char *oprop, char *buffer) +__inline__ char * +prom_nextprop(int node, const char *oprop, char *buffer) { char buf[32]; @@ -265,7 +279,8 @@ prom_setprop(int node, const char *pname, char *value, int size) node, pname, value, P1275_SIZE(size)); } -inline int prom_inst2pkg(int inst) +__inline__ int +prom_inst2pkg(int inst) { int node; diff --git a/trunk/arch/um/Kconfig.i386 b/trunk/arch/um/Kconfig.i386 index e0ac74e5d4c4..9876d80d85dd 100644 --- a/trunk/arch/um/Kconfig.i386 +++ b/trunk/arch/um/Kconfig.i386 @@ -1,6 +1,6 @@ menu "Host processor type and features" -source "arch/x86/Kconfig.cpu" +source "arch/i386/Kconfig.cpu" endmenu diff --git a/trunk/arch/um/Makefile-i386 b/trunk/arch/um/Makefile-i386 index b01dfb00e5f8..0178df306939 100644 --- a/trunk/arch/um/Makefile-i386 +++ b/trunk/arch/um/Makefile-i386 @@ -9,7 +9,6 @@ ELF_ARCH := $(SUBARCH) ELF_FORMAT := elf32-$(SUBARCH) OBJCOPYFLAGS := -O binary -R .note -R .comment -S HEADER_ARCH := x86 -CHECKFLAGS += -D__i386__ ifeq ("$(origin SUBARCH)", "command line") ifneq ("$(shell uname -m | sed -e s/i.86/i386/)", "$(SUBARCH)") @@ -27,8 +26,10 @@ AFLAGS += -DCONFIG_X86_32 CONFIG_X86_32 := y export CONFIG_X86_32 +ARCH_KERNEL_DEFINES += -U__$(SUBARCH)__ -U$(SUBARCH) + # First of all, tune CFLAGS for the specific CPU. This actually sets cflags-y. -include $(srctree)/arch/x86/Makefile_32.cpu +include $(srctree)/arch/i386/Makefile.cpu # prevent gcc from keeping the stack 16 byte aligned. Taken from i386. cflags-y += $(call cc-option,-mpreferred-stack-boundary=2) diff --git a/trunk/arch/um/Makefile-x86_64 b/trunk/arch/um/Makefile-x86_64 index 8ed362f93582..fe5316f0c6a5 100644 --- a/trunk/arch/um/Makefile-x86_64 +++ b/trunk/arch/um/Makefile-x86_64 @@ -6,9 +6,12 @@ START := 0x60000000 _extra_flags_ = -fno-builtin -m64 +#We #undef __x86_64__ for kernelspace, not for userspace where +#it's needed for headers to work! +ARCH_KERNEL_DEFINES = -U__$(SUBARCH)__ KBUILD_CFLAGS += $(_extra_flags_) -CHECKFLAGS += -m64 -D__x86_64__ +CHECKFLAGS += -m64 KBUILD_AFLAGS += -m64 LDFLAGS += -m elf_x86_64 KBUILD_CPPFLAGS += -m64 diff --git a/trunk/arch/um/drivers/ubd_kern.c b/trunk/arch/um/drivers/ubd_kern.c index e184b44b1011..3a8cd3dfb51c 100644 --- a/trunk/arch/um/drivers/ubd_kern.c +++ b/trunk/arch/um/drivers/ubd_kern.c @@ -35,7 +35,6 @@ #include "linux/genhd.h" #include "linux/spinlock.h" #include "linux/platform_device.h" -#include "linux/scatterlist.h" #include "asm/segment.h" #include "asm/uaccess.h" #include "asm/irq.h" @@ -705,7 +704,6 @@ static int ubd_add(int n, char **error_out) ubd_dev->size = ROUND_BLOCK(ubd_dev->size); INIT_LIST_HEAD(&ubd_dev->restart); - sg_init_table(&ubd_dev->sg, MAX_SG); err = -ENOMEM; ubd_dev->queue = blk_init_queue(do_ubd_request, &ubd_dev->lock); diff --git a/trunk/arch/um/kernel/mem.c b/trunk/arch/um/kernel/mem.c index 59822dee438a..8456397f5f4d 100644 --- a/trunk/arch/um/kernel/mem.c +++ b/trunk/arch/um/kernel/mem.c @@ -165,7 +165,7 @@ static void __init kmap_init(void) kmap_prot = PAGE_KERNEL; } -static void __init init_highmem(void) +static void init_highmem(void) { pgd_t *pgd; pud_t *pud; diff --git a/trunk/arch/um/sys-i386/ptrace.c b/trunk/arch/um/sys-i386/ptrace.c index bd3da8a61f64..9657c89fdf31 100644 --- a/trunk/arch/um/sys-i386/ptrace.c +++ b/trunk/arch/um/sys-i386/ptrace.c @@ -155,7 +155,7 @@ int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) if (err) return err; - n = copy_to_user(buf, fpregs, sizeof(fpregs)); + n = copy_to_user((void *) buf, fpregs, sizeof(fpregs)); if(n > 0) return -EFAULT; @@ -168,7 +168,7 @@ int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) long fpregs[HOST_FP_SIZE]; BUG_ON(sizeof(*buf) != sizeof(fpregs)); - n = copy_from_user(fpregs, buf, sizeof(fpregs)); + n = copy_from_user(fpregs, (void *) buf, sizeof(fpregs)); if (n > 0) return -EFAULT; @@ -185,7 +185,7 @@ int get_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child) if (err) return err; - n = copy_to_user(buf, fpregs, sizeof(fpregs)); + n = copy_to_user((void *) buf, fpregs, sizeof(fpregs)); if(n > 0) return -EFAULT; @@ -198,7 +198,7 @@ int set_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child) long fpregs[HOST_XFP_SIZE]; BUG_ON(sizeof(*buf) != sizeof(fpregs)); - n = copy_from_user(fpregs, buf, sizeof(fpregs)); + n = copy_from_user(fpregs, (void *) buf, sizeof(fpregs)); if (n > 0) return -EFAULT; diff --git a/trunk/arch/um/sys-x86_64/ptrace.c b/trunk/arch/um/sys-x86_64/ptrace.c index b7631b0e9ddc..a3cfeed17af4 100644 --- a/trunk/arch/um/sys-x86_64/ptrace.c +++ b/trunk/arch/um/sys-x86_64/ptrace.c @@ -154,7 +154,7 @@ int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) if (err) return err; - n = copy_to_user(buf, fpregs, sizeof(fpregs)); + n = copy_to_user((void *) buf, fpregs, sizeof(fpregs)); if(n > 0) return -EFAULT; @@ -167,7 +167,7 @@ int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) long fpregs[HOST_FP_SIZE]; BUG_ON(sizeof(*buf) != sizeof(fpregs)); - n = copy_from_user(fpregs, buf, sizeof(fpregs)); + n = copy_from_user(fpregs, (void *) buf, sizeof(fpregs)); if (n > 0) return -EFAULT; diff --git a/trunk/arch/x86/Makefile b/trunk/arch/x86/Makefile deleted file mode 100644 index 309597386a77..000000000000 --- a/trunk/arch/x86/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# Unified Makefile for i386 and x86_64 - -# select defconfig based on actual architecture -KBUILD_DEFCONFIG := $(ARCH)_defconfig - -# # No need to remake these files -$(srctree)/arch/x86/Makefile%: ; - -ifeq ($(ARCH),i386) - include $(srctree)/arch/x86/Makefile_32 -else - include $(srctree)/arch/x86/Makefile_64 -endif - - - diff --git a/trunk/arch/x86/boot/boot.h b/trunk/arch/x86/boot/boot.h index d2b5adf46512..20bab9431acb 100644 --- a/trunk/arch/x86/boot/boot.h +++ b/trunk/arch/x86/boot/boot.h @@ -17,15 +17,13 @@ #ifndef BOOT_BOOT_H #define BOOT_BOOT_H -#define STACK_SIZE 512 /* Minimum number of bytes for stack */ - #ifndef __ASSEMBLY__ #include #include #include #include -#include +#include /* Useful macros */ #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) @@ -200,6 +198,8 @@ static inline int isdigit(int ch) } /* Heap -- available for dynamic lists. */ +#define STACK_SIZE 512 /* Minimum number of bytes for stack */ + extern char _end[]; extern char *HEAP; extern char *heap_end; @@ -216,9 +216,9 @@ static inline char *__get_heap(size_t s, size_t a, size_t n) #define GET_HEAP(type, n) \ ((type *)__get_heap(sizeof(type),__alignof__(type),(n))) -static inline bool heap_free(size_t n) +static inline int heap_free(void) { - return (int)(heap_end-HEAP) >= (int)n; + return heap_end-HEAP; } /* copy.S */ diff --git a/trunk/arch/x86/boot/compressed/head_32.S b/trunk/arch/x86/boot/compressed/head_32.S index 036e635f18a3..a0ae2e7f6cec 100644 --- a/trunk/arch/x86/boot/compressed/head_32.S +++ b/trunk/arch/x86/boot/compressed/head_32.S @@ -33,20 +33,24 @@ .globl startup_32 startup_32: - cld + /* check to see if KEEP_SEGMENTS flag is meaningful */ + cmpw $0x207, BP_version(%esi) + jb 1f + /* test KEEP_SEGMENTS flag to see if the bootloader is asking * us to not reload segments */ testb $(1<<6), BP_loadflags(%esi) - jnz 1f + jnz 2f - cli +1: cli movl $(__BOOT_DS),%eax movl %eax,%ds movl %eax,%es movl %eax,%fs movl %eax,%gs movl %eax,%ss -1: + +2: cld /* Calculate the delta between where we were compiled to run * at and where we were actually loaded at. This can only be done diff --git a/trunk/arch/x86/boot/compressed/head_64.S b/trunk/arch/x86/boot/compressed/head_64.S index 1ccb38a7f0d2..49467640751f 100644 --- a/trunk/arch/x86/boot/compressed/head_64.S +++ b/trunk/arch/x86/boot/compressed/head_64.S @@ -29,7 +29,6 @@ #include #include #include -#include .section ".text.head" .code32 @@ -37,17 +36,11 @@ startup_32: cld - /* test KEEP_SEGMENTS flag to see if the bootloader is asking - * us to not reload segments */ - testb $(1<<6), BP_loadflags(%esi) - jnz 1f - cli movl $(__KERNEL_DS), %eax movl %eax, %ds movl %eax, %es movl %eax, %ss -1: /* Calculate the delta between where we were compiled to run * at and where we were actually loaded at. This can only be done diff --git a/trunk/arch/x86/boot/compressed/relocs.c b/trunk/arch/x86/boot/compressed/relocs.c index 7a0d00b2cf28..2d77ee728f92 100644 --- a/trunk/arch/x86/boot/compressed/relocs.c +++ b/trunk/arch/x86/boot/compressed/relocs.c @@ -38,9 +38,11 @@ static const char* safe_abs_relocs[] = { static int is_safe_abs_reloc(const char* sym_name) { - int i; + int i, array_size; + + array_size = sizeof(safe_abs_relocs)/sizeof(char*); - for(i = 0; i < ARRAY_SIZE(safe_abs_relocs); i++) { + for(i = 0; i < array_size; i++) { if (!strcmp(sym_name, safe_abs_relocs[i])) /* Match found */ return 1; diff --git a/trunk/arch/x86/boot/header.S b/trunk/arch/x86/boot/header.S index 6ef5a060fa11..8353c81c41c0 100644 --- a/trunk/arch/x86/boot/header.S +++ b/trunk/arch/x86/boot/header.S @@ -173,8 +173,7 @@ ramdisk_size: .long 0 # its size in bytes bootsect_kludge: .long 0 # obsolete -heap_end_ptr: .word _end+STACK_SIZE-512 - # (Header version 0x0201 or later) +heap_end_ptr: .word _end+1024 # (Header version 0x0201 or later) # space from here (exclusive) down to # end of setup code can be used by setup # for local heap purposes. @@ -231,53 +230,28 @@ start_of_setup: int $0x13 #endif +# We will have entered with %cs = %ds+0x20, normalize %cs so +# it is on par with the other segments. + pushw %ds + pushw $setup2 + lretw + +setup2: # Force %es = %ds movw %ds, %ax movw %ax, %es cld -# Apparently some ancient versions of LILO invoked the kernel -# with %ss != %ds, which happened to work by accident for the -# old code. If the CAN_USE_HEAP flag is set in loadflags, or -# %ss != %ds, then adjust the stack pointer. - - # Smallest possible stack we can tolerate - movw $(_end+STACK_SIZE), %cx - - movw heap_end_ptr, %dx - addw $512, %dx - jnc 1f - xorw %dx, %dx # Wraparound - whole segment available -1: testb $CAN_USE_HEAP, loadflags - jnz 2f - - # No CAN_USE_HEAP - movw %ss, %dx - cmpw %ax, %dx # %ds == %ss? - movw %sp, %dx - # If so, assume %sp is reasonably set, otherwise use - # the smallest possible stack. - jne 4f # -> Smallest possible stack... - - # Make sure the stack is at least minimum size. Take a value - # of zero to mean "full segment." -2: - andw $~3, %dx # dword align (might as well...) - jnz 3f - movw $0xfffc, %dx # Make sure we're not zero -3: cmpw %cx, %dx - jnb 5f -4: movw %cx, %dx # Minimum value we can possibly use -5: movw %ax, %ss - movzwl %dx, %esp # Clear upper half of %esp - sti # Now we should have a working stack - -# We will have entered with %cs = %ds+0x20, normalize %cs so -# it is on par with the other segments. - pushw %ds - pushw $6f - lretw -6: +# Stack paranoia: align the stack and make sure it is good +# for both 16- and 32-bit references. In particular, if we +# were meant to have been using the full 16-bit segment, the +# caller might have set %sp to zero, which breaks %esp-based +# references. + andw $~3, %sp # dword align (might as well...) + jnz 1f + movw $0xfffc, %sp # Make sure we're not zero +1: movzwl %sp, %esp # Clear upper half of %esp + sti # Check signature at end of setup cmpl $0x5a5aaa55, setup_sig diff --git a/trunk/arch/x86/boot/main.c b/trunk/arch/x86/boot/main.c index 1f95750ede28..0eeef3989a17 100644 --- a/trunk/arch/x86/boot/main.c +++ b/trunk/arch/x86/boot/main.c @@ -26,6 +26,8 @@ char *heap_end = _end; /* Default end of heap = no heap */ * screws up the old-style command line protocol, adjust by * filling in the new-style command line pointer instead. */ +#define OLD_CL_MAGIC 0xA33F +#define OLD_CL_ADDRESS 0x20 static void copy_boot_params(void) { diff --git a/trunk/arch/x86/boot/video-bios.c b/trunk/arch/x86/boot/video-bios.c index ed0672a81870..68e65d95cdfd 100644 --- a/trunk/arch/x86/boot/video-bios.c +++ b/trunk/arch/x86/boot/video-bios.c @@ -79,7 +79,7 @@ static int bios_probe(void) video_bios.modes = GET_HEAP(struct mode_info, 0); for (mode = 0x14; mode <= 0x7f; mode++) { - if (!heap_free(sizeof(struct mode_info))) + if (heap_free() < sizeof(struct mode_info)) break; if (mode_defined(VIDEO_FIRST_BIOS+mode)) diff --git a/trunk/arch/x86/boot/video-vesa.c b/trunk/arch/x86/boot/video-vesa.c index 4716b9a96357..192190710710 100644 --- a/trunk/arch/x86/boot/video-vesa.c +++ b/trunk/arch/x86/boot/video-vesa.c @@ -57,7 +57,7 @@ static int vesa_probe(void) while ((mode = rdfs16(mode_ptr)) != 0xffff) { mode_ptr += 2; - if (!heap_free(sizeof(struct mode_info))) + if (heap_free() < sizeof(struct mode_info)) break; /* Heap full, can't save mode info */ if (mode & ~0x1ff) diff --git a/trunk/arch/x86/boot/video.c b/trunk/arch/x86/boot/video.c index ad9712f01739..e4ba897bf9a3 100644 --- a/trunk/arch/x86/boot/video.c +++ b/trunk/arch/x86/boot/video.c @@ -371,7 +371,7 @@ static void save_screen(void) saved.curx = boot_params.screen_info.orig_x; saved.cury = boot_params.screen_info.orig_y; - if (!heap_free(saved.x*saved.y*sizeof(u16)+512)) + if (heap_free() < saved.x*saved.y*sizeof(u16)+512) return; /* Not enough heap to save the screen */ saved.data = GET_HEAP(u16, saved.x*saved.y); diff --git a/trunk/arch/x86/crypto/Makefile b/trunk/arch/x86/crypto/Makefile index 46bb609e2444..18dcdc6fb7aa 100644 --- a/trunk/arch/x86/crypto/Makefile +++ b/trunk/arch/x86/crypto/Makefile @@ -1,15 +1,5 @@ -# -# Arch-specific CryptoAPI modules. -# - -obj-$(CONFIG_CRYPTO_AES_586) += aes-i586.o -obj-$(CONFIG_CRYPTO_TWOFISH_586) += twofish-i586.o - -obj-$(CONFIG_CRYPTO_AES_X86_64) += aes-x86_64.o -obj-$(CONFIG_CRYPTO_TWOFISH_X86_64) += twofish-x86_64.o - -aes-i586-y := aes-i586-asm_32.o aes_32.o -twofish-i586-y := twofish-i586-asm_32.o twofish_32.o - -aes-x86_64-y := aes-x86_64-asm_64.o aes_64.o -twofish-x86_64-y := twofish-x86_64-asm_64.o twofish_64.o +ifeq ($(CONFIG_X86_32),y) +include ${srctree}/arch/x86/crypto/Makefile_32 +else +include ${srctree}/arch/x86/crypto/Makefile_64 +endif diff --git a/trunk/arch/x86/crypto/Makefile_32 b/trunk/arch/x86/crypto/Makefile_32 new file mode 100644 index 000000000000..2d873a2388ed --- /dev/null +++ b/trunk/arch/x86/crypto/Makefile_32 @@ -0,0 +1,12 @@ +# +# x86/crypto/Makefile +# +# Arch-specific CryptoAPI modules. +# + +obj-$(CONFIG_CRYPTO_AES_586) += aes-i586.o +obj-$(CONFIG_CRYPTO_TWOFISH_586) += twofish-i586.o + +aes-i586-y := aes-i586-asm_32.o aes_32.o +twofish-i586-y := twofish-i586-asm_32.o twofish_32.o + diff --git a/trunk/arch/x86/crypto/Makefile_64 b/trunk/arch/x86/crypto/Makefile_64 new file mode 100644 index 000000000000..b40896276e93 --- /dev/null +++ b/trunk/arch/x86/crypto/Makefile_64 @@ -0,0 +1,12 @@ +# +# x86/crypto/Makefile +# +# Arch-specific CryptoAPI modules. +# + +obj-$(CONFIG_CRYPTO_AES_X86_64) += aes-x86_64.o +obj-$(CONFIG_CRYPTO_TWOFISH_X86_64) += twofish-x86_64.o + +aes-x86_64-y := aes-x86_64-asm_64.o aes_64.o +twofish-x86_64-y := twofish-x86_64-asm_64.o twofish_64.o + diff --git a/trunk/arch/x86/kernel/Makefile_32 b/trunk/arch/x86/kernel/Makefile_32 index b9d679820306..ccea590bbb92 100644 --- a/trunk/arch/x86/kernel/Makefile_32 +++ b/trunk/arch/x86/kernel/Makefile_32 @@ -26,7 +26,7 @@ obj-$(CONFIG_X86_MPPARSE) += mpparse_32.o obj-$(CONFIG_X86_LOCAL_APIC) += apic_32.o nmi_32.o obj-$(CONFIG_X86_IO_APIC) += io_apic_32.o obj-$(CONFIG_X86_REBOOTFIXUPS) += reboot_fixups_32.o -obj-$(CONFIG_KEXEC) += machine_kexec_32.o relocate_kernel_32.o crash.o +obj-$(CONFIG_KEXEC) += machine_kexec_32.o relocate_kernel_32.o crash_32.o obj-$(CONFIG_CRASH_DUMP) += crash_dump_32.o obj-$(CONFIG_X86_NUMAQ) += numaq_32.o obj-$(CONFIG_X86_SUMMIT_NUMA) += summit_32.o diff --git a/trunk/arch/x86/kernel/Makefile_64 b/trunk/arch/x86/kernel/Makefile_64 index 24671c3838b3..dec06e769281 100644 --- a/trunk/arch/x86/kernel/Makefile_64 +++ b/trunk/arch/x86/kernel/Makefile_64 @@ -9,23 +9,27 @@ obj-y := process_64.o signal_64.o entry_64.o traps_64.o irq_64.o \ x8664_ksyms_64.o i387_64.o syscall_64.o vsyscall_64.o \ setup64.o bootflag.o e820_64.o reboot_64.o quirks.o i8237.o \ pci-dma_64.o pci-nommu_64.o alternative.o hpet.o tsc_64.o bugs_64.o \ - i8253.o + perfctr-watchdog.o i8253.o obj-$(CONFIG_STACKTRACE) += stacktrace.o -obj-y += cpu/ -obj-y += acpi/ +obj-$(CONFIG_X86_MCE) += mce_64.o therm_throt.o +obj-$(CONFIG_X86_MCE_INTEL) += mce_intel_64.o +obj-$(CONFIG_X86_MCE_AMD) += mce_amd_64.o +obj-$(CONFIG_MTRR) += cpu/mtrr/ +obj-$(CONFIG_ACPI) += acpi/ obj-$(CONFIG_X86_MSR) += msr.o obj-$(CONFIG_MICROCODE) += microcode.o obj-$(CONFIG_X86_CPUID) += cpuid.o obj-$(CONFIG_SMP) += smp_64.o smpboot_64.o trampoline_64.o tsc_sync.o obj-y += apic_64.o nmi_64.o obj-y += io_apic_64.o mpparse_64.o genapic_64.o genapic_flat_64.o -obj-$(CONFIG_KEXEC) += machine_kexec_64.o relocate_kernel_64.o crash.o +obj-$(CONFIG_KEXEC) += machine_kexec_64.o relocate_kernel_64.o crash_64.o obj-$(CONFIG_CRASH_DUMP) += crash_dump_64.o obj-$(CONFIG_PM) += suspend_64.o obj-$(CONFIG_HIBERNATION) += suspend_asm_64.o +obj-$(CONFIG_CPU_FREQ) += cpu/cpufreq/ obj-$(CONFIG_EARLY_PRINTK) += early_printk.o -obj-$(CONFIG_GART_IOMMU) += pci-gart_64.o aperture_64.o +obj-$(CONFIG_IOMMU) += pci-gart_64.o aperture_64.o obj-$(CONFIG_CALGARY_IOMMU) += pci-calgary_64.o tce_64.o obj-$(CONFIG_SWIOTLB) += pci-swiotlb_64.o obj-$(CONFIG_KPROBES) += kprobes_64.o @@ -38,6 +42,13 @@ obj-$(CONFIG_MODULES) += module_64.o obj-$(CONFIG_PCI) += early-quirks.o obj-y += topology.o +obj-y += intel_cacheinfo.o +obj-y += addon_cpuid_features.o obj-y += pcspeaker.o CFLAGS_vsyscall_64.o := $(PROFILING) -g0 + +therm_throt-y += cpu/mcheck/therm_throt.o +intel_cacheinfo-y += cpu/intel_cacheinfo.o +addon_cpuid_features-y += cpu/addon_cpuid_features.o +perfctr-watchdog-y += cpu/perfctr-watchdog.o diff --git a/trunk/arch/x86/kernel/acpi/Makefile b/trunk/arch/x86/kernel/acpi/Makefile index 1351c3982ee4..3d5671939542 100644 --- a/trunk/arch/x86/kernel/acpi/Makefile +++ b/trunk/arch/x86/kernel/acpi/Makefile @@ -1,7 +1,5 @@ -obj-$(CONFIG_ACPI) += boot.o -obj-$(CONFIG_ACPI_SLEEP) += sleep_$(BITS).o wakeup_$(BITS).o - -ifneq ($(CONFIG_ACPI_PROCESSOR),) -obj-y += cstate.o processor.o +ifeq ($(CONFIG_X86_32),y) +include ${srctree}/arch/x86/kernel/acpi/Makefile_32 +else +include ${srctree}/arch/x86/kernel/acpi/Makefile_64 endif - diff --git a/trunk/arch/x86/kernel/acpi/Makefile_32 b/trunk/arch/x86/kernel/acpi/Makefile_32 new file mode 100644 index 000000000000..045dd54b33e0 --- /dev/null +++ b/trunk/arch/x86/kernel/acpi/Makefile_32 @@ -0,0 +1,7 @@ +obj-$(CONFIG_ACPI) += boot.o +obj-$(CONFIG_ACPI_SLEEP) += sleep_32.o wakeup_32.o + +ifneq ($(CONFIG_ACPI_PROCESSOR),) +obj-y += cstate.o processor.o +endif + diff --git a/trunk/arch/x86/kernel/acpi/Makefile_64 b/trunk/arch/x86/kernel/acpi/Makefile_64 new file mode 100644 index 000000000000..629425bc002d --- /dev/null +++ b/trunk/arch/x86/kernel/acpi/Makefile_64 @@ -0,0 +1,7 @@ +obj-y := boot.o +obj-$(CONFIG_ACPI_SLEEP) += sleep_64.o wakeup_64.o + +ifneq ($(CONFIG_ACPI_PROCESSOR),) +obj-y += processor.o cstate.o +endif + diff --git a/trunk/arch/x86/kernel/acpi/processor.c b/trunk/arch/x86/kernel/acpi/processor.c index f63e5ff0aca1..2ed0a4ce62f0 100644 --- a/trunk/arch/x86/kernel/acpi/processor.c +++ b/trunk/arch/x86/kernel/acpi/processor.c @@ -62,7 +62,8 @@ static void init_intel_pdc(struct acpi_processor *pr, struct cpuinfo_x86 *c) /* Initialize _PDC data based on the CPU vendor */ void arch_acpi_processor_init_pdc(struct acpi_processor *pr) { - struct cpuinfo_x86 *c = &cpu_data(pr->id); + unsigned int cpu = pr->id; + struct cpuinfo_x86 *c = &cpu_data(cpu); pr->pdc = NULL; if (c->x86_vendor == X86_VENDOR_INTEL) diff --git a/trunk/arch/x86/kernel/acpi/wakeup_64.S b/trunk/arch/x86/kernel/acpi/wakeup_64.S index 5ed3bc5c61d7..55608ec2ed72 100644 --- a/trunk/arch/x86/kernel/acpi/wakeup_64.S +++ b/trunk/arch/x86/kernel/acpi/wakeup_64.S @@ -4,7 +4,6 @@ #include #include #include -#include # Copyright 2003 Pavel Machek , distribute under GPLv2 # @@ -343,32 +342,31 @@ do_suspend_lowlevel: xorl %eax, %eax call save_processor_state - movq $saved_context, %rax - movq %rsp, pt_regs_rsp(%rax) - movq %rbp, pt_regs_rbp(%rax) - movq %rsi, pt_regs_rsi(%rax) - movq %rdi, pt_regs_rdi(%rax) - movq %rbx, pt_regs_rbx(%rax) - movq %rcx, pt_regs_rcx(%rax) - movq %rdx, pt_regs_rdx(%rax) - movq %r8, pt_regs_r8(%rax) - movq %r9, pt_regs_r9(%rax) - movq %r10, pt_regs_r10(%rax) - movq %r11, pt_regs_r11(%rax) - movq %r12, pt_regs_r12(%rax) - movq %r13, pt_regs_r13(%rax) - movq %r14, pt_regs_r14(%rax) - movq %r15, pt_regs_r15(%rax) - pushfq - popq pt_regs_eflags(%rax) + movq %rsp, saved_context_esp(%rip) + movq %rax, saved_context_eax(%rip) + movq %rbx, saved_context_ebx(%rip) + movq %rcx, saved_context_ecx(%rip) + movq %rdx, saved_context_edx(%rip) + movq %rbp, saved_context_ebp(%rip) + movq %rsi, saved_context_esi(%rip) + movq %rdi, saved_context_edi(%rip) + movq %r8, saved_context_r08(%rip) + movq %r9, saved_context_r09(%rip) + movq %r10, saved_context_r10(%rip) + movq %r11, saved_context_r11(%rip) + movq %r12, saved_context_r12(%rip) + movq %r13, saved_context_r13(%rip) + movq %r14, saved_context_r14(%rip) + movq %r15, saved_context_r15(%rip) + pushfq ; popq saved_context_eflags(%rip) movq $.L97, saved_rip(%rip) - movq %rsp, saved_rsp - movq %rbp, saved_rbp - movq %rbx, saved_rbx - movq %rdi, saved_rdi - movq %rsi, saved_rsi + movq %rsp,saved_rsp + movq %rbp,saved_rbp + movq %rbx,saved_rbx + movq %rdi,saved_rdi + movq %rsi,saved_rsi addq $8, %rsp movl $3, %edi @@ -379,35 +377,32 @@ do_suspend_lowlevel: .L99: .align 4 movl $24, %eax - movw %ax, %ds - - /* We don't restore %rax, it must be 0 anyway */ - movq $saved_context, %rax - movq saved_context_cr4(%rax), %rbx - movq %rbx, %cr4 - movq saved_context_cr3(%rax), %rbx - movq %rbx, %cr3 - movq saved_context_cr2(%rax), %rbx - movq %rbx, %cr2 - movq saved_context_cr0(%rax), %rbx - movq %rbx, %cr0 - pushq pt_regs_eflags(%rax) - popfq - movq pt_regs_rsp(%rax), %rsp - movq pt_regs_rbp(%rax), %rbp - movq pt_regs_rsi(%rax), %rsi - movq pt_regs_rdi(%rax), %rdi - movq pt_regs_rbx(%rax), %rbx - movq pt_regs_rcx(%rax), %rcx - movq pt_regs_rdx(%rax), %rdx - movq pt_regs_r8(%rax), %r8 - movq pt_regs_r9(%rax), %r9 - movq pt_regs_r10(%rax), %r10 - movq pt_regs_r11(%rax), %r11 - movq pt_regs_r12(%rax), %r12 - movq pt_regs_r13(%rax), %r13 - movq pt_regs_r14(%rax), %r14 - movq pt_regs_r15(%rax), %r15 + movw %ax, %ds + movq saved_context+58(%rip), %rax + movq %rax, %cr4 + movq saved_context+50(%rip), %rax + movq %rax, %cr3 + movq saved_context+42(%rip), %rax + movq %rax, %cr2 + movq saved_context+34(%rip), %rax + movq %rax, %cr0 + pushq saved_context_eflags(%rip) ; popfq + movq saved_context_esp(%rip), %rsp + movq saved_context_ebp(%rip), %rbp + movq saved_context_eax(%rip), %rax + movq saved_context_ebx(%rip), %rbx + movq saved_context_ecx(%rip), %rcx + movq saved_context_edx(%rip), %rdx + movq saved_context_esi(%rip), %rsi + movq saved_context_edi(%rip), %rdi + movq saved_context_r08(%rip), %r8 + movq saved_context_r09(%rip), %r9 + movq saved_context_r10(%rip), %r10 + movq saved_context_r11(%rip), %r11 + movq saved_context_r12(%rip), %r12 + movq saved_context_r13(%rip), %r13 + movq saved_context_r14(%rip), %r14 + movq saved_context_r15(%rip), %r15 xorl %eax, %eax addq $8, %rsp diff --git a/trunk/arch/x86/kernel/aperture_64.c b/trunk/arch/x86/kernel/aperture_64.c index 5b6992799c9d..8f681cae7bf7 100644 --- a/trunk/arch/x86/kernel/aperture_64.c +++ b/trunk/arch/x86/kernel/aperture_64.c @@ -20,14 +20,14 @@ #include #include #include -#include +#include #include #include #include -int gart_iommu_aperture; -int gart_iommu_aperture_disabled __initdata = 0; -int gart_iommu_aperture_allowed __initdata = 0; +int iommu_aperture; +int iommu_aperture_disabled __initdata = 0; +int iommu_aperture_allowed __initdata = 0; int fallback_aper_order __initdata = 1; /* 64MB */ int fallback_aper_force __initdata = 0; @@ -204,15 +204,14 @@ static __u32 __init search_agp_bridge(u32 *order, int *valid_agp) return 0; } -void __init gart_iommu_hole_init(void) +void __init iommu_hole_init(void) { int fix, num; u32 aper_size, aper_alloc = 0, aper_order = 0, last_aper_order = 0; u64 aper_base, last_aper_base = 0; int valid_agp = 0; - if (gart_iommu_aperture_disabled || !fix_aperture || - !early_pci_allowed()) + if (iommu_aperture_disabled || !fix_aperture || !early_pci_allowed()) return; printk(KERN_INFO "Checking aperture...\n"); @@ -223,7 +222,7 @@ void __init gart_iommu_hole_init(void) continue; iommu_detected = 1; - gart_iommu_aperture = 1; + iommu_aperture = 1; aper_order = (read_pci_config(0, num, 3, 0x90) >> 1) & 7; aper_size = (32 * 1024 * 1024) << aper_order; diff --git a/trunk/arch/x86/kernel/apic_64.c b/trunk/arch/x86/kernel/apic_64.c index f28ccb588fba..f47bc493dba9 100644 --- a/trunk/arch/x86/kernel/apic_64.c +++ b/trunk/arch/x86/kernel/apic_64.c @@ -287,20 +287,6 @@ void disable_local_APIC(void) apic_write(APIC_SPIV, value); } -void lapic_shutdown(void) -{ - unsigned long flags; - - if (!cpu_has_apic) - return; - - local_irq_save(flags); - - disable_local_APIC(); - - local_irq_restore(flags); -} - /* * This is to verify that we're looking at a real local APIC. * Check these against your board if the CPUs aren't getting diff --git a/trunk/arch/x86/kernel/asm-offsets_64.c b/trunk/arch/x86/kernel/asm-offsets_64.c index d1b6ed98774e..778953bc636c 100644 --- a/trunk/arch/x86/kernel/asm-offsets_64.c +++ b/trunk/arch/x86/kernel/asm-offsets_64.c @@ -15,16 +15,12 @@ #include #include #include -#include #define DEFINE(sym, val) \ asm volatile("\n->" #sym " %0 " #val : : "i" (val)) #define BLANK() asm volatile("\n->" : : ) -#define OFFSET(sym, str, mem) \ - DEFINE(sym, offsetof(struct str, mem)) - #define __NO_STUBS 1 #undef __SYSCALL #undef _ASM_X86_64_UNISTD_H_ @@ -80,44 +76,10 @@ int main(void) DEFINE(pbe_orig_address, offsetof(struct pbe, orig_address)); DEFINE(pbe_next, offsetof(struct pbe, next)); BLANK(); -#define ENTRY(entry) DEFINE(pt_regs_ ## entry, offsetof(struct pt_regs, entry)) - ENTRY(rbx); - ENTRY(rbx); - ENTRY(rcx); - ENTRY(rdx); - ENTRY(rsp); - ENTRY(rbp); - ENTRY(rsi); - ENTRY(rdi); - ENTRY(r8); - ENTRY(r9); - ENTRY(r10); - ENTRY(r11); - ENTRY(r12); - ENTRY(r13); - ENTRY(r14); - ENTRY(r15); - ENTRY(eflags); - BLANK(); -#undef ENTRY -#define ENTRY(entry) DEFINE(saved_context_ ## entry, offsetof(struct saved_context, entry)) - ENTRY(cr0); - ENTRY(cr2); - ENTRY(cr3); - ENTRY(cr4); - ENTRY(cr8); - BLANK(); -#undef ENTRY DEFINE(TSS_ist, offsetof(struct tss_struct, ist)); BLANK(); DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx)); BLANK(); DEFINE(__NR_syscall_max, sizeof(syscalls) - 1); - - BLANK(); - OFFSET(BP_scratch, boot_params, scratch); - OFFSET(BP_loadflags, boot_params, hdr.loadflags); - OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch); - OFFSET(BP_version, boot_params, hdr.version); return 0; } diff --git a/trunk/arch/x86/kernel/cpu/Makefile b/trunk/arch/x86/kernel/cpu/Makefile index cfdb2f3bd763..778396c78d65 100644 --- a/trunk/arch/x86/kernel/cpu/Makefile +++ b/trunk/arch/x86/kernel/cpu/Makefile @@ -2,19 +2,19 @@ # Makefile for x86-compatible CPU details and quirks # -obj-y := intel_cacheinfo.o addon_cpuid_features.o +obj-y := common.o proc.o bugs.o -obj-$(CONFIG_X86_32) += common.o proc.o bugs.o -obj-$(CONFIG_X86_32) += amd.o -obj-$(CONFIG_X86_32) += cyrix.o -obj-$(CONFIG_X86_32) += centaur.o -obj-$(CONFIG_X86_32) += transmeta.o -obj-$(CONFIG_X86_32) += intel.o -obj-$(CONFIG_X86_32) += nexgen.o -obj-$(CONFIG_X86_32) += umc.o +obj-y += amd.o +obj-y += cyrix.o +obj-y += centaur.o +obj-y += transmeta.o +obj-y += intel.o intel_cacheinfo.o addon_cpuid_features.o +obj-y += nexgen.o +obj-y += umc.o -obj-$(CONFIG_X86_MCE) += mcheck/ -obj-$(CONFIG_MTRR) += mtrr/ -obj-$(CONFIG_CPU_FREQ) += cpufreq/ +obj-$(CONFIG_X86_MCE) += mcheck/ + +obj-$(CONFIG_MTRR) += mtrr/ +obj-$(CONFIG_CPU_FREQ) += cpufreq/ obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o diff --git a/trunk/arch/x86/kernel/cpu/mcheck/Makefile b/trunk/arch/x86/kernel/cpu/mcheck/Makefile index d7d2323bbb69..f1ebe1c1c17a 100644 --- a/trunk/arch/x86/kernel/cpu/mcheck/Makefile +++ b/trunk/arch/x86/kernel/cpu/mcheck/Makefile @@ -1,6 +1,2 @@ -obj-y = mce_$(BITS).o therm_throt.o - -obj-$(CONFIG_X86_32) += k7.o p4.o p5.o p6.o winchip.o -obj-$(CONFIG_X86_MCE_INTEL) += mce_intel_64.o -obj-$(CONFIG_X86_MCE_AMD) += mce_amd_64.o -obj-$(CONFIG_X86_MCE_NONFATAL) += non-fatal.o +obj-y = mce.o k7.o p4.o p5.o p6.o winchip.o therm_throt.o +obj-$(CONFIG_X86_MCE_NONFATAL) += non-fatal.o diff --git a/trunk/arch/x86/kernel/cpu/mcheck/mce_32.c b/trunk/arch/x86/kernel/cpu/mcheck/mce.c similarity index 100% rename from trunk/arch/x86/kernel/cpu/mcheck/mce_32.c rename to trunk/arch/x86/kernel/cpu/mcheck/mce.c diff --git a/trunk/arch/x86/kernel/cpu/proc.c b/trunk/arch/x86/kernel/cpu/proc.c index 066f8c6af4df..2d42b414b777 100644 --- a/trunk/arch/x86/kernel/cpu/proc.c +++ b/trunk/arch/x86/kernel/cpu/proc.c @@ -49,7 +49,7 @@ static int show_cpuinfo(struct seq_file *m, void *v) /* Intel-defined (#2) */ "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", "smx", "est", "tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL, - NULL, NULL, "dca", "sse4_1", "sse4_2", NULL, NULL, "popcnt", + NULL, NULL, "dca", NULL, NULL, NULL, NULL, "popcnt", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* VIA/Cyrix/Centaur-defined */ @@ -59,10 +59,10 @@ static int show_cpuinfo(struct seq_file *m, void *v) NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* AMD-defined (#2) */ - "lahf_lm", "cmp_legacy", "svm", "extapic", - "cr8_legacy", "abm", "sse4a", "misalignsse", - "3dnowprefetch", "osvw", "ibs", "sse5", - "skinit", "wdt", NULL, NULL, + "lahf_lm", "cmp_legacy", "svm", "extapic", "cr8_legacy", + "altmovcr8", "abm", "sse4a", + "misalignsse", "3dnowprefetch", + "osvw", "ibs", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, diff --git a/trunk/arch/x86/kernel/crash.c b/trunk/arch/x86/kernel/crash_32.c similarity index 94% rename from trunk/arch/x86/kernel/crash.c rename to trunk/arch/x86/kernel/crash_32.c index 8bb482ff091b..53589d1b1a05 100644 --- a/trunk/arch/x86/kernel/crash.c +++ b/trunk/arch/x86/kernel/crash_32.c @@ -1,5 +1,5 @@ /* - * Architecture specific (i386/x86_64) functions for kexec based crash dumps. + * Architecture specific (i386) functions for kexec based crash dumps. * * Created by: Hariprasad Nellitheertha (hari@in.ibm.com) * @@ -25,11 +25,8 @@ #include #include -#ifdef CONFIG_X86_32 #include -#else -#include -#endif + /* This keeps a track of which one is crashing cpu. */ static int crashing_cpu; @@ -41,9 +38,7 @@ static int crash_nmi_callback(struct notifier_block *self, unsigned long val, void *data) { struct pt_regs *regs; -#ifdef CONFIG_X86_32 struct pt_regs fixed_regs; -#endif int cpu; if (val != DIE_NMI_IPI) @@ -60,12 +55,10 @@ static int crash_nmi_callback(struct notifier_block *self, return NOTIFY_STOP; local_irq_disable(); -#ifdef CONFIG_X86_32 if (!user_mode_vm(regs)) { crash_fixup_ss_esp(&fixed_regs, regs); regs = &fixed_regs; } -#endif crash_save_cpu(regs, cpu); disable_local_APIC(); atomic_dec(&waiting_for_crash_ipi); diff --git a/trunk/arch/x86/kernel/crash_64.c b/trunk/arch/x86/kernel/crash_64.c new file mode 100644 index 000000000000..13432a1ae904 --- /dev/null +++ b/trunk/arch/x86/kernel/crash_64.c @@ -0,0 +1,135 @@ +/* + * Architecture specific (x86_64) functions for kexec based crash dumps. + * + * Created by: Hariprasad Nellitheertha (hari@in.ibm.com) + * + * Copyright (C) IBM Corporation, 2004. All rights reserved. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +/* This keeps a track of which one is crashing cpu. */ +static int crashing_cpu; + +#ifdef CONFIG_SMP +static atomic_t waiting_for_crash_ipi; + +static int crash_nmi_callback(struct notifier_block *self, + unsigned long val, void *data) +{ + struct pt_regs *regs; + int cpu; + + if (val != DIE_NMI_IPI) + return NOTIFY_OK; + + regs = ((struct die_args *)data)->regs; + cpu = raw_smp_processor_id(); + + /* + * Don't do anything if this handler is invoked on crashing cpu. + * Otherwise, system will completely hang. Crashing cpu can get + * an NMI if system was initially booted with nmi_watchdog parameter. + */ + if (cpu == crashing_cpu) + return NOTIFY_STOP; + local_irq_disable(); + + crash_save_cpu(regs, cpu); + disable_local_APIC(); + atomic_dec(&waiting_for_crash_ipi); + /* Assume hlt works */ + for(;;) + halt(); + + return 1; +} + +static void smp_send_nmi_allbutself(void) +{ + send_IPI_allbutself(NMI_VECTOR); +} + +/* + * This code is a best effort heuristic to get the + * other cpus to stop executing. So races with + * cpu hotplug shouldn't matter. + */ + +static struct notifier_block crash_nmi_nb = { + .notifier_call = crash_nmi_callback, +}; + +static void nmi_shootdown_cpus(void) +{ + unsigned long msecs; + + atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1); + if (register_die_notifier(&crash_nmi_nb)) + return; /* return what? */ + + /* + * Ensure the new callback function is set before sending + * out the NMI + */ + wmb(); + + smp_send_nmi_allbutself(); + + msecs = 1000; /* Wait at most a second for the other cpus to stop */ + while ((atomic_read(&waiting_for_crash_ipi) > 0) && msecs) { + mdelay(1); + msecs--; + } + /* Leave the nmi callback set */ + disable_local_APIC(); +} +#else +static void nmi_shootdown_cpus(void) +{ + /* There are no cpus to shootdown */ +} +#endif + +void machine_crash_shutdown(struct pt_regs *regs) +{ + /* + * This function is only called after the system + * has panicked or is otherwise in a critical state. + * The minimum amount of code to allow a kexec'd kernel + * to run successfully needs to happen here. + * + * In practice this means shooting down the other cpus in + * an SMP system. + */ + /* The kernel is broken so disable interrupts */ + local_irq_disable(); + + /* Make a note of crashing cpu. Will be used in NMI callback.*/ + crashing_cpu = smp_processor_id(); + nmi_shootdown_cpus(); + + if(cpu_has_apic) + disable_local_APIC(); + + disable_IO_APIC(); + + crash_save_cpu(regs, smp_processor_id()); +} diff --git a/trunk/arch/x86/kernel/early-quirks.c b/trunk/arch/x86/kernel/early-quirks.c index 88bb83ec895f..dc34acbd54aa 100644 --- a/trunk/arch/x86/kernel/early-quirks.c +++ b/trunk/arch/x86/kernel/early-quirks.c @@ -17,32 +17,30 @@ #include #include -#ifdef CONFIG_GART_IOMMU -#include +#ifdef CONFIG_IOMMU +#include #endif static void __init via_bugs(void) { -#ifdef CONFIG_GART_IOMMU +#ifdef CONFIG_IOMMU if ((end_pfn > MAX_DMA32_PFN || force_iommu) && - !gart_iommu_aperture_allowed) { + !iommu_aperture_allowed) { printk(KERN_INFO "Looks like a VIA chipset. Disabling IOMMU." " Override with iommu=allowed\n"); - gart_iommu_aperture_disabled = 1; + iommu_aperture_disabled = 1; } #endif } #ifdef CONFIG_ACPI -#ifdef CONFIG_X86_IO_APIC static int __init nvidia_hpet_check(struct acpi_table_header *header) { return 0; } -#endif /* CONFIG_X86_IO_APIC */ -#endif /* CONFIG_ACPI */ +#endif static void __init nvidia_bugs(void) { diff --git a/trunk/arch/x86/kernel/head_32.S b/trunk/arch/x86/kernel/head_32.S index 374b7ece8961..00b1c2c56454 100644 --- a/trunk/arch/x86/kernel/head_32.S +++ b/trunk/arch/x86/kernel/head_32.S @@ -124,7 +124,12 @@ ENTRY(startup_32) movsl movl boot_params - __PAGE_OFFSET + NEW_CL_POINTER,%esi andl %esi,%esi - jz 1f # No comand line + jnz 2f # New command line protocol + cmpw $(OLD_CL_MAGIC),OLD_CL_MAGIC_ADDR + jne 1f + movzwl OLD_CL_OFFSET,%esi + addl $(OLD_CL_BASE_ADDR),%esi +2: movl $(boot_command_line - __PAGE_OFFSET),%edi movl $(COMMAND_LINE_SIZE/4),%ecx rep diff --git a/trunk/arch/x86/kernel/machine_kexec_64.c b/trunk/arch/x86/kernel/machine_kexec_64.c index aa3d2c8f7737..0d8577f05422 100644 --- a/trunk/arch/x86/kernel/machine_kexec_64.c +++ b/trunk/arch/x86/kernel/machine_kexec_64.c @@ -233,8 +233,6 @@ NORET_TYPE void machine_kexec(struct kimage *image) void arch_crash_save_vmcoreinfo(void) { - VMCOREINFO_SYMBOL(init_level4_pgt); - #ifdef CONFIG_ARCH_DISCONTIGMEM_ENABLE VMCOREINFO_SYMBOL(node_data); VMCOREINFO_LENGTH(node_data, MAX_NUMNODES); diff --git a/trunk/arch/x86/kernel/cpu/mcheck/mce_64.c b/trunk/arch/x86/kernel/mce_64.c similarity index 90% rename from trunk/arch/x86/kernel/cpu/mcheck/mce_64.c rename to trunk/arch/x86/kernel/mce_64.c index b9f802e35209..07bbfe7aa7f7 100644 --- a/trunk/arch/x86/kernel/cpu/mcheck/mce_64.c +++ b/trunk/arch/x86/kernel/mce_64.c @@ -1,8 +1,8 @@ /* * Machine check handler. * K8 parts Copyright 2002,2003 Andi Kleen, SuSE Labs. - * Rest from unknown author(s). - * 2004 Andi Kleen. Rewrote most of it. + * Rest from unknown author(s). + * 2004 Andi Kleen. Rewrote most of it. */ #include @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -63,10 +63,10 @@ static DECLARE_WAIT_QUEUE_HEAD(mce_wait); * separate MCEs from kernel messages to avoid bogus bug reports. */ -struct mce_log mcelog = { +struct mce_log mcelog = { MCE_LOG_SIGNATURE, MCE_LOG_LEN, -}; +}; void mce_log(struct mce *mce) { @@ -111,42 +111,42 @@ static void print_mce(struct mce *m) "CPU %d: Machine Check Exception: %16Lx Bank %d: %016Lx\n", m->cpu, m->mcgstatus, m->bank, m->status); if (m->rip) { - printk(KERN_EMERG "RIP%s %02x:<%016Lx> ", + printk(KERN_EMERG + "RIP%s %02x:<%016Lx> ", !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "", m->cs, m->rip); if (m->cs == __KERNEL_CS) print_symbol("{%s}", m->rip); printk("\n"); } - printk(KERN_EMERG "TSC %Lx ", m->tsc); + printk(KERN_EMERG "TSC %Lx ", m->tsc); if (m->addr) printk("ADDR %Lx ", m->addr); if (m->misc) - printk("MISC %Lx ", m->misc); + printk("MISC %Lx ", m->misc); printk("\n"); printk(KERN_EMERG "This is not a software problem!\n"); - printk(KERN_EMERG "Run through mcelog --ascii to decode " - "and contact your hardware vendor\n"); + printk(KERN_EMERG + "Run through mcelog --ascii to decode and contact your hardware vendor\n"); } static void mce_panic(char *msg, struct mce *backup, unsigned long start) -{ +{ int i; oops_begin(); for (i = 0; i < MCE_LOG_LEN; i++) { unsigned long tsc = mcelog.entry[i].tsc; - if (time_before(tsc, start)) continue; - print_mce(&mcelog.entry[i]); + print_mce(&mcelog.entry[i]); if (backup && mcelog.entry[i].tsc == backup->tsc) backup = NULL; } if (backup) print_mce(backup); panic(msg); -} +} static int mce_available(struct cpuinfo_x86 *c) { @@ -170,9 +170,10 @@ static inline void mce_get_rip(struct mce *m, struct pt_regs *regs) } } -/* +/* * The actual machine check handler */ + void do_machine_check(struct pt_regs * regs, long error_code) { struct mce m, panicm; @@ -193,8 +194,7 @@ void do_machine_check(struct pt_regs * regs, long error_code) atomic_inc(&mce_entry); if (regs) - notify_die(DIE_NMI, "machine check", regs, error_code, 18, - SIGKILL); + notify_die(DIE_NMI, "machine check", regs, error_code, 18, SIGKILL); if (!banks) goto out2; @@ -204,15 +204,15 @@ void do_machine_check(struct pt_regs * regs, long error_code) /* if the restart IP is not valid, we're done for */ if (!(m.mcgstatus & MCG_STATUS_RIPV)) no_way_out = 1; - + rdtscll(mcestart); barrier(); for (i = 0; i < banks; i++) { if (!bank[i]) continue; - - m.misc = 0; + + m.misc = 0; m.addr = 0; m.bank = i; m.tsc = 0; @@ -372,7 +372,7 @@ static void mcheck_timer(struct work_struct *work) if (mce_notify_user()) { next_interval = max(next_interval/2, HZ/100); } else { - next_interval = min(next_interval * 2, + next_interval = min(next_interval*2, (int)round_jiffies_relative(check_interval*HZ)); } @@ -423,18 +423,18 @@ static struct notifier_block mce_idle_notifier = { }; static __init int periodic_mcheck_init(void) -{ +{ next_interval = check_interval * HZ; if (next_interval) schedule_delayed_work(&mcheck_work, round_jiffies_relative(next_interval)); idle_notifier_register(&mce_idle_notifier); return 0; -} +} __initcall(periodic_mcheck_init); -/* +/* * Initialize Machine Checks for a CPU. */ static void mce_init(void *dummy) @@ -444,9 +444,9 @@ static void mce_init(void *dummy) rdmsrl(MSR_IA32_MCG_CAP, cap); banks = cap & 0xff; - if (banks > NR_BANKS) { + if (banks > NR_BANKS) { printk(KERN_INFO "MCE: warning: using only %d banks\n", banks); - banks = NR_BANKS; + banks = NR_BANKS; } /* Use accurate RIP reporting if available. */ if ((cap & (1<<9)) && ((cap >> 16) & 0xff) >= 9) @@ -464,15 +464,15 @@ static void mce_init(void *dummy) for (i = 0; i < banks; i++) { wrmsrl(MSR_IA32_MC0_CTL+4*i, bank[i]); wrmsrl(MSR_IA32_MC0_STATUS+4*i, 0); - } + } } /* Add per CPU specific workarounds here */ static void __cpuinit mce_cpu_quirks(struct cpuinfo_x86 *c) -{ +{ /* This should be disabled by the BIOS, but isn't always */ if (c->x86_vendor == X86_VENDOR_AMD && c->x86 == 15) { - /* disable GART TBL walk error reporting, which trips off + /* disable GART TBL walk error reporting, which trips off incorrectly with the IOMMU & 3ware & Cerberus. */ clear_bit(10, &bank[4]); /* Lots of broken BIOS around that don't clear them @@ -480,7 +480,7 @@ static void __cpuinit mce_cpu_quirks(struct cpuinfo_x86 *c) mce_bootlog = 0; } -} +} static void __cpuinit mce_cpu_features(struct cpuinfo_x86 *c) { @@ -496,15 +496,15 @@ static void __cpuinit mce_cpu_features(struct cpuinfo_x86 *c) } } -/* +/* * Called for each booted CPU to set up machine checks. - * Must be called with preempt off. + * Must be called with preempt off. */ void __cpuinit mcheck_init(struct cpuinfo_x86 *c) { static cpumask_t mce_cpus = CPU_MASK_NONE; - mce_cpu_quirks(c); + mce_cpu_quirks(c); if (mce_dont_init || cpu_test_and_set(smp_processor_id(), mce_cpus) || @@ -553,15 +553,13 @@ static int mce_release(struct inode *inode, struct file *file) return 0; } -static void collect_tscs(void *data) -{ +static void collect_tscs(void *data) +{ unsigned long *cpu_tsc = (unsigned long *)data; - rdtscll(cpu_tsc[smp_processor_id()]); -} +} -static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize, - loff_t *off) +static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize, loff_t *off) { unsigned long *cpu_tsc; static DECLARE_MUTEX(mce_read_sem); @@ -573,20 +571,19 @@ static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize, if (!cpu_tsc) return -ENOMEM; - down(&mce_read_sem); + down(&mce_read_sem); next = rcu_dereference(mcelog.next); /* Only supports full reads right now */ - if (*off != 0 || usize < MCE_LOG_LEN*sizeof(struct mce)) { + if (*off != 0 || usize < MCE_LOG_LEN*sizeof(struct mce)) { up(&mce_read_sem); kfree(cpu_tsc); return -EINVAL; } err = 0; - for (i = 0; i < next; i++) { + for (i = 0; i < next; i++) { unsigned long start = jiffies; - while (!mcelog.entry[i].finished) { if (time_after_eq(jiffies, start + 2)) { memset(mcelog.entry + i,0, sizeof(struct mce)); @@ -596,34 +593,31 @@ static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize, } smp_rmb(); err |= copy_to_user(buf, mcelog.entry + i, sizeof(struct mce)); - buf += sizeof(struct mce); + buf += sizeof(struct mce); timeout: ; - } + } memset(mcelog.entry, 0, next * sizeof(struct mce)); mcelog.next = 0; synchronize_sched(); - /* - * Collect entries that were still getting written before the - * synchronize. - */ + /* Collect entries that were still getting written before the synchronize. */ + on_each_cpu(collect_tscs, cpu_tsc, 1, 1); - for (i = next; i < MCE_LOG_LEN; i++) { - if (mcelog.entry[i].finished && - mcelog.entry[i].tsc < cpu_tsc[mcelog.entry[i].cpu]) { - err |= copy_to_user(buf, mcelog.entry+i, - sizeof(struct mce)); + for (i = next; i < MCE_LOG_LEN; i++) { + if (mcelog.entry[i].finished && + mcelog.entry[i].tsc < cpu_tsc[mcelog.entry[i].cpu]) { + err |= copy_to_user(buf, mcelog.entry+i, sizeof(struct mce)); smp_rmb(); buf += sizeof(struct mce); memset(&mcelog.entry[i], 0, sizeof(struct mce)); } - } + } up(&mce_read_sem); kfree(cpu_tsc); - return err ? -EFAULT : buf - ubuf; + return err ? -EFAULT : buf - ubuf; } static unsigned int mce_poll(struct file *file, poll_table *wait) @@ -634,29 +628,26 @@ static unsigned int mce_poll(struct file *file, poll_table *wait) return 0; } -static int mce_ioctl(struct inode *i, struct file *f,unsigned int cmd, - unsigned long arg) +static int mce_ioctl(struct inode *i, struct file *f,unsigned int cmd, unsigned long arg) { int __user *p = (int __user *)arg; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; + return -EPERM; switch (cmd) { - case MCE_GET_RECORD_LEN: + case MCE_GET_RECORD_LEN: return put_user(sizeof(struct mce), p); case MCE_GET_LOG_LEN: - return put_user(MCE_LOG_LEN, p); + return put_user(MCE_LOG_LEN, p); case MCE_GETCLEAR_FLAGS: { unsigned flags; - - do { + do { flags = mcelog.flags; - } while (cmpxchg(&mcelog.flags, flags, 0) != flags); - return put_user(flags, p); + } while (cmpxchg(&mcelog.flags, flags, 0) != flags); + return put_user(flags, p); } default: - return -ENOTTY; - } + return -ENOTTY; + } } static const struct file_operations mce_chrdev_ops = { @@ -687,9 +678,10 @@ void __init restart_mce(void) set_in_cr4(X86_CR4_MCE); } -/* - * Old style boot options parsing. Only for compatibility. +/* + * Old style boot options parsing. Only for compatibility. */ + static int __init mcheck_disable(char *str) { mce_dont_init = 1; @@ -710,16 +702,16 @@ static int __init mcheck_enable(char *str) else if (isdigit(str[0])) get_option(&str, &tolerant); else - printk("mce= argument %s ignored. Please use /sys", str); + printk("mce= argument %s ignored. Please use /sys", str); return 1; } __setup("nomce", mcheck_disable); __setup("mce=", mcheck_enable); -/* +/* * Sysfs support - */ + */ /* On resume clear all MCE state. Don't want to see leftovers from the BIOS. Only one CPU is active at this time, the others get readded later using @@ -731,12 +723,12 @@ static int mce_resume(struct sys_device *dev) } /* Reinit MCEs after user configuration changes */ -static void mce_restart(void) -{ +static void mce_restart(void) +{ if (next_interval) cancel_delayed_work(&mcheck_work); /* Timer race is harmless here */ - on_each_cpu(mce_init, NULL, 1, 1); + on_each_cpu(mce_init, NULL, 1, 1); next_interval = check_interval * HZ; if (next_interval) schedule_delayed_work(&mcheck_work, @@ -752,17 +744,17 @@ DEFINE_PER_CPU(struct sys_device, device_mce); /* Why are there no generic functions for this? */ #define ACCESSOR(name, var, start) \ - static ssize_t show_ ## name(struct sys_device *s, char *buf) { \ - return sprintf(buf, "%lx\n", (unsigned long)var); \ - } \ + static ssize_t show_ ## name(struct sys_device *s, char *buf) { \ + return sprintf(buf, "%lx\n", (unsigned long)var); \ + } \ static ssize_t set_ ## name(struct sys_device *s,const char *buf,size_t siz) { \ - char *end; \ - unsigned long new = simple_strtoul(buf, &end, 0); \ - if (end == buf) return -EINVAL; \ - var = new; \ - start; \ - return end-buf; \ - } \ + char *end; \ + unsigned long new = simple_strtoul(buf, &end, 0); \ + if (end == buf) return -EINVAL; \ + var = new; \ + start; \ + return end-buf; \ + } \ static SYSDEV_ATTR(name, 0644, show_ ## name, set_ ## name); /* TBD should generate these dynamically based on number of available banks */ diff --git a/trunk/arch/x86/kernel/cpu/mcheck/mce_amd_64.c b/trunk/arch/x86/kernel/mce_amd_64.c similarity index 100% rename from trunk/arch/x86/kernel/cpu/mcheck/mce_amd_64.c rename to trunk/arch/x86/kernel/mce_amd_64.c diff --git a/trunk/arch/x86/kernel/cpu/mcheck/mce_intel_64.c b/trunk/arch/x86/kernel/mce_intel_64.c similarity index 100% rename from trunk/arch/x86/kernel/cpu/mcheck/mce_intel_64.c rename to trunk/arch/x86/kernel/mce_intel_64.c diff --git a/trunk/arch/x86/kernel/pci-calgary_64.c b/trunk/arch/x86/kernel/pci-calgary_64.c index 6bf1f716909d..1a20fe31338b 100644 --- a/trunk/arch/x86/kernel/pci-calgary_64.c +++ b/trunk/arch/x86/kernel/pci-calgary_64.c @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/trunk/arch/x86/kernel/pci-dma_64.c b/trunk/arch/x86/kernel/pci-dma_64.c index aa805b11b24f..393e2725a6e3 100644 --- a/trunk/arch/x86/kernel/pci-dma_64.c +++ b/trunk/arch/x86/kernel/pci-dma_64.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include int iommu_merge __read_mostly = 1; @@ -275,7 +275,7 @@ __init int iommu_setup(char *p) swiotlb = 1; #endif -#ifdef CONFIG_GART_IOMMU +#ifdef CONFIG_IOMMU gart_parse_options(p); #endif @@ -298,8 +298,8 @@ void __init pci_iommu_alloc(void) * The order of these functions is important for * fall-back/fail-over reasons */ -#ifdef CONFIG_GART_IOMMU - gart_iommu_hole_init(); +#ifdef CONFIG_IOMMU + iommu_hole_init(); #endif #ifdef CONFIG_CALGARY_IOMMU @@ -321,7 +321,7 @@ static int __init pci_iommu_init(void) intel_iommu_init(); -#ifdef CONFIG_GART_IOMMU +#ifdef CONFIG_IOMMU gart_iommu_init(); #endif diff --git a/trunk/arch/x86/kernel/pci-gart_64.c b/trunk/arch/x86/kernel/pci-gart_64.c index 06bcba536045..c56e9ee64964 100644 --- a/trunk/arch/x86/kernel/pci-gart_64.c +++ b/trunk/arch/x86/kernel/pci-gart_64.c @@ -30,17 +30,17 @@ #include #include #include -#include +#include #include #include #include #include -static unsigned long iommu_bus_base; /* GART remapping area (physical) */ +unsigned long iommu_bus_base; /* GART remapping area (physical) */ static unsigned long iommu_size; /* size of remapping area bytes */ static unsigned long iommu_pages; /* .. and in pages */ -static u32 *iommu_gatt_base; /* Remapping table */ +u32 *iommu_gatt_base; /* Remapping table */ /* If this is disabled the IOMMU will use an optimized flushing strategy of only flushing when an mapping is reused. With it true the GART is flushed @@ -135,8 +135,8 @@ static void flush_gart(void) /* Debugging aid for drivers that don't free their IOMMU tables */ static void **iommu_leak_tab; static int leak_trace; -static int iommu_leak_pages = 20; -static void dump_leak(void) +int iommu_leak_pages = 20; +void dump_leak(void) { int i; static int dump; @@ -338,6 +338,7 @@ static int __dma_map_cont(struct scatterlist *start, int nelems, BUG_ON(s != start && s->offset); if (s == start) { + *sout = *s; sout->dma_address = iommu_bus_base; sout->dma_address += iommu_page*PAGE_SIZE + s->offset; sout->dma_length = s->length; @@ -364,7 +365,7 @@ static inline int dma_map_cont(struct scatterlist *start, int nelems, { if (!need) { BUG_ON(nelems != 1); - sout->dma_address = start->dma_address; + *sout = *start; sout->dma_length = start->length; return 0; } @@ -435,7 +436,7 @@ static int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, error: flush_gart(); - gart_unmap_sg(dev, sg, out, dir); + gart_unmap_sg(dev, sg, nents, dir); /* When it was forced or merged try again in a dumb way */ if (force_iommu || iommu_merge) { out = dma_map_sg_nonforce(dev, sg, nents, dir); @@ -627,12 +628,12 @@ void __init gart_iommu_init(void) return; /* Did we detect a different HW IOMMU? */ - if (iommu_detected && !gart_iommu_aperture) + if (iommu_detected && !iommu_aperture) return; if (no_iommu || (!force_iommu && end_pfn <= MAX_DMA32_PFN) || - !gart_iommu_aperture || + !iommu_aperture || (no_agp && init_k8_gatt(&info) < 0)) { if (end_pfn > MAX_DMA32_PFN) { printk(KERN_ERR "WARNING more than 4GB of memory " @@ -733,9 +734,9 @@ void __init gart_parse_options(char *p) fix_aperture = 0; /* duplicated from pci-dma.c */ if (!strncmp(p,"force",5)) - gart_iommu_aperture_allowed = 1; + iommu_aperture_allowed = 1; if (!strncmp(p,"allowed",7)) - gart_iommu_aperture_allowed = 1; + iommu_aperture_allowed = 1; if (!strncmp(p, "memaper", 7)) { fallback_aper_force = 1; p += 7; diff --git a/trunk/arch/x86/kernel/pci-nommu_64.c b/trunk/arch/x86/kernel/pci-nommu_64.c index ab08e1832228..faf70bdca335 100644 --- a/trunk/arch/x86/kernel/pci-nommu_64.c +++ b/trunk/arch/x86/kernel/pci-nommu_64.c @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include diff --git a/trunk/arch/x86/kernel/pci-swiotlb_64.c b/trunk/arch/x86/kernel/pci-swiotlb_64.c index 102866d729a5..b2f405ea7c85 100644 --- a/trunk/arch/x86/kernel/pci-swiotlb_64.c +++ b/trunk/arch/x86/kernel/pci-swiotlb_64.c @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include diff --git a/trunk/arch/x86/kernel/quirks.c b/trunk/arch/x86/kernel/quirks.c index fab30e134836..a4ce1911efdf 100644 --- a/trunk/arch/x86/kernel/quirks.c +++ b/trunk/arch/x86/kernel/quirks.c @@ -60,8 +60,7 @@ static enum { NONE_FORCE_HPET_RESUME, OLD_ICH_FORCE_HPET_RESUME, ICH_FORCE_HPET_RESUME, - VT8237_FORCE_HPET_RESUME, - NVIDIA_FORCE_HPET_RESUME, + VT8237_FORCE_HPET_RESUME } force_hpet_resume_type; static void __iomem *rcba_base; @@ -322,55 +321,6 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235, DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, vt8237_force_enable_hpet); -/* - * Undocumented chipset feature taken from LinuxBIOS. - */ -static void nvidia_force_hpet_resume(void) -{ - pci_write_config_dword(cached_dev, 0x44, 0xfed00001); - printk(KERN_DEBUG "Force enabled HPET at resume\n"); -} - -static void nvidia_force_enable_hpet(struct pci_dev *dev) -{ - u32 uninitialized_var(val); - - if (!hpet_force_user || hpet_address || force_hpet_address) - return; - - pci_write_config_dword(dev, 0x44, 0xfed00001); - pci_read_config_dword(dev, 0x44, &val); - force_hpet_address = val & 0xfffffffe; - force_hpet_resume_type = NVIDIA_FORCE_HPET_RESUME; - printk(KERN_DEBUG "Force enabled HPET at base address 0x%lx\n", - force_hpet_address); - cached_dev = dev; - return; -} - -/* ISA Bridges */ -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0050, - nvidia_force_enable_hpet); -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0051, - nvidia_force_enable_hpet); - -/* LPC bridges */ -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0360, - nvidia_force_enable_hpet); -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0361, - nvidia_force_enable_hpet); -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0362, - nvidia_force_enable_hpet); -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0363, - nvidia_force_enable_hpet); -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0364, - nvidia_force_enable_hpet); -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0365, - nvidia_force_enable_hpet); -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0366, - nvidia_force_enable_hpet); -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0367, - nvidia_force_enable_hpet); void force_hpet_resume(void) { @@ -384,9 +334,6 @@ void force_hpet_resume(void) case VT8237_FORCE_HPET_RESUME: return vt8237_force_hpet_resume(); - case NVIDIA_FORCE_HPET_RESUME: - return nvidia_force_hpet_resume(); - default: break; } diff --git a/trunk/arch/x86/kernel/reboot_64.c b/trunk/arch/x86/kernel/reboot_64.c index 71b13c5f5817..776eb06b6512 100644 --- a/trunk/arch/x86/kernel/reboot_64.c +++ b/trunk/arch/x86/kernel/reboot_64.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include /* * Power off function, if any diff --git a/trunk/arch/x86/kernel/setup_32.c b/trunk/arch/x86/kernel/setup_32.c index e1e18c34c821..cc0e91447b76 100644 --- a/trunk/arch/x86/kernel/setup_32.c +++ b/trunk/arch/x86/kernel/setup_32.c @@ -86,6 +86,9 @@ unsigned long mmu_cr4_features; /* for MCA, but anyone else can use it if they want */ unsigned int machine_id; +#ifdef CONFIG_MCA +EXPORT_SYMBOL(machine_id); +#endif unsigned int machine_submodel_id; unsigned int BIOS_revision; unsigned int mca_pentium_flag; diff --git a/trunk/arch/x86/kernel/setup_64.c b/trunk/arch/x86/kernel/setup_64.c index 238633d3d09a..e7a9e36bd52d 100644 --- a/trunk/arch/x86/kernel/setup_64.c +++ b/trunk/arch/x86/kernel/setup_64.c @@ -1040,7 +1040,7 @@ static int show_cpuinfo(struct seq_file *m, void *v) /* Intel-defined (#2) */ "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", "smx", "est", "tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL, - NULL, NULL, "dca", "sse4_1", "sse4_2", NULL, NULL, "popcnt", + NULL, NULL, "dca", NULL, NULL, NULL, NULL, "popcnt", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* VIA/Cyrix/Centaur-defined */ @@ -1050,10 +1050,10 @@ static int show_cpuinfo(struct seq_file *m, void *v) NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* AMD-defined (#2) */ - "lahf_lm", "cmp_legacy", "svm", "extapic", - "cr8_legacy", "abm", "sse4a", "misalignsse", - "3dnowprefetch", "osvw", "ibs", "sse5", - "skinit", "wdt", NULL, NULL, + "lahf_lm", "cmp_legacy", "svm", "extapic", "cr8_legacy", + "altmovcr8", "abm", "sse4a", + "misalignsse", "3dnowprefetch", + "osvw", "ibs", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, diff --git a/trunk/arch/x86/kernel/smp_32.c b/trunk/arch/x86/kernel/smp_32.c index fcaa026eb807..f32115308399 100644 --- a/trunk/arch/x86/kernel/smp_32.c +++ b/trunk/arch/x86/kernel/smp_32.c @@ -708,4 +708,10 @@ struct smp_ops smp_ops = { .smp_send_reschedule = native_smp_send_reschedule, .smp_call_function_mask = native_smp_call_function_mask, }; -EXPORT_SYMBOL_GPL(smp_ops); + +int smp_call_function_mask(cpumask_t mask, void (*func) (void *info), + void *info, int wait) +{ + return smp_ops.smp_call_function_mask(mask, func, info, wait); +} +EXPORT_SYMBOL(smp_call_function_mask); diff --git a/trunk/arch/x86/kernel/smpboot_64.c b/trunk/arch/x86/kernel/smpboot_64.c index 500670c93d81..b7e768dd87c9 100644 --- a/trunk/arch/x86/kernel/smpboot_64.c +++ b/trunk/arch/x86/kernel/smpboot_64.c @@ -388,7 +388,7 @@ static void inquire_remote_apic(int apicid) printk(KERN_INFO "Inquiring remote APIC #%d...\n", apicid); - for (i = 0; i < ARRAY_SIZE(regs); i++) { + for (i = 0; i < sizeof(regs) / sizeof(*regs); i++) { printk("... APIC #%d %s: ", apicid, names[i]); /* diff --git a/trunk/arch/x86/kernel/suspend_64.c b/trunk/arch/x86/kernel/suspend_64.c index db284ef44d53..bc9f59c246fd 100644 --- a/trunk/arch/x86/kernel/suspend_64.c +++ b/trunk/arch/x86/kernel/suspend_64.c @@ -19,6 +19,12 @@ extern const void __nosave_begin, __nosave_end; struct saved_context saved_context; +unsigned long saved_context_eax, saved_context_ebx, saved_context_ecx, saved_context_edx; +unsigned long saved_context_esp, saved_context_ebp, saved_context_esi, saved_context_edi; +unsigned long saved_context_r08, saved_context_r09, saved_context_r10, saved_context_r11; +unsigned long saved_context_r12, saved_context_r13, saved_context_r14, saved_context_r15; +unsigned long saved_context_eflags; + void __save_processor_state(struct saved_context *ctxt) { kernel_fpu_begin(); diff --git a/trunk/arch/x86/kernel/suspend_asm_64.S b/trunk/arch/x86/kernel/suspend_asm_64.S index 72f952103e50..48344b666d2c 100644 --- a/trunk/arch/x86/kernel/suspend_asm_64.S +++ b/trunk/arch/x86/kernel/suspend_asm_64.S @@ -17,24 +17,24 @@ #include ENTRY(swsusp_arch_suspend) - movq $saved_context, %rax - movq %rsp, pt_regs_rsp(%rax) - movq %rbp, pt_regs_rbp(%rax) - movq %rsi, pt_regs_rsi(%rax) - movq %rdi, pt_regs_rdi(%rax) - movq %rbx, pt_regs_rbx(%rax) - movq %rcx, pt_regs_rcx(%rax) - movq %rdx, pt_regs_rdx(%rax) - movq %r8, pt_regs_r8(%rax) - movq %r9, pt_regs_r9(%rax) - movq %r10, pt_regs_r10(%rax) - movq %r11, pt_regs_r11(%rax) - movq %r12, pt_regs_r12(%rax) - movq %r13, pt_regs_r13(%rax) - movq %r14, pt_regs_r14(%rax) - movq %r15, pt_regs_r15(%rax) - pushfq - popq pt_regs_eflags(%rax) + + movq %rsp, saved_context_esp(%rip) + movq %rax, saved_context_eax(%rip) + movq %rbx, saved_context_ebx(%rip) + movq %rcx, saved_context_ecx(%rip) + movq %rdx, saved_context_edx(%rip) + movq %rbp, saved_context_ebp(%rip) + movq %rsi, saved_context_esi(%rip) + movq %rdi, saved_context_edi(%rip) + movq %r8, saved_context_r08(%rip) + movq %r9, saved_context_r09(%rip) + movq %r10, saved_context_r10(%rip) + movq %r11, saved_context_r11(%rip) + movq %r12, saved_context_r12(%rip) + movq %r13, saved_context_r13(%rip) + movq %r14, saved_context_r14(%rip) + movq %r15, saved_context_r15(%rip) + pushfq ; popq saved_context_eflags(%rip) /* save the address of restore_registers */ movq $restore_registers, %rax @@ -113,25 +113,23 @@ ENTRY(restore_registers) movq %rcx, %cr3 movq %rax, %cr4; # turn PGE back on - /* We don't restore %rax, it must be 0 anyway */ - movq $saved_context, %rax - movq pt_regs_rsp(%rax), %rsp - movq pt_regs_rbp(%rax), %rbp - movq pt_regs_rsi(%rax), %rsi - movq pt_regs_rdi(%rax), %rdi - movq pt_regs_rbx(%rax), %rbx - movq pt_regs_rcx(%rax), %rcx - movq pt_regs_rdx(%rax), %rdx - movq pt_regs_r8(%rax), %r8 - movq pt_regs_r9(%rax), %r9 - movq pt_regs_r10(%rax), %r10 - movq pt_regs_r11(%rax), %r11 - movq pt_regs_r12(%rax), %r12 - movq pt_regs_r13(%rax), %r13 - movq pt_regs_r14(%rax), %r14 - movq pt_regs_r15(%rax), %r15 - pushq pt_regs_eflags(%rax) - popfq + movq saved_context_esp(%rip), %rsp + movq saved_context_ebp(%rip), %rbp + /* restore GPRs (we don't restore %rax, it must be 0 anyway) */ + movq saved_context_ebx(%rip), %rbx + movq saved_context_ecx(%rip), %rcx + movq saved_context_edx(%rip), %rdx + movq saved_context_esi(%rip), %rsi + movq saved_context_edi(%rip), %rdi + movq saved_context_r08(%rip), %r8 + movq saved_context_r09(%rip), %r9 + movq saved_context_r10(%rip), %r10 + movq saved_context_r11(%rip), %r11 + movq saved_context_r12(%rip), %r12 + movq saved_context_r13(%rip), %r13 + movq saved_context_r14(%rip), %r14 + movq saved_context_r15(%rip), %r15 + pushq saved_context_eflags(%rip) ; popfq xorq %rax, %rax diff --git a/trunk/arch/x86/kernel/tsc_32.c b/trunk/arch/x86/kernel/tsc_32.c index 9ebc0dab66b4..d78444c788a3 100644 --- a/trunk/arch/x86/kernel/tsc_32.c +++ b/trunk/arch/x86/kernel/tsc_32.c @@ -131,43 +131,38 @@ unsigned long native_calculate_cpu_khz(void) { unsigned long long start, end; unsigned long count; - u64 delta64 = (u64)ULLONG_MAX; + u64 delta64; int i; unsigned long flags; local_irq_save(flags); - /* run 3 times to ensure the cache is warm and to get an accurate reading */ + /* run 3 times to ensure the cache is warm */ for (i = 0; i < 3; i++) { mach_prepare_counter(); rdtscll(start); mach_countup(&count); rdtscll(end); - - /* - * Error: ECTCNEVERSET - * The CTC wasn't reliable: we got a hit on the very first read, - * or the CPU was so fast/slow that the quotient wouldn't fit in - * 32 bits.. - */ - if (count <= 1) - continue; - - /* cpu freq too slow: */ - if ((end - start) <= CALIBRATE_TIME_MSEC) - continue; - - /* - * We want the minimum time of all runs in case one of them - * is inaccurate due to SMI or other delay - */ - delta64 = min(delta64, (end - start)); } + /* + * Error: ECTCNEVERSET + * The CTC wasn't reliable: we got a hit on the very first read, + * or the CPU was so fast/slow that the quotient wouldn't fit in + * 32 bits.. + */ + if (count <= 1) + goto err; - /* cpu freq too fast (or every run was bad): */ + delta64 = end - start; + + /* cpu freq too fast: */ if (delta64 > (1ULL<<32)) goto err; + /* cpu freq too slow: */ + if (delta64 <= CALIBRATE_TIME_MSEC) + goto err; + delta64 += CALIBRATE_TIME_MSEC/2; /* round for do_div */ do_div(delta64,CALIBRATE_TIME_MSEC); diff --git a/trunk/arch/x86/lguest/boot.c b/trunk/arch/x86/lguest/boot.c index a55b0902f9d3..d2235db4085f 100644 --- a/trunk/arch/x86/lguest/boot.c +++ b/trunk/arch/x86/lguest/boot.c @@ -56,7 +56,6 @@ #include #include #include -#include #include #include #include @@ -99,7 +98,7 @@ static cycle_t clock_base; * When lazy_mode is set, it means we're allowed to defer all hypercalls and do * them as a batch when lazy_mode is eventually turned off. Because hypercalls * are reasonably expensive, batching them up makes sense. For example, a - * large munmap might update dozens of page table entries: that code calls + * large mmap might update dozens of page table entries: that code calls * paravirt_enter_lazy_mmu(), does the dozen updates, then calls * lguest_leave_lazy_mode(). * @@ -164,8 +163,8 @@ void async_hcall(unsigned long call, /*:*/ /*G:033 - * After that diversion we return to our first native-instruction - * replacements: four functions for interrupt control. + * Here are our first native-instruction replacements: four functions for + * interrupt control. * * The simplest way of implementing these would be to have "turn interrupts * off" and "turn interrupts on" hypercalls. Unfortunately, this is too slow: @@ -184,7 +183,7 @@ static unsigned long save_fl(void) return lguest_data.irq_enabled; } -/* restore_flags() just sets the flags back to the value given. */ +/* "restore_flags" just sets the flags back to the value given. */ static void restore_fl(unsigned long flags) { lguest_data.irq_enabled = flags; @@ -357,7 +356,7 @@ static void lguest_cpuid(unsigned int *eax, unsigned int *ebx, * it. The Host needs to know when the Guest wants to change them, so we have * a whole series of functions like read_cr0() and write_cr0(). * - * We start with cr0. cr0 allows you to turn on and off all kinds of basic + * We start with CR0. CR0 allows you to turn on and off all kinds of basic * features, but Linux only really cares about one: the horrifically-named Task * Switched (TS) bit at bit 3 (ie. 8) * @@ -372,7 +371,8 @@ static void lguest_cpuid(unsigned int *eax, unsigned int *ebx, static unsigned long current_cr0, current_cr3; static void lguest_write_cr0(unsigned long val) { - lazy_hcall(LHCALL_TS, val & X86_CR0_TS, 0, 0); + /* 8 == TS bit. */ + lazy_hcall(LHCALL_TS, val & 8, 0, 0); current_cr0 = val; } @@ -387,10 +387,10 @@ static unsigned long lguest_read_cr0(void) static void lguest_clts(void) { lazy_hcall(LHCALL_TS, 0, 0, 0); - current_cr0 &= ~X86_CR0_TS; + current_cr0 &= ~8U; } -/* cr2 is the virtual address of the last page fault, which the Guest only ever +/* CR2 is the virtual address of the last page fault, which the Guest only ever * reads. The Host kindly writes this into our "struct lguest_data", so we * just read it out of there. */ static unsigned long lguest_read_cr2(void) @@ -398,7 +398,7 @@ static unsigned long lguest_read_cr2(void) return lguest_data.cr2; } -/* cr3 is the current toplevel pagetable page: the principle is the same as +/* CR3 is the current toplevel pagetable page: the principle is the same as * cr0. Keep a local copy, and tell the Host when it changes. */ static void lguest_write_cr3(unsigned long cr3) { @@ -411,7 +411,7 @@ static unsigned long lguest_read_cr3(void) return current_cr3; } -/* cr4 is used to enable and disable PGE, but we don't care. */ +/* CR4 is used to enable and disable PGE, but we don't care. */ static unsigned long lguest_read_cr4(void) { return 0; @@ -432,7 +432,7 @@ static void lguest_write_cr4(unsigned long val) * maps virtual addresses to physical addresses using "page tables". We could * use one huge index of 1 million entries: each address is 4 bytes, so that's * 1024 pages just to hold the page tables. But since most virtual addresses - * are unused, we use a two level index which saves space. The cr3 register + * are unused, we use a two level index which saves space. The CR3 register * contains the physical address of the top level "page directory" page, which * contains physical addresses of up to 1024 second-level pages. Each of these * second level pages contains up to 1024 physical addresses of actual pages, @@ -440,7 +440,7 @@ static void lguest_write_cr4(unsigned long val) * * Here's a diagram, where arrows indicate physical addresses: * - * cr3 ---> +---------+ + * CR3 ---> +---------+ * | --------->+---------+ * | | | PADDR1 | * Top-level | | PADDR2 | @@ -498,7 +498,8 @@ static void lguest_set_pmd(pmd_t *pmdp, pmd_t pmdval) * * ... except in early boot when the kernel sets up the initial pagetables, * which makes booting astonishingly slow. So we don't even tell the Host - * anything changed until we've done the first page table switch. */ + * anything changed until we've done the first page table switch. + */ static void lguest_set_pte(pte_t *ptep, pte_t pteval) { *ptep = pteval; @@ -719,10 +720,10 @@ static void lguest_time_init(void) /* Set up the timer interrupt (0) to go to our simple timer routine */ set_irq_handler(0, lguest_time_irq); - /* Our clock structure looks like arch/x86/kernel/tsc_32.c if we can - * use the TSC, otherwise it's a dumb nanosecond-resolution clock. - * Either way, the "rating" is set so high that it's always chosen over - * any other clocksource. */ + /* Our clock structure look like arch/i386/kernel/tsc.c if we can use + * the TSC, otherwise it's a dumb nanosecond-resolution clock. Either + * way, the "rating" is initialized so high that it's always chosen + * over any other clocksource. */ if (lguest_data.tsc_khz) lguest_clock.mult = clocksource_khz2mult(lguest_data.tsc_khz, lguest_clock.shift); @@ -748,7 +749,7 @@ static void lguest_time_init(void) * to work. They're pretty simple. */ -/* The Guest needs to tell the Host what stack it expects traps to use. For +/* The Guest needs to tell the host what stack it expects traps to use. For * native hardware, this is part of the Task State Segment mentioned above in * lguest_load_tr_desc(), but to help hypervisors there's this special call. * @@ -849,16 +850,13 @@ static __init char *lguest_memory_setup(void) return "LGUEST"; } -/* We will eventually use the virtio console device to produce console output, - * but before that is set up we use LHCALL_NOTIFY on normal memory to produce - * console output. */ +/* Before virtqueues are set up, we use LHCALL_NOTIFY on normal memory to + * produce console output. */ static __init int early_put_chars(u32 vtermno, const char *buf, int count) { char scratch[17]; unsigned int len = count; - /* We use a nul-terminated string, so we have to make a copy. Icky, - * huh? */ if (len > sizeof(scratch) - 1) len = sizeof(scratch) - 1; scratch[len] = '\0'; @@ -885,7 +883,7 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count) * Our current solution is to allow the paravirt back end to optionally patch * over the indirect calls to replace them with something more efficient. We * patch the four most commonly called functions: disable interrupts, enable - * interrupts, restore interrupts and save interrupts. We usually have 6 or 10 + * interrupts, restore interrupts and save interrupts. We usually have 10 * bytes to patch into: the Guest versions of these operations are small enough * that we can fit comfortably. * @@ -1017,7 +1015,7 @@ __init void lguest_init(void) asm volatile ("mov %0, %%fs" : : "r" (__KERNEL_DS) : "memory"); /* The Host uses the top of the Guest's virtual address space for the - * Host<->Guest Switcher, and it tells us how big that is in + * Host<->Guest Switcher, and it tells us how much it needs in * lguest_data.reserve_mem, set up on the LGUEST_INIT hypercall. */ reserve_top_address(lguest_data.reserve_mem); @@ -1067,6 +1065,6 @@ __init void lguest_init(void) /* * This marks the end of stage II of our journey, The Guest. * - * It is now time for us to explore the layer of virtual drivers and complete - * our understanding of the Guest in "make Drivers". + * It is now time for us to explore the nooks and crannies of the three Guest + * devices and complete our understanding of the Guest in "make Drivers". */ diff --git a/trunk/arch/x86/lguest/i386_head.S b/trunk/arch/x86/lguest/i386_head.S index 95b6fbcded63..ebc6ac733899 100644 --- a/trunk/arch/x86/lguest/i386_head.S +++ b/trunk/arch/x86/lguest/i386_head.S @@ -6,7 +6,7 @@ #include /*G:020 This is where we begin: head.S notes that the boot header's platform - * type field is "1" (lguest), so calls us here. + * type field is "1" (lguest), so calls us here. The boot header is in %esi. * * WARNING: be very careful here! We're running at addresses equal to physical * addesses (around 0), not above PAGE_OFFSET as most code expectes @@ -17,15 +17,13 @@ * boot. */ .section .init.text, "ax", @progbits ENTRY(lguest_entry) - /* We make the "initialization" hypercall now to tell the Host about - * us, and also find out where it put our page tables. */ + /* Make initial hypercall now, so we can set up the pagetables. */ movl $LHCALL_LGUEST_INIT, %eax movl $lguest_data - __PAGE_OFFSET, %edx int $LGUEST_TRAP_ENTRY /* The Host put the toplevel pagetable in lguest_data.pgdir. The movsl - * instruction uses %esi implicitly as the source for the copy we' - * about to do. */ + * instruction uses %esi implicitly. */ movl lguest_data - __PAGE_OFFSET + LGUEST_DATA_pgdir, %esi /* Copy first 32 entries of page directory to __PAGE_OFFSET entries. diff --git a/trunk/arch/x86/mach-voyager/voyager_smp.c b/trunk/arch/x86/mach-voyager/voyager_smp.c index 69371434b0cf..361ac5107b33 100644 --- a/trunk/arch/x86/mach-voyager/voyager_smp.c +++ b/trunk/arch/x86/mach-voyager/voyager_smp.c @@ -29,14 +29,14 @@ #include /* TLB state -- visible externally, indexed physically */ -DEFINE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate) = { &init_mm, 0 }; +DEFINE_PER_CPU(struct tlb_state, cpu_tlbstate) ____cacheline_aligned = { &init_mm, 0 }; /* CPU IRQ affinity -- set to all ones initially */ static unsigned long cpu_irq_affinity[NR_CPUS] __cacheline_aligned = { [0 ... NR_CPUS-1] = ~0UL }; /* per CPU data structure (for /proc/cpuinfo et al), visible externally * indexed physically */ -DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info); +DEFINE_PER_CPU(cpuinfo_x86, cpu_info) __cacheline_aligned; EXPORT_PER_CPU_SYMBOL(cpu_info); /* physical ID of the CPU used to boot the system */ diff --git a/trunk/arch/x86/mm/discontig_32.c b/trunk/arch/x86/mm/discontig_32.c index 13a474d3c6e9..fe608a45ffb6 100644 --- a/trunk/arch/x86/mm/discontig_32.c +++ b/trunk/arch/x86/mm/discontig_32.c @@ -40,7 +40,7 @@ struct pglist_data *node_data[MAX_NUMNODES] __read_mostly; EXPORT_SYMBOL(node_data); -static bootmem_data_t node0_bdata; +bootmem_data_t node0_bdata; /* * numa interface - we expect the numa architecture specific code to have @@ -404,7 +404,7 @@ void __init set_highmem_pages_init(int bad_ppro) } #ifdef CONFIG_MEMORY_HOTPLUG -static int paddr_to_nid(u64 addr) +int paddr_to_nid(u64 addr) { int nid; unsigned long pfn = PFN_DOWN(addr); diff --git a/trunk/arch/x86/mm/fault_32.c b/trunk/arch/x86/mm/fault_32.c index 33563ee8eb0f..503dfc05111b 100644 --- a/trunk/arch/x86/mm/fault_32.c +++ b/trunk/arch/x86/mm/fault_32.c @@ -550,7 +550,7 @@ fastcall void __kprobes do_page_fault(struct pt_regs *regs, page &= PAGE_MASK; page = ((__typeof__(page) *) __va(page))[(address >> PMD_SHIFT) & (PTRS_PER_PMD - 1)]; - printk(KERN_CONT "*pde = %016Lx ", page); + printk(KERN_ALERT "*pde = %016Lx ", page); page &= ~_PAGE_NX; } #else diff --git a/trunk/arch/x86/mm/init_64.c b/trunk/arch/x86/mm/init_64.c index a7308b2cd058..1e3862e41065 100644 --- a/trunk/arch/x86/mm/init_64.c +++ b/trunk/arch/x86/mm/init_64.c @@ -728,6 +728,12 @@ int in_gate_area_no_task(unsigned long addr) return (addr >= VSYSCALL_START) && (addr < VSYSCALL_END); } +void * __init alloc_bootmem_high_node(pg_data_t *pgdat, unsigned long size) +{ + return __alloc_bootmem_core(pgdat->bdata, size, + SMP_CACHE_BYTES, (4UL*1024*1024*1024), 0); +} + const char *arch_vma_name(struct vm_area_struct *vma) { if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso) diff --git a/trunk/arch/x86/oprofile/Kconfig b/trunk/arch/x86/oprofile/Kconfig new file mode 100644 index 000000000000..d8a84088471a --- /dev/null +++ b/trunk/arch/x86/oprofile/Kconfig @@ -0,0 +1,17 @@ +config PROFILING + bool "Profiling support (EXPERIMENTAL)" + help + Say Y here to enable the extended profiling support mechanisms used + by profilers such as OProfile. + + +config OPROFILE + tristate "OProfile system profiling (EXPERIMENTAL)" + depends on PROFILING + help + OProfile is a profiling system capable of profiling the + whole system, include the kernel, kernel modules, libraries, + and applications. + + If unsure, say N. + diff --git a/trunk/arch/x86/xen/events.c b/trunk/arch/x86/xen/events.c index 6d1da5809e6f..da1b173547a1 100644 --- a/trunk/arch/x86/xen/events.c +++ b/trunk/arch/x86/xen/events.c @@ -383,7 +383,7 @@ static void unbind_from_irq(unsigned int irq) } int bind_evtchn_to_irqhandler(unsigned int evtchn, - irq_handler_t handler, + irqreturn_t (*handler)(int, void *), unsigned long irqflags, const char *devname, void *dev_id) { @@ -402,7 +402,7 @@ int bind_evtchn_to_irqhandler(unsigned int evtchn, EXPORT_SYMBOL_GPL(bind_evtchn_to_irqhandler); int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu, - irq_handler_t handler, + irqreturn_t (*handler)(int, void *), unsigned long irqflags, const char *devname, void *dev_id) { unsigned int irq; diff --git a/trunk/arch/x86_64/.gitignore b/trunk/arch/x86_64/.gitignore new file mode 100644 index 000000000000..36ef4c374d25 --- /dev/null +++ b/trunk/arch/x86_64/.gitignore @@ -0,0 +1 @@ +boot diff --git a/trunk/arch/x86/Kconfig.x86_64 b/trunk/arch/x86_64/Kconfig similarity index 99% rename from trunk/arch/x86/Kconfig.x86_64 rename to trunk/arch/x86_64/Kconfig index cc468ea61240..c2d24991bb2b 100644 --- a/trunk/arch/x86/Kconfig.x86_64 +++ b/trunk/arch/x86_64/Kconfig @@ -97,6 +97,10 @@ config X86_CMPXCHG bool default y +config EARLY_PRINTK + bool + default y + config GENERIC_ISA_DMA bool default y @@ -475,8 +479,8 @@ config HPET_EMULATE_RTC # Mark as embedded because too many people got it wrong. # The code disables itself when not needed. -config GART_IOMMU - bool "GART IOMMU support" if EMBEDDED +config IOMMU + bool "IOMMU support" if EMBEDDED default y select SWIOTLB select AGP @@ -683,7 +687,7 @@ source kernel/Kconfig.hz config K8_NB def_bool y - depends on AGP_AMD64 || GART_IOMMU || (PCI && NUMA) + depends on AGP_AMD64 || IOMMU || (PCI && NUMA) endmenu @@ -749,6 +753,7 @@ config PCI_DOMAINS config DMAR bool "Support for DMA Remapping Devices (EXPERIMENTAL)" depends on PCI_MSI && ACPI && EXPERIMENTAL + default y help DMA remapping (DMAR) devices support enables independent address translations for Direct Memory Access (DMA) from devices. @@ -828,9 +833,7 @@ source "drivers/firmware/Kconfig" source fs/Kconfig -source "kernel/Kconfig.instrumentation" - -source "arch/x86/Kconfig.debug" +source "arch/x86_64/Kconfig.debug" source "security/Kconfig" diff --git a/trunk/arch/x86_64/Kconfig.debug b/trunk/arch/x86_64/Kconfig.debug new file mode 100644 index 000000000000..775d211a5cf9 --- /dev/null +++ b/trunk/arch/x86_64/Kconfig.debug @@ -0,0 +1,61 @@ +menu "Kernel hacking" + +config TRACE_IRQFLAGS_SUPPORT + bool + default y + +source "lib/Kconfig.debug" + +config DEBUG_RODATA + bool "Write protect kernel read-only data structures" + depends on DEBUG_KERNEL + help + Mark the kernel read-only data as write-protected in the pagetables, + in order to catch accidental (and incorrect) writes to such const data. + This option may have a slight performance impact because a portion + of the kernel code won't be covered by a 2MB TLB anymore. + If in doubt, say "N". + +config IOMMU_DEBUG + depends on IOMMU && DEBUG_KERNEL + bool "Enable IOMMU debugging" + help + Force the IOMMU to on even when you have less than 4GB of + memory and add debugging code. On overflow always panic. And + allow to enable IOMMU leak tracing. Can be disabled at boot + time with iommu=noforce. This will also enable scatter gather + list merging. Currently not recommended for production + code. When you use it make sure you have a big enough + IOMMU/AGP aperture. Most of the options enabled by this can + be set more finegrained using the iommu= command line + options. See Documentation/x86_64/boot-options.txt for more + details. + +config IOMMU_LEAK + bool "IOMMU leak tracing" + depends on DEBUG_KERNEL + depends on IOMMU_DEBUG + help + Add a simple leak tracer to the IOMMU code. This is useful when you + are debugging a buggy device driver that leaks IOMMU mappings. + +config DEBUG_STACKOVERFLOW + bool "Check for stack overflows" + depends on DEBUG_KERNEL + help + This option will cause messages to be printed if free stack space + drops below a certain limit. + +config DEBUG_STACK_USAGE + bool "Stack utilization instrumentation" + depends on DEBUG_KERNEL + help + Enables the display of the minimum amount of free stack which each + task has ever had available in the sysrq-T and sysrq-P debug output. + + This option will slow down process creation somewhat. + +#config X86_REMOTE_DEBUG +# bool "kgdb debugging stub" + +endmenu diff --git a/trunk/arch/x86/Makefile_64 b/trunk/arch/x86_64/Makefile similarity index 96% rename from trunk/arch/x86/Makefile_64 rename to trunk/arch/x86_64/Makefile index 57e714a47af7..6d89ab762ffc 100644 --- a/trunk/arch/x86/Makefile_64 +++ b/trunk/arch/x86_64/Makefile @@ -1,5 +1,5 @@ # -# x86_64 Makefile +# x86_64/Makefile # # This file is included by the global makefile so that you can add your own # architecture-specific flags and dependencies. Remember to do have actions @@ -21,11 +21,8 @@ # # $Id: Makefile,v 1.31 2002/03/22 15:56:07 ak Exp $ -# BITS is used as extension for files which are available in a 32 bit -# and a 64 bit version to simplify shared Makefiles. -# e.g.: obj-y += foo_$(BITS).o -BITS := 64 -export BITS +# Fill in SRCARCH +SRCARCH := x86 LDFLAGS := -m elf_x86_64 OBJCOPYFLAGS := -O binary -R .note -R .comment -S diff --git a/trunk/arch/x86/configs/x86_64_defconfig b/trunk/arch/x86_64/defconfig similarity index 99% rename from trunk/arch/x86/configs/x86_64_defconfig rename to trunk/arch/x86_64/defconfig index 38a83f9c966f..b091c5e35558 100644 --- a/trunk/arch/x86/configs/x86_64_defconfig +++ b/trunk/arch/x86_64/defconfig @@ -170,7 +170,7 @@ CONFIG_HOTPLUG_CPU=y CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y CONFIG_HPET_TIMER=y CONFIG_HPET_EMULATE_RTC=y -CONFIG_GART_IOMMU=y +CONFIG_IOMMU=y # CONFIG_CALGARY_IOMMU is not set CONFIG_SWIOTLB=y CONFIG_X86_MCE=y diff --git a/trunk/arch/xtensa/Kconfig b/trunk/arch/xtensa/Kconfig index d3cb3d6af4c8..85ffbb491490 100644 --- a/trunk/arch/xtensa/Kconfig +++ b/trunk/arch/xtensa/Kconfig @@ -1,5 +1,5 @@ # For a description of the syntax of this configuration file, -# see Documentation/kbuild/kconfig-language.txt. +# see Documentation/kbuild/config-language.txt. mainmenu "Linux/Xtensa Kernel Configuration" diff --git a/trunk/block/cfq-iosched.c b/trunk/block/cfq-iosched.c index e47a9309eb48..54dc05439009 100644 --- a/trunk/block/cfq-iosched.c +++ b/trunk/block/cfq-iosched.c @@ -1443,11 +1443,8 @@ cfq_get_queue(struct cfq_data *cfqd, int is_sync, struct task_struct *tsk, cfqq = *async_cfqq; } - if (!cfqq) { + if (!cfqq) cfqq = cfq_find_alloc_queue(cfqd, is_sync, tsk, gfp_mask); - if (!cfqq) - return NULL; - } /* * pin the queue now that it's allocated, scheduler exit will prune it @@ -2056,7 +2053,7 @@ static void cfq_shutdown_timer_wq(struct cfq_data *cfqd) { del_timer_sync(&cfqd->idle_slice_timer); del_timer_sync(&cfqd->idle_class_timer); - kblockd_flush_work(&cfqd->unplug_work); + blk_sync_queue(cfqd->queue); } static void cfq_put_async_queues(struct cfq_data *cfqd) diff --git a/trunk/block/compat_ioctl.c b/trunk/block/compat_ioctl.c index cae0a852619e..f84093b97f70 100644 --- a/trunk/block/compat_ioctl.c +++ b/trunk/block/compat_ioctl.c @@ -581,7 +581,7 @@ static int compat_blkdev_driver_ioctl(struct inode *inode, struct file *file, { int ret; - switch (cmd) { + switch (arg) { case HDIO_GET_UNMASKINTR: case HDIO_GET_MULTCOUNT: case HDIO_GET_KEEPSETTINGS: diff --git a/trunk/block/ll_rw_blk.c b/trunk/block/ll_rw_blk.c index 56f2646612e6..de5ba479c224 100644 --- a/trunk/block/ll_rw_blk.c +++ b/trunk/block/ll_rw_blk.c @@ -39,7 +39,7 @@ static void blk_unplug_work(struct work_struct *work); static void blk_unplug_timeout(unsigned long data); -static void drive_stat_acct(struct request *rq, int new_io); +static void drive_stat_acct(struct request *rq, int nr_sectors, int new_io); static void init_request_from_bio(struct request *req, struct bio *bio); static int __make_request(struct request_queue *q, struct bio *bio); static struct io_context *current_io_context(gfp_t gfp_flags, int node); @@ -791,6 +791,7 @@ static int __blk_free_tags(struct blk_queue_tag *bqt) retval = atomic_dec_and_test(&bqt->refcnt); if (retval) { BUG_ON(bqt->busy); + BUG_ON(!list_empty(&bqt->busy_list)); kfree(bqt->tag_index); bqt->tag_index = NULL; @@ -902,6 +903,7 @@ static struct blk_queue_tag *__blk_queue_init_tags(struct request_queue *q, if (init_tag_map(q, tags, depth)) goto fail; + INIT_LIST_HEAD(&tags->busy_list); tags->busy = 0; atomic_set(&tags->refcnt, 1); return tags; @@ -952,7 +954,6 @@ int blk_queue_init_tags(struct request_queue *q, int depth, */ q->queue_tags = tags; q->queue_flags |= (1 << QUEUE_FLAG_QUEUED); - INIT_LIST_HEAD(&q->tag_busy_list); return 0; fail: kfree(tags); @@ -1056,16 +1057,18 @@ void blk_queue_end_tag(struct request_queue *q, struct request *rq) bqt->tag_index[tag] = NULL; - if (unlikely(!test_bit(tag, bqt->tag_map))) { + /* + * We use test_and_clear_bit's memory ordering properties here. + * The tag_map bit acts as a lock for tag_index[bit], so we need + * a barrer before clearing the bit (precisely: release semantics). + * Could use clear_bit_unlock when it is merged. + */ + if (unlikely(!test_and_clear_bit(tag, bqt->tag_map))) { printk(KERN_ERR "%s: attempt to clear non-busy tag (%d)\n", __FUNCTION__, tag); return; } - /* - * The tag_map bit acts as a lock for tag_index[bit], so we need - * unlock memory barrier semantics. - */ - clear_bit_unlock(tag, bqt->tag_map); + bqt->busy--; } @@ -1111,17 +1114,17 @@ int blk_queue_start_tag(struct request_queue *q, struct request *rq) if (tag >= bqt->max_depth) return 1; - } while (test_and_set_bit_lock(tag, bqt->tag_map)); + } while (test_and_set_bit(tag, bqt->tag_map)); /* - * We need lock ordering semantics given by test_and_set_bit_lock. - * See blk_queue_end_tag for details. + * We rely on test_and_set_bit providing lock memory ordering semantics + * (could use test_and_set_bit_lock when it is merged). */ rq->cmd_flags |= REQ_QUEUED; rq->tag = tag; bqt->tag_index[tag] = rq; blkdev_dequeue_request(rq); - list_add(&rq->queuelist, &q->tag_busy_list); + list_add(&rq->queuelist, &bqt->busy_list); bqt->busy++; return 0; } @@ -1142,10 +1145,11 @@ EXPORT_SYMBOL(blk_queue_start_tag); **/ void blk_queue_invalidate_tags(struct request_queue *q) { + struct blk_queue_tag *bqt = q->queue_tags; struct list_head *tmp, *n; struct request *rq; - list_for_each_safe(tmp, n, &q->tag_busy_list) { + list_for_each_safe(tmp, n, &bqt->busy_list) { rq = list_entry_rq(tmp); if (rq->tag == -1) { @@ -1362,7 +1366,9 @@ int blk_rq_map_sg(struct request_queue *q, struct request *rq, sg = sg_next(sg); } - sg_set_page(sg, bvec->bv_page, nbytes, bvec->bv_offset); + sg_set_page(sg, bvec->bv_page); + sg->length = nbytes; + sg->offset = bvec->bv_offset; nsegs++; } bvprv = bvec; @@ -1734,7 +1740,6 @@ EXPORT_SYMBOL(blk_stop_queue); void blk_sync_queue(struct request_queue *q) { del_timer_sync(&q->unplug_timer); - kblockd_flush_work(&q->unplug_work); } EXPORT_SYMBOL(blk_sync_queue); @@ -2338,7 +2343,7 @@ void blk_insert_request(struct request_queue *q, struct request *rq, if (blk_rq_tagged(rq)) blk_queue_end_tag(q, rq); - drive_stat_acct(rq, 1); + drive_stat_acct(rq, rq->nr_sectors, 1); __elv_add_request(q, rq, where, 0); blk_start_queueing(q); spin_unlock_irqrestore(q->queue_lock, flags); @@ -2733,7 +2738,7 @@ int blkdev_issue_flush(struct block_device *bdev, sector_t *error_sector) EXPORT_SYMBOL(blkdev_issue_flush); -static void drive_stat_acct(struct request *rq, int new_io) +static void drive_stat_acct(struct request *rq, int nr_sectors, int new_io) { int rw = rq_data_dir(rq); @@ -2755,7 +2760,7 @@ static void drive_stat_acct(struct request *rq, int new_io) */ static inline void add_request(struct request_queue * q, struct request * req) { - drive_stat_acct(req, 1); + drive_stat_acct(req, req->nr_sectors, 1); /* * elevator indicated where it wants this request to be @@ -3012,7 +3017,7 @@ static int __make_request(struct request_queue *q, struct bio *bio) req->biotail = bio; req->nr_sectors = req->hard_nr_sectors += nr_sectors; req->ioprio = ioprio_best(req->ioprio, prio); - drive_stat_acct(req, 0); + drive_stat_acct(req, nr_sectors, 0); if (!attempt_back_merge(q, req)) elv_merged_request(q, req, el_ret); goto out; @@ -3039,7 +3044,7 @@ static int __make_request(struct request_queue *q, struct bio *bio) req->sector = req->hard_sector = bio->bi_sector; req->nr_sectors = req->hard_nr_sectors += nr_sectors; req->ioprio = ioprio_best(req->ioprio, prio); - drive_stat_acct(req, 0); + drive_stat_acct(req, nr_sectors, 0); if (!attempt_front_merge(q, req)) elv_merged_request(q, req, el_ret); goto out; diff --git a/trunk/crypto/hmac.c b/trunk/crypto/hmac.c index 0f05be769c34..e4eb6ac53b5c 100644 --- a/trunk/crypto/hmac.c +++ b/trunk/crypto/hmac.c @@ -61,7 +61,7 @@ static int hmac_setkey(struct crypto_hash *parent, desc.tfm = tfm; desc.flags = crypto_hash_get_flags(parent); desc.flags &= CRYPTO_TFM_REQ_MAY_SLEEP; - sg_init_one(&tmp, inkey, keylen); + sg_set_buf(&tmp, inkey, keylen); err = crypto_hash_digest(&desc, &tmp, keylen, digest); if (err) @@ -96,7 +96,7 @@ static int hmac_init(struct hash_desc *pdesc) desc.tfm = ctx->child; desc.flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP; - sg_init_one(&tmp, ipad, bs); + sg_set_buf(&tmp, ipad, bs); err = crypto_hash_init(&desc); if (unlikely(err)) @@ -131,7 +131,7 @@ static int hmac_final(struct hash_desc *pdesc, u8 *out) desc.tfm = ctx->child; desc.flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP; - sg_init_one(&tmp, opad, bs + ds); + sg_set_buf(&tmp, opad, bs + ds); err = crypto_hash_final(&desc, digest); if (unlikely(err)) @@ -158,11 +158,10 @@ static int hmac_digest(struct hash_desc *pdesc, struct scatterlist *sg, desc.tfm = ctx->child; desc.flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP; - sg_init_table(sg1, 2); sg_set_buf(sg1, ipad, bs); - sg_set_page(&sg1[1], (void *) sg, 0, 0); - sg_init_table(sg2, 1); + sg_set_page(&sg[1], (void *) sg); + sg1[1].length = 0; sg_set_buf(sg2, opad, bs + ds); err = crypto_hash_digest(&desc, sg1, nbytes + bs, digest); diff --git a/trunk/crypto/tcrypt.c b/trunk/crypto/tcrypt.c index 24141fb6f5cb..d741c63af42c 100644 --- a/trunk/crypto/tcrypt.c +++ b/trunk/crypto/tcrypt.c @@ -139,7 +139,7 @@ static void test_hash(char *algo, struct hash_testvec *template, printk("test %u:\n", i + 1); memset(result, 0, 64); - sg_init_one(&sg[0], hash_tv[i].plaintext, hash_tv[i].psize); + sg_set_buf(&sg[0], hash_tv[i].plaintext, hash_tv[i].psize); if (hash_tv[i].ksize) { ret = crypto_hash_setkey(tfm, hash_tv[i].key, @@ -176,7 +176,6 @@ static void test_hash(char *algo, struct hash_testvec *template, memset(result, 0, 64); temp = 0; - sg_init_table(sg, hash_tv[i].np); for (k = 0; k < hash_tv[i].np; k++) { memcpy(&xbuf[IDX[k]], hash_tv[i].plaintext + temp, @@ -290,8 +289,8 @@ static void test_cipher(char *algo, int enc, goto out; } - sg_init_one(&sg[0], cipher_tv[i].input, - cipher_tv[i].ilen); + sg_set_buf(&sg[0], cipher_tv[i].input, + cipher_tv[i].ilen); ablkcipher_request_set_crypt(req, sg, sg, cipher_tv[i].ilen, @@ -354,7 +353,6 @@ static void test_cipher(char *algo, int enc, } temp = 0; - sg_init_table(sg, cipher_tv[i].np); for (k = 0; k < cipher_tv[i].np; k++) { memcpy(&xbuf[IDX[k]], cipher_tv[i].input + temp, @@ -416,7 +414,7 @@ static int test_cipher_jiffies(struct blkcipher_desc *desc, int enc, char *p, int bcount; int ret; - sg_init_one(sg, p, blen); + sg_set_buf(sg, p, blen); for (start = jiffies, end = start + sec * HZ, bcount = 0; time_before(jiffies, end); bcount++) { @@ -442,7 +440,7 @@ static int test_cipher_cycles(struct blkcipher_desc *desc, int enc, char *p, int ret = 0; int i; - sg_init_one(sg, p, blen); + sg_set_buf(sg, p, blen); local_bh_disable(); local_irq_disable(); @@ -572,8 +570,6 @@ static int test_hash_jiffies_digest(struct hash_desc *desc, char *p, int blen, int bcount; int ret; - sg_init_table(sg, 1); - for (start = jiffies, end = start + sec * HZ, bcount = 0; time_before(jiffies, end); bcount++) { sg_set_buf(sg, p, blen); @@ -599,8 +595,6 @@ static int test_hash_jiffies(struct hash_desc *desc, char *p, int blen, if (plen == blen) return test_hash_jiffies_digest(desc, p, blen, out, sec); - sg_init_table(sg, 1); - for (start = jiffies, end = start + sec * HZ, bcount = 0; time_before(jiffies, end); bcount++) { ret = crypto_hash_init(desc); @@ -632,8 +626,6 @@ static int test_hash_cycles_digest(struct hash_desc *desc, char *p, int blen, int i; int ret; - sg_init_table(sg, 1); - local_bh_disable(); local_irq_disable(); @@ -685,8 +677,6 @@ static int test_hash_cycles(struct hash_desc *desc, char *p, int blen, if (plen == blen) return test_hash_cycles_digest(desc, p, blen, out); - sg_init_table(sg, 1); - local_bh_disable(); local_irq_disable(); diff --git a/trunk/drivers/Makefile b/trunk/drivers/Makefile index 8cb37e3557d4..560496b43306 100644 --- a/trunk/drivers/Makefile +++ b/trunk/drivers/Makefile @@ -34,6 +34,7 @@ obj-$(CONFIG_NUBUS) += nubus/ obj-$(CONFIG_ATM) += atm/ obj-y += macintosh/ obj-$(CONFIG_IDE) += ide/ +obj-$(CONFIG_FC4) += fc4/ obj-$(CONFIG_SCSI) += scsi/ obj-$(CONFIG_ATA) += ata/ obj-$(CONFIG_FUSION) += message/ diff --git a/trunk/drivers/acpi/Kconfig b/trunk/drivers/acpi/Kconfig index da3a08fa9e4f..5d0e26a5c34c 100644 --- a/trunk/drivers/acpi/Kconfig +++ b/trunk/drivers/acpi/Kconfig @@ -3,7 +3,7 @@ # menuconfig ACPI - bool "ACPI (Advanced Configuration and Power Interface) Support" + bool "ACPI Support (Advanced Configuration and Power Interface) Support" depends on !X86_NUMAQ depends on !X86_VISWS depends on !IA64_HP_SIM @@ -88,8 +88,7 @@ config ACPI_PROC_EVENT config ACPI_AC tristate "AC Adapter" - depends on X86 - select POWER_SUPPLY + depends on X86 && POWER_SUPPLY default y help This driver adds support for the AC Adapter object, which indicates @@ -98,8 +97,7 @@ config ACPI_AC config ACPI_BATTERY tristate "Battery" - depends on X86 - select POWER_SUPPLY + depends on X86 && POWER_SUPPLY default y help This driver adds support for battery information through @@ -354,7 +352,7 @@ config ACPI_HOTPLUG_MEMORY config ACPI_SBS tristate "Smart Battery System" depends on X86 - select POWER_SUPPLY + depends on POWER_SUPPLY help This driver adds support for the Smart Battery System, another type of access to battery information, found on some laptops. diff --git a/trunk/drivers/acpi/battery.c b/trunk/drivers/acpi/battery.c index c2ce0ad21693..681e26b56b11 100644 --- a/trunk/drivers/acpi/battery.c +++ b/trunk/drivers/acpi/battery.c @@ -125,15 +125,11 @@ static int acpi_battery_technology(struct acpi_battery *battery) return POWER_SUPPLY_TECHNOLOGY_NiMH; if (!strcasecmp("LION", battery->type)) return POWER_SUPPLY_TECHNOLOGY_LION; - if (!strcasecmp("LI-ION", battery->type)) - return POWER_SUPPLY_TECHNOLOGY_LION; if (!strcasecmp("LiP", battery->type)) return POWER_SUPPLY_TECHNOLOGY_LIPO; return POWER_SUPPLY_TECHNOLOGY_UNKNOWN; } -static int acpi_battery_update(struct acpi_battery *battery); - static int acpi_battery_get_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) @@ -143,7 +139,6 @@ static int acpi_battery_get_property(struct power_supply *psy, if ((!acpi_battery_present(battery)) && psp != POWER_SUPPLY_PROP_PRESENT) return -ENODEV; - acpi_battery_update(battery); switch (psp) { case POWER_SUPPLY_PROP_STATUS: if (battery->state & 0x01) @@ -262,7 +257,7 @@ static int extract_package(struct acpi_battery *battery, union acpi_object *package, struct acpi_offsets *offsets, int num) { - int i; + int i, *x; union acpi_object *element; if (package->type != ACPI_TYPE_PACKAGE) return -EFAULT; @@ -271,21 +266,16 @@ static int extract_package(struct acpi_battery *battery, return -EFAULT; element = &package->package.elements[i]; if (offsets[i].mode) { - u8 *ptr = (u8 *)battery + offsets[i].offset; - if (element->type == ACPI_TYPE_STRING || - element->type == ACPI_TYPE_BUFFER) - strncpy(ptr, element->string.pointer, 32); - else if (element->type == ACPI_TYPE_INTEGER) { - strncpy(ptr, (u8 *)&element->integer.value, - sizeof(acpi_integer)); - ptr[sizeof(acpi_integer)] = 0; - } else return -EFAULT; + if (element->type != ACPI_TYPE_STRING && + element->type != ACPI_TYPE_BUFFER) + return -EFAULT; + strncpy((u8 *)battery + offsets[i].offset, + element->string.pointer, 32); } else { - if (element->type == ACPI_TYPE_INTEGER) { - int *x = (int *)((u8 *)battery + - offsets[i].offset); - *x = element->integer.value; - } else return -EFAULT; + if (element->type != ACPI_TYPE_INTEGER) + return -EFAULT; + x = (int *)((u8 *)battery + offsets[i].offset); + *x = element->integer.value; } } return 0; @@ -395,81 +385,29 @@ static int acpi_battery_init_alarm(struct acpi_battery *battery) return acpi_battery_set_alarm(battery); } -static ssize_t acpi_battery_alarm_show(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); - return sprintf(buf, "%d\n", battery->alarm * 1000); -} - -static ssize_t acpi_battery_alarm_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - unsigned long x; - struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); - if (sscanf(buf, "%ld\n", &x) == 1) - battery->alarm = x/1000; - if (acpi_battery_present(battery)) - acpi_battery_set_alarm(battery); - return count; -} - -static struct device_attribute alarm_attr = { - .attr = {.name = "alarm", .mode = 0644, .owner = THIS_MODULE}, - .show = acpi_battery_alarm_show, - .store = acpi_battery_alarm_store, -}; - -static int sysfs_add_battery(struct acpi_battery *battery) -{ - int result; - - battery->update_time = 0; - result = acpi_battery_get_info(battery); - acpi_battery_init_alarm(battery); - if (result) - return result; - if (battery->power_unit) { - battery->bat.properties = charge_battery_props; - battery->bat.num_properties = - ARRAY_SIZE(charge_battery_props); - } else { - battery->bat.properties = energy_battery_props; - battery->bat.num_properties = - ARRAY_SIZE(energy_battery_props); - } - - battery->bat.name = acpi_device_bid(battery->device); - battery->bat.type = POWER_SUPPLY_TYPE_BATTERY; - battery->bat.get_property = acpi_battery_get_property; - - result = power_supply_register(&battery->device->dev, &battery->bat); - if (result) - return result; - return device_create_file(battery->bat.dev, &alarm_attr); -} - -static void sysfs_remove_battery(struct acpi_battery *battery) -{ - if (!battery->bat.dev) - return; - device_remove_file(battery->bat.dev, &alarm_attr); - power_supply_unregister(&battery->bat); -} - static int acpi_battery_update(struct acpi_battery *battery) { + int saved_present = acpi_battery_present(battery); int result = acpi_battery_get_status(battery); - if (result) + if (result || !acpi_battery_present(battery)) return result; - if (!acpi_battery_present(battery)) { - sysfs_remove_battery(battery); - return 0; + if (saved_present != acpi_battery_present(battery) || + !battery->update_time) { + battery->update_time = 0; + result = acpi_battery_get_info(battery); + if (result) + return result; + if (battery->power_unit) { + battery->bat.properties = charge_battery_props; + battery->bat.num_properties = + ARRAY_SIZE(charge_battery_props); + } else { + battery->bat.properties = energy_battery_props; + battery->bat.num_properties = + ARRAY_SIZE(energy_battery_props); + } + acpi_battery_init_alarm(battery); } - if (!battery->bat.dev) - sysfs_add_battery(battery); return acpi_battery_get_state(battery); } @@ -616,6 +554,10 @@ static ssize_t acpi_battery_write_alarm(struct file *file, if (!battery || (count > sizeof(alarm_string) - 1)) return -EINVAL; + if (result) { + result = -ENODEV; + goto end; + } if (!acpi_battery_present(battery)) { result = -ENODEV; goto end; @@ -746,6 +688,33 @@ static void acpi_battery_remove_fs(struct acpi_device *device) #endif +static ssize_t acpi_battery_alarm_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); + return sprintf(buf, "%d\n", battery->alarm * 1000); +} + +static ssize_t acpi_battery_alarm_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + unsigned long x; + struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); + if (sscanf(buf, "%ld\n", &x) == 1) + battery->alarm = x/1000; + if (acpi_battery_present(battery)) + acpi_battery_set_alarm(battery); + return count; +} + +static struct device_attribute alarm_attr = { + .attr = {.name = "alarm", .mode = 0644, .owner = THIS_MODULE}, + .show = acpi_battery_alarm_show, + .store = acpi_battery_alarm_store, +}; + /* -------------------------------------------------------------------------- Driver Interface -------------------------------------------------------------------------- */ @@ -763,9 +732,7 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) acpi_bus_generate_netlink_event(device->pnp.device_class, device->dev.bus_id, event, acpi_battery_present(battery)); - /* acpi_batter_update could remove power_supply object */ - if (battery->bat.dev) - kobject_uevent(&battery->bat.dev->kobj, KOBJ_CHANGE); + kobject_uevent(&battery->bat.dev->kobj, KOBJ_CHANGE); } static int acpi_battery_add(struct acpi_device *device) @@ -789,6 +756,11 @@ static int acpi_battery_add(struct acpi_device *device) if (result) goto end; #endif + battery->bat.name = acpi_device_bid(device); + battery->bat.type = POWER_SUPPLY_TYPE_BATTERY; + battery->bat.get_property = acpi_battery_get_property; + result = power_supply_register(&battery->device->dev, &battery->bat); + result = device_create_file(battery->bat.dev, &alarm_attr); status = acpi_install_notify_handler(device->handle, ACPI_ALL_NOTIFY, acpi_battery_notify, battery); @@ -824,7 +796,10 @@ static int acpi_battery_remove(struct acpi_device *device, int type) #ifdef CONFIG_ACPI_PROCFS acpi_battery_remove_fs(device); #endif - sysfs_remove_battery(battery); + if (battery->bat.dev) { + device_remove_file(battery->bat.dev, &alarm_attr); + power_supply_unregister(&battery->bat); + } mutex_destroy(&battery->lock); kfree(battery); return 0; @@ -838,7 +813,6 @@ static int acpi_battery_resume(struct acpi_device *device) return -EINVAL; battery = acpi_driver_data(device); battery->update_time = 0; - acpi_battery_update(battery); return 0; } diff --git a/trunk/drivers/acpi/bus.c b/trunk/drivers/acpi/bus.c index 49d432d0a12c..fb2cff9a2d24 100644 --- a/trunk/drivers/acpi/bus.c +++ b/trunk/drivers/acpi/bus.c @@ -198,10 +198,12 @@ int acpi_bus_set_power(acpi_handle handle, int state) return -ENODEV; } /* - * Get device's current power state + * Get device's current power state if it's unknown + * This means device power state isn't initialized or previous setting failed */ - acpi_bus_get_power(device->handle, &device->power.state); - if (state == device->power.state) { + if ((device->power.state == ACPI_STATE_UNKNOWN) || device->flags.force_power_state) + acpi_bus_get_power(device->handle, &device->power.state); + if ((state == device->power.state) && !device->flags.force_power_state) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", state)); return 0; diff --git a/trunk/drivers/acpi/button.c b/trunk/drivers/acpi/button.c index 24a7865a57cb..301e832e6961 100644 --- a/trunk/drivers/acpi/button.c +++ b/trunk/drivers/acpi/button.c @@ -78,7 +78,6 @@ MODULE_DEVICE_TABLE(acpi, button_device_ids); static int acpi_button_add(struct acpi_device *device); static int acpi_button_remove(struct acpi_device *device, int type); -static int acpi_button_resume(struct acpi_device *device); static int acpi_button_info_open_fs(struct inode *inode, struct file *file); static int acpi_button_state_open_fs(struct inode *inode, struct file *file); @@ -88,7 +87,6 @@ static struct acpi_driver acpi_button_driver = { .ids = button_device_ids, .ops = { .add = acpi_button_add, - .resume = acpi_button_resume, .remove = acpi_button_remove, }, }; @@ -255,19 +253,6 @@ static int acpi_button_remove_fs(struct acpi_device *device) /* -------------------------------------------------------------------------- Driver Interface -------------------------------------------------------------------------- */ -static int acpi_lid_send_state(struct acpi_button *button) -{ - unsigned long state; - acpi_status status; - - status = acpi_evaluate_integer(button->device->handle, "_LID", NULL, - &state); - if (ACPI_FAILURE(status)) - return -ENODEV; - /* input layer checks if event is redundant */ - input_report_switch(button->input, SW_LID, !state); - return 0; -} static void acpi_button_notify(acpi_handle handle, u32 event, void *data) { @@ -280,8 +265,15 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data) switch (event) { case ACPI_BUTTON_NOTIFY_STATUS: input = button->input; + if (button->type == ACPI_BUTTON_TYPE_LID) { - acpi_lid_send_state(button); + struct acpi_handle *handle = button->device->handle; + unsigned long state; + + if (!ACPI_FAILURE(acpi_evaluate_integer(handle, "_LID", + NULL, &state))) + input_report_switch(input, SW_LID, !state); + } else { int keycode = test_bit(KEY_SLEEP, input->keybit) ? KEY_SLEEP : KEY_POWER; @@ -344,17 +336,6 @@ static int acpi_button_install_notify_handlers(struct acpi_button *button) return ACPI_FAILURE(status) ? -ENODEV : 0; } -static int acpi_button_resume(struct acpi_device *device) -{ - struct acpi_button *button; - if (!device) - return -EINVAL; - button = acpi_driver_data(device); - if (button && button->type == ACPI_BUTTON_TYPE_LID) - return acpi_lid_send_state(button); - return 0; -} - static void acpi_button_remove_notify_handlers(struct acpi_button *button) { switch (button->type) { @@ -472,8 +453,6 @@ static int acpi_button_add(struct acpi_device *device) error = input_register_device(input); if (error) goto err_remove_handlers; - if (button->type == ACPI_BUTTON_TYPE_LID) - acpi_lid_send_state(button); if (device->wakeup.flags.valid) { /* Button's GPE is run-wake GPE */ diff --git a/trunk/drivers/acpi/ec.c b/trunk/drivers/acpi/ec.c index 06b78e5e33a1..7b4178393e34 100644 --- a/trunk/drivers/acpi/ec.c +++ b/trunk/drivers/acpi/ec.c @@ -65,18 +65,16 @@ enum ec_command { /* EC events */ enum ec_event { ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */ - ACPI_EC_EVENT_IBF_0, /* Input buffer empty */ + ACPI_EC_EVENT_IBF_0, /* Input buffer empty */ }; #define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */ #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ -enum { - EC_FLAGS_WAIT_GPE = 0, /* Don't check status until GPE arrives */ - EC_FLAGS_QUERY_PENDING, /* Query is pending */ - EC_FLAGS_GPE_MODE, /* Expect GPE to be sent for status change */ - EC_FLAGS_ONLY_IBF_GPE, /* Expect GPE only for IBF = 0 event */ -}; +static enum ec_mode { + EC_INTR = 1, /* Output buffer full */ + EC_POLL, /* Input buffer empty */ +} acpi_ec_mode = EC_INTR; static int acpi_ec_remove(struct acpi_device *device, int type); static int acpi_ec_start(struct acpi_device *device); @@ -118,8 +116,9 @@ static struct acpi_ec { unsigned long command_addr; unsigned long data_addr; unsigned long global_lock; - unsigned long flags; struct mutex lock; + atomic_t query_pending; + atomic_t event_count; wait_queue_head_t wait; struct list_head list; u8 handlers_installed; @@ -149,54 +148,45 @@ static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data) outb(data, ec->data_addr); } -static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event) +static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event, + unsigned old_count) { - if (test_bit(EC_FLAGS_WAIT_GPE, &ec->flags)) + u8 status = acpi_ec_read_status(ec); + if (old_count == atomic_read(&ec->event_count)) return 0; if (event == ACPI_EC_EVENT_OBF_1) { - if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_OBF) + if (status & ACPI_EC_FLAG_OBF) return 1; } else if (event == ACPI_EC_EVENT_IBF_0) { - if (!(acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF)) + if (!(status & ACPI_EC_FLAG_IBF)) return 1; } return 0; } -static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll) +static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, + unsigned count, int force_poll) { - if (likely(test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) && - likely(!force_poll)) { - if (wait_event_timeout(ec->wait, acpi_ec_check_status(ec, event), - msecs_to_jiffies(ACPI_EC_DELAY))) - return 0; - clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); - if (acpi_ec_check_status(ec, event)) { - if (event == ACPI_EC_EVENT_OBF_1) { - /* miss OBF = 1 GPE, don't expect it anymore */ - printk(KERN_INFO PREFIX "missing OBF_1 confirmation," - "switching to degraded mode.\n"); - set_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags); - } else { - /* missing GPEs, switch back to poll mode */ - printk(KERN_INFO PREFIX "missing IBF_1 confirmations," - "switch off interrupt mode.\n"); - clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); - } - return 0; - } - } else { + if (unlikely(force_poll) || acpi_ec_mode == EC_POLL) { unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); - clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); while (time_before(jiffies, delay)) { - if (acpi_ec_check_status(ec, event)) + if (acpi_ec_check_status(ec, event, 0)) return 0; } - } - printk(KERN_ERR PREFIX "acpi_ec_wait timeout," + } else { + if (wait_event_timeout(ec->wait, + acpi_ec_check_status(ec, event, count), + msecs_to_jiffies(ACPI_EC_DELAY)) || + acpi_ec_check_status(ec, event, 0)) { + return 0; + } else { + printk(KERN_ERR PREFIX "acpi_ec_wait timeout," " status = %d, expect_event = %d\n", acpi_ec_read_status(ec), event); + } + } + return -ETIME; } @@ -206,42 +196,39 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, int force_poll) { int result = 0; - set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); + unsigned count = atomic_read(&ec->event_count); acpi_ec_write_cmd(ec, command); for (; wdata_len > 0; --wdata_len) { - result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll); + result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, count, force_poll); if (result) { printk(KERN_ERR PREFIX "write_cmd timeout, command = %d\n", command); goto end; } - set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); + count = atomic_read(&ec->event_count); acpi_ec_write_data(ec, *(wdata++)); } if (!rdata_len) { - result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll); + result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, count, force_poll); if (result) { printk(KERN_ERR PREFIX "finish-write timeout, command = %d\n", command); goto end; } - } else if (command == ACPI_EC_COMMAND_QUERY) - clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); + } else if (command == ACPI_EC_COMMAND_QUERY) { + atomic_set(&ec->query_pending, 0); + } for (; rdata_len > 0; --rdata_len) { - if (test_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags)) - force_poll = 1; - result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, force_poll); + result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, count, force_poll); if (result) { printk(KERN_ERR PREFIX "read timeout, command = %d\n", command); goto end; } - /* Don't expect GPE after last read */ - if (rdata_len > 1) - set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); + count = atomic_read(&ec->event_count); *(rdata++) = acpi_ec_read_data(ec); } end: @@ -271,7 +258,10 @@ static int acpi_ec_transaction(struct acpi_ec *ec, u8 command, } } - status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0); + /* Make sure GPE is enabled before doing transaction */ + acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); + + status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0, 0); if (status) { printk(KERN_ERR PREFIX "input buffer is not empty, aborting transaction\n"); @@ -445,9 +435,9 @@ EXPORT_SYMBOL_GPL(acpi_ec_add_query_handler); void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit) { - struct acpi_ec_query_handler *handler, *tmp; + struct acpi_ec_query_handler *handler; mutex_lock(&ec->lock); - list_for_each_entry_safe(handler, tmp, &ec->list, node) { + list_for_each_entry(handler, &ec->list, node) { if (query_bit == handler->query_bit) { list_del(&handler->node); kfree(handler); @@ -486,24 +476,23 @@ static void acpi_ec_gpe_query(void *ec_cxt) static u32 acpi_ec_gpe_handler(void *data) { acpi_status status = AE_OK; + u8 value; struct acpi_ec *ec = data; - clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); - if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) + atomic_inc(&ec->event_count); + + if (acpi_ec_mode == EC_INTR) { wake_up(&ec->wait); + } - if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_SCI) { - if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) - status = acpi_os_execute(OSL_EC_BURST_HANDLER, - acpi_ec_gpe_query, ec); - } else if (unlikely(!test_bit(EC_FLAGS_GPE_MODE, &ec->flags))) { - /* this is non-query, must be confirmation */ - printk(KERN_INFO PREFIX "non-query interrupt received," - " switching to interrupt mode\n"); - set_bit(EC_FLAGS_GPE_MODE, &ec->flags); + value = acpi_ec_read_status(ec); + if ((value & ACPI_EC_FLAG_SCI) && !atomic_read(&ec->query_pending)) { + atomic_set(&ec->query_pending, 1); + status = + acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query, ec); } - return ACPI_SUCCESS(status) ? + return status == AE_OK ? ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; } @@ -652,10 +641,13 @@ static struct acpi_ec *make_acpi_ec(void) struct acpi_ec *ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL); if (!ec) return NULL; - ec->flags = 1 << EC_FLAGS_QUERY_PENDING; + + atomic_set(&ec->query_pending, 1); + atomic_set(&ec->event_count, 1); mutex_init(&ec->lock); init_waitqueue_head(&ec->wait); INIT_LIST_HEAD(&ec->list); + return ec; } @@ -749,8 +741,6 @@ static int acpi_ec_add(struct acpi_device *device) acpi_ec_add_fs(device); printk(KERN_INFO PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n", ec->gpe, ec->command_addr, ec->data_addr); - printk(KERN_INFO PREFIX "driver started in %s mode\n", - (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))?"interrupt":"poll"); return 0; } @@ -843,7 +833,7 @@ static int acpi_ec_start(struct acpi_device *device) ret = ec_install_handlers(ec); /* EC is fully operational, allow queries */ - clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); + atomic_set(&ec->query_pending, 0); return ret; } @@ -934,4 +924,20 @@ static void __exit acpi_ec_exit(void) return; } -#endif /* 0 */ +#endif /* 0 */ + +static int __init acpi_ec_set_intr_mode(char *str) +{ + int intr; + + if (!get_option(&str, &intr)) + return 0; + + acpi_ec_mode = (intr) ? EC_INTR : EC_POLL; + + printk(KERN_NOTICE PREFIX "%s mode.\n", intr ? "interrupt" : "polling"); + + return 1; +} + +__setup("ec_intr=", acpi_ec_set_intr_mode); diff --git a/trunk/drivers/acpi/fan.c b/trunk/drivers/acpi/fan.c index a5a5532db268..c81f6bdb68b8 100644 --- a/trunk/drivers/acpi/fan.c +++ b/trunk/drivers/acpi/fan.c @@ -47,6 +47,8 @@ MODULE_LICENSE("GPL"); static int acpi_fan_add(struct acpi_device *device); static int acpi_fan_remove(struct acpi_device *device, int type); +static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state); +static int acpi_fan_resume(struct acpi_device *device); static const struct acpi_device_id fan_device_ids[] = { {"PNP0C0B", 0}, @@ -61,9 +63,15 @@ static struct acpi_driver acpi_fan_driver = { .ops = { .add = acpi_fan_add, .remove = acpi_fan_remove, + .suspend = acpi_fan_suspend, + .resume = acpi_fan_resume, }, }; +struct acpi_fan { + struct acpi_device * device; +}; + /* -------------------------------------------------------------------------- FS Interface (/proc) -------------------------------------------------------------------------- */ @@ -72,12 +80,12 @@ static struct proc_dir_entry *acpi_fan_dir; static int acpi_fan_read_state(struct seq_file *seq, void *offset) { - struct acpi_device *device = seq->private; + struct acpi_fan *fan = seq->private; int state = 0; - if (device) { - if (acpi_bus_get_power(device->handle, &state)) + if (fan) { + if (acpi_bus_get_power(fan->device->handle, &state)) seq_printf(seq, "status: ERROR\n"); else seq_printf(seq, "status: %s\n", @@ -97,10 +105,11 @@ acpi_fan_write_state(struct file *file, const char __user * buffer, { int result = 0; struct seq_file *m = file->private_data; - struct acpi_device *device = m->private; + struct acpi_fan *fan = m->private; char state_string[12] = { '\0' }; - if (count > sizeof(state_string) - 1) + + if (!fan || (count > sizeof(state_string) - 1)) return -EINVAL; if (copy_from_user(state_string, buffer, count)) @@ -108,7 +117,7 @@ acpi_fan_write_state(struct file *file, const char __user * buffer, state_string[count] = '\0'; - result = acpi_bus_set_power(device->handle, + result = acpi_bus_set_power(fan->device->handle, simple_strtoul(state_string, NULL, 0)); if (result) return result; @@ -149,7 +158,7 @@ static int acpi_fan_add_fs(struct acpi_device *device) return -ENODEV; else { entry->proc_fops = &acpi_fan_state_ops; - entry->data = device; + entry->data = acpi_driver_data(device); entry->owner = THIS_MODULE; } @@ -182,8 +191,14 @@ static int acpi_fan_add(struct acpi_device *device) if (!device) return -EINVAL; + fan = kzalloc(sizeof(struct acpi_fan), GFP_KERNEL); + if (!fan) + return -ENOMEM; + + fan->device = device; strcpy(acpi_device_name(device), "Fan"); strcpy(acpi_device_class(device), ACPI_FAN_CLASS); + acpi_driver_data(device) = fan; result = acpi_bus_get_power(device->handle, &state); if (result) { @@ -191,6 +206,10 @@ static int acpi_fan_add(struct acpi_device *device) goto end; } + device->flags.force_power_state = 1; + acpi_bus_set_power(device->handle, state); + device->flags.force_power_state = 0; + result = acpi_fan_add_fs(device); if (result) goto end; @@ -208,14 +227,53 @@ static int acpi_fan_add(struct acpi_device *device) static int acpi_fan_remove(struct acpi_device *device, int type) { + struct acpi_fan *fan = NULL; + + if (!device || !acpi_driver_data(device)) return -EINVAL; + fan = acpi_driver_data(device); + acpi_fan_remove_fs(device); + kfree(fan); + return 0; } +static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state) +{ + if (!device) + return -EINVAL; + + acpi_bus_set_power(device->handle, ACPI_STATE_D0); + + return AE_OK; +} + +static int acpi_fan_resume(struct acpi_device *device) +{ + int result = 0; + int power_state = 0; + + if (!device) + return -EINVAL; + + result = acpi_bus_get_power(device->handle, &power_state); + if (result) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error reading fan power state\n")); + return result; + } + + device->flags.force_power_state = 1; + acpi_bus_set_power(device->handle, power_state); + device->flags.force_power_state = 0; + + return result; +} + static int __init acpi_fan_init(void) { int result = 0; diff --git a/trunk/drivers/acpi/power.c b/trunk/drivers/acpi/power.c index af1769a20c7a..57b9a2998fd0 100644 --- a/trunk/drivers/acpi/power.c +++ b/trunk/drivers/acpi/power.c @@ -86,6 +86,7 @@ struct acpi_power_resource { acpi_bus_id name; u32 system_level; u32 order; + int state; struct mutex resource_lock; struct list_head reference; }; @@ -127,31 +128,33 @@ acpi_power_get_context(acpi_handle handle, return 0; } -static int acpi_power_get_state(struct acpi_power_resource *resource, int *state) +static int acpi_power_get_state(struct acpi_power_resource *resource) { acpi_status status = AE_OK; unsigned long sta = 0; - if (!resource || !state) + if (!resource) return -EINVAL; status = acpi_evaluate_integer(resource->device->handle, "_STA", NULL, &sta); if (ACPI_FAILURE(status)) return -ENODEV; - *state = (sta & 0x01)?ACPI_POWER_RESOURCE_STATE_ON: - ACPI_POWER_RESOURCE_STATE_OFF; + if (sta & 0x01) + resource->state = ACPI_POWER_RESOURCE_STATE_ON; + else + resource->state = ACPI_POWER_RESOURCE_STATE_OFF; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", - resource->name, state ? "on" : "off")); + resource->name, resource->state ? "on" : "off")); return 0; } static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) { - int result = 0, state1; + int result = 0; struct acpi_power_resource *resource = NULL; u32 i = 0; @@ -165,11 +168,11 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) result = acpi_power_get_context(list->handles[i], &resource); if (result) return result; - result = acpi_power_get_state(resource, &state1); + result = acpi_power_get_state(resource); if (result) return result; - *state = state1; + *state = resource->state; if (*state != ACPI_POWER_RESOURCE_STATE_ON) break; @@ -183,7 +186,7 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) static int acpi_power_on(acpi_handle handle, struct acpi_device *dev) { - int result = 0, state; + int result = 0; int found = 0; acpi_status status = AE_OK; struct acpi_power_resource *resource = NULL; @@ -221,14 +224,20 @@ static int acpi_power_on(acpi_handle handle, struct acpi_device *dev) } mutex_unlock(&resource->resource_lock); + if (resource->state == ACPI_POWER_RESOURCE_STATE_ON) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already on\n", + resource->name)); + return 0; + } + status = acpi_evaluate_object(resource->device->handle, "_ON", NULL, NULL); if (ACPI_FAILURE(status)) return -ENODEV; - result = acpi_power_get_state(resource, &state); + result = acpi_power_get_state(resource); if (result) return result; - if (state != ACPI_POWER_RESOURCE_STATE_ON) + if (resource->state != ACPI_POWER_RESOURCE_STATE_ON) return -ENOEXEC; /* Update the power resource's _device_ power state */ @@ -241,7 +250,7 @@ static int acpi_power_on(acpi_handle handle, struct acpi_device *dev) static int acpi_power_off_device(acpi_handle handle, struct acpi_device *dev) { - int result = 0, state; + int result = 0; acpi_status status = AE_OK; struct acpi_power_resource *resource = NULL; struct list_head *node, *next; @@ -272,14 +281,20 @@ static int acpi_power_off_device(acpi_handle handle, struct acpi_device *dev) } mutex_unlock(&resource->resource_lock); + if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n", + resource->name)); + return 0; + } + status = acpi_evaluate_object(resource->device->handle, "_OFF", NULL, NULL); if (ACPI_FAILURE(status)) return -ENODEV; - result = acpi_power_get_state(resource, &state); + result = acpi_power_get_state(resource); if (result) return result; - if (state != ACPI_POWER_RESOURCE_STATE_OFF) + if (resource->state != ACPI_POWER_RESOURCE_STATE_OFF) return -ENOEXEC; /* Update the power resource's _device_ power state */ @@ -479,7 +494,7 @@ static struct proc_dir_entry *acpi_power_dir; static int acpi_power_seq_show(struct seq_file *seq, void *offset) { int count = 0; - int result = 0, state; + int result = 0; struct acpi_power_resource *resource = NULL; struct list_head *node, *next; struct acpi_power_reference *ref; @@ -490,12 +505,12 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset) if (!resource) goto end; - result = acpi_power_get_state(resource, &state); + result = acpi_power_get_state(resource); if (result) goto end; seq_puts(seq, "state: "); - switch (state) { + switch (resource->state) { case ACPI_POWER_RESOURCE_STATE_ON: seq_puts(seq, "on\n"); break; @@ -576,7 +591,7 @@ static int acpi_power_remove_fs(struct acpi_device *device) static int acpi_power_add(struct acpi_device *device) { - int result = 0, state; + int result = 0; acpi_status status = AE_OK; struct acpi_power_resource *resource = NULL; union acpi_object acpi_object; @@ -607,11 +622,11 @@ static int acpi_power_add(struct acpi_device *device) resource->system_level = acpi_object.power_resource.system_level; resource->order = acpi_object.power_resource.resource_order; - result = acpi_power_get_state(resource, &state); + result = acpi_power_get_state(resource); if (result) goto end; - switch (state) { + switch (resource->state) { case ACPI_POWER_RESOURCE_STATE_ON: device->power.state = ACPI_STATE_D0; break; @@ -628,7 +643,7 @@ static int acpi_power_add(struct acpi_device *device) goto end; printk(KERN_INFO PREFIX "%s [%s] (%s)\n", acpi_device_name(device), - acpi_device_bid(device), state ? "on" : "off"); + acpi_device_bid(device), resource->state ? "on" : "off"); end: if (result) @@ -665,7 +680,7 @@ static int acpi_power_remove(struct acpi_device *device, int type) static int acpi_power_resume(struct acpi_device *device) { - int result = 0, state; + int result = 0; struct acpi_power_resource *resource = NULL; struct acpi_power_reference *ref; @@ -674,12 +689,12 @@ static int acpi_power_resume(struct acpi_device *device) resource = (struct acpi_power_resource *)acpi_driver_data(device); - result = acpi_power_get_state(resource, &state); + result = acpi_power_get_state(resource); if (result) return result; mutex_lock(&resource->resource_lock); - if (state == ACPI_POWER_RESOURCE_STATE_OFF && + if ((resource->state == ACPI_POWER_RESOURCE_STATE_OFF) && !list_empty(&resource->reference)) { ref = container_of(resource->reference.next, struct acpi_power_reference, node); mutex_unlock(&resource->resource_lock); diff --git a/trunk/drivers/acpi/sleep/main.c b/trunk/drivers/acpi/sleep/main.c index 2c0b6630f8ba..f3d3867303ec 100644 --- a/trunk/drivers/acpi/sleep/main.c +++ b/trunk/drivers/acpi/sleep/main.c @@ -167,8 +167,8 @@ static void acpi_pm_finish(void) { u32 acpi_state = acpi_target_sleep_state; - acpi_disable_wakeup_device(acpi_state); acpi_leave_sleep_state(acpi_state); + acpi_disable_wakeup_device(acpi_state); /* reset firmware waking vector */ acpi_set_firmware_waking_vector((acpi_physical_address) 0); @@ -272,8 +272,8 @@ static void acpi_hibernation_finish(void) * enable it here. */ acpi_enable(); - acpi_disable_wakeup_device(ACPI_STATE_S4); acpi_leave_sleep_state(ACPI_STATE_S4); + acpi_disable_wakeup_device(ACPI_STATE_S4); /* reset firmware waking vector */ acpi_set_firmware_waking_vector((acpi_physical_address) 0); @@ -410,7 +410,6 @@ static void acpi_power_off(void) /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ printk("%s called\n", __FUNCTION__); local_irq_disable(); - acpi_enable_wakeup_device(ACPI_STATE_S5); acpi_enter_sleep_state(ACPI_STATE_S5); } diff --git a/trunk/drivers/acpi/sleep/proc.c b/trunk/drivers/acpi/sleep/proc.c index 1538355c266b..3839efd5eaea 100644 --- a/trunk/drivers/acpi/sleep/proc.c +++ b/trunk/drivers/acpi/sleep/proc.c @@ -194,23 +194,6 @@ static int get_date_field(char **p, u32 * value) return result; } -/* Read a possibly BCD register, always return binary */ -static u32 cmos_bcd_read(int offset, int rtc_control) -{ - u32 val = CMOS_READ(offset); - if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) - BCD_TO_BIN(val); - return val; -} - -/* Write binary value into possibly BCD register */ -static void cmos_bcd_write(u32 val, int offset, int rtc_control) -{ - if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) - BIN_TO_BCD(val); - CMOS_WRITE(val, offset); -} - static ssize_t acpi_system_write_alarm(struct file *file, const char __user * buffer, size_t count, loff_t * ppos) @@ -275,18 +258,35 @@ acpi_system_write_alarm(struct file *file, spin_lock_irq(&rtc_lock); rtc_control = CMOS_READ(RTC_CONTROL); + if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { + BIN_TO_BCD(yr); + BIN_TO_BCD(mo); + BIN_TO_BCD(day); + BIN_TO_BCD(hr); + BIN_TO_BCD(min); + BIN_TO_BCD(sec); + } if (adjust) { - yr += cmos_bcd_read(RTC_YEAR, rtc_control); - mo += cmos_bcd_read(RTC_MONTH, rtc_control); - day += cmos_bcd_read(RTC_DAY_OF_MONTH, rtc_control); - hr += cmos_bcd_read(RTC_HOURS, rtc_control); - min += cmos_bcd_read(RTC_MINUTES, rtc_control); - sec += cmos_bcd_read(RTC_SECONDS, rtc_control); + yr += CMOS_READ(RTC_YEAR); + mo += CMOS_READ(RTC_MONTH); + day += CMOS_READ(RTC_DAY_OF_MONTH); + hr += CMOS_READ(RTC_HOURS); + min += CMOS_READ(RTC_MINUTES); + sec += CMOS_READ(RTC_SECONDS); } spin_unlock_irq(&rtc_lock); + if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { + BCD_TO_BIN(yr); + BCD_TO_BIN(mo); + BCD_TO_BIN(day); + BCD_TO_BIN(hr); + BCD_TO_BIN(min); + BCD_TO_BIN(sec); + } + if (sec > 59) { min++; sec -= 60; @@ -307,6 +307,14 @@ acpi_system_write_alarm(struct file *file, yr++; mo -= 12; } + if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { + BIN_TO_BCD(yr); + BIN_TO_BCD(mo); + BIN_TO_BCD(day); + BIN_TO_BCD(hr); + BIN_TO_BCD(min); + BIN_TO_BCD(sec); + } spin_lock_irq(&rtc_lock); /* @@ -318,9 +326,9 @@ acpi_system_write_alarm(struct file *file, CMOS_READ(RTC_INTR_FLAGS); /* write the fields the rtc knows about */ - cmos_bcd_write(hr, RTC_HOURS_ALARM, rtc_control); - cmos_bcd_write(min, RTC_MINUTES_ALARM, rtc_control); - cmos_bcd_write(sec, RTC_SECONDS_ALARM, rtc_control); + CMOS_WRITE(hr, RTC_HOURS_ALARM); + CMOS_WRITE(min, RTC_MINUTES_ALARM); + CMOS_WRITE(sec, RTC_SECONDS_ALARM); /* * If the system supports an enhanced alarm it will have non-zero @@ -328,11 +336,11 @@ acpi_system_write_alarm(struct file *file, * to the RTC area of memory. */ if (acpi_gbl_FADT.day_alarm) - cmos_bcd_write(day, acpi_gbl_FADT.day_alarm, rtc_control); + CMOS_WRITE(day, acpi_gbl_FADT.day_alarm); if (acpi_gbl_FADT.month_alarm) - cmos_bcd_write(mo, acpi_gbl_FADT.month_alarm, rtc_control); + CMOS_WRITE(mo, acpi_gbl_FADT.month_alarm); if (acpi_gbl_FADT.century) - cmos_bcd_write(yr / 100, acpi_gbl_FADT.century, rtc_control); + CMOS_WRITE(yr / 100, acpi_gbl_FADT.century); /* enable the rtc alarm interrupt */ rtc_control |= RTC_AIE; CMOS_WRITE(rtc_control, RTC_CONTROL); diff --git a/trunk/drivers/ata/ahci.c b/trunk/drivers/ata/ahci.c index ed9b407e42d4..47c806040524 100644 --- a/trunk/drivers/ata/ahci.c +++ b/trunk/drivers/ata/ahci.c @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -49,9 +48,6 @@ #define DRV_NAME "ahci" #define DRV_VERSION "3.0" -static int ahci_enable_alpm(struct ata_port *ap, - enum link_pm policy); -static void ahci_disable_alpm(struct ata_port *ap); enum { AHCI_PCI_BAR = 5, @@ -102,7 +98,6 @@ enum { HOST_CAP_SSC = (1 << 14), /* Slumber capable */ HOST_CAP_PMP = (1 << 17), /* Port Multiplier support */ HOST_CAP_CLO = (1 << 24), /* Command List Override support */ - HOST_CAP_ALPM = (1 << 26), /* Aggressive Link PM support */ HOST_CAP_SSS = (1 << 27), /* Staggered Spin-up */ HOST_CAP_SNTF = (1 << 29), /* SNotification register */ HOST_CAP_NCQ = (1 << 30), /* Native Command Queueing */ @@ -159,8 +154,6 @@ enum { PORT_IRQ_PIOS_FIS | PORT_IRQ_D2H_REG_FIS, /* PORT_CMD bits */ - PORT_CMD_ASP = (1 << 27), /* Aggressive Slumber/Partial */ - PORT_CMD_ALPE = (1 << 26), /* Aggressive Link PM enable */ PORT_CMD_ATAPI = (1 << 24), /* Device is ATAPI */ PORT_CMD_PMP = (1 << 17), /* PMP attached */ PORT_CMD_LIST_ON = (1 << 15), /* cmd list DMA engine running */ @@ -184,14 +177,13 @@ enum { AHCI_HFLAG_MV_PATA = (1 << 4), /* PATA port */ AHCI_HFLAG_NO_MSI = (1 << 5), /* no PCI MSI */ AHCI_HFLAG_NO_PMP = (1 << 6), /* no PMP */ - AHCI_HFLAG_NO_HOTPLUG = (1 << 7), /* ignore PxSERR.DIAG.N */ /* ap->flags bits */ + AHCI_FLAG_NO_HOTPLUG = (1 << 24), /* ignore PxSERR.DIAG.N */ AHCI_FLAG_COMMON = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | - ATA_FLAG_ACPI_SATA | ATA_FLAG_AN | - ATA_FLAG_IPM, + ATA_FLAG_ACPI_SATA | ATA_FLAG_AN, AHCI_LFLAG_COMMON = ATA_LFLAG_SKIP_D2H_BSY, }; @@ -235,7 +227,7 @@ struct ahci_port_priv { static int ahci_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); static int ahci_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); -static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); +static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc); static void ahci_irq_clear(struct ata_port *ap); static int ahci_port_start(struct ata_port *ap); @@ -249,7 +241,6 @@ static void ahci_pmp_attach(struct ata_port *ap); static void ahci_pmp_detach(struct ata_port *ap); static void ahci_error_handler(struct ata_port *ap); static void ahci_vt8251_error_handler(struct ata_port *ap); -static void ahci_p5wdh_error_handler(struct ata_port *ap); static void ahci_post_internal_cmd(struct ata_queued_cmd *qc); static int ahci_port_resume(struct ata_port *ap); static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl); @@ -261,11 +252,6 @@ static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); static int ahci_pci_device_resume(struct pci_dev *pdev); #endif -static struct class_device_attribute *ahci_shost_attrs[] = { - &class_device_attr_link_power_management_policy, - NULL -}; - static struct scsi_host_template ahci_sht = { .module = THIS_MODULE, .name = DRV_NAME, @@ -283,7 +269,6 @@ static struct scsi_host_template ahci_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, - .shost_attrs = ahci_shost_attrs, }; static const struct ata_port_operations ahci_ops = { @@ -315,8 +300,6 @@ static const struct ata_port_operations ahci_ops = { .port_suspend = ahci_port_suspend, .port_resume = ahci_port_resume, #endif - .enable_pm = ahci_enable_alpm, - .disable_pm = ahci_disable_alpm, .port_start = ahci_port_start, .port_stop = ahci_port_stop, @@ -356,40 +339,6 @@ static const struct ata_port_operations ahci_vt8251_ops = { .port_stop = ahci_port_stop, }; -static const struct ata_port_operations ahci_p5wdh_ops = { - .check_status = ahci_check_status, - .check_altstatus = ahci_check_status, - .dev_select = ata_noop_dev_select, - - .tf_read = ahci_tf_read, - - .qc_defer = sata_pmp_qc_defer_cmd_switch, - .qc_prep = ahci_qc_prep, - .qc_issue = ahci_qc_issue, - - .irq_clear = ahci_irq_clear, - - .scr_read = ahci_scr_read, - .scr_write = ahci_scr_write, - - .freeze = ahci_freeze, - .thaw = ahci_thaw, - - .error_handler = ahci_p5wdh_error_handler, - .post_internal_cmd = ahci_post_internal_cmd, - - .pmp_attach = ahci_pmp_attach, - .pmp_detach = ahci_pmp_detach, - -#ifdef CONFIG_PM - .port_suspend = ahci_port_suspend, - .port_resume = ahci_port_resume, -#endif - - .port_start = ahci_port_start, - .port_stop = ahci_port_stop, -}; - #define AHCI_HFLAGS(flags) .private_data = (void *)(flags) static const struct ata_port_info ahci_port_info[] = { @@ -780,7 +729,7 @@ static int ahci_stop_engine(struct ata_port *ap) /* wait for engine to stop. This could be as long as 500 msec */ tmp = ata_wait_register(port_mmio + PORT_CMD, - PORT_CMD_LIST_ON, PORT_CMD_LIST_ON, 1, 500); + PORT_CMD_LIST_ON, PORT_CMD_LIST_ON, 1, 500); if (tmp & PORT_CMD_LIST_ON) return -EIO; @@ -851,130 +800,6 @@ static void ahci_power_up(struct ata_port *ap) writel(cmd | PORT_CMD_ICC_ACTIVE, port_mmio + PORT_CMD); } -static void ahci_disable_alpm(struct ata_port *ap) -{ - struct ahci_host_priv *hpriv = ap->host->private_data; - void __iomem *port_mmio = ahci_port_base(ap); - u32 cmd; - struct ahci_port_priv *pp = ap->private_data; - - /* IPM bits should be disabled by libata-core */ - /* get the existing command bits */ - cmd = readl(port_mmio + PORT_CMD); - - /* disable ALPM and ASP */ - cmd &= ~PORT_CMD_ASP; - cmd &= ~PORT_CMD_ALPE; - - /* force the interface back to active */ - cmd |= PORT_CMD_ICC_ACTIVE; - - /* write out new cmd value */ - writel(cmd, port_mmio + PORT_CMD); - cmd = readl(port_mmio + PORT_CMD); - - /* wait 10ms to be sure we've come out of any low power state */ - msleep(10); - - /* clear out any PhyRdy stuff from interrupt status */ - writel(PORT_IRQ_PHYRDY, port_mmio + PORT_IRQ_STAT); - - /* go ahead and clean out PhyRdy Change from Serror too */ - ahci_scr_write(ap, SCR_ERROR, ((1 << 16) | (1 << 18))); - - /* - * Clear flag to indicate that we should ignore all PhyRdy - * state changes - */ - hpriv->flags &= ~AHCI_HFLAG_NO_HOTPLUG; - - /* - * Enable interrupts on Phy Ready. - */ - pp->intr_mask |= PORT_IRQ_PHYRDY; - writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK); - - /* - * don't change the link pm policy - we can be called - * just to turn of link pm temporarily - */ -} - -static int ahci_enable_alpm(struct ata_port *ap, - enum link_pm policy) -{ - struct ahci_host_priv *hpriv = ap->host->private_data; - void __iomem *port_mmio = ahci_port_base(ap); - u32 cmd; - struct ahci_port_priv *pp = ap->private_data; - u32 asp; - - /* Make sure the host is capable of link power management */ - if (!(hpriv->cap & HOST_CAP_ALPM)) - return -EINVAL; - - switch (policy) { - case MAX_PERFORMANCE: - case NOT_AVAILABLE: - /* - * if we came here with NOT_AVAILABLE, - * it just means this is the first time we - * have tried to enable - default to max performance, - * and let the user go to lower power modes on request. - */ - ahci_disable_alpm(ap); - return 0; - case MIN_POWER: - /* configure HBA to enter SLUMBER */ - asp = PORT_CMD_ASP; - break; - case MEDIUM_POWER: - /* configure HBA to enter PARTIAL */ - asp = 0; - break; - default: - return -EINVAL; - } - - /* - * Disable interrupts on Phy Ready. This keeps us from - * getting woken up due to spurious phy ready interrupts - * TBD - Hot plug should be done via polling now, is - * that even supported? - */ - pp->intr_mask &= ~PORT_IRQ_PHYRDY; - writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK); - - /* - * Set a flag to indicate that we should ignore all PhyRdy - * state changes since these can happen now whenever we - * change link state - */ - hpriv->flags |= AHCI_HFLAG_NO_HOTPLUG; - - /* get the existing command bits */ - cmd = readl(port_mmio + PORT_CMD); - - /* - * Set ASP based on Policy - */ - cmd |= asp; - - /* - * Setting this bit will instruct the HBA to aggressively - * enter a lower power link state when it's appropriate and - * based on the value set above for ASP - */ - cmd |= PORT_CMD_ALPE; - - /* write out new cmd value */ - writel(cmd, port_mmio + PORT_CMD); - cmd = readl(port_mmio + PORT_CMD); - - /* IPM bits should be set by libata-core */ - return 0; -} - #ifdef CONFIG_PM static void ahci_power_down(struct ata_port *ap) { @@ -1037,10 +862,8 @@ static int ahci_reset_controller(struct ata_host *host) * AHCI-specific, such as HOST_RESET. */ tmp = readl(mmio + HOST_CTL); - if (!(tmp & HOST_AHCI_EN)) { - tmp |= HOST_AHCI_EN; - writel(tmp, mmio + HOST_CTL); - } + if (!(tmp & HOST_AHCI_EN)) + writel(tmp | HOST_AHCI_EN, mmio + HOST_CTL); /* global controller reset */ if ((tmp & HOST_RESET) == 0) { @@ -1294,8 +1117,15 @@ static int ahci_do_softreset(struct ata_link *link, unsigned int *class, tf.ctl &= ~ATA_SRST; ahci_exec_polled_cmd(ap, pmp, &tf, 0, 0, 0); - /* wait a while before checking status */ - ata_wait_after_reset(ap, deadline); + /* spec mandates ">= 2ms" before checking status. + * We wait 150ms, because that was the magic delay used for + * ATAPI devices in Hale Landis's ATADRVR, for the period of time + * between when the ATA command register is written, and then + * status is checked. Because waiting for "a while" before + * checking status is fine, post SRST, we perform this magic + * delay here as well. + */ + msleep(150); rc = ata_wait_ready(ap, deadline); /* link occupied, -ENODEV too is an error */ @@ -1383,53 +1213,6 @@ static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class, return rc ?: -EAGAIN; } -static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class, - unsigned long deadline) -{ - struct ata_port *ap = link->ap; - struct ahci_port_priv *pp = ap->private_data; - u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG; - struct ata_taskfile tf; - int rc; - - ahci_stop_engine(ap); - - /* clear D2H reception area to properly wait for D2H FIS */ - ata_tf_init(link->device, &tf); - tf.command = 0x80; - ata_tf_to_fis(&tf, 0, 0, d2h_fis); - - rc = sata_link_hardreset(link, sata_ehc_deb_timing(&link->eh_context), - deadline); - - ahci_start_engine(ap); - - if (rc || ata_link_offline(link)) - return rc; - - /* spec mandates ">= 2ms" before checking status */ - msleep(150); - - /* The pseudo configuration device on SIMG4726 attached to - * ASUS P5W-DH Deluxe doesn't send signature FIS after - * hardreset if no device is attached to the first downstream - * port && the pseudo device locks up on SRST w/ PMP==0. To - * work around this, wait for !BSY only briefly. If BSY isn't - * cleared, perform CLO and proceed to IDENTIFY (achieved by - * ATA_LFLAG_NO_SRST and ATA_LFLAG_ASSUME_ATA). - * - * Wait for two seconds. Devices attached to downstream port - * which can't process the following IDENTIFY after this will - * have to be reset again. For most cases, this should - * suffice while making probing snappish enough. - */ - rc = ata_wait_ready(ap, jiffies + 2 * HZ); - if (rc) - ahci_kick_engine(ap, 0); - - return 0; -} - static void ahci_postreset(struct ata_link *link, unsigned int *class) { struct ata_port *ap = link->ap; @@ -1643,17 +1426,6 @@ static void ahci_port_intr(struct ata_port *ap) if (unlikely(resetting)) status &= ~PORT_IRQ_BAD_PMP; - /* If we are getting PhyRdy, this is - * just a power state change, we should - * clear out this, plus the PhyRdy/Comm - * Wake bits from Serror - */ - if ((hpriv->flags & AHCI_HFLAG_NO_HOTPLUG) && - (status & PORT_IRQ_PHYRDY)) { - status &= ~PORT_IRQ_PHYRDY; - ahci_scr_write(ap, SCR_ERROR, ((1 << 16) | (1 << 18))); - } - if (unlikely(status & PORT_IRQ_ERROR)) { ahci_error_intr(ap, status); return; @@ -1792,9 +1564,9 @@ static irqreturn_t ahci_interrupt(int irq, void *dev_instance) if (!irq_stat) return IRQ_NONE; - spin_lock(&host->lock); + spin_lock(&host->lock); - for (i = 0; i < host->n_ports; i++) { + for (i = 0; i < host->n_ports; i++) { struct ata_port *ap; if (!(irq_stat & (1 << i))) @@ -1898,19 +1670,6 @@ static void ahci_vt8251_error_handler(struct ata_port *ap) ahci_postreset); } -static void ahci_p5wdh_error_handler(struct ata_port *ap) -{ - if (!(ap->pflags & ATA_PFLAG_FROZEN)) { - /* restart engine */ - ahci_stop_engine(ap); - ahci_start_engine(ap); - } - - /* perform recovery */ - ata_do_eh(ap, ata_std_prereset, ahci_softreset, ahci_p5wdh_hardreset, - ahci_postreset); -} - static void ahci_post_internal_cmd(struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; @@ -2070,9 +1829,9 @@ static int ahci_port_start(struct ata_port *ap) pp->cmd_tbl_dma = mem_dma; /* - * Save off initial list of interrupts to be enabled. - * This could be changed later - */ + * Save off initial list of interrupts to be enabled. + * This could be changed later + */ pp->intr_mask = DEF_PORT_IRQ; ap->private_data = pp; @@ -2159,12 +1918,12 @@ static void ahci_print_info(struct ata_host *host) dev_printk(KERN_INFO, &pdev->dev, "AHCI %02x%02x.%02x%02x " "%u slots %u ports %s Gbps 0x%x impl %s mode\n" - , + , - (vers >> 24) & 0xff, - (vers >> 16) & 0xff, - (vers >> 8) & 0xff, - vers & 0xff, + (vers >> 24) & 0xff, + (vers >> 16) & 0xff, + (vers >> 8) & 0xff, + vers & 0xff, ((cap >> 8) & 0x1f) + 1, (cap & 0x1f) + 1, @@ -2176,7 +1935,7 @@ static void ahci_print_info(struct ata_host *host) "flags: " "%s%s%s%s%s%s%s" "%s%s%s%s%s%s%s\n" - , + , cap & (1 << 31) ? "64bit " : "", cap & (1 << 30) ? "ncq " : "", @@ -2196,51 +1955,6 @@ static void ahci_print_info(struct ata_host *host) ); } -/* On ASUS P5W DH Deluxe, the second port of PCI device 00:1f.2 is - * hardwired to on-board SIMG 4726. The chipset is ICH8 and doesn't - * support PMP and the 4726 either directly exports the device - * attached to the first downstream port or acts as a hardware storage - * controller and emulate a single ATA device (can be RAID 0/1 or some - * other configuration). - * - * When there's no device attached to the first downstream port of the - * 4726, "Config Disk" appears, which is a pseudo ATA device to - * configure the 4726. However, ATA emulation of the device is very - * lame. It doesn't send signature D2H Reg FIS after the initial - * hardreset, pukes on SRST w/ PMP==0 and has bunch of other issues. - * - * The following function works around the problem by always using - * hardreset on the port and not depending on receiving signature FIS - * afterward. If signature FIS isn't received soon, ATA class is - * assumed without follow-up softreset. - */ -static void ahci_p5wdh_workaround(struct ata_host *host) -{ - static struct dmi_system_id sysids[] = { - { - .ident = "P5W DH Deluxe", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, - "ASUSTEK COMPUTER INC"), - DMI_MATCH(DMI_PRODUCT_NAME, "P5W DH Deluxe"), - }, - }, - { } - }; - struct pci_dev *pdev = to_pci_dev(host->dev); - - if (pdev->bus->number == 0 && pdev->devfn == PCI_DEVFN(0x1f, 2) && - dmi_check_system(sysids)) { - struct ata_port *ap = host->ports[1]; - - dev_printk(KERN_INFO, &pdev->dev, "enabling ASUS P5W DH " - "Deluxe on-board SIMG4726 workaround\n"); - - ap->ops = &ahci_p5wdh_ops; - ap->link.flags |= ATA_LFLAG_NO_SRST | ATA_LFLAG_ASSUME_ATA; - } -} - static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; @@ -2301,9 +2015,6 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ata_port_pbar_desc(ap, AHCI_PCI_BAR, 0x100 + ap->port_no * 0x80, "port"); - /* set initial link pm policy */ - ap->pm_policy = NOT_AVAILABLE; - /* standard SATA port setup */ if (hpriv->port_map & (1 << i)) ap->ioaddr.cmd_addr = port_mmio; @@ -2313,9 +2024,6 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ap->ops = &ata_dummy_port_ops; } - /* apply workaround for ASUS P5W DH Deluxe mainboard */ - ahci_p5wdh_workaround(host); - /* initialize adapter */ rc = ahci_configure_dma_masks(pdev, hpriv->cap & HOST_CAP_64); if (rc) diff --git a/trunk/drivers/ata/ata_piix.c b/trunk/drivers/ata/ata_piix.c index a4b2cb29f46c..3c6f43e381f4 100644 --- a/trunk/drivers/ata/ata_piix.c +++ b/trunk/drivers/ata/ata_piix.c @@ -157,12 +157,12 @@ struct piix_host_priv { const int *map; }; -static int piix_init_one(struct pci_dev *pdev, - const struct pci_device_id *ent); +static int piix_init_one (struct pci_dev *pdev, + const struct pci_device_id *ent); static void piix_pata_error_handler(struct ata_port *ap); -static void piix_set_piomode(struct ata_port *ap, struct ata_device *adev); -static void piix_set_dmamode(struct ata_port *ap, struct ata_device *adev); -static void ich_set_dmamode(struct ata_port *ap, struct ata_device *adev); +static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev); +static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev); +static void ich_set_dmamode (struct ata_port *ap, struct ata_device *adev); static int ich_pata_cable_detect(struct ata_port *ap); #ifdef CONFIG_PM static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); @@ -650,9 +650,9 @@ static int ich_pata_cable_detect(struct ata_port *ap) while (lap->device) { if (lap->device == pdev->device && lap->subvendor == pdev->subsystem_vendor && - lap->subdevice == pdev->subsystem_device) + lap->subdevice == pdev->subsystem_device) { return ATA_CBL_PATA40_SHORT; - + } lap++; } @@ -699,7 +699,7 @@ static void piix_pata_error_handler(struct ata_port *ap) * None (inherited from caller). */ -static void piix_set_piomode(struct ata_port *ap, struct ata_device *adev) +static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev) { unsigned int pio = adev->pio_mode - XFER_PIO_0; struct pci_dev *dev = to_pci_dev(ap->host->dev); @@ -786,7 +786,7 @@ static void piix_set_piomode(struct ata_port *ap, struct ata_device *adev) * None (inherited from caller). */ -static void do_pata_set_dmamode(struct ata_port *ap, struct ata_device *adev, int isich) +static void do_pata_set_dmamode (struct ata_port *ap, struct ata_device *adev, int isich) { struct pci_dev *dev = to_pci_dev(ap->host->dev); u8 master_port = ap->port_no ? 0x42 : 0x40; @@ -813,7 +813,7 @@ static void do_pata_set_dmamode(struct ata_port *ap, struct ata_device *adev, in int u_clock, u_speed; /* - * UDMA is handled by a combination of clock switching and + * UDMA is handled by a combination of clock switching and * selection of dividers * * Handy rule: Odd modes are UDMATIMx 01, even are 02 @@ -905,7 +905,7 @@ static void do_pata_set_dmamode(struct ata_port *ap, struct ata_device *adev, in * None (inherited from caller). */ -static void piix_set_dmamode(struct ata_port *ap, struct ata_device *adev) +static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev) { do_pata_set_dmamode(ap, adev, 0); } @@ -921,7 +921,7 @@ static void piix_set_dmamode(struct ata_port *ap, struct ata_device *adev) * None (inherited from caller). */ -static void ich_set_dmamode(struct ata_port *ap, struct ata_device *adev) +static void ich_set_dmamode (struct ata_port *ap, struct ata_device *adev) { do_pata_set_dmamode(ap, adev, 1); } @@ -1106,7 +1106,8 @@ static int __devinit piix_check_450nx_errata(struct pci_dev *ata_dev) u16 cfg; int no_piix_dma = 0; - while ((pdev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, pdev)) != NULL) { + while((pdev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, pdev)) != NULL) + { /* Look for 450NX PXB. Check for problem configurations A PCI quirk checks bit 6 already */ pci_read_config_word(pdev, 0x41, &cfg); @@ -1240,7 +1241,7 @@ static void piix_iocfg_bit18_quirk(struct pci_dev *pdev) * Zero on success, or -ERRNO value. */ -static int piix_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) +static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; struct device *dev = &pdev->dev; diff --git a/trunk/drivers/ata/libata-acpi.c b/trunk/drivers/ata/libata-acpi.c index 08a52dd45fb6..3f7533589041 100644 --- a/trunk/drivers/ata/libata-acpi.c +++ b/trunk/drivers/ata/libata-acpi.c @@ -26,7 +26,7 @@ #include #define NO_PORT_MULT 0xffff -#define SATA_ADR(root, pmp) (((root) << 16) | (pmp)) +#define SATA_ADR(root,pmp) (((root) << 16) | (pmp)) #define REGS_PER_GTF 7 struct ata_acpi_gtf { @@ -96,8 +96,8 @@ static void ata_acpi_associate_ide_port(struct ata_port *ap) } } -static void ata_acpi_handle_hotplug(struct ata_port *ap, struct kobject *kobj, - u32 event) +static void ata_acpi_handle_hotplug (struct ata_port *ap, struct kobject *kobj, + u32 event) { char event_string[12]; char *envp[] = { event_string, NULL }; @@ -114,7 +114,7 @@ static void ata_acpi_handle_hotplug(struct ata_port *ap, struct kobject *kobj, } if (kobj) { - sprintf(event_string, "BAY_EVENT=%d", event); + sprintf(event_string, "BAY_EVENT=%d", event); kobject_uevent_env(kobj, KOBJ_CHANGE, envp); } } @@ -127,14 +127,14 @@ static void ata_acpi_dev_notify(acpi_handle handle, u32 event, void *data) if (dev->sdev) kobj = &dev->sdev->sdev_gendev.kobj; - ata_acpi_handle_hotplug(dev->link->ap, kobj, event); + ata_acpi_handle_hotplug (dev->link->ap, kobj, event); } static void ata_acpi_ap_notify(acpi_handle handle, u32 event, void *data) { struct ata_port *ap = data; - ata_acpi_handle_hotplug(ap, &ap->dev->kobj, event); + ata_acpi_handle_hotplug (ap, &ap->dev->kobj, event); } /** @@ -398,11 +398,11 @@ int ata_acpi_cbl_80wire(struct ata_port *ap) { struct ata_acpi_gtm gtm; int valid = 0; - + /* No _GTM data, no information */ if (ata_acpi_gtm(ap, >m) < 0) return 0; - + /* Split timing, DMA enabled */ if ((gtm.flags & 0x11) == 0x11 && gtm.drive[0].dma < 55) valid |= 1; diff --git a/trunk/drivers/ata/libata-core.c b/trunk/drivers/ata/libata-core.c index 63035d71a61a..69092bce1ada 100644 --- a/trunk/drivers/ata/libata-core.c +++ b/trunk/drivers/ata/libata-core.c @@ -49,11 +49,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include @@ -68,8 +68,7 @@ const unsigned long sata_deb_timing_long[] = { 100, 2000, 5000 }; static unsigned int ata_dev_init_params(struct ata_device *dev, u16 heads, u16 sectors); static unsigned int ata_dev_set_xfermode(struct ata_device *dev); -static unsigned int ata_dev_set_feature(struct ata_device *dev, - u8 enable, u8 feature); +static unsigned int ata_dev_set_AN(struct ata_device *dev, u8 enable); static void ata_dev_xfermask(struct ata_device *dev); static unsigned long ata_dev_blacklisted(const struct ata_device *dev); @@ -94,7 +93,7 @@ int libata_fua = 0; module_param_named(fua, libata_fua, int, 0444); MODULE_PARM_DESC(fua, "FUA support (0=off, 1=on)"); -static int ata_ignore_hpa; +static int ata_ignore_hpa = 0; module_param_named(ignore_hpa, ata_ignore_hpa, int, 0644); MODULE_PARM_DESC(ignore_hpa, "Ignore HPA limit (0=keep BIOS limits, 1=ignore limits, using full disk)"); @@ -620,177 +619,6 @@ void ata_dev_disable(struct ata_device *dev) } } -static int ata_dev_set_dipm(struct ata_device *dev, enum link_pm policy) -{ - struct ata_link *link = dev->link; - struct ata_port *ap = link->ap; - u32 scontrol; - unsigned int err_mask; - int rc; - - /* - * disallow DIPM for drivers which haven't set - * ATA_FLAG_IPM. This is because when DIPM is enabled, - * phy ready will be set in the interrupt status on - * state changes, which will cause some drivers to - * think there are errors - additionally drivers will - * need to disable hot plug. - */ - if (!(ap->flags & ATA_FLAG_IPM) || !ata_dev_enabled(dev)) { - ap->pm_policy = NOT_AVAILABLE; - return -EINVAL; - } - - /* - * For DIPM, we will only enable it for the - * min_power setting. - * - * Why? Because Disks are too stupid to know that - * If the host rejects a request to go to SLUMBER - * they should retry at PARTIAL, and instead it - * just would give up. So, for medium_power to - * work at all, we need to only allow HIPM. - */ - rc = sata_scr_read(link, SCR_CONTROL, &scontrol); - if (rc) - return rc; - - switch (policy) { - case MIN_POWER: - /* no restrictions on IPM transitions */ - scontrol &= ~(0x3 << 8); - rc = sata_scr_write(link, SCR_CONTROL, scontrol); - if (rc) - return rc; - - /* enable DIPM */ - if (dev->flags & ATA_DFLAG_DIPM) - err_mask = ata_dev_set_feature(dev, - SETFEATURES_SATA_ENABLE, SATA_DIPM); - break; - case MEDIUM_POWER: - /* allow IPM to PARTIAL */ - scontrol &= ~(0x1 << 8); - scontrol |= (0x2 << 8); - rc = sata_scr_write(link, SCR_CONTROL, scontrol); - if (rc) - return rc; - - /* disable DIPM */ - if (ata_dev_enabled(dev) && (dev->flags & ATA_DFLAG_DIPM)) - err_mask = ata_dev_set_feature(dev, - SETFEATURES_SATA_DISABLE, SATA_DIPM); - break; - case NOT_AVAILABLE: - case MAX_PERFORMANCE: - /* disable all IPM transitions */ - scontrol |= (0x3 << 8); - rc = sata_scr_write(link, SCR_CONTROL, scontrol); - if (rc) - return rc; - - /* disable DIPM */ - if (ata_dev_enabled(dev) && (dev->flags & ATA_DFLAG_DIPM)) - err_mask = ata_dev_set_feature(dev, - SETFEATURES_SATA_DISABLE, SATA_DIPM); - break; - } - - /* FIXME: handle SET FEATURES failure */ - (void) err_mask; - - return 0; -} - -/** - * ata_dev_enable_pm - enable SATA interface power management - * @device - device to enable ipm for - * @policy - the link power management policy - * - * Enable SATA Interface power management. This will enable - * Device Interface Power Management (DIPM) for min_power - * policy, and then call driver specific callbacks for - * enabling Host Initiated Power management. - * - * Locking: Caller. - * Returns: -EINVAL if IPM is not supported, 0 otherwise. - */ -void ata_dev_enable_pm(struct ata_device *dev, enum link_pm policy) -{ - int rc = 0; - struct ata_port *ap = dev->link->ap; - - /* set HIPM first, then DIPM */ - if (ap->ops->enable_pm) - rc = ap->ops->enable_pm(ap, policy); - if (rc) - goto enable_pm_out; - rc = ata_dev_set_dipm(dev, policy); - -enable_pm_out: - if (rc) - ap->pm_policy = MAX_PERFORMANCE; - else - ap->pm_policy = policy; - return /* rc */; /* hopefully we can use 'rc' eventually */ -} - -/** - * ata_dev_disable_pm - disable SATA interface power management - * @device - device to enable ipm for - * - * Disable SATA Interface power management. This will disable - * Device Interface Power Management (DIPM) without changing - * policy, call driver specific callbacks for disabling Host - * Initiated Power management. - * - * Locking: Caller. - * Returns: void - */ -static void ata_dev_disable_pm(struct ata_device *dev) -{ - struct ata_port *ap = dev->link->ap; - - ata_dev_set_dipm(dev, MAX_PERFORMANCE); - if (ap->ops->disable_pm) - ap->ops->disable_pm(ap); -} - -void ata_lpm_schedule(struct ata_port *ap, enum link_pm policy) -{ - ap->pm_policy = policy; - ap->link.eh_info.action |= ATA_EHI_LPM; - ap->link.eh_info.flags |= ATA_EHI_NO_AUTOPSY; - ata_port_schedule_eh(ap); -} - -static void ata_lpm_enable(struct ata_host *host) -{ - struct ata_link *link; - struct ata_port *ap; - struct ata_device *dev; - int i; - - for (i = 0; i < host->n_ports; i++) { - ap = host->ports[i]; - ata_port_for_each_link(link, ap) { - ata_link_for_each_dev(dev, link) - ata_dev_disable_pm(dev); - } - } -} - -static void ata_lpm_disable(struct ata_host *host) -{ - int i; - - for (i = 0; i < host->n_ports; i++) { - struct ata_port *ap = host->ports[i]; - ata_lpm_schedule(ap, ap->pm_policy); - } -} - - /** * ata_devchk - PATA device presence detection * @ap: ATA channel to examine @@ -885,7 +713,7 @@ unsigned int ata_dev_classify(const struct ata_taskfile *tf) } if ((tf->lbam == 0x3c) && (tf->lbah == 0xc3)) { - printk(KERN_INFO "ata: SEMB device ignored\n"); + printk("ata: SEMB device ignored\n"); return ATA_DEV_SEMB_UNSUP; /* not yet */ } @@ -1111,7 +939,7 @@ static int ata_read_native_max_address(struct ata_device *dev, u64 *max_sectors) *max_sectors = ata_tf_to_lba48(&tf); else *max_sectors = ata_tf_to_lba(&tf); - if (dev->horkage & ATA_HORKAGE_HPA_SIZE) + if (dev->horkage & ATA_HORKAGE_HPA_SIZE) (*max_sectors)--; return 0; } @@ -1323,7 +1151,7 @@ void ata_id_to_dma_mode(struct ata_device *dev, u8 unknown) * LOCKING: * caller. */ -void ata_noop_dev_select(struct ata_port *ap, unsigned int device) +void ata_noop_dev_select (struct ata_port *ap, unsigned int device) { } @@ -1343,7 +1171,7 @@ void ata_noop_dev_select(struct ata_port *ap, unsigned int device) * caller. */ -void ata_std_dev_select(struct ata_port *ap, unsigned int device) +void ata_std_dev_select (struct ata_port *ap, unsigned int device) { u8 tmp; @@ -1464,7 +1292,7 @@ static unsigned int ata_id_xfermask(const u16 *id) */ u8 mode = (id[ATA_ID_OLD_PIO_MODES] >> 8) & 0xFF; if (mode < 5) /* Valid PIO range */ - pio_mask = (2 << mode) - 1; + pio_mask = (2 << mode) - 1; else pio_mask = 1; @@ -1865,7 +1693,7 @@ static u32 ata_pio_mask_no_iordy(const struct ata_device *adev) * for pre-ATA4 drives. * * FIXME: ATA_CMD_ID_ATA is optional for early drives and right - * now we abort if we hit that case. + * now we abort if we hit that case. * * LOCKING: * Kernel thread context (may sleep) @@ -1971,7 +1799,13 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, * SET_FEATURES spin-up subcommand before it will accept * anything other than the original IDENTIFY command. */ - err_mask = ata_dev_set_feature(dev, SETFEATURES_SPINUP, 0); + ata_tf_init(dev, &tf); + tf.command = ATA_CMD_SET_FEATURES; + tf.feature = SETFEATURES_SPINUP; + tf.protocol = ATA_PROT_NODATA; + tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; + err_mask = ata_exec_internal(dev, &tf, NULL, + DMA_NONE, NULL, 0, 0); if (err_mask && id[2] != 0x738c) { rc = -EIO; reason = "SPINUP failed"; @@ -2145,8 +1979,9 @@ int ata_dev_configure(struct ata_device *dev) "supports DRM functions and may " "not be fully accessable.\n"); snprintf(revbuf, 7, "CFA"); - } else - snprintf(revbuf, 7, "ATA-%d", ata_id_major_version(id)); + } + else + snprintf(revbuf, 7, "ATA-%d", ata_id_major_version(id)); dev->n_sectors = ata_id_n_sectors(id); @@ -2241,8 +2076,7 @@ int ata_dev_configure(struct ata_device *dev) unsigned int err_mask; /* issue SET feature command to turn this on */ - err_mask = ata_dev_set_feature(dev, - SETFEATURES_SATA_ENABLE, SATA_AN); + err_mask = ata_dev_set_AN(dev, SETFEATURES_SATA_ENABLE); if (err_mask) ata_dev_printk(dev, KERN_ERR, "failed to enable ATAPI AN " @@ -2272,18 +2106,11 @@ int ata_dev_configure(struct ata_device *dev) if (dev->flags & ATA_DFLAG_LBA48) dev->max_sectors = ATA_MAX_SECTORS_LBA48; - if (!(dev->horkage & ATA_HORKAGE_IPM)) { - if (ata_id_has_hipm(dev->id)) - dev->flags |= ATA_DFLAG_HIPM; - if (ata_id_has_dipm(dev->id)) - dev->flags |= ATA_DFLAG_DIPM; - } - if (dev->horkage & ATA_HORKAGE_DIAGNOSTIC) { /* Let the user know. We don't want to disallow opens for rescue purposes, or in case the vendor is just a blithering idiot */ - if (print_info) { + if (print_info) { ata_dev_printk(dev, KERN_WARNING, "Drive reports diagnostics failure. This may indicate a drive\n"); ata_dev_printk(dev, KERN_WARNING, @@ -2304,13 +2131,6 @@ int ata_dev_configure(struct ata_device *dev) dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_128, dev->max_sectors); - if (ata_dev_blacklisted(dev) & ATA_HORKAGE_IPM) { - dev->horkage |= ATA_HORKAGE_IPM; - - /* reset link pm_policy for this port to no pm */ - ap->pm_policy = MAX_PERFORMANCE; - } - if (ap->ops->dev_config) ap->ops->dev_config(dev); @@ -2404,25 +2224,6 @@ int ata_bus_probe(struct ata_port *ap) tries[dev->devno] = ATA_PROBE_MAX_TRIES; retry: - ata_link_for_each_dev(dev, &ap->link) { - /* If we issue an SRST then an ATA drive (not ATAPI) - * may change configuration and be in PIO0 timing. If - * we do a hard reset (or are coming from power on) - * this is true for ATA or ATAPI. Until we've set a - * suitable controller mode we should not touch the - * bus as we may be talking too fast. - */ - dev->pio_mode = XFER_PIO_0; - - /* If the controller has a pio mode setup function - * then use it to set the chipset to rights. Don't - * touch the DMA setup as that will be dealt with when - * configuring devices. - */ - if (ap->ops->set_piomode) - ap->ops->set_piomode(ap, dev); - } - /* reset and determine device classes */ ap->ops->phy_reset(ap); @@ -2438,6 +2239,12 @@ int ata_bus_probe(struct ata_port *ap) ata_port_probe(ap); + /* after the reset the device state is PIO 0 and the controller + state is undefined. Record the mode */ + + ata_link_for_each_dev(dev, &ap->link) + dev->pio_mode = XFER_PIO_0; + /* read IDENTIFY page and configure devices. We have to do the identify specific sequence bass-ackwards so that PDIAG- is released by the slave device */ @@ -2860,8 +2667,8 @@ static const struct ata_timing ata_timing[] = { { 0xFF } }; -#define ENOUGH(v, unit) (((v)-1)/(unit)+1) -#define EZ(v, unit) ((v)?ENOUGH(v, unit):0) +#define ENOUGH(v,unit) (((v)-1)/(unit)+1) +#define EZ(v,unit) ((v)?ENOUGH(v,unit):0) static void ata_timing_quantize(const struct ata_timing *t, struct ata_timing *q, int T, int UT) { @@ -2888,7 +2695,7 @@ void ata_timing_merge(const struct ata_timing *a, const struct ata_timing *b, if (what & ATA_TIMING_UDMA ) m->udma = max(a->udma, b->udma); } -static const struct ata_timing *ata_timing_find_mode(unsigned short speed) +static const struct ata_timing* ata_timing_find_mode(unsigned short speed) { const struct ata_timing *t; @@ -2920,10 +2727,10 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed, if (adev->id[ATA_ID_FIELD_VALID] & 2) { /* EIDE drive */ memset(&p, 0, sizeof(p)); - if (speed >= XFER_PIO_0 && speed <= XFER_SW_DMA_0) { + if(speed >= XFER_PIO_0 && speed <= XFER_SW_DMA_0) { if (speed <= XFER_PIO_2) p.cycle = p.cyc8b = adev->id[ATA_ID_EIDE_PIO]; else p.cycle = p.cyc8b = adev->id[ATA_ID_EIDE_PIO_IORDY]; - } else if (speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2) { + } else if(speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2) { p.cycle = adev->id[ATA_ID_EIDE_DMA_MIN]; } ata_timing_merge(&p, t, t, ATA_TIMING_CYCLE | ATA_TIMING_CYC8B); @@ -3069,24 +2876,14 @@ static int ata_dev_set_mode(struct ata_device *dev) dev->flags |= ATA_DFLAG_PIO; err_mask = ata_dev_set_xfermode(dev); - /* Old CFA may refuse this command, which is just fine */ if (dev->xfer_shift == ATA_SHIFT_PIO && ata_id_is_cfa(dev->id)) - err_mask &= ~AC_ERR_DEV; - + err_mask &= ~AC_ERR_DEV; /* Some very old devices and some bad newer ones fail any kind of SET_XFERMODE request but support PIO0-2 timings and no IORDY */ if (dev->xfer_shift == ATA_SHIFT_PIO && !ata_id_has_iordy(dev->id) && dev->pio_mode <= XFER_PIO_2) err_mask &= ~AC_ERR_DEV; - - /* Early MWDMA devices do DMA but don't allow DMA mode setting. - Don't fail an MWDMA0 set IFF the device indicates it is in MWDMA0 */ - if (dev->xfer_shift == ATA_SHIFT_MWDMA && - dev->dma_mode == XFER_MW_DMA_0 && - (dev->id[63] >> 8) & 1) - err_mask &= ~AC_ERR_DEV; - if (err_mask) { ata_dev_printk(dev, KERN_ERR, "failed to set xfermode " "(err_mask=0x%x)\n", err_mask); @@ -3315,55 +3112,6 @@ int ata_busy_sleep(struct ata_port *ap, return 0; } -/** - * ata_wait_after_reset - wait before checking status after reset - * @ap: port containing status register to be polled - * @deadline: deadline jiffies for the operation - * - * After reset, we need to pause a while before reading status. - * Also, certain combination of controller and device report 0xff - * for some duration (e.g. until SATA PHY is up and running) - * which is interpreted as empty port in ATA world. This - * function also waits for such devices to get out of 0xff - * status. - * - * LOCKING: - * Kernel thread context (may sleep). - */ -void ata_wait_after_reset(struct ata_port *ap, unsigned long deadline) -{ - unsigned long until = jiffies + ATA_TMOUT_FF_WAIT; - - if (time_before(until, deadline)) - deadline = until; - - /* Spec mandates ">= 2ms" before checking status. We wait - * 150ms, because that was the magic delay used for ATAPI - * devices in Hale Landis's ATADRVR, for the period of time - * between when the ATA command register is written, and then - * status is checked. Because waiting for "a while" before - * checking status is fine, post SRST, we perform this magic - * delay here as well. - * - * Old drivers/ide uses the 2mS rule and then waits for ready. - */ - msleep(150); - - /* Wait for 0xff to clear. Some SATA devices take a long time - * to clear 0xff after reset. For example, HHD424020F7SV00 - * iVDR needs >= 800ms while. Quantum GoVault needs even more - * than that. - */ - while (1) { - u8 status = ata_chk_status(ap); - - if (status != 0xff || time_after(jiffies, deadline)) - return; - - msleep(50); - } -} - /** * ata_wait_ready - sleep until BSY clears, or timeout * @ap: port containing status register to be polled @@ -3470,6 +3218,8 @@ static int ata_bus_softreset(struct ata_port *ap, unsigned int devmask, unsigned long deadline) { struct ata_ioports *ioaddr = &ap->ioaddr; + struct ata_device *dev; + int i = 0; DPRINTK("ata%u: bus reset via SRST\n", ap->print_id); @@ -3480,14 +3230,42 @@ static int ata_bus_softreset(struct ata_port *ap, unsigned int devmask, udelay(20); /* FIXME: flush */ iowrite8(ap->ctl, ioaddr->ctl_addr); - /* wait a while before checking status */ - ata_wait_after_reset(ap, deadline); + /* If we issued an SRST then an ATA drive (not ATAPI) + * may have changed configuration and be in PIO0 timing. If + * we did a hard reset (or are coming from power on) this is + * true for ATA or ATAPI. Until we've set a suitable controller + * mode we should not touch the bus as we may be talking too fast. + */ + + ata_link_for_each_dev(dev, &ap->link) + dev->pio_mode = XFER_PIO_0; + + /* If the controller has a pio mode setup function then use + it to set the chipset to rights. Don't touch the DMA setup + as that will be dealt with when revalidating */ + if (ap->ops->set_piomode) { + ata_link_for_each_dev(dev, &ap->link) + if (devmask & (1 << i++)) + ap->ops->set_piomode(ap, dev); + } + + /* spec mandates ">= 2ms" before checking status. + * We wait 150ms, because that was the magic delay used for + * ATAPI devices in Hale Landis's ATADRVR, for the period of time + * between when the ATA command register is written, and then + * status is checked. Because waiting for "a while" before + * checking status is fine, post SRST, we perform this magic + * delay here as well. + * + * Old drivers/ide uses the 2mS rule and then waits for ready + */ + msleep(150); /* Before we perform post reset processing we want to see if * the bus shows 0xFF because the odd clown forgets the D7 * pulldown resistor. */ - if (ata_chk_status(ap) == 0xFF) + if (ata_check_status(ap) == 0xFF) return -ENODEV; return ata_bus_post_reset(ap, devmask, deadline); @@ -3908,8 +3686,8 @@ int sata_std_hardreset(struct ata_link *link, unsigned int *class, return 0; } - /* wait a while before checking status */ - ata_wait_after_reset(ap, deadline); + /* wait a while before checking status, see SRST for more info */ + msleep(150); /* If PMP is supported, we have to do follow-up SRST. Note * that some PMPs don't send D2H Reg FIS after hardreset at @@ -4165,8 +3943,11 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { { "SAMSUNG CD-ROM SC", NULL, ATA_HORKAGE_NODMA }, { "ATAPI CD-ROM DRIVE 40X MAXIMUM",NULL,ATA_HORKAGE_NODMA }, { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA }, - { "SAMSUNG CD-ROM SN-124", "N001", ATA_HORKAGE_NODMA }, + { "SAMSUNG CD-ROM SN-124","N001", ATA_HORKAGE_NODMA }, { "Seagate STT20000A", NULL, ATA_HORKAGE_NODMA }, + { "IOMEGA ZIP 250 ATAPI", NULL, ATA_HORKAGE_NODMA }, /* temporary fix */ + { "IOMEGA ZIP 250 ATAPI Floppy", + NULL, ATA_HORKAGE_NODMA }, /* Odd clown on sil3726/4726 PMPs */ { "Config Disk", NULL, ATA_HORKAGE_NODMA | ATA_HORKAGE_SKIP_PM }, @@ -4178,7 +3959,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { /* Devices where NCQ should be avoided */ /* NCQ is slow */ - { "WDC WD740ADFD-00", NULL, ATA_HORKAGE_NONCQ }, + { "WDC WD740ADFD-00", NULL, ATA_HORKAGE_NONCQ }, /* http://thread.gmane.org/gmane.linux.ide/14907 */ { "FUJITSU MHT2060BH", NULL, ATA_HORKAGE_NONCQ }, /* NCQ is broken */ @@ -4198,7 +3979,6 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { { "HTS541612J9SA00", "SBDIC7JP", ATA_HORKAGE_NONCQ, }, { "HDT722516DLA380", "V43OA96A", ATA_HORKAGE_NONCQ, }, { "Hitachi HTS541616J9SA00", "SB4OC70P", ATA_HORKAGE_NONCQ, }, - { "Hitachi HTS542525K9SA00", "BBFOC31P", ATA_HORKAGE_NONCQ, }, { "WDC WD740ADFD-00NLR1", NULL, ATA_HORKAGE_NONCQ, }, { "WDC WD3200AAJS-00RYA0", "12.01B01", ATA_HORKAGE_NONCQ, }, { "FUJITSU MHV2080BH", "00840028", ATA_HORKAGE_NONCQ, }, @@ -4209,7 +3989,6 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { { "ST3160812AS", "3.ADJ", ATA_HORKAGE_NONCQ, }, { "ST980813AS", "3.ADB", ATA_HORKAGE_NONCQ, }, { "SAMSUNG HD401LJ", "ZZ100-15", ATA_HORKAGE_NONCQ, }, - { "Maxtor 7V300F0", "VA111900", ATA_HORKAGE_NONCQ, }, /* devices which puke on READ_NATIVE_MAX */ { "HDS724040KLSA80", "KFAOA20N", ATA_HORKAGE_BROKEN_HPA, }, @@ -4225,7 +4004,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { { } }; -static int strn_pattern_cmp(const char *patt, const char *name, int wildchar) +int strn_pattern_cmp(const char *patt, const char *name, int wildchar) { const char *p; int len; @@ -4327,7 +4106,7 @@ static void ata_dev_xfermask(struct ata_device *dev) } if ((host->flags & ATA_HOST_SIMPLEX) && - host->simplex_claimed && host->simplex_claimed != ap) { + host->simplex_claimed && host->simplex_claimed != ap) { xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); ata_dev_printk(dev, KERN_WARNING, "simplex DMA is claimed by " "other device, disabling DMA\n"); @@ -4349,11 +4128,11 @@ static void ata_dev_xfermask(struct ata_device *dev) */ if (xfer_mask & (0xF8 << ATA_SHIFT_UDMA)) /* UDMA/44 or higher would be available */ - if ((ap->cbl == ATA_CBL_PATA40) || - (ata_drive_40wire(dev->id) && - (ap->cbl == ATA_CBL_PATA_UNK || - ap->cbl == ATA_CBL_PATA80))) { - ata_dev_printk(dev, KERN_WARNING, + if((ap->cbl == ATA_CBL_PATA40) || + (ata_drive_40wire(dev->id) && + (ap->cbl == ATA_CBL_PATA_UNK || + ap->cbl == ATA_CBL_PATA80))) { + ata_dev_printk(dev, KERN_WARNING, "limited to UDMA/33 due to 40-wire cable\n"); xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA); } @@ -4399,14 +4178,15 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev) DPRINTK("EXIT, err_mask=%x\n", err_mask); return err_mask; } + /** - * ata_dev_set_feature - Issue SET FEATURES - SATA FEATURES + * ata_dev_set_AN - Issue SET FEATURES - SATA FEATURES * @dev: Device to which command will be sent * @enable: Whether to enable or disable the feature - * @feature: The sector count represents the feature to set * * Issue SET FEATURES - SATA FEATURES command to device @dev - * on port @ap with sector count + * on port @ap with sector count set to indicate Asynchronous + * Notification feature * * LOCKING: * PCI/etc. bus probe sem. @@ -4414,8 +4194,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev) * RETURNS: * 0 on success, AC_ERR_* mask otherwise. */ -static unsigned int ata_dev_set_feature(struct ata_device *dev, u8 enable, - u8 feature) +static unsigned int ata_dev_set_AN(struct ata_device *dev, u8 enable) { struct ata_taskfile tf; unsigned int err_mask; @@ -4428,7 +4207,7 @@ static unsigned int ata_dev_set_feature(struct ata_device *dev, u8 enable, tf.feature = enable; tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; tf.protocol = ATA_PROT_NODATA; - tf.nsect = feature; + tf.nsect = SATA_AN; err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); @@ -4616,7 +4395,7 @@ static void ata_fill_sg_dumb(struct ata_queued_cmd *qc) u32 addr, offset; u32 sg_len, len, blen; - /* determine if physical DMA addr spans 64K boundary. + /* determine if physical DMA addr spans 64K boundary. * Note h/w doesn't support 64-bit, so we unconditionally * truncate dma_addr_t to u32. */ @@ -4907,9 +4686,8 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) * data in this function or read data in ata_sg_clean. */ offset = lsg->offset + lsg->length - qc->pad_len; - sg_init_table(psg, 1); - sg_set_page(psg, nth_page(sg_page(lsg), offset >> PAGE_SHIFT), - qc->pad_len, offset_in_page(offset)); + sg_set_page(psg, nth_page(sg_page(lsg), offset >> PAGE_SHIFT)); + psg->offset = offset_in_page(offset); if (qc->tf.flags & ATA_TFLAG_WRITE) { void *addr = kmap_atomic(sg_page(psg), KM_IRQ0); @@ -5202,7 +4980,7 @@ static void __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes) "%u bytes trailing data\n", bytes); for (i = 0; i < words; i++) - ap->ops->data_xfer(qc->dev, (unsigned char *)pad_buf, 2, do_write); + ap->ops->data_xfer(qc->dev, (unsigned char*)pad_buf, 2, do_write); ap->hsm_task_state = HSM_ST_LAST; return; @@ -5813,9 +5591,6 @@ void ata_qc_complete(struct ata_queued_cmd *qc) * taken care of. */ if (ap->ops->error_handler) { - struct ata_device *dev = qc->dev; - struct ata_eh_info *ehi = &dev->link->eh_info; - WARN_ON(ap->pflags & ATA_PFLAG_FROZEN); if (unlikely(qc->err_mask)) @@ -5834,27 +5609,6 @@ void ata_qc_complete(struct ata_queued_cmd *qc) if (qc->flags & ATA_QCFLAG_RESULT_TF) fill_result_tf(qc); - /* Some commands need post-processing after successful - * completion. - */ - switch (qc->tf.command) { - case ATA_CMD_SET_FEATURES: - if (qc->tf.feature != SETFEATURES_WC_ON && - qc->tf.feature != SETFEATURES_WC_OFF) - break; - /* fall through */ - case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */ - case ATA_CMD_SET_MULTI: /* multi_count changed */ - /* revalidate device */ - ehi->dev_action[dev->devno] |= ATA_EH_REVALIDATE; - ata_port_schedule_eh(ap); - break; - - case ATA_CMD_SLEEP: - dev->flags |= ATA_DFLAG_SLEEPING; - break; - } - __ata_qc_complete(qc); } else { if (qc->flags & ATA_QCFLAG_EH_SCHEDULED) @@ -5992,14 +5746,6 @@ void ata_qc_issue(struct ata_queued_cmd *qc) qc->flags &= ~ATA_QCFLAG_DMAMAP; } - /* if device is sleeping, schedule softreset and abort the link */ - if (unlikely(qc->dev->flags & ATA_DFLAG_SLEEPING)) { - link->eh_info.action |= ATA_EH_SOFTRESET; - ata_ehi_push_desc(&link->eh_info, "waking up from sleep"); - ata_link_abort(link); - return; - } - ap->ops->qc_prep(qc); qc->err_mask |= ap->ops->qc_issue(qc); @@ -6162,8 +5908,8 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc) * One if interrupt was handled, zero if not (shared irq). */ -inline unsigned int ata_host_intr(struct ata_port *ap, - struct ata_queued_cmd *qc) +inline unsigned int ata_host_intr (struct ata_port *ap, + struct ata_queued_cmd *qc) { struct ata_eh_info *ehi = &ap->link.eh_info; u8 status, host_stat = 0; @@ -6263,7 +6009,7 @@ inline unsigned int ata_host_intr(struct ata_port *ap, * IRQ_NONE or IRQ_HANDLED. */ -irqreturn_t ata_interrupt(int irq, void *dev_instance) +irqreturn_t ata_interrupt (int irq, void *dev_instance) { struct ata_host *host = dev_instance; unsigned int i; @@ -6466,7 +6212,7 @@ int ata_flush_cache(struct ata_device *dev) /* This is wrong. On a failed flush we get back the LBA of the lost sector and we should (assuming it wasn't aborted as unknown) issue - a further flush command to continue the writeback until it + a further flush command to continue the writeback until it does not error */ err_mask = ata_do_simple_cmd(dev, cmd); if (err_mask) { @@ -6547,12 +6293,6 @@ int ata_host_suspend(struct ata_host *host, pm_message_t mesg) { int rc; - /* - * disable link pm on all ports before requesting - * any pm activity - */ - ata_lpm_enable(host); - rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1); if (rc == 0) host->dev->power.power_state = mesg; @@ -6575,9 +6315,6 @@ void ata_host_resume(struct ata_host *host) ata_host_request_pm(host, PMSG_ON, ATA_EH_SOFTRESET, ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET, 0); host->dev->power.power_state = PMSG_ON; - - /* reenable link pm */ - ata_lpm_disable(host); } #endif @@ -7120,7 +6857,6 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) struct ata_port *ap = host->ports[i]; ata_scsi_scan_host(ap, 1); - ata_lpm_schedule(ap, ap->pm_policy); } return 0; @@ -7182,7 +6918,7 @@ int ata_host_activate(struct ata_host *host, int irq, * LOCKING: * Kernel thread context (may sleep). */ -static void ata_port_detach(struct ata_port *ap) +void ata_port_detach(struct ata_port *ap) { unsigned long flags; struct ata_link *link; @@ -7517,6 +7253,7 @@ const struct ata_port_info ata_dummy_port_info = { * likely to change as new drivers are added and updated. * Do not depend on ABI/API stability. */ + EXPORT_SYMBOL_GPL(sata_deb_timing_normal); EXPORT_SYMBOL_GPL(sata_deb_timing_hotplug); EXPORT_SYMBOL_GPL(sata_deb_timing_long); @@ -7586,7 +7323,6 @@ EXPORT_SYMBOL_GPL(ata_port_disable); EXPORT_SYMBOL_GPL(ata_ratelimit); EXPORT_SYMBOL_GPL(ata_wait_register); EXPORT_SYMBOL_GPL(ata_busy_sleep); -EXPORT_SYMBOL_GPL(ata_wait_after_reset); EXPORT_SYMBOL_GPL(ata_wait_ready); EXPORT_SYMBOL_GPL(ata_port_queue_task); EXPORT_SYMBOL_GPL(ata_scsi_ioctl); diff --git a/trunk/drivers/ata/libata-eh.c b/trunk/drivers/ata/libata-eh.c index 8d64f8fd8f1d..2eaa39fc65d0 100644 --- a/trunk/drivers/ata/libata-eh.c +++ b/trunk/drivers/ata/libata-eh.c @@ -1197,7 +1197,7 @@ void ata_eh_done(struct ata_link *link, struct ata_device *dev, * RETURNS: * Descriptive string for @err_mask */ -static const char *ata_err_string(unsigned int err_mask) +static const char * ata_err_string(unsigned int err_mask) { if (err_mask & AC_ERR_HOST_BUS) return "host bus error"; @@ -1800,8 +1800,10 @@ static void ata_eh_link_autopsy(struct ata_link *link) qc->err_mask &= ~AC_ERR_OTHER; /* SENSE_VALID trumps dev/unknown error and revalidation */ - if (qc->flags & ATA_QCFLAG_SENSE_VALID) + if (qc->flags & ATA_QCFLAG_SENSE_VALID) { qc->err_mask &= ~(AC_ERR_DEV | AC_ERR_OTHER); + ehc->i.action &= ~ATA_EH_REVALIDATE; + } /* accumulate error info */ ehc->i.dev = qc->dev; @@ -1814,8 +1816,7 @@ static void ata_eh_link_autopsy(struct ata_link *link) if (ap->pflags & ATA_PFLAG_FROZEN || all_err_mask & (AC_ERR_HSM | AC_ERR_TIMEOUT)) ehc->i.action |= ATA_EH_SOFTRESET; - else if ((is_io && all_err_mask) || - (!is_io && (all_err_mask & ~AC_ERR_DEV))) + else if (all_err_mask) ehc->i.action |= ATA_EH_REVALIDATE; /* if we have offending qcs and the associated failed device */ @@ -1878,9 +1879,7 @@ static void ata_eh_link_report(struct ata_link *link) for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); - if (!(qc->flags & ATA_QCFLAG_FAILED) || qc->dev->link != link || - ((qc->flags & ATA_QCFLAG_QUIET) && - qc->err_mask == AC_ERR_DEV)) + if (!(qc->flags & ATA_QCFLAG_FAILED) || qc->dev->link != link) continue; if (qc->flags & ATA_QCFLAG_SENSE_VALID && !qc->err_mask) continue; @@ -1935,7 +1934,7 @@ static void ata_eh_link_report(struct ata_link *link) ehc->i.serror & SERR_LINK_SEQ_ERR ? "LinkSeq " : "", ehc->i.serror & SERR_TRANS_ST_ERROR ? "TrStaTrns " : "", ehc->i.serror & SERR_UNRECOG_FIS ? "UnrecFIS " : "", - ehc->i.serror & SERR_DEV_XCHG ? "DevExch " : ""); + ehc->i.serror & SERR_DEV_XCHG ? "DevExch " : "" ); for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { static const char *dma_str[] = { @@ -1970,17 +1969,17 @@ static void ata_eh_link_report(struct ata_link *link) qc->err_mask & AC_ERR_NCQ ? " " : ""); if (res->command & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | - ATA_ERR)) { + ATA_ERR) ) { if (res->command & ATA_BUSY) ata_dev_printk(qc->dev, KERN_ERR, - "status: { Busy }\n"); + "status: { Busy }\n" ); else ata_dev_printk(qc->dev, KERN_ERR, "status: { %s%s%s%s}\n", res->command & ATA_DRDY ? "DRDY " : "", res->command & ATA_DF ? "DF " : "", res->command & ATA_DRQ ? "DRQ " : "", - res->command & ATA_ERR ? "ERR " : ""); + res->command & ATA_ERR ? "ERR " : "" ); } if (cmd->command != ATA_CMD_PACKET && @@ -1991,7 +1990,7 @@ static void ata_eh_link_report(struct ata_link *link) res->feature & ATA_ICRC ? "ICRC " : "", res->feature & ATA_UNC ? "UNC " : "", res->feature & ATA_IDNF ? "IDNF " : "", - res->feature & ATA_ABORTED ? "ABRT " : ""); + res->feature & ATA_ABORTED ? "ABRT " : "" ); } } @@ -2072,7 +2071,7 @@ int ata_eh_reset(struct ata_link *link, int classify, int try = 0; struct ata_device *dev; unsigned long deadline; - unsigned int tmp_action; + unsigned int action; ata_reset_fn_t reset; unsigned long flags; int rc; @@ -2084,36 +2083,17 @@ int ata_eh_reset(struct ata_link *link, int classify, ata_eh_about_to_do(link, NULL, ehc->i.action & ATA_EH_RESET_MASK); - ata_link_for_each_dev(dev, link) { - /* If we issue an SRST then an ATA drive (not ATAPI) - * may change configuration and be in PIO0 timing. If - * we do a hard reset (or are coming from power on) - * this is true for ATA or ATAPI. Until we've set a - * suitable controller mode we should not touch the - * bus as we may be talking too fast. - */ - dev->pio_mode = XFER_PIO_0; - - /* If the controller has a pio mode setup function - * then use it to set the chipset to rights. Don't - * touch the DMA setup as that will be dealt with when - * configuring devices. - */ - if (ap->ops->set_piomode) - ap->ops->set_piomode(ap, dev); - } - /* Determine which reset to use and record in ehc->i.action. * prereset() may examine and modify it. */ + action = ehc->i.action; + ehc->i.action &= ~ATA_EH_RESET_MASK; if (softreset && (!hardreset || (!(link->flags & ATA_LFLAG_NO_SRST) && !sata_set_spd_needed(link) && - !(ehc->i.action & ATA_EH_HARDRESET)))) - tmp_action = ATA_EH_SOFTRESET; + !(action & ATA_EH_HARDRESET)))) + ehc->i.action |= ATA_EH_SOFTRESET; else - tmp_action = ATA_EH_HARDRESET; - - ehc->i.action = (ehc->i.action & ~ATA_EH_RESET_MASK) | tmp_action; + ehc->i.action |= ATA_EH_HARDRESET; if (prereset) { rc = prereset(link, jiffies + ATA_EH_PRERESET_TIMEOUT); @@ -2228,11 +2208,9 @@ int ata_eh_reset(struct ata_link *link, int classify, ata_link_for_each_dev(dev, link) { /* After the reset, the device state is PIO 0 * and the controller state is undefined. - * Reset also wakes up drives from sleeping - * mode. + * Record the mode. */ dev->pio_mode = XFER_PIO_0; - dev->flags &= ~ATA_DFLAG_SLEEPING; if (ata_link_offline(link)) continue; @@ -2438,7 +2416,7 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err) /* give it just one more chance */ ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1); case -EIO: - if (ehc->tries[dev->devno] == 1 && dev->pio_mode > XFER_PIO_0) { + if (ehc->tries[dev->devno] == 1) { /* This is the last chance, better to slow * down than lose it. */ @@ -2629,15 +2607,11 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, ehc->i.flags &= ~ATA_EHI_SETMODE; } - if (ehc->i.action & ATA_EHI_LPM) - ata_link_for_each_dev(dev, link) - ata_dev_enable_pm(dev, ap->pm_policy); - /* this link is okay now */ ehc->i.flags = 0; continue; -dev_fail: + dev_fail: nr_failed_devs++; if (ata_eh_handle_dev_fail(dev, rc)) nr_disabled_devs++; @@ -2698,15 +2672,8 @@ void ata_eh_finish(struct ata_port *ap) /* FIXME: Once EH migration is complete, * generate sense data in this function, * considering both err_mask and tf. - * - * There's no point in retrying invalid - * (detected by libata) and non-IO device - * errors (rejected by device). Finish them - * immediately. */ - if ((qc->err_mask & AC_ERR_INVALID) || - (!(qc->flags & ATA_QCFLAG_IO) && - qc->err_mask == AC_ERR_DEV)) + if (qc->err_mask & AC_ERR_INVALID) ata_eh_qc_complete(qc); else ata_eh_qc_retry(qc); diff --git a/trunk/drivers/ata/libata-scsi.c b/trunk/drivers/ata/libata-scsi.c index fc89590d3772..5b758b9ad0b8 100644 --- a/trunk/drivers/ata/libata-scsi.c +++ b/trunk/drivers/ata/libata-scsi.c @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include "libata.h" @@ -53,9 +53,9 @@ typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc); -static struct ata_device *__ata_scsi_find_dev(struct ata_port *ap, +static struct ata_device * __ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev); -static struct ata_device *ata_scsi_find_dev(struct ata_port *ap, +static struct ata_device * ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev); static int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel, unsigned int id, unsigned int lun); @@ -110,74 +110,6 @@ static struct scsi_transport_template ata_scsi_transport_template = { }; -static const struct { - enum link_pm value; - const char *name; -} link_pm_policy[] = { - { NOT_AVAILABLE, "max_performance" }, - { MIN_POWER, "min_power" }, - { MAX_PERFORMANCE, "max_performance" }, - { MEDIUM_POWER, "medium_power" }, -}; - -const char *ata_scsi_lpm_get(enum link_pm policy) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(link_pm_policy); i++) - if (link_pm_policy[i].value == policy) - return link_pm_policy[i].name; - - return NULL; -} - -static ssize_t ata_scsi_lpm_put(struct class_device *class_dev, - const char *buf, size_t count) -{ - struct Scsi_Host *shost = class_to_shost(class_dev); - struct ata_port *ap = ata_shost_to_port(shost); - enum link_pm policy = 0; - int i; - - /* - * we are skipping array location 0 on purpose - this - * is because a value of NOT_AVAILABLE is displayed - * to the user as max_performance, but when the user - * writes "max_performance", they actually want the - * value to match MAX_PERFORMANCE. - */ - for (i = 1; i < ARRAY_SIZE(link_pm_policy); i++) { - const int len = strlen(link_pm_policy[i].name); - if (strncmp(link_pm_policy[i].name, buf, len) == 0 && - buf[len] == '\n') { - policy = link_pm_policy[i].value; - break; - } - } - if (!policy) - return -EINVAL; - - ata_lpm_schedule(ap, policy); - return count; -} - -static ssize_t -ata_scsi_lpm_show(struct class_device *class_dev, char *buf) -{ - struct Scsi_Host *shost = class_to_shost(class_dev); - struct ata_port *ap = ata_shost_to_port(shost); - const char *policy = - ata_scsi_lpm_get(ap->pm_policy); - - if (!policy) - return -EINVAL; - - return snprintf(buf, 23, "%s\n", policy); -} -CLASS_DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR, - ata_scsi_lpm_show, ata_scsi_lpm_put); -EXPORT_SYMBOL_GPL(class_device_attr_link_power_management_policy); - static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) { @@ -296,7 +228,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg) scsi_cmd[1] = (4 << 1); /* PIO Data-in */ scsi_cmd[2] = 0x0e; /* no off.line or cc, read from dev, - block count in sector count field */ + block count in sector count field */ data_dir = DMA_FROM_DEVICE; } else { scsi_cmd[1] = (3 << 1); /* Non-data */ @@ -320,7 +252,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg) /* Good values for timeout and retries? Values below from scsi_ioctl_send_command() for default case... */ cmd_result = scsi_execute(scsidev, scsi_cmd, data_dir, argbuf, argsize, - sensebuf, (10*HZ), 5, 0); + sensebuf, (10*HZ), 5, 0); if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */ u8 *desc = sensebuf + 8; @@ -331,18 +263,18 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg) if (cmd_result & SAM_STAT_CHECK_CONDITION) { struct scsi_sense_hdr sshdr; scsi_normalize_sense(sensebuf, SCSI_SENSE_BUFFERSIZE, - &sshdr); - if (sshdr.sense_key == 0 && - sshdr.asc == 0 && sshdr.ascq == 0) + &sshdr); + if (sshdr.sense_key==0 && + sshdr.asc==0 && sshdr.ascq==0) cmd_result &= ~SAM_STAT_CHECK_CONDITION; } /* Send userspace a few ATA registers (same as drivers/ide) */ - if (sensebuf[0] == 0x72 && /* format is "descriptor" */ - desc[0] == 0x09) { /* code is "ATA Descriptor" */ - args[0] = desc[13]; /* status */ - args[1] = desc[3]; /* error */ - args[2] = desc[5]; /* sector count (0:7) */ + if (sensebuf[0] == 0x72 && /* format is "descriptor" */ + desc[0] == 0x09 ) { /* code is "ATA Descriptor" */ + args[0] = desc[13]; /* status */ + args[1] = desc[3]; /* error */ + args[2] = desc[5]; /* sector count (0:7) */ if (copy_to_user(arg, args, sizeof(args))) rc = -EFAULT; } @@ -418,8 +350,8 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg) struct scsi_sense_hdr sshdr; scsi_normalize_sense(sensebuf, SCSI_SENSE_BUFFERSIZE, &sshdr); - if (sshdr.sense_key == 0 && - sshdr.asc == 0 && sshdr.ascq == 0) + if (sshdr.sense_key==0 && + sshdr.asc==0 && sshdr.ascq==0) cmd_result &= ~SAM_STAT_CHECK_CONDITION; } @@ -1043,7 +975,7 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc) if ((qc->dev->flags & ATA_DFLAG_SPUNDOWN) && (system_state == SYSTEM_HALT || system_state == SYSTEM_POWER_OFF)) { - static unsigned long warned; + static unsigned long warned = 0; if (!test_and_set_bit(0, &warned)) { ata_dev_printk(qc->dev, KERN_WARNING, @@ -1108,9 +1040,6 @@ static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc) else tf->command = ATA_CMD_FLUSH; - /* flush is critical for IO integrity, consider it an IO command */ - qc->flags |= ATA_QCFLAG_IO; - return 0; } @@ -1432,9 +1361,32 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc) static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; + struct ata_eh_info *ehi = &qc->dev->link->eh_info; struct scsi_cmnd *cmd = qc->scsicmd; u8 *cdb = cmd->cmnd; - int need_sense = (qc->err_mask != 0); + int need_sense = (qc->err_mask != 0); + + /* We snoop the SET_FEATURES - Write Cache ON/OFF command, and + * schedule EH_REVALIDATE operation to update the IDENTIFY DEVICE + * cache + */ + if (ap->ops->error_handler && !need_sense) { + switch (qc->tf.command) { + case ATA_CMD_SET_FEATURES: + if ((qc->tf.feature == SETFEATURES_WC_ON) || + (qc->tf.feature == SETFEATURES_WC_OFF)) { + ehi->action |= ATA_EH_REVALIDATE; + ata_port_schedule_eh(ap); + } + break; + + case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */ + case ATA_CMD_SET_MULTI: /* multi_count changed */ + ehi->action |= ATA_EH_REVALIDATE; + ata_port_schedule_eh(ap); + break; + } + } /* For ATA pass thru (SAT) commands, generate a sense block if * user mandated it or if there's an error. Note that if we @@ -1444,7 +1396,7 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) * was no error, SK, ASC and ASCQ will all be zero. */ if (((cdb[0] == ATA_16) || (cdb[0] == ATA_12)) && - ((cdb[2] & 0x20) || need_sense)) { + ((cdb[2] & 0x20) || need_sense)) { ata_gen_passthru_sense(qc); } else { if (!need_sense) { @@ -1548,7 +1500,7 @@ static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd, return 0; early_finish: - ata_qc_free(qc); + ata_qc_free(qc); qc->scsidone(cmd); DPRINTK("EXIT - early finish (good or error)\n"); return 0; @@ -1638,8 +1590,8 @@ static inline void ata_scsi_rbuf_put(struct scsi_cmnd *cmd, u8 *buf) */ void ata_scsi_rbuf_fill(struct ata_scsi_args *args, - unsigned int (*actor) (struct ata_scsi_args *args, - u8 *rbuf, unsigned int buflen)) + unsigned int (*actor) (struct ata_scsi_args *args, + u8 *rbuf, unsigned int buflen)) { u8 *rbuf; unsigned int buflen, rc; @@ -2188,7 +2140,7 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, * None. */ unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf, - unsigned int buflen) + unsigned int buflen) { u64 last_lba = args->dev->n_sectors - 1; /* LBA of the last block */ @@ -2512,7 +2464,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc) return 0; } -static struct ata_device *ata_find_dev(struct ata_port *ap, int devno) +static struct ata_device * ata_find_dev(struct ata_port *ap, int devno) { if (ap->nr_pmp_links == 0) { if (likely(devno < ata_link_max_devices(&ap->link))) @@ -2525,8 +2477,8 @@ static struct ata_device *ata_find_dev(struct ata_port *ap, int devno) return NULL; } -static struct ata_device *__ata_scsi_find_dev(struct ata_port *ap, - const struct scsi_device *scsidev) +static struct ata_device * __ata_scsi_find_dev(struct ata_port *ap, + const struct scsi_device *scsidev) { int devno; @@ -2612,27 +2564,27 @@ static u8 ata_scsi_map_proto(u8 byte1) { switch((byte1 & 0x1e) >> 1) { - case 3: /* Non-data */ - return ATA_PROT_NODATA; - - case 6: /* DMA */ - case 10: /* UDMA Data-in */ - case 11: /* UDMA Data-Out */ - return ATA_PROT_DMA; - - case 4: /* PIO Data-in */ - case 5: /* PIO Data-out */ - return ATA_PROT_PIO; - - case 0: /* Hard Reset */ - case 1: /* SRST */ - case 8: /* Device Diagnostic */ - case 9: /* Device Reset */ - case 7: /* DMA Queued */ - case 12: /* FPDMA */ - case 15: /* Return Response Info */ - default: /* Reserved */ - break; + case 3: /* Non-data */ + return ATA_PROT_NODATA; + + case 6: /* DMA */ + case 10: /* UDMA Data-in */ + case 11: /* UDMA Data-Out */ + return ATA_PROT_DMA; + + case 4: /* PIO Data-in */ + case 5: /* PIO Data-out */ + return ATA_PROT_PIO; + + case 0: /* Hard Reset */ + case 1: /* SRST */ + case 8: /* Device Diagnostic */ + case 9: /* Device Reset */ + case 7: /* DMA Queued */ + case 12: /* FPDMA */ + case 15: /* Return Response Info */ + default: /* Reserved */ + break; } return ATA_PROT_UNKNOWN; @@ -2767,8 +2719,8 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) */ qc->nbytes = scsi_bufflen(scmd); - /* request result TF and be quiet about device error */ - qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET; + /* request result TF */ + qc->flags |= ATA_QCFLAG_RESULT_TF; return 0; @@ -2967,94 +2919,94 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, args.done = done; switch(scsicmd[0]) { - /* TODO: worth improving? */ - case FORMAT_UNIT: - ata_scsi_invalid_field(cmd, done); - break; - - case INQUIRY: - if (scsicmd[1] & 2) /* is CmdDt set? */ + /* TODO: worth improving? */ + case FORMAT_UNIT: ata_scsi_invalid_field(cmd, done); - else if ((scsicmd[1] & 1) == 0) /* is EVPD clear? */ - ata_scsi_rbuf_fill(&args, ata_scsiop_inq_std); - else switch (scsicmd[2]) { - case 0x00: - ata_scsi_rbuf_fill(&args, ata_scsiop_inq_00); break; - case 0x80: - ata_scsi_rbuf_fill(&args, ata_scsiop_inq_80); - break; - case 0x83: - ata_scsi_rbuf_fill(&args, ata_scsiop_inq_83); + + case INQUIRY: + if (scsicmd[1] & 2) /* is CmdDt set? */ + ata_scsi_invalid_field(cmd, done); + else if ((scsicmd[1] & 1) == 0) /* is EVPD clear? */ + ata_scsi_rbuf_fill(&args, ata_scsiop_inq_std); + else switch (scsicmd[2]) { + case 0x00: + ata_scsi_rbuf_fill(&args, ata_scsiop_inq_00); + break; + case 0x80: + ata_scsi_rbuf_fill(&args, ata_scsiop_inq_80); + break; + case 0x83: + ata_scsi_rbuf_fill(&args, ata_scsiop_inq_83); + break; + case 0x89: + ata_scsi_rbuf_fill(&args, ata_scsiop_inq_89); + break; + default: + ata_scsi_invalid_field(cmd, done); + break; + } break; - case 0x89: - ata_scsi_rbuf_fill(&args, ata_scsiop_inq_89); + + case MODE_SENSE: + case MODE_SENSE_10: + ata_scsi_rbuf_fill(&args, ata_scsiop_mode_sense); break; - default: + + case MODE_SELECT: /* unconditionally return */ + case MODE_SELECT_10: /* bad-field-in-cdb */ ata_scsi_invalid_field(cmd, done); break; - } - break; - case MODE_SENSE: - case MODE_SENSE_10: - ata_scsi_rbuf_fill(&args, ata_scsiop_mode_sense); - break; - - case MODE_SELECT: /* unconditionally return */ - case MODE_SELECT_10: /* bad-field-in-cdb */ - ata_scsi_invalid_field(cmd, done); - break; - - case READ_CAPACITY: - ata_scsi_rbuf_fill(&args, ata_scsiop_read_cap); - break; - - case SERVICE_ACTION_IN: - if ((scsicmd[1] & 0x1f) == SAI_READ_CAPACITY_16) + case READ_CAPACITY: ata_scsi_rbuf_fill(&args, ata_scsiop_read_cap); - else - ata_scsi_invalid_field(cmd, done); - break; + break; - case REPORT_LUNS: - ata_scsi_rbuf_fill(&args, ata_scsiop_report_luns); - break; + case SERVICE_ACTION_IN: + if ((scsicmd[1] & 0x1f) == SAI_READ_CAPACITY_16) + ata_scsi_rbuf_fill(&args, ata_scsiop_read_cap); + else + ata_scsi_invalid_field(cmd, done); + break; - case REQUEST_SENSE: - ata_scsi_set_sense(cmd, 0, 0, 0); - cmd->result = (DRIVER_SENSE << 24); - done(cmd); - break; + case REPORT_LUNS: + ata_scsi_rbuf_fill(&args, ata_scsiop_report_luns); + break; - /* if we reach this, then writeback caching is disabled, - * turning this into a no-op. - */ - case SYNCHRONIZE_CACHE: - /* fall through */ - - /* no-op's, complete with success */ - case REZERO_UNIT: - case SEEK_6: - case SEEK_10: - case TEST_UNIT_READY: - ata_scsi_rbuf_fill(&args, ata_scsiop_noop); - break; + case REQUEST_SENSE: + ata_scsi_set_sense(cmd, 0, 0, 0); + cmd->result = (DRIVER_SENSE << 24); + done(cmd); + break; - case SEND_DIAGNOSTIC: - tmp8 = scsicmd[1] & ~(1 << 3); - if ((tmp8 == 0x4) && (!scsicmd[3]) && (!scsicmd[4])) + /* if we reach this, then writeback caching is disabled, + * turning this into a no-op. + */ + case SYNCHRONIZE_CACHE: + /* fall through */ + + /* no-op's, complete with success */ + case REZERO_UNIT: + case SEEK_6: + case SEEK_10: + case TEST_UNIT_READY: ata_scsi_rbuf_fill(&args, ata_scsiop_noop); - else - ata_scsi_invalid_field(cmd, done); - break; + break; - /* all other commands */ - default: - ata_scsi_set_sense(cmd, ILLEGAL_REQUEST, 0x20, 0x0); - /* "Invalid command operation code" */ - done(cmd); - break; + case SEND_DIAGNOSTIC: + tmp8 = scsicmd[1] & ~(1 << 3); + if ((tmp8 == 0x4) && (!scsicmd[3]) && (!scsicmd[4])) + ata_scsi_rbuf_fill(&args, ata_scsiop_noop); + else + ata_scsi_invalid_field(cmd, done); + break; + + /* all other commands */ + default: + ata_scsi_set_sense(cmd, ILLEGAL_REQUEST, 0x20, 0x0); + /* "Invalid command operation code" */ + done(cmd); + break; } } diff --git a/trunk/drivers/ata/libata-sff.c b/trunk/drivers/ata/libata-sff.c index 48acc09dab96..8227c45109ec 100644 --- a/trunk/drivers/ata/libata-sff.c +++ b/trunk/drivers/ata/libata-sff.c @@ -248,7 +248,7 @@ void ata_bmdma_setup(struct ata_queued_cmd *qc) * LOCKING: * spin_lock_irqsave(host lock) */ -void ata_bmdma_start(struct ata_queued_cmd *qc) +void ata_bmdma_start (struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; u8 dmactl; diff --git a/trunk/drivers/ata/libata.h b/trunk/drivers/ata/libata.h index 0e6cf3a484dc..90df58a3edc9 100644 --- a/trunk/drivers/ata/libata.h +++ b/trunk/drivers/ata/libata.h @@ -101,8 +101,6 @@ extern int sata_link_init_spd(struct ata_link *link); extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg); extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg); extern struct ata_port *ata_port_alloc(struct ata_host *host); -extern void ata_dev_enable_pm(struct ata_device *dev, enum link_pm policy); -extern void ata_lpm_schedule(struct ata_port *ap, enum link_pm); /* libata-acpi.c */ #ifdef CONFIG_ATA_ACPI diff --git a/trunk/drivers/ata/pata_acpi.c b/trunk/drivers/ata/pata_acpi.c index e4542ab9c7f8..0f6f7bcc3def 100644 --- a/trunk/drivers/ata/pata_acpi.c +++ b/trunk/drivers/ata/pata_acpi.c @@ -181,7 +181,7 @@ static void pacpi_set_piomode(struct ata_port *ap, struct ata_device *adev) int unit = adev->devno; struct pata_acpi *acpi = ap->private_data; - if (!(acpi->gtm.flags & 0x10)) + if(!(acpi->gtm.flags & 0x10)) unit = 0; /* Now stuff the nS values into the structure */ @@ -202,7 +202,7 @@ static void pacpi_set_dmamode(struct ata_port *ap, struct ata_device *adev) int unit = adev->devno; struct pata_acpi *acpi = ap->private_data; - if (!(acpi->gtm.flags & 0x10)) + if(!(acpi->gtm.flags & 0x10)) unit = 0; /* Now stuff the nS values into the structure */ diff --git a/trunk/drivers/ata/pata_icside.c b/trunk/drivers/ata/pata_icside.c index 842fe08a3c13..be30923566c5 100644 --- a/trunk/drivers/ata/pata_icside.c +++ b/trunk/drivers/ata/pata_icside.c @@ -332,13 +332,12 @@ static void ata_dummy_noret(struct ata_port *port) { } -static void pata_icside_postreset(struct ata_link *link, unsigned int *classes) +static void pata_icside_postreset(struct ata_port *ap, unsigned int *classes) { - struct ata_port *ap = link->ap; struct pata_icside_state *state = ap->host->private_data; if (classes[0] != ATA_DEV_NONE || classes[1] != ATA_DEV_NONE) - return ata_std_postreset(link, classes); + return ata_std_postreset(ap, classes); state->port[ap->port_no].disabled = 1; @@ -396,30 +395,29 @@ static struct ata_port_operations pata_icside_port_ops = { static void __devinit pata_icside_setup_ioaddr(struct ata_port *ap, void __iomem *base, - struct pata_icside_info *info, - const struct portinfo *port) + const struct portinfo *info) { struct ata_ioports *ioaddr = &ap->ioaddr; - void __iomem *cmd = base + port->dataoffset; + void __iomem *cmd = base + info->dataoffset; ioaddr->cmd_addr = cmd; - ioaddr->data_addr = cmd + (ATA_REG_DATA << port->stepping); - ioaddr->error_addr = cmd + (ATA_REG_ERR << port->stepping); - ioaddr->feature_addr = cmd + (ATA_REG_FEATURE << port->stepping); - ioaddr->nsect_addr = cmd + (ATA_REG_NSECT << port->stepping); - ioaddr->lbal_addr = cmd + (ATA_REG_LBAL << port->stepping); - ioaddr->lbam_addr = cmd + (ATA_REG_LBAM << port->stepping); - ioaddr->lbah_addr = cmd + (ATA_REG_LBAH << port->stepping); - ioaddr->device_addr = cmd + (ATA_REG_DEVICE << port->stepping); - ioaddr->status_addr = cmd + (ATA_REG_STATUS << port->stepping); - ioaddr->command_addr = cmd + (ATA_REG_CMD << port->stepping); - - ioaddr->ctl_addr = base + port->ctrloffset; + ioaddr->data_addr = cmd + (ATA_REG_DATA << info->stepping); + ioaddr->error_addr = cmd + (ATA_REG_ERR << info->stepping); + ioaddr->feature_addr = cmd + (ATA_REG_FEATURE << info->stepping); + ioaddr->nsect_addr = cmd + (ATA_REG_NSECT << info->stepping); + ioaddr->lbal_addr = cmd + (ATA_REG_LBAL << info->stepping); + ioaddr->lbam_addr = cmd + (ATA_REG_LBAM << info->stepping); + ioaddr->lbah_addr = cmd + (ATA_REG_LBAH << info->stepping); + ioaddr->device_addr = cmd + (ATA_REG_DEVICE << info->stepping); + ioaddr->status_addr = cmd + (ATA_REG_STATUS << info->stepping); + ioaddr->command_addr = cmd + (ATA_REG_CMD << info->stepping); + + ioaddr->ctl_addr = base + info->ctrloffset; ioaddr->altstatus_addr = ioaddr->ctl_addr; ata_port_desc(ap, "cmd 0x%lx ctl 0x%lx", - info->raw_base + port->dataoffset, - info->raw_base + port->ctrloffset); + info->raw_base + info->dataoffset, + info->raw_base + info->ctrloffset); if (info->raw_ioc_base) ata_port_desc(ap, "iocbase 0x%lx", info->raw_ioc_base); @@ -443,7 +441,7 @@ static int __devinit pata_icside_register_v5(struct pata_icside_info *info) info->nr_ports = 1; info->port[0] = &pata_icside_portinfo_v5; - info->raw_base = ecard_resource_start(info->ec, ECARD_RES_MEMC); + info->raw_base = ecard_resource_start(ec, ECARD_RES_MEMC); return 0; } @@ -524,7 +522,7 @@ static int __devinit pata_icside_add_ports(struct pata_icside_info *info) ap->flags |= ATA_FLAG_SLAVE_POSS; ap->ops = &pata_icside_port_ops; - pata_icside_setup_ioaddr(ap, info->base, info, info->port[i]); + pata_icside_setup_ioaddr(ap, info->base, info->port[i]); } return ata_host_activate(host, ec->irq, ata_interrupt, 0, diff --git a/trunk/drivers/ata/pata_ns87415.c b/trunk/drivers/ata/pata_ns87415.c index d0e2e50823b1..bb97ef583f9b 100644 --- a/trunk/drivers/ata/pata_ns87415.c +++ b/trunk/drivers/ata/pata_ns87415.c @@ -17,7 +17,7 @@ * TODO: * Test PARISC SuperIO * Get someone to test on SPARC - * Implement lazy pio/dma switching for better performance + * Implement lazy pio/dma switching for better performance * 8bit shared timing. * See if we need to kill the FIFO for ATAPI */ @@ -60,10 +60,10 @@ static void ns87415_set_mode(struct ata_port *ap, struct ata_device *adev, u8 mo u16 clocking; u8 iordy; u8 status; - + /* Timing register format is 17 - low nybble read timing with the high nybble being 16 - x for recovery time in PCI clocks */ - + ata_timing_compute(adev, adev->pio_mode, &t, T, 0); clocking = 17 - FIT(t.active, 2, 17); @@ -71,7 +71,7 @@ static void ns87415_set_mode(struct ata_port *ap, struct ata_device *adev, u8 mo /* Use the same timing for read and write bytes */ clocking |= (clocking << 8); pci_write_config_word(dev, timing, clocking); - + /* Set the IORDY enable versus DMA enable on or off properly */ pci_read_config_byte(dev, 0x42, &iordy); iordy &= ~(1 << (4 + unit)); @@ -185,7 +185,7 @@ static void ns87415_bmdma_irq_clear(struct ata_port *ap) if (!mmio) return; - iowrite8((ioread8(mmio + ATA_DMA_CMD) | ATA_DMA_INTR | ATA_DMA_ERR), + iowrite8((ioread8(mmio + ATA_DMA_CMD) | ATA_DMA_INTR | ATA_DMA_ERR), mmio + ATA_DMA_CMD); } @@ -215,8 +215,6 @@ static int ns87415_check_atapi_dma(struct ata_queued_cmd *qc) #include -#define SUPERIO_IDE_MAX_RETRIES 25 - /** * ns87560_read_buggy - workaround buggy Super I/O chip * @port: Port to read diff --git a/trunk/drivers/ata/pata_optidma.c b/trunk/drivers/ata/pata_optidma.c index f9b485a487ae..6b07b5b48532 100644 --- a/trunk/drivers/ata/pata_optidma.c +++ b/trunk/drivers/ata/pata_optidma.c @@ -449,7 +449,7 @@ static int optiplus_with_udma(struct pci_dev *pdev) /* Find function 1 */ dev1 = pci_get_device(0x1045, 0xC701, NULL); - if (dev1 == NULL) + if(dev1 == NULL) return 0; /* Rev must be >= 0x10 */ diff --git a/trunk/drivers/ata/pata_pcmcia.c b/trunk/drivers/ata/pata_pcmcia.c index fd36099428a4..5db2013230b3 100644 --- a/trunk/drivers/ata/pata_pcmcia.c +++ b/trunk/drivers/ata/pata_pcmcia.c @@ -74,7 +74,8 @@ static int pcmcia_set_mode(struct ata_link *link, struct ata_device **r_failed_d return ata_do_set_mode(link, r_failed_dev); if (memcmp(master->id + ATA_ID_FW_REV, slave->id + ATA_ID_FW_REV, - ATA_ID_FW_REV_LEN + ATA_ID_PROD_LEN) == 0) { + ATA_ID_FW_REV_LEN + ATA_ID_PROD_LEN) == 0) + { /* Suspicious match, but could be two cards from the same vendor - check serial */ if (memcmp(master->id + ATA_ID_SERNO, slave->id + ATA_ID_SERNO, @@ -247,8 +248,7 @@ static int pcmcia_init_one(struct pcmcia_device *pdev) goto next_entry; io_base = pdev->io.BasePort1; ctl_base = pdev->io.BasePort1 + 0x0e; - } else - goto next_entry; + } else goto next_entry; /* If we've got this far, we're done */ break; } @@ -285,8 +285,8 @@ static int pcmcia_init_one(struct pcmcia_device *pdev) printk(KERN_WARNING DRV_NAME ": second channel not yet supported.\n"); /* - * Having done the PCMCIA plumbing the ATA side is relatively - * sane. + * Having done the PCMCIA plumbing the ATA side is relatively + * sane. */ ret = -ENOMEM; host = ata_host_alloc(&pdev->dev, 1); @@ -363,7 +363,7 @@ static struct pcmcia_device_id pcmcia_devices[] = { PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */ PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), PCMCIA_DEVICE_MANF_CARD(0x00ce, 0x0000), /* Samsung */ - PCMCIA_DEVICE_MANF_CARD(0x0319, 0x0000), /* Hitachi */ + PCMCIA_DEVICE_MANF_CARD(0x0319, 0x0000), /* Hitachi */ PCMCIA_DEVICE_MANF_CARD(0x2080, 0x0001), PCMCIA_DEVICE_MANF_CARD(0x4e01, 0x0100), /* Viking CFA */ PCMCIA_DEVICE_MANF_CARD(0x4e01, 0x0200), /* Lexar, Viking CFA */ diff --git a/trunk/drivers/ata/pata_pdc2027x.c b/trunk/drivers/ata/pata_pdc2027x.c index 2622577521a1..3d3f1558cdee 100644 --- a/trunk/drivers/ata/pata_pdc2027x.c +++ b/trunk/drivers/ata/pata_pdc2027x.c @@ -348,7 +348,7 @@ static unsigned long pdc2027x_mode_filter(struct ata_device *adev, unsigned long ata_id_c_string(pair->id, model_num, ATA_ID_PROD, ATA_ID_PROD_LEN + 1); /* If the master is a maxtor in UDMA6 then the slave should not use UDMA 6 */ - if (strstr(model_num, "Maxtor") == 0 && pair->dma_mode == XFER_UDMA_6) + if(strstr(model_num, "Maxtor") == 0 && pair->dma_mode == XFER_UDMA_6) mask &= ~ (1 << (6 + ATA_SHIFT_UDMA)); return ata_pci_default_filter(adev, mask); diff --git a/trunk/drivers/ata/pata_pdc202xx_old.c b/trunk/drivers/ata/pata_pdc202xx_old.c index bc7c2d5d8d5e..65d951618c60 100644 --- a/trunk/drivers/ata/pata_pdc202xx_old.c +++ b/trunk/drivers/ata/pata_pdc202xx_old.c @@ -351,9 +351,9 @@ static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id struct pci_dev *bridge = dev->bus->self; /* Don't grab anything behind a Promise I2O RAID */ if (bridge && bridge->vendor == PCI_VENDOR_ID_INTEL) { - if (bridge->device == PCI_DEVICE_ID_INTEL_I960) + if( bridge->device == PCI_DEVICE_ID_INTEL_I960) return -ENODEV; - if (bridge->device == PCI_DEVICE_ID_INTEL_I960RM) + if( bridge->device == PCI_DEVICE_ID_INTEL_I960RM) return -ENODEV; } } diff --git a/trunk/drivers/ata/pata_scc.c b/trunk/drivers/ata/pata_scc.c index ea2ef9fc15be..55576138faea 100644 --- a/trunk/drivers/ata/pata_scc.c +++ b/trunk/drivers/ata/pata_scc.c @@ -570,8 +570,17 @@ static unsigned int scc_bus_softreset(struct ata_port *ap, unsigned int devmask, udelay(20); out_be32(ioaddr->ctl_addr, ap->ctl); - /* wait a while before checking status */ - ata_wait_after_reset(ap, deadline); + /* spec mandates ">= 2ms" before checking status. + * We wait 150ms, because that was the magic delay used for + * ATAPI devices in Hale Landis's ATADRVR, for the period of time + * between when the ATA command register is written, and then + * status is checked. Because waiting for "a while" before + * checking status is fine, post SRST, we perform this magic + * delay here as well. + * + * Old drivers/ide uses the 2mS rule and then waits for ready + */ + msleep(150); /* Before we perform post reset processing we want to see if * the bus shows 0xFF because the odd clown forgets the D7 diff --git a/trunk/drivers/ata/pata_via.c b/trunk/drivers/ata/pata_via.c index a4175fbdd170..ea7a9a652e61 100644 --- a/trunk/drivers/ata/pata_via.c +++ b/trunk/drivers/ata/pata_via.c @@ -176,7 +176,7 @@ static int via_cable_detect(struct ata_port *ap) { if ((config->flags & VIA_UDMA) < VIA_UDMA_66) return ATA_CBL_PATA40; /* UDMA 66 chips have only drive side logic */ - else if ((config->flags & VIA_UDMA) < VIA_UDMA_100) + else if((config->flags & VIA_UDMA) < VIA_UDMA_100) return ATA_CBL_PATA_UNK; /* UDMA 100 or later */ pci_read_config_dword(pdev, 0x50, &ata66); diff --git a/trunk/drivers/ata/pata_winbond.c b/trunk/drivers/ata/pata_winbond.c index 311cdb3a5566..549cbbe9fd07 100644 --- a/trunk/drivers/ata/pata_winbond.c +++ b/trunk/drivers/ata/pata_winbond.c @@ -279,7 +279,7 @@ static __init int winbond_init(void) if (request_region(port, 2, "pata_winbond")) { ret = winbond_init_one(port); - if (ret <= 0) + if(ret <= 0) release_region(port, 2); else ct+= ret; } diff --git a/trunk/drivers/ata/pdc_adma.c b/trunk/drivers/ata/pdc_adma.c index bd4c2a3c88d7..199f7e150eb3 100644 --- a/trunk/drivers/ata/pdc_adma.c +++ b/trunk/drivers/ata/pdc_adma.c @@ -47,10 +47,10 @@ #define DRV_VERSION "1.0" /* macro to calculate base address for ATA regs */ -#define ADMA_ATA_REGS(base, port_no) ((base) + ((port_no) * 0x40)) +#define ADMA_ATA_REGS(base,port_no) ((base) + ((port_no) * 0x40)) /* macro to calculate base address for ADMA regs */ -#define ADMA_REGS(base, port_no) ((base) + 0x80 + ((port_no) * 0x20)) +#define ADMA_REGS(base,port_no) ((base) + 0x80 + ((port_no) * 0x20)) /* macro to obtain addresses from ata_port */ #define ADMA_PORT_REGS(ap) \ @@ -128,7 +128,7 @@ struct adma_port_priv { adma_state_t state; }; -static int adma_ata_init_one(struct pci_dev *pdev, +static int adma_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); static int adma_port_start(struct ata_port *ap); static void adma_host_stop(struct ata_host *host); @@ -340,8 +340,8 @@ static int adma_fill_sg(struct ata_queued_cmd *qc) buf[i++] = 0; /* pPKLW */ buf[i++] = 0; /* reserved */ - *(__le32 *)(buf + i) = - (pFLAGS & pEND) ? 0 : cpu_to_le32(pp->pkt_dma + i + 4); + *(__le32 *)(buf + i) + = (pFLAGS & pEND) ? 0 : cpu_to_le32(pp->pkt_dma + i + 4); i += 4; VPRINTK("PRD[%u] = (0x%lX, 0x%X)\n", i/4, @@ -617,7 +617,7 @@ static int adma_port_start(struct ata_port *ap) return -ENOMEM; /* paranoia? */ if ((pp->pkt_dma & 7) != 0) { - printk(KERN_ERR "bad alignment for pp->pkt_dma: %08x\n", + printk("bad alignment for pp->pkt_dma: %08x\n", (u32)pp->pkt_dma); return -ENOMEM; } diff --git a/trunk/drivers/ata/sata_inic162x.c b/trunk/drivers/ata/sata_inic162x.c index 323c087e8cc1..08595f34b3e8 100644 --- a/trunk/drivers/ata/sata_inic162x.c +++ b/trunk/drivers/ata/sata_inic162x.c @@ -143,7 +143,7 @@ static const int scr_map[] = { [SCR_CONTROL] = 2, }; -static void __iomem *inic_port_base(struct ata_port *ap) +static void __iomem * inic_port_base(struct ata_port *ap) { return ap->host->iomap[MMIO_BAR] + ap->port_no * PORT_SIZE; } @@ -448,7 +448,7 @@ static int inic_hardreset(struct ata_link *link, unsigned int *class, struct ata_taskfile tf; /* wait a while before checking status */ - ata_wait_after_reset(ap, deadline); + msleep(150); rc = ata_wait_ready(ap, deadline); /* link occupied, -ENODEV too is an error */ diff --git a/trunk/drivers/ata/sata_mv.c b/trunk/drivers/ata/sata_mv.c index a43f64d2775b..7f1b13e89cf7 100644 --- a/trunk/drivers/ata/sata_mv.c +++ b/trunk/drivers/ata/sata_mv.c @@ -845,7 +845,7 @@ static int __mv_stop_dma(struct ata_port *ap) pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN; } else { WARN_ON(EDMA_EN & readl(port_mmio + EDMA_CMD_OFS)); - } + } /* now properly wait for the eDMA to stop */ for (i = 1000; i > 0; i--) { @@ -883,7 +883,7 @@ static void mv_dump_mem(void __iomem *start, unsigned bytes) for (b = 0; b < bytes; ) { DPRINTK("%p: ", start + b); for (w = 0; b < bytes && w < 4; w++) { - printk("%08x ", readl(start + b)); + printk("%08x ",readl(start + b)); b += sizeof(u32); } printk("\n"); @@ -899,8 +899,8 @@ static void mv_dump_pci_cfg(struct pci_dev *pdev, unsigned bytes) for (b = 0; b < bytes; ) { DPRINTK("%02x: ", b); for (w = 0; b < bytes && w < 4; w++) { - (void) pci_read_config_dword(pdev, b, &dw); - printk("%08x ", dw); + (void) pci_read_config_dword(pdev,b,&dw); + printk("%08x ",dw); b += sizeof(u32); } printk("\n"); @@ -944,9 +944,9 @@ static void mv_dump_all_regs(void __iomem *mmio_base, int port, } for (p = start_port; p < start_port + num_ports; p++) { port_base = mv_port_base(mmio_base, p); - DPRINTK("EDMA regs (port %i):\n", p); + DPRINTK("EDMA regs (port %i):\n",p); mv_dump_mem(port_base, 0x54); - DPRINTK("SATA regs (port %i):\n", p); + DPRINTK("SATA regs (port %i):\n",p); mv_dump_mem(port_base+0x300, 0x60); } #endif @@ -1156,7 +1156,7 @@ static void mv_fill_sg(struct ata_queued_cmd *qc) last_sg->flags_size |= cpu_to_le32(EPRD_FLAG_END_OF_TBL); } -static void mv_crqb_pack_cmd(__le16 *cmdw, u8 data, u8 addr, unsigned last) +static inline void mv_crqb_pack_cmd(__le16 *cmdw, u8 data, u8 addr, unsigned last) { u16 tmp = data | (addr << CRQB_CMD_ADDR_SHIFT) | CRQB_CMD_CS | (last ? CRQB_CMD_LAST : 0); @@ -1184,7 +1184,7 @@ static void mv_qc_prep(struct ata_queued_cmd *qc) u16 flags = 0; unsigned in_index; - if (qc->tf.protocol != ATA_PROT_DMA) + if (qc->tf.protocol != ATA_PROT_DMA) return; /* Fill in command request block @@ -1276,7 +1276,7 @@ static void mv_qc_prep_iie(struct ata_queued_cmd *qc) unsigned in_index; u32 flags = 0; - if (qc->tf.protocol != ATA_PROT_DMA) + if (qc->tf.protocol != ATA_PROT_DMA) return; /* Fill in Gen IIE command request block @@ -1606,7 +1606,7 @@ static void mv_host_intr(struct ata_host *host, u32 relevant, unsigned int hc) writelfl(~hc_irq_cause, hc_mmio + HC_IRQ_CAUSE_OFS); VPRINTK("ENTER, hc%u relevant=0x%08x HC IRQ cause=0x%08x\n", - hc, relevant, hc_irq_cause); + hc,relevant,hc_irq_cause); for (port = port0; port < port0 + MV_PORTS_PER_HC; port++) { struct ata_port *ap = host->ports[port]; @@ -1983,8 +1983,9 @@ static int mv6_reset_hc(struct mv_host_priv *hpriv, void __iomem *mmio, for (i = 0; i < 1000; i++) { udelay(1); t = readl(reg); - if (PCI_MASTER_EMPTY & t) + if (PCI_MASTER_EMPTY & t) { break; + } } if (!(PCI_MASTER_EMPTY & t)) { printk(KERN_ERR DRV_NAME ": PCI master won't flush\n"); @@ -2429,7 +2430,7 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx) struct mv_host_priv *hpriv = host->private_data; u32 hp_flags = hpriv->hp_flags; - switch (board_idx) { + switch(board_idx) { case chip_5080: hpriv->ops = &mv5xxx_ops; hp_flags |= MV_HP_GEN_I; @@ -2510,8 +2511,7 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx) break; default: - dev_printk(KERN_ERR, &pdev->dev, - "BUG: invalid board index %u\n", board_idx); + printk(KERN_ERR DRV_NAME ": BUG: invalid board index %u\n", board_idx); return 1; } @@ -2668,7 +2668,7 @@ static void mv_print_info(struct ata_host *host) */ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { - static int printed_version; + static int printed_version = 0; unsigned int board_idx = (unsigned int)ent->driver_data; const struct ata_port_info *ppi[] = { &mv_port_info[board_idx], NULL }; struct ata_host *host; diff --git a/trunk/drivers/ata/sata_nv.c b/trunk/drivers/ata/sata_nv.c index 35b2df297527..240a8920d0bd 100644 --- a/trunk/drivers/ata/sata_nv.c +++ b/trunk/drivers/ata/sata_nv.c @@ -163,7 +163,7 @@ enum { NV_ADMA_STAT_STOPPED = (1 << 10), NV_ADMA_STAT_DONE = (1 << 12), NV_ADMA_STAT_ERR = NV_ADMA_STAT_CPBERR | - NV_ADMA_STAT_TIMEOUT, + NV_ADMA_STAT_TIMEOUT, /* port flags */ NV_ADMA_PORT_REGISTER_MODE = (1 << 0), @@ -228,7 +228,7 @@ struct nv_adma_cpb { u8 reserved1; /* 1 */ u8 ctl_flags; /* 2 */ /* len is length of taskfile in 64 bit words */ - u8 len; /* 3 */ + u8 len; /* 3 */ u8 tag; /* 4 */ u8 next_cpb_idx; /* 5 */ __le16 reserved2; /* 6-7 */ @@ -244,9 +244,9 @@ struct nv_adma_port_priv { dma_addr_t cpb_dma; struct nv_adma_prd *aprd; dma_addr_t aprd_dma; - void __iomem *ctl_block; - void __iomem *gen_block; - void __iomem *notifier_clear_block; + void __iomem * ctl_block; + void __iomem * gen_block; + void __iomem * notifier_clear_block; u8 flags; int last_issue_ncq; }; @@ -291,9 +291,9 @@ struct nv_swncq_port_priv { }; -#define NV_ADMA_CHECK_INTR(GCTL, PORT) ((GCTL) & (1 << (19 + (12 * (PORT))))) +#define NV_ADMA_CHECK_INTR(GCTL, PORT) ((GCTL) & ( 1 << (19 + (12 * (PORT))))) -static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); +static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); #ifdef CONFIG_PM static int nv_pci_device_resume(struct pci_dev *pdev); #endif @@ -301,8 +301,8 @@ static void nv_ck804_host_stop(struct ata_host *host); static irqreturn_t nv_generic_interrupt(int irq, void *dev_instance); static irqreturn_t nv_nf2_interrupt(int irq, void *dev_instance); static irqreturn_t nv_ck804_interrupt(int irq, void *dev_instance); -static int nv_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); -static int nv_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); +static int nv_scr_read (struct ata_port *ap, unsigned int sc_reg, u32 *val); +static int nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); static void nv_nf2_freeze(struct ata_port *ap); static void nv_nf2_thaw(struct ata_port *ap); @@ -365,9 +365,9 @@ static const struct pci_device_id nv_pci_tbl[] = { { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA2), SWNCQ }, { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA), SWNCQ }, { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA2), SWNCQ }, - { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA), GENERIC }, - { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2), GENERIC }, - { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3), GENERIC }, + { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA), SWNCQ }, + { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2), SWNCQ }, + { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3), SWNCQ }, { } /* terminate list */ }; @@ -653,12 +653,12 @@ static void nv_adma_register_mode(struct ata_port *ap) return; status = readw(mmio + NV_ADMA_STAT); - while (!(status & NV_ADMA_STAT_IDLE) && count < 20) { + while(!(status & NV_ADMA_STAT_IDLE) && count < 20) { ndelay(50); status = readw(mmio + NV_ADMA_STAT); count++; } - if (count == 20) + if(count == 20) ata_port_printk(ap, KERN_WARNING, "timeout waiting for ADMA IDLE, stat=0x%hx\n", status); @@ -668,12 +668,12 @@ static void nv_adma_register_mode(struct ata_port *ap) count = 0; status = readw(mmio + NV_ADMA_STAT); - while (!(status & NV_ADMA_STAT_LEGACY) && count < 20) { + while(!(status & NV_ADMA_STAT_LEGACY) && count < 20) { ndelay(50); status = readw(mmio + NV_ADMA_STAT); count++; } - if (count == 20) + if(count == 20) ata_port_printk(ap, KERN_WARNING, "timeout waiting for ADMA LEGACY, stat=0x%hx\n", status); @@ -697,13 +697,13 @@ static void nv_adma_mode(struct ata_port *ap) writew(tmp | NV_ADMA_CTL_GO, mmio + NV_ADMA_CTL); status = readw(mmio + NV_ADMA_STAT); - while (((status & NV_ADMA_STAT_LEGACY) || + while(((status & NV_ADMA_STAT_LEGACY) || !(status & NV_ADMA_STAT_IDLE)) && count < 20) { ndelay(50); status = readw(mmio + NV_ADMA_STAT); count++; } - if (count == 20) + if(count == 20) ata_port_printk(ap, KERN_WARNING, "timeout waiting for ADMA LEGACY clear and IDLE, stat=0x%hx\n", status); @@ -747,7 +747,8 @@ static int nv_adma_slave_config(struct scsi_device *sdev) on the port. */ adma_enable = 0; nv_adma_register_mode(ap); - } else { + } + else { bounce_limit = *ap->dev->dma_mask; segment_boundary = NV_ADMA_DMA_BOUNDARY; sg_tablesize = NV_ADMA_SGTBL_TOTAL_LEN; @@ -756,22 +757,23 @@ static int nv_adma_slave_config(struct scsi_device *sdev) pci_read_config_dword(pdev, NV_MCP_SATA_CFG_20, ¤t_reg); - if (ap->port_no == 1) + if(ap->port_no == 1) config_mask = NV_MCP_SATA_CFG_20_PORT1_EN | NV_MCP_SATA_CFG_20_PORT1_PWB_EN; else config_mask = NV_MCP_SATA_CFG_20_PORT0_EN | NV_MCP_SATA_CFG_20_PORT0_PWB_EN; - if (adma_enable) { + if(adma_enable) { new_reg = current_reg | config_mask; pp->flags &= ~NV_ADMA_ATAPI_SETUP_COMPLETE; - } else { + } + else { new_reg = current_reg & ~config_mask; pp->flags |= NV_ADMA_ATAPI_SETUP_COMPLETE; } - if (current_reg != new_reg) + if(current_reg != new_reg) pci_write_config_dword(pdev, NV_MCP_SATA_CFG_20, new_reg); blk_queue_bounce_limit(sdev->request_queue, bounce_limit); @@ -805,7 +807,7 @@ static unsigned int nv_adma_tf_to_cpb(struct ata_taskfile *tf, __le16 *cpb) { unsigned int idx = 0; - if (tf->flags & ATA_TFLAG_ISADDR) { + if(tf->flags & ATA_TFLAG_ISADDR) { if (tf->flags & ATA_TFLAG_LBA48) { cpb[idx++] = cpu_to_le16((ATA_REG_ERR << 8) | tf->hob_feature | WNB); cpb[idx++] = cpu_to_le16((ATA_REG_NSECT << 8) | tf->hob_nsect); @@ -822,12 +824,12 @@ static unsigned int nv_adma_tf_to_cpb(struct ata_taskfile *tf, __le16 *cpb) cpb[idx++] = cpu_to_le16((ATA_REG_LBAH << 8) | tf->lbah); } - if (tf->flags & ATA_TFLAG_DEVICE) + if(tf->flags & ATA_TFLAG_DEVICE) cpb[idx++] = cpu_to_le16((ATA_REG_DEVICE << 8) | tf->device); cpb[idx++] = cpu_to_le16((ATA_REG_CMD << 8) | tf->command | CMDEND); - while (idx < 12) + while(idx < 12) cpb[idx++] = cpu_to_le16(IGN); return idx; @@ -848,7 +850,7 @@ static int nv_adma_check_cpb(struct ata_port *ap, int cpb_num, int force_err) int freeze = 0; ata_ehi_clear_desc(ehi); - __ata_ehi_push_desc(ehi, "CPB resp_flags 0x%x: ", flags); + __ata_ehi_push_desc(ehi, "CPB resp_flags 0x%x: ", flags ); if (flags & NV_CPB_RESP_ATA_ERR) { ata_ehi_push_desc(ehi, "ATA error"); ehi->err_mask |= AC_ERR_DEV; @@ -877,16 +879,15 @@ static int nv_adma_check_cpb(struct ata_port *ap, int cpb_num, int force_err) struct ata_queued_cmd *qc = ata_qc_from_tag(ap, cpb_num); VPRINTK("CPB flags done, flags=0x%x\n", flags); if (likely(qc)) { - DPRINTK("Completing qc from tag %d\n", cpb_num); + DPRINTK("Completing qc from tag %d\n",cpb_num); ata_qc_complete(qc); } else { struct ata_eh_info *ehi = &ap->link.eh_info; /* Notifier bits set without a command may indicate the drive is misbehaving. Raise host state machine violation on this condition. */ - ata_port_printk(ap, KERN_ERR, - "notifier for tag %d with no cmd?\n", - cpb_num); + ata_port_printk(ap, KERN_ERR, "notifier for tag %d with no command?\n", + cpb_num); ehi->err_mask |= AC_ERR_HSM; ehi->action |= ATA_EH_SOFTRESET; ata_port_freeze(ap); @@ -951,7 +952,7 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance) if (pp->flags & NV_ADMA_PORT_REGISTER_MODE) { u8 irq_stat = readb(host->iomap[NV_MMIO_BAR] + NV_INT_STATUS_CK804) >> (NV_INT_PORT_SHIFT * i); - if (ata_tag_valid(ap->link.active_tag)) + if(ata_tag_valid(ap->link.active_tag)) /** NV_INT_DEV indication seems unreliable at times at least in ADMA mode. Force it on always when a command is active, to prevent losing interrupts. */ @@ -965,7 +966,7 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance) gen_ctl = readl(pp->gen_block + NV_ADMA_GEN_CTL); - if (!NV_ADMA_CHECK_INTR(gen_ctl, ap->port_no) && !notifier && + if( !NV_ADMA_CHECK_INTR(gen_ctl, ap->port_no) && !notifier && !notifier_error) /* Nothing to do */ continue; @@ -989,7 +990,7 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance) struct ata_eh_info *ehi = &ap->link.eh_info; ata_ehi_clear_desc(ehi); - __ata_ehi_push_desc(ehi, "ADMA status 0x%08x: ", status); + __ata_ehi_push_desc(ehi, "ADMA status 0x%08x: ", status ); if (status & NV_ADMA_STAT_TIMEOUT) { ehi->err_mask |= AC_ERR_SYSTEM; ata_ehi_push_desc(ehi, "timeout"); @@ -1013,7 +1014,7 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance) u32 check_commands; int pos, error = 0; - if (ata_tag_valid(ap->link.active_tag)) + if(ata_tag_valid(ap->link.active_tag)) check_commands = 1 << ap->link.active_tag; else check_commands = ap->link.sactive; @@ -1022,14 +1023,14 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance) while ((pos = ffs(check_commands)) && !error) { pos--; error = nv_adma_check_cpb(ap, pos, - notifier_error & (1 << pos)); - check_commands &= ~(1 << pos); + notifier_error & (1 << pos) ); + check_commands &= ~(1 << pos ); } } } } - if (notifier_clears[0] || notifier_clears[1]) { + if(notifier_clears[0] || notifier_clears[1]) { /* Note: Both notifier clear registers must be written if either is set, even if one is zero, according to NVIDIA. */ struct nv_adma_port_priv *pp = host->ports[0]->private_data; @@ -1055,14 +1056,14 @@ static void nv_adma_freeze(struct ata_port *ap) return; /* clear any outstanding CK804 notifications */ - writeb(NV_INT_ALL << (ap->port_no * NV_INT_PORT_SHIFT), + writeb( NV_INT_ALL << (ap->port_no * NV_INT_PORT_SHIFT), ap->host->iomap[NV_MMIO_BAR] + NV_INT_STATUS_CK804); /* Disable interrupt */ tmp = readw(mmio + NV_ADMA_CTL); - writew(tmp & ~(NV_ADMA_CTL_AIEN | NV_ADMA_CTL_HOTPLUG_IEN), + writew( tmp & ~(NV_ADMA_CTL_AIEN | NV_ADMA_CTL_HOTPLUG_IEN), mmio + NV_ADMA_CTL); - readw(mmio + NV_ADMA_CTL); /* flush posted write */ + readw( mmio + NV_ADMA_CTL ); /* flush posted write */ } static void nv_adma_thaw(struct ata_port *ap) @@ -1078,9 +1079,9 @@ static void nv_adma_thaw(struct ata_port *ap) /* Enable interrupt */ tmp = readw(mmio + NV_ADMA_CTL); - writew(tmp | (NV_ADMA_CTL_AIEN | NV_ADMA_CTL_HOTPLUG_IEN), + writew( tmp | (NV_ADMA_CTL_AIEN | NV_ADMA_CTL_HOTPLUG_IEN), mmio + NV_ADMA_CTL); - readw(mmio + NV_ADMA_CTL); /* flush posted write */ + readw( mmio + NV_ADMA_CTL ); /* flush posted write */ } static void nv_adma_irq_clear(struct ata_port *ap) @@ -1095,7 +1096,7 @@ static void nv_adma_irq_clear(struct ata_port *ap) } /* clear any outstanding CK804 notifications */ - writeb(NV_INT_ALL << (ap->port_no * NV_INT_PORT_SHIFT), + writeb( NV_INT_ALL << (ap->port_no * NV_INT_PORT_SHIFT), ap->host->iomap[NV_MMIO_BAR] + NV_INT_STATUS_CK804); /* clear ADMA status */ @@ -1120,7 +1121,7 @@ static void nv_adma_post_internal_cmd(struct ata_queued_cmd *qc) { struct nv_adma_port_priv *pp = qc->ap->private_data; - if (pp->flags & NV_ADMA_PORT_REGISTER_MODE) + if(pp->flags & NV_ADMA_PORT_REGISTER_MODE) ata_bmdma_post_internal_cmd(qc); } @@ -1166,7 +1167,7 @@ static int nv_adma_port_start(struct ata_port *ap) pp->cpb_dma = mem_dma; writel(mem_dma & 0xFFFFFFFF, mmio + NV_ADMA_CPB_BASE_LOW); - writel((mem_dma >> 16) >> 16, mmio + NV_ADMA_CPB_BASE_HIGH); + writel((mem_dma >> 16 ) >> 16, mmio + NV_ADMA_CPB_BASE_HIGH); mem += NV_ADMA_MAX_CPBS * NV_ADMA_CPB_SZ; mem_dma += NV_ADMA_MAX_CPBS * NV_ADMA_CPB_SZ; @@ -1190,15 +1191,15 @@ static int nv_adma_port_start(struct ata_port *ap) /* clear GO for register mode, enable interrupt */ tmp = readw(mmio + NV_ADMA_CTL); - writew((tmp & ~NV_ADMA_CTL_GO) | NV_ADMA_CTL_AIEN | - NV_ADMA_CTL_HOTPLUG_IEN, mmio + NV_ADMA_CTL); + writew( (tmp & ~NV_ADMA_CTL_GO) | NV_ADMA_CTL_AIEN | + NV_ADMA_CTL_HOTPLUG_IEN, mmio + NV_ADMA_CTL); tmp = readw(mmio + NV_ADMA_CTL); writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); - readw(mmio + NV_ADMA_CTL); /* flush posted write */ + readw( mmio + NV_ADMA_CTL ); /* flush posted write */ udelay(1); writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); - readw(mmio + NV_ADMA_CTL); /* flush posted write */ + readw( mmio + NV_ADMA_CTL ); /* flush posted write */ return 0; } @@ -1238,7 +1239,7 @@ static int nv_adma_port_resume(struct ata_port *ap) /* set CPB block location */ writel(pp->cpb_dma & 0xFFFFFFFF, mmio + NV_ADMA_CPB_BASE_LOW); - writel((pp->cpb_dma >> 16) >> 16, mmio + NV_ADMA_CPB_BASE_HIGH); + writel((pp->cpb_dma >> 16 ) >> 16, mmio + NV_ADMA_CPB_BASE_HIGH); /* clear any outstanding interrupt conditions */ writew(0xffff, mmio + NV_ADMA_STAT); @@ -1251,15 +1252,15 @@ static int nv_adma_port_resume(struct ata_port *ap) /* clear GO for register mode, enable interrupt */ tmp = readw(mmio + NV_ADMA_CTL); - writew((tmp & ~NV_ADMA_CTL_GO) | NV_ADMA_CTL_AIEN | - NV_ADMA_CTL_HOTPLUG_IEN, mmio + NV_ADMA_CTL); + writew( (tmp & ~NV_ADMA_CTL_GO) | NV_ADMA_CTL_AIEN | + NV_ADMA_CTL_HOTPLUG_IEN, mmio + NV_ADMA_CTL); tmp = readw(mmio + NV_ADMA_CTL); writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); - readw(mmio + NV_ADMA_CTL); /* flush posted write */ + readw( mmio + NV_ADMA_CTL ); /* flush posted write */ udelay(1); writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); - readw(mmio + NV_ADMA_CTL); /* flush posted write */ + readw( mmio + NV_ADMA_CTL ); /* flush posted write */ return 0; } @@ -1343,8 +1344,7 @@ static void nv_adma_fill_sg(struct ata_queued_cmd *qc, struct nv_adma_cpb *cpb) idx = 0; ata_for_each_sg(sg, qc) { - aprd = (idx < 5) ? &cpb->aprd[idx] : - &pp->aprd[NV_ADMA_SGTBL_LEN * qc->tag + (idx-5)]; + aprd = (idx < 5) ? &cpb->aprd[idx] : &pp->aprd[NV_ADMA_SGTBL_LEN * qc->tag + (idx-5)]; nv_adma_fill_aprd(qc, sg, idx, aprd); idx++; } @@ -1361,12 +1361,12 @@ static int nv_adma_use_reg_mode(struct ata_queued_cmd *qc) /* ADMA engine can only be used for non-ATAPI DMA commands, or interrupt-driven no-data commands, where a result taskfile is not required. */ - if ((pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) || + if((pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) || (qc->tf.flags & ATA_TFLAG_POLLING) || (qc->flags & ATA_QCFLAG_RESULT_TF)) return 1; - if ((qc->flags & ATA_QCFLAG_DMAMAP) || + if((qc->flags & ATA_QCFLAG_DMAMAP) || (qc->tf.protocol == ATA_PROT_NODATA)) return 0; @@ -1403,14 +1403,14 @@ static void nv_adma_qc_prep(struct ata_queued_cmd *qc) nv_adma_tf_to_cpb(&qc->tf, cpb->tf); - if (qc->flags & ATA_QCFLAG_DMAMAP) { + if(qc->flags & ATA_QCFLAG_DMAMAP) { nv_adma_fill_sg(qc, cpb); ctl_flags |= NV_CPB_CTL_APRD_VALID; } else memset(&cpb->aprd[0], 0, sizeof(struct nv_adma_prd) * 5); - /* Be paranoid and don't let the device see NV_CPB_CTL_CPB_VALID - until we are finished filling in all of the contents */ + /* Be paranoid and don't let the device see NV_CPB_CTL_CPB_VALID until we are + finished filling in all of the contents */ wmb(); cpb->ctl_flags = ctl_flags; wmb(); @@ -1437,16 +1437,16 @@ static unsigned int nv_adma_qc_issue(struct ata_queued_cmd *qc) and (number of cpbs to append -1) in top 8 bits */ wmb(); - if (curr_ncq != pp->last_issue_ncq) { - /* Seems to need some delay before switching between NCQ and - non-NCQ commands, else we get command timeouts and such. */ + if(curr_ncq != pp->last_issue_ncq) { + /* Seems to need some delay before switching between NCQ and non-NCQ + commands, else we get command timeouts and such. */ udelay(20); pp->last_issue_ncq = curr_ncq; } writew(qc->tag, mmio + NV_ADMA_APPEND); - DPRINTK("Issued tag %u\n", qc->tag); + DPRINTK("Issued tag %u\n",qc->tag); return 0; } @@ -1643,12 +1643,12 @@ static void nv_error_handler(struct ata_port *ap) static void nv_adma_error_handler(struct ata_port *ap) { struct nv_adma_port_priv *pp = ap->private_data; - if (!(pp->flags & NV_ADMA_PORT_REGISTER_MODE)) { + if(!(pp->flags & NV_ADMA_PORT_REGISTER_MODE)) { void __iomem *mmio = pp->ctl_block; int i; u16 tmp; - if (ata_tag_valid(ap->link.active_tag) || ap->link.sactive) { + if(ata_tag_valid(ap->link.active_tag) || ap->link.sactive) { u32 notifier = readl(mmio + NV_ADMA_NOTIFIER); u32 notifier_error = readl(mmio + NV_ADMA_NOTIFIER_ERROR); u32 gen_ctl = readl(pp->gen_block + NV_ADMA_GEN_CTL); @@ -1656,17 +1656,16 @@ static void nv_adma_error_handler(struct ata_port *ap) u8 cpb_count = readb(mmio + NV_ADMA_CPB_COUNT); u8 next_cpb_idx = readb(mmio + NV_ADMA_NEXT_CPB_IDX); - ata_port_printk(ap, KERN_ERR, - "EH in ADMA mode, notifier 0x%X " + ata_port_printk(ap, KERN_ERR, "EH in ADMA mode, notifier 0x%X " "notifier_error 0x%X gen_ctl 0x%X status 0x%X " "next cpb count 0x%X next cpb idx 0x%x\n", notifier, notifier_error, gen_ctl, status, cpb_count, next_cpb_idx); - for (i = 0; i < NV_ADMA_MAX_CPBS; i++) { + for( i=0;icpb[i]; - if ((ata_tag_valid(ap->link.active_tag) && i == ap->link.active_tag) || - ap->link.sactive & (1 << i)) + if( (ata_tag_valid(ap->link.active_tag) && i == ap->link.active_tag) || + ap->link.sactive & (1 << i) ) ata_port_printk(ap, KERN_ERR, "CPB %d: ctl_flags 0x%x, resp_flags 0x%x\n", i, cpb->ctl_flags, cpb->resp_flags); @@ -1676,9 +1675,8 @@ static void nv_adma_error_handler(struct ata_port *ap) /* Push us back into port register mode for error handling. */ nv_adma_register_mode(ap); - /* Mark all of the CPBs as invalid to prevent them from - being executed */ - for (i = 0; i < NV_ADMA_MAX_CPBS; i++) + /* Mark all of the CPBs as invalid to prevent them from being executed */ + for( i=0;icpb[i].ctl_flags &= ~NV_CPB_CTL_CPB_VALID; /* clear CPB fetch count */ @@ -1687,10 +1685,10 @@ static void nv_adma_error_handler(struct ata_port *ap) /* Reset channel */ tmp = readw(mmio + NV_ADMA_CTL); writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); - readw(mmio + NV_ADMA_CTL); /* flush posted write */ + readw( mmio + NV_ADMA_CTL ); /* flush posted write */ udelay(1); writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); - readw(mmio + NV_ADMA_CTL); /* flush posted write */ + readw( mmio + NV_ADMA_CTL ); /* flush posted write */ } ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, @@ -2354,9 +2352,9 @@ static irqreturn_t nv_swncq_interrupt(int irq, void *dev_instance) return IRQ_RETVAL(handled); } -static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) +static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { - static int printed_version; + static int printed_version = 0; const struct ata_port_info *ppi[] = { NULL, NULL }; struct ata_host *host; struct nv_host_priv *hpriv; @@ -2368,7 +2366,7 @@ static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) // Make sure this is a SATA controller by counting the number of bars // (NVIDIA SATA controllers will always have six bars). Otherwise, // it's an IDE controller and we ignore it. - for (bar = 0; bar < 6; bar++) + for (bar=0; bar<6; bar++) if (pci_resource_start(pdev, bar) == 0) return -ENODEV; @@ -2385,14 +2383,6 @@ static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) type = ADMA; } - if (type == SWNCQ) { - if (swncq_enabled) - dev_printk(KERN_NOTICE, &pdev->dev, - "Using SWNCQ mode\n"); - else - type = GENERIC; - } - ppi[0] = &nv_port_info[type]; rc = ata_pci_prepare_sff_host(pdev, ppi, &host); if (rc) @@ -2434,8 +2424,10 @@ static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) rc = nv_adma_host_init(host); if (rc) return rc; - } else if (type == SWNCQ) + } else if (type == SWNCQ && swncq_enabled) { + dev_printk(KERN_NOTICE, &pdev->dev, "Using SWNCQ mode\n"); nv_swncq_host_init(host); + } pci_set_master(pdev); return ata_host_activate(host, pdev->irq, ppi[0]->irq_handler, @@ -2450,37 +2442,37 @@ static int nv_pci_device_resume(struct pci_dev *pdev) int rc; rc = ata_pci_device_do_resume(pdev); - if (rc) + if(rc) return rc; if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) { - if (hpriv->type >= CK804) { + if(hpriv->type >= CK804) { u8 regval; pci_read_config_byte(pdev, NV_MCP_SATA_CFG_20, ®val); regval |= NV_MCP_SATA_CFG_20_SATA_SPACE_EN; pci_write_config_byte(pdev, NV_MCP_SATA_CFG_20, regval); } - if (hpriv->type == ADMA) { + if(hpriv->type == ADMA) { u32 tmp32; struct nv_adma_port_priv *pp; /* enable/disable ADMA on the ports appropriately */ pci_read_config_dword(pdev, NV_MCP_SATA_CFG_20, &tmp32); pp = host->ports[0]->private_data; - if (pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) + if(pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) tmp32 &= ~(NV_MCP_SATA_CFG_20_PORT0_EN | - NV_MCP_SATA_CFG_20_PORT0_PWB_EN); + NV_MCP_SATA_CFG_20_PORT0_PWB_EN); else tmp32 |= (NV_MCP_SATA_CFG_20_PORT0_EN | - NV_MCP_SATA_CFG_20_PORT0_PWB_EN); + NV_MCP_SATA_CFG_20_PORT0_PWB_EN); pp = host->ports[1]->private_data; - if (pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) + if(pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE) tmp32 &= ~(NV_MCP_SATA_CFG_20_PORT1_EN | - NV_MCP_SATA_CFG_20_PORT1_PWB_EN); + NV_MCP_SATA_CFG_20_PORT1_PWB_EN); else tmp32 |= (NV_MCP_SATA_CFG_20_PORT1_EN | - NV_MCP_SATA_CFG_20_PORT1_PWB_EN); + NV_MCP_SATA_CFG_20_PORT1_PWB_EN); pci_write_config_dword(pdev, NV_MCP_SATA_CFG_20, tmp32); } diff --git a/trunk/drivers/ata/sata_promise.c b/trunk/drivers/ata/sata_promise.c index 825e717bcef9..903213153b5d 100644 --- a/trunk/drivers/ata/sata_promise.c +++ b/trunk/drivers/ata/sata_promise.c @@ -2,7 +2,6 @@ * sata_promise.c - Promise SATA * * Maintained by: Jeff Garzik - * Mikael Pettersson * Please ALWAYS copy linux-ide@vger.kernel.org * on emails. * @@ -46,12 +45,11 @@ #include "sata_promise.h" #define DRV_NAME "sata_promise" -#define DRV_VERSION "2.11" +#define DRV_VERSION "2.10" enum { PDC_MAX_PORTS = 4, PDC_MMIO_BAR = 3, - PDC_MAX_PRD = LIBATA_MAX_PRD - 1, /* -1 for ASIC PRD bug workaround */ /* register offsets */ PDC_FEATURE = 0x04, /* Feature/Error reg (per port) */ @@ -85,12 +83,10 @@ enum { PDC_PCI_SYS_ERR = (1 << 22), /* PCI system error */ PDC1_PCI_PARITY_ERR = (1 << 23), /* PCI parity error (from SATA150 driver) */ PDC1_ERR_MASK = PDC1_PCI_PARITY_ERR, - PDC2_ERR_MASK = PDC2_HTO_ERR | PDC2_ATA_HBA_ERR | - PDC2_ATA_DMA_CNT_ERR, - PDC_ERR_MASK = PDC_PH_ERR | PDC_SH_ERR | PDC_DH_ERR | - PDC_OVERRUN_ERR | PDC_UNDERRUN_ERR | - PDC_DRIVE_ERR | PDC_PCI_SYS_ERR | - PDC1_ERR_MASK | PDC2_ERR_MASK, + PDC2_ERR_MASK = PDC2_HTO_ERR | PDC2_ATA_HBA_ERR | PDC2_ATA_DMA_CNT_ERR, + PDC_ERR_MASK = (PDC_PH_ERR | PDC_SH_ERR | PDC_DH_ERR | PDC_OVERRUN_ERR + | PDC_UNDERRUN_ERR | PDC_DRIVE_ERR | PDC_PCI_SYS_ERR + | PDC1_ERR_MASK | PDC2_ERR_MASK), board_2037x = 0, /* FastTrak S150 TX2plus */ board_2037x_pata = 1, /* FastTrak S150 TX2plus PATA port */ @@ -159,7 +155,7 @@ static struct scsi_host_template pdc_ata_sht = { .queuecommand = ata_scsi_queuecmd, .can_queue = ATA_DEF_QUEUE, .this_id = ATA_SHT_THIS_ID, - .sg_tablesize = PDC_MAX_PRD, + .sg_tablesize = LIBATA_MAX_PRD, .cmd_per_lun = ATA_SHT_CMD_PER_LUN, .emulated = ATA_SHT_EMULATED, .use_clustering = ATA_SHT_USE_CLUSTERING, @@ -242,7 +238,7 @@ static const struct ata_port_operations pdc_pata_ops = { }; static const struct ata_port_info pdc_port_info[] = { - [board_2037x] = + /* board_2037x */ { .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA | PDC_FLAG_SATA_PATA, @@ -252,7 +248,7 @@ static const struct ata_port_info pdc_port_info[] = { .port_ops = &pdc_old_sata_ops, }, - [board_2037x_pata] = + /* board_2037x_pata */ { .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS, .pio_mask = 0x1f, /* pio0-4 */ @@ -261,7 +257,7 @@ static const struct ata_port_info pdc_port_info[] = { .port_ops = &pdc_pata_ops, }, - [board_20319] = + /* board_20319 */ { .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA | PDC_FLAG_4_PORTS, @@ -271,7 +267,7 @@ static const struct ata_port_info pdc_port_info[] = { .port_ops = &pdc_old_sata_ops, }, - [board_20619] = + /* board_20619 */ { .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS | PDC_FLAG_4_PORTS, @@ -281,7 +277,7 @@ static const struct ata_port_info pdc_port_info[] = { .port_ops = &pdc_pata_ops, }, - [board_2057x] = + /* board_2057x */ { .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA | PDC_FLAG_GEN_II | PDC_FLAG_SATA_PATA, @@ -291,7 +287,7 @@ static const struct ata_port_info pdc_port_info[] = { .port_ops = &pdc_sata_ops, }, - [board_2057x_pata] = + /* board_2057x_pata */ { .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS | PDC_FLAG_GEN_II, @@ -301,7 +297,7 @@ static const struct ata_port_info pdc_port_info[] = { .port_ops = &pdc_pata_ops, }, - [board_40518] = + /* board_40518 */ { .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA | PDC_FLAG_GEN_II | PDC_FLAG_4_PORTS, @@ -525,84 +521,6 @@ static void pdc_atapi_pkt(struct ata_queued_cmd *qc) memcpy(buf+31, cdb, cdb_len); } -/** - * pdc_fill_sg - Fill PCI IDE PRD table - * @qc: Metadata associated with taskfile to be transferred - * - * Fill PCI IDE PRD (scatter-gather) table with segments - * associated with the current disk command. - * Make sure hardware does not choke on it. - * - * LOCKING: - * spin_lock_irqsave(host lock) - * - */ -static void pdc_fill_sg(struct ata_queued_cmd *qc) -{ - struct ata_port *ap = qc->ap; - struct scatterlist *sg; - unsigned int idx; - const u32 SG_COUNT_ASIC_BUG = 41*4; - - if (!(qc->flags & ATA_QCFLAG_DMAMAP)) - return; - - WARN_ON(qc->__sg == NULL); - WARN_ON(qc->n_elem == 0 && qc->pad_len == 0); - - idx = 0; - ata_for_each_sg(sg, qc) { - u32 addr, offset; - u32 sg_len, len; - - /* determine if physical DMA addr spans 64K boundary. - * Note h/w doesn't support 64-bit, so we unconditionally - * truncate dma_addr_t to u32. - */ - addr = (u32) sg_dma_address(sg); - sg_len = sg_dma_len(sg); - - while (sg_len) { - offset = addr & 0xffff; - len = sg_len; - if ((offset + sg_len) > 0x10000) - len = 0x10000 - offset; - - ap->prd[idx].addr = cpu_to_le32(addr); - ap->prd[idx].flags_len = cpu_to_le32(len & 0xffff); - VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", idx, addr, len); - - idx++; - sg_len -= len; - addr += len; - } - } - - if (idx) { - u32 len = le32_to_cpu(ap->prd[idx - 1].flags_len); - - if (len > SG_COUNT_ASIC_BUG) { - u32 addr; - - VPRINTK("Splitting last PRD.\n"); - - addr = le32_to_cpu(ap->prd[idx - 1].addr); - ap->prd[idx - 1].flags_len -= cpu_to_le32(SG_COUNT_ASIC_BUG); - VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", idx - 1, addr, SG_COUNT_ASIC_BUG); - - addr = addr + len - SG_COUNT_ASIC_BUG; - len = SG_COUNT_ASIC_BUG; - ap->prd[idx].addr = cpu_to_le32(addr); - ap->prd[idx].flags_len = cpu_to_le32(len); - VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", idx, addr, len); - - idx++; - } - - ap->prd[idx - 1].flags_len |= cpu_to_le32(ATA_PRD_EOT); - } -} - static void pdc_qc_prep(struct ata_queued_cmd *qc) { struct pdc_port_priv *pp = qc->ap->private_data; @@ -612,7 +530,7 @@ static void pdc_qc_prep(struct ata_queued_cmd *qc) switch (qc->tf.protocol) { case ATA_PROT_DMA: - pdc_fill_sg(qc); + ata_qc_prep(qc); /* fall through */ case ATA_PROT_NODATA: @@ -628,11 +546,11 @@ static void pdc_qc_prep(struct ata_queued_cmd *qc) break; case ATA_PROT_ATAPI: - pdc_fill_sg(qc); + ata_qc_prep(qc); break; case ATA_PROT_ATAPI_DMA: - pdc_fill_sg(qc); + ata_qc_prep(qc); /*FALLTHROUGH*/ case ATA_PROT_ATAPI_NODATA: pdc_atapi_pkt(qc); @@ -777,20 +695,19 @@ static void pdc_irq_clear(struct ata_port *ap) readl(mmio + PDC_INT_SEQMASK); } -static int pdc_is_sataii_tx4(unsigned long flags) +static inline int pdc_is_sataii_tx4(unsigned long flags) { const unsigned long mask = PDC_FLAG_GEN_II | PDC_FLAG_4_PORTS; return (flags & mask) == mask; } -static unsigned int pdc_port_no_to_ata_no(unsigned int port_no, - int is_sataii_tx4) +static inline unsigned int pdc_port_no_to_ata_no(unsigned int port_no, int is_sataii_tx4) { static const unsigned char sataii_tx4_port_remap[4] = { 3, 1, 0, 2}; return is_sataii_tx4 ? sataii_tx4_port_remap[port_no] : port_no; } -static irqreturn_t pdc_interrupt(int irq, void *dev_instance) +static irqreturn_t pdc_interrupt (int irq, void *dev_instance) { struct ata_host *host = dev_instance; struct ata_port *ap; @@ -922,16 +839,15 @@ static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc) static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf) { - WARN_ON(tf->protocol == ATA_PROT_DMA || - tf->protocol == ATA_PROT_ATAPI_DMA); + WARN_ON (tf->protocol == ATA_PROT_DMA || + tf->protocol == ATA_PROT_ATAPI_DMA); ata_tf_load(ap, tf); } -static void pdc_exec_command_mmio(struct ata_port *ap, - const struct ata_taskfile *tf) +static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf) { - WARN_ON(tf->protocol == ATA_PROT_DMA || - tf->protocol == ATA_PROT_ATAPI_DMA); + WARN_ON (tf->protocol == ATA_PROT_DMA || + tf->protocol == ATA_PROT_ATAPI_DMA); ata_exec_command(ap, tf); } @@ -954,11 +870,8 @@ static int pdc_check_atapi_dma(struct ata_queued_cmd *qc) } /* -45150 (FFFF4FA2) to -1 (FFFFFFFF) shall use PIO mode */ if (scsicmd[0] == WRITE_10) { - unsigned int lba = - (scsicmd[2] << 24) | - (scsicmd[3] << 16) | - (scsicmd[4] << 8) | - scsicmd[5]; + unsigned int lba; + lba = (scsicmd[2] << 24) | (scsicmd[3] << 16) | (scsicmd[4] << 8) | scsicmd[5]; if (lba >= 0xFFFF4FA2) pio = 1; } @@ -1043,8 +956,7 @@ static void pdc_host_init(struct ata_host *host) writel(tmp, mmio + PDC_SLEW_CTL); } -static int pdc_ata_init_one(struct pci_dev *pdev, - const struct pci_device_id *ent) +static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; const struct ata_port_info *pi = &pdc_port_info[ent->driver_data]; diff --git a/trunk/drivers/ata/sata_qstor.c b/trunk/drivers/ata/sata_qstor.c index 6d43ba79e154..c4c4cd29eebb 100644 --- a/trunk/drivers/ata/sata_qstor.c +++ b/trunk/drivers/ata/sata_qstor.c @@ -113,7 +113,7 @@ struct qs_port_priv { static int qs_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); static int qs_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); -static int qs_ata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); +static int qs_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); static int qs_port_start(struct ata_port *ap); static void qs_host_stop(struct ata_host *host); static void qs_phy_reset(struct ata_port *ap); @@ -135,6 +135,7 @@ static struct scsi_host_template qs_ata_sht = { .sg_tablesize = QS_MAX_PRD, .cmd_per_lun = ATA_SHT_CMD_PER_LUN, .emulated = ATA_SHT_EMULATED, + //FIXME .use_clustering = ATA_SHT_USE_CLUSTERING, .use_clustering = ENABLE_CLUSTERING, .proc_name = DRV_NAME, .dma_boundary = QS_DMA_BOUNDARY, diff --git a/trunk/drivers/ata/sata_sil.c b/trunk/drivers/ata/sata_sil.c index 4e6e381279cc..ea3a0ab7e027 100644 --- a/trunk/drivers/ata/sata_sil.c +++ b/trunk/drivers/ata/sata_sil.c @@ -111,7 +111,7 @@ enum { SIL_QUIRK_UDMA5MAX = (1 << 1), }; -static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); +static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); #ifdef CONFIG_PM static int sil_pci_device_resume(struct pci_dev *pdev); #endif @@ -138,7 +138,7 @@ static const struct pci_device_id sil_pci_tbl[] = { /* TODO firmware versions should be added - eric */ static const struct sil_drivelist { - const char *product; + const char * product; unsigned int quirk; } sil_blacklist [] = { { "ST320012AS", SIL_QUIRK_MOD15WRITE }, @@ -279,7 +279,7 @@ MODULE_LICENSE("GPL"); MODULE_DEVICE_TABLE(pci, sil_pci_tbl); MODULE_VERSION(DRV_VERSION); -static int slow_down; +static int slow_down = 0; module_param(slow_down, int, 0444); MODULE_PARM_DESC(slow_down, "Sledgehammer used to work around random problems, by limiting commands to 15 sectors (0=off, 1=on)"); @@ -332,8 +332,7 @@ static int sil_set_mode(struct ata_link *link, struct ata_device **r_failed) return 0; } -static inline void __iomem *sil_scr_addr(struct ata_port *ap, - unsigned int sc_reg) +static inline void __iomem *sil_scr_addr(struct ata_port *ap, unsigned int sc_reg) { void __iomem *offset = ap->ioaddr.scr_addr; @@ -644,7 +643,7 @@ static void sil_init_controller(struct ata_host *host) } } -static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) +static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; int board_id = ent->driver_data; diff --git a/trunk/drivers/ata/sata_sil24.c b/trunk/drivers/ata/sata_sil24.c index 187dcb02c681..26ebffc10f3e 100644 --- a/trunk/drivers/ata/sata_sil24.c +++ b/trunk/drivers/ata/sata_sil24.c @@ -265,11 +265,11 @@ static struct sil24_cerr_info { unsigned int err_mask, action; const char *desc; } sil24_cerr_db[] = { - [0] = { AC_ERR_DEV, 0, + [0] = { AC_ERR_DEV, ATA_EH_REVALIDATE, "device error" }, - [PORT_CERR_DEV] = { AC_ERR_DEV, 0, + [PORT_CERR_DEV] = { AC_ERR_DEV, ATA_EH_REVALIDATE, "device error via D2H FIS" }, - [PORT_CERR_SDB] = { AC_ERR_DEV, 0, + [PORT_CERR_SDB] = { AC_ERR_DEV, ATA_EH_REVALIDATE, "device error via SDB FIS" }, [PORT_CERR_DATA] = { AC_ERR_ATA_BUS, ATA_EH_SOFTRESET, "error in data FIS" }, @@ -674,7 +674,7 @@ static int sil24_do_softreset(struct ata_link *link, unsigned int *class, /* put the port into known state */ if (sil24_init_port(ap)) { - reason = "port not ready"; + reason ="port not ready"; goto err; } @@ -756,8 +756,7 @@ static int sil24_hardreset(struct ata_link *link, unsigned int *class, writel(PORT_CS_DEV_RST, port + PORT_CTRL_STAT); tmp = ata_wait_register(port + PORT_CTRL_STAT, - PORT_CS_DEV_RST, PORT_CS_DEV_RST, 10, - tout_msec); + PORT_CS_DEV_RST, PORT_CS_DEV_RST, 10, tout_msec); /* SStatus oscillates between zero and valid status after * DEV_RST, debounce it. @@ -1271,7 +1270,7 @@ static void sil24_init_controller(struct ata_host *host) PORT_CS_PORT_RST, 10, 100); if (tmp & PORT_CS_PORT_RST) dev_printk(KERN_ERR, host->dev, - "failed to clear port RST\n"); + "failed to clear port RST\n"); } /* configure port */ @@ -1284,7 +1283,7 @@ static void sil24_init_controller(struct ata_host *host) static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { - static int printed_version; + static int printed_version = 0; struct ata_port_info pi = sil24_port_info[ent->driver_data]; const struct ata_port_info *ppi[] = { &pi, NULL }; void __iomem * const *iomap; diff --git a/trunk/drivers/ata/sata_sis.c b/trunk/drivers/ata/sata_sis.c index a01260a56432..f147dc7bf464 100644 --- a/trunk/drivers/ata/sata_sis.c +++ b/trunk/drivers/ata/sata_sis.c @@ -63,17 +63,17 @@ enum { GENCTL_IOMAPPED_SCR = (1 << 26), /* if set, SCRs are in IO space */ }; -static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); -static int sis_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); -static int sis_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); +static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); +static int sis_scr_read (struct ata_port *ap, unsigned int sc_reg, u32 *val); +static int sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); static const struct pci_device_id sis_pci_tbl[] = { - { PCI_VDEVICE(SI, 0x0180), sis_180 }, /* SiS 964/180 */ - { PCI_VDEVICE(SI, 0x0181), sis_180 }, /* SiS 964/180 */ - { PCI_VDEVICE(SI, 0x0182), sis_180 }, /* SiS 965/965L */ - { PCI_VDEVICE(SI, 0x0183), sis_180 }, /* SiS 965/965L */ - { PCI_VDEVICE(SI, 0x1182), sis_180 }, /* SiS 966/680 */ - { PCI_VDEVICE(SI, 0x1183), sis_180 }, /* SiS 966/966L/968/680 */ + { PCI_VDEVICE(SI, 0x0180), sis_180 }, /* SiS 964/180 */ + { PCI_VDEVICE(SI, 0x0181), sis_180 }, /* SiS 964/180 */ + { PCI_VDEVICE(SI, 0x0182), sis_180 }, /* SiS 965/965L */ + { PCI_VDEVICE(SI, 0x0183), sis_180 }, /* SiS 965/965L */ + { PCI_VDEVICE(SI, 0x1182), sis_180 }, /* SiS 966/680 */ + { PCI_VDEVICE(SI, 0x1183), sis_180 }, /* SiS 966/966L/968/680 */ { } /* terminate list */ }; @@ -149,24 +149,24 @@ static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg) if (ap->port_no) { switch (pdev->device) { - case 0x0180: - case 0x0181: - pci_read_config_byte(pdev, SIS_PMR, &pmr); - if ((pmr & SIS_PMR_COMBINED) == 0) - addr += SIS180_SATA1_OFS; - break; - - case 0x0182: - case 0x0183: - case 0x1182: - addr += SIS182_SATA1_OFS; - break; + case 0x0180: + case 0x0181: + pci_read_config_byte(pdev, SIS_PMR, &pmr); + if ((pmr & SIS_PMR_COMBINED) == 0) + addr += SIS180_SATA1_OFS; + break; + + case 0x0182: + case 0x0183: + case 0x1182: + addr += SIS182_SATA1_OFS; + break; } } return addr; } -static u32 sis_scr_cfg_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) +static u32 sis_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg, u32 *val) { struct pci_dev *pdev = to_pci_dev(ap->host->dev); unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg); @@ -190,7 +190,7 @@ static u32 sis_scr_cfg_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) return 0; } -static void sis_scr_cfg_write(struct ata_port *ap, unsigned int sc_reg, u32 val) +static void sis_scr_cfg_write (struct ata_port *ap, unsigned int sc_reg, u32 val) { struct pci_dev *pdev = to_pci_dev(ap->host->dev); unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg); @@ -253,7 +253,7 @@ static int sis_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) return 0; } -static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) +static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; struct ata_port_info pi = sis_port_info; @@ -309,33 +309,29 @@ static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) } else { dev_printk(KERN_INFO, &pdev->dev, "Detected SiS 180/181 chipset in combined mode\n"); - port2_start = 0; + port2_start=0; pi.flags |= ATA_FLAG_SLAVE_POSS; } break; case 0x0182: case 0x0183: - pci_read_config_dword(pdev, 0x6C, &val); + pci_read_config_dword ( pdev, 0x6C, &val); if (val & (1L << 31)) { - dev_printk(KERN_INFO, &pdev->dev, - "Detected SiS 182/965 chipset\n"); + dev_printk(KERN_INFO, &pdev->dev, "Detected SiS 182/965 chipset\n"); pi.flags |= ATA_FLAG_SLAVE_POSS; } else { - dev_printk(KERN_INFO, &pdev->dev, - "Detected SiS 182/965L chipset\n"); + dev_printk(KERN_INFO, &pdev->dev, "Detected SiS 182/965L chipset\n"); } break; case 0x1182: - dev_printk(KERN_INFO, &pdev->dev, - "Detected SiS 1182/966/680 SATA controller\n"); + dev_printk(KERN_INFO, &pdev->dev, "Detected SiS 1182/966/680 SATA controller\n"); pi.flags |= ATA_FLAG_SLAVE_POSS; break; case 0x1183: - dev_printk(KERN_INFO, &pdev->dev, - "Detected SiS 1183/966/966L/968/680 controller in PATA mode\n"); + dev_printk(KERN_INFO, &pdev->dev, "Detected SiS 1183/966/966L/968/680 controller in PATA mode\n"); ppi[0] = &sis_info133_for_sata; ppi[1] = &sis_info133_for_sata; break; diff --git a/trunk/drivers/ata/sata_svw.c b/trunk/drivers/ata/sata_svw.c index 69f651e0bc98..12d613c48c19 100644 --- a/trunk/drivers/ata/sata_svw.c +++ b/trunk/drivers/ata/sata_svw.c @@ -182,7 +182,7 @@ static void k2_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) tf->hob_lbal = lbal >> 8; tf->hob_lbam = lbam >> 8; tf->hob_lbah = lbah >> 8; - } + } } /** @@ -193,7 +193,7 @@ static void k2_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) * spin_lock_irqsave(host lock) */ -static void k2_bmdma_setup_mmio(struct ata_queued_cmd *qc) +static void k2_bmdma_setup_mmio (struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE); @@ -224,7 +224,7 @@ static void k2_bmdma_setup_mmio(struct ata_queued_cmd *qc) * spin_lock_irqsave(host lock) */ -static void k2_bmdma_start_mmio(struct ata_queued_cmd *qc) +static void k2_bmdma_start_mmio (struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; void __iomem *mmio = ap->ioaddr.bmdma_addr; @@ -255,7 +255,7 @@ static void k2_bmdma_start_mmio(struct ata_queued_cmd *qc) static u8 k2_stat_check_status(struct ata_port *ap) { - return readl(ap->ioaddr.status_addr); + return readl(ap->ioaddr.status_addr); } #ifdef CONFIG_PPC_OF @@ -395,7 +395,7 @@ static void k2_sata_setup_port(struct ata_ioports *port, void __iomem *base) } -static int k2_sata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) +static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; const struct ata_port_info *ppi[] = diff --git a/trunk/drivers/ata/sata_sx4.c b/trunk/drivers/ata/sata_sx4.c index 4d857185f33b..9f9f7b30654a 100644 --- a/trunk/drivers/ata/sata_sx4.c +++ b/trunk/drivers/ata/sata_sx4.c @@ -62,13 +62,13 @@ submit ATA packet to hardware hardware executes ATA WRITE command, w/ data in DIMM hardware raises interrupt - + and each READ looks like this: submit ATA packet to hardware hardware executes ATA READ command, w/ data in DIMM hardware raises interrupt - + submit HDMA packet to hardware hardware copies data from DIMM to system memory hardware raises interrupt @@ -212,9 +212,9 @@ struct pdc_host_priv { }; -static int pdc_sata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); +static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); static void pdc_eng_timeout(struct ata_port *ap); -static void pdc_20621_phy_reset(struct ata_port *ap); +static void pdc_20621_phy_reset (struct ata_port *ap); static int pdc_port_start(struct ata_port *ap); static void pdc20621_qc_prep(struct ata_queued_cmd *qc); static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); @@ -320,16 +320,16 @@ static int pdc_port_start(struct ata_port *ap) return 0; } -static void pdc_20621_phy_reset(struct ata_port *ap) +static void pdc_20621_phy_reset (struct ata_port *ap) { VPRINTK("ENTER\n"); - ap->cbl = ATA_CBL_SATA; - ata_port_probe(ap); - ata_bus_reset(ap); + ap->cbl = ATA_CBL_SATA; + ata_port_probe(ap); + ata_bus_reset(ap); } static inline void pdc20621_ata_sg(struct ata_taskfile *tf, u8 *buf, - unsigned int portno, + unsigned int portno, unsigned int total_len) { u32 addr; @@ -351,7 +351,7 @@ static inline void pdc20621_ata_sg(struct ata_taskfile *tf, u8 *buf, } static inline void pdc20621_host_sg(struct ata_taskfile *tf, u8 *buf, - unsigned int portno, + unsigned int portno, unsigned int total_len) { u32 addr; @@ -711,8 +711,8 @@ static unsigned int pdc20621_qc_issue_prot(struct ata_queued_cmd *qc) return ata_qc_issue_prot(qc); } -static inline unsigned int pdc20621_host_intr(struct ata_port *ap, - struct ata_queued_cmd *qc, +static inline unsigned int pdc20621_host_intr( struct ata_port *ap, + struct ata_queued_cmd *qc, unsigned int doing_hdma, void __iomem *mmio) { @@ -803,7 +803,7 @@ static void pdc20621_irq_clear(struct ata_port *ap) readl(mmio + PDC_20621_SEQMASK); } -static irqreturn_t pdc20621_interrupt(int irq, void *dev_instance) +static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance) { struct ata_host *host = dev_instance; struct ata_port *ap; @@ -836,9 +836,9 @@ static irqreturn_t pdc20621_interrupt(int irq, void *dev_instance) return IRQ_NONE; } - spin_lock(&host->lock); + spin_lock(&host->lock); - for (i = 1; i < 9; i++) { + for (i = 1; i < 9; i++) { port_no = i - 1; if (port_no > 3) port_no -= 4; @@ -859,7 +859,7 @@ static irqreturn_t pdc20621_interrupt(int irq, void *dev_instance) } } - spin_unlock(&host->lock); + spin_unlock(&host->lock); VPRINTK("mask == 0x%x\n", mask); @@ -906,16 +906,16 @@ static void pdc_eng_timeout(struct ata_port *ap) static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf) { - WARN_ON(tf->protocol == ATA_PROT_DMA || - tf->protocol == ATA_PROT_NODATA); + WARN_ON (tf->protocol == ATA_PROT_DMA || + tf->protocol == ATA_PROT_NODATA); ata_tf_load(ap, tf); } static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf) { - WARN_ON(tf->protocol == ATA_PROT_DMA || - tf->protocol == ATA_PROT_NODATA); + WARN_ON (tf->protocol == ATA_PROT_DMA || + tf->protocol == ATA_PROT_NODATA); ata_exec_command(ap, tf); } @@ -953,7 +953,7 @@ static void pdc20621_get_from_dimm(struct ata_host *host, void *psource, mmio += PDC_CHIP0_OFS; page_mask = 0x00; - window_size = 0x2000 * 4; /* 32K byte uchar size */ + window_size = 0x2000 * 4; /* 32K byte uchar size */ idx = (u16) (offset / window_size); writel(0x01, mmio + PDC_GENERAL_CTLR); @@ -979,7 +979,7 @@ static void pdc20621_get_from_dimm(struct ata_host *host, void *psource, window_size / 4); psource += window_size; size -= window_size; - idx++; + idx ++; } if (size) { @@ -1008,7 +1008,7 @@ static void pdc20621_put_to_dimm(struct ata_host *host, void *psource, mmio += PDC_CHIP0_OFS; page_mask = 0x00; - window_size = 0x2000 * 4; /* 32K byte uchar size */ + window_size = 0x2000 * 4; /* 32K byte uchar size */ idx = (u16) (offset / window_size); writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR); @@ -1031,7 +1031,7 @@ static void pdc20621_put_to_dimm(struct ata_host *host, void *psource, readl(mmio + PDC_GENERAL_CTLR); psource += window_size; size -= window_size; - idx++; + idx ++; } if (size) { @@ -1050,7 +1050,7 @@ static unsigned int pdc20621_i2c_read(struct ata_host *host, u32 device, void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; u32 i2creg = 0; u32 status; - u32 count = 0; + u32 count =0; /* hard-code chip #0 */ mmio += PDC_CHIP0_OFS; @@ -1082,21 +1082,21 @@ static unsigned int pdc20621_i2c_read(struct ata_host *host, u32 device, static int pdc20621_detect_dimm(struct ata_host *host) { - u32 data = 0; + u32 data=0 ; if (pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, PDC_DIMM_SPD_SYSTEM_FREQ, &data)) { - if (data == 100) + if (data == 100) return 100; - } else + } else return 0; if (pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, 9, &data)) { - if (data <= 0x75) + if(data <= 0x75) return 133; - } else + } else return 0; - return 0; + return 0; } @@ -1104,8 +1104,8 @@ static int pdc20621_prog_dimm0(struct ata_host *host) { u32 spd0[50]; u32 data = 0; - int size, i; - u8 bdimmsize; + int size, i; + u8 bdimmsize; void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; static const struct { unsigned int reg; @@ -1128,40 +1128,40 @@ static int pdc20621_prog_dimm0(struct ata_host *host) /* hard-code chip #0 */ mmio += PDC_CHIP0_OFS; - for (i = 0; i < ARRAY_SIZE(pdc_i2c_read_data); i++) + for(i=0; i spd0[28]) + data |= (((((spd0[29] > spd0[28]) ? spd0[29] : spd0[28]) + 9) / 10) - 1) << 10; - data |= ((spd0[30] - spd0[29] + 9) / 10 - 2) << 12; + data |= ((spd0[30] - spd0[29] + 9) / 10 - 2) << 12; - if (spd0[18] & 0x08) + if (spd0[18] & 0x08) data |= ((0x03) << 14); - else if (spd0[18] & 0x04) + else if (spd0[18] & 0x04) data |= ((0x02) << 14); - else if (spd0[18] & 0x01) + else if (spd0[18] & 0x01) data |= ((0x01) << 14); - else + else data |= (0 << 14); - /* + /* Calculate the size of bDIMMSize (power of 2) and merge the DIMM size by program start/end address. */ - bdimmsize = spd0[4] + (spd0[5] / 2) + spd0[3] + (spd0[17] / 2) + 3; - size = (1 << bdimmsize) >> 20; /* size = xxx(MB) */ - data |= (((size / 16) - 1) << 16); - data |= (0 << 23); + bdimmsize = spd0[4] + (spd0[5] / 2) + spd0[3] + (spd0[17] / 2) + 3; + size = (1 << bdimmsize) >> 20; /* size = xxx(MB) */ + data |= (((size / 16) - 1) << 16); + data |= (0 << 23); data |= 8; - writel(data, mmio + PDC_DIMM0_CONTROL); + writel(data, mmio + PDC_DIMM0_CONTROL); readl(mmio + PDC_DIMM0_CONTROL); - return size; + return size; } @@ -1172,9 +1172,9 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_host *host) void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; /* hard-code chip #0 */ - mmio += PDC_CHIP0_OFS; + mmio += PDC_CHIP0_OFS; - /* + /* Set To Default : DIMM Module Global Control Register (0x022259F1) DIMM Arbitration Disable (bit 20) DIMM Data/Control Output Driving Selection (bit12 - bit15) @@ -1193,40 +1193,40 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_host *host) writel(data, mmio + PDC_SDRAM_CONTROL); readl(mmio + PDC_SDRAM_CONTROL); printk(KERN_ERR "Local DIMM ECC Enabled\n"); - } + } - /* DIMM Initialization Select/Enable (bit 18/19) */ - data &= (~(1<<18)); - data |= (1<<19); - writel(data, mmio + PDC_SDRAM_CONTROL); + /* DIMM Initialization Select/Enable (bit 18/19) */ + data &= (~(1<<18)); + data |= (1<<19); + writel(data, mmio + PDC_SDRAM_CONTROL); - error = 1; - for (i = 1; i <= 10; i++) { /* polling ~5 secs */ + error = 1; + for (i = 1; i <= 10; i++) { /* polling ~5 secs */ data = readl(mmio + PDC_SDRAM_CONTROL); if (!(data & (1<<19))) { - error = 0; - break; + error = 0; + break; } msleep(i*100); - } - return error; + } + return error; } static unsigned int pdc20621_dimm_init(struct ata_host *host) { int speed, size, length; - u32 addr, spd0, pci_status; - u32 tmp = 0; - u32 time_period = 0; - u32 tcount = 0; - u32 ticks = 0; - u32 clock = 0; - u32 fparam = 0; + u32 addr,spd0,pci_status; + u32 tmp=0; + u32 time_period=0; + u32 tcount=0; + u32 ticks=0; + u32 clock=0; + u32 fparam=0; void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; /* hard-code chip #0 */ - mmio += PDC_CHIP0_OFS; + mmio += PDC_CHIP0_OFS; /* Initialize PLL based upon PCI Bus Frequency */ @@ -1254,7 +1254,7 @@ static unsigned int pdc20621_dimm_init(struct ata_host *host) If SX4 is on PCI-X bus, after 3 seconds, the timer counter register should be >= (0xffffffff - 3x10^8). */ - if (tcount >= PCI_X_TCOUNT) { + if(tcount >= PCI_X_TCOUNT) { ticks = (time_period - tcount); VPRINTK("Num counters 0x%x (%d)\n", ticks, ticks); @@ -1285,43 +1285,41 @@ static unsigned int pdc20621_dimm_init(struct ata_host *host) if (!(speed = pdc20621_detect_dimm(host))) { printk(KERN_ERR "Detect Local DIMM Fail\n"); return 1; /* DIMM error */ - } - VPRINTK("Local DIMM Speed = %d\n", speed); + } + VPRINTK("Local DIMM Speed = %d\n", speed); - /* Programming DIMM0 Module Control Register (index_CID0:80h) */ + /* Programming DIMM0 Module Control Register (index_CID0:80h) */ size = pdc20621_prog_dimm0(host); - VPRINTK("Local DIMM Size = %dMB\n", size); + VPRINTK("Local DIMM Size = %dMB\n",size); - /* Programming DIMM Module Global Control Register (index_CID0:88h) */ + /* Programming DIMM Module Global Control Register (index_CID0:88h) */ if (pdc20621_prog_dimm_global(host)) { printk(KERN_ERR "Programming DIMM Module Global Control Register Fail\n"); return 1; - } + } #ifdef ATA_VERBOSE_DEBUG { - u8 test_parttern1[40] = - {0x55,0xAA,'P','r','o','m','i','s','e',' ', - 'N','o','t',' ','Y','e','t',' ', - 'D','e','f','i','n','e','d',' ', - '1','.','1','0', - '9','8','0','3','1','6','1','2',0,0}; + u8 test_parttern1[40] = {0x55,0xAA,'P','r','o','m','i','s','e',' ', + 'N','o','t',' ','Y','e','t',' ','D','e','f','i','n','e','d',' ', + '1','.','1','0', + '9','8','0','3','1','6','1','2',0,0}; u8 test_parttern2[40] = {0}; - pdc20621_put_to_dimm(host, test_parttern2, 0x10040, 40); - pdc20621_put_to_dimm(host, test_parttern2, 0x40, 40); + pdc20621_put_to_dimm(host, (void *) test_parttern2, 0x10040, 40); + pdc20621_put_to_dimm(host, (void *) test_parttern2, 0x40, 40); - pdc20621_put_to_dimm(host, test_parttern1, 0x10040, 40); - pdc20621_get_from_dimm(host, test_parttern2, 0x40, 40); + pdc20621_put_to_dimm(host, (void *) test_parttern1, 0x10040, 40); + pdc20621_get_from_dimm(host, (void *) test_parttern2, 0x40, 40); printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0], test_parttern2[1], &(test_parttern2[2])); - pdc20621_get_from_dimm(host, test_parttern2, 0x10040, + pdc20621_get_from_dimm(host, (void *) test_parttern2, 0x10040, 40); printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0], test_parttern2[1], &(test_parttern2[2])); - pdc20621_put_to_dimm(host, test_parttern1, 0x40, 40); - pdc20621_get_from_dimm(host, test_parttern2, 0x40, 40); + pdc20621_put_to_dimm(host, (void *) test_parttern1, 0x40, 40); + pdc20621_get_from_dimm(host, (void *) test_parttern2, 0x40, 40); printk(KERN_ERR "%x, %x, %s\n", test_parttern2[0], test_parttern2[1], &(test_parttern2[2])); } @@ -1377,8 +1375,7 @@ static void pdc_20621_init(struct ata_host *host) readl(mmio + PDC_HDMA_CTLSTAT); /* flush */ } -static int pdc_sata_init_one(struct pci_dev *pdev, - const struct pci_device_id *ent) +static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; const struct ata_port_info *ppi[] = diff --git a/trunk/drivers/ata/sata_uli.c b/trunk/drivers/ata/sata_uli.c index e710e71b7b92..d394da085ae4 100644 --- a/trunk/drivers/ata/sata_uli.c +++ b/trunk/drivers/ata/sata_uli.c @@ -56,9 +56,9 @@ struct uli_priv { unsigned int scr_cfg_addr[uli_max_ports]; }; -static int uli_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); -static int uli_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); -static int uli_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); +static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); +static int uli_scr_read (struct ata_port *ap, unsigned int sc_reg, u32 *val); +static int uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); static const struct pci_device_id uli_pci_tbl[] = { { PCI_VDEVICE(AL, 0x5289), uli_5289 }, @@ -143,7 +143,7 @@ static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg) return hpriv->scr_cfg_addr[ap->port_no] + (4 * sc_reg); } -static u32 uli_scr_cfg_read(struct ata_port *ap, unsigned int sc_reg) +static u32 uli_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg) { struct pci_dev *pdev = to_pci_dev(ap->host->dev); unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg); @@ -153,7 +153,7 @@ static u32 uli_scr_cfg_read(struct ata_port *ap, unsigned int sc_reg) return val; } -static void uli_scr_cfg_write(struct ata_port *ap, unsigned int scr, u32 val) +static void uli_scr_cfg_write (struct ata_port *ap, unsigned int scr, u32 val) { struct pci_dev *pdev = to_pci_dev(ap->host->dev); unsigned int cfg_addr = get_scr_cfg_addr(ap, scr); @@ -161,7 +161,7 @@ static void uli_scr_cfg_write(struct ata_port *ap, unsigned int scr, u32 val) pci_write_config_dword(pdev, cfg_addr, val); } -static int uli_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) +static int uli_scr_read (struct ata_port *ap, unsigned int sc_reg, u32 *val) { if (sc_reg > SCR_CONTROL) return -EINVAL; @@ -170,16 +170,16 @@ static int uli_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) return 0; } -static int uli_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) +static int uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) { - if (sc_reg > SCR_CONTROL) //SCR_CONTROL=2, SCR_ERROR=1, SCR_STATUS=0 + if (sc_reg > SCR_CONTROL) //SCR_CONTROL=2, SCR_ERROR=1, SCR_STATUS=0 return -EINVAL; uli_scr_cfg_write(ap, sc_reg, val); return 0; } -static int uli_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) +static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; const struct ata_port_info *ppi[] = { &uli_port_info, NULL }; diff --git a/trunk/drivers/ata/sata_via.c b/trunk/drivers/ata/sata_via.c index 3ef072ff319d..cc6ee0890f56 100644 --- a/trunk/drivers/ata/sata_via.c +++ b/trunk/drivers/ata/sata_via.c @@ -3,7 +3,7 @@ * * Maintained by: Jeff Garzik * Please ALWAYS copy linux-ide@vger.kernel.org - * on emails. + on emails. * * Copyright 2003-2004 Red Hat, Inc. All rights reserved. * Copyright 2003-2004 Jeff Garzik @@ -69,7 +69,7 @@ enum { SATA_EXT_PHY = (1 << 6), /* 0==use PATA, 1==ext phy */ }; -static int svia_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); +static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); static int svia_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); static int svia_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); static void svia_noop_freeze(struct ata_port *ap); @@ -372,12 +372,12 @@ static const unsigned int vt6421_bar_sizes[] = { 16, 16, 16, 16, 32, 128 }; -static void __iomem *svia_scr_addr(void __iomem *addr, unsigned int port) +static void __iomem * svia_scr_addr(void __iomem *addr, unsigned int port) { return addr + (port * 128); } -static void __iomem *vt6421_scr_addr(void __iomem *addr, unsigned int port) +static void __iomem * vt6421_scr_addr(void __iomem *addr, unsigned int port) { return addr + (port * 64); } @@ -472,7 +472,7 @@ static void svia_configure(struct pci_dev *pdev) if ((tmp8 & ALL_PORTS) != ALL_PORTS) { dev_printk(KERN_DEBUG, &pdev->dev, "enabling SATA channels (0x%x)\n", - (int) tmp8); + (int) tmp8); tmp8 |= ALL_PORTS; pci_write_config_byte(pdev, SATA_CHAN_ENAB, tmp8); } @@ -482,7 +482,7 @@ static void svia_configure(struct pci_dev *pdev) if ((tmp8 & ALL_PORTS) != ALL_PORTS) { dev_printk(KERN_DEBUG, &pdev->dev, "enabling SATA channel interrupts (0x%x)\n", - (int) tmp8); + (int) tmp8); tmp8 |= ALL_PORTS; pci_write_config_byte(pdev, SATA_INT_GATE, tmp8); } @@ -492,13 +492,13 @@ static void svia_configure(struct pci_dev *pdev) if ((tmp8 & NATIVE_MODE_ALL) != NATIVE_MODE_ALL) { dev_printk(KERN_DEBUG, &pdev->dev, "enabling SATA channel native mode (0x%x)\n", - (int) tmp8); + (int) tmp8); tmp8 |= NATIVE_MODE_ALL; pci_write_config_byte(pdev, SATA_NATIVE_MODE, tmp8); } } -static int svia_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) +static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; unsigned int i; @@ -525,8 +525,8 @@ static int svia_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) dev_printk(KERN_ERR, &pdev->dev, "invalid PCI BAR %u (sz 0x%llx, val 0x%llx)\n", i, - (unsigned long long)pci_resource_start(pdev, i), - (unsigned long long)pci_resource_len(pdev, i)); + (unsigned long long)pci_resource_start(pdev, i), + (unsigned long long)pci_resource_len(pdev, i)); return -ENODEV; } diff --git a/trunk/drivers/ata/sata_vsc.c b/trunk/drivers/ata/sata_vsc.c index 95ae3ed24a9d..0d9be1684873 100644 --- a/trunk/drivers/ata/sata_vsc.c +++ b/trunk/drivers/ata/sata_vsc.c @@ -162,8 +162,7 @@ static void vsc_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) /* * The only thing the ctl register is used for is SRST. * That is not enabled or disabled via tf_load. - * However, if ATA_NIEN is changed, then we need to change - * the interrupt register. + * However, if ATA_NIEN is changed, then we need to change the interrupt register. */ if ((tf->ctl & ATA_NIEN) != (ap->last_ctl & ATA_NIEN)) { ap->last_ctl = tf->ctl; @@ -220,7 +219,7 @@ static void vsc_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) tf->hob_lbal = lbal >> 8; tf->hob_lbam = lbam >> 8; tf->hob_lbah = lbah >> 8; - } + } } static inline void vsc_error_intr(u8 port_status, struct ata_port *ap) @@ -257,10 +256,9 @@ static void vsc_port_intr(u8 port_status, struct ata_port *ap) /* * vsc_sata_interrupt * - * Read the interrupt register and process for the devices that have - * them pending. + * Read the interrupt register and process for the devices that have them pending. */ -static irqreturn_t vsc_sata_interrupt(int irq, void *dev_instance) +static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance) { struct ata_host *host = dev_instance; unsigned int i; @@ -289,7 +287,7 @@ static irqreturn_t vsc_sata_interrupt(int irq, void *dev_instance) handled++; } else dev_printk(KERN_ERR, host->dev, - "interrupt from disabled port %d\n", i); + ": interrupt from disabled port %d\n", i); } } @@ -365,8 +363,7 @@ static void __devinit vsc_sata_setup_port(struct ata_ioports *port, } -static int __devinit vsc_sata_init_one(struct pci_dev *pdev, - const struct pci_device_id *ent) +static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static const struct ata_port_info pi = { .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | diff --git a/trunk/drivers/atm/horizon.c b/trunk/drivers/atm/horizon.c index 9b2cf253f02f..f96446c358ba 100644 --- a/trunk/drivers/atm/horizon.c +++ b/trunk/drivers/atm/horizon.c @@ -1382,9 +1382,8 @@ static inline void rx_data_av_handler (hrz_dev * dev) { /********** interrupt handler **********/ -static irqreturn_t interrupt_handler(int irq, void *dev_id) -{ - hrz_dev *dev = dev_id; +static irqreturn_t interrupt_handler(int irq, void *dev_id) { + hrz_dev * dev = (hrz_dev *) dev_id; u32 int_source; unsigned int irq_ok; diff --git a/trunk/drivers/block/DAC960.c b/trunk/drivers/block/DAC960.c index 9030c373ce67..53505422867c 100644 --- a/trunk/drivers/block/DAC960.c +++ b/trunk/drivers/block/DAC960.c @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include "DAC960.h" diff --git a/trunk/drivers/block/cciss.c b/trunk/drivers/block/cciss.c index 7d704968765f..5a6fe17fc638 100644 --- a/trunk/drivers/block/cciss.c +++ b/trunk/drivers/block/cciss.c @@ -1,20 +1,20 @@ /* - * Disk Array driver for HP Smart Array controllers. - * (C) Copyright 2000, 2007 Hewlett-Packard Development Company, L.P. + * Disk Array driver for HP SA 5xxx and 6xxx Controllers + * Copyright 2000, 2006 Hewlett-Packard Development Company, L.P. * * 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; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or + * NON INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307, USA. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * Questions/Comments/Bugfixes to iss_storagedev@hp.com * diff --git a/trunk/drivers/block/cciss_scsi.c b/trunk/drivers/block/cciss_scsi.c index 63ee6c076cb3..4aca7ddfdddf 100644 --- a/trunk/drivers/block/cciss_scsi.c +++ b/trunk/drivers/block/cciss_scsi.c @@ -1,20 +1,20 @@ /* - * Disk Array driver for HP Smart Array controllers, SCSI Tape module. - * (C) Copyright 2001, 2007 Hewlett-Packard Development Company, L.P. + * Disk Array driver for Compaq SA53xx Controllers, SCSI Tape module + * Copyright 2001 Compaq Computer Corporation * * 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; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or + * NON INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 300, Boston, MA - * 02111-1307, USA. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * Questions/Comments/Bugfixes to iss_storagedev@hp.com * diff --git a/trunk/drivers/block/cciss_scsi.h b/trunk/drivers/block/cciss_scsi.h index d9c2c586502f..5e7e06c07d6c 100644 --- a/trunk/drivers/block/cciss_scsi.h +++ b/trunk/drivers/block/cciss_scsi.h @@ -1,20 +1,20 @@ /* - * Disk Array driver for HP Smart Array controllers, SCSI Tape module. - * (C) Copyright 2001, 2007 Hewlett-Packard Development Company, L.P. + * Disk Array driver for Compaq SA53xx Controllers, SCSI Tape module + * Copyright 2001 Compaq Computer Corporation * * 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; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or + * NON INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 300, Boston, MA - * 02111-1307, USA. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * Questions/Comments/Bugfixes to iss_storagedev@hp.com * diff --git a/trunk/drivers/block/cpqarray.c b/trunk/drivers/block/cpqarray.c index c8132d958795..efab27fa1083 100644 --- a/trunk/drivers/block/cpqarray.c +++ b/trunk/drivers/block/cpqarray.c @@ -37,7 +37,6 @@ #include #include #include -#include #include #include diff --git a/trunk/drivers/block/cryptoloop.c b/trunk/drivers/block/cryptoloop.c index 241167878edf..1b58b010797f 100644 --- a/trunk/drivers/block/cryptoloop.c +++ b/trunk/drivers/block/cryptoloop.c @@ -150,8 +150,13 @@ cryptoloop_transfer(struct loop_device *lo, int cmd, u32 iv[4] = { 0, }; iv[0] = cpu_to_le32(IV & 0xffffffff); - sg_set_page(&sg_in, in_page, sz, in_offs); - sg_set_page(&sg_out, out_page, sz, out_offs); + sg_set_page(&sg_in, in_page); + sg_in.offset = in_offs; + sg_in.length = sz; + + sg_set_page(&sg_out, out_page); + sg_out.offset = out_offs; + sg_out.length = sz; desc.info = iv; err = encdecfunc(&desc, &sg_out, &sg_in, sz); diff --git a/trunk/drivers/block/sunvdc.c b/trunk/drivers/block/sunvdc.c index fac4c6cd04f7..7276f7d207c2 100644 --- a/trunk/drivers/block/sunvdc.c +++ b/trunk/drivers/block/sunvdc.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include diff --git a/trunk/drivers/block/sx8.c b/trunk/drivers/block/sx8.c index 52dc5e131718..282a69558e8a 100644 --- a/trunk/drivers/block/sx8.c +++ b/trunk/drivers/block/sx8.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include diff --git a/trunk/drivers/block/ub.c b/trunk/drivers/block/ub.c index 08e909dc7944..14143f2c484d 100644 --- a/trunk/drivers/block/ub.c +++ b/trunk/drivers/block/ub.c @@ -1428,9 +1428,9 @@ static void ub_state_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd) scmd->state = UB_CMDST_INIT; scmd->nsg = 1; sg = &scmd->sgv[0]; - sg_init_table(sg, UB_MAX_REQ_SG); - sg_set_page(sg, virt_to_page(sc->top_sense), UB_SENSE_SIZE, - (unsigned long)sc->top_sense & (PAGE_SIZE-1)); + sg_set_page(sg, virt_to_page(sc->top_sense)); + sg->offset = (unsigned long)sc->top_sense & (PAGE_SIZE-1); + sg->length = UB_SENSE_SIZE; scmd->len = UB_SENSE_SIZE; scmd->lun = cmd->lun; scmd->done = ub_top_sense_done; @@ -1864,8 +1864,9 @@ static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun, cmd->state = UB_CMDST_INIT; cmd->nsg = 1; sg = &cmd->sgv[0]; - sg_init_table(sg, UB_MAX_REQ_SG); - sg_set_page(sg, virt_to_page(p), 8, (unsigned long)p & (PAGE_SIZE-1)); + sg_set_page(sg, virt_to_page(p)); + sg->offset = (unsigned long)p & (PAGE_SIZE-1); + sg->length = 8; cmd->len = 8; cmd->lun = lun; cmd->done = ub_probe_done; diff --git a/trunk/drivers/block/virtio_blk.c b/trunk/drivers/block/virtio_blk.c index 3cf7129d83e6..a901eee64ba5 100644 --- a/trunk/drivers/block/virtio_blk.c +++ b/trunk/drivers/block/virtio_blk.c @@ -4,9 +4,7 @@ #include #include #include -#include - -#define VIRTIO_MAX_SG (3+MAX_PHYS_SEGMENTS) +#include static unsigned char virtblk_index = 'a'; struct virtio_blk @@ -25,7 +23,7 @@ struct virtio_blk mempool_t *pool; /* Scatterlist: can be too big for stack. */ - struct scatterlist sg[VIRTIO_MAX_SG]; + struct scatterlist sg[3+MAX_PHYS_SEGMENTS]; }; struct virtblk_req @@ -96,8 +94,8 @@ static bool do_req(struct request_queue *q, struct virtio_blk *vblk, if (blk_barrier_rq(vbr->req)) vbr->out_hdr.type |= VIRTIO_BLK_T_BARRIER; - /* This init could be done at vblk creation time */ - sg_init_table(vblk->sg, VIRTIO_MAX_SG); + /* We have to zero this, otherwise blk_rq_map_sg gets upset. */ + memset(vblk->sg, 0, sizeof(vblk->sg)); sg_set_buf(&vblk->sg[0], &vbr->out_hdr, sizeof(vbr->out_hdr)); num = blk_rq_map_sg(q, vbr->req, vblk->sg+1); sg_set_buf(&vblk->sg[num+1], &vbr->in_hdr, sizeof(vbr->in_hdr)); diff --git a/trunk/drivers/cdrom/viocd.c b/trunk/drivers/cdrom/viocd.c index d8bb44b98a6a..880b5dce3a62 100644 --- a/trunk/drivers/cdrom/viocd.c +++ b/trunk/drivers/cdrom/viocd.c @@ -41,9 +41,9 @@ #include #include #include -#include #include +#include #include #include #include @@ -258,7 +258,6 @@ static int send_request(struct request *req) cmd = viomajorsubtype_cdio | viocdwrite; } - sg_init_table(&sg, 1); if (blk_rq_map_sg(req->q, req, &sg) == 0) { printk(VIOCD_KERN_WARNING "error setting up scatter/gather list\n"); diff --git a/trunk/drivers/char/agp/Kconfig b/trunk/drivers/char/agp/Kconfig index ccb1fa89de29..f22c253bc09f 100644 --- a/trunk/drivers/char/agp/Kconfig +++ b/trunk/drivers/char/agp/Kconfig @@ -56,9 +56,9 @@ config AGP_AMD X on AMD Irongate, 761, and 762 chipsets. config AGP_AMD64 - tristate "AMD Opteron/Athlon64 on-CPU GART support" if !GART_IOMMU + tristate "AMD Opteron/Athlon64 on-CPU GART support" if !IOMMU depends on AGP && X86 - default y if GART_IOMMU + default y if IOMMU help This option gives you AGP support for the GLX component of X using the on-CPU northbridge of the AMD Athlon64/Opteron CPUs. diff --git a/trunk/drivers/char/agp/amd64-agp.c b/trunk/drivers/char/agp/amd64-agp.c index d8200ac8f8cb..d95662e96326 100644 --- a/trunk/drivers/char/agp/amd64-agp.c +++ b/trunk/drivers/char/agp/amd64-agp.c @@ -787,7 +787,7 @@ static void __exit agp_amd64_cleanup(void) /* On AMD64 the PCI driver needs to initialize this driver early for the IOMMU, so it has to be called via a backdoor. */ -#ifndef CONFIG_GART_IOMMU +#ifndef CONFIG_IOMMU module_init(agp_amd64_init); module_exit(agp_amd64_cleanup); #endif diff --git a/trunk/drivers/char/ip2/ip2main.c b/trunk/drivers/char/ip2/ip2main.c index e04e66cf2c68..2124dce38f2b 100644 --- a/trunk/drivers/char/ip2/ip2main.c +++ b/trunk/drivers/char/ip2/ip2main.c @@ -752,7 +752,7 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize) continue; rc = request_irq( ip2config.irq[i], ip2_interrupt, IP2_SA_FLAGS | (ip2config.type[i] == PCI ? IRQF_SHARED : 0), - pcName, i2BoardPtrTable[i]); + pcName, (void *)&pcName); if (rc) { printk(KERN_ERR "IP2: an request_irq failed: error %d\n",rc); ip2config.irq[i] = CIR_POLL; @@ -1166,37 +1166,12 @@ ip2_interrupt_bh(struct work_struct *work) /* */ /* */ /******************************************************************************/ -static void -ip2_irq_work(i2eBordStrPtr pB) -{ -#ifdef USE_IQI - if (NO_MAIL_HERE != ( pB->i2eStartMail = iiGetMail(pB))) { -// Disable his interrupt (will be enabled when serviced) -// This is mostly to protect from reentrancy. - iiDisableMailIrq(pB); - -// Park the board on the immediate queue for processing. - schedule_work(&pB->tqueue_interrupt); - -// Make sure the immediate queue is flagged to fire. - } -#else - -// We are using immediate servicing here. This sucks and can -// cause all sorts of havoc with ppp and others. The failsafe -// check on iiSendPendingMail could also throw a hairball. - - i2ServiceBoard( pB ); - -#endif /* USE_IQI */ -} - -static void -ip2_polled_interrupt(void) +static irqreturn_t +ip2_interrupt(int irq, void *dev_id) { int i; i2eBordStrPtr pB; - const int irq = 0; + int handled = 0; ip2trace (ITRC_NO_PORT, ITRC_INTR, 99, 1, irq ); @@ -1208,28 +1183,32 @@ ip2_polled_interrupt(void) // IRQ = 0 for polled boards, we won't poll "IRQ" boards if ( pB && (pB->i2eUsingIrq == irq) ) { - ip2_irq_work(pB); - } - } - - ++irq_counter; - - ip2trace (ITRC_NO_PORT, ITRC_INTR, ITRC_RETURN, 0 ); -} + handled = 1; +#ifdef USE_IQI -static irqreturn_t -ip2_interrupt(int irq, void *dev_id) -{ - i2eBordStrPtr pB = dev_id; + if (NO_MAIL_HERE != ( pB->i2eStartMail = iiGetMail(pB))) { +// Disable his interrupt (will be enabled when serviced) +// This is mostly to protect from reentrancy. + iiDisableMailIrq(pB); - ip2trace (ITRC_NO_PORT, ITRC_INTR, 99, 1, pB->i2eUsingIrq ); +// Park the board on the immediate queue for processing. + schedule_work(&pB->tqueue_interrupt); - ip2_irq_work(pB); +// Make sure the immediate queue is flagged to fire. + } +#else +// We are using immediate servicing here. This sucks and can +// cause all sorts of havoc with ppp and others. The failsafe +// check on iiSendPendingMail could also throw a hairball. + i2ServiceBoard( pB ); +#endif /* USE_IQI */ + } + } ++irq_counter; ip2trace (ITRC_NO_PORT, ITRC_INTR, ITRC_RETURN, 0 ); - return IRQ_HANDLED; + return IRQ_RETVAL(handled); } /******************************************************************************/ @@ -1252,7 +1231,7 @@ ip2_poll(unsigned long arg) // Just polled boards, IRQ = 0 will hit all non-interrupt boards. // It will NOT poll boards handled by hard interrupts. // The issue of queued BH interrups is handled in ip2_interrupt(). - ip2_polled_interrupt(); + ip2_interrupt(0, NULL); PollTimer.expires = POLL_TIMEOUT; add_timer( &PollTimer ); diff --git a/trunk/drivers/char/mem.c b/trunk/drivers/char/mem.c index 20070b7c573d..0e937f64a789 100644 --- a/trunk/drivers/char/mem.c +++ b/trunk/drivers/char/mem.c @@ -41,7 +41,7 @@ */ static inline int uncached_access(struct file *file, unsigned long addr) { -#if defined(__i386__) && !defined(__arch_um__) +#if defined(__i386__) /* * On the PPro and successors, the MTRRs are used to set * memory types for physical addresses outside main memory, @@ -57,7 +57,7 @@ static inline int uncached_access(struct file *file, unsigned long addr) test_bit(X86_FEATURE_CYRIX_ARR, boot_cpu_data.x86_capability) || test_bit(X86_FEATURE_CENTAUR_MCR, boot_cpu_data.x86_capability) ) && addr >= __pa(high_memory); -#elif defined(__x86_64__) && !defined(__arch_um__) +#elif defined(__x86_64__) /* * This is broken because it can generate memory type aliases, * which can cause cache corruptions diff --git a/trunk/drivers/char/pcmcia/synclink_cs.c b/trunk/drivers/char/pcmcia/synclink_cs.c index 8caff0ca80ff..2b889317461e 100644 --- a/trunk/drivers/char/pcmcia/synclink_cs.c +++ b/trunk/drivers/char/pcmcia/synclink_cs.c @@ -123,7 +123,7 @@ typedef struct #define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK)) struct _input_signal_events { - int ri_up; + int ri_up; int ri_down; int dsr_up; int dsr_down; @@ -137,7 +137,7 @@ struct _input_signal_events { /* * Device instance data structure */ - + typedef struct _mgslpc_info { void *if_ptr; /* General purpose pointer (used by SPPP) */ int magic; @@ -146,15 +146,15 @@ typedef struct _mgslpc_info { int line; unsigned short close_delay; unsigned short closing_wait; /* time to wait before closing */ - + struct mgsl_icount icount; - + struct tty_struct *tty; int timeout; int x_char; /* xon/xoff character */ int blocked_open; /* # of blocked opens */ unsigned char read_status_mask; - unsigned char ignore_status_mask; + unsigned char ignore_status_mask; unsigned char *tx_buf; int tx_put; @@ -170,10 +170,10 @@ typedef struct _mgslpc_info { int rx_buf_size; /* size in bytes of single rx buffer */ int rx_buf_count; /* total number of rx buffers */ int rx_frame_count; /* number of full rx buffers */ - + wait_queue_head_t open_wait; wait_queue_head_t close_wait; - + wait_queue_head_t status_event_wait_q; wait_queue_head_t event_wait_q; struct timer_list tx_timer; /* HDLC transmit timeout timer */ @@ -192,7 +192,7 @@ typedef struct _mgslpc_info { int bh_running; int bh_requested; - + int dcd_chkcount; /* check counts to prevent */ int cts_chkcount; /* too many IRQs if a signal */ int dsr_chkcount; /* is floating */ @@ -212,7 +212,7 @@ typedef struct _mgslpc_info { unsigned int io_base; /* base I/O address of adapter */ unsigned int irq_level; - + MGSL_PARAMS params; /* communications parameters */ unsigned char serial_signals; /* current serial signal states */ @@ -249,7 +249,7 @@ typedef struct _mgslpc_info { */ #define TXBUFSIZE 4096 - + #define CHA 0x00 /* channel A offset */ #define CHB 0x40 /* channel B offset */ @@ -298,9 +298,9 @@ typedef struct _mgslpc_info { #define PIM 0x3d #define PCR 0x3e #define CCR4 0x3f - + // IMR/ISR - + #define IRQ_BREAK_ON BIT15 // rx break detected #define IRQ_DATAOVERRUN BIT14 // receive data overflow #define IRQ_ALLSENT BIT13 // all sent @@ -315,13 +315,13 @@ typedef struct _mgslpc_info { #define IRQ_DCD BIT2 // carrier detect status change #define IRQ_OVERRUN BIT1 // receive frame overflow #define IRQ_RXFIFO BIT0 // receive pool full - + // STAR - + #define XFW BIT6 // transmit FIFO write enable #define CEC BIT2 // command executing #define CTS BIT1 // CTS state - + #define PVR_DTR BIT0 #define PVR_DSR BIT1 #define PVR_RI BIT2 @@ -329,25 +329,25 @@ typedef struct _mgslpc_info { #define PVR_RS232 0x20 /* 0010b */ #define PVR_V35 0xe0 /* 1110b */ #define PVR_RS422 0x40 /* 0100b */ - -/* Register access functions */ - + +/* Register access functions */ + #define write_reg(info, reg, val) outb((val),(info)->io_base + (reg)) #define read_reg(info, reg) inb((info)->io_base + (reg)) -#define read_reg16(info, reg) inw((info)->io_base + (reg)) +#define read_reg16(info, reg) inw((info)->io_base + (reg)) #define write_reg16(info, reg, val) outw((val), (info)->io_base + (reg)) - + #define set_reg_bits(info, reg, mask) \ write_reg(info, (reg), \ - (unsigned char) (read_reg(info, (reg)) | (mask))) + (unsigned char) (read_reg(info, (reg)) | (mask))) #define clear_reg_bits(info, reg, mask) \ write_reg(info, (reg), \ - (unsigned char) (read_reg(info, (reg)) & ~(mask))) + (unsigned char) (read_reg(info, (reg)) & ~(mask))) /* * interrupt enable/disable routines - */ -static void irq_disable(MGSLPC_INFO *info, unsigned char channel, unsigned short mask) + */ +static void irq_disable(MGSLPC_INFO *info, unsigned char channel, unsigned short mask) { if (channel == CHA) { info->imra_value |= mask; @@ -357,7 +357,7 @@ static void irq_disable(MGSLPC_INFO *info, unsigned char channel, unsigned short write_reg16(info, CHB + IMR, info->imrb_value); } } -static void irq_enable(MGSLPC_INFO *info, unsigned char channel, unsigned short mask) +static void irq_enable(MGSLPC_INFO *info, unsigned char channel, unsigned short mask) { if (channel == CHA) { info->imra_value &= ~mask; @@ -558,7 +558,7 @@ static int mgslpc_probe(struct pcmcia_device *link) spin_lock_init(&info->lock); spin_lock_init(&info->netlock); memcpy(&info->params,&default_params,sizeof(MGSL_PARAMS)); - info->idle_mode = HDLC_TXIDLE_FLAGS; + info->idle_mode = HDLC_TXIDLE_FLAGS; info->imra_value = 0xffff; info->imrb_value = 0xffff; info->pim_value = 0xff; @@ -600,7 +600,7 @@ static int mgslpc_config(struct pcmcia_device *link) u_char buf[64]; cistpl_cftable_entry_t dflt = { 0 }; cistpl_cftable_entry_t *cfg; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("mgslpc_config(0x%p)\n", link); @@ -624,7 +624,7 @@ static int mgslpc_config(struct pcmcia_device *link) link->conf.ConfigIndex = cfg->index; link->conf.Attributes |= CONF_ENABLE_IRQ; - + /* IO window settings */ link->io.NumPorts1 = 0; if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { @@ -644,7 +644,7 @@ static int mgslpc_config(struct pcmcia_device *link) link->conf.IntType = INT_MEMORY_AND_IO; link->conf.ConfigIndex = 8; link->conf.Present = PRESENT_OPTION; - + link->irq.Attributes |= IRQ_HANDLE_PRESENT; link->irq.Handler = mgslpc_isr; link->irq.Instance = info; @@ -753,10 +753,10 @@ static inline int mgslpc_paranoia_check(MGSLPC_INFO *info, #define CMD_TXEOM BIT1 // transmit end message #define CMD_TXRESET BIT0 // transmit reset -static BOOLEAN wait_command_complete(MGSLPC_INFO *info, unsigned char channel) +static BOOLEAN wait_command_complete(MGSLPC_INFO *info, unsigned char channel) { int i = 0; - /* wait for command completion */ + /* wait for command completion */ while (read_reg(info, (unsigned char)(channel+STAR)) & BIT2) { udelay(1); if (i++ == 1000) @@ -765,7 +765,7 @@ static BOOLEAN wait_command_complete(MGSLPC_INFO *info, unsigned char channel) return TRUE; } -static void issue_command(MGSLPC_INFO *info, unsigned char channel, unsigned char cmd) +static void issue_command(MGSLPC_INFO *info, unsigned char channel, unsigned char cmd) { wait_command_complete(info, channel); write_reg(info, (unsigned char) (channel + CMDR), cmd); @@ -775,12 +775,12 @@ static void tx_pause(struct tty_struct *tty) { MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; - + if (mgslpc_paranoia_check(info, tty->name, "tx_pause")) return; if (debug_level >= DEBUG_LEVEL_INFO) - printk("tx_pause(%s)\n",info->device_name); - + printk("tx_pause(%s)\n",info->device_name); + spin_lock_irqsave(&info->lock,flags); if (info->tx_enabled) tx_stop(info); @@ -791,12 +791,12 @@ static void tx_release(struct tty_struct *tty) { MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; - + if (mgslpc_paranoia_check(info, tty->name, "tx_release")) return; if (debug_level >= DEBUG_LEVEL_INFO) - printk("tx_release(%s)\n",info->device_name); - + printk("tx_release(%s)\n",info->device_name); + spin_lock_irqsave(&info->lock,flags); if (!info->tx_enabled) tx_start(info); @@ -810,7 +810,7 @@ static int bh_action(MGSLPC_INFO *info) { unsigned long flags; int rc = 0; - + spin_lock_irqsave(&info->lock,flags); if (info->pending_bh & BH_RECEIVE) { @@ -829,9 +829,9 @@ static int bh_action(MGSLPC_INFO *info) info->bh_running = 0; info->bh_requested = 0; } - + spin_unlock_irqrestore(&info->lock,flags); - + return rc; } @@ -842,22 +842,22 @@ static void bh_handler(struct work_struct *work) if (!info) return; - + if (debug_level >= DEBUG_LEVEL_BH) printk( "%s(%d):bh_handler(%s) entry\n", __FILE__,__LINE__,info->device_name); - + info->bh_running = 1; while((action = bh_action(info)) != 0) { - + /* Process work item */ if ( debug_level >= DEBUG_LEVEL_BH ) printk( "%s(%d):bh_handler() work item action=%d\n", __FILE__,__LINE__,action); switch (action) { - + case BH_RECEIVE: while(rx_get_frame(info)); break; @@ -897,7 +897,7 @@ static void bh_status(MGSLPC_INFO *info) info->cts_chkcount = 0; } -/* eom: non-zero = end of frame */ +/* eom: non-zero = end of frame */ static void rx_ready_hdlc(MGSLPC_INFO *info, int eom) { unsigned char data[2]; @@ -906,7 +906,7 @@ static void rx_ready_hdlc(MGSLPC_INFO *info, int eom) if (debug_level >= DEBUG_LEVEL_ISR) printk("%s(%d):rx_ready_hdlc(eom=%d)\n",__FILE__,__LINE__,eom); - + if (!info->rx_enabled) return; @@ -920,12 +920,12 @@ static void rx_ready_hdlc(MGSLPC_INFO *info, int eom) } if (eom) { - /* end of frame, get FIFO count from RBCL register */ + /* end of frame, get FIFO count from RBCL register */ if (!(fifo_count = (unsigned char)(read_reg(info, CHA+RBCL) & 0x1f))) fifo_count = 32; } else fifo_count = 32; - + do { if (fifo_count == 1) { read_count = 1; @@ -969,7 +969,7 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd) struct mgsl_icount *icount = &info->icount; if (tcd) { - /* early termination, get FIFO count from RBCL register */ + /* early termination, get FIFO count from RBCL register */ fifo_count = (unsigned char)(read_reg(info, CHA+RBCL) & 0x1f); /* Zero fifo count could mean 0 or 32 bytes available. @@ -981,7 +981,7 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd) fifo_count = 32; tty_buffer_request_room(tty, fifo_count); - /* Flush received async data to receive data buffer. */ + /* Flush received async data to receive data buffer. */ while (fifo_count) { data = read_reg(info, CHA + RXFIFO); status = read_reg(info, CHA + RXFIFO); @@ -995,7 +995,7 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd) // BIT6:framing error if (status & (BIT7 + BIT6)) { - if (status & BIT7) + if (status & BIT7) icount->parity++; else icount->frame++; @@ -1003,7 +1003,7 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd) /* discard char if tty control flags say so */ if (status & info->ignore_status_mask) continue; - + status &= info->read_status_mask; if (status & BIT7) @@ -1022,7 +1022,7 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd) __FILE__,__LINE__,icount->rx,icount->brk, icount->parity,icount->frame,icount->overrun); } - + if (work) tty_flip_buffer_push(tty); } @@ -1032,7 +1032,7 @@ static void tx_done(MGSLPC_INFO *info) { if (!info->tx_active) return; - + info->tx_active = 0; info->tx_aborting = 0; @@ -1040,8 +1040,8 @@ static void tx_done(MGSLPC_INFO *info) return; info->tx_count = info->tx_put = info->tx_get = 0; - del_timer(&info->tx_timer); - + del_timer(&info->tx_timer); + if (info->drop_rts_on_tx_done) { get_signals(info); if (info->serial_signals & SerialSignal_RTS) { @@ -1054,7 +1054,7 @@ static void tx_done(MGSLPC_INFO *info) #if SYNCLINK_GENERIC_HDLC if (info->netcount) hdlcdev_tx_done(info); - else + else #endif { if (info->tty->stopped || info->tty->hw_stopped) { @@ -1090,7 +1090,7 @@ static void tx_ready(MGSLPC_INFO *info) while (info->tx_count && fifo_count) { c = min(2, min_t(int, fifo_count, min(info->tx_count, TXBUFSIZE - info->tx_get))); - + if (c == 1) { write_reg(info, CHA + TXFIFO, *(info->tx_buf + info->tx_get)); } else { @@ -1220,9 +1220,9 @@ static void ri_change(MGSLPC_INFO *info) } /* Interrupt service routine entry point. - * + * * Arguments: - * + * * irq interrupt number that caused interrupt * dev_id device ID supplied during interrupt registration */ @@ -1233,18 +1233,18 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id) unsigned char gis, pis; int count=0; - if (debug_level >= DEBUG_LEVEL_ISR) + if (debug_level >= DEBUG_LEVEL_ISR) printk("mgslpc_isr(%d) entry.\n", irq); if (!info) return IRQ_NONE; - + if (!(info->p_dev->_locked)) return IRQ_HANDLED; spin_lock(&info->lock); while ((gis = read_reg(info, CHA + GIS))) { - if (debug_level >= DEBUG_LEVEL_ISR) + if (debug_level >= DEBUG_LEVEL_ISR) printk("mgslpc_isr %s gis=%04X\n", info->device_name,gis); if ((gis & 0x70) || count > 1000) { @@ -1268,7 +1268,7 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id) irq_disable(info, CHA, IRQ_TIMER); } - /* receive IRQs */ + /* receive IRQs */ if (isr & IRQ_EXITHUNT) { info->icount.exithunt++; wake_up_interruptible(&info->event_wait_q); @@ -1283,12 +1283,12 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id) } if (isr & (IRQ_RXEOM + IRQ_RXFIFO)) { if (info->params.mode == MGSL_MODE_HDLC) - rx_ready_hdlc(info, isr & IRQ_RXEOM); + rx_ready_hdlc(info, isr & IRQ_RXEOM); else rx_ready_async(info, isr & IRQ_RXEOM); } - /* transmit IRQs */ + /* transmit IRQs */ if (isr & IRQ_UNDERRUN) { if (info->tx_aborting) info->icount.txabort++; @@ -1311,13 +1311,13 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id) ri_change(info); } } - - /* Request bottom half processing if there's something + + /* Request bottom half processing if there's something * for it to do and the bh is not already running */ if (info->pending_bh && !info->bh_running && !info->bh_requested) { - if ( debug_level >= DEBUG_LEVEL_ISR ) + if ( debug_level >= DEBUG_LEVEL_ISR ) printk("%s(%d):%s queueing bh task.\n", __FILE__,__LINE__,info->device_name); schedule_work(&info->task); @@ -1325,8 +1325,8 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id) } spin_unlock(&info->lock); - - if (debug_level >= DEBUG_LEVEL_ISR) + + if (debug_level >= DEBUG_LEVEL_ISR) printk("%s(%d):mgslpc_isr(%d)exit.\n", __FILE__,__LINE__,irq); @@ -1338,13 +1338,13 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id) static int startup(MGSLPC_INFO * info) { int retval = 0; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):startup(%s)\n",__FILE__,__LINE__,info->device_name); - + if (info->flags & ASYNC_INITIALIZED) return 0; - + if (!info->tx_buf) { /* allocate a page of memory for a transmit buffer */ info->tx_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL); @@ -1356,18 +1356,18 @@ static int startup(MGSLPC_INFO * info) } info->pending_bh = 0; - + memset(&info->icount, 0, sizeof(info->icount)); setup_timer(&info->tx_timer, tx_timeout, (unsigned long)info); /* Allocate and claim adapter resources */ retval = claim_resources(info); - + /* perform existance check and diagnostics */ if ( !retval ) retval = adapter_test(info); - + if ( retval ) { if (capable(CAP_SYS_ADMIN) && info->tty) set_bit(TTY_IO_ERROR, &info->tty->flags); @@ -1377,12 +1377,12 @@ static int startup(MGSLPC_INFO * info) /* program hardware for current parameters */ mgslpc_change_params(info); - + if (info->tty) clear_bit(TTY_IO_ERROR, &info->tty->flags); info->flags |= ASYNC_INITIALIZED; - + return 0; } @@ -1391,7 +1391,7 @@ static int startup(MGSLPC_INFO * info) static void shutdown(MGSLPC_INFO * info) { unsigned long flags; - + if (!(info->flags & ASYNC_INITIALIZED)) return; @@ -1418,16 +1418,16 @@ static void shutdown(MGSLPC_INFO * info) /* TODO:disable interrupts instead of reset to preserve signal states */ reset_device(info); - + if (!info->tty || info->tty->termios->c_cflag & HUPCL) { info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS); set_signals(info); } - + spin_unlock_irqrestore(&info->lock,flags); - release_resources(info); - + release_resources(info); + if (info->tty) set_bit(TTY_IO_ERROR, &info->tty->flags); @@ -1439,18 +1439,18 @@ static void mgslpc_program_hw(MGSLPC_INFO *info) unsigned long flags; spin_lock_irqsave(&info->lock,flags); - + rx_stop(info); tx_stop(info); info->tx_count = info->tx_put = info->tx_get = 0; - + if (info->params.mode == MGSL_MODE_HDLC || info->netcount) hdlc_mode(info); else async_mode(info); - + set_signals(info); - + info->dcd_chkcount = 0; info->cts_chkcount = 0; info->ri_chkcount = 0; @@ -1459,10 +1459,10 @@ static void mgslpc_program_hw(MGSLPC_INFO *info) irq_enable(info, CHB, IRQ_DCD | IRQ_CTS); port_irq_enable(info, (unsigned char) PVR_DSR | PVR_RI); get_signals(info); - + if (info->netcount || info->tty->termios->c_cflag & CREAD) rx_start(info); - + spin_unlock_irqrestore(&info->lock,flags); } @@ -1475,11 +1475,11 @@ static void mgslpc_change_params(MGSLPC_INFO *info) if (!info->tty || !info->tty->termios) return; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_change_params(%s)\n", __FILE__,__LINE__, info->device_name ); - + cflag = info->tty->termios->c_cflag; /* if B0 rate (hangup) specified then negate DTR and RTS */ @@ -1488,9 +1488,9 @@ static void mgslpc_change_params(MGSLPC_INFO *info) info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; else info->serial_signals &= ~(SerialSignal_RTS + SerialSignal_DTR); - + /* byte size and parity */ - + switch (cflag & CSIZE) { case CS5: info->params.data_bits = 5; break; case CS6: info->params.data_bits = 6; break; @@ -1498,7 +1498,7 @@ static void mgslpc_change_params(MGSLPC_INFO *info) case CS8: info->params.data_bits = 8; break; default: info->params.data_bits = 7; break; } - + if (cflag & CSTOPB) info->params.stop_bits = 2; else @@ -1519,7 +1519,7 @@ static void mgslpc_change_params(MGSLPC_INFO *info) /* calculate number of jiffies to transmit a full * FIFO (32 bytes) at specified data rate */ - bits_per_char = info->params.data_bits + + bits_per_char = info->params.data_bits + info->params.stop_bits + 1; /* if port data rate is set to 460800 or less then @@ -1529,9 +1529,9 @@ static void mgslpc_change_params(MGSLPC_INFO *info) if (info->params.data_rate <= 460800) { info->params.data_rate = tty_get_baud_rate(info->tty); } - + if ( info->params.data_rate ) { - info->timeout = (32*HZ*bits_per_char) / + info->timeout = (32*HZ*bits_per_char) / info->params.data_rate; } info->timeout += HZ/50; /* Add .02 seconds of slop */ @@ -1540,14 +1540,14 @@ static void mgslpc_change_params(MGSLPC_INFO *info) info->flags |= ASYNC_CTS_FLOW; else info->flags &= ~ASYNC_CTS_FLOW; - + if (cflag & CLOCAL) info->flags &= ~ASYNC_CHECK_CD; else info->flags |= ASYNC_CHECK_CD; /* process tty input control flags */ - + info->read_status_mask = 0; if (I_INPCK(info->tty)) info->read_status_mask |= BIT7 | BIT6; @@ -1576,7 +1576,7 @@ static void mgslpc_put_char(struct tty_struct *tty, unsigned char ch) return; spin_lock_irqsave(&info->lock,flags); - + if (info->params.mode == MGSL_MODE_ASYNC || !info->tx_active) { if (info->tx_count < TXBUFSIZE - 1) { info->tx_buf[info->tx_put++] = ch; @@ -1584,7 +1584,7 @@ static void mgslpc_put_char(struct tty_struct *tty, unsigned char ch) info->tx_count++; } } - + spin_unlock_irqrestore(&info->lock,flags); } @@ -1595,11 +1595,11 @@ static void mgslpc_flush_chars(struct tty_struct *tty) { MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk( "%s(%d):mgslpc_flush_chars() entry on %s tx_count=%d\n", __FILE__,__LINE__,info->device_name,info->tx_count); - + if (mgslpc_paranoia_check(info, tty->name, "mgslpc_flush_chars")) return; @@ -1618,13 +1618,13 @@ static void mgslpc_flush_chars(struct tty_struct *tty) } /* Send a block of data - * + * * Arguments: - * + * * tty pointer to tty information structure * buf pointer to buffer containing send data * count size of send data in bytes - * + * * Returns: number of characters written */ static int mgslpc_write(struct tty_struct * tty, @@ -1633,11 +1633,11 @@ static int mgslpc_write(struct tty_struct * tty, int c, ret = 0; MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk( "%s(%d):mgslpc_write(%s) count=%d\n", __FILE__,__LINE__,info->device_name,count); - + if (mgslpc_paranoia_check(info, tty->name, "mgslpc_write") || !info->tx_buf) goto cleanup; @@ -1659,7 +1659,7 @@ static int mgslpc_write(struct tty_struct * tty, TXBUFSIZE - info->tx_put)); if (c <= 0) break; - + memcpy(info->tx_buf + info->tx_put, buf, c); spin_lock_irqsave(&info->lock,flags); @@ -1678,7 +1678,7 @@ static int mgslpc_write(struct tty_struct * tty, tx_start(info); spin_unlock_irqrestore(&info->lock,flags); } -cleanup: +cleanup: if (debug_level >= DEBUG_LEVEL_INFO) printk( "%s(%d):mgslpc_write(%s) returning=%d\n", __FILE__,__LINE__,info->device_name,ret); @@ -1691,7 +1691,7 @@ static int mgslpc_write_room(struct tty_struct *tty) { MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; int ret; - + if (mgslpc_paranoia_check(info, tty->name, "mgslpc_write_room")) return 0; @@ -1706,7 +1706,7 @@ static int mgslpc_write_room(struct tty_struct *tty) if (ret < 0) ret = 0; } - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_write_room(%s)=%d\n", __FILE__,__LINE__, info->device_name, ret); @@ -1719,14 +1719,14 @@ static int mgslpc_chars_in_buffer(struct tty_struct *tty) { MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; int rc; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_chars_in_buffer(%s)\n", __FILE__,__LINE__, info->device_name ); - + if (mgslpc_paranoia_check(info, tty->name, "mgslpc_chars_in_buffer")) return 0; - + if (info->params.mode == MGSL_MODE_HDLC) rc = info->tx_active ? info->max_frame_size : 0; else @@ -1735,7 +1735,7 @@ static int mgslpc_chars_in_buffer(struct tty_struct *tty) if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_chars_in_buffer(%s)=%d\n", __FILE__,__LINE__, info->device_name, rc); - + return rc; } @@ -1745,17 +1745,17 @@ static void mgslpc_flush_buffer(struct tty_struct *tty) { MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_flush_buffer(%s) entry\n", __FILE__,__LINE__, info->device_name ); - + if (mgslpc_paranoia_check(info, tty->name, "mgslpc_flush_buffer")) return; - - spin_lock_irqsave(&info->lock,flags); + + spin_lock_irqsave(&info->lock,flags); info->tx_count = info->tx_put = info->tx_get = 0; - del_timer(&info->tx_timer); + del_timer(&info->tx_timer); spin_unlock_irqrestore(&info->lock,flags); wake_up_interruptible(&tty->write_wait); @@ -1772,7 +1772,7 @@ static void mgslpc_send_xchar(struct tty_struct *tty, char ch) if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_send_xchar(%s,%d)\n", __FILE__,__LINE__, info->device_name, ch ); - + if (mgslpc_paranoia_check(info, tty->name, "mgslpc_send_xchar")) return; @@ -1791,17 +1791,17 @@ static void mgslpc_throttle(struct tty_struct * tty) { MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_throttle(%s) entry\n", __FILE__,__LINE__, info->device_name ); if (mgslpc_paranoia_check(info, tty->name, "mgslpc_throttle")) return; - + if (I_IXOFF(tty)) mgslpc_send_xchar(tty, STOP_CHAR(tty)); - + if (tty->termios->c_cflag & CRTSCTS) { spin_lock_irqsave(&info->lock,flags); info->serial_signals &= ~SerialSignal_RTS; @@ -1816,21 +1816,21 @@ static void mgslpc_unthrottle(struct tty_struct * tty) { MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_unthrottle(%s) entry\n", __FILE__,__LINE__, info->device_name ); if (mgslpc_paranoia_check(info, tty->name, "mgslpc_unthrottle")) return; - + if (I_IXOFF(tty)) { if (info->x_char) info->x_char = 0; else mgslpc_send_xchar(tty, START_CHAR(tty)); } - + if (tty->termios->c_cflag & CRTSCTS) { spin_lock_irqsave(&info->lock,flags); info->serial_signals |= SerialSignal_RTS; @@ -1870,9 +1870,9 @@ static int get_params(MGSLPC_INFO * info, MGSL_PARAMS __user *user_params) } /* set the serial parameters - * + * * Arguments: - * + * * info pointer to device instance data * new_params user buffer containing new serial params * @@ -1883,7 +1883,7 @@ static int set_params(MGSLPC_INFO * info, MGSL_PARAMS __user *new_params) unsigned long flags; MGSL_PARAMS tmp_params; int err; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):set_params %s\n", __FILE__,__LINE__, info->device_name ); @@ -1894,13 +1894,13 @@ static int set_params(MGSLPC_INFO * info, MGSL_PARAMS __user *new_params) __FILE__,__LINE__,info->device_name); return -EFAULT; } - + spin_lock_irqsave(&info->lock,flags); memcpy(&info->params,&tmp_params,sizeof(MGSL_PARAMS)); spin_unlock_irqrestore(&info->lock,flags); - + mgslpc_change_params(info); - + return 0; } @@ -1963,10 +1963,10 @@ static int set_interface(MGSLPC_INFO * info, int if_mode) static int set_txenable(MGSLPC_INFO * info, int enable) { unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("set_txenable(%s,%d)\n", info->device_name, enable); - + spin_lock_irqsave(&info->lock,flags); if (enable) { if (!info->tx_enabled) @@ -1982,10 +1982,10 @@ static int set_txenable(MGSLPC_INFO * info, int enable) static int tx_abort(MGSLPC_INFO * info) { unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("tx_abort(%s)\n", info->device_name); - + spin_lock_irqsave(&info->lock,flags); if (info->tx_active && info->tx_count && info->params.mode == MGSL_MODE_HDLC) { @@ -2002,10 +2002,10 @@ static int tx_abort(MGSLPC_INFO * info) static int set_rxenable(MGSLPC_INFO * info, int enable) { unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("set_rxenable(%s,%d)\n", info->device_name, enable); - + spin_lock_irqsave(&info->lock,flags); if (enable) { if (!info->rx_enabled) @@ -2019,7 +2019,7 @@ static int set_rxenable(MGSLPC_INFO * info, int enable) } /* wait for specified event to occur - * + * * Arguments: info pointer to device instance data * mask pointer to bitmask of events to wait for * Return Value: 0 if successful and bit mask updated with @@ -2040,7 +2040,7 @@ static int wait_events(MGSLPC_INFO * info, int __user *mask_ptr) COPY_FROM_USER(rc,&mask, mask_ptr, sizeof(int)); if (rc) return -EFAULT; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("wait_events(%s,%d)\n", info->device_name, mask); @@ -2062,24 +2062,24 @@ static int wait_events(MGSLPC_INFO * info, int __user *mask_ptr) /* save current irq counts */ cprev = info->icount; oldsigs = info->input_signal_events; - + if ((info->params.mode == MGSL_MODE_HDLC) && (mask & MgslEvent_ExitHuntMode)) irq_enable(info, CHA, IRQ_EXITHUNT); - + set_current_state(TASK_INTERRUPTIBLE); add_wait_queue(&info->event_wait_q, &wait); - + spin_unlock_irqrestore(&info->lock,flags); - - + + for(;;) { schedule(); if (signal_pending(current)) { rc = -ERESTARTSYS; break; } - + /* get current irq counts */ spin_lock_irqsave(&info->lock,flags); cnow = info->icount; @@ -2115,11 +2115,11 @@ static int wait_events(MGSLPC_INFO * info, int __user *mask_ptr) (cnow.rxidle != cprev.rxidle ? MgslEvent_IdleReceived:0) ); if (events) break; - + cprev = cnow; oldsigs = newsigs; } - + remove_wait_queue(&info->event_wait_q, &wait); set_current_state(TASK_RUNNING); @@ -2247,42 +2247,42 @@ static void mgslpc_break(struct tty_struct *tty, int break_state) { MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_break(%s,%d)\n", __FILE__,__LINE__, info->device_name, break_state); - + if (mgslpc_paranoia_check(info, tty->name, "mgslpc_break")) return; spin_lock_irqsave(&info->lock,flags); if (break_state == -1) set_reg_bits(info, CHA+DAFO, BIT6); - else + else clear_reg_bits(info, CHA+DAFO, BIT6); spin_unlock_irqrestore(&info->lock,flags); } /* Service an IOCTL request - * + * * Arguments: - * + * * tty pointer to tty instance data * file pointer to associated file object for device * cmd IOCTL command code * arg command argument/context - * + * * Return Value: 0 if success, otherwise error code */ static int mgslpc_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) { MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_ioctl %s cmd=%08X\n", __FILE__,__LINE__, info->device_name, cmd ); - + if (mgslpc_paranoia_check(info, tty->name, "mgslpc_ioctl")) return -ENODEV; @@ -2302,7 +2302,7 @@ static int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg) struct serial_icounter_struct __user *p_cuser; /* user space */ void __user *argp = (void __user *)arg; unsigned long flags; - + switch (cmd) { case MGSL_IOCGPARAMS: return get_params(info, argp); @@ -2363,9 +2363,9 @@ static int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg) } /* Set new termios settings - * + * * Arguments: - * + * * tty pointer to tty structure * termios pointer to buffer to hold returned old termios */ @@ -2373,14 +2373,14 @@ static void mgslpc_set_termios(struct tty_struct *tty, struct ktermios *old_term { MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_set_termios %s\n", __FILE__,__LINE__, tty->driver->name ); - + /* just return if nothing has changed */ if ((tty->termios->c_cflag == old_termios->c_cflag) - && (RELEVANT_IFLAG(tty->termios->c_iflag) + && (RELEVANT_IFLAG(tty->termios->c_iflag) == RELEVANT_IFLAG(old_termios->c_iflag))) return; @@ -2394,12 +2394,12 @@ static void mgslpc_set_termios(struct tty_struct *tty, struct ktermios *old_term set_signals(info); spin_unlock_irqrestore(&info->lock,flags); } - + /* Handle transition away from B0 status */ if (!(old_termios->c_cflag & CBAUD) && tty->termios->c_cflag & CBAUD) { info->serial_signals |= SerialSignal_DTR; - if (!(tty->termios->c_cflag & CRTSCTS) || + if (!(tty->termios->c_cflag & CRTSCTS) || !test_bit(TTY_THROTTLED, &tty->flags)) { info->serial_signals |= SerialSignal_RTS; } @@ -2407,7 +2407,7 @@ static void mgslpc_set_termios(struct tty_struct *tty, struct ktermios *old_term set_signals(info); spin_unlock_irqrestore(&info->lock,flags); } - + /* Handle turning off CRTSCTS */ if (old_termios->c_cflag & CRTSCTS && !(tty->termios->c_cflag & CRTSCTS)) { @@ -2422,17 +2422,17 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp) if (mgslpc_paranoia_check(info, tty->name, "mgslpc_close")) return; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_close(%s) entry, count=%d\n", __FILE__,__LINE__, info->device_name, info->count); - + if (!info->count) return; if (tty_hung_up_p(filp)) goto cleanup; - + if ((tty->count == 1) && (info->count != 1)) { /* * tty->count is 1 and the tty structure will be freed. @@ -2443,30 +2443,30 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp) "info->count is %d\n", info->count); info->count = 1; } - + info->count--; - + /* if at least one open remaining, leave hardware active */ if (info->count) goto cleanup; - + info->flags |= ASYNC_CLOSING; - - /* set tty->closing to notify line discipline to + + /* set tty->closing to notify line discipline to * only process XON/XOFF characters. Only the N_TTY * discipline appears to use this (ppp does not). */ tty->closing = 1; - + /* wait for transmit data to clear all layers */ - + if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE) { if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_close(%s) calling tty_wait_until_sent\n", __FILE__,__LINE__, info->device_name ); tty_wait_until_sent(tty, info->closing_wait); } - + if (info->flags & ASYNC_INITIALIZED) mgslpc_wait_until_sent(tty, info->timeout); @@ -2474,24 +2474,24 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp) tty->driver->flush_buffer(tty); ldisc_flush_buffer(tty); - + shutdown(info); - + tty->closing = 0; info->tty = NULL; - + if (info->blocked_open) { if (info->close_delay) { msleep_interruptible(jiffies_to_msecs(info->close_delay)); } wake_up_interruptible(&info->open_wait); } - + info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); - + wake_up_interruptible(&info->close_wait); - -cleanup: + +cleanup: if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__,__LINE__, tty->driver->name, info->count); @@ -2510,31 +2510,31 @@ static void mgslpc_wait_until_sent(struct tty_struct *tty, int timeout) if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_wait_until_sent(%s) entry\n", __FILE__,__LINE__, info->device_name ); - + if (mgslpc_paranoia_check(info, tty->name, "mgslpc_wait_until_sent")) return; if (!(info->flags & ASYNC_INITIALIZED)) goto exit; - + orig_jiffies = jiffies; - + /* Set check interval to 1/5 of estimated time to * send a character, and make it at least 1. The check * interval should also be less than the timeout. * Note: use tight timings here to satisfy the NIST-PCTS. - */ - + */ + if ( info->params.data_rate ) { char_time = info->timeout/(32 * 5); if (!char_time) char_time++; } else char_time = 1; - + if (timeout) char_time = min_t(unsigned long, char_time, timeout); - + if (info->params.mode == MGSL_MODE_HDLC) { while (info->tx_active) { msleep_interruptible(jiffies_to_msecs(char_time)); @@ -2553,7 +2553,7 @@ static void mgslpc_wait_until_sent(struct tty_struct *tty, int timeout) break; } } - + exit: if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_wait_until_sent(%s) exit\n", @@ -2566,18 +2566,18 @@ static void mgslpc_wait_until_sent(struct tty_struct *tty, int timeout) static void mgslpc_hangup(struct tty_struct *tty) { MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_hangup(%s)\n", __FILE__,__LINE__, info->device_name ); - + if (mgslpc_paranoia_check(info, tty->name, "mgslpc_hangup")) return; mgslpc_flush_buffer(tty); shutdown(info); - - info->count = 0; + + info->count = 0; info->flags &= ~ASYNC_NORMAL_ACTIVE; info->tty = NULL; @@ -2594,7 +2594,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, int retval; int do_clocal = 0, extra_count = 0; unsigned long flags; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):block_til_ready on %s\n", __FILE__,__LINE__, tty->driver->name ); @@ -2615,10 +2615,10 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, * mgslpc_close() knows when to free things. We restore it upon * exit, either normal or abnormal. */ - + retval = 0; add_wait_queue(&info->open_wait, &wait); - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):block_til_ready before block on %s count=%d\n", __FILE__,__LINE__, tty->driver->name, info->count ); @@ -2630,7 +2630,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, } spin_unlock_irqrestore(&info->lock, flags); info->blocked_open++; - + while (1) { if ((tty->termios->c_cflag & CBAUD)) { spin_lock_irqsave(&info->lock,flags); @@ -2638,50 +2638,50 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, set_signals(info); spin_unlock_irqrestore(&info->lock,flags); } - + set_current_state(TASK_INTERRUPTIBLE); - + if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)){ retval = (info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS; break; } - + spin_lock_irqsave(&info->lock,flags); get_signals(info); spin_unlock_irqrestore(&info->lock,flags); - + if (!(info->flags & ASYNC_CLOSING) && (do_clocal || (info->serial_signals & SerialSignal_DCD)) ) { break; } - + if (signal_pending(current)) { retval = -ERESTARTSYS; break; } - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):block_til_ready blocking on %s count=%d\n", __FILE__,__LINE__, tty->driver->name, info->count ); - + schedule(); } - + set_current_state(TASK_RUNNING); remove_wait_queue(&info->open_wait, &wait); - + if (extra_count) info->count++; info->blocked_open--; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):block_til_ready after blocking on %s count=%d\n", __FILE__,__LINE__, tty->driver->name, info->count ); - + if (!retval) info->flags |= ASYNC_NORMAL_ACTIVE; - + return retval; } @@ -2691,7 +2691,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp) int retval, line; unsigned long flags; - /* verify range of specified line number */ + /* verify range of specified line number */ line = tty->index; if ((line < 0) || (line >= mgslpc_device_count)) { printk("%s(%d):mgslpc_open with invalid line #%d.\n", @@ -2705,10 +2705,10 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp) info = info->next_device; if (mgslpc_paranoia_check(info, tty->name, "mgslpc_open")) return -ENODEV; - + tty->driver_data = info; info->tty = tty; - + if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):mgslpc_open(%s), old ref count = %d\n", __FILE__,__LINE__,tty->driver->name, info->count); @@ -2721,7 +2721,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp) -EAGAIN : -ERESTARTSYS); goto cleanup; } - + info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; spin_lock_irqsave(&info->netlock, flags); @@ -2752,15 +2752,15 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp) printk("%s(%d):mgslpc_open(%s) success\n", __FILE__,__LINE__, info->device_name); retval = 0; - -cleanup: + +cleanup: if (retval) { if (tty->count == 1) info->tty = NULL; /* tty layer will release tty struct */ if(info->count) info->count--; } - + return retval; } @@ -2781,7 +2781,7 @@ static inline int line_info(char *buf, MGSLPC_INFO *info) spin_lock_irqsave(&info->lock,flags); get_signals(info); spin_unlock_irqrestore(&info->lock,flags); - + stat_buf[0] = 0; stat_buf[1] = 0; if (info->serial_signals & SerialSignal_RTS) @@ -2805,7 +2805,7 @@ static inline int line_info(char *buf, MGSLPC_INFO *info) if (info->icount.txabort) ret += sprintf(buf+ret, " txabort:%d", info->icount.txabort); if (info->icount.rxshort) - ret += sprintf(buf+ret, " rxshort:%d", info->icount.rxshort); + ret += sprintf(buf+ret, " rxshort:%d", info->icount.rxshort); if (info->icount.rxlong) ret += sprintf(buf+ret, " rxlong:%d", info->icount.rxlong); if (info->icount.rxover) @@ -2820,18 +2820,18 @@ static inline int line_info(char *buf, MGSLPC_INFO *info) if (info->icount.parity) ret += sprintf(buf+ret, " pe:%d", info->icount.parity); if (info->icount.brk) - ret += sprintf(buf+ret, " brk:%d", info->icount.brk); + ret += sprintf(buf+ret, " brk:%d", info->icount.brk); if (info->icount.overrun) ret += sprintf(buf+ret, " oe:%d", info->icount.overrun); } - + /* Append serial signal status to end */ ret += sprintf(buf+ret, " %s\n", stat_buf+1); - + ret += sprintf(buf+ret, "txactive=%d bh_req=%d bh_run=%d pending_bh=%x\n", info->tx_active,info->bh_requested,info->bh_running, info->pending_bh); - + return ret; } @@ -2843,9 +2843,9 @@ static int mgslpc_read_proc(char *page, char **start, off_t off, int count, int len = 0, l; off_t begin = 0; MGSLPC_INFO *info; - + len += sprintf(page, "synclink driver:%s\n", driver_version); - + info = mgslpc_device_list; while( info ) { l = line_info(page + len, info); @@ -2902,7 +2902,7 @@ static int claim_resources(MGSLPC_INFO *info) printk( "Cant allocate rx buffer %s\n", info->device_name); release_resources(info); return -ENODEV; - } + } return 0; } @@ -2915,7 +2915,7 @@ static void release_resources(MGSLPC_INFO *info) /* Add the specified device instance data structure to the * global linked list of devices and increment the device count. - * + * * Arguments: info pointer to device instance data */ static void mgslpc_add_device(MGSLPC_INFO *info) @@ -2923,7 +2923,7 @@ static void mgslpc_add_device(MGSLPC_INFO *info) info->next_device = NULL; info->line = mgslpc_device_count; sprintf(info->device_name,"ttySLP%d",info->line); - + if (info->line < MAX_DEVICE_COUNT) { if (maxframe[info->line]) info->max_frame_size = maxframe[info->line]; @@ -2931,21 +2931,21 @@ static void mgslpc_add_device(MGSLPC_INFO *info) } mgslpc_device_count++; - + if (!mgslpc_device_list) mgslpc_device_list = info; - else { + else { MGSLPC_INFO *current_dev = mgslpc_device_list; while( current_dev->next_device ) current_dev = current_dev->next_device; current_dev->next_device = info; } - + if (info->max_frame_size < 4096) info->max_frame_size = 4096; else if (info->max_frame_size > 65535) info->max_frame_size = 65535; - + printk( "SyncLink PC Card %s:IO=%04X IRQ=%d\n", info->device_name, info->io_base, info->irq_level); @@ -3060,7 +3060,7 @@ static int __init synclink_cs_init(void) } /* Initialize the tty_driver structure */ - + serial_driver->owner = THIS_MODULE; serial_driver->driver_name = "synclink_cs"; serial_driver->name = "ttySLP"; @@ -3081,11 +3081,11 @@ static int __init synclink_cs_init(void) serial_driver = NULL; goto error; } - + printk("%s %s, tty major#%d\n", driver_name, driver_version, serial_driver->major); - + return 0; error: @@ -3093,7 +3093,7 @@ static int __init synclink_cs_init(void) return rc; } -static void __exit synclink_cs_exit(void) +static void __exit synclink_cs_exit(void) { synclink_cs_cleanup(); } @@ -3106,8 +3106,8 @@ static void mgslpc_set_rate(MGSLPC_INFO *info, unsigned char channel, unsigned i unsigned int M, N; unsigned char val; - /* note:standard BRG mode is broken in V3.2 chip - * so enhanced mode is always used + /* note:standard BRG mode is broken in V3.2 chip + * so enhanced mode is always used */ if (rate) { @@ -3126,7 +3126,7 @@ static void mgslpc_set_rate(MGSLPC_INFO *info, unsigned char channel, unsigned i * divisor = (N+1)*2^M * * Note: M *must* not be zero (causes asymetric duty cycle) - */ + */ write_reg(info, (unsigned char) (channel + BGR), (unsigned char) ((M << 6) + N)); val = read_reg(info, (unsigned char) (channel + CCR2)) & 0x3f; @@ -3140,7 +3140,7 @@ static void mgslpc_set_rate(MGSLPC_INFO *info, unsigned char channel, unsigned i static void enable_auxclk(MGSLPC_INFO *info) { unsigned char val; - + /* MODE * * 07..06 MDS[1..0] 10 = transparent HDLC mode @@ -3152,14 +3152,14 @@ static void enable_auxclk(MGSLPC_INFO *info) * 00 TLP Test Loop, 0 = no loop * * 1000 0010 - */ + */ val = 0x82; - - /* channel B RTS is used to enable AUXCLK driver on SP505 */ + + /* channel B RTS is used to enable AUXCLK driver on SP505 */ if (info->params.mode == MGSL_MODE_HDLC && info->params.clock_speed) val |= BIT2; write_reg(info, CHB + MODE, val); - + /* CCR0 * * 07 PU Power Up, 1=active, 0=power down @@ -3169,9 +3169,9 @@ static void enable_auxclk(MGSLPC_INFO *info) * 01..00 SM[1..0] Serial Mode, 00=HDLC * * 11000000 - */ + */ write_reg(info, CHB + CCR0, 0xc0); - + /* CCR1 * * 07 SFLG Shared Flag, 0 = disable shared flags @@ -3182,9 +3182,9 @@ static void enable_auxclk(MGSLPC_INFO *info) * 02..00 CM[2..0] Clock Mode * * 0001 0111 - */ + */ write_reg(info, CHB + CCR1, 0x17); - + /* CCR2 (Channel B) * * 07..06 BGR[9..8] Baud rate bits 9..8 @@ -3196,12 +3196,12 @@ static void enable_auxclk(MGSLPC_INFO *info) * 00 DIV, data inversion 0=disabled, 1=enabled * * 0011 1000 - */ + */ if (info->params.mode == MGSL_MODE_HDLC && info->params.clock_speed) write_reg(info, CHB + CCR2, 0x38); else write_reg(info, CHB + CCR2, 0x30); - + /* CCR4 * * 07 MCK4 Master Clock Divide by 4, 1=enabled @@ -3212,37 +3212,37 @@ static void enable_auxclk(MGSLPC_INFO *info) * 01..00 RFT[1..0] RxFIFO Threshold 00=32 bytes * * 0101 0000 - */ + */ write_reg(info, CHB + CCR4, 0x50); - + /* if auxclk not enabled, set internal BRG so * CTS transitions can be detected (requires TxC) - */ + */ if (info->params.mode == MGSL_MODE_HDLC && info->params.clock_speed) mgslpc_set_rate(info, CHB, info->params.clock_speed); else mgslpc_set_rate(info, CHB, 921600); } -static void loopback_enable(MGSLPC_INFO *info) +static void loopback_enable(MGSLPC_INFO *info) { unsigned char val; - - /* CCR1:02..00 CM[2..0] Clock Mode = 111 (clock mode 7) */ + + /* CCR1:02..00 CM[2..0] Clock Mode = 111 (clock mode 7) */ val = read_reg(info, CHA + CCR1) | (BIT2 + BIT1 + BIT0); write_reg(info, CHA + CCR1, val); - - /* CCR2:04 SSEL Clock source select, 1=submode b */ + + /* CCR2:04 SSEL Clock source select, 1=submode b */ val = read_reg(info, CHA + CCR2) | (BIT4 + BIT5); write_reg(info, CHA + CCR2, val); - - /* set LinkSpeed if available, otherwise default to 2Mbps */ + + /* set LinkSpeed if available, otherwise default to 2Mbps */ if (info->params.clock_speed) mgslpc_set_rate(info, CHA, info->params.clock_speed); else mgslpc_set_rate(info, CHA, 1843200); - - /* MODE:00 TLP Test Loop, 1=loopback enabled */ + + /* MODE:00 TLP Test Loop, 1=loopback enabled */ val = read_reg(info, CHA + MODE) | BIT0; write_reg(info, CHA + MODE, val); } @@ -3252,36 +3252,36 @@ static void hdlc_mode(MGSLPC_INFO *info) unsigned char val; unsigned char clkmode, clksubmode; - /* disable all interrupts */ + /* disable all interrupts */ irq_disable(info, CHA, 0xffff); irq_disable(info, CHB, 0xffff); port_irq_disable(info, 0xff); - - /* assume clock mode 0a, rcv=RxC xmt=TxC */ + + /* assume clock mode 0a, rcv=RxC xmt=TxC */ clkmode = clksubmode = 0; if (info->params.flags & HDLC_FLAG_RXC_DPLL && info->params.flags & HDLC_FLAG_TXC_DPLL) { - /* clock mode 7a, rcv = DPLL, xmt = DPLL */ + /* clock mode 7a, rcv = DPLL, xmt = DPLL */ clkmode = 7; } else if (info->params.flags & HDLC_FLAG_RXC_BRG && info->params.flags & HDLC_FLAG_TXC_BRG) { - /* clock mode 7b, rcv = BRG, xmt = BRG */ + /* clock mode 7b, rcv = BRG, xmt = BRG */ clkmode = 7; clksubmode = 1; } else if (info->params.flags & HDLC_FLAG_RXC_DPLL) { if (info->params.flags & HDLC_FLAG_TXC_BRG) { - /* clock mode 6b, rcv = DPLL, xmt = BRG/16 */ + /* clock mode 6b, rcv = DPLL, xmt = BRG/16 */ clkmode = 6; clksubmode = 1; } else { - /* clock mode 6a, rcv = DPLL, xmt = TxC */ + /* clock mode 6a, rcv = DPLL, xmt = TxC */ clkmode = 6; } } else if (info->params.flags & HDLC_FLAG_TXC_BRG) { - /* clock mode 0b, rcv = RxC, xmt = BRG */ + /* clock mode 0b, rcv = RxC, xmt = BRG */ clksubmode = 1; } - + /* MODE * * 07..06 MDS[1..0] 10 = transparent HDLC mode @@ -3293,16 +3293,16 @@ static void hdlc_mode(MGSLPC_INFO *info) * 00 TLP Test Loop, 0 = no loop * * 1000 0010 - */ + */ val = 0x82; if (info->params.loopback) val |= BIT0; - - /* preserve RTS state */ + + /* preserve RTS state */ if (info->serial_signals & SerialSignal_RTS) val |= BIT2; write_reg(info, CHA + MODE, val); - + /* CCR0 * * 07 PU Power Up, 1=active, 0=power down @@ -3312,7 +3312,7 @@ static void hdlc_mode(MGSLPC_INFO *info) * 01..00 SM[1..0] Serial Mode, 00=HDLC * * 11000000 - */ + */ val = 0xc0; switch (info->params.encoding) { @@ -3330,7 +3330,7 @@ static void hdlc_mode(MGSLPC_INFO *info) break; // Manchester } write_reg(info, CHA + CCR0, val); - + /* CCR1 * * 07 SFLG Shared Flag, 0 = disable shared flags @@ -3341,10 +3341,10 @@ static void hdlc_mode(MGSLPC_INFO *info) * 02..00 CM[2..0] Clock Mode * * 0001 0000 - */ + */ val = 0x10 + clkmode; write_reg(info, CHA + CCR1, val); - + /* CCR2 * * 07..06 BGR[9..8] Baud rate bits 9..8 @@ -3356,7 +3356,7 @@ static void hdlc_mode(MGSLPC_INFO *info) * 00 DIV, data inversion 0=disabled, 1=enabled * * 0000 0000 - */ + */ val = 0x00; if (clkmode == 2 || clkmode == 3 || clkmode == 6 || clkmode == 7 || (clkmode == 0 && clksubmode == 1)) @@ -3368,7 +3368,7 @@ static void hdlc_mode(MGSLPC_INFO *info) if (info->params.encoding == HDLC_ENCODING_NRZB) val |= BIT0; write_reg(info, CHA + CCR2, val); - + /* CCR3 * * 07..06 PRE[1..0] Preamble count 00=1, 01=2, 10=4, 11=8 @@ -3380,7 +3380,7 @@ static void hdlc_mode(MGSLPC_INFO *info) * 00 PSD DPLL Phase Shift Disable * * 0000 0000 - */ + */ val = 0x00; if (info->params.crc_type == HDLC_CRC_NONE) val |= BIT2 + BIT1; @@ -3399,8 +3399,8 @@ static void hdlc_mode(MGSLPC_INFO *info) break; } write_reg(info, CHA + CCR3, val); - - /* PRE - Preamble pattern */ + + /* PRE - Preamble pattern */ val = 0; switch (info->params.preamble) { @@ -3410,7 +3410,7 @@ static void hdlc_mode(MGSLPC_INFO *info) case HDLC_PREAMBLE_PATTERN_ONES: val = 0xff; break; } write_reg(info, CHA + PRE, val); - + /* CCR4 * * 07 MCK4 Master Clock Divide by 4, 1=enabled @@ -3421,21 +3421,21 @@ static void hdlc_mode(MGSLPC_INFO *info) * 01..00 RFT[1..0] RxFIFO Threshold 00=32 bytes * * 0101 0000 - */ + */ val = 0x50; write_reg(info, CHA + CCR4, val); if (info->params.flags & HDLC_FLAG_RXC_DPLL) mgslpc_set_rate(info, CHA, info->params.clock_speed * 16); else mgslpc_set_rate(info, CHA, info->params.clock_speed); - + /* RLCR Receive length check register * * 7 1=enable receive length check * 6..0 Max frame length = (RL + 1) * 32 - */ + */ write_reg(info, CHA + RLCR, 0); - + /* XBCH Transmit Byte Count High * * 07 DMA mode, 0 = interrupt driven @@ -3445,7 +3445,7 @@ static void hdlc_mode(MGSLPC_INFO *info) * 03..00 XBC[10..8] Transmit byte count bits 10..8 * * 0000 0000 - */ + */ val = 0x00; if (info->params.flags & HDLC_FLAG_AUTO_DCD) val |= BIT5; @@ -3456,7 +3456,7 @@ static void hdlc_mode(MGSLPC_INFO *info) if (info->params.flags & HDLC_FLAG_AUTO_CTS) { irq_enable(info, CHB, IRQ_CTS); - /* PVR[3] 1=AUTO CTS active */ + /* PVR[3] 1=AUTO CTS active */ set_reg_bits(info, CHA + PVR, BIT3); } else clear_reg_bits(info, CHA + PVR, BIT3); @@ -3467,7 +3467,7 @@ static void hdlc_mode(MGSLPC_INFO *info) issue_command(info, CHA, CMD_TXRESET + CMD_RXRESET); wait_command_complete(info, CHA); read_reg16(info, CHA + ISR); /* clear pending IRQs */ - + /* Master clock mode enabled above to allow reset commands * to complete even if no data clocks are present. * @@ -3477,7 +3477,7 @@ static void hdlc_mode(MGSLPC_INFO *info) * * Leave master clock mode enabled for IRQ test because the * timer IRQ used by the test can only happen in master clock mode. - */ + */ if (!info->testing_irq) clear_reg_bits(info, CHA + CCR0, BIT6); @@ -3492,8 +3492,8 @@ static void rx_stop(MGSLPC_INFO *info) if (debug_level >= DEBUG_LEVEL_ISR) printk("%s(%d):rx_stop(%s)\n", __FILE__,__LINE__, info->device_name ); - - /* MODE:03 RAC Receiver Active, 0=inactive */ + + /* MODE:03 RAC Receiver Active, 0=inactive */ clear_reg_bits(info, CHA + MODE, BIT3); info->rx_enabled = 0; @@ -3510,7 +3510,7 @@ static void rx_start(MGSLPC_INFO *info) info->rx_enabled = 0; info->rx_overflow = 0; - /* MODE:03 RAC Receiver Active, 1=active */ + /* MODE:03 RAC Receiver Active, 1=active */ set_reg_bits(info, CHA + MODE, BIT3); info->rx_enabled = 1; @@ -3521,7 +3521,7 @@ static void tx_start(MGSLPC_INFO *info) if (debug_level >= DEBUG_LEVEL_ISR) printk("%s(%d):tx_start(%s)\n", __FILE__,__LINE__, info->device_name ); - + if (info->tx_count) { /* If auto RTS enabled and RTS is inactive, then assert */ /* RTS and set a flag indicating that the driver should */ @@ -3559,8 +3559,8 @@ static void tx_stop(MGSLPC_INFO *info) if (debug_level >= DEBUG_LEVEL_ISR) printk("%s(%d):tx_stop(%s)\n", __FILE__,__LINE__, info->device_name ); - - del_timer(&info->tx_timer); + + del_timer(&info->tx_timer); info->tx_enabled = 0; info->tx_active = 0; @@ -3570,17 +3570,17 @@ static void tx_stop(MGSLPC_INFO *info) */ static void reset_device(MGSLPC_INFO *info) { - /* power up both channels (set BIT7) */ + /* power up both channels (set BIT7) */ write_reg(info, CHA + CCR0, 0x80); write_reg(info, CHB + CCR0, 0x80); write_reg(info, CHA + MODE, 0); write_reg(info, CHB + MODE, 0); - - /* disable all interrupts */ + + /* disable all interrupts */ irq_disable(info, CHA, 0xffff); irq_disable(info, CHB, 0xffff); port_irq_disable(info, 0xff); - + /* PCR Port Configuration Register * * 07..04 DEC[3..0] Serial I/F select outputs @@ -3590,9 +3590,9 @@ static void reset_device(MGSLPC_INFO *info) * 00 DTR output 0=active * * 0000 0110 - */ + */ write_reg(info, PCR, 0x06); - + /* PVR Port Value Register * * 07..04 DEC[3..0] Serial I/F select (0000=disabled) @@ -3604,7 +3604,7 @@ static void reset_device(MGSLPC_INFO *info) * 0000 0001 */ // write_reg(info, PVR, PVR_DTR); - + /* IPC Interrupt Port Configuration * * 07 VIS 1=Masked interrupts visible @@ -3614,7 +3614,7 @@ static void reset_device(MGSLPC_INFO *info) * 01..00 IC[1..0] Interrupt Config, 01=push-pull output, active low * * 0000 0101 - */ + */ write_reg(info, IPC, 0x05); } @@ -3622,11 +3622,11 @@ static void async_mode(MGSLPC_INFO *info) { unsigned char val; - /* disable all interrupts */ + /* disable all interrupts */ irq_disable(info, CHA, 0xffff); irq_disable(info, CHB, 0xffff); port_irq_disable(info, 0xff); - + /* MODE * * 07 Reserved, 0 @@ -3639,16 +3639,16 @@ static void async_mode(MGSLPC_INFO *info) * 00 TLP Test Loop, 0 = no loop * * 0000 0110 - */ + */ val = 0x06; if (info->params.loopback) val |= BIT0; - - /* preserve RTS state */ + + /* preserve RTS state */ if (!(info->serial_signals & SerialSignal_RTS)) val |= BIT6; write_reg(info, CHA + MODE, val); - + /* CCR0 * * 07 PU Power Up, 1=active, 0=power down @@ -3658,9 +3658,9 @@ static void async_mode(MGSLPC_INFO *info) * 01..00 SM[1..0] Serial Mode, 11=Async * * 1000 0011 - */ + */ write_reg(info, CHA + CCR0, 0x83); - + /* CCR1 * * 07..05 Reserved, 0 @@ -3669,9 +3669,9 @@ static void async_mode(MGSLPC_INFO *info) * 02..00 CM[2..0] Clock Mode, 111=BRG * * 0001 1111 - */ + */ write_reg(info, CHA + CCR1, 0x1f); - + /* CCR2 (channel A) * * 07..06 BGR[9..8] Baud rate bits 9..8 @@ -3683,18 +3683,18 @@ static void async_mode(MGSLPC_INFO *info) * 00 DIV, data inversion 0=disabled, 1=enabled * * 0001 0000 - */ + */ write_reg(info, CHA + CCR2, 0x10); - + /* CCR3 * * 07..01 Reserved, 0 * 00 PSD DPLL Phase Shift Disable * * 0000 0000 - */ + */ write_reg(info, CHA + CCR3, 0); - + /* CCR4 * * 07 MCK4 Master Clock Divide by 4, 1=enabled @@ -3704,10 +3704,10 @@ static void async_mode(MGSLPC_INFO *info) * 03..00 Reserved, must be 0 * * 0101 0000 - */ + */ write_reg(info, CHA + CCR4, 0x50); mgslpc_set_rate(info, CHA, info->params.data_rate * 16); - + /* DAFO Data Format * * 07 Reserved, 0 @@ -3717,7 +3717,7 @@ static void async_mode(MGSLPC_INFO *info) * 02 PAREN Parity Enable * 01..00 CHL[1..0] Character Length (00=8, 01=7) * - */ + */ val = 0x00; if (info->params.data_bits != 8) val |= BIT0; /* 7 bits */ @@ -3732,7 +3732,7 @@ static void async_mode(MGSLPC_INFO *info) val |= BIT4; } write_reg(info, CHA + DAFO, val); - + /* RFC Rx FIFO Control * * 07 Reserved, 0 @@ -3744,15 +3744,15 @@ static void async_mode(MGSLPC_INFO *info) * 00 TCDE Terminate Char Detect Enable, 0=disabled * * 0101 1100 - */ + */ write_reg(info, CHA + RFC, 0x5c); - + /* RLCR Receive length check register * * Max frame length = (RL + 1) * 32 - */ + */ write_reg(info, CHA + RLCR, 0); - + /* XBCH Transmit Byte Count High * * 07 DMA mode, 0 = interrupt driven @@ -3762,20 +3762,20 @@ static void async_mode(MGSLPC_INFO *info) * 03..00 XBC[10..8] Transmit byte count bits 10..8 * * 0000 0000 - */ + */ val = 0x00; if (info->params.flags & HDLC_FLAG_AUTO_DCD) val |= BIT5; write_reg(info, CHA + XBCH, val); if (info->params.flags & HDLC_FLAG_AUTO_CTS) irq_enable(info, CHA, IRQ_CTS); - - /* MODE:03 RAC Receiver Active, 1=active */ + + /* MODE:03 RAC Receiver Active, 1=active */ set_reg_bits(info, CHA + MODE, BIT3); enable_auxclk(info); if (info->params.flags & HDLC_FLAG_AUTO_CTS) { irq_enable(info, CHB, IRQ_CTS); - /* PVR[3] 1=AUTO CTS active */ + /* PVR[3] 1=AUTO CTS active */ set_reg_bits(info, CHA + PVR, BIT3); } else clear_reg_bits(info, CHA + PVR, BIT3); @@ -3791,7 +3791,7 @@ static void async_mode(MGSLPC_INFO *info) */ static void tx_set_idle(MGSLPC_INFO *info) { - /* Note: ESCC2 only supports flags and one idle modes */ + /* Note: ESCC2 only supports flags and one idle modes */ if (info->idle_mode == HDLC_TXIDLE_FLAGS) set_reg_bits(info, CHA + CCR1, BIT3); else @@ -3803,8 +3803,8 @@ static void tx_set_idle(MGSLPC_INFO *info) static void get_signals(MGSLPC_INFO *info) { unsigned char status = 0; - - /* preserve DTR and RTS */ + + /* preserve DTR and RTS */ info->serial_signals &= SerialSignal_DTR + SerialSignal_RTS; if (read_reg(info, CHB + VSTR) & BIT7) @@ -3873,7 +3873,7 @@ static int rx_get_frame(MGSLPC_INFO *info) unsigned long flags; struct tty_struct *tty = info->tty; int return_frame = 0; - + if (info->rx_frame_count == 0) return 0; @@ -3913,10 +3913,10 @@ static int rx_get_frame(MGSLPC_INFO *info) if (debug_level >= DEBUG_LEVEL_BH) printk("%s(%d):rx_get_frame(%s) status=%04X size=%d\n", __FILE__,__LINE__,info->device_name,status,framesize); - + if (debug_level >= DEBUG_LEVEL_DATA) - trace_block(info, buf->data, framesize, 0); - + trace_block(info, buf->data, framesize, 0); + if (framesize) { if ((info->params.crc_type & HDLC_CRC_RETURN_EX && framesize+1 > info->max_frame_size) || @@ -3953,7 +3953,7 @@ static int rx_get_frame(MGSLPC_INFO *info) static BOOLEAN register_test(MGSLPC_INFO *info) { - static unsigned char patterns[] = + static unsigned char patterns[] = { 0x00, 0xff, 0xaa, 0x55, 0x69, 0x96, 0x0f }; static unsigned int count = ARRAY_SIZE(patterns); unsigned int i; @@ -4002,13 +4002,13 @@ static BOOLEAN irq_test(MGSLPC_INFO *info) while(end_time-- && !info->irq_occurred) { msleep_interruptible(10); } - + info->testing_irq = FALSE; spin_lock_irqsave(&info->lock,flags); reset_device(info); spin_unlock_irqrestore(&info->lock,flags); - + return info->irq_occurred ? TRUE : FALSE; } @@ -4042,13 +4042,13 @@ static void trace_block(MGSLPC_INFO *info,const char* data, int count, int xmit) printk("%s tx data:\n",info->device_name); else printk("%s rx data:\n",info->device_name); - + while(count) { if (count > 16) linecount = 16; else linecount = count; - + for(i=0;i= DEBUG_LEVEL_INFO ) printk( "%s(%d):tx_timeout(%s)\n", __FILE__,__LINE__,info->device_name); @@ -4086,7 +4086,7 @@ static void tx_timeout(unsigned long context) info->tx_count = info->tx_put = info->tx_get = 0; spin_unlock_irqrestore(&info->lock,flags); - + #if SYNCLINK_GENERIC_HDLC if (info->netcount) hdlcdev_tx_done(info); diff --git a/trunk/drivers/char/ppdev.c b/trunk/drivers/char/ppdev.c index 3aab837d9480..efe2f5c55b91 100644 --- a/trunk/drivers/char/ppdev.c +++ b/trunk/drivers/char/ppdev.c @@ -267,9 +267,9 @@ static ssize_t pp_write (struct file * file, const char __user * buf, return bytes_written; } -static void pp_irq (void *private) +static void pp_irq (int irq, void * private) { - struct pp_struct *pp = private; + struct pp_struct * pp = (struct pp_struct *) private; if (pp->irqresponse) { parport_write_control (pp->pdev->port, pp->irqctl); diff --git a/trunk/drivers/char/riscom8.c b/trunk/drivers/char/riscom8.c index 102ece4c4e0e..b37e626f4faa 100644 --- a/trunk/drivers/char/riscom8.c +++ b/trunk/drivers/char/riscom8.c @@ -79,6 +79,7 @@ #define RS_EVENT_WRITE_WAKEUP 0 +static struct riscom_board * IRQ_to_board[16]; static struct tty_driver *riscom_driver; static struct riscom_board rc_board[RC_NBOARD] = { @@ -536,14 +537,16 @@ static inline void rc_check_modem(struct riscom_board const * bp) } /* The main interrupt processing routine */ -static irqreturn_t rc_interrupt(int dummy, void * dev_id) +static irqreturn_t rc_interrupt(int irq, void * dev_id) { unsigned char status; unsigned char ack; - struct riscom_board *bp = dev_id; + struct riscom_board *bp; unsigned long loop = 0; int handled = 0; + bp = IRQ_to_board[irq]; + if (!(bp->flags & RC_BOARD_ACTIVE)) return IRQ_NONE; @@ -600,7 +603,7 @@ static irqreturn_t rc_interrupt(int dummy, void * dev_id) */ /* Called with disabled interrupts */ -static int rc_setup_board(struct riscom_board * bp) +static inline int rc_setup_board(struct riscom_board * bp) { int error; @@ -608,7 +611,7 @@ static int rc_setup_board(struct riscom_board * bp) return 0; error = request_irq(bp->irq, rc_interrupt, IRQF_DISABLED, - "RISCom/8", bp); + "RISCom/8", NULL); if (error) return error; @@ -616,13 +619,14 @@ static int rc_setup_board(struct riscom_board * bp) bp->DTR = ~0; rc_out(bp, RC_DTR, bp->DTR); /* Drop DTR on all ports */ + IRQ_to_board[bp->irq] = bp; bp->flags |= RC_BOARD_ACTIVE; return 0; } /* Called with disabled interrupts */ -static void rc_shutdown_board(struct riscom_board *bp) +static inline void rc_shutdown_board(struct riscom_board *bp) { if (!(bp->flags & RC_BOARD_ACTIVE)) return; @@ -630,6 +634,7 @@ static void rc_shutdown_board(struct riscom_board *bp) bp->flags &= ~RC_BOARD_ACTIVE; free_irq(bp->irq, NULL); + IRQ_to_board[bp->irq] = NULL; bp->DTR = ~0; rc_out(bp, RC_DTR, bp->DTR); /* Drop DTR on all ports */ @@ -1589,6 +1594,7 @@ static inline int rc_init_drivers(void) if (!riscom_driver) return -ENOMEM; + memset(IRQ_to_board, 0, sizeof(IRQ_to_board)); riscom_driver->owner = THIS_MODULE; riscom_driver->name = "ttyL"; riscom_driver->major = RISCOM8_NORMAL_MAJOR; diff --git a/trunk/drivers/char/tpm/tpm_tis.c b/trunk/drivers/char/tpm/tpm_tis.c index fd771a4d6d18..a8e808461377 100644 --- a/trunk/drivers/char/tpm/tpm_tis.c +++ b/trunk/drivers/char/tpm/tpm_tis.c @@ -381,7 +381,7 @@ static struct tpm_vendor_specific tpm_tis = { static irqreturn_t tis_int_probe(int irq, void *dev_id) { - struct tpm_chip *chip = dev_id; + struct tpm_chip *chip = (struct tpm_chip *) dev_id; u32 interrupt; interrupt = ioread32(chip->vendor.iobase + @@ -401,7 +401,7 @@ static irqreturn_t tis_int_probe(int irq, void *dev_id) static irqreturn_t tis_int_handler(int irq, void *dev_id) { - struct tpm_chip *chip = dev_id; + struct tpm_chip *chip = (struct tpm_chip *) dev_id; u32 interrupt; int i; diff --git a/trunk/drivers/cpuidle/cpuidle.c b/trunk/drivers/cpuidle/cpuidle.c index d2fabe7863a9..fdf4106b817b 100644 --- a/trunk/drivers/cpuidle/cpuidle.c +++ b/trunk/drivers/cpuidle/cpuidle.c @@ -19,6 +19,7 @@ #include "cpuidle.h" DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices); +EXPORT_PER_CPU_SYMBOL_GPL(cpuidle_devices); DEFINE_MUTEX(cpuidle_lock); LIST_HEAD(cpuidle_detected_devices); diff --git a/trunk/drivers/cpuidle/governor.c b/trunk/drivers/cpuidle/governor.c index 70b59642a708..bb699cb2dc5a 100644 --- a/trunk/drivers/cpuidle/governor.c +++ b/trunk/drivers/cpuidle/governor.c @@ -94,6 +94,8 @@ int cpuidle_register_governor(struct cpuidle_governor *gov) return ret; } +EXPORT_SYMBOL_GPL(cpuidle_register_governor); + /** * cpuidle_replace_governor - find a replacement governor * @exclude_rating: the rating that will be skipped while looking for @@ -136,3 +138,4 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov) mutex_unlock(&cpuidle_lock); } +EXPORT_SYMBOL_GPL(cpuidle_unregister_governor); diff --git a/trunk/drivers/crypto/padlock-sha.c b/trunk/drivers/crypto/padlock-sha.c index c666b4e0933e..4e8de162fc12 100644 --- a/trunk/drivers/crypto/padlock-sha.c +++ b/trunk/drivers/crypto/padlock-sha.c @@ -55,7 +55,7 @@ static void padlock_sha_bypass(struct crypto_tfm *tfm) if (ctx(tfm)->data && ctx(tfm)->used) { struct scatterlist sg; - sg_init_one(&sg, ctx(tfm)->data, ctx(tfm)->used); + sg_set_buf(&sg, ctx(tfm)->data, ctx(tfm)->used); crypto_hash_update(&ctx(tfm)->fallback, &sg, sg.length); } @@ -79,7 +79,7 @@ static void padlock_sha_update(struct crypto_tfm *tfm, if (unlikely(ctx(tfm)->bypass)) { struct scatterlist sg; - sg_init_one(&sg, (uint8_t *)data, length); + sg_set_buf(&sg, (uint8_t *)data, length); crypto_hash_update(&ctx(tfm)->fallback, &sg, length); return; } diff --git a/trunk/drivers/dma/Kconfig b/trunk/drivers/dma/Kconfig index 6a7d25fc2470..9c91b0fd134f 100644 --- a/trunk/drivers/dma/Kconfig +++ b/trunk/drivers/dma/Kconfig @@ -43,6 +43,7 @@ comment "DMA Clients" config NET_DMA bool "Network: TCP receive copy offload" depends on DMA_ENGINE && NET + default y help This enables the use of DMA engines in the network stack to offload receive copy-to-user operations, freeing CPU cycles. diff --git a/trunk/drivers/fc4/Kconfig b/trunk/drivers/fc4/Kconfig new file mode 100644 index 000000000000..345dbe6f10df --- /dev/null +++ b/trunk/drivers/fc4/Kconfig @@ -0,0 +1,81 @@ +# +# FC4 device configuration +# + +menu "Fibre Channel support" + +config FC4 + tristate "Fibre Channel and FC4 SCSI support" + ---help--- + Fibre Channel is a high speed serial protocol mainly used to + connect large storage devices to the computer; it is compatible with + and intended to replace SCSI. + + This is an experimental support for storage arrays connected to your + computer using optical fibre cables and the "X3.269-199X Fibre + Channel Protocol for SCSI" specification. If you want to use this, + you need to say Y here and to "SCSI support" as well as to the + drivers for the storage array itself and for the interface adapter + such as SOC or SOC+. This subsystem could even serve for IP + networking, with some code extensions. + + If unsure, say N. + +comment "FC4 drivers" + depends on FC4 + +config FC4_SOC + tristate "Sun SOC/Sbus" + depends on FC4!=n && SPARC + help + Serial Optical Channel is an interface card with one or two Fibre + Optic ports, each of which can be connected to a disk array. Note + that if you have older firmware in the card, you'll need the + microcode from the Solaris driver to make it work. + + To compile this support as a module, choose M here: the module will + be called soc. + +config FC4_SOCAL + tristate "Sun SOC+ (aka SOCAL)" + depends on FC4!=n && SPARC + ---help--- + Serial Optical Channel Plus is an interface card with up to two + Fibre Optic ports. This card supports FC Arbitrated Loop (usually + A5000 or internal FC disks in E[3-6]000 machines through the + Interface Board). You'll probably need the microcode from the + Solaris driver to make it work. + + To compile this support as a module, choose M here: the module will + be called socal. + +comment "FC4 targets" + depends on FC4 + +config SCSI_PLUTO + tristate "SparcSTORAGE Array 100 and 200 series" + depends on FC4!=n && SCSI + help + If you never bought a disk array made by Sun, go with N. + + To compile this support as a module, choose M here: the module will + be called pluto. + +config SCSI_FCAL + tristate "Sun Enterprise Network Array (A5000 and EX500)" if SPARC + depends on FC4!=n && SCSI + help + This driver drives FC-AL disks connected through a Fibre Channel + card using the drivers/fc4 layer (currently only SOCAL). The most + common is either A5000 array or internal disks in E[3-6]000 + machines. + + To compile this support as a module, choose M here: the module will + be called fcal. + +config SCSI_FCAL + prompt "Generic FC-AL disk driver" + depends on FC4!=n && SCSI && !SPARC + +endmenu + diff --git a/trunk/drivers/fc4/Makefile b/trunk/drivers/fc4/Makefile new file mode 100644 index 000000000000..0db3fbb553e9 --- /dev/null +++ b/trunk/drivers/fc4/Makefile @@ -0,0 +1,9 @@ +# +# Makefile for the Linux Fibre Channel device drivers. +# + +fc4-objs := fc.o fc_syms.o + +obj-$(CONFIG_FC4) += fc4.o +obj-$(CONFIG_FC4_SOC) += soc.o +obj-$(CONFIG_FC4_SOCAL) += socal.o diff --git a/trunk/drivers/fc4/fc-al.h b/trunk/drivers/fc4/fc-al.h new file mode 100644 index 000000000000..62d3ca436d72 --- /dev/null +++ b/trunk/drivers/fc4/fc-al.h @@ -0,0 +1,27 @@ +/* fc-al.h: Definitions for Fibre Channel Arbitrated Loop topology. + * + * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) + * + * Sources: + * Fibre Channel Arbitrated Loop (FC-AL), ANSI, Rev. 4.5, 1995 + */ + +#ifndef __FC_AL_H +#define __FC_AL_H + +/* Loop initialization payloads */ +#define FC_AL_LISM 0x11010000 /* Select Master, 12B payload */ +#define FC_AL_LIFA 0x11020000 /* Fabric Assign AL_PA bitmap, 20B payload */ +#define FC_AL_LIPA 0x11030000 /* Previously Acquired AL_PA bitmap, 20B payload */ +#define FC_AL_LIHA 0x11040000 /* Hard Assigned AL_PA bitmap, 20B payload */ +#define FC_AL_LISA 0x11050000 /* Soft Assigned AL_PA bitmap, 20B payload */ +#define FC_AL_LIRP 0x11060000 /* Report AL_PA position map, 132B payload */ +#define FC_AL_LILP 0x11070000 /* Loop AL_PA position map, 132B payload */ + +typedef struct { + u32 magic; + u8 len; + u8 alpa[127]; +} fc_al_posmap; + +#endif /* !(__FC_H) */ diff --git a/trunk/drivers/fc4/fc.c b/trunk/drivers/fc4/fc.c new file mode 100644 index 000000000000..82de9e1adb1e --- /dev/null +++ b/trunk/drivers/fc4/fc.c @@ -0,0 +1,1146 @@ +/* fc.c: Generic Fibre Channel and FC4 SCSI driver. + * + * Copyright (C) 1997,1998,1999 Jakub Jelinek (jj@ultra.linux.cz) + * Copyright (C) 1997,1998 Jirka Hanika (geo@ff.cuni.cz) + * + * There are two kinds of Fibre Channel adapters used in Linux. Either + * the adapter is "smart" and does all FC bookkeeping by itself and + * just presents a standard SCSI interface to the operating system + * (that's e.g. the case with Qlogic FC cards), or leaves most of the FC + * bookkeeping to the OS (e.g. soc, socal). Drivers for the former adapters + * will look like normal SCSI drivers (with the exception of max_id will be + * usually 127), the latter on the other side allows SCSI, IP over FC and other + * protocols. This driver tree is for the latter adapters. + * + * This file should support both Point-to-Point and Arbitrated Loop topologies. + * + * Sources: + * Fibre Channel Physical & Signaling Interface (FC-PH), dpANS, 1994 + * dpANS Fibre Channel Protocol for SCSI (X3.269-199X), Rev. 012, 1995 + * Fibre Channel Arbitrated Loop (FC-AL), Rev. 4.5, 1995 + * Fibre Channel Private Loop SCSI Direct Attach (FC-PLDA), Rev. 2.1, 1997 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "fcp_impl.h" +#include + +/* #define FCDEBUG */ + +#define fc_printk printk ("%s: ", fc->name); printk + +#ifdef FCDEBUG +#define FCD(x) fc_printk x; +#define FCND(x) printk ("FC: "); printk x; +#else +#define FCD(x) +#define FCND(x) +#endif + +#ifdef __sparc__ +#define dma_alloc_consistent(d,s,p) sbus_alloc_consistent(d,s,p) +#define dma_free_consistent(d,s,v,h) sbus_free_consistent(d,s,v,h) +#define dma_map_single(d,v,s,dir) sbus_map_single(d,v,s,dir) +#define dma_unmap_single(d,h,s,dir) sbus_unmap_single(d,h,s,dir) +#define dma_map_sg(d,s,n,dir) sbus_map_sg(d,s,n,dir) +#define dma_unmap_sg(d,s,n,dir) sbus_unmap_sg(d,s,n,dir) +#else +#define dma_alloc_consistent(d,s,p) pci_alloc_consistent(d,s,p) +#define dma_free_consistent(d,s,v,h) pci_free_consistent(d,s,v,h) +#define dma_map_single(d,v,s,dir) pci_map_single(d,v,s,dir) +#define dma_unmap_single(d,h,s,dir) pci_unmap_single(d,h,s,dir) +#define dma_map_sg(d,s,n,dir) pci_map_sg(d,s,n,dir) +#define dma_unmap_sg(d,s,n,dir) pci_unmap_sg(d,s,n,dir) +#endif + +#define FCP_CMND(SCpnt) ((fcp_cmnd *)&(SCpnt->SCp)) +#define FC_SCMND(SCpnt) ((fc_channel *)(SCpnt->device->host->hostdata[0])) +#define SC_FCMND(fcmnd) ((struct scsi_cmnd *)((long)fcmnd - (long)&(((struct scsi_cmnd *)0)->SCp))) + +static int fcp_scsi_queue_it(fc_channel *, struct scsi_cmnd *, fcp_cmnd *, int); +void fcp_queue_empty(fc_channel *); + +static void fcp_scsi_insert_queue (fc_channel *fc, fcp_cmnd *fcmd) +{ + if (!fc->scsi_que) { + fc->scsi_que = fcmd; + fcmd->next = fcmd; + fcmd->prev = fcmd; + } else { + fc->scsi_que->prev->next = fcmd; + fcmd->prev = fc->scsi_que->prev; + fc->scsi_que->prev = fcmd; + fcmd->next = fc->scsi_que; + } +} + +static void fcp_scsi_remove_queue (fc_channel *fc, fcp_cmnd *fcmd) +{ + if (fcmd == fcmd->next) { + fc->scsi_que = NULL; + return; + } + if (fcmd == fc->scsi_que) + fc->scsi_que = fcmd->next; + fcmd->prev->next = fcmd->next; + fcmd->next->prev = fcmd->prev; +} + +fc_channel *fc_channels = NULL; + +#define LSMAGIC 620829043 +typedef struct { + /* Must be first */ + struct semaphore sem; + int magic; + int count; + logi *logi; + fcp_cmnd *fcmds; + atomic_t todo; + struct timer_list timer; + unsigned char grace[0]; +} ls; + +#define LSOMAGIC 654907799 +typedef struct { + /* Must be first */ + struct semaphore sem; + int magic; + int count; + fcp_cmnd *fcmds; + atomic_t todo; + struct timer_list timer; +} lso; + +#define LSEMAGIC 84482456 +typedef struct { + /* Must be first */ + struct semaphore sem; + int magic; + int status; + struct timer_list timer; +} lse; + +static void fcp_login_timeout(unsigned long data) +{ + ls *l = (ls *)data; + FCND(("Login timeout\n")) + up(&l->sem); +} + +static void fcp_login_done(fc_channel *fc, int i, int status) +{ + fcp_cmnd *fcmd; + logi *plogi; + fc_hdr *fch; + ls *l = (ls *)fc->ls; + + FCD(("Login done %d %d\n", i, status)) + if (i < l->count) { + if (fc->state == FC_STATE_FPORT_OK) { + FCD(("Additional FPORT_OK received with status %d\n", status)) + return; + } + switch (status) { + case FC_STATUS_OK: /* Oh, we found a fabric */ + case FC_STATUS_P_RJT: /* Oh, we haven't found any */ + fc->state = FC_STATE_FPORT_OK; + fcmd = l->fcmds + i; + plogi = l->logi + 3 * i; + dma_unmap_single (fc->dev, fcmd->cmd, 3 * sizeof(logi), + DMA_BIDIRECTIONAL); + plogi->code = LS_PLOGI; + memcpy (&plogi->nport_wwn, &fc->wwn_nport, sizeof(fc_wwn)); + memcpy (&plogi->node_wwn, &fc->wwn_node, sizeof(fc_wwn)); + memcpy (&plogi->common, fc->common_svc, sizeof(common_svc_parm)); + memcpy (&plogi->class1, fc->class_svcs, 3*sizeof(svc_parm)); + fch = &fcmd->fch; + fcmd->token += l->count; + FILL_FCHDR_RCTL_DID(fch, R_CTL_ELS_REQ, fc->did); + FILL_FCHDR_SID(fch, fc->sid); +#ifdef FCDEBUG + { + int i; + unsigned *x = (unsigned *)plogi; + printk ("logi: "); + for (i = 0; i < 21; i++) + printk ("%08x ", x[i]); + printk ("\n"); + } +#endif + fcmd->cmd = dma_map_single (fc->dev, plogi, 3 * sizeof(logi), + DMA_BIDIRECTIONAL); + fcmd->rsp = fcmd->cmd + 2 * sizeof(logi); + if (fc->hw_enque (fc, fcmd)) + printk ("FC: Cannot enque PLOGI packet on %s\n", fc->name); + break; + case FC_STATUS_ERR_OFFLINE: + fc->state = FC_STATE_MAYBEOFFLINE; + FCD (("FC is offline %d\n", l->grace[i])) + break; + default: + printk ("FLOGI failed for %s with status %d\n", fc->name, status); + /* Do some sort of error recovery here */ + break; + } + } else { + i -= l->count; + if (fc->state != FC_STATE_FPORT_OK) { + FCD(("Unexpected N-PORT rsp received")) + return; + } + switch (status) { + case FC_STATUS_OK: + plogi = l->logi + 3 * i; + dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi), + DMA_BIDIRECTIONAL); + if (!fc->wwn_dest.lo && !fc->wwn_dest.hi) { + memcpy (&fc->wwn_dest, &plogi[1].node_wwn, sizeof(fc_wwn)); + FCD(("Dest WWN %08x%08x\n", *(u32 *)&fc->wwn_dest, fc->wwn_dest.lo)) + } else if (fc->wwn_dest.lo != plogi[1].node_wwn.lo || + fc->wwn_dest.hi != plogi[1].node_wwn.hi) { + printk ("%s: mismatch in wwns. Got %08x%08x, expected %08x%08x\n", + fc->name, + *(u32 *)&plogi[1].node_wwn, plogi[1].node_wwn.lo, + *(u32 *)&fc->wwn_dest, fc->wwn_dest.lo); + } + fc->state = FC_STATE_ONLINE; + printk ("%s: ONLINE\n", fc->name); + if (atomic_dec_and_test (&l->todo)) + up(&l->sem); + break; + case FC_STATUS_ERR_OFFLINE: + fc->state = FC_STATE_OFFLINE; + dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi), + DMA_BIDIRECTIONAL); + printk ("%s: FC is offline\n", fc->name); + if (atomic_dec_and_test (&l->todo)) + up(&l->sem); + break; + default: + printk ("PLOGI failed for %s with status %d\n", fc->name, status); + /* Do some sort of error recovery here */ + break; + } + } +} + +static void fcp_report_map_done(fc_channel *fc, int i, int status) +{ + fcp_cmnd *fcmd; + fc_hdr *fch; + unsigned char j; + ls *l = (ls *)fc->ls; + fc_al_posmap *p; + + FCD(("Report map done %d %d\n", i, status)) + switch (status) { + case FC_STATUS_OK: /* Ok, let's have a fun on a loop */ + dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi), + DMA_BIDIRECTIONAL); + p = (fc_al_posmap *)(l->logi + 3 * i); +#ifdef FCDEBUG + { + u32 *u = (u32 *)p; + FCD(("%08x\n", u[0])) + u ++; + FCD(("%08x.%08x.%08x.%08x.%08x.%08x.%08x.%08x\n", u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7])) + } +#endif + if ((p->magic & 0xffff0000) != FC_AL_LILP || !p->len) { + printk ("FC: Bad magic from REPORT_AL_MAP on %s - %08x\n", fc->name, p->magic); + fc->state = FC_STATE_OFFLINE; + } else { + fc->posmap = kzalloc(sizeof(fcp_posmap)+p->len, GFP_KERNEL); + if (!fc->posmap) { + printk("FC: Not enough memory, offlining channel\n"); + fc->state = FC_STATE_OFFLINE; + } else { + int k; + /* FIXME: This is where SOCAL transfers our AL-PA. + Keep it here till we found out what other cards do... */ + fc->sid = (p->magic & 0xff); + for (i = 0; i < p->len; i++) + if (p->alpa[i] == fc->sid) + break; + k = p->len; + if (i == p->len) + i = 0; + else { + p->len--; + i++; + } + fc->posmap->len = p->len; + for (j = 0; j < p->len; j++) { + if (i == k) i = 0; + fc->posmap->list[j] = p->alpa[i++]; + } + fc->state = FC_STATE_ONLINE; + } + } + printk ("%s: ONLINE\n", fc->name); + if (atomic_dec_and_test (&l->todo)) + up(&l->sem); + break; + case FC_STATUS_POINTTOPOINT: /* We're Point-to-Point, no AL... */ + FCD(("SID %d DID %d\n", fc->sid, fc->did)) + fcmd = l->fcmds + i; + dma_unmap_single(fc->dev, fcmd->cmd, 3 * sizeof(logi), + DMA_BIDIRECTIONAL); + fch = &fcmd->fch; + memset(l->logi + 3 * i, 0, 3 * sizeof(logi)); + FILL_FCHDR_RCTL_DID(fch, R_CTL_ELS_REQ, FS_FABRIC_F_PORT); + FILL_FCHDR_SID(fch, 0); + FILL_FCHDR_TYPE_FCTL(fch, TYPE_EXTENDED_LS, F_CTL_FIRST_SEQ | F_CTL_SEQ_INITIATIVE); + FILL_FCHDR_SEQ_DF_SEQ(fch, 0, 0, 0); + FILL_FCHDR_OXRX(fch, 0xffff, 0xffff); + fch->param = 0; + l->logi [3 * i].code = LS_FLOGI; + fcmd->cmd = dma_map_single (fc->dev, l->logi + 3 * i, 3 * sizeof(logi), + DMA_BIDIRECTIONAL); + fcmd->rsp = fcmd->cmd + sizeof(logi); + fcmd->cmdlen = sizeof(logi); + fcmd->rsplen = sizeof(logi); + fcmd->data = (dma_addr_t)NULL; + fcmd->class = FC_CLASS_SIMPLE; + fcmd->proto = TYPE_EXTENDED_LS; + if (fc->hw_enque (fc, fcmd)) + printk ("FC: Cannot enque FLOGI packet on %s\n", fc->name); + break; + case FC_STATUS_ERR_OFFLINE: + fc->state = FC_STATE_MAYBEOFFLINE; + FCD (("FC is offline %d\n", l->grace[i])) + break; + default: + printk ("FLOGI failed for %s with status %d\n", fc->name, status); + /* Do some sort of error recovery here */ + break; + } +} + +void fcp_register(fc_channel *fc, u8 type, int unregister) +{ + int size, i; + int slots = (fc->can_queue * 3) >> 1; + + FCND(("Going to %sregister\n", unregister ? "un" : "")) + + if (type == TYPE_SCSI_FCP) { + if (!unregister) { + fc->scsi_cmd_pool = (fcp_cmd *) + dma_alloc_consistent (fc->dev, + slots * (sizeof (fcp_cmd) + fc->rsp_size), + &fc->dma_scsi_cmd); + fc->scsi_rsp_pool = (char *)(fc->scsi_cmd_pool + slots); + fc->dma_scsi_rsp = fc->dma_scsi_cmd + slots * sizeof (fcp_cmd); + fc->scsi_bitmap_end = (slots + 63) & ~63; + size = fc->scsi_bitmap_end / 8; + fc->scsi_bitmap = kzalloc (size, GFP_KERNEL); + set_bit (0, fc->scsi_bitmap); + for (i = fc->can_queue; i < fc->scsi_bitmap_end; i++) + set_bit (i, fc->scsi_bitmap); + fc->scsi_free = fc->can_queue; + fc->cmd_slots = kzalloc(slots * sizeof(fcp_cmnd*), GFP_KERNEL); + fc->abort_count = 0; + } else { + fc->scsi_name[0] = 0; + kfree (fc->scsi_bitmap); + kfree (fc->cmd_slots); + FCND(("Unregistering\n")); +#if 0 + if (fc->rst_pkt) { + if (fc->rst_pkt->eh_state == SCSI_STATE_UNUSED) + kfree(fc->rst_pkt); + else { + /* Can't happen. Some memory would be lost. */ + printk("FC: Reset in progress. Now?!"); + } + } +#endif + FCND(("Unregistered\n")); + } + } else + printk ("FC: %segistering unknown type %02x\n", unregister ? "Unr" : "R", type); +} + +static void fcp_scsi_done(struct scsi_cmnd *SCpnt); + +static inline void fcp_scsi_receive(fc_channel *fc, int token, int status, fc_hdr *fch) +{ + fcp_cmnd *fcmd; + fcp_rsp *rsp; + int host_status; + struct scsi_cmnd *SCpnt; + int sense_len; + int rsp_status; + + fcmd = fc->cmd_slots[token]; + if (!fcmd) return; + rsp = (fcp_rsp *) (fc->scsi_rsp_pool + fc->rsp_size * token); + SCpnt = SC_FCMND(fcmd); + + if (SCpnt->done != fcp_scsi_done) + return; + + rsp_status = rsp->fcp_status; + FCD(("rsp_status %08x status %08x\n", rsp_status, status)) + switch (status) { + case FC_STATUS_OK: + host_status=DID_OK; + + if (rsp_status & FCP_STATUS_RESID) { +#ifdef FCDEBUG + FCD(("Resid %d\n", rsp->fcp_resid)) + { + fcp_cmd *cmd = fc->scsi_cmd_pool + token; + int i; + + printk ("Command "); + for (i = 0; i < sizeof(fcp_cmd); i+=4) + printk ("%08x ", *(u32 *)(((char *)cmd)+i)); + printk ("\nResponse "); + for (i = 0; i < fc->rsp_size; i+=4) + printk ("%08x ", *(u32 *)(((char *)rsp)+i)); + printk ("\n"); + } +#endif + } + + if (rsp_status & FCP_STATUS_SENSE_LEN) { + sense_len = rsp->fcp_sense_len; + if (sense_len > sizeof(SCpnt->sense_buffer)) sense_len = sizeof(SCpnt->sense_buffer); + memcpy(SCpnt->sense_buffer, ((char *)(rsp+1)), sense_len); + } + + if (fcmd->data) + dma_unmap_sg(fc->dev, scsi_sglist(SCpnt), + scsi_sg_count(SCpnt), + SCpnt->sc_data_direction); + break; + default: + host_status=DID_ERROR; /* FIXME */ + FCD(("Wrong FC status %d for token %d\n", status, token)) + break; + } + + if (status_byte(rsp_status) == QUEUE_FULL) { + printk ("%s: (%d,%d) Received rsp_status 0x%x\n", fc->name, SCpnt->device->channel, SCpnt->device->id, rsp_status); + } + + SCpnt->result = (host_status << 16) | (rsp_status & 0xff); +#ifdef FCDEBUG + if (host_status || SCpnt->result || rsp_status) printk("FC: host_status %d, packet status %d\n", + host_status, SCpnt->result); +#endif + SCpnt->done = fcmd->done; + fcmd->done=NULL; + clear_bit(token, fc->scsi_bitmap); + fc->scsi_free++; + FCD(("Calling scsi_done with %08x\n", SCpnt->result)) + SCpnt->scsi_done(SCpnt); +} + +void fcp_receive_solicited(fc_channel *fc, int proto, int token, int status, fc_hdr *fch) +{ + int magic; + FCD(("receive_solicited %d %d %d\n", proto, token, status)) + switch (proto) { + case TYPE_SCSI_FCP: + fcp_scsi_receive(fc, token, status, fch); break; + case TYPE_EXTENDED_LS: + case PROTO_REPORT_AL_MAP: + magic = 0; + if (fc->ls) + magic = ((ls *)(fc->ls))->magic; + if (magic == LSMAGIC) { + ls *l = (ls *)fc->ls; + int i = (token >= l->count) ? token - l->count : token; + + /* Let's be sure */ + if ((unsigned)i < l->count && l->fcmds[i].fc == fc) { + if (proto == TYPE_EXTENDED_LS) + fcp_login_done(fc, token, status); + else + fcp_report_map_done(fc, token, status); + break; + } + } + FCD(("fc %p fc->ls %p fc->cmd_slots %p\n", fc, fc->ls, fc->cmd_slots)) + if (proto == TYPE_EXTENDED_LS && !fc->ls && fc->cmd_slots) { + fcp_cmnd *fcmd; + + fcmd = fc->cmd_slots[token]; + if (fcmd && fcmd->ls && ((ls *)(fcmd->ls))->magic == LSEMAGIC) { + lse *l = (lse *)fcmd->ls; + + l->status = status; + up (&l->sem); + } + } + break; + case PROTO_OFFLINE: + if (fc->ls && ((lso *)(fc->ls))->magic == LSOMAGIC) { + lso *l = (lso *)fc->ls; + + if ((unsigned)token < l->count && l->fcmds[token].fc == fc) { + /* Wow, OFFLINE response arrived :) */ + FCD(("OFFLINE Response arrived\n")) + fc->state = FC_STATE_OFFLINE; + if (atomic_dec_and_test (&l->todo)) + up(&l->sem); + } + } + break; + + default: + break; + } +} + +void fcp_state_change(fc_channel *fc, int state) +{ + FCD(("state_change %d %d\n", state, fc->state)) + if (state == FC_STATE_ONLINE && fc->state == FC_STATE_MAYBEOFFLINE) + fc->state = FC_STATE_UNINITED; + else if (state == FC_STATE_ONLINE) + printk (KERN_WARNING "%s: state change to ONLINE\n", fc->name); + else + printk (KERN_ERR "%s: state change to OFFLINE\n", fc->name); +} + +int fcp_initialize(fc_channel *fcchain, int count) +{ + fc_channel *fc; + fcp_cmnd *fcmd; + int i, retry, ret; + ls *l; + + FCND(("fcp_inititialize %08lx\n", (long)fcp_init)) + FCND(("fc_channels %08lx\n", (long)fc_channels)) + FCND((" SID %d DID %d\n", fcchain->sid, fcchain->did)) + l = kzalloc(sizeof (ls) + count, GFP_KERNEL); + if (!l) { + printk ("FC: Cannot allocate memory for initialization\n"); + return -ENOMEM; + } + l->magic = LSMAGIC; + l->count = count; + FCND(("FCP Init for %d channels\n", count)) + init_MUTEX_LOCKED(&l->sem); + init_timer(&l->timer); + l->timer.function = fcp_login_timeout; + l->timer.data = (unsigned long)l; + atomic_set (&l->todo, count); + l->logi = kzalloc (count * 3 * sizeof(logi), GFP_KERNEL); + l->fcmds = kzalloc (count * sizeof(fcp_cmnd), GFP_KERNEL); + if (!l->logi || !l->fcmds) { + kfree (l->logi); + kfree (l->fcmds); + kfree (l); + printk ("FC: Cannot allocate DMA memory for initialization\n"); + return -ENOMEM; + } + for (fc = fcchain, i = 0; fc && i < count; fc = fc->next, i++) { + fc->state = FC_STATE_UNINITED; + fc->rst_pkt = NULL; /* kmalloc when first used */ + } + /* First try if we are in a AL topology */ + FCND(("Initializing REPORT_MAP packets\n")) + for (fc = fcchain, i = 0; fc && i < count; fc = fc->next, i++) { + fcmd = l->fcmds + i; + fc->login = fcmd; + fc->ls = (void *)l; + /* Assumes sizeof(fc_al_posmap) < 3 * sizeof(logi), which is true */ + fcmd->cmd = dma_map_single (fc->dev, l->logi + 3 * i, 3 * sizeof(logi), + DMA_BIDIRECTIONAL); + fcmd->proto = PROTO_REPORT_AL_MAP; + fcmd->token = i; + fcmd->fc = fc; + } + for (retry = 0; retry < 8; retry++) { + int nqueued = 0; + FCND(("Sending REPORT_MAP/FLOGI/PLOGI packets\n")) + for (fc = fcchain, i = 0; fc && i < count; fc = fc->next, i++) { + if (fc->state == FC_STATE_ONLINE || fc->state == FC_STATE_OFFLINE) + continue; + disable_irq(fc->irq); + if (fc->state == FC_STATE_MAYBEOFFLINE) { + if (!l->grace[i]) { + l->grace[i]++; + FCD(("Grace\n")) + } else { + fc->state = FC_STATE_OFFLINE; + enable_irq(fc->irq); + dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi), DMA_BIDIRECTIONAL); + if (atomic_dec_and_test (&l->todo)) + goto all_done; + } + } + ret = fc->hw_enque (fc, fc->login); + enable_irq(fc->irq); + if (!ret) { + nqueued++; + continue; + } + if (ret == -ENOSYS && fc->login->proto == PROTO_REPORT_AL_MAP) { + /* Oh yes, this card handles Point-to-Point only, so let's try that. */ + fc_hdr *fch; + + FCD(("SID %d DID %d\n", fc->sid, fc->did)) + fcmd = l->fcmds + i; + dma_unmap_single(fc->dev, fcmd->cmd, 3 * sizeof(logi), DMA_BIDIRECTIONAL); + fch = &fcmd->fch; + FILL_FCHDR_RCTL_DID(fch, R_CTL_ELS_REQ, FS_FABRIC_F_PORT); + FILL_FCHDR_SID(fch, 0); + FILL_FCHDR_TYPE_FCTL(fch, TYPE_EXTENDED_LS, F_CTL_FIRST_SEQ | F_CTL_SEQ_INITIATIVE); + FILL_FCHDR_SEQ_DF_SEQ(fch, 0, 0, 0); + FILL_FCHDR_OXRX(fch, 0xffff, 0xffff); + fch->param = 0; + l->logi [3 * i].code = LS_FLOGI; + fcmd->cmd = dma_map_single (fc->dev, l->logi + 3 * i, 3 * sizeof(logi), DMA_BIDIRECTIONAL); + fcmd->rsp = fcmd->cmd + sizeof(logi); + fcmd->cmdlen = sizeof(logi); + fcmd->rsplen = sizeof(logi); + fcmd->data = (dma_addr_t)NULL; + fcmd->class = FC_CLASS_SIMPLE; + fcmd->proto = TYPE_EXTENDED_LS; + } else + printk ("FC: Cannot enque FLOGI/REPORT_MAP packet on %s\n", fc->name); + } + + if (nqueued) { + l->timer.expires = jiffies + 5 * HZ; + add_timer(&l->timer); + + down(&l->sem); + if (!atomic_read(&l->todo)) { + FCND(("All channels answered in time\n")) + break; /* All fc channels have answered us */ + } + } + } +all_done: + for (fc = fcchain, i = 0; fc && i < count; fc = fc->next, i++) { + fc->ls = NULL; + switch (fc->state) { + case FC_STATE_ONLINE: break; + case FC_STATE_OFFLINE: break; + default: dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi), DMA_BIDIRECTIONAL); + break; + } + } + del_timer(&l->timer); + kfree (l->logi); + kfree (l->fcmds); + kfree (l); + return 0; +} + +int fcp_forceoffline(fc_channel *fcchain, int count) +{ + fc_channel *fc; + fcp_cmnd *fcmd; + int i, ret; + lso l; + + memset (&l, 0, sizeof(lso)); + l.count = count; + l.magic = LSOMAGIC; + FCND(("FCP Force Offline for %d channels\n", count)) + init_MUTEX_LOCKED(&l.sem); + init_timer(&l.timer); + l.timer.function = fcp_login_timeout; + l.timer.data = (unsigned long)&l; + atomic_set (&l.todo, count); + l.fcmds = kzalloc (count * sizeof(fcp_cmnd), GFP_KERNEL); + if (!l.fcmds) { + printk ("FC: Cannot allocate memory for forcing offline\n"); + return -ENOMEM; + } + FCND(("Initializing OFFLINE packets\n")) + for (fc = fcchain, i = 0; fc && i < count; fc = fc->next, i++) { + fc->state = FC_STATE_UNINITED; + fcmd = l.fcmds + i; + fc->login = fcmd; + fc->ls = (void *)&l; + fcmd->did = fc->did; + fcmd->class = FC_CLASS_OFFLINE; + fcmd->proto = PROTO_OFFLINE; + fcmd->token = i; + fcmd->fc = fc; + disable_irq(fc->irq); + ret = fc->hw_enque (fc, fc->login); + enable_irq(fc->irq); + if (ret) printk ("FC: Cannot enque OFFLINE packet on %s\n", fc->name); + } + + l.timer.expires = jiffies + 5 * HZ; + add_timer(&l.timer); + down(&l.sem); + del_timer(&l.timer); + + for (fc = fcchain, i = 0; fc && i < count; fc = fc->next, i++) + fc->ls = NULL; + kfree (l.fcmds); + return 0; +} + +int fcp_init(fc_channel *fcchain) +{ + fc_channel *fc; + int count=0; + int ret; + + for (fc = fcchain; fc; fc = fc->next) { + fc->fcp_register = fcp_register; + count++; + } + + ret = fcp_initialize (fcchain, count); + if (ret) + return ret; + + if (!fc_channels) + fc_channels = fcchain; + else { + for (fc = fc_channels; fc->next; fc = fc->next); + fc->next = fcchain; + } + return ret; +} + +void fcp_release(fc_channel *fcchain, int count) /* count must > 0 */ +{ + fc_channel *fc; + fc_channel *fcx; + + for (fc = fcchain; --count && fc->next; fc = fc->next); + if (count) { + printk("FC: nothing to release\n"); + return; + } + + if (fc_channels == fcchain) + fc_channels = fc->next; + else { + for (fcx = fc_channels; fcx->next != fcchain; fcx = fcx->next); + fcx->next = fc->next; + } + fc->next = NULL; + + /* + * We've just grabbed fcchain out of the fc_channel list + * and zero-terminated it, while destroying the count. + * + * Freeing the fc's is the low level driver's responsibility. + */ +} + + +static void fcp_scsi_done(struct scsi_cmnd *SCpnt) +{ + if (FCP_CMND(SCpnt)->done) + FCP_CMND(SCpnt)->done(SCpnt); +} + +static int fcp_scsi_queue_it(fc_channel *fc, struct scsi_cmnd *SCpnt, + fcp_cmnd *fcmd, int prepare) +{ + long i; + fcp_cmd *cmd; + u32 fcp_cntl; + if (prepare) { + i = find_first_zero_bit (fc->scsi_bitmap, fc->scsi_bitmap_end); + set_bit (i, fc->scsi_bitmap); + fcmd->token = i; + cmd = fc->scsi_cmd_pool + i; + + if (fc->encode_addr (SCpnt, cmd->fcp_addr, fc, fcmd)) { + /* Invalid channel/id/lun and couldn't map it into fcp_addr */ + clear_bit (i, fc->scsi_bitmap); + SCpnt->result = (DID_BAD_TARGET << 16); + SCpnt->scsi_done(SCpnt); + return 0; + } + fc->scsi_free--; + fc->cmd_slots[fcmd->token] = fcmd; + + if (SCpnt->device->tagged_supported) { + if (jiffies - fc->ages[SCpnt->device->channel * fc->targets + SCpnt->device->id] > (5 * 60 * HZ)) { + fc->ages[SCpnt->device->channel * fc->targets + SCpnt->device->id] = jiffies; + fcp_cntl = FCP_CNTL_QTYPE_ORDERED; + } else + fcp_cntl = FCP_CNTL_QTYPE_SIMPLE; + } else + fcp_cntl = FCP_CNTL_QTYPE_UNTAGGED; + + if (!scsi_bufflen(SCpnt)) { + cmd->fcp_cntl = fcp_cntl; + fcmd->data = (dma_addr_t)NULL; + } else { + struct scatterlist *sg; + int nents; + + switch (SCpnt->cmnd[0]) { + case WRITE_6: + case WRITE_10: + case WRITE_12: + cmd->fcp_cntl = (FCP_CNTL_WRITE | fcp_cntl); break; + default: + cmd->fcp_cntl = (FCP_CNTL_READ | fcp_cntl); break; + } + + sg = scsi_sglist(SCpnt); + nents = dma_map_sg(fc->dev, sg, scsi_sg_count(SCpnt), + SCpnt->sc_data_direction); + fcmd->data = sg_dma_address(sg); + cmd->fcp_data_len = sg_dma_len(sg); + } + memcpy (cmd->fcp_cdb, SCpnt->cmnd, SCpnt->cmd_len); + memset (cmd->fcp_cdb+SCpnt->cmd_len, 0, sizeof(cmd->fcp_cdb)-SCpnt->cmd_len); + FCD(("XXX: %04x.%04x.%04x.%04x - %08x%08x%08x\n", cmd->fcp_addr[0], cmd->fcp_addr[1], cmd->fcp_addr[2], cmd->fcp_addr[3], *(u32 *)SCpnt->cmnd, *(u32 *)(SCpnt->cmnd+4), *(u32 *)(SCpnt->cmnd+8))) + } + FCD(("Trying to enque %p\n", fcmd)) + if (!fc->scsi_que) { + if (!fc->hw_enque (fc, fcmd)) { + FCD(("hw_enque succeeded for %p\n", fcmd)) + return 0; + } + } + FCD(("Putting into que1 %p\n", fcmd)) + fcp_scsi_insert_queue (fc, fcmd); + return 0; +} + +int fcp_scsi_queuecommand(struct scsi_cmnd *SCpnt, + void (* done)(struct scsi_cmnd *)) +{ + fcp_cmnd *fcmd = FCP_CMND(SCpnt); + fc_channel *fc = FC_SCMND(SCpnt); + + FCD(("Entering SCSI queuecommand %p\n", fcmd)) + if (SCpnt->done != fcp_scsi_done) { + fcmd->done = SCpnt->done; + SCpnt->done = fcp_scsi_done; + SCpnt->scsi_done = done; + fcmd->proto = TYPE_SCSI_FCP; + if (!fc->scsi_free) { + FCD(("FC: !scsi_free, putting cmd on ML queue\n")) +#if (FCP_SCSI_USE_NEW_EH_CODE == 0) + printk("fcp_scsi_queue_command: queue full, losing cmd, bad\n"); +#endif + return 1; + } + return fcp_scsi_queue_it(fc, SCpnt, fcmd, 1); + } + return fcp_scsi_queue_it(fc, SCpnt, fcmd, 0); +} + +void fcp_queue_empty(fc_channel *fc) +{ + fcp_cmnd *fcmd; + + FCD(("Queue empty\n")) + while ((fcmd = fc->scsi_que)) { + /* The hw told us we can try again queue some packet */ + if (fc->hw_enque (fc, fcmd)) + break; + fcp_scsi_remove_queue (fc, fcmd); + } +} + +int fcp_scsi_abort(struct scsi_cmnd *SCpnt) +{ + /* Internal bookkeeping only. Lose 1 cmd_slots slot. */ + fcp_cmnd *fcmd = FCP_CMND(SCpnt); + fc_channel *fc = FC_SCMND(SCpnt); + + /* + * We react to abort requests by simply forgetting + * about the command and pretending everything's sweet. + * This may or may not be silly. We can't, however, + * immediately reuse the command's cmd_slots slot, + * as its result may arrive later and we cannot + * check whether it is the aborted one, can't we? + * + * Therefore, after the first few aborts are done, + * we tell the scsi error handler to do something clever. + * It will eventually call host reset, refreshing + * cmd_slots for us. + * + * There is a theoretical chance that we sometimes allow + * more than can_queue packets to the jungle this way, + * but the worst outcome possible is a series of + * more aborts and eventually the dev_reset catharsis. + */ + + if (++fc->abort_count < (fc->can_queue >> 1)) { + SCpnt->result = DID_ABORT; + fcmd->done(SCpnt); + printk("FC: soft abort\n"); + return SUCCESS; + } else { + printk("FC: hard abort refused\n"); + return FAILED; + } +} + +#if 0 +void fcp_scsi_reset_done(struct scsi_cmnd *SCpnt) +{ + fc_channel *fc = FC_SCMND(SCpnt); + + fc->rst_pkt->eh_state = SCSI_STATE_FINISHED; + up(fc->rst_pkt->device->host->eh_action); +} +#endif + +#define FCP_RESET_TIMEOUT (2*HZ) + +int fcp_scsi_dev_reset(struct scsi_cmnd *SCpnt) +{ +#if 0 /* broken junk, but if davem wants to compile this driver, let him.. */ + unsigned long flags; + fcp_cmd *cmd; + fcp_cmnd *fcmd; + fc_channel *fc = FC_SCMND(SCpnt); + DECLARE_MUTEX_LOCKED(sem); + + if (!fc->rst_pkt) { + fc->rst_pkt = kmalloc(sizeof(SCpnt), GFP_KERNEL); + if (!fc->rst_pkt) return FAILED; + + fcmd = FCP_CMND(fc->rst_pkt); + + + fcmd->token = 0; + cmd = fc->scsi_cmd_pool + 0; + FCD(("Preparing rst packet\n")) + fc->encode_addr (SCpnt, cmd->fcp_addr, fc, fcmd); + fc->rst_pkt->device = SCpnt->device; + fc->rst_pkt->cmd_len = 0; + + fc->cmd_slots[0] = fcmd; + + cmd->fcp_cntl = FCP_CNTL_QTYPE_ORDERED | FCP_CNTL_RESET; + fcmd->data = (dma_addr_t)NULL; + fcmd->proto = TYPE_SCSI_FCP; + + memcpy (cmd->fcp_cdb, SCpnt->cmnd, SCpnt->cmd_len); + memset (cmd->fcp_cdb+SCpnt->cmd_len, 0, sizeof(cmd->fcp_cdb)-SCpnt->cmd_len); + FCD(("XXX: %04x.%04x.%04x.%04x - %08x%08x%08x\n", cmd->fcp_addr[0], cmd->fcp_addr[1], cmd->fcp_addr[2], cmd->fcp_addr[3], *(u32 *)SCpnt->cmnd, *(u32 *)(SCpnt->cmnd+4), *(u32 *)(SCpnt->cmnd+8))) + } else { + fcmd = FCP_CMND(fc->rst_pkt); + if (fc->rst_pkt->eh_state == SCSI_STATE_QUEUED) + return FAILED; /* or SUCCESS. Only these */ + } + fc->rst_pkt->done = NULL; + + + fc->rst_pkt->eh_state = SCSI_STATE_QUEUED; + init_timer(&fc->rst_pkt->eh_timeout); + fc->rst_pkt->eh_timeout.data = (unsigned long) fc->rst_pkt; + fc->rst_pkt->eh_timeout.expires = jiffies + FCP_RESET_TIMEOUT; + fc->rst_pkt->eh_timeout.function = (void (*)(unsigned long))fcp_scsi_reset_done; + + add_timer(&fc->rst_pkt->eh_timeout); + + /* + * Set up the semaphore so we wait for the command to complete. + */ + + fc->rst_pkt->device->host->eh_action = &sem; + + fc->rst_pkt->done = fcp_scsi_reset_done; + + spin_lock_irqsave(SCpnt->device->host->host_lock, flags); + fcp_scsi_queue_it(fc, fc->rst_pkt, fcmd, 0); + spin_unlock_irqrestore(SCpnt->device->host->host_lock, flags); + + down(&sem); + + fc->rst_pkt->device->host->eh_action = NULL; + del_timer(&fc->rst_pkt->eh_timeout); + + /* + * See if timeout. If so, tell the host to forget about it. + * In other words, we don't want a callback any more. + */ + if (fc->rst_pkt->eh_state == SCSI_STATE_TIMEOUT ) { + fc->rst_pkt->eh_state = SCSI_STATE_UNUSED; + return FAILED; + } + fc->rst_pkt->eh_state = SCSI_STATE_UNUSED; +#endif + return SUCCESS; +} + +static int __fcp_scsi_host_reset(struct scsi_cmnd *SCpnt) +{ + fc_channel *fc = FC_SCMND(SCpnt); + fcp_cmnd *fcmd = FCP_CMND(SCpnt); + int i; + + printk ("FC: host reset\n"); + + for (i=0; i < fc->can_queue; i++) { + if (fc->cmd_slots[i] && SCpnt->result != DID_ABORT) { + SCpnt->result = DID_RESET; + fcmd->done(SCpnt); + fc->cmd_slots[i] = NULL; + } + } + fc->reset(fc); + fc->abort_count = 0; + if (fcp_initialize(fc, 1)) return SUCCESS; + else return FAILED; +} + +int fcp_scsi_host_reset(struct scsi_cmnd *SCpnt) +{ + unsigned long flags; + int rc; + + spin_lock_irqsave(SCpnt->device->host->host_lock, flags); + rc = __fcp_scsi_host_reset(SCpnt); + spin_unlock_irqrestore(SCpnt->device->host->host_lock, flags); + + return rc; +} + +static int fcp_els_queue_it(fc_channel *fc, fcp_cmnd *fcmd) +{ + long i; + + i = find_first_zero_bit (fc->scsi_bitmap, fc->scsi_bitmap_end); + set_bit (i, fc->scsi_bitmap); + fcmd->token = i; + fc->scsi_free--; + fc->cmd_slots[fcmd->token] = fcmd; + return fcp_scsi_queue_it(fc, NULL, fcmd, 0); +} + +static int fc_do_els(fc_channel *fc, unsigned int alpa, void *data, int len) +{ + fcp_cmnd _fcmd, *fcmd; + fc_hdr *fch; + lse l; + int i; + + fcmd = &_fcmd; + memset(fcmd, 0, sizeof(fcp_cmnd)); + FCD(("PLOGI SID %d DID %d\n", fc->sid, alpa)) + fch = &fcmd->fch; + FILL_FCHDR_RCTL_DID(fch, R_CTL_ELS_REQ, alpa); + FILL_FCHDR_SID(fch, fc->sid); + FILL_FCHDR_TYPE_FCTL(fch, TYPE_EXTENDED_LS, F_CTL_FIRST_SEQ | F_CTL_SEQ_INITIATIVE); + FILL_FCHDR_SEQ_DF_SEQ(fch, 0, 0, 0); + FILL_FCHDR_OXRX(fch, 0xffff, 0xffff); + fch->param = 0; + fcmd->cmd = dma_map_single (fc->dev, data, 2 * len, DMA_BIDIRECTIONAL); + fcmd->rsp = fcmd->cmd + len; + fcmd->cmdlen = len; + fcmd->rsplen = len; + fcmd->data = (dma_addr_t)NULL; + fcmd->fc = fc; + fcmd->class = FC_CLASS_SIMPLE; + fcmd->proto = TYPE_EXTENDED_LS; + + memset (&l, 0, sizeof(lse)); + l.magic = LSEMAGIC; + init_MUTEX_LOCKED(&l.sem); + l.timer.function = fcp_login_timeout; + l.timer.data = (unsigned long)&l; + l.status = FC_STATUS_TIMED_OUT; + fcmd->ls = (void *)&l; + + disable_irq(fc->irq); + fcp_els_queue_it(fc, fcmd); + enable_irq(fc->irq); + + for (i = 0;;) { + l.timer.expires = jiffies + 5 * HZ; + add_timer(&l.timer); + down(&l.sem); + del_timer(&l.timer); + if (l.status != FC_STATUS_TIMED_OUT) break; + if (++i == 3) break; + disable_irq(fc->irq); + fcp_scsi_queue_it(fc, NULL, fcmd, 0); + enable_irq(fc->irq); + } + + clear_bit(fcmd->token, fc->scsi_bitmap); + fc->scsi_free++; + dma_unmap_single (fc->dev, fcmd->cmd, 2 * len, DMA_BIDIRECTIONAL); + return l.status; +} + +int fc_do_plogi(fc_channel *fc, unsigned char alpa, fc_wwn *node, fc_wwn *nport) +{ + logi *l; + int status; + + l = kzalloc(2 * sizeof(logi), GFP_KERNEL); + if (!l) return -ENOMEM; + l->code = LS_PLOGI; + memcpy (&l->nport_wwn, &fc->wwn_nport, sizeof(fc_wwn)); + memcpy (&l->node_wwn, &fc->wwn_node, sizeof(fc_wwn)); + memcpy (&l->common, fc->common_svc, sizeof(common_svc_parm)); + memcpy (&l->class1, fc->class_svcs, 3*sizeof(svc_parm)); + status = fc_do_els(fc, alpa, l, sizeof(logi)); + if (status == FC_STATUS_OK) { + if (l[1].code == LS_ACC) { +#ifdef FCDEBUG + u32 *u = (u32 *)&l[1].nport_wwn; + FCD(("AL-PA %02x: Port WWN %08x%08x Node WWN %08x%08x\n", alpa, + u[0], u[1], u[2], u[3])) +#endif + memcpy(nport, &l[1].nport_wwn, sizeof(fc_wwn)); + memcpy(node, &l[1].node_wwn, sizeof(fc_wwn)); + } else + status = FC_STATUS_BAD_RSP; + } + kfree(l); + return status; +} + +typedef struct { + unsigned int code; + unsigned params[4]; +} prli; + +int fc_do_prli(fc_channel *fc, unsigned char alpa) +{ + prli *p; + int status; + + p = kzalloc(2 * sizeof(prli), GFP_KERNEL); + if (!p) return -ENOMEM; + p->code = LS_PRLI; + p->params[0] = 0x08002000; + p->params[3] = 0x00000022; + status = fc_do_els(fc, alpa, p, sizeof(prli)); + if (status == FC_STATUS_OK && p[1].code != LS_PRLI_ACC && p[1].code != LS_ACC) + status = FC_STATUS_BAD_RSP; + kfree(p); + return status; +} + +MODULE_LICENSE("GPL"); + diff --git a/trunk/drivers/fc4/fc.h b/trunk/drivers/fc4/fc.h new file mode 100644 index 000000000000..13f89d4c8cb9 --- /dev/null +++ b/trunk/drivers/fc4/fc.h @@ -0,0 +1,230 @@ +/* fc.h: Definitions for Fibre Channel Physical and Signaling Interface. + * + * Copyright (C) 1996-1997,1999 Jakub Jelinek (jj@ultra.linux.cz) + * + * Sources: + * Fibre Channel Physical & Signaling Interface (FC-PH), dpANS, 1994 + * dpANS Fibre Channel Protocol for SCSI (X3.269-199X), Rev. 012, 1995 + */ + +#ifndef __FC_H +#define __FC_H + +/* World Wide Name */ +#define NAAID_IEEE 1 +#define NAAID_IEEE_EXT 2 +#define NAAID_LOCAL 3 +#define NAAID_IP 4 +#define NAAID_IEEE_REG 5 +#define NAAID_IEEE_REG_EXT 6 +#define NAAID_CCITT 12 +#define NAAID_CCITT_GRP 14 + +/* This is NAAID_IEEE_EXT scheme */ +typedef struct { + u32 naaid:4; + u32 nportid:12; + u32 hi:16; + u32 lo; +} fc_wwn; + +/* Frame header for FC-PH frames */ + +/* r_ctl field */ +#define R_CTL_DEVICE_DATA 0x00 /* FC4 Device_Data frame */ +#define R_CTL_EXTENDED_SVC 0x20 /* Extended Link_Data frame */ +#define R_CTL_FC4_SVC 0x30 /* FC4 Link_Data frame */ +#define R_CTL_VIDEO 0x40 /* Video_Data frame */ +#define R_CTL_BASIC_SVC 0x80 /* Basic Link_Data frame */ +#define R_CTL_LINK_CTL 0xc0 /* Link_Control frame */ +/* FC4 Device_Data frames */ +#define R_CTL_UNCATEGORIZED 0x00 +#define R_CTL_SOLICITED_DATA 0x01 +#define R_CTL_UNSOL_CONTROL 0x02 +#define R_CTL_SOLICITED_CONTROL 0x03 +#define R_CTL_UNSOL_DATA 0x04 +#define R_CTL_XFER_RDY 0x05 +#define R_CTL_COMMAND 0x06 +#define R_CTL_STATUS 0x07 +/* Basic Link_Data frames */ +#define R_CTL_LS_NOP 0x80 +#define R_CTL_LS_ABTS 0x81 +#define R_CTL_LS_RMC 0x82 +#define R_CTL_LS_BA_ACC 0x84 +#define R_CTL_LS_BA_RJT 0x85 +/* Extended Link_Data frames */ +#define R_CTL_ELS_REQ 0x22 +#define R_CTL_ELS_RSP 0x23 +/* Link_Control frames */ +#define R_CTL_ACK_1 0xc0 +#define R_CTL_ACK_N 0xc1 +#define R_CTL_P_RJT 0xc2 +#define R_CTL_F_RJT 0xc3 +#define R_CTL_P_BSY 0xc4 +#define R_CTL_F_BSY_DF 0xc5 +#define R_CTL_F_BSY_LC 0xc6 +#define R_CTL_LCR 0xc7 + +/* type field */ +#define TYPE_BASIC_LS 0x00 +#define TYPE_EXTENDED_LS 0x01 +#define TYPE_IS8802 0x04 +#define TYPE_IS8802_SNAP 0x05 +#define TYPE_SCSI_FCP 0x08 +#define TYPE_SCSI_GPP 0x09 +#define TYPE_HIPP_FP 0x0a +#define TYPE_IPI3_MASTER 0x11 +#define TYPE_IPI3_SLAVE 0x12 +#define TYPE_IPI3_PEER 0x13 + +/* f_ctl field */ +#define F_CTL_FILL_BYTES 0x000003 +#define F_CTL_XCHG_REASSEMBLE 0x000004 +#define F_CTL_RO_PRESENT 0x000008 +#define F_CTL_ABORT_SEQ 0x000030 +#define F_CTL_CONTINUE_SEQ 0x0000c0 +#define F_CTL_INVALIDATE_XID 0x004000 +#define F_CTL_XID_REASSIGNED 0x008000 +#define F_CTL_SEQ_INITIATIVE 0x010000 +#define F_CTL_CHAINED_SEQ 0x020000 +#define F_CTL_END_CONNECT 0x040000 +#define F_CTL_END_SEQ 0x080000 +#define F_CTL_LAST_SEQ 0x100000 +#define F_CTL_FIRST_SEQ 0x200000 +#define F_CTL_SEQ_CONTEXT 0x400000 +#define F_CTL_XCHG_CONTEXT 0x800000 + +typedef struct { + u32 r_ctl:8, did:24; + u32 xxx1:8, sid:24; + u32 type:8, f_ctl:24; + u32 seq_id:8, df_ctl:8, seq_cnt:16; + u16 ox_id, rx_id; + u32 param; +} fc_hdr; +/* The following are ugly macros to make setup of this structure faster */ +#define FILL_FCHDR_RCTL_DID(fch, r_ctl, did) *(u32 *)(fch) = ((r_ctl) << 24) | (did); +#define FILL_FCHDR_SID(fch, sid) *((u32 *)(fch)+1) = (sid); +#define FILL_FCHDR_TYPE_FCTL(fch, type, f_ctl) *((u32 *)(fch)+2) = ((type) << 24) | (f_ctl); +#define FILL_FCHDR_SEQ_DF_SEQ(fch, seq_id, df_ctl, seq_cnt) *((u32 *)(fch)+3) = ((seq_id) << 24) | ((df_ctl) << 16) | (seq_cnt); +#define FILL_FCHDR_OXRX(fch, ox_id, rx_id) *((u32 *)(fch)+4) = ((ox_id) << 16) | (rx_id); + +/* Well known addresses */ +#define FS_GENERAL_MULTICAST 0xfffff7 +#define FS_WELL_KNOWN_MULTICAST 0xfffff8 +#define FS_HUNT_GROUP 0xfffff9 +#define FS_MANAGEMENT_SERVER 0xfffffa +#define FS_TIME_SERVER 0xfffffb +#define FS_NAME_SERVER 0xfffffc +#define FS_FABRIC_CONTROLLER 0xfffffd +#define FS_FABRIC_F_PORT 0xfffffe +#define FS_BROADCAST 0xffffff + +/* Reject frames */ +/* The param field should be cast to this structure */ +typedef struct { + u8 action; + u8 reason; + u8 xxx; + u8 vendor_unique; +} rjt_param; + +/* Reject action codes */ +#define RJT_RETRY 0x01 +#define RJT_NONRETRY 0x02 + +/* Reject reason codes */ +#define RJT_INVALID_DID 0x01 +#define RJT_INVALID_SID 0x02 +#define RJT_NPORT_NOT_AVAIL_TEMP 0x03 +#define RJT_NPORT_NOT_AVAIL_PERM 0x04 +#define RJT_CLASS_NOT_SUPPORTED 0x05 +#define RJT_DELIMITER_ERROR 0x06 +#define RJT_TYPE_NOT_SUPPORTED 0x07 +#define RJT_INVALID_LINK_CONTROL 0x08 +#define RJT_INVALID_R_CTL 0x09 +#define RJT_INVALID_F_CTL 0x0a +#define RJT_INVALID_OX_ID 0x0b +#define RJT_INVALID_RX_ID 0x0c +#define RJT_INVALID_SEQ_ID 0x0d +#define RJT_INVALID_DF_CTL 0x0e +#define RJT_INVALID_SEQ_CNT 0x0f +#define RJT_INVALID_PARAMETER 0x10 +#define RJT_EXCHANGE_ERROR 0x11 +#define RJT_PROTOCOL_ERROR 0x12 +#define RJT_INCORRECT_LENGTH 0x13 +#define RJT_UNEXPECTED_ACK 0x14 +#define RJT_UNEXPECTED_LINK_RESP 0x15 +#define RJT_LOGIN_REQUIRED 0x16 +#define RJT_EXCESSIVE_SEQUENCES 0x17 +#define RJT_CANT_ESTABLISH_EXCHANGE 0x18 +#define RJT_SECURITY_NOT_SUPPORTED 0x19 +#define RJT_FABRIC_NA 0x1a +#define RJT_VENDOR_UNIQUE 0xff + + +#define SP_F_PORT_LOGIN 0x10 + +/* Extended SVC commands */ +#define LS_RJT 0x01000000 +#define LS_ACC 0x02000000 +#define LS_PRLI_ACC 0x02100014 +#define LS_PLOGI 0x03000000 +#define LS_FLOGI 0x04000000 +#define LS_LOGO 0x05000000 +#define LS_ABTX 0x06000000 +#define LS_RCS 0x07000000 +#define LS_RES 0x08000000 +#define LS_RSS 0x09000000 +#define LS_RSI 0x0a000000 +#define LS_ESTS 0x0b000000 +#define LS_ESTC 0x0c000000 +#define LS_ADVC 0x0d000000 +#define LS_RTV 0x0e000000 +#define LS_RLS 0x0f000000 +#define LS_ECHO 0x10000000 +#define LS_TEST 0x11000000 +#define LS_RRQ 0x12000000 +#define LS_IDENT 0x20000000 +#define LS_PRLI 0x20100014 +#define LS_DISPLAY 0x21000000 +#define LS_PRLO 0x21100014 +#define LS_PDISC 0x50000000 +#define LS_ADISC 0x52000000 + +typedef struct { + u8 fcph_hi, fcph_lo; + u16 buf2buf_credit; + u8 common_features; + u8 xxx1; + u16 buf2buf_size; + u8 xxx2; + u8 total_concurrent; + u16 off_by_info; + u32 e_d_tov; +} common_svc_parm; + +typedef struct { + u16 serv_opts; + u16 initiator_ctl; + u16 rcpt_ctl; + u16 recv_size; + u8 xxx1; + u8 concurrent_seqs; + u16 end2end_credit; + u16 open_seqs_per_xchg; + u16 xxx2; +} svc_parm; + +/* Login */ +typedef struct { + u32 code; + common_svc_parm common; + fc_wwn nport_wwn; + fc_wwn node_wwn; + svc_parm class1; + svc_parm class2; + svc_parm class3; +} logi; + +#endif /* !(__FC_H) */ diff --git a/trunk/drivers/fc4/fc_syms.c b/trunk/drivers/fc4/fc_syms.c new file mode 100644 index 000000000000..bd3918ddf7ac --- /dev/null +++ b/trunk/drivers/fc4/fc_syms.c @@ -0,0 +1,30 @@ +/* + * We should not even be trying to compile this if we are not doing + * a module. + */ +#include + +#ifdef CONFIG_MODULES + +#include +#include +#include + +#include "fcp_impl.h" + +EXPORT_SYMBOL(fcp_init); +EXPORT_SYMBOL(fcp_release); +EXPORT_SYMBOL(fcp_queue_empty); +EXPORT_SYMBOL(fcp_receive_solicited); +EXPORT_SYMBOL(fc_channels); +EXPORT_SYMBOL(fcp_state_change); +EXPORT_SYMBOL(fc_do_plogi); +EXPORT_SYMBOL(fc_do_prli); + +/* SCSI stuff */ +EXPORT_SYMBOL(fcp_scsi_queuecommand); +EXPORT_SYMBOL(fcp_scsi_abort); +EXPORT_SYMBOL(fcp_scsi_dev_reset); +EXPORT_SYMBOL(fcp_scsi_host_reset); + +#endif /* CONFIG_MODULES */ diff --git a/trunk/drivers/fc4/fcp.h b/trunk/drivers/fc4/fcp.h new file mode 100644 index 000000000000..6aa34a7a4c11 --- /dev/null +++ b/trunk/drivers/fc4/fcp.h @@ -0,0 +1,94 @@ +/* fcp.h: Definitions for Fibre Channel Protocol. + * + * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz) + * + */ + +#ifndef __FCP_H +#define __FCP_H + +/* FCP addressing is hierarchical with up to 4 layers, MS first. + Exact meaning of the addresses is up to the vendor */ + +/* fcp_cntl field */ +#define FCP_CNTL_WRITE 0x00000001 /* Initiator write */ +#define FCP_CNTL_READ 0x00000002 /* Initiator read */ +#define FCP_CNTL_ABORT_TSK 0x00000200 /* Abort task set */ +#define FCP_CNTL_CLR_TASK 0x00000400 /* Clear task set */ +#define FCP_CNTL_RESET 0x00002000 /* Reset */ +#define FCP_CNTL_CLR_ACA 0x00004000 /* Clear ACA */ +#define FCP_CNTL_KILL_TASK 0x00008000 /* Terminate task */ +#define FCP_CNTL_QTYPE_MASK 0x00070000 /* Tagged queueing type */ +#define FCP_CNTL_QTYPE_SIMPLE 0x00000000 +#define FCP_CNTL_QTYPE_HEAD_OF_Q 0x00010000 +#define FCP_CNTL_QTYPE_ORDERED 0x00020000 +#define FCP_CNTL_QTYPE_ACA_Q_TAG 0x00040000 +#define FCP_CNTL_QTYPE_UNTAGGED 0x00050000 + +typedef struct { + u16 fcp_addr[4]; + u32 fcp_cntl; + u8 fcp_cdb[16]; + u32 fcp_data_len; +} fcp_cmd; + +/* fcp_status field */ +#define FCP_STATUS_MASK 0x000000ff /* scsi status of command */ +#define FCP_STATUS_RSP_LEN 0x00000100 /* response_len != 0 */ +#define FCP_STATUS_SENSE_LEN 0x00000200 /* sense_len != 0 */ +#define FCP_STATUS_RESID 0x00000400 /* resid != 0 */ + +typedef struct { + u32 xxx[2]; + u32 fcp_status; + u32 fcp_resid; + u32 fcp_sense_len; + u32 fcp_response_len; + /* u8 fcp_sense[fcp_sense_len]; */ + /* u8 fcp_response[fcp_response_len]; */ +} fcp_rsp; + +/* fcp errors */ + +/* rsp_info_type field */ +#define FCP_RSP_SCSI_BUS_ERR 0x01 +#define FCP_RSP_SCSI_PORT_ERR 0x02 +#define FCP_RSP_CARD_ERR 0x03 + +/* isp_status field */ +#define FCP_RSP_CMD_COMPLETE 0x0000 +#define FCP_RSP_CMD_INCOMPLETE 0x0001 +#define FCP_RSP_CMD_DMA_ERR 0x0002 +#define FCP_RSP_CMD_TRAN_ERR 0x0003 +#define FCP_RSP_CMD_RESET 0x0004 +#define FCP_RSP_CMD_ABORTED 0x0005 +#define FCP_RSP_CMD_TIMEOUT 0x0006 +#define FCP_RSP_CMD_OVERRUN 0x0007 + +/* isp_state_flags field */ +#define FCP_RSP_ST_GOT_BUS 0x0100 +#define FCP_RSP_ST_GOT_TARGET 0x0200 +#define FCP_RSP_ST_SENT_CMD 0x0400 +#define FCP_RSP_ST_XFRD_DATA 0x0800 +#define FCP_RSP_ST_GOT_STATUS 0x1000 +#define FCP_RSP_ST_GOT_SENSE 0x2000 + +/* isp_stat_flags field */ +#define FCP_RSP_STAT_DISC 0x0001 +#define FCP_RSP_STAT_SYNC 0x0002 +#define FCP_RSP_STAT_PERR 0x0004 +#define FCP_RSP_STAT_BUS_RESET 0x0008 +#define FCP_RSP_STAT_DEV_RESET 0x0010 +#define FCP_RSP_STAT_ABORTED 0x0020 +#define FCP_RSP_STAT_TIMEOUT 0x0040 +#define FCP_RSP_STAT_NEGOTIATE 0x0080 + +typedef struct { + u8 rsp_info_type; + u8 xxx; + u16 isp_status; + u16 isp_state_flags; + u16 isp_stat_flags; +} fcp_scsi_err; + +#endif /* !(__FCP_H) */ diff --git a/trunk/drivers/fc4/fcp_impl.h b/trunk/drivers/fc4/fcp_impl.h new file mode 100644 index 000000000000..506338a461ba --- /dev/null +++ b/trunk/drivers/fc4/fcp_impl.h @@ -0,0 +1,164 @@ +/* fcp_impl.h: Generic SCSI on top of FC4 - our interface defines. + * + * Copyright (C) 1997-1999 Jakub Jelinek (jj@ultra.linux.cz) + * Copyright (C) 1998 Jirka Hanika (geo@ff.cuni.cz) + */ + +#ifndef _FCP_SCSI_H +#define _FCP_SCSI_H + +#include +#include "../scsi/scsi.h" + +#include "fc.h" +#include "fcp.h" +#include "fc-al.h" + +#include +#ifdef __sparc__ +#include +#endif + +/* 0 or 1 */ +#define FCP_SCSI_USE_NEW_EH_CODE 0 + +#define FC_CLASS_OUTBOUND 0x01 +#define FC_CLASS_INBOUND 0x02 +#define FC_CLASS_SIMPLE 0x03 +#define FC_CLASS_IO_WRITE 0x04 +#define FC_CLASS_IO_READ 0x05 +#define FC_CLASS_UNSOLICITED 0x06 +#define FC_CLASS_OFFLINE 0x08 + +#define PROTO_OFFLINE 0x02 +#define PROTO_REPORT_AL_MAP 0x03 +#define PROTO_FORCE_LIP 0x06 + +struct _fc_channel; + +typedef struct fcp_cmnd { + struct fcp_cmnd *next; + struct fcp_cmnd *prev; + void (*done)(struct scsi_cmnd *); + unsigned short proto; + unsigned short token; + unsigned int did; + /* FCP SCSI stuff */ + dma_addr_t data; + /* From now on this cannot be touched for proto == TYPE_SCSI_FCP */ + fc_hdr fch; + dma_addr_t cmd; + dma_addr_t rsp; + int cmdlen; + int rsplen; + int class; + int datalen; + /* This is just used as a verification during login */ + struct _fc_channel *fc; + void *ls; +} fcp_cmnd; + +typedef struct { + unsigned int len; + unsigned char list[0]; +} fcp_posmap; + +typedef struct _fc_channel { + struct _fc_channel *next; + int irq; + int state; + int sid; + int did; + char name[16]; + void (*fcp_register)(struct _fc_channel *, u8, int); + void (*reset)(struct _fc_channel *); + int (*hw_enque)(struct _fc_channel *, fcp_cmnd *); + fc_wwn wwn_node; + fc_wwn wwn_nport; + fc_wwn wwn_dest; + common_svc_parm *common_svc; + svc_parm *class_svcs; +#ifdef __sparc__ + struct sbus_dev *dev; +#else + struct pci_dev *dev; +#endif + struct module *module; + /* FCP SCSI stuff */ + short can_queue; + short abort_count; + int rsp_size; + fcp_cmd *scsi_cmd_pool; + char *scsi_rsp_pool; + dma_addr_t dma_scsi_cmd, dma_scsi_rsp; + unsigned long *scsi_bitmap; + long scsi_bitmap_end; + int scsi_free; + int (*encode_addr)(struct scsi_cmnd *, u16 *, struct _fc_channel *, fcp_cmnd *); + fcp_cmnd *scsi_que; + char scsi_name[4]; + fcp_cmnd **cmd_slots; + int channels; + int targets; + long *ages; + struct scsi_cmnd *rst_pkt; + fcp_posmap *posmap; + /* LOGIN stuff */ + fcp_cmnd *login; + void *ls; +} fc_channel; + +extern fc_channel *fc_channels; + +#define FC_STATE_UNINITED 0 +#define FC_STATE_ONLINE 1 +#define FC_STATE_OFFLINE 2 +#define FC_STATE_RESETING 3 +#define FC_STATE_FPORT_OK 4 +#define FC_STATE_MAYBEOFFLINE 5 + +#define FC_STATUS_OK 0 +#define FC_STATUS_P_RJT 2 +#define FC_STATUS_F_RJT 3 +#define FC_STATUS_P_BSY 4 +#define FC_STATUS_F_BSY 5 +#define FC_STATUS_ERR_OFFLINE 0x11 +#define FC_STATUS_TIMEOUT 0x12 +#define FC_STATUS_ERR_OVERRUN 0x13 +#define FC_STATUS_POINTTOPOINT 0x15 +#define FC_STATUS_AL 0x16 +#define FC_STATUS_UNKNOWN_CQ_TYPE 0x20 +#define FC_STATUS_BAD_SEG_CNT 0x21 +#define FC_STATUS_MAX_XCHG_EXCEEDED 0x22 +#define FC_STATUS_BAD_XID 0x23 +#define FC_STATUS_XCHG_BUSY 0x24 +#define FC_STATUS_BAD_POOL_ID 0x25 +#define FC_STATUS_INSUFFICIENT_CQES 0x26 +#define FC_STATUS_ALLOC_FAIL 0x27 +#define FC_STATUS_BAD_SID 0x28 +#define FC_STATUS_NO_SEQ_INIT 0x29 +#define FC_STATUS_TIMED_OUT -1 +#define FC_STATUS_BAD_RSP -2 + +void fcp_queue_empty(fc_channel *); +int fcp_init(fc_channel *); +void fcp_release(fc_channel *fc_chain, int count); +void fcp_receive_solicited(fc_channel *, int, int, int, fc_hdr *); +void fcp_state_change(fc_channel *, int); +int fc_do_plogi(fc_channel *, unsigned char, fc_wwn *, fc_wwn *); +int fc_do_prli(fc_channel *, unsigned char); + +#define for_each_fc_channel(fc) \ + for (fc = fc_channels; fc; fc = fc->next) + +#define for_each_online_fc_channel(fc) \ + for_each_fc_channel(fc) \ + if (fc->state == FC_STATE_ONLINE) + +int fcp_scsi_queuecommand(struct scsi_cmnd *, + void (* done) (struct scsi_cmnd *)); +int fcp_scsi_abort(struct scsi_cmnd *); +int fcp_scsi_dev_reset(struct scsi_cmnd *); +int fcp_scsi_host_reset(struct scsi_cmnd *); + +#endif /* !(_FCP_SCSI_H) */ diff --git a/trunk/drivers/fc4/soc.c b/trunk/drivers/fc4/soc.c new file mode 100644 index 000000000000..d517734462e6 --- /dev/null +++ b/trunk/drivers/fc4/soc.c @@ -0,0 +1,764 @@ +/* soc.c: Sparc SUNW,soc (Serial Optical Channel) Fibre Channel Sbus adapter support. + * + * Copyright (C) 1996,1997,1999 Jakub Jelinek (jj@ultra.linux.cz) + * Copyright (C) 1997,1998 Jirka Hanika (geo@ff.cuni.cz) + * + * Sources: + * Fibre Channel Physical & Signaling Interface (FC-PH), dpANS, 1994 + * dpANS Fibre Channel Protocol for SCSI (X3.269-199X), Rev. 012, 1995 + * + * Supported hardware: + * Tested on SOC sbus card bought with SS1000 in Linux running on SS5 and Ultra1. + * For SOC sbus cards, you have to make sure your FCode is 1.52 or later. + * If you have older FCode, you should try to upgrade or get SOC microcode from Sun + * (the microcode is present in Solaris soc driver as well). In that case you need + * to #define HAVE_SOC_UCODE and format the microcode into soc_asm.c. For the exact + * format mail me and I will tell you. I cannot offer you the actual microcode though, + * unless Sun confirms they don't mind. + */ + +static char *version = + "soc.c:v1.3 9/Feb/99 Jakub Jelinek (jj@ultra.linux.cz), Jirka Hanika (geo@ff.cuni.cz)\n"; + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +/* #define SOCDEBUG */ +/* #define HAVE_SOC_UCODE */ + +#include "fcp_impl.h" +#include "soc.h" +#ifdef HAVE_SOC_UCODE +#include "soc_asm.h" +#endif + +#define soc_printk printk ("soc%d: ", s->soc_no); printk + +#ifdef SOCDEBUG +#define SOD(x) soc_printk x; +#else +#define SOD(x) +#endif + +#define for_each_soc(s) for (s = socs; s; s = s->next) +struct soc *socs = NULL; + +static inline void soc_disable(struct soc *s) +{ + sbus_writel(0, s->regs + IMASK); + sbus_writel(SOC_CMD_SOFT_RESET, s->regs + CMD); +} + +static inline void soc_enable(struct soc *s) +{ + SOD(("enable %08x\n", s->cfg)) + sbus_writel(0, s->regs + SAE); + sbus_writel(s->cfg, s->regs + CFG); + sbus_writel(SOC_CMD_RSP_QALL, s->regs + CMD); + SOC_SETIMASK(s, SOC_IMASK_RSP_QALL | SOC_IMASK_SAE); + SOD(("imask %08lx %08lx\n", s->imask, sbus_readl(s->regs + IMAK))); +} + +static void soc_reset(fc_channel *fc) +{ + soc_port *port = (soc_port *)fc; + struct soc *s = port->s; + + /* FIXME */ + soc_disable(s); + s->req[0].seqno = 1; + s->req[1].seqno = 1; + s->rsp[0].seqno = 1; + s->rsp[1].seqno = 1; + s->req[0].in = 0; + s->req[1].in = 0; + s->rsp[0].in = 0; + s->rsp[1].in = 0; + s->req[0].out = 0; + s->req[1].out = 0; + s->rsp[0].out = 0; + s->rsp[1].out = 0; + + /* FIXME */ + soc_enable(s); +} + +static inline void soc_solicited (struct soc *s) +{ + fc_hdr fchdr; + soc_rsp __iomem *hwrsp; + soc_cq_rsp *sw_cq; + int token; + int status; + fc_channel *fc; + + sw_cq = &s->rsp[SOC_SOLICITED_RSP_Q]; + + if (sw_cq->pool == NULL) + sw_cq->pool = (soc_req __iomem *) + (s->xram + xram_get_32low ((xram_p)&sw_cq->hw_cq->address)); + sw_cq->in = xram_get_8 ((xram_p)&sw_cq->hw_cq->in); + SOD (("soc_solicited, %d pkts arrived\n", (sw_cq->in-sw_cq->out) & sw_cq->last)) + for (;;) { + hwrsp = (soc_rsp __iomem *)sw_cq->pool + sw_cq->out; + token = xram_get_32low ((xram_p)&hwrsp->shdr.token); + status = xram_get_32low ((xram_p)&hwrsp->status); + fc = (fc_channel *)(&s->port[(token >> 11) & 1]); + + if (status == SOC_OK) { + fcp_receive_solicited(fc, token >> 12, + token & ((1 << 11) - 1), + FC_STATUS_OK, NULL); + } else { + xram_copy_from(&fchdr, (xram_p)&hwrsp->fchdr, sizeof(fchdr)); + /* We have intentionally defined FC_STATUS_* constants + * to match SOC_* constants, otherwise we'd have to + * translate status. + */ + fcp_receive_solicited(fc, token >> 12, + token & ((1 << 11) - 1), + status, &fchdr); + } + + if (++sw_cq->out > sw_cq->last) { + sw_cq->seqno++; + sw_cq->out = 0; + } + + if (sw_cq->out == sw_cq->in) { + sw_cq->in = xram_get_8 ((xram_p)&sw_cq->hw_cq->in); + if (sw_cq->out == sw_cq->in) { + /* Tell the hardware about it */ + sbus_writel((sw_cq->out << 24) | + (SOC_CMD_RSP_QALL & + ~(SOC_CMD_RSP_Q0 << SOC_SOLICITED_RSP_Q)), + s->regs + CMD); + + /* Read it, so that we're sure it has been updated */ + sbus_readl(s->regs + CMD); + sw_cq->in = xram_get_8 ((xram_p)&sw_cq->hw_cq->in); + if (sw_cq->out == sw_cq->in) + break; + } + } + } +} + +static inline void soc_request (struct soc *s, u32 cmd) +{ + SOC_SETIMASK(s, s->imask & ~(cmd & SOC_CMD_REQ_QALL)); + SOD(("imask %08lx %08lx\n", s->imask, sbus_readl(s->regs + IMASK))); + + SOD(("Queues available %08x OUT %X %X\n", cmd, + xram_get_8((xram_p)&s->req[0].hw_cq->out), + xram_get_8((xram_p)&s->req[0].hw_cq->out))) + if (s->port[s->curr_port].fc.state != FC_STATE_OFFLINE) { + fcp_queue_empty ((fc_channel *)&(s->port[s->curr_port])); + if (((s->req[1].in + 1) & s->req[1].last) != (s->req[1].out)) + fcp_queue_empty ((fc_channel *)&(s->port[1 - s->curr_port])); + } else { + fcp_queue_empty ((fc_channel *)&(s->port[1 - s->curr_port])); + } + if (s->port[1 - s->curr_port].fc.state != FC_STATE_OFFLINE) + s->curr_port ^= 1; +} + +static inline void soc_unsolicited (struct soc *s) +{ + soc_rsp __iomem *hwrsp, *hwrspc; + soc_cq_rsp *sw_cq; + int count; + int status; + int flags; + fc_channel *fc; + + sw_cq = &s->rsp[SOC_UNSOLICITED_RSP_Q]; + if (sw_cq->pool == NULL) + sw_cq->pool = (soc_req __iomem *) + (s->xram + (xram_get_32low ((xram_p)&sw_cq->hw_cq->address))); + + sw_cq->in = xram_get_8 ((xram_p)&sw_cq->hw_cq->in); + SOD (("soc_unsolicited, %d packets arrived\n", (sw_cq->in - sw_cq->out) & sw_cq->last)) + while (sw_cq->in != sw_cq->out) { + /* ...real work per entry here... */ + hwrsp = (soc_rsp __iomem *)sw_cq->pool + sw_cq->out; + + hwrspc = NULL; + flags = xram_get_16 ((xram_p)&hwrsp->shdr.flags); + count = xram_get_8 ((xram_p)&hwrsp->count); + fc = (fc_channel *)&s->port[flags & SOC_PORT_B]; + SOD(("FC %08lx fcp_state_change %08lx\n", + (long)fc, (long)fc->fcp_state_change)) + + if (count != 1) { + /* Ugh, continuation entries */ + u8 in; + + if (count != 2) { + printk("%s: Too many continuations entries %d\n", + fc->name, count); + goto update_out; + } + + in = sw_cq->in; + if (in < sw_cq->out) in += sw_cq->last + 1; + if (in < sw_cq->out + 2) { + /* Ask the hardware if they haven't arrived yet. */ + sbus_writel((sw_cq->out << 24) | + (SOC_CMD_RSP_QALL & + ~(SOC_CMD_RSP_Q0 << SOC_UNSOLICITED_RSP_Q)), + s->regs + CMD); + + /* Read it, so that we're sure it has been updated */ + sbus_readl(s->regs + CMD); + sw_cq->in = xram_get_8 ((xram_p)&sw_cq->hw_cq->in); + in = sw_cq->in; + if (in < sw_cq->out) + in += sw_cq->last + 1; + if (in < sw_cq->out + 2) /* Nothing came, let us wait */ + return; + } + if (sw_cq->out == sw_cq->last) + hwrspc = (soc_rsp __iomem *)sw_cq->pool; + else + hwrspc = hwrsp + 1; + } + + switch (flags & ~SOC_PORT_B) { + case SOC_STATUS: + status = xram_get_32low ((xram_p)&hwrsp->status); + switch (status) { + case SOC_ONLINE: + SOD(("State change to ONLINE\n")); + fcp_state_change(fc, FC_STATE_ONLINE); + break; + case SOC_OFFLINE: + SOD(("State change to OFFLINE\n")); + fcp_state_change(fc, FC_STATE_OFFLINE); + break; + default: + printk ("%s: Unknown STATUS no %d\n", + fc->name, status); + break; + } + break; + case (SOC_UNSOLICITED|SOC_FC_HDR): + { + int r_ctl = xram_get_8 ((xram_p)&hwrsp->fchdr); + unsigned len; + char buf[64]; + + if ((r_ctl & 0xf0) == R_CTL_EXTENDED_SVC) { + len = xram_get_32 ((xram_p)&hwrsp->shdr.bytecnt); + if (len < 4 || !hwrspc) { + printk ("%s: Invalid R_CTL %02x " + "continuation entries\n", + fc->name, r_ctl); + } else { + if (len > 60) + len = 60; + xram_copy_from (buf, (xram_p)hwrspc, + (len + 3) & ~3); + if (*(u32 *)buf == LS_DISPLAY) { + int i; + + for (i = 4; i < len; i++) + if (buf[i] == '\n') + buf[i] = ' '; + buf[len] = 0; + printk ("%s message: %s\n", + fc->name, buf + 4); + } else { + printk ("%s: Unknown LS_CMD " + "%02x\n", fc->name, + buf[0]); + } + } + } else { + printk ("%s: Unsolicited R_CTL %02x " + "not handled\n", fc->name, r_ctl); + } + } + break; + default: + printk ("%s: Unexpected flags %08x\n", fc->name, flags); + break; + }; +update_out: + if (++sw_cq->out > sw_cq->last) { + sw_cq->seqno++; + sw_cq->out = 0; + } + + if (hwrspc) { + if (++sw_cq->out > sw_cq->last) { + sw_cq->seqno++; + sw_cq->out = 0; + } + } + + if (sw_cq->out == sw_cq->in) { + sw_cq->in = xram_get_8 ((xram_p)&sw_cq->hw_cq->in); + if (sw_cq->out == sw_cq->in) { + /* Tell the hardware about it */ + sbus_writel((sw_cq->out << 24) | + (SOC_CMD_RSP_QALL & + ~(SOC_CMD_RSP_Q0 << SOC_UNSOLICITED_RSP_Q)), + s->regs + CMD); + + /* Read it, so that we're sure it has been updated */ + sbus_readl(s->regs + CMD); + sw_cq->in = xram_get_8 ((xram_p)&sw_cq->hw_cq->in); + } + } + } +} + +static irqreturn_t soc_intr(int irq, void *dev_id) +{ + u32 cmd; + unsigned long flags; + register struct soc *s = (struct soc *)dev_id; + + spin_lock_irqsave(&s->lock, flags); + cmd = sbus_readl(s->regs + CMD); + for (; (cmd = SOC_INTR (s, cmd)); cmd = sbus_readl(s->regs + CMD)) { + if (cmd & SOC_CMD_RSP_Q1) soc_unsolicited (s); + if (cmd & SOC_CMD_RSP_Q0) soc_solicited (s); + if (cmd & SOC_CMD_REQ_QALL) soc_request (s, cmd); + } + spin_unlock_irqrestore(&s->lock, flags); + + return IRQ_HANDLED; +} + +#define TOKEN(proto, port, token) (((proto)<<12)|(token)|(port)) + +static int soc_hw_enque (fc_channel *fc, fcp_cmnd *fcmd) +{ + soc_port *port = (soc_port *)fc; + struct soc *s = port->s; + int qno; + soc_cq_req *sw_cq; + int cq_next_in; + soc_req *request; + fc_hdr *fch; + int i; + + if (fcmd->proto == TYPE_SCSI_FCP) + qno = 1; + else + qno = 0; + SOD(("Putting a FCP packet type %d into hw queue %d\n", fcmd->proto, qno)) + if (s->imask & (SOC_IMASK_REQ_Q0 << qno)) { + SOD(("EIO %08x\n", s->imask)) + return -EIO; + } + sw_cq = s->req + qno; + cq_next_in = (sw_cq->in + 1) & sw_cq->last; + + if (cq_next_in == sw_cq->out && + cq_next_in == (sw_cq->out = xram_get_8((xram_p)&sw_cq->hw_cq->out))) { + SOD(("%d IN %d OUT %d LAST %d\n", qno, sw_cq->in, sw_cq->out, sw_cq->last)) + SOC_SETIMASK(s, s->imask | (SOC_IMASK_REQ_Q0 << qno)); + SOD(("imask %08lx %08lx\n", s->imask, sbus_readl(s->regs + IMASK))); + /* If queue is full, just say NO */ + return -EBUSY; + } + + request = sw_cq->pool + sw_cq->in; + fch = &request->fchdr; + + switch (fcmd->proto) { + case TYPE_SCSI_FCP: + request->shdr.token = TOKEN(TYPE_SCSI_FCP, port->mask, fcmd->token); + request->data[0].base = fc->dma_scsi_cmd + fcmd->token * sizeof(fcp_cmd); + request->data[0].count = sizeof(fcp_cmd); + request->data[1].base = fc->dma_scsi_rsp + fcmd->token * fc->rsp_size; + request->data[1].count = fc->rsp_size; + if (fcmd->data) { + request->shdr.segcnt = 3; + i = fc->scsi_cmd_pool[fcmd->token].fcp_data_len; + request->shdr.bytecnt = i; + request->data[2].base = fcmd->data; + request->data[2].count = i; + request->type = + (fc->scsi_cmd_pool[fcmd->token].fcp_cntl & FCP_CNTL_WRITE) ? + SOC_CQTYPE_IO_WRITE : SOC_CQTYPE_IO_READ; + } else { + request->shdr.segcnt = 2; + request->shdr.bytecnt = 0; + request->data[2].base = 0; + request->data[2].count = 0; + request->type = SOC_CQTYPE_SIMPLE; + } + FILL_FCHDR_RCTL_DID(fch, R_CTL_COMMAND, fc->did); + FILL_FCHDR_SID(fch, fc->sid); + FILL_FCHDR_TYPE_FCTL(fch, TYPE_SCSI_FCP, + F_CTL_FIRST_SEQ | F_CTL_SEQ_INITIATIVE); + FILL_FCHDR_SEQ_DF_SEQ(fch, 0, 0, 0); + FILL_FCHDR_OXRX(fch, 0xffff, 0xffff); + fch->param = 0; + request->shdr.flags = port->flags; + request->shdr.class = 2; + break; + + case PROTO_OFFLINE: + memset (request, 0, sizeof(*request)); + request->shdr.token = TOKEN(PROTO_OFFLINE, port->mask, fcmd->token); + request->type = SOC_CQTYPE_OFFLINE; + FILL_FCHDR_RCTL_DID(fch, R_CTL_COMMAND, fc->did); + FILL_FCHDR_SID(fch, fc->sid); + FILL_FCHDR_TYPE_FCTL(fch, TYPE_SCSI_FCP, + F_CTL_FIRST_SEQ | F_CTL_SEQ_INITIATIVE); + FILL_FCHDR_SEQ_DF_SEQ(fch, 0, 0, 0); + FILL_FCHDR_OXRX(fch, 0xffff, 0xffff); + request->shdr.flags = port->flags; + break; + + case PROTO_REPORT_AL_MAP: + /* SOC only supports Point-to-Point topology, no FC-AL, sorry... */ + return -ENOSYS; + + default: + request->shdr.token = TOKEN(fcmd->proto, port->mask, fcmd->token); + request->shdr.class = 2; + request->shdr.flags = port->flags; + memcpy (fch, &fcmd->fch, sizeof(fc_hdr)); + request->data[0].count = fcmd->cmdlen; + request->data[1].count = fcmd->rsplen; + request->type = fcmd->class; + switch (fcmd->class) { + case FC_CLASS_OUTBOUND: + request->data[0].base = fcmd->cmd; + request->data[0].count = fcmd->cmdlen; + request->type = SOC_CQTYPE_OUTBOUND; + request->shdr.bytecnt = fcmd->cmdlen; + request->shdr.segcnt = 1; + break; + case FC_CLASS_INBOUND: + request->data[0].base = fcmd->rsp; + request->data[0].count = fcmd->rsplen; + request->type = SOC_CQTYPE_INBOUND; + request->shdr.bytecnt = 0; + request->shdr.segcnt = 1; + break; + case FC_CLASS_SIMPLE: + request->data[0].base = fcmd->cmd; + request->data[1].base = fcmd->rsp; + request->data[0].count = fcmd->cmdlen; + request->data[1].count = fcmd->rsplen; + request->type = SOC_CQTYPE_SIMPLE; + request->shdr.bytecnt = fcmd->cmdlen; + request->shdr.segcnt = 2; + break; + case FC_CLASS_IO_READ: + case FC_CLASS_IO_WRITE: + request->data[0].base = fcmd->cmd; + request->data[1].base = fcmd->rsp; + request->data[0].count = fcmd->cmdlen; + request->data[1].count = fcmd->rsplen; + request->type = + (fcmd->class == FC_CLASS_IO_READ) ? + SOC_CQTYPE_IO_READ : SOC_CQTYPE_IO_WRITE; + if (fcmd->data) { + request->data[2].base = fcmd->data; + request->data[2].count = fcmd->datalen; + request->shdr.bytecnt = fcmd->datalen; + request->shdr.segcnt = 3; + } else { + request->shdr.bytecnt = 0; + request->shdr.segcnt = 2; + } + break; + }; + break; + }; + + request->count = 1; + request->flags = 0; + request->seqno = sw_cq->seqno; + + /* And now tell the SOC about it */ + + if (++sw_cq->in > sw_cq->last) { + sw_cq->in = 0; + sw_cq->seqno++; + } + + SOD(("Putting %08x into cmd\n", + SOC_CMD_RSP_QALL | (sw_cq->in << 24) | (SOC_CMD_REQ_Q0 << qno))) + + sbus_writel(SOC_CMD_RSP_QALL | (sw_cq->in << 24) | (SOC_CMD_REQ_Q0 << qno), + s->regs + CMD); + + /* Read so that command is completed. */ + sbus_readl(s->regs + CMD); + + return 0; +} + +static inline void soc_download_fw(struct soc *s) +{ +#ifdef HAVE_SOC_UCODE + xram_copy_to (s->xram, soc_ucode, sizeof(soc_ucode)); + xram_bzero (s->xram + sizeof(soc_ucode), 32768 - sizeof(soc_ucode)); +#endif +} + +/* Check for what the best SBUS burst we can use happens + * to be on this machine. + */ +static inline void soc_init_bursts(struct soc *s, struct sbus_dev *sdev) +{ + int bsizes, bsizes_more; + + bsizes = (prom_getintdefault(sdev->prom_node,"burst-sizes",0xff) & 0xff); + bsizes_more = (prom_getintdefault(sdev->bus->prom_node, "burst-sizes", 0xff) & 0xff); + bsizes &= bsizes_more; + if ((bsizes & 0x7f) == 0x7f) + s->cfg = SOC_CFG_BURST_64; + else if ((bsizes & 0x3f) == 0x3f) + s->cfg = SOC_CFG_BURST_32; + else if ((bsizes & 0x1f) == 0x1f) + s->cfg = SOC_CFG_BURST_16; + else + s->cfg = SOC_CFG_BURST_4; +} + +static inline void soc_init(struct sbus_dev *sdev, int no) +{ + unsigned char tmp[60]; + int propl; + struct soc *s; + static int version_printed = 0; + soc_hw_cq cq[8]; + int size, i; + int irq; + + s = kzalloc (sizeof (struct soc), GFP_KERNEL); + if (s == NULL) + return; + spin_lock_init(&s->lock); + s->soc_no = no; + + SOD(("socs %08lx soc_intr %08lx soc_hw_enque %08x\n", + (long)socs, (long)soc_intr, (long)soc_hw_enque)) + if (version_printed++ == 0) + printk (version); + + s->port[0].fc.module = THIS_MODULE; + s->port[1].fc.module = THIS_MODULE; + + s->next = socs; + socs = s; + s->port[0].fc.dev = sdev; + s->port[1].fc.dev = sdev; + s->port[0].s = s; + s->port[1].s = s; + + s->port[0].fc.next = &s->port[1].fc; + + /* World Wide Name of SOC */ + propl = prom_getproperty (sdev->prom_node, "soc-wwn", tmp, sizeof(tmp)); + if (propl != sizeof (fc_wwn)) { + s->wwn.naaid = NAAID_IEEE; + s->wwn.lo = 0x12345678; + } else + memcpy (&s->wwn, tmp, sizeof (fc_wwn)); + + propl = prom_getproperty (sdev->prom_node, "port-wwns", tmp, sizeof(tmp)); + if (propl != 2 * sizeof (fc_wwn)) { + s->port[0].fc.wwn_nport.naaid = NAAID_IEEE_EXT; + s->port[0].fc.wwn_nport.hi = s->wwn.hi; + s->port[0].fc.wwn_nport.lo = s->wwn.lo; + s->port[1].fc.wwn_nport.naaid = NAAID_IEEE_EXT; + s->port[1].fc.wwn_nport.nportid = 1; + s->port[1].fc.wwn_nport.hi = s->wwn.hi; + s->port[1].fc.wwn_nport.lo = s->wwn.lo; + } else { + memcpy (&s->port[0].fc.wwn_nport, tmp, sizeof (fc_wwn)); + memcpy (&s->port[1].fc.wwn_nport, tmp + sizeof (fc_wwn), sizeof (fc_wwn)); + } + memcpy (&s->port[0].fc.wwn_node, &s->wwn, sizeof (fc_wwn)); + memcpy (&s->port[1].fc.wwn_node, &s->wwn, sizeof (fc_wwn)); + SOD(("Got wwns %08x%08x ports %08x%08x and %08x%08x\n", + *(u32 *)&s->port[0].fc.wwn_nport, s->port[0].fc.wwn_nport.lo, + *(u32 *)&s->port[0].fc.wwn_nport, s->port[0].fc.wwn_nport.lo, + *(u32 *)&s->port[1].fc.wwn_nport, s->port[1].fc.wwn_nport.lo)) + + s->port[0].fc.sid = 1; + s->port[1].fc.sid = 17; + s->port[0].fc.did = 2; + s->port[1].fc.did = 18; + + s->port[0].fc.reset = soc_reset; + s->port[1].fc.reset = soc_reset; + + if (sdev->num_registers == 1) { + /* Probably SunFire onboard SOC */ + s->xram = sbus_ioremap(&sdev->resource[0], 0, + 0x10000UL, "soc xram"); + s->regs = sbus_ioremap(&sdev->resource[0], 0x10000UL, + 0x10UL, "soc regs"); + } else { + /* Probably SOC sbus card */ + s->xram = sbus_ioremap(&sdev->resource[1], 0, + sdev->reg_addrs[1].reg_size, "soc xram"); + s->regs = sbus_ioremap(&sdev->resource[2], 0, + sdev->reg_addrs[2].reg_size, "soc regs"); + } + + soc_init_bursts(s, sdev); + + SOD(("Disabling SOC\n")) + + soc_disable (s); + + irq = sdev->irqs[0]; + + if (request_irq (irq, soc_intr, IRQF_SHARED, "SOC", (void *)s)) { + soc_printk ("Cannot order irq %d to go\n", irq); + socs = s->next; + return; + } + + SOD(("SOC uses IRQ %d\n", irq)) + + s->port[0].fc.irq = irq; + s->port[1].fc.irq = irq; + + sprintf (s->port[0].fc.name, "soc%d port A", no); + sprintf (s->port[1].fc.name, "soc%d port B", no); + s->port[0].flags = SOC_FC_HDR | SOC_PORT_A; + s->port[1].flags = SOC_FC_HDR | SOC_PORT_B; + s->port[1].mask = (1 << 11); + + s->port[0].fc.hw_enque = soc_hw_enque; + s->port[1].fc.hw_enque = soc_hw_enque; + + soc_download_fw (s); + + SOD(("Downloaded firmware\n")) + + /* Now setup xram circular queues */ + memset (cq, 0, sizeof(cq)); + + size = (SOC_CQ_REQ0_SIZE + SOC_CQ_REQ1_SIZE) * sizeof(soc_req); + s->req_cpu = sbus_alloc_consistent(sdev, size, &s->req_dvma); + s->req[0].pool = s->req_cpu; + cq[0].address = s->req_dvma; + s->req[1].pool = s->req[0].pool + SOC_CQ_REQ0_SIZE; + + s->req[0].hw_cq = (soc_hw_cq __iomem *)(s->xram + SOC_CQ_REQ_OFFSET); + s->req[1].hw_cq = (soc_hw_cq __iomem *)(s->xram + SOC_CQ_REQ_OFFSET + sizeof(soc_hw_cq)); + s->rsp[0].hw_cq = (soc_hw_cq __iomem *)(s->xram + SOC_CQ_RSP_OFFSET); + s->rsp[1].hw_cq = (soc_hw_cq __iomem *)(s->xram + SOC_CQ_RSP_OFFSET + sizeof(soc_hw_cq)); + + cq[1].address = cq[0].address + (SOC_CQ_REQ0_SIZE * sizeof(soc_req)); + cq[4].address = 1; + cq[5].address = 1; + cq[0].last = SOC_CQ_REQ0_SIZE - 1; + cq[1].last = SOC_CQ_REQ1_SIZE - 1; + cq[4].last = SOC_CQ_RSP0_SIZE - 1; + cq[5].last = SOC_CQ_RSP1_SIZE - 1; + for (i = 0; i < 8; i++) + cq[i].seqno = 1; + + s->req[0].last = SOC_CQ_REQ0_SIZE - 1; + s->req[1].last = SOC_CQ_REQ1_SIZE - 1; + s->rsp[0].last = SOC_CQ_RSP0_SIZE - 1; + s->rsp[1].last = SOC_CQ_RSP1_SIZE - 1; + + s->req[0].seqno = 1; + s->req[1].seqno = 1; + s->rsp[0].seqno = 1; + s->rsp[1].seqno = 1; + + xram_copy_to (s->xram + SOC_CQ_REQ_OFFSET, cq, sizeof(cq)); + + /* Make our sw copy of SOC service parameters */ + xram_copy_from (s->serv_params, s->xram + 0x140, sizeof (s->serv_params)); + + s->port[0].fc.common_svc = (common_svc_parm *)s->serv_params; + s->port[0].fc.class_svcs = (svc_parm *)(s->serv_params + 0x20); + s->port[1].fc.common_svc = (common_svc_parm *)&s->serv_params; + s->port[1].fc.class_svcs = (svc_parm *)(s->serv_params + 0x20); + + soc_enable (s); + + SOD(("Enabled SOC\n")) +} + +static int __init soc_probe(void) +{ + struct sbus_bus *sbus; + struct sbus_dev *sdev = NULL; + struct soc *s; + int cards = 0; + + for_each_sbus(sbus) { + for_each_sbusdev(sdev, sbus) { + if(!strcmp(sdev->prom_name, "SUNW,soc")) { + soc_init(sdev, cards); + cards++; + } + } + } + if (!cards) return -EIO; + + for_each_soc(s) + if (s->next) + s->port[1].fc.next = &s->next->port[0].fc; + fcp_init (&socs->port[0].fc); + return 0; +} + +static void __exit soc_cleanup(void) +{ + struct soc *s; + int irq; + struct sbus_dev *sdev; + + for_each_soc(s) { + irq = s->port[0].fc.irq; + free_irq (irq, s); + + fcp_release(&(s->port[0].fc), 2); + + sdev = s->port[0].fc.dev; + if (sdev->num_registers == 1) { + sbus_iounmap(s->xram, 0x10000UL); + sbus_iounmap(s->regs, 0x10UL); + } else { + sbus_iounmap(s->xram, sdev->reg_addrs[1].reg_size); + sbus_iounmap(s->regs, sdev->reg_addrs[2].reg_size); + } + sbus_free_consistent(sdev, + (SOC_CQ_REQ0_SIZE+SOC_CQ_REQ1_SIZE)*sizeof(soc_req), + s->req_cpu, s->req_dvma); + } +} + +module_init(soc_probe); +module_exit(soc_cleanup); +MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/fc4/soc.h b/trunk/drivers/fc4/soc.h new file mode 100644 index 000000000000..d38cf5b28eed --- /dev/null +++ b/trunk/drivers/fc4/soc.h @@ -0,0 +1,301 @@ +/* soc.h: Definitions for Sparc SUNW,soc Fibre Channel Sbus driver. + * + * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz) + */ + +#ifndef __SOC_H +#define __SOC_H + +#include "fc.h" +#include "fcp.h" +#include "fcp_impl.h" + +/* Hardware register offsets and constants first {{{ */ +#define CFG 0x00UL /* Config Register */ +#define SAE 0x04UL /* Slave Access Error Register */ +#define CMD 0x08UL /* Command and Status Register */ +#define IMASK 0x0cUL /* Interrupt Mask Register */ + +/* Config Register */ +#define SOC_CFG_EXT_RAM_BANK_MASK 0x07000000 +#define SOC_CFG_EEPROM_BANK_MASK 0x00030000 +#define SOC_CFG_BURST64_MASK 0x00000700 +#define SOC_CFG_SBUS_PARITY_TEST 0x00000020 +#define SOC_CFG_SBUS_PARITY_CHECK 0x00000010 +#define SOC_CFG_SBUS_ENHANCED 0x00000008 +#define SOC_CFG_BURST_MASK 0x00000007 +/* Bursts */ +#define SOC_CFG_BURST_4 0x00000000 +#define SOC_CFG_BURST_16 0x00000004 +#define SOC_CFG_BURST_32 0x00000005 +#define SOC_CFG_BURST_64 0x00000006 + +/* Slave Access Error Register */ +#define SOC_SAE_ALIGNMENT 0x00000004 +#define SOC_SAE_UNSUPPORTED 0x00000002 +#define SOC_SAE_PARITY 0x00000001 + +/* Command & Status Register */ +#define SOC_CMD_RSP_QALL 0x000f0000 +#define SOC_CMD_RSP_Q0 0x00010000 +#define SOC_CMD_RSP_Q1 0x00020000 +#define SOC_CMD_RSP_Q2 0x00040000 +#define SOC_CMD_RSP_Q3 0x00080000 +#define SOC_CMD_REQ_QALL 0x00000f00 +#define SOC_CMD_REQ_Q0 0x00000100 +#define SOC_CMD_REQ_Q1 0x00000200 +#define SOC_CMD_REQ_Q2 0x00000400 +#define SOC_CMD_REQ_Q3 0x00000800 +#define SOC_CMD_SAE 0x00000080 +#define SOC_CMD_INTR_PENDING 0x00000008 +#define SOC_CMD_NON_QUEUED 0x00000004 +#define SOC_CMD_IDLE 0x00000002 +#define SOC_CMD_SOFT_RESET 0x00000001 + +/* Interrupt Mask Register */ +#define SOC_IMASK_RSP_QALL 0x000f0000 +#define SOC_IMASK_RSP_Q0 0x00010000 +#define SOC_IMASK_RSP_Q1 0x00020000 +#define SOC_IMASK_RSP_Q2 0x00040000 +#define SOC_IMASK_RSP_Q3 0x00080000 +#define SOC_IMASK_REQ_QALL 0x00000f00 +#define SOC_IMASK_REQ_Q0 0x00000100 +#define SOC_IMASK_REQ_Q1 0x00000200 +#define SOC_IMASK_REQ_Q2 0x00000400 +#define SOC_IMASK_REQ_Q3 0x00000800 +#define SOC_IMASK_SAE 0x00000080 +#define SOC_IMASK_NON_QUEUED 0x00000004 + +#define SOC_INTR(s, cmd) \ + (((cmd & SOC_CMD_RSP_QALL) | ((~cmd) & SOC_CMD_REQ_QALL)) \ + & s->imask) + +#define SOC_SETIMASK(s, i) \ +do { (s)->imask = (i); \ + sbus_writel((i), (s)->regs + IMASK); \ +} while(0) + +/* XRAM + * + * This is a 64KB register area. It accepts only halfword access. + * That's why here are the following inline functions... + */ + +typedef void __iomem *xram_p; + +/* Get 32bit number from XRAM */ +static inline u32 xram_get_32(xram_p x) +{ + return ((sbus_readw(x + 0x00UL) << 16) | + (sbus_readw(x + 0x02UL))); +} + +/* Like the above, but when we don't care about the high 16 bits */ +static inline u32 xram_get_32low(xram_p x) +{ + return (u32) sbus_readw(x + 0x02UL); +} + +static inline u16 xram_get_16(xram_p x) +{ + return sbus_readw(x); +} + +static inline u8 xram_get_8(xram_p x) +{ + if ((unsigned long)x & 0x1UL) { + x = x - 1; + return (u8) sbus_readw(x); + } else { + return (u8) (sbus_readw(x) >> 8); + } +} + +static inline void xram_copy_from(void *p, xram_p x, int len) +{ + for (len >>= 2; len > 0; len--, x += sizeof(u32)) { + u32 val, *p32 = p; + + val = ((sbus_readw(x + 0x00UL) << 16) | + (sbus_readw(x + 0x02UL))); + *p32++ = val; + p = p32; + } +} + +static inline void xram_copy_to(xram_p x, void *p, int len) +{ + for (len >>= 2; len > 0; len--, x += sizeof(u32)) { + u32 tmp, *p32 = p; + + tmp = *p32++; + p = p32; + sbus_writew(tmp >> 16, x + 0x00UL); + sbus_writew(tmp, x + 0x02UL); + } +} + +static inline void xram_bzero(xram_p x, int len) +{ + for (len >>= 1; len > 0; len--, x += sizeof(u16)) + sbus_writew(0, x); +} + +/* Circular Queue */ + +#define SOC_CQ_REQ_OFFSET (0x100 * sizeof(u16)) +#define SOC_CQ_RSP_OFFSET (0x110 * sizeof(u16)) + +typedef struct { + u32 address; + u8 in; + u8 out; + u8 last; + u8 seqno; +} soc_hw_cq; + +#define SOC_PORT_A 0x0000 /* From/To Port A */ +#define SOC_PORT_B 0x0001 /* From/To Port A */ +#define SOC_FC_HDR 0x0002 /* Contains FC Header */ +#define SOC_NORSP 0x0004 /* Don't generate response nor interrupt */ +#define SOC_NOINT 0x0008 /* Generate response but not interrupt */ +#define SOC_XFERRDY 0x0010 /* Generate XFERRDY */ +#define SOC_IGNOREPARAM 0x0020 /* Ignore PARAM field in the FC header */ +#define SOC_COMPLETE 0x0040 /* Command completed */ +#define SOC_UNSOLICITED 0x0080 /* For request this is the packet to establish unsolicited pools, */ + /* for rsp this is unsolicited packet */ +#define SOC_STATUS 0x0100 /* State change (on/off line) */ + +typedef struct { + u32 token; + u16 flags; + u8 class; + u8 segcnt; + u32 bytecnt; +} soc_hdr; + +typedef struct { + u32 base; + u32 count; +} soc_data; + +#define SOC_CQTYPE_OUTBOUND 0x01 +#define SOC_CQTYPE_INBOUND 0x02 +#define SOC_CQTYPE_SIMPLE 0x03 +#define SOC_CQTYPE_IO_WRITE 0x04 +#define SOC_CQTYPE_IO_READ 0x05 +#define SOC_CQTYPE_UNSOLICITED 0x06 +#define SOC_CQTYPE_DIAG 0x07 +#define SOC_CQTYPE_OFFLINE 0x08 +#define SOC_CQTYPE_RESPONSE 0x10 +#define SOC_CQTYPE_INLINE 0x20 + +#define SOC_CQFLAGS_CONT 0x01 +#define SOC_CQFLAGS_FULL 0x02 +#define SOC_CQFLAGS_BADHDR 0x04 +#define SOC_CQFLAGS_BADPKT 0x08 + +typedef struct { + soc_hdr shdr; + soc_data data[3]; + fc_hdr fchdr; + u8 count; + u8 type; + u8 flags; + u8 seqno; +} soc_req; + +#define SOC_OK 0 +#define SOC_P_RJT 2 +#define SOC_F_RJT 3 +#define SOC_P_BSY 4 +#define SOC_F_BSY 5 +#define SOC_ONLINE 0x10 +#define SOC_OFFLINE 0x11 +#define SOC_TIMEOUT 0x12 +#define SOC_OVERRUN 0x13 +#define SOC_UNKOWN_CQ_TYPE 0x20 +#define SOC_BAD_SEG_CNT 0x21 +#define SOC_MAX_XCHG_EXCEEDED 0x22 +#define SOC_BAD_XID 0x23 +#define SOC_XCHG_BUSY 0x24 +#define SOC_BAD_POOL_ID 0x25 +#define SOC_INSUFFICIENT_CQES 0x26 +#define SOC_ALLOC_FAIL 0x27 +#define SOC_BAD_SID 0x28 +#define SOC_NO_SEG_INIT 0x29 + +typedef struct { + soc_hdr shdr; + u32 status; + soc_data data; + u8 xxx1[12]; + fc_hdr fchdr; + u8 count; + u8 type; + u8 flags; + u8 seqno; +} soc_rsp; + +/* }}} */ + +/* Now our software structures and constants we use to drive the beast {{{ */ + +#define SOC_CQ_REQ0_SIZE 4 +#define SOC_CQ_REQ1_SIZE 64 +#define SOC_CQ_RSP0_SIZE 8 +#define SOC_CQ_RSP1_SIZE 4 + +#define SOC_SOLICITED_RSP_Q 0 +#define SOC_UNSOLICITED_RSP_Q 1 + +struct soc; + +typedef struct { + /* This must come first */ + fc_channel fc; + struct soc *s; + u16 flags; + u16 mask; +} soc_port; + +typedef struct { + soc_hw_cq __iomem *hw_cq; /* Related XRAM cq */ + soc_req __iomem *pool; + u8 in; + u8 out; + u8 last; + u8 seqno; +} soc_cq_rsp; + +typedef struct { + soc_hw_cq __iomem *hw_cq; /* Related XRAM cq */ + soc_req *pool; + u8 in; + u8 out; + u8 last; + u8 seqno; +} soc_cq_req; + +struct soc { + spinlock_t lock; + soc_port port[2]; /* Every SOC has one or two FC ports */ + soc_cq_req req[2]; /* Request CQs */ + soc_cq_rsp rsp[2]; /* Response CQs */ + int soc_no; + void __iomem *regs; + xram_p xram; + fc_wwn wwn; + u32 imask; /* Our copy of regs->imask */ + u32 cfg; /* Our copy of regs->cfg */ + char serv_params[80]; + struct soc *next; + int curr_port; /* Which port will have priority to fcp_queue_empty */ + + soc_req *req_cpu; + u32 req_dvma; +}; + +/* }}} */ + +#endif /* !(__SOC_H) */ diff --git a/trunk/drivers/fc4/socal.c b/trunk/drivers/fc4/socal.c new file mode 100644 index 000000000000..c903ebfab526 --- /dev/null +++ b/trunk/drivers/fc4/socal.c @@ -0,0 +1,904 @@ +/* socal.c: Sparc SUNW,socal (SOC+) Fibre Channel Sbus adapter support. + * + * Copyright (C) 1998,1999 Jakub Jelinek (jj@ultra.linux.cz) + * + * Sources: + * Fibre Channel Physical & Signaling Interface (FC-PH), dpANS, 1994 + * dpANS Fibre Channel Protocol for SCSI (X3.269-199X), Rev. 012, 1995 + * SOC+ Programming Guide 0.1 + * Fibre Channel Arbitrated Loop (FC-AL), dpANS rev. 4.5, 1995 + * + * Supported hardware: + * On-board SOC+ adapters of Ultra Enterprise servers and sun4d. + */ + +static char *version = + "socal.c: SOC+ driver v1.1 9/Feb/99 Jakub Jelinek (jj@ultra.linux.cz)\n"; + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +/* #define SOCALDEBUG */ +/* #define HAVE_SOCAL_UCODE */ +/* #define USE_64BIT_MODE */ + +#include "fcp_impl.h" +#include "socal.h" +#ifdef HAVE_SOCAL_UCODE +#include "socal_asm.h" +#endif + +#define socal_printk printk ("socal%d: ", s->socal_no); printk + +#ifdef SOCALDEBUG +#define SOD(x) socal_printk x; +#else +#define SOD(x) +#endif + +#define for_each_socal(s) for (s = socals; s; s = s->next) +struct socal *socals = NULL; + +static void socal_copy_from_xram(void *d, void __iomem *xram, long size) +{ + u32 *dp = (u32 *) d; + while (size) { + *dp++ = sbus_readl(xram); + xram += sizeof(u32); + size -= sizeof(u32); + } +} + +static void socal_copy_to_xram(void __iomem *xram, void *s, long size) +{ + u32 *sp = (u32 *) s; + while (size) { + u32 val = *sp++; + sbus_writel(val, xram); + xram += sizeof(u32); + size -= sizeof(u32); + } +} + +#ifdef HAVE_SOCAL_UCODE +static void socal_bzero(unsigned long xram, int size) +{ + while (size) { + sbus_writel(0, xram); + xram += sizeof(u32); + size -= sizeof(u32); + } +} +#endif + +static inline void socal_disable(struct socal *s) +{ + sbus_writel(0, s->regs + IMASK); + sbus_writel(SOCAL_CMD_SOFT_RESET, s->regs + CMD); +} + +static inline void socal_enable(struct socal *s) +{ + SOD(("enable %08x\n", s->cfg)) + sbus_writel(0, s->regs + SAE); + sbus_writel(s->cfg, s->regs + CFG); + sbus_writel(SOCAL_CMD_RSP_QALL, s->regs + CMD); + SOCAL_SETIMASK(s, SOCAL_IMASK_RSP_QALL | SOCAL_IMASK_SAE); + SOD(("imask %08x %08x\n", s->imask, sbus_readl(s->regs + IMASK))); +} + +static void socal_reset(fc_channel *fc) +{ + socal_port *port = (socal_port *)fc; + struct socal *s = port->s; + + /* FIXME */ + socal_disable(s); + s->req[0].seqno = 1; + s->req[1].seqno = 1; + s->rsp[0].seqno = 1; + s->rsp[1].seqno = 1; + s->req[0].in = 0; + s->req[1].in = 0; + s->rsp[0].in = 0; + s->rsp[1].in = 0; + s->req[0].out = 0; + s->req[1].out = 0; + s->rsp[0].out = 0; + s->rsp[1].out = 0; + + /* FIXME */ + socal_enable(s); +} + +static inline void socal_solicited(struct socal *s, unsigned long qno) +{ + socal_rsp *hwrsp; + socal_cq *sw_cq; + int token; + int status; + fc_channel *fc; + + sw_cq = &s->rsp[qno]; + + /* Finally an improvement against old SOC :) */ + sw_cq->in = sbus_readb(s->regs + RESP + qno); + SOD (("socal_solicited, %d packets arrived\n", + (sw_cq->in - sw_cq->out) & sw_cq->last)) + for (;;) { + hwrsp = (socal_rsp *)sw_cq->pool + sw_cq->out; + SOD(("hwrsp %p out %d\n", hwrsp, sw_cq->out)) + +#if defined(SOCALDEBUG) && 0 + { + u32 *u = (u32 *)hwrsp; + SOD(("%08x.%08x.%08x.%08x.%08x.%08x.%08x.%08x\n", + u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7])) + u += 8; + SOD(("%08x.%08x.%08x.%08x.%08x.%08x.%08x.%08x\n", + u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7])) + u = (u32 *)s->xram; + while (u < ((u32 *)s->regs)) { + if (sbus_readl(&u[0]) == 0x00003000 || + sbus_readl(&u[0]) == 0x00003801) { + SOD(("Found at %04lx\n", + (unsigned long)u - (unsigned long)s->xram)) + SOD((" %08x.%08x.%08x.%08x.%08x.%08x.%08x.%08x\n", + sbus_readl(&u[0]), sbus_readl(&u[1]), + sbus_readl(&u[2]), sbus_readl(&u[3]), + sbus_readl(&u[4]), sbus_readl(&u[5]), + sbus_readl(&u[6]), sbus_readl(&u[7]))) + u += 8; + SOD((" %08x.%08x.%08x.%08x.%08x.%08x.%08x.%08x\n", + sbus_readl(&u[0]), sbus_readl(&u[1]), + sbus_readl(&u[2]), sbus_readl(&u[3]), + sbus_readl(&u[4]), sbus_readl(&u[5]), + sbus_readl(&u[6]), sbus_readl(&u[7]))) + u -= 8; + } + u++; + } + } +#endif + + token = hwrsp->shdr.token; + status = hwrsp->status; + fc = (fc_channel *)(&s->port[(token >> 11) & 1]); + + SOD(("Solicited token %08x status %08x\n", token, status)) + if (status == SOCAL_OK) { + fcp_receive_solicited(fc, token >> 12, + token & ((1 << 11) - 1), + FC_STATUS_OK, NULL); + } else { + /* We have intentionally defined FC_STATUS_* constants + * to match SOCAL_* constants, otherwise we'd have to + * translate status. + */ + fcp_receive_solicited(fc, token >> 12, + token & ((1 << 11) - 1), status, &hwrsp->fchdr); + } + + if (++sw_cq->out > sw_cq->last) { + sw_cq->seqno++; + sw_cq->out = 0; + } + + if (sw_cq->out == sw_cq->in) { + sw_cq->in = sbus_readb(s->regs + RESP + qno); + if (sw_cq->out == sw_cq->in) { + /* Tell the hardware about it */ + sbus_writel((sw_cq->out << 24) | + (SOCAL_CMD_RSP_QALL & + ~(SOCAL_CMD_RSP_Q0 << qno)), + s->regs + CMD); + + /* Read it, so that we're sure it has been updated */ + sbus_readl(s->regs + CMD); + sw_cq->in = sbus_readb(s->regs + RESP + qno); + if (sw_cq->out == sw_cq->in) + break; + } + } + } +} + +static inline void socal_request (struct socal *s, u32 cmd) +{ + SOCAL_SETIMASK(s, s->imask & ~(cmd & SOCAL_CMD_REQ_QALL)); + SOD(("imask %08x %08x\n", s->imask, sbus_readl(s->regs + IMASK))); + + SOD(("Queues available %08x OUT %X\n", cmd, s->regs->reqpr[0])) + if (s->port[s->curr_port].fc.state != FC_STATE_OFFLINE) { + fcp_queue_empty ((fc_channel *)&(s->port[s->curr_port])); + if (((s->req[1].in + 1) & s->req[1].last) != (s->req[1].out)) + fcp_queue_empty ((fc_channel *)&(s->port[1 - s->curr_port])); + } else { + fcp_queue_empty ((fc_channel *)&(s->port[1 - s->curr_port])); + } + if (s->port[1 - s->curr_port].fc.state != FC_STATE_OFFLINE) + s->curr_port ^= 1; +} + +static inline void socal_unsolicited (struct socal *s, unsigned long qno) +{ + socal_rsp *hwrsp, *hwrspc; + socal_cq *sw_cq; + int count; + int status; + int flags; + fc_channel *fc; + + sw_cq = &s->rsp[qno]; + + sw_cq->in = sbus_readb(s->regs + RESP + qno); + SOD (("socal_unsolicited, %d packets arrived, in %d\n", + (sw_cq->in - sw_cq->out) & sw_cq->last, sw_cq->in)) + while (sw_cq->in != sw_cq->out) { + /* ...real work per entry here... */ + hwrsp = (socal_rsp *)sw_cq->pool + sw_cq->out; + SOD(("hwrsp %p out %d\n", hwrsp, sw_cq->out)) + +#if defined(SOCALDEBUG) && 0 + { + u32 *u = (u32 *)hwrsp; + SOD(("%08x.%08x.%08x.%08x.%08x.%08x.%08x.%08x\n", + u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7])) + u += 8; + SOD(("%08x.%08x.%08x.%08x.%08x.%08x.%08x.%08x\n", + u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7])) + } +#endif + + hwrspc = NULL; + flags = hwrsp->shdr.flags; + count = hwrsp->count; + fc = (fc_channel *)&s->port[flags & SOCAL_PORT_B]; + SOD(("FC %08lx\n", (long)fc)) + + if (count != 1) { + /* Ugh, continuation entries */ + u8 in; + + if (count != 2) { + printk("%s: Too many continuations entries %d\n", + fc->name, count); + goto update_out; + } + + in = sw_cq->in; + if (in < sw_cq->out) + in += sw_cq->last + 1; + if (in < sw_cq->out + 2) { + /* Ask the hardware if they haven't arrived yet. */ + sbus_writel((sw_cq->out << 24) | + (SOCAL_CMD_RSP_QALL & + ~(SOCAL_CMD_RSP_Q0 << qno)), + s->regs + CMD); + + /* Read it, so that we're sure it has been updated */ + sbus_readl(s->regs + CMD); + sw_cq->in = sbus_readb(s->regs + RESP + qno); + in = sw_cq->in; + if (in < sw_cq->out) + in += sw_cq->last + 1; + if (in < sw_cq->out + 2) /* Nothing came, let us wait */ + return; + } + if (sw_cq->out == sw_cq->last) + hwrspc = (socal_rsp *)sw_cq->pool; + else + hwrspc = hwrsp + 1; + } + + switch (flags & ~SOCAL_PORT_B) { + case SOCAL_STATUS: + status = hwrsp->status; + switch (status) { + case SOCAL_ONLINE: + SOD(("State change to ONLINE\n")); + fcp_state_change(fc, FC_STATE_ONLINE); + break; + case SOCAL_ONLINE_LOOP: + SOD(("State change to ONLINE_LOOP\n")); + fcp_state_change(fc, FC_STATE_ONLINE); + break; + case SOCAL_OFFLINE: + SOD(("State change to OFFLINE\n")); + fcp_state_change(fc, FC_STATE_OFFLINE); + break; + default: + printk ("%s: Unknown STATUS no %d\n", + fc->name, status); + break; + }; + + break; + case (SOCAL_UNSOLICITED|SOCAL_FC_HDR): + { + int r_ctl = *((u8 *)&hwrsp->fchdr); + unsigned len; + + if ((r_ctl & 0xf0) == R_CTL_EXTENDED_SVC) { + len = hwrsp->shdr.bytecnt; + if (len < 4 || !hwrspc) { + printk ("%s: Invalid R_CTL %02x " + "continuation entries\n", + fc->name, r_ctl); + } else { + if (len > 60) + len = 60; + if (*(u32 *)hwrspc == LS_DISPLAY) { + int i; + + for (i = 4; i < len; i++) + if (((u8 *)hwrspc)[i] == '\n') + ((u8 *)hwrspc)[i] = ' '; + ((u8 *)hwrspc)[len] = 0; + printk ("%s message: %s\n", + fc->name, ((u8 *)hwrspc) + 4); + } else { + printk ("%s: Unknown LS_CMD " + "%08x\n", fc->name, + *(u32 *)hwrspc); + } + } + } else { + printk ("%s: Unsolicited R_CTL %02x " + "not handled\n", fc->name, r_ctl); + } + } + break; + default: + printk ("%s: Unexpected flags %08x\n", fc->name, flags); + break; + }; +update_out: + if (++sw_cq->out > sw_cq->last) { + sw_cq->seqno++; + sw_cq->out = 0; + } + + if (hwrspc) { + if (++sw_cq->out > sw_cq->last) { + sw_cq->seqno++; + sw_cq->out = 0; + } + } + + if (sw_cq->out == sw_cq->in) { + sw_cq->in = sbus_readb(s->regs + RESP + qno); + if (sw_cq->out == sw_cq->in) { + /* Tell the hardware about it */ + sbus_writel((sw_cq->out << 24) | + (SOCAL_CMD_RSP_QALL & + ~(SOCAL_CMD_RSP_Q0 << qno)), + s->regs + CMD); + + /* Read it, so that we're sure it has been updated */ + sbus_readl(s->regs + CMD); + sw_cq->in = sbus_readb(s->regs + RESP + qno); + } + } + } +} + +static irqreturn_t socal_intr(int irq, void *dev_id) +{ + u32 cmd; + unsigned long flags; + register struct socal *s = (struct socal *)dev_id; + + spin_lock_irqsave(&s->lock, flags); + cmd = sbus_readl(s->regs + CMD); + for (; (cmd = SOCAL_INTR (s, cmd)); cmd = sbus_readl(s->regs + CMD)) { +#ifdef SOCALDEBUG + static int cnt = 0; + if (cnt++ < 50) + printk("soc_intr %08x\n", cmd); +#endif + if (cmd & SOCAL_CMD_RSP_Q2) + socal_unsolicited (s, SOCAL_UNSOLICITED_RSP_Q); + if (cmd & SOCAL_CMD_RSP_Q1) + socal_unsolicited (s, SOCAL_SOLICITED_BAD_RSP_Q); + if (cmd & SOCAL_CMD_RSP_Q0) + socal_solicited (s, SOCAL_SOLICITED_RSP_Q); + if (cmd & SOCAL_CMD_REQ_QALL) + socal_request (s, cmd); + } + spin_unlock_irqrestore(&s->lock, flags); + + return IRQ_HANDLED; +} + +#define TOKEN(proto, port, token) (((proto)<<12)|(token)|(port)) + +static int socal_hw_enque (fc_channel *fc, fcp_cmnd *fcmd) +{ + socal_port *port = (socal_port *)fc; + struct socal *s = port->s; + unsigned long qno; + socal_cq *sw_cq; + int cq_next_in; + socal_req *request; + fc_hdr *fch; + int i; + + if (fcmd->proto == TYPE_SCSI_FCP) + qno = 1; + else + qno = 0; + SOD(("Putting a FCP packet type %d into hw queue %d\n", fcmd->proto, qno)) + if (s->imask & (SOCAL_IMASK_REQ_Q0 << qno)) { + SOD(("EIO %08x\n", s->imask)) + return -EIO; + } + sw_cq = s->req + qno; + cq_next_in = (sw_cq->in + 1) & sw_cq->last; + + if (cq_next_in == sw_cq->out && + cq_next_in == (sw_cq->out = sbus_readb(s->regs + REQP + qno))) { + SOD(("%d IN %d OUT %d LAST %d\n", + qno, sw_cq->in, + sw_cq->out, sw_cq->last)) + SOCAL_SETIMASK(s, s->imask | (SOCAL_IMASK_REQ_Q0 << qno)); + SOD(("imask %08x %08x\n", s->imask, sbus_readl(s->regs + IMASK))); + + /* If queue is full, just say NO. */ + return -EBUSY; + } + + request = sw_cq->pool + sw_cq->in; + fch = &request->fchdr; + + switch (fcmd->proto) { + case TYPE_SCSI_FCP: + request->shdr.token = TOKEN(TYPE_SCSI_FCP, port->mask, fcmd->token); + request->data[0].base = fc->dma_scsi_cmd + fcmd->token * sizeof(fcp_cmd); + request->data[0].count = sizeof(fcp_cmd); + request->data[1].base = fc->dma_scsi_rsp + fcmd->token * fc->rsp_size; + request->data[1].count = fc->rsp_size; + if (fcmd->data) { + request->shdr.segcnt = 3; + i = fc->scsi_cmd_pool[fcmd->token].fcp_data_len; + request->shdr.bytecnt = i; + request->data[2].base = fcmd->data; + request->data[2].count = i; + request->type = (fc->scsi_cmd_pool[fcmd->token].fcp_cntl & FCP_CNTL_WRITE) ? + SOCAL_CQTYPE_IO_WRITE : SOCAL_CQTYPE_IO_READ; + } else { + request->shdr.segcnt = 2; + request->shdr.bytecnt = 0; + request->data[2].base = 0; + request->data[2].count = 0; + request->type = SOCAL_CQTYPE_SIMPLE; + } + FILL_FCHDR_RCTL_DID(fch, R_CTL_COMMAND, fcmd->did); + FILL_FCHDR_SID(fch, fc->sid); + FILL_FCHDR_TYPE_FCTL(fch, TYPE_SCSI_FCP, F_CTL_FIRST_SEQ | F_CTL_SEQ_INITIATIVE); + FILL_FCHDR_SEQ_DF_SEQ(fch, 0, 0, 0); + FILL_FCHDR_OXRX(fch, 0xffff, 0xffff); + fch->param = 0; + request->shdr.flags = port->flags; + request->shdr.class = fc->posmap ? 3 : 2; + break; + + case PROTO_OFFLINE: + memset (request, 0, sizeof(*request)); + request->shdr.token = TOKEN(PROTO_OFFLINE, port->mask, fcmd->token); + request->type = SOCAL_CQTYPE_OFFLINE; + FILL_FCHDR_RCTL_DID(fch, R_CTL_COMMAND, fcmd->did); + FILL_FCHDR_SID(fch, fc->sid); + FILL_FCHDR_TYPE_FCTL(fch, TYPE_SCSI_FCP, F_CTL_FIRST_SEQ | F_CTL_SEQ_INITIATIVE); + FILL_FCHDR_SEQ_DF_SEQ(fch, 0, 0, 0); + FILL_FCHDR_OXRX(fch, 0xffff, 0xffff); + request->shdr.flags = port->flags; + break; + + case PROTO_REPORT_AL_MAP: + memset (request, 0, sizeof(*request)); + request->shdr.token = TOKEN(PROTO_REPORT_AL_MAP, port->mask, fcmd->token); + request->type = SOCAL_CQTYPE_REPORT_MAP; + request->shdr.flags = port->flags; + request->shdr.segcnt = 1; + request->shdr.bytecnt = sizeof(fc_al_posmap); + request->data[0].base = fcmd->cmd; + request->data[0].count = sizeof(fc_al_posmap); + break; + + default: + request->shdr.token = TOKEN(fcmd->proto, port->mask, fcmd->token); + request->shdr.class = fc->posmap ? 3 : 2; + request->shdr.flags = port->flags; + memcpy (fch, &fcmd->fch, sizeof(fc_hdr)); + request->data[0].count = fcmd->cmdlen; + request->data[1].count = fcmd->rsplen; + request->type = fcmd->class; + switch (fcmd->class) { + case FC_CLASS_OUTBOUND: + request->data[0].base = fcmd->cmd; + request->data[0].count = fcmd->cmdlen; + request->type = SOCAL_CQTYPE_OUTBOUND; + request->shdr.bytecnt = fcmd->cmdlen; + request->shdr.segcnt = 1; + break; + case FC_CLASS_INBOUND: + request->data[0].base = fcmd->rsp; + request->data[0].count = fcmd->rsplen; + request->type = SOCAL_CQTYPE_INBOUND; + request->shdr.bytecnt = 0; + request->shdr.segcnt = 1; + break; + case FC_CLASS_SIMPLE: + request->data[0].base = fcmd->cmd; + request->data[1].base = fcmd->rsp; + request->data[0].count = fcmd->cmdlen; + request->data[1].count = fcmd->rsplen; + request->type = SOCAL_CQTYPE_SIMPLE; + request->shdr.bytecnt = fcmd->cmdlen; + request->shdr.segcnt = 2; + break; + case FC_CLASS_IO_READ: + case FC_CLASS_IO_WRITE: + request->data[0].base = fcmd->cmd; + request->data[1].base = fcmd->rsp; + request->data[0].count = fcmd->cmdlen; + request->data[1].count = fcmd->rsplen; + request->type = (fcmd->class == FC_CLASS_IO_READ) ? SOCAL_CQTYPE_IO_READ : SOCAL_CQTYPE_IO_WRITE; + if (fcmd->data) { + request->data[2].base = fcmd->data; + request->data[2].count = fcmd->datalen; + request->shdr.bytecnt = fcmd->datalen; + request->shdr.segcnt = 3; + } else { + request->shdr.bytecnt = 0; + request->shdr.segcnt = 2; + } + break; + } + break; + } + + request->count = 1; + request->flags = 0; + request->seqno = sw_cq->seqno; + + SOD(("queueing token %08x\n", request->shdr.token)) + + /* And now tell the SOCAL about it */ + + if (++sw_cq->in > sw_cq->last) { + sw_cq->in = 0; + sw_cq->seqno++; + } + + SOD(("Putting %08x into cmd\n", SOCAL_CMD_RSP_QALL | (sw_cq->in << 24) | (SOCAL_CMD_REQ_Q0 << qno))) + + sbus_writel(SOCAL_CMD_RSP_QALL | (sw_cq->in << 24) | (SOCAL_CMD_REQ_Q0 << qno), + s->regs + CMD); + + /* Read so that command is completed */ + sbus_readl(s->regs + CMD); + + return 0; +} + +static inline void socal_download_fw(struct socal *s) +{ +#ifdef HAVE_SOCAL_UCODE + SOD(("Loading %ld bytes from %p to %p\n", sizeof(socal_ucode), socal_ucode, s->xram)) + socal_copy_to_xram(s->xram, socal_ucode, sizeof(socal_ucode)); + SOD(("Clearing the rest of memory\n")) + socal_bzero (s->xram + sizeof(socal_ucode), 65536 - sizeof(socal_ucode)); + SOD(("Done\n")) +#endif +} + +/* Check for what the best SBUS burst we can use happens + * to be on this machine. + */ +static inline void socal_init_bursts(struct socal *s, struct sbus_dev *sdev) +{ + int bsizes, bsizes_more; + u32 cfg; + + bsizes = (prom_getintdefault(sdev->prom_node,"burst-sizes",0xff) & 0xff); + bsizes_more = (prom_getintdefault(sdev->bus->prom_node, "burst-sizes", 0xff) & 0xff); + bsizes &= bsizes_more; +#ifdef USE_64BIT_MODE +#ifdef __sparc_v9__ + mmu_set_sbus64(sdev, bsizes >> 16); +#endif +#endif + if ((bsizes & 0x7f) == 0x7f) + cfg = SOCAL_CFG_BURST_64; + else if ((bsizes & 0x3f) == 0x3f) + cfg = SOCAL_CFG_BURST_32; + else if ((bsizes & 0x1f) == 0x1f) + cfg = SOCAL_CFG_BURST_16; + else + cfg = SOCAL_CFG_BURST_4; +#ifdef USE_64BIT_MODE +#ifdef __sparc_v9__ + /* What is BURST_128? -jj */ + if ((bsizes & 0x780000) == 0x780000) + cfg |= (SOCAL_CFG_BURST_64 << 8) | SOCAL_CFG_SBUS_ENHANCED; + else if ((bsizes & 0x380000) == 0x380000) + cfg |= (SOCAL_CFG_BURST_32 << 8) | SOCAL_CFG_SBUS_ENHANCED; + else if ((bsizes & 0x180000) == 0x180000) + cfg |= (SOCAL_CFG_BURST_16 << 8) | SOCAL_CFG_SBUS_ENHANCED; + else + cfg |= (SOCAL_CFG_BURST_8 << 8) | SOCAL_CFG_SBUS_ENHANCED; +#endif +#endif + s->cfg = cfg; +} + +static inline void socal_init(struct sbus_dev *sdev, int no) +{ + unsigned char tmp[60]; + int propl; + struct socal *s; + static unsigned version_printed = 0; + socal_hw_cq cq[8]; + int size, i; + int irq, node; + + s = kzalloc (sizeof (struct socal), GFP_KERNEL); + if (!s) return; + spin_lock_init(&s->lock); + s->socal_no = no; + + SOD(("socals %08lx socal_intr %08lx socal_hw_enque %08lx\n", + (long)socals, (long)socal_intr, (long)socal_hw_enque)) + if (version_printed++ == 0) + printk (version); + + s->port[0].fc.module = THIS_MODULE; + s->port[1].fc.module = THIS_MODULE; + + s->next = socals; + socals = s; + s->port[0].fc.dev = sdev; + s->port[1].fc.dev = sdev; + s->port[0].s = s; + s->port[1].s = s; + + s->port[0].fc.next = &s->port[1].fc; + + /* World Wide Name of SOCAL */ + propl = prom_getproperty (sdev->prom_node, "wwn", tmp, sizeof(tmp)); + if (propl != sizeof (fc_wwn)) { + s->wwn.naaid = NAAID_IEEE_REG; + s->wwn.nportid = 0x123; + s->wwn.hi = 0x1234; + s->wwn.lo = 0x12345678; + } else + memcpy (&s->wwn, tmp, sizeof (fc_wwn)); + + memcpy (&s->port[0].fc.wwn_nport, &s->wwn, sizeof (fc_wwn)); + s->port[0].fc.wwn_nport.lo++; + memcpy (&s->port[1].fc.wwn_nport, &s->wwn, sizeof (fc_wwn)); + s->port[1].fc.wwn_nport.lo+=2; + + node = prom_getchild (sdev->prom_node); + while (node && (node = prom_searchsiblings (node, "sf"))) { + int port; + + port = prom_getintdefault(node, "port#", -1); + switch (port) { + case 0: + case 1: + if (prom_getproplen(node, "port-wwn") == sizeof (fc_wwn)) + prom_getproperty (node, "port-wwn", + (char *)&s->port[port].fc.wwn_nport, + sizeof (fc_wwn)); + break; + default: + break; + }; + + node = prom_getsibling(node); + } + + memcpy (&s->port[0].fc.wwn_node, &s->wwn, sizeof (fc_wwn)); + memcpy (&s->port[1].fc.wwn_node, &s->wwn, sizeof (fc_wwn)); + SOD(("Got wwns %08x%08x ports %08x%08x and %08x%08x\n", + *(u32 *)&s->port[0].fc.wwn_node, s->port[0].fc.wwn_node.lo, + *(u32 *)&s->port[0].fc.wwn_nport, s->port[0].fc.wwn_nport.lo, + *(u32 *)&s->port[1].fc.wwn_nport, s->port[1].fc.wwn_nport.lo)) + + s->port[0].fc.sid = 1; + s->port[1].fc.sid = 17; + s->port[0].fc.did = 2; + s->port[1].fc.did = 18; + + s->port[0].fc.reset = socal_reset; + s->port[1].fc.reset = socal_reset; + + if (sdev->num_registers == 1) { + s->eeprom = sbus_ioremap(&sdev->resource[0], 0, + sdev->reg_addrs[0].reg_size, "socal xram"); + if (sdev->reg_addrs[0].reg_size > 0x20000) + s->xram = s->eeprom + 0x10000UL; + else + s->xram = s->eeprom; + s->regs = (s->xram + 0x10000UL); + } else { + /* E.g. starfire presents 3 registers for SOCAL */ + s->xram = sbus_ioremap(&sdev->resource[1], 0, + sdev->reg_addrs[1].reg_size, "socal xram"); + s->regs = sbus_ioremap(&sdev->resource[2], 0, + sdev->reg_addrs[2].reg_size, "socal regs"); + } + + socal_init_bursts(s, sdev); + + SOD(("Disabling SOCAL\n")) + + socal_disable (s); + + irq = sdev->irqs[0]; + + if (request_irq (irq, socal_intr, IRQF_SHARED, "SOCAL", (void *)s)) { + socal_printk ("Cannot order irq %d to go\n", irq); + socals = s->next; + return; + } + + SOD(("SOCAL uses IRQ %d\n", irq)) + + s->port[0].fc.irq = irq; + s->port[1].fc.irq = irq; + + sprintf (s->port[0].fc.name, "socal%d port A", no); + sprintf (s->port[1].fc.name, "socal%d port B", no); + s->port[0].flags = SOCAL_FC_HDR | SOCAL_PORT_A; + s->port[1].flags = SOCAL_FC_HDR | SOCAL_PORT_B; + s->port[1].mask = (1 << 11); + + s->port[0].fc.hw_enque = socal_hw_enque; + s->port[1].fc.hw_enque = socal_hw_enque; + + socal_download_fw (s); + + SOD(("Downloaded firmware\n")) + + /* Now setup xram circular queues */ + memset (cq, 0, sizeof(cq)); + + size = (SOCAL_CQ_REQ0_SIZE + SOCAL_CQ_REQ1_SIZE + + SOCAL_CQ_RSP0_SIZE + SOCAL_CQ_RSP1_SIZE + + SOCAL_CQ_RSP2_SIZE) * sizeof(socal_req); + s->req_cpu = sbus_alloc_consistent(sdev, size, &s->req_dvma); + s->req[0].pool = s->req_cpu; + cq[0].address = s->req_dvma; + s->req[1].pool = s->req[0].pool + SOCAL_CQ_REQ0_SIZE; + s->rsp[0].pool = s->req[1].pool + SOCAL_CQ_REQ1_SIZE; + s->rsp[1].pool = s->rsp[0].pool + SOCAL_CQ_RSP0_SIZE; + s->rsp[2].pool = s->rsp[1].pool + SOCAL_CQ_RSP1_SIZE; + + s->req[0].hw_cq = (socal_hw_cq __iomem *)(s->xram + SOCAL_CQ_REQ_OFFSET); + s->req[1].hw_cq = (socal_hw_cq __iomem *)(s->xram + SOCAL_CQ_REQ_OFFSET + sizeof(socal_hw_cq)); + s->rsp[0].hw_cq = (socal_hw_cq __iomem *)(s->xram + SOCAL_CQ_RSP_OFFSET); + s->rsp[1].hw_cq = (socal_hw_cq __iomem *)(s->xram + SOCAL_CQ_RSP_OFFSET + sizeof(socal_hw_cq)); + s->rsp[2].hw_cq = (socal_hw_cq __iomem *)(s->xram + SOCAL_CQ_RSP_OFFSET + 2 * sizeof(socal_hw_cq)); + + cq[1].address = cq[0].address + (SOCAL_CQ_REQ0_SIZE * sizeof(socal_req)); + cq[4].address = cq[1].address + (SOCAL_CQ_REQ1_SIZE * sizeof(socal_req)); + cq[5].address = cq[4].address + (SOCAL_CQ_RSP0_SIZE * sizeof(socal_req)); + cq[6].address = cq[5].address + (SOCAL_CQ_RSP1_SIZE * sizeof(socal_req)); + + cq[0].last = SOCAL_CQ_REQ0_SIZE - 1; + cq[1].last = SOCAL_CQ_REQ1_SIZE - 1; + cq[4].last = SOCAL_CQ_RSP0_SIZE - 1; + cq[5].last = SOCAL_CQ_RSP1_SIZE - 1; + cq[6].last = SOCAL_CQ_RSP2_SIZE - 1; + for (i = 0; i < 8; i++) + cq[i].seqno = 1; + + s->req[0].last = SOCAL_CQ_REQ0_SIZE - 1; + s->req[1].last = SOCAL_CQ_REQ1_SIZE - 1; + s->rsp[0].last = SOCAL_CQ_RSP0_SIZE - 1; + s->rsp[1].last = SOCAL_CQ_RSP1_SIZE - 1; + s->rsp[2].last = SOCAL_CQ_RSP2_SIZE - 1; + + s->req[0].seqno = 1; + s->req[1].seqno = 1; + s->rsp[0].seqno = 1; + s->rsp[1].seqno = 1; + s->rsp[2].seqno = 1; + + socal_copy_to_xram(s->xram + SOCAL_CQ_REQ_OFFSET, cq, sizeof(cq)); + + SOD(("Setting up params\n")) + + /* Make our sw copy of SOCAL service parameters */ + socal_copy_from_xram(s->serv_params, s->xram + 0x280, sizeof (s->serv_params)); + + s->port[0].fc.common_svc = (common_svc_parm *)s->serv_params; + s->port[0].fc.class_svcs = (svc_parm *)(s->serv_params + 0x20); + s->port[1].fc.common_svc = (common_svc_parm *)&s->serv_params; + s->port[1].fc.class_svcs = (svc_parm *)(s->serv_params + 0x20); + + socal_enable (s); + + SOD(("Enabled SOCAL\n")) +} + +static int __init socal_probe(void) +{ + struct sbus_bus *sbus; + struct sbus_dev *sdev = NULL; + struct socal *s; + int cards = 0; + + for_each_sbus(sbus) { + for_each_sbusdev(sdev, sbus) { + if(!strcmp(sdev->prom_name, "SUNW,socal")) { + socal_init(sdev, cards); + cards++; + } + } + } + if (!cards) + return -EIO; + + for_each_socal(s) + if (s->next) + s->port[1].fc.next = &s->next->port[0].fc; + + fcp_init (&socals->port[0].fc); + return 0; +} + +static void __exit socal_cleanup(void) +{ + struct socal *s; + int irq; + struct sbus_dev *sdev; + + for_each_socal(s) { + irq = s->port[0].fc.irq; + free_irq (irq, s); + + fcp_release(&(s->port[0].fc), 2); + + sdev = s->port[0].fc.dev; + if (sdev->num_registers == 1) { + sbus_iounmap(s->eeprom, sdev->reg_addrs[0].reg_size); + } else { + sbus_iounmap(s->xram, sdev->reg_addrs[1].reg_size); + sbus_iounmap(s->regs, sdev->reg_addrs[2].reg_size); + } + sbus_free_consistent(sdev, + (SOCAL_CQ_REQ0_SIZE + SOCAL_CQ_REQ1_SIZE + + SOCAL_CQ_RSP0_SIZE + SOCAL_CQ_RSP1_SIZE + + SOCAL_CQ_RSP2_SIZE) * sizeof(socal_req), + s->req_cpu, s->req_dvma); + } +} + +module_init(socal_probe); +module_exit(socal_cleanup); +MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/fc4/socal.h b/trunk/drivers/fc4/socal.h new file mode 100644 index 000000000000..774edf68e4d2 --- /dev/null +++ b/trunk/drivers/fc4/socal.h @@ -0,0 +1,314 @@ +/* socal.h: Definitions for Sparc SUNW,socal (SOC+) Fibre Channel Sbus driver. + * + * Copyright (C) 1998,1999 Jakub Jelinek (jj@ultra.linux.cz) + */ + +#ifndef __SOCAL_H +#define __SOCAL_H + +#include "fc.h" +#include "fcp.h" +#include "fcp_impl.h" + +/* Hardware register offsets and constants first {{{ */ +#define CFG 0x00UL +#define SAE 0x04UL +#define CMD 0x08UL +#define IMASK 0x0cUL +#define REQP 0x10UL +#define RESP 0x14UL + +/* Config Register */ +#define SOCAL_CFG_EXT_RAM_BANK_MASK 0x07000000 +#define SOCAL_CFG_EEPROM_BANK_MASK 0x00030000 +#define SOCAL_CFG_BURST64_MASK 0x00000700 +#define SOCAL_CFG_SBUS_PARITY_TEST 0x00000020 +#define SOCAL_CFG_SBUS_PARITY_CHECK 0x00000010 +#define SOCAL_CFG_SBUS_ENHANCED 0x00000008 +#define SOCAL_CFG_BURST_MASK 0x00000007 +/* Bursts */ +#define SOCAL_CFG_BURST_4 0x00000000 +#define SOCAL_CFG_BURST_8 0x00000003 +#define SOCAL_CFG_BURST_16 0x00000004 +#define SOCAL_CFG_BURST_32 0x00000005 +#define SOCAL_CFG_BURST_64 0x00000006 +#define SOCAL_CFG_BURST_128 0x00000007 + +/* Slave Access Error Register */ +#define SOCAL_SAE_ALIGNMENT 0x00000004 +#define SOCAL_SAE_UNSUPPORTED 0x00000002 +#define SOCAL_SAE_PARITY 0x00000001 + +/* Command & Status Register */ +#define SOCAL_CMD_RSP_QALL 0x000f0000 +#define SOCAL_CMD_RSP_Q0 0x00010000 +#define SOCAL_CMD_RSP_Q1 0x00020000 +#define SOCAL_CMD_RSP_Q2 0x00040000 +#define SOCAL_CMD_RSP_Q3 0x00080000 +#define SOCAL_CMD_REQ_QALL 0x00000f00 +#define SOCAL_CMD_REQ_Q0 0x00000100 +#define SOCAL_CMD_REQ_Q1 0x00000200 +#define SOCAL_CMD_REQ_Q2 0x00000400 +#define SOCAL_CMD_REQ_Q3 0x00000800 +#define SOCAL_CMD_SAE 0x00000080 +#define SOCAL_CMD_INTR_PENDING 0x00000008 +#define SOCAL_CMD_NON_QUEUED 0x00000004 +#define SOCAL_CMD_IDLE 0x00000002 +#define SOCAL_CMD_SOFT_RESET 0x00000001 + +/* Interrupt Mask Register */ +#define SOCAL_IMASK_RSP_QALL 0x000f0000 +#define SOCAL_IMASK_RSP_Q0 0x00010000 +#define SOCAL_IMASK_RSP_Q1 0x00020000 +#define SOCAL_IMASK_RSP_Q2 0x00040000 +#define SOCAL_IMASK_RSP_Q3 0x00080000 +#define SOCAL_IMASK_REQ_QALL 0x00000f00 +#define SOCAL_IMASK_REQ_Q0 0x00000100 +#define SOCAL_IMASK_REQ_Q1 0x00000200 +#define SOCAL_IMASK_REQ_Q2 0x00000400 +#define SOCAL_IMASK_REQ_Q3 0x00000800 +#define SOCAL_IMASK_SAE 0x00000080 +#define SOCAL_IMASK_NON_QUEUED 0x00000004 + +#define SOCAL_INTR(s, cmd) \ + (((cmd & SOCAL_CMD_RSP_QALL) | ((~cmd) & SOCAL_CMD_REQ_QALL)) \ + & s->imask) + +#define SOCAL_SETIMASK(s, i) \ +do { (s)->imask = (i); \ + sbus_writel((i), (s)->regs + IMASK); \ +} while (0) + +#define SOCAL_MAX_EXCHANGES 1024 + +/* XRAM + * + * This is a 64KB register area. + * From the documentation, it seems like it is finally able to cope + * at least with 1,2,4 byte accesses for read and 2,4 byte accesses for write. + */ + +/* Circular Queue */ + +#define SOCAL_CQ_REQ_OFFSET 0x200 +#define SOCAL_CQ_RSP_OFFSET 0x220 + +typedef struct { + u32 address; + u8 in; + u8 out; + u8 last; + u8 seqno; +} socal_hw_cq; + +#define SOCAL_PORT_A 0x0000 /* From/To Port A */ +#define SOCAL_PORT_B 0x0001 /* From/To Port A */ +#define SOCAL_FC_HDR 0x0002 /* Contains FC Header */ +#define SOCAL_NORSP 0x0004 /* Don't generate response nor interrupt */ +#define SOCAL_NOINT 0x0008 /* Generate response but not interrupt */ +#define SOCAL_XFERRDY 0x0010 /* Generate XFERRDY */ +#define SOCAL_IGNOREPARAM 0x0020 /* Ignore PARAM field in the FC header */ +#define SOCAL_COMPLETE 0x0040 /* Command completed */ +#define SOCAL_UNSOLICITED 0x0080 /* For request this is the packet to establish unsolicited pools, */ + /* for rsp this is unsolicited packet */ +#define SOCAL_STATUS 0x0100 /* State change (on/off line) */ +#define SOCAL_RSP_HDR 0x0200 /* Return frame header in any case */ + +typedef struct { + u32 token; + u16 flags; + u8 class; + u8 segcnt; + u32 bytecnt; +} socal_hdr; + +typedef struct { + u32 base; + u32 count; +} socal_data; + +#define SOCAL_CQTYPE_NOP 0x00 +#define SOCAL_CQTYPE_OUTBOUND 0x01 +#define SOCAL_CQTYPE_INBOUND 0x02 +#define SOCAL_CQTYPE_SIMPLE 0x03 +#define SOCAL_CQTYPE_IO_WRITE 0x04 +#define SOCAL_CQTYPE_IO_READ 0x05 +#define SOCAL_CQTYPE_UNSOLICITED 0x06 +#define SOCAL_CQTYPE_BYPASS_DEV 0x06 +#define SOCAL_CQTYPE_DIAG 0x07 +#define SOCAL_CQTYPE_OFFLINE 0x08 +#define SOCAL_CQTYPE_ADD_POOL 0x09 +#define SOCAL_CQTYPE_DELETE_POOL 0x0a +#define SOCAL_CQTYPE_ADD_BUFFER 0x0b +#define SOCAL_CQTYPE_ADD_POOL_BUFFER 0x0c +#define SOCAL_CQTYPE_REQUEST_ABORT 0x0d +#define SOCAL_CQTYPE_REQUEST_LIP 0x0e +#define SOCAL_CQTYPE_REPORT_MAP 0x0f +#define SOCAL_CQTYPE_RESPONSE 0x10 +#define SOCAL_CQTYPE_INLINE 0x20 + +#define SOCAL_CQFLAGS_CONT 0x01 +#define SOCAL_CQFLAGS_FULL 0x02 +#define SOCAL_CQFLAGS_BADHDR 0x04 +#define SOCAL_CQFLAGS_BADPKT 0x08 + +typedef struct { + socal_hdr shdr; + socal_data data[3]; + fc_hdr fchdr; + u8 count; + u8 type; + u8 flags; + u8 seqno; +} socal_req; + +#define SOCAL_OK 0 +#define SOCAL_P_RJT 2 +#define SOCAL_F_RJT 3 +#define SOCAL_P_BSY 4 +#define SOCAL_F_BSY 5 +#define SOCAL_ONLINE 0x10 +#define SOCAL_OFFLINE 0x11 +#define SOCAL_TIMEOUT 0x12 +#define SOCAL_OVERRUN 0x13 +#define SOCAL_ONLINE_LOOP 0x14 +#define SOCAL_OLD_PORT 0x15 +#define SOCAL_AL_PORT 0x16 +#define SOCAL_UNKOWN_CQ_TYPE 0x20 +#define SOCAL_BAD_SEG_CNT 0x21 +#define SOCAL_MAX_XCHG_EXCEEDED 0x22 +#define SOCAL_BAD_XID 0x23 +#define SOCAL_XCHG_BUSY 0x24 +#define SOCAL_BAD_POOL_ID 0x25 +#define SOCAL_INSUFFICIENT_CQES 0x26 +#define SOCAL_ALLOC_FAIL 0x27 +#define SOCAL_BAD_SID 0x28 +#define SOCAL_NO_SEG_INIT 0x29 +#define SOCAL_BAD_DID 0x2a +#define SOCAL_ABORTED 0x30 +#define SOCAL_ABORT_FAILED 0x31 + +typedef struct { + socal_hdr shdr; + u32 status; + socal_data data; + u8 xxx1[10]; + u16 ncmds; + fc_hdr fchdr; + u8 count; + u8 type; + u8 flags; + u8 seqno; +} socal_rsp; + +typedef struct { + socal_hdr shdr; + u8 xxx1[48]; + u8 count; + u8 type; + u8 flags; + u8 seqno; +} socal_cmdonly; + +#define SOCAL_DIAG_NOP 0x00 +#define SOCAL_DIAG_INT_LOOP 0x01 +#define SOCAL_DIAG_EXT_LOOP 0x02 +#define SOCAL_DIAG_REM_LOOP 0x03 +#define SOCAL_DIAG_XRAM_TEST 0x04 +#define SOCAL_DIAG_SOC_TEST 0x05 +#define SOCAL_DIAG_HCB_TEST 0x06 +#define SOCAL_DIAG_SOCLB_TEST 0x07 +#define SOCAL_DIAG_SRDSLB_TEST 0x08 +#define SOCAL_DIAG_EXTOE_TEST 0x09 + +typedef struct { + socal_hdr shdr; + u32 cmd; + u8 xxx1[44]; + u8 count; + u8 type; + u8 flags; + u8 seqno; +} socal_diag_req; + +#define SOCAL_POOL_MASK_RCTL 0x800000 +#define SOCAL_POOL_MASK_DID 0x700000 +#define SOCAL_POOL_MASK_SID 0x070000 +#define SOCAL_POOL_MASK_TYPE 0x008000 +#define SOCAL_POOL_MASK_F_CTL 0x007000 +#define SOCAL_POOL_MASK_SEQ_ID 0x000800 +#define SOCAL_POOL_MASK_D_CTL 0x000400 +#define SOCAL_POOL_MASK_SEQ_CNT 0x000300 +#define SOCAL_POOL_MASK_OX_ID 0x0000f0 +#define SOCAL_POOL_MASK_PARAM 0x00000f + +typedef struct { + socal_hdr shdr; + u32 pool_id; + u32 header_mask; + u32 buf_size; + u32 entries; + u8 xxx1[8]; + fc_hdr fchdr; + u8 count; + u8 type; + u8 flags; + u8 seqno; +} socal_pool_req; + +/* }}} */ + +/* Now our software structures and constants we use to drive the beast {{{ */ + +#define SOCAL_CQ_REQ0_SIZE 4 +#define SOCAL_CQ_REQ1_SIZE 256 +#define SOCAL_CQ_RSP0_SIZE 8 +#define SOCAL_CQ_RSP1_SIZE 4 +#define SOCAL_CQ_RSP2_SIZE 4 + +#define SOCAL_SOLICITED_RSP_Q 0 +#define SOCAL_SOLICITED_BAD_RSP_Q 1 +#define SOCAL_UNSOLICITED_RSP_Q 2 + +struct socal; + +typedef struct { + /* This must come first */ + fc_channel fc; + struct socal *s; + u16 flags; + u16 mask; +} socal_port; + +typedef struct { + socal_hw_cq __iomem *hw_cq; /* Related XRAM cq */ + socal_req *pool; + u8 in; + u8 out; + u8 last; + u8 seqno; +} socal_cq; + +struct socal { + spinlock_t lock; + socal_port port[2]; /* Every SOCAL has one or two FC ports */ + socal_cq req[4]; /* Request CQs */ + socal_cq rsp[4]; /* Response CQs */ + int socal_no; + void __iomem *regs; + void __iomem *xram; + void __iomem *eeprom; + fc_wwn wwn; + u32 imask; /* Our copy of regs->imask */ + u32 cfg; /* Our copy of regs->cfg */ + char serv_params[80]; + struct socal *next; + int curr_port; /* Which port will have priority to fcp_queue_empty */ + + socal_req * req_cpu; + u32 req_dvma; +}; + +/* }}} */ + +#endif /* !(__SOCAL_H) */ diff --git a/trunk/drivers/ide/arm/icside.c b/trunk/drivers/ide/arm/icside.c index 93f71fcfc04d..410a0d13e35e 100644 --- a/trunk/drivers/ide/arm/icside.c +++ b/trunk/drivers/ide/arm/icside.c @@ -316,13 +316,13 @@ static int icside_dma_end(ide_drive_t *drive) drive->waiting_for_dma = 0; - disable_dma(ECARD_DEV(state->dev)->dma); + disable_dma(state->dev->dma); /* Teardown mappings after DMA has completed. */ dma_unmap_sg(state->dev, hwif->sg_table, hwif->sg_nents, hwif->sg_dma_direction); - return get_dma_residue(ECARD_DEV(state->dev)->dma) != 0; + return get_dma_residue(state->dev->dma) != 0; } static void icside_dma_start(ide_drive_t *drive) @@ -331,8 +331,8 @@ static void icside_dma_start(ide_drive_t *drive) struct icside_state *state = hwif->hwif_data; /* We can not enable DMA on both channels simultaneously. */ - BUG_ON(dma_channel_active(ECARD_DEV(state->dev)->dma)); - enable_dma(ECARD_DEV(state->dev)->dma); + BUG_ON(dma_channel_active(state->dev->dma)); + enable_dma(state->dev->dma); } static int icside_dma_setup(ide_drive_t *drive) @@ -350,7 +350,7 @@ static int icside_dma_setup(ide_drive_t *drive) /* * We can not enable DMA on both channels. */ - BUG_ON(dma_channel_active(ECARD_DEV(state->dev)->dma)); + BUG_ON(dma_channel_active(state->dev->dma)); icside_build_sglist(drive, rq); @@ -367,14 +367,14 @@ static int icside_dma_setup(ide_drive_t *drive) /* * Select the correct timing for this drive. */ - set_dma_speed(ECARD_DEV(state->dev)->dma, drive->drive_data); + set_dma_speed(state->dev->dma, drive->drive_data); /* * Tell the DMA engine about the SG table and * data direction. */ - set_dma_sg(ECARD_DEV(state->dev)->dma, hwif->sg_table, hwif->sg_nents); - set_dma_mode(ECARD_DEV(state->dev)->dma, dma_mode); + set_dma_sg(state->dev->dma, hwif->sg_table, hwif->sg_nents); + set_dma_mode(state->dev->dma, dma_mode); drive->waiting_for_dma = 1; diff --git a/trunk/drivers/ide/ide-iops.c b/trunk/drivers/ide/ide-iops.c index dcda0f109df5..95168833d069 100644 --- a/trunk/drivers/ide/ide-iops.c +++ b/trunk/drivers/ide/ide-iops.c @@ -582,12 +582,9 @@ EXPORT_SYMBOL_GPL(ide_in_drive_list); /* * Early UDMA66 devices don't set bit14 to 1, only bit13 is valid. * We list them here and depend on the device side cable detection for them. - * - * Some optical devices with the buggy firmwares have the same problem. */ static const struct drive_list_entry ivb_list[] = { { "QUANTUM FIREBALLlct10 05" , "A03.0900" }, - { "TSSTcorp CDDVDW SH-S202J" , "SB00" }, { NULL , NULL } }; diff --git a/trunk/drivers/ide/pci/cy82c693.c b/trunk/drivers/ide/pci/cy82c693.c index 1cd4e9cb0521..3ef4fc10fe2c 100644 --- a/trunk/drivers/ide/pci/cy82c693.c +++ b/trunk/drivers/ide/pci/cy82c693.c @@ -1,5 +1,5 @@ /* - * linux/drivers/ide/pci/cy82c693.c Version 0.42 Oct 23, 2007 + * linux/drivers/ide/pci/cy82c693.c Version 0.41 Aug 27, 2007 * * Copyright (C) 1998-2000 Andreas S. Krebs (akrebs@altavista.net), Maintainer * Copyright (C) 1998-2002 Andre Hedrick , Integrator @@ -436,10 +436,10 @@ static void __devinit init_hwif_cy82c693(ide_hwif_t *hwif) hwif->ide_dma_on = &cy82c693_ide_dma_on; } +static __devinitdata ide_hwif_t *primary; + static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) { - static ide_hwif_t *primary; - if (PCI_FUNC(hwif->pci_dev->devfn) == 1) primary = hwif; else { diff --git a/trunk/drivers/ide/pci/generic.c b/trunk/drivers/ide/pci/generic.c index 06885697ed7b..f44d70852c3c 100644 --- a/trunk/drivers/ide/pci/generic.c +++ b/trunk/drivers/ide/pci/generic.c @@ -49,7 +49,7 @@ static int __init ide_generic_all_on(char *unused) printk(KERN_INFO "IDE generic will claim all unknown PCI IDE storage controllers.\n"); return 1; } -const __setup("all-generic-ide", ide_generic_all_on); +__setup("all-generic-ide", ide_generic_all_on); #endif module_param_named(all_generic_ide, ide_generic_all, bool, 0444); MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE storage controllers."); diff --git a/trunk/drivers/ide/pci/hpt366.c b/trunk/drivers/ide/pci/hpt366.c index 5682895d36d9..612b795241bf 100644 --- a/trunk/drivers/ide/pci/hpt366.c +++ b/trunk/drivers/ide/pci/hpt366.c @@ -1,5 +1,5 @@ /* - * linux/drivers/ide/pci/hpt366.c Version 1.21 Oct 23, 2007 + * linux/drivers/ide/pci/hpt366.c Version 1.20 Oct 1, 2007 * * Copyright (C) 1999-2003 Andre Hedrick * Portions Copyright (C) 2001 Sun Microsystems, Inc. @@ -433,7 +433,7 @@ static u32 *hpt37x_settings[NUM_ATA_CLOCKS] = { sixty_six_base_hpt37x }; -static const struct hpt_info hpt36x __devinitdata = { +static struct hpt_info hpt36x __devinitdata = { .chip_name = "HPT36x", .chip_type = HPT36x, .udma_mask = HPT366_ALLOW_ATA66_3 ? (HPT366_ALLOW_ATA66_4 ? ATA_UDMA4 : ATA_UDMA3) : ATA_UDMA2, @@ -441,7 +441,7 @@ static const struct hpt_info hpt36x __devinitdata = { .settings = hpt36x_settings }; -static const struct hpt_info hpt370 __devinitdata = { +static struct hpt_info hpt370 __devinitdata = { .chip_name = "HPT370", .chip_type = HPT370, .udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4, @@ -449,7 +449,7 @@ static const struct hpt_info hpt370 __devinitdata = { .settings = hpt37x_settings }; -static const struct hpt_info hpt370a __devinitdata = { +static struct hpt_info hpt370a __devinitdata = { .chip_name = "HPT370A", .chip_type = HPT370A, .udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4, @@ -457,7 +457,7 @@ static const struct hpt_info hpt370a __devinitdata = { .settings = hpt37x_settings }; -static const struct hpt_info hpt374 __devinitdata = { +static struct hpt_info hpt374 __devinitdata = { .chip_name = "HPT374", .chip_type = HPT374, .udma_mask = ATA_UDMA5, @@ -465,7 +465,7 @@ static const struct hpt_info hpt374 __devinitdata = { .settings = hpt37x_settings }; -static const struct hpt_info hpt372 __devinitdata = { +static struct hpt_info hpt372 __devinitdata = { .chip_name = "HPT372", .chip_type = HPT372, .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, @@ -473,7 +473,7 @@ static const struct hpt_info hpt372 __devinitdata = { .settings = hpt37x_settings }; -static const struct hpt_info hpt372a __devinitdata = { +static struct hpt_info hpt372a __devinitdata = { .chip_name = "HPT372A", .chip_type = HPT372A, .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, @@ -481,7 +481,7 @@ static const struct hpt_info hpt372a __devinitdata = { .settings = hpt37x_settings }; -static const struct hpt_info hpt302 __devinitdata = { +static struct hpt_info hpt302 __devinitdata = { .chip_name = "HPT302", .chip_type = HPT302, .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, @@ -489,7 +489,7 @@ static const struct hpt_info hpt302 __devinitdata = { .settings = hpt37x_settings }; -static const struct hpt_info hpt371 __devinitdata = { +static struct hpt_info hpt371 __devinitdata = { .chip_name = "HPT371", .chip_type = HPT371, .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, @@ -497,7 +497,7 @@ static const struct hpt_info hpt371 __devinitdata = { .settings = hpt37x_settings }; -static const struct hpt_info hpt372n __devinitdata = { +static struct hpt_info hpt372n __devinitdata = { .chip_name = "HPT372N", .chip_type = HPT372N, .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, @@ -505,7 +505,7 @@ static const struct hpt_info hpt372n __devinitdata = { .settings = hpt37x_settings }; -static const struct hpt_info hpt302n __devinitdata = { +static struct hpt_info hpt302n __devinitdata = { .chip_name = "HPT302N", .chip_type = HPT302N, .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, @@ -513,7 +513,7 @@ static const struct hpt_info hpt302n __devinitdata = { .settings = hpt37x_settings }; -static const struct hpt_info hpt371n __devinitdata = { +static struct hpt_info hpt371n __devinitdata = { .chip_name = "HPT371N", .chip_type = HPT371N, .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, @@ -1508,7 +1508,7 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = { */ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - const struct hpt_info *info = NULL; + struct hpt_info *info = NULL; struct pci_dev *dev2 = NULL; struct ide_port_info d; u8 idx = id->driver_data; @@ -1522,7 +1522,7 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic if (rev < 3) info = &hpt36x; else { - static const struct hpt_info *hpt37x_info[] = + static struct hpt_info *hpt37x_info[] = { &hpt370, &hpt370a, &hpt372, &hpt372n }; info = hpt37x_info[min_t(u8, rev, 6) - 3]; @@ -1552,7 +1552,7 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic d.name = info->chip_name; d.udma_mask = info->udma_mask; - pci_set_drvdata(dev, (void *)info); + pci_set_drvdata(dev, info); if (info == &hpt36x || info == &hpt374) dev2 = pci_get_slot(dev->bus, dev->devfn + 1); @@ -1560,7 +1560,7 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic if (dev2) { int ret; - pci_set_drvdata(dev2, (void *)info); + pci_set_drvdata(dev2, info); if (info == &hpt374) hpt374_init(dev, dev2); diff --git a/trunk/drivers/ide/pci/sc1200.c b/trunk/drivers/ide/pci/sc1200.c index 0a7b3202066d..d2c8b5524f28 100644 --- a/trunk/drivers/ide/pci/sc1200.c +++ b/trunk/drivers/ide/pci/sc1200.c @@ -324,18 +324,17 @@ static int sc1200_suspend (struct pci_dev *dev, pm_message_t state) pci_disable_device(dev); pci_set_power_state(dev, pci_choose_state(dev, state)); + dev->current_state = state.event; return 0; } static int sc1200_resume (struct pci_dev *dev) { ide_hwif_t *hwif = NULL; - int i; - - i = pci_enable_device(dev); - if (i) - return i; + pci_set_power_state(dev, PCI_D0); // bring chip back from sleep state + dev->current_state = PM_EVENT_ON; + pci_enable_device(dev); // // loop over all interfaces that are part of this pci device: // diff --git a/trunk/drivers/ieee1394/dma.c b/trunk/drivers/ieee1394/dma.c index f5f4983dfbf3..25e113b50d86 100644 --- a/trunk/drivers/ieee1394/dma.c +++ b/trunk/drivers/ieee1394/dma.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include "dma.h" @@ -111,8 +111,8 @@ int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes, unsigned long va = (unsigned long)dma->kvirt + (i << PAGE_SHIFT); - sg_set_page(&dma->sglist[i], vmalloc_to_page((void *)va), - PAGE_SIZE, 0); + sg_set_page(&dma->sglist[i], vmalloc_to_page((void *)va)); + dma->sglist[i].length = PAGE_SIZE; } /* map sglist to the IOMMU */ diff --git a/trunk/drivers/infiniband/core/umem.c b/trunk/drivers/infiniband/core/umem.c index 4e3128ff73c1..14159ff29408 100644 --- a/trunk/drivers/infiniband/core/umem.c +++ b/trunk/drivers/infiniband/core/umem.c @@ -171,7 +171,9 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, if (vma_list && !is_vm_hugetlb_page(vma_list[i + off])) umem->hugetlb = 0; - sg_set_page(&chunk->page_list[i], page_list[i + off], PAGE_SIZE, 0); + sg_set_page(&chunk->page_list[i], page_list[i + off]); + chunk->page_list[i].offset = 0; + chunk->page_list[i].length = PAGE_SIZE; } chunk->nmap = ib_dma_map_sg(context->device, diff --git a/trunk/drivers/infiniband/hw/mthca/mthca_memfree.c b/trunk/drivers/infiniband/hw/mthca/mthca_memfree.c index 1f4d27d7c16d..007b38157fc4 100644 --- a/trunk/drivers/infiniband/hw/mthca/mthca_memfree.c +++ b/trunk/drivers/infiniband/hw/mthca/mthca_memfree.c @@ -113,7 +113,9 @@ static int mthca_alloc_icm_pages(struct scatterlist *mem, int order, gfp_t gfp_m if (!page) return -ENOMEM; - sg_set_page(mem, page, PAGE_SIZE << order, 0); + sg_set_page(mem, page); + mem->length = PAGE_SIZE << order; + mem->offset = 0; return 0; } @@ -479,8 +481,9 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar, if (ret < 0) goto out; - sg_set_page(&db_tab->page[i].mem, pages[0], MTHCA_ICM_PAGE_SIZE, - uaddr & ~PAGE_MASK); + sg_set_page(&db_tab->page[i].mem, pages[0]); + db_tab->page[i].mem.length = MTHCA_ICM_PAGE_SIZE; + db_tab->page[i].mem.offset = uaddr & ~PAGE_MASK; ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); if (ret < 0) { diff --git a/trunk/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/trunk/drivers/infiniband/ulp/ipoib/ipoib_cm.c index 87610772a979..059cf92b60a5 100644 --- a/trunk/drivers/infiniband/ulp/ipoib/ipoib_cm.c +++ b/trunk/drivers/infiniband/ulp/ipoib/ipoib_cm.c @@ -60,7 +60,7 @@ static struct ib_qp_attr ipoib_cm_err_attr = { .qp_state = IB_QPS_ERR }; -#define IPOIB_CM_RX_DRAIN_WRID 0x7fffffff +#define IPOIB_CM_RX_DRAIN_WRID 0xffffffff static struct ib_send_wr ipoib_cm_rx_drain_wr = { .wr_id = IPOIB_CM_RX_DRAIN_WRID, diff --git a/trunk/drivers/input/serio/parkbd.c b/trunk/drivers/input/serio/parkbd.c index b089977e0ef9..688610e86a3e 100644 --- a/trunk/drivers/input/serio/parkbd.c +++ b/trunk/drivers/input/serio/parkbd.c @@ -102,7 +102,7 @@ static int parkbd_write(struct serio *port, unsigned char c) return 0; } -static void parkbd_interrupt(void *dev_id) +static void parkbd_interrupt(int irq, void *dev_id) { if (parkbd_writing) { diff --git a/trunk/drivers/isdn/act2000/act2000_isa.c b/trunk/drivers/isdn/act2000/act2000_isa.c index 1bd8960ead33..819ea85576a3 100644 --- a/trunk/drivers/isdn/act2000/act2000_isa.c +++ b/trunk/drivers/isdn/act2000/act2000_isa.c @@ -61,7 +61,7 @@ act2000_isa_detect(unsigned short portbase) } static irqreturn_t -act2000_isa_interrupt(int dummy, void *dev_id) +act2000_isa_interrupt(int irq, void *dev_id) { act2000_card *card = dev_id; u_char istatus; @@ -80,7 +80,7 @@ act2000_isa_interrupt(int dummy, void *dev_id) printk(KERN_WARNING "act2000: errIRQ\n"); } if (istatus) - printk(KERN_DEBUG "act2000: ?IRQ %d %02x\n", card->irq, istatus); + printk(KERN_DEBUG "act2000: ?IRQ %d %02x\n", irq, istatus); return IRQ_HANDLED; } @@ -131,8 +131,6 @@ act2000_isa_enable_irq(act2000_card * card) int act2000_isa_config_irq(act2000_card * card, short irq) { - int old_irq; - if (card->flags & ACT2000_FLAGS_IVALID) { free_irq(card->irq, card); } @@ -141,10 +139,8 @@ act2000_isa_config_irq(act2000_card * card, short irq) if (!irq) return 0; - old_irq = card->irq; - card->irq = irq; - if (request_irq(irq, &act2000_isa_interrupt, 0, card->regname, card)) { - card->irq = old_irq; + if (!request_irq(irq, &act2000_isa_interrupt, 0, card->regname, card)) { + card->irq = irq; card->flags |= ACT2000_FLAGS_IVALID; printk(KERN_WARNING "act2000: Could not request irq %d\n",irq); diff --git a/trunk/drivers/isdn/capi/capidrv.c b/trunk/drivers/isdn/capi/capidrv.c index 48c1775ef5b3..476012b6dfac 100644 --- a/trunk/drivers/isdn/capi/capidrv.c +++ b/trunk/drivers/isdn/capi/capidrv.c @@ -1843,7 +1843,6 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb) int msglen; u16 errcode; u16 datahandle; - u32 data; if (!card) { printk(KERN_ERR "capidrv: if_sendbuf called with invalid driverId %d!\n", @@ -1861,26 +1860,9 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb) return 0; } datahandle = nccip->datahandle; - - /* - * Here we copy pointer skb->data into the 32-bit 'Data' field. - * The 'Data' field is not used in practice in linux kernel - * (neither in 32 or 64 bit), but should have some value, - * since a CAPI message trace will display it. - * - * The correct value in the 32 bit case is the address of the - * data, in 64 bit it makes no sense, we use 0 there. - */ - -#ifdef CONFIG_64BIT - data = 0; -#else - data = (unsigned long) skb->data; -#endif - capi_fill_DATA_B3_REQ(&sendcmsg, global.ap.applid, card->msgid++, nccip->ncci, /* adr */ - data, /* Data */ + (u32) skb->data, /* Data */ skb->len, /* DataLength */ datahandle, /* DataHandle */ 0 /* Flags */ @@ -2141,10 +2123,7 @@ static int capidrv_delcontr(u16 contr) printk(KERN_ERR "capidrv: delcontr: no contr %u\n", contr); return -1; } - - /* FIXME: maybe a race condition the card should be removed - * here from global list /kkeil - */ + #warning FIXME: maybe a race condition the card should be removed here from global list /kkeil spin_unlock_irqrestore(&global_lock, flags); del_timer(&card->listentimer); diff --git a/trunk/drivers/isdn/sc/init.c b/trunk/drivers/isdn/sc/init.c index dd0acd06750b..d09c854cfac7 100644 --- a/trunk/drivers/isdn/sc/init.c +++ b/trunk/drivers/isdn/sc/init.c @@ -334,8 +334,7 @@ static int __init sc_init(void) */ sc_adapter[cinst]->interrupt = irq[b]; if (request_irq(sc_adapter[cinst]->interrupt, interrupt_handler, - IRQF_DISABLED, interface->id, - (void *)(unsigned long) cinst)) + IRQF_DISABLED, interface->id, NULL)) { kfree(sc_adapter[cinst]->channel); indicate_status(cinst, ISDN_STAT_UNLOAD, 0, NULL); /* Fix me */ diff --git a/trunk/drivers/isdn/sc/interrupt.c b/trunk/drivers/isdn/sc/interrupt.c index 485be8b1e1b3..bef7963cdd02 100644 --- a/trunk/drivers/isdn/sc/interrupt.c +++ b/trunk/drivers/isdn/sc/interrupt.c @@ -21,15 +21,28 @@ #include "card.h" #include +static int get_card_from_irq(int irq) +{ + int i; + + for(i = 0 ; i < cinst ; i++) { + if(sc_adapter[i]->interrupt == irq) + return i; + } + return -1; +} + /* * */ -irqreturn_t interrupt_handler(int dummy, void *card_inst) +irqreturn_t interrupt_handler(int interrupt, void *cardptr) { RspMessage rcvmsg; int channel; - int card = (int)(unsigned long) card_inst; + int card; + + card = get_card_from_irq(interrupt); if(!IS_VALID_CARD(card)) { pr_debug("Invalid param: %d is not a valid card id\n", card); diff --git a/trunk/drivers/isdn/sc/shmem.c b/trunk/drivers/isdn/sc/shmem.c index e0331e0094f1..034d41a61ae1 100644 --- a/trunk/drivers/isdn/sc/shmem.c +++ b/trunk/drivers/isdn/sc/shmem.c @@ -28,15 +28,15 @@ void memcpy_toshmem(int card, void *dest, const void *src, size_t n) { unsigned long flags; unsigned char ch; - unsigned long dest_rem = ((unsigned long) dest) % 0x4000; - if (!IS_VALID_CARD(card)) { + if(!IS_VALID_CARD(card)) { pr_debug("Invalid param: %d is not a valid card id\n", card); return; } - if (n > SRAM_PAGESIZE) + if(n > SRAM_PAGESIZE) { return; + } /* * determine the page to load from the address @@ -50,7 +50,8 @@ void memcpy_toshmem(int card, void *dest, const void *src, size_t n) outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80, sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); - memcpy_toio(sc_adapter[card]->rambase + dest_rem, src, n); + memcpy_toio(sc_adapter[card]->rambase + + ((unsigned long) dest % 0x4000), src, n); spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename, ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80); diff --git a/trunk/drivers/lguest/core.c b/trunk/drivers/lguest/core.c index cb4c67025d52..35d19ae58de7 100644 --- a/trunk/drivers/lguest/core.c +++ b/trunk/drivers/lguest/core.c @@ -128,12 +128,9 @@ static void unmap_switcher(void) __free_pages(switcher_page[i], 0); } -/*H:032 +/*L:305 * Dealing With Guest Memory. * - * Before we go too much further into the Host, we need to grok the routines - * we use to deal with Guest memory. - * * When the Guest gives us (what it thinks is) a physical address, we can use * the normal copy_from_user() & copy_to_user() on the corresponding place in * the memory region allocated by the Launcher. diff --git a/trunk/drivers/lguest/hypercalls.c b/trunk/drivers/lguest/hypercalls.c index b478affe8f91..9d5184c7c14a 100644 --- a/trunk/drivers/lguest/hypercalls.c +++ b/trunk/drivers/lguest/hypercalls.c @@ -90,7 +90,6 @@ static void do_hcall(struct lguest *lg, struct hcall_args *args) lg->pending_notify = args->arg1; break; default: - /* It should be an architecture-specific hypercall. */ if (lguest_arch_do_hcall(lg, args)) kill_guest(lg, "Bad hypercall %li\n", args->arg0); } @@ -158,6 +157,7 @@ static void do_async_hcalls(struct lguest *lg) * Guest makes a hypercall, we end up here to set things up: */ static void initialize(struct lguest *lg) { + /* You can't do anything until you're initialized. The Guest knows the * rules, so we're unforgiving here. */ if (lg->hcall->arg0 != LHCALL_LGUEST_INIT) { @@ -174,8 +174,7 @@ static void initialize(struct lguest *lg) || get_user(lg->noirq_end, &lg->lguest_data->noirq_end)) kill_guest(lg, "bad guest page %p", lg->lguest_data); - /* We write the current time into the Guest's data page once so it can - * set its clock. */ + /* We write the current time into the Guest's data page once now. */ write_timestamp(lg); /* page_tables.c will also do some setup. */ @@ -183,8 +182,8 @@ static void initialize(struct lguest *lg) /* This is the one case where the above accesses might have been the * first write to a Guest page. This may have caused a copy-on-write - * fault, but the old page might be (read-only) in the Guest - * pagetable. */ + * fault, but the Guest might be referring to the old (read-only) + * page. */ guest_pagetable_clear_all(lg); } @@ -221,7 +220,7 @@ void do_hypercalls(struct lguest *lg) * Normally it doesn't matter: the Guest will run again and * update the trap number before we come back here. * - * However, if we are signalled or the Guest sends I/O to the + * However, if we are signalled or the Guest sends DMA to the * Launcher, the run_guest() loop will exit without running the * Guest. When it comes back it would try to re-run the * hypercall. */ diff --git a/trunk/drivers/lguest/interrupts_and_traps.c b/trunk/drivers/lguest/interrupts_and_traps.c index 2b66f79c208b..82966982cb38 100644 --- a/trunk/drivers/lguest/interrupts_and_traps.c +++ b/trunk/drivers/lguest/interrupts_and_traps.c @@ -92,8 +92,8 @@ static void set_guest_interrupt(struct lguest *lg, u32 lo, u32 hi, int has_err) /* Remember that we never let the Guest actually disable interrupts, so * the "Interrupt Flag" bit is always set. We copy that bit from the - * Guest's "irq_enabled" field into the eflags word: we saw the Guest - * copy it back in "lguest_iret". */ + * Guest's "irq_enabled" field into the eflags word: the Guest copies + * it back in "lguest_iret". */ eflags = lg->regs->eflags; if (get_user(irq_enable, &lg->lguest_data->irq_enabled) == 0 && !(irq_enable & X86_EFLAGS_IF)) @@ -124,7 +124,7 @@ static void set_guest_interrupt(struct lguest *lg, u32 lo, u32 hi, int has_err) kill_guest(lg, "Disabling interrupts"); } -/*H:205 +/*H:200 * Virtual Interrupts. * * maybe_do_interrupt() gets called before every entry to the Guest, to see if @@ -256,21 +256,19 @@ int deliver_trap(struct lguest *lg, unsigned int num) * bogus one in): if we fail here, the Guest will be killed. */ if (!idt_present(lg->arch.idt[num].a, lg->arch.idt[num].b)) return 0; - set_guest_interrupt(lg, lg->arch.idt[num].a, lg->arch.idt[num].b, - has_err(num)); + set_guest_interrupt(lg, lg->arch.idt[num].a, lg->arch.idt[num].b, has_err(num)); return 1; } /*H:250 Here's the hard part: returning to the Host every time a trap happens * and then calling deliver_trap() and re-entering the Guest is slow. - * Particularly because Guest userspace system calls are traps (usually trap - * 128). + * Particularly because Guest userspace system calls are traps (trap 128). * * So we'd like to set up the IDT to tell the CPU to deliver traps directly * into the Guest. This is possible, but the complexities cause the size of * this file to double! However, 150 lines of code is worth writing for taking * system calls down from 1750ns to 270ns. Plus, if lguest didn't do it, all - * the other hypervisors would beat it up at lunchtime. + * the other hypervisors would tease it. * * This routine indicates if a particular trap number could be delivered * directly. */ @@ -333,7 +331,7 @@ void pin_stack_pages(struct lguest *lg) * change stacks on each context switch. */ void guest_set_stack(struct lguest *lg, u32 seg, u32 esp, unsigned int pages) { - /* You are not allowed have a stack segment with privilege level 0: bad + /* You are not allowd have a stack segment with privilege level 0: bad * Guest! */ if ((seg & 0x3) != GUEST_PL) kill_guest(lg, "bad stack segment %i", seg); @@ -352,7 +350,7 @@ void guest_set_stack(struct lguest *lg, u32 seg, u32 esp, unsigned int pages) * part of the Host: page table handling. */ /*H:235 This is the routine which actually checks the Guest's IDT entry and - * transfers it into the entry in "struct lguest": */ + * transfers it into our entry in "struct lguest": */ static void set_trap(struct lguest *lg, struct desc_struct *trap, unsigned int num, u32 lo, u32 hi) { @@ -458,18 +456,6 @@ void copy_traps(const struct lguest *lg, struct desc_struct *idt, } } -/*H:200 - * The Guest Clock. - * - * There are two sources of virtual interrupts. We saw one in lguest_user.c: - * the Launcher sending interrupts for virtual devices. The other is the Guest - * timer interrupt. - * - * The Guest uses the LHCALL_SET_CLOCKEVENT hypercall to tell us how long to - * the next timer interrupt (in nanoseconds). We use the high-resolution timer - * infrastructure to set a callback at that time. - * - * 0 means "turn off the clock". */ void guest_set_clockevent(struct lguest *lg, unsigned long delta) { ktime_t expires; @@ -480,27 +466,20 @@ void guest_set_clockevent(struct lguest *lg, unsigned long delta) return; } - /* We use wallclock time here, so the Guest might not be running for - * all the time between now and the timer interrupt it asked for. This - * is almost always the right thing to do. */ expires = ktime_add_ns(ktime_get_real(), delta); hrtimer_start(&lg->hrt, expires, HRTIMER_MODE_ABS); } -/* This is the function called when the Guest's timer expires. */ static enum hrtimer_restart clockdev_fn(struct hrtimer *timer) { struct lguest *lg = container_of(timer, struct lguest, hrt); - /* Remember the first interrupt is the timer interrupt. */ set_bit(0, lg->irqs_pending); - /* If the Guest is actually stopped, we need to wake it up. */ if (lg->halted) wake_up_process(lg->tsk); return HRTIMER_NORESTART; } -/* This sets up the timer for this Guest. */ void init_clockdev(struct lguest *lg) { hrtimer_init(&lg->hrt, CLOCK_REALTIME, HRTIMER_MODE_ABS); diff --git a/trunk/drivers/lguest/lg.h b/trunk/drivers/lguest/lg.h index 86924891b5eb..d9144beca82c 100644 --- a/trunk/drivers/lguest/lg.h +++ b/trunk/drivers/lguest/lg.h @@ -74,6 +74,9 @@ struct lguest u32 pgdidx; struct pgdir pgdirs[4]; + /* Cached wakeup: we hold a reference to this task. */ + struct task_struct *wake; + unsigned long noirq_start, noirq_end; unsigned long pending_notify; /* pfn from LHCALL_NOTIFY */ @@ -100,7 +103,7 @@ int lguest_address_ok(const struct lguest *lg, void __lgread(struct lguest *, void *, unsigned long, unsigned); void __lgwrite(struct lguest *, unsigned long, const void *, unsigned); -/*H:035 Using memory-copy operations like that is usually inconvient, so we +/*L:306 Using memory-copy operations like that is usually inconvient, so we * have the following helper macros which read and write a specific type (often * an unsigned long). * @@ -188,7 +191,7 @@ void write_timestamp(struct lguest *lg); * Let's step aside for the moment, to study one important routine that's used * widely in the Host code. * - * There are many cases where the Guest can do something invalid, like pass crap + * There are many cases where the Guest does something invalid, like pass crap * to a hypercall. Since only the Guest kernel can make hypercalls, it's quite * acceptable to simply terminate the Guest and give the Launcher a nicely * formatted reason. It's also simpler for the Guest itself, which doesn't diff --git a/trunk/drivers/lguest/lguest_device.c b/trunk/drivers/lguest/lguest_device.c index 8904f72f97c6..71c64837b437 100644 --- a/trunk/drivers/lguest/lguest_device.c +++ b/trunk/drivers/lguest/lguest_device.c @@ -53,8 +53,7 @@ struct lguest_device { * Device configurations * * The configuration information for a device consists of a series of fields. - * We don't really care what they are: the Launcher set them up, and the driver - * will look at them during setup. + * The device will look for these fields during setup. * * For us these fields come immediately after that device's descriptor in the * lguest_devices page. @@ -123,8 +122,8 @@ static void lg_set_status(struct virtio_device *vdev, u8 status) * The other piece of infrastructure virtio needs is a "virtqueue": a way of * the Guest device registering buffers for the other side to read from or * write into (ie. send and receive buffers). Each device can have multiple - * virtqueues: for example the console driver uses one queue for sending and - * another for receiving. + * virtqueues: for example the console has one queue for sending and one for + * receiving. * * Fortunately for us, a very fast shared-memory-plus-descriptors virtqueue * already exists in virtio_ring.c. We just need to connect it up. @@ -159,7 +158,7 @@ static void lg_notify(struct virtqueue *vq) * * This is kind of an ugly duckling. It'd be nicer to have a standard * representation of a virtqueue in the configuration space, but it seems that - * everyone wants to do it differently. The KVM coders want the Guest to + * everyone wants to do it differently. The KVM guys want the Guest to * allocate its own pages and tell the Host where they are, but for lguest it's * simpler for the Host to simply tell us where the pages are. * @@ -285,8 +284,6 @@ static void add_lguest_device(struct lguest_device_desc *d) { struct lguest_device *ldev; - /* Start with zeroed memory; Linux's device layer seems to count on - * it. */ ldev = kzalloc(sizeof(*ldev), GFP_KERNEL); if (!ldev) { printk(KERN_EMERG "Cannot allocate lguest dev %u\n", diff --git a/trunk/drivers/lguest/lguest_user.c b/trunk/drivers/lguest/lguest_user.c index 9d716fa42cad..ee405b38383d 100644 --- a/trunk/drivers/lguest/lguest_user.c +++ b/trunk/drivers/lguest/lguest_user.c @@ -8,22 +8,20 @@ #include #include "lg.h" -/*L:055 When something happens, the Waker process needs a way to stop the - * kernel running the Guest and return to the Launcher. So the Waker writes - * LHREQ_BREAK and the value "1" to /dev/lguest to do this. Once the Launcher - * has done whatever needs attention, it writes LHREQ_BREAK and "0" to release - * the Waker. */ +/*L:315 To force the Guest to stop running and return to the Launcher, the + * Waker sets writes LHREQ_BREAK and the value "1" to /dev/lguest. The + * Launcher then writes LHREQ_BREAK and "0" to release the Waker. */ static int break_guest_out(struct lguest *lg, const unsigned long __user *input) { unsigned long on; - /* Fetch whether they're turning break on or off. */ + /* Fetch whether they're turning break on or off.. */ if (get_user(on, input) != 0) return -EFAULT; if (on) { lg->break_out = 1; - /* Pop it out of the Guest (may be running on different CPU) */ + /* Pop it out (may be running on different CPU) */ wake_up_process(lg->tsk); /* Wait for them to reset it */ return wait_event_interruptible(lg->break_wq, !lg->break_out); @@ -60,7 +58,7 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o) if (!lg) return -EINVAL; - /* If you're not the task which owns the Guest, go away. */ + /* If you're not the task which owns the guest, go away. */ if (current != lg->tsk) return -EPERM; @@ -94,8 +92,8 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o) * base: The start of the Guest-physical memory inside the Launcher memory. * * pfnlimit: The highest (Guest-physical) page number the Guest should be - * allowed to access. The Guest memory lives inside the Launcher, so it sets - * this to ensure the Guest can only reach its own memory. + * allowed to access. The Launcher has to live in Guest memory, so it sets + * this to ensure the Guest can't reach it. * * pgdir: The (Guest-physical) address of the top of the initial Guest * pagetables (which are set up by the Launcher). @@ -191,7 +189,7 @@ static int initialize(struct file *file, const unsigned long __user *input) } /*L:010 The first operation the Launcher does must be a write. All writes - * start with an unsigned long number: for the first write this must be + * start with a 32 bit number: for the first write this must be * LHREQ_INITIALIZE to set up the Guest. After that the Launcher can use * writes of other values to send interrupts. */ static ssize_t write(struct file *file, const char __user *in, @@ -277,7 +275,8 @@ static int close(struct inode *inode, struct file *file) * The Launcher is the Host userspace program which sets up, runs and services * the Guest. In fact, many comments in the Drivers which refer to "the Host" * doing things are inaccurate: the Launcher does all the device handling for - * the Guest, but the Guest can't know that. + * the Guest. The Guest can't tell what's done by the the Launcher and what by + * the Host. * * Just to confuse you: to the Host kernel, the Launcher *is* the Guest and we * shall see more of that later. diff --git a/trunk/drivers/lguest/page_tables.c b/trunk/drivers/lguest/page_tables.c index fffabb327157..2a45f0691c9b 100644 --- a/trunk/drivers/lguest/page_tables.c +++ b/trunk/drivers/lguest/page_tables.c @@ -26,8 +26,7 @@ * * We use two-level page tables for the Guest. If you're not entirely * comfortable with virtual addresses, physical addresses and page tables then - * I recommend you review arch/x86/lguest/boot.c's "Page Table Handling" (with - * diagrams!). + * I recommend you review lguest.c's "Page Table Handling" (with diagrams!). * * The Guest keeps page tables, but we maintain the actual ones here: these are * called "shadow" page tables. Which is a very Guest-centric name: these are @@ -37,11 +36,11 @@ * * Anyway, this is the most complicated part of the Host code. There are seven * parts to this: - * (i) Looking up a page table entry when the Guest faults, - * (ii) Making sure the Guest stack is mapped, - * (iii) Setting up a page table entry when the Guest tells us one has changed, + * (i) Setting up a page table entry for the Guest when it faults, + * (ii) Setting up the page table entry for the Guest stack, + * (iii) Setting up a page table entry when the Guest tells us it has changed, * (iv) Switching page tables, - * (v) Flushing (throwing away) page tables, + * (v) Flushing (thowing away) page tables, * (vi) Mapping the Switcher when the Guest is about to run, * (vii) Setting up the page tables initially. :*/ @@ -58,15 +57,16 @@ static DEFINE_PER_CPU(pte_t *, switcher_pte_pages); #define switcher_pte_page(cpu) per_cpu(switcher_pte_pages, cpu) -/*H:320 The page table code is curly enough to need helper functions to keep it - * clear and clean. +/*H:320 With our shadow and Guest types established, we need to deal with + * them: the page table code is curly enough to need helper functions to keep + * it clear and clean. * * There are two functions which return pointers to the shadow (aka "real") * page tables. * * spgd_addr() takes the virtual address and returns a pointer to the top-level - * page directory entry (PGD) for that address. Since we keep track of several - * page tables, the "i" argument tells us which one we're interested in (it's + * page directory entry for that address. Since we keep track of several page + * tables, the "i" argument tells us which one we're interested in (it's * usually the current one). */ static pgd_t *spgd_addr(struct lguest *lg, u32 i, unsigned long vaddr) { @@ -81,9 +81,9 @@ static pgd_t *spgd_addr(struct lguest *lg, u32 i, unsigned long vaddr) return &lg->pgdirs[i].pgdir[index]; } -/* This routine then takes the page directory entry returned above, which - * contains the address of the page table entry (PTE) page. It then returns a - * pointer to the PTE entry for the given address. */ +/* This routine then takes the PGD entry given above, which contains the + * address of the PTE page. It then returns a pointer to the PTE entry for the + * given address. */ static pte_t *spte_addr(struct lguest *lg, pgd_t spgd, unsigned long vaddr) { pte_t *page = __va(pgd_pfn(spgd) << PAGE_SHIFT); @@ -191,7 +191,7 @@ static void check_gpgd(struct lguest *lg, pgd_t gpgd) } /*H:330 - * (i) Looking up a page table entry when the Guest faults. + * (i) Setting up a page table entry for the Guest when it faults * * We saw this call in run_guest(): when we see a page fault in the Guest, we * come here. That's because we only set up the shadow page tables lazily as @@ -199,7 +199,7 @@ static void check_gpgd(struct lguest *lg, pgd_t gpgd) * and return to the Guest without it knowing. * * If we fixed up the fault (ie. we mapped the address), this routine returns - * true. Otherwise, it was a real fault and we need to tell the Guest. */ + * true. */ int demand_page(struct lguest *lg, unsigned long vaddr, int errcode) { pgd_t gpgd; @@ -246,16 +246,16 @@ int demand_page(struct lguest *lg, unsigned long vaddr, int errcode) if ((errcode & 2) && !(pte_flags(gpte) & _PAGE_RW)) return 0; - /* User access to a kernel-only page? (bit 3 == user access) */ + /* User access to a kernel page? (bit 3 == user access) */ if ((errcode & 4) && !(pte_flags(gpte) & _PAGE_USER)) return 0; /* Check that the Guest PTE flags are OK, and the page number is below * the pfn_limit (ie. not mapping the Launcher binary). */ check_gpte(lg, gpte); - /* Add the _PAGE_ACCESSED and (for a write) _PAGE_DIRTY flag */ gpte = pte_mkyoung(gpte); + if (errcode & 2) gpte = pte_mkdirty(gpte); @@ -272,28 +272,23 @@ int demand_page(struct lguest *lg, unsigned long vaddr, int errcode) else /* If this is a read, don't set the "writable" bit in the page * table entry, even if the Guest says it's writable. That way - * we will come back here when a write does actually occur, so - * we can update the Guest's _PAGE_DIRTY flag. */ + * we come back here when a write does actually ocur, so we can + * update the Guest's _PAGE_DIRTY flag. */ *spte = gpte_to_spte(lg, pte_wrprotect(gpte), 0); /* Finally, we write the Guest PTE entry back: we've set the * _PAGE_ACCESSED and maybe the _PAGE_DIRTY flags. */ lgwrite(lg, gpte_ptr, pte_t, gpte); - /* The fault is fixed, the page table is populated, the mapping - * manipulated, the result returned and the code complete. A small - * delay and a trace of alliteration are the only indications the Guest - * has that a page fault occurred at all. */ + /* We succeeded in mapping the page! */ return 1; } -/*H:360 - * (ii) Making sure the Guest stack is mapped. +/*H:360 (ii) Setting up the page table entry for the Guest stack. * - * Remember that direct traps into the Guest need a mapped Guest kernel stack. - * pin_stack_pages() calls us here: we could simply call demand_page(), but as - * we've seen that logic is quite long, and usually the stack pages are already - * mapped, so it's overkill. + * Remember pin_stack_pages() which makes sure the stack is mapped? It could + * simply call demand_page(), but as we've seen that logic is quite long, and + * usually the stack pages are already mapped anyway, so it's not required. * * This is a quick version which answers the question: is this virtual address * mapped by the shadow page tables, and is it writable? */ @@ -302,7 +297,7 @@ static int page_writable(struct lguest *lg, unsigned long vaddr) pgd_t *spgd; unsigned long flags; - /* Look at the current top level entry: is it present? */ + /* Look at the top level entry: is it present? */ spgd = spgd_addr(lg, lg->pgdidx, vaddr); if (!(pgd_flags(*spgd) & _PAGE_PRESENT)) return 0; @@ -338,14 +333,15 @@ static void release_pgd(struct lguest *lg, pgd_t *spgd) release_pte(ptepage[i]); /* Now we can free the page of PTEs */ free_page((long)ptepage); - /* And zero out the PGD entry so we never release it twice. */ + /* And zero out the PGD entry we we never release it twice. */ *spgd = __pgd(0); } } -/*H:445 We saw flush_user_mappings() twice: once from the flush_user_mappings() - * hypercall and once in new_pgdir() when we re-used a top-level pgdir page. - * It simply releases every PTE page from 0 up to the Guest's kernel address. */ +/*H:440 (v) Flushing (thowing away) page tables, + * + * We saw flush_user_mappings() called when we re-used a top-level pgdir page. + * It simply releases every PTE page from 0 up to the kernel address. */ static void flush_user_mappings(struct lguest *lg, int idx) { unsigned int i; @@ -354,10 +350,8 @@ static void flush_user_mappings(struct lguest *lg, int idx) release_pgd(lg, lg->pgdirs[idx].pgdir + i); } -/*H:440 (v) Flushing (throwing away) page tables, - * - * The Guest has a hypercall to throw away the page tables: it's used when a - * large number of mappings have been changed. */ +/* The Guest also has a hypercall to do this manually: it's used when a large + * number of mappings have been changed. */ void guest_pagetable_flush_user(struct lguest *lg) { /* Drop the userspace part of the current page table. */ @@ -429,9 +423,8 @@ static unsigned int new_pgdir(struct lguest *lg, /*H:430 (iv) Switching page tables * - * Now we've seen all the page table setting and manipulation, let's see what - * what happens when the Guest changes page tables (ie. changes the top-level - * pgdir). This occurs on almost every context switch. */ + * This is what happens when the Guest changes page tables (ie. changes the + * top-level pgdir). This happens on almost every context switch. */ void guest_new_pagetable(struct lguest *lg, unsigned long pgtable) { int newpgdir, repin = 0; @@ -450,8 +443,7 @@ void guest_new_pagetable(struct lguest *lg, unsigned long pgtable) } /*H:470 Finally, a routine which throws away everything: all PGD entries in all - * the shadow page tables, including the Guest's kernel mappings. This is used - * when we destroy the Guest. */ + * the shadow page tables. This is used when we destroy the Guest. */ static void release_all_pagetables(struct lguest *lg) { unsigned int i, j; @@ -466,22 +458,13 @@ static void release_all_pagetables(struct lguest *lg) /* We also throw away everything when a Guest tells us it's changed a kernel * mapping. Since kernel mappings are in every page table, it's easiest to - * throw them all away. This traps the Guest in amber for a while as - * everything faults back in, but it's rare. */ + * throw them all away. This is amazingly slow, but thankfully rare. */ void guest_pagetable_clear_all(struct lguest *lg) { release_all_pagetables(lg); /* We need the Guest kernel stack mapped again. */ pin_stack_pages(lg); } -/*:*/ -/*M:009 Since we throw away all mappings when a kernel mapping changes, our - * performance sucks for guests using highmem. In fact, a guest with - * PAGE_OFFSET 0xc0000000 (the default) and more than about 700MB of RAM is - * usually slower than a Guest with less memory. - * - * This, of course, cannot be fixed. It would take some kind of... well, I - * don't know, but the term "puissant code-fu" comes to mind. :*/ /*H:420 This is the routine which actually sets the page table entry for then * "idx"'th shadow page table. @@ -500,7 +483,7 @@ void guest_pagetable_clear_all(struct lguest *lg) static void do_set_pte(struct lguest *lg, int idx, unsigned long vaddr, pte_t gpte) { - /* Look up the matching shadow page directory entry. */ + /* Look up the matching shadow page directot entry. */ pgd_t *spgd = spgd_addr(lg, idx, vaddr); /* If the top level isn't present, there's no entry to update. */ @@ -517,8 +500,7 @@ static void do_set_pte(struct lguest *lg, int idx, *spte = gpte_to_spte(lg, gpte, pte_flags(gpte) & _PAGE_DIRTY); } else - /* Otherwise kill it and we can demand_page() it in - * later. */ + /* Otherwise we can demand_page() it in later. */ *spte = __pte(0); } } @@ -553,7 +535,7 @@ void guest_set_pte(struct lguest *lg, } /*H:400 - * (iii) Setting up a page table entry when the Guest tells us one has changed. + * (iii) Setting up a page table entry when the Guest tells us it has changed. * * Just like we did in interrupts_and_traps.c, it makes sense for us to deal * with the other side of page tables while we're here: what happens when the @@ -630,10 +612,9 @@ void free_guest_pagetable(struct lguest *lg) /*H:480 (vi) Mapping the Switcher when the Guest is about to run. * - * The Switcher and the two pages for this CPU need to be visible in the + * The Switcher and the two pages for this CPU need to be available to the * Guest (and not the pages for other CPUs). We have the appropriate PTE pages - * for each CPU already set up, we just need to hook them in now we know which - * Guest is about to run on this CPU. */ + * for each CPU already set up, we just need to hook them in. */ void map_switcher_in_guest(struct lguest *lg, struct lguest_pages *pages) { pte_t *switcher_pte_page = __get_cpu_var(switcher_pte_pages); @@ -696,18 +677,6 @@ static __init void populate_switcher_pte_page(unsigned int cpu, __pgprot(_PAGE_PRESENT|_PAGE_ACCESSED)); } -/* We've made it through the page table code. Perhaps our tired brains are - * still processing the details, or perhaps we're simply glad it's over. - * - * If nothing else, note that all this complexity in juggling shadow page - * tables in sync with the Guest's page tables is for one reason: for most - * Guests this page table dance determines how bad performance will be. This - * is why Xen uses exotic direct Guest pagetable manipulation, and why both - * Intel and AMD have implemented shadow page table support directly into - * hardware. - * - * There is just one file remaining in the Host. */ - /*H:510 At boot or module load time, init_pagetables() allocates and populates * the Switcher PTE page for each CPU. */ __init int init_pagetables(struct page **switcher_page, unsigned int pages) diff --git a/trunk/drivers/lguest/segments.c b/trunk/drivers/lguest/segments.c index 9e189cbec7dd..c2434ec99f7b 100644 --- a/trunk/drivers/lguest/segments.c +++ b/trunk/drivers/lguest/segments.c @@ -12,6 +12,8 @@ #include "lg.h" /*H:600 + * We've almost completed the Host; there's just one file to go! + * * Segments & The Global Descriptor Table * * (That title sounds like a bad Nerdcore group. Not to suggest that there are @@ -53,7 +55,7 @@ static int ignored_gdt(unsigned int num) || num == GDT_ENTRY_DOUBLEFAULT_TSS); } -/*H:630 Once the Guest gave us new GDT entries, we fix them up a little. We +/*H:610 Once the GDT has been changed, we fix the new entries up a little. We * don't care if they're invalid: the worst that can happen is a General * Protection Fault in the Switcher when it restores a Guest segment register * which tries to use that entry. Then we kill the Guest for causing such a @@ -82,33 +84,25 @@ static void fixup_gdt_table(struct lguest *lg, unsigned start, unsigned end) } } -/*H:610 Like the IDT, we never simply use the GDT the Guest gives us. We keep - * a GDT for each CPU, and copy across the Guest's entries each time we want to - * run the Guest on that CPU. - * - * This routine is called at boot or modprobe time for each CPU to set up the - * constant GDT entries: the ones which are the same no matter what Guest we're - * running. */ +/* This routine is called at boot or modprobe time for each CPU to set up the + * "constant" GDT entries for Guests running on that CPU. */ void setup_default_gdt_entries(struct lguest_ro_state *state) { struct desc_struct *gdt = state->guest_gdt; unsigned long tss = (unsigned long)&state->guest_tss; - /* The Switcher segments are full 0-4G segments, privilege level 0 */ + /* The hypervisor segments are full 0-4G segments, privilege level 0 */ gdt[GDT_ENTRY_LGUEST_CS] = FULL_EXEC_SEGMENT; gdt[GDT_ENTRY_LGUEST_DS] = FULL_SEGMENT; - /* The TSS segment refers to the TSS entry for this particular CPU. - * Forgive the magic flags: the 0x8900 means the entry is Present, it's - * privilege level 0 Available 386 TSS system segment, and the 0x67 - * means Saturn is eclipsed by Mercury in the twelfth house. */ + /* The TSS segment refers to the TSS entry for this CPU, so we cannot + * copy it from the Guest. Forgive the magic flags */ gdt[GDT_ENTRY_TSS].a = 0x00000067 | (tss << 16); gdt[GDT_ENTRY_TSS].b = 0x00008900 | (tss & 0xFF000000) | ((tss >> 16) & 0x000000FF); } -/* This routine sets up the initial Guest GDT for booting. All entries start - * as 0 (unusable). */ +/* This routine is called before the Guest is run for the first time. */ void setup_guest_gdt(struct lguest *lg) { /* Start with full 0-4G segments... */ @@ -120,8 +114,13 @@ void setup_guest_gdt(struct lguest *lg) lg->arch.gdt[GDT_ENTRY_KERNEL_DS].b |= (GUEST_PL << 13); } -/*H:650 An optimization of copy_gdt(), for just the three "thead-local storage" - * entries. */ +/* Like the IDT, we never simply use the GDT the Guest gives us. We set up the + * GDTs for each CPU, then we copy across the entries each time we want to run + * a different Guest on that CPU. */ + +/* A partial GDT load, for the three "thead-local storage" entries. Otherwise + * it's just like load_guest_gdt(). So much, in fact, it would probably be + * neater to have a single hypercall to cover both. */ void copy_gdt_tls(const struct lguest *lg, struct desc_struct *gdt) { unsigned int i; @@ -130,9 +129,7 @@ void copy_gdt_tls(const struct lguest *lg, struct desc_struct *gdt) gdt[i] = lg->arch.gdt[i]; } -/*H:640 When the Guest is run on a different CPU, or the GDT entries have - * changed, copy_gdt() is called to copy the Guest's GDT entries across to this - * CPU's GDT. */ +/* This is the full version */ void copy_gdt(const struct lguest *lg, struct desc_struct *gdt) { unsigned int i; @@ -144,8 +141,7 @@ void copy_gdt(const struct lguest *lg, struct desc_struct *gdt) gdt[i] = lg->arch.gdt[i]; } -/*H:620 This is where the Guest asks us to load a new GDT (LHCALL_LOAD_GDT). - * We copy it from the Guest and tweak the entries. */ +/* This is where the Guest asks us to load a new GDT (LHCALL_LOAD_GDT). */ void load_guest_gdt(struct lguest *lg, unsigned long table, u32 num) { /* We assume the Guest has the same number of GDT entries as the @@ -161,22 +157,16 @@ void load_guest_gdt(struct lguest *lg, unsigned long table, u32 num) lg->changed |= CHANGED_GDT; } -/* This is the fast-track version for just changing the three TLS entries. - * Remember that this happens on every context switch, so it's worth - * optimizing. But wouldn't it be neater to have a single hypercall to cover - * both cases? */ void guest_load_tls(struct lguest *lg, unsigned long gtls) { struct desc_struct *tls = &lg->arch.gdt[GDT_ENTRY_TLS_MIN]; __lgread(lg, tls, gtls, sizeof(*tls)*GDT_ENTRY_TLS_ENTRIES); fixup_gdt_table(lg, GDT_ENTRY_TLS_MIN, GDT_ENTRY_TLS_MAX+1); - /* Note that just the TLS entries have changed. */ lg->changed |= CHANGED_GDT_TLS; } -/*:*/ -/*H:660 +/* * With this, we have finished the Host. * * Five of the seven parts of our task are complete. You have made it through diff --git a/trunk/drivers/lguest/x86/core.c b/trunk/drivers/lguest/x86/core.c index 482aec2a9631..9eed12d5a395 100644 --- a/trunk/drivers/lguest/x86/core.c +++ b/trunk/drivers/lguest/x86/core.c @@ -63,7 +63,7 @@ static struct lguest_pages *lguest_pages(unsigned int cpu) static DEFINE_PER_CPU(struct lguest *, last_guest); /*S:010 - * We approach the Switcher. + * We are getting close to the Switcher. * * Remember that each CPU has two pages which are visible to the Guest when it * runs on that CPU. This has to contain the state for that Guest: we copy the @@ -134,7 +134,7 @@ static void run_guest_once(struct lguest *lg, struct lguest_pages *pages) * * The lcall also pushes the old code segment (KERNEL_CS) onto the * stack, then the address of this call. This stack layout happens to - * exactly match the stack layout created by an interrupt... */ + * exactly match the stack of an interrupt... */ asm volatile("pushf; lcall *lguest_entry" /* This is how we tell GCC that %eax ("a") and %ebx ("b") * are changed by this routine. The "=" means output. */ @@ -151,46 +151,40 @@ static void run_guest_once(struct lguest *lg, struct lguest_pages *pages) } /*:*/ -/*M:002 There are hooks in the scheduler which we can register to tell when we - * get kicked off the CPU (preempt_notifier_register()). This would allow us - * to lazily disable SYSENTER which would regain some performance, and should - * also simplify copy_in_guest_info(). Note that we'd still need to restore - * things when we exit to Launcher userspace, but that's fairly easy. - * - * The hooks were designed for KVM, but we can also put them to good use. :*/ - /*H:040 This is the i386-specific code to setup and run the Guest. Interrupts * are disabled: we own the CPU. */ void lguest_arch_run_guest(struct lguest *lg) { - /* Remember the awfully-named TS bit? If the Guest has asked to set it - * we set it now, so we can trap and pass that trap to the Guest if it - * uses the FPU. */ + /* Remember the awfully-named TS bit? If the Guest has asked + * to set it we set it now, so we can trap and pass that trap + * to the Guest if it uses the FPU. */ if (lg->ts) lguest_set_ts(); - /* SYSENTER is an optimized way of doing system calls. We can't allow - * it because it always jumps to privilege level 0. A normal Guest - * won't try it because we don't advertise it in CPUID, but a malicious - * Guest (or malicious Guest userspace program) could, so we tell the - * CPU to disable it before running the Guest. */ + /* SYSENTER is an optimized way of doing system calls. We + * can't allow it because it always jumps to privilege level 0. + * A normal Guest won't try it because we don't advertise it in + * CPUID, but a malicious Guest (or malicious Guest userspace + * program) could, so we tell the CPU to disable it before + * running the Guest. */ if (boot_cpu_has(X86_FEATURE_SEP)) wrmsr(MSR_IA32_SYSENTER_CS, 0, 0); - /* Now we actually run the Guest. It will return when something - * interesting happens, and we can examine its registers to see what it - * was doing. */ + /* Now we actually run the Guest. It will pop back out when + * something interesting happens, and we can examine its + * registers to see what it was doing. */ run_guest_once(lg, lguest_pages(raw_smp_processor_id())); - /* Note that the "regs" pointer contains two extra entries which are - * not really registers: a trap number which says what interrupt or - * trap made the switcher code come back, and an error code which some - * traps set. */ + /* The "regs" pointer contains two extra entries which are not + * really registers: a trap number which says what interrupt or + * trap made the switcher code come back, and an error code + * which some traps set. */ - /* If the Guest page faulted, then the cr2 register will tell us the - * bad virtual address. We have to grab this now, because once we - * re-enable interrupts an interrupt could fault and thus overwrite - * cr2, or we could even move off to a different CPU. */ + /* If the Guest page faulted, then the cr2 register will tell + * us the bad virtual address. We have to grab this now, + * because once we re-enable interrupts an interrupt could + * fault and thus overwrite cr2, or we could even move off to a + * different CPU. */ if (lg->regs->trapnum == 14) lg->arch.last_pagefault = read_cr2(); /* Similarly, if we took a trap because the Guest used the FPU, @@ -203,15 +197,14 @@ void lguest_arch_run_guest(struct lguest *lg) wrmsr(MSR_IA32_SYSENTER_CS, __KERNEL_CS, 0); } -/*H:130 Now we've examined the hypercall code; our Guest can make requests. - * Our Guest is usually so well behaved; it never tries to do things it isn't - * allowed to, and uses hypercalls instead. Unfortunately, Linux's paravirtual - * infrastructure isn't quite complete, because it doesn't contain replacements - * for the Intel I/O instructions. As a result, the Guest sometimes fumbles - * across one during the boot process as it probes for various things which are - * usually attached to a PC. +/*H:130 Our Guest is usually so well behaved; it never tries to do things it + * isn't allowed to. Unfortunately, Linux's paravirtual infrastructure isn't + * quite complete, because it doesn't contain replacements for the Intel I/O + * instructions. As a result, the Guest sometimes fumbles across one during + * the boot process as it probes for various things which are usually attached + * to a PC. * - * When the Guest uses one of these instructions, we get a trap (General + * When the Guest uses one of these instructions, we get trap #13 (General * Protection Fault) and come here. We see if it's one of those troublesome * instructions and skip over it. We return true if we did. */ static int emulate_insn(struct lguest *lg) @@ -282,43 +275,43 @@ static int emulate_insn(struct lguest *lg) void lguest_arch_handle_trap(struct lguest *lg) { switch (lg->regs->trapnum) { - case 13: /* We've intercepted a General Protection Fault. */ - /* Check if this was one of those annoying IN or OUT - * instructions which we need to emulate. If so, we just go - * back into the Guest after we've done it. */ + case 13: /* We've intercepted a GPF. */ + /* Check if this was one of those annoying IN or OUT + * instructions which we need to emulate. If so, we + * just go back into the Guest after we've done it. */ if (lg->regs->errcode == 0) { if (emulate_insn(lg)) return; } break; - case 14: /* We've intercepted a Page Fault. */ - /* The Guest accessed a virtual address that wasn't mapped. - * This happens a lot: we don't actually set up most of the - * page tables for the Guest at all when we start: as it runs - * it asks for more and more, and we set them up as - * required. In this case, we don't even tell the Guest that - * the fault happened. - * - * The errcode tells whether this was a read or a write, and - * whether kernel or userspace code. */ + case 14: /* We've intercepted a page fault. */ + /* The Guest accessed a virtual address that wasn't + * mapped. This happens a lot: we don't actually set + * up most of the page tables for the Guest at all when + * we start: as it runs it asks for more and more, and + * we set them up as required. In this case, we don't + * even tell the Guest that the fault happened. + * + * The errcode tells whether this was a read or a + * write, and whether kernel or userspace code. */ if (demand_page(lg, lg->arch.last_pagefault, lg->regs->errcode)) return; - /* OK, it's really not there (or not OK): the Guest needs to - * know. We write out the cr2 value so it knows where the - * fault occurred. - * - * Note that if the Guest were really messed up, this could - * happen before it's done the LHCALL_LGUEST_INIT hypercall, so - * lg->lguest_data could be NULL */ + /* OK, it's really not there (or not OK): the Guest + * needs to know. We write out the cr2 value so it + * knows where the fault occurred. + * + * Note that if the Guest were really messed up, this + * could happen before it's done the INITIALIZE + * hypercall, so lg->lguest_data will be NULL */ if (lg->lguest_data && put_user(lg->arch.last_pagefault, &lg->lguest_data->cr2)) kill_guest(lg, "Writing cr2"); break; case 7: /* We've intercepted a Device Not Available fault. */ - /* If the Guest doesn't want to know, we already restored the - * Floating Point Unit, so we just continue without telling - * it. */ + /* If the Guest doesn't want to know, we already + * restored the Floating Point Unit, so we just + * continue without telling it. */ if (!lg->ts) return; break; @@ -543,6 +536,9 @@ int lguest_arch_init_hypercalls(struct lguest *lg) return 0; } +/* Now we've examined the hypercall code; our Guest can make requests. There + * is one other way we can do things for the Guest, as we see in + * emulate_insn(). :*/ /*L:030 lguest_arch_setup_regs() * @@ -566,7 +562,7 @@ void lguest_arch_setup_regs(struct lguest *lg, unsigned long start) * is supposed to always be "1". Bit 9 (0x200) controls whether * interrupts are enabled. We always leave interrupts enabled while * running the Guest. */ - regs->eflags = X86_EFLAGS_IF | 0x2; + regs->eflags = 0x202; /* The "Extended Instruction Pointer" register says where the Guest is * running. */ @@ -574,8 +570,8 @@ void lguest_arch_setup_regs(struct lguest *lg, unsigned long start) /* %esi points to our boot information, at physical address 0, so don't * touch it. */ - /* There are a couple of GDT entries the Guest expects when first * booting. */ + setup_guest_gdt(lg); } diff --git a/trunk/drivers/lguest/x86/switcher_32.S b/trunk/drivers/lguest/x86/switcher_32.S index 0af8baaa0d4a..1010b90b11fc 100644 --- a/trunk/drivers/lguest/x86/switcher_32.S +++ b/trunk/drivers/lguest/x86/switcher_32.S @@ -6,37 +6,6 @@ * are feeling invigorated and refreshed then the next, more challenging stage * can be found in "make Guest". :*/ -/*M:012 Lguest is meant to be simple: my rule of thumb is that 1% more LOC must - * gain at least 1% more performance. Since neither LOC nor performance can be - * measured beforehand, it generally means implementing a feature then deciding - * if it's worth it. And once it's implemented, who can say no? - * - * This is why I haven't implemented this idea myself. I want to, but I - * haven't. You could, though. - * - * The main place where lguest performance sucks is Guest page faulting. When - * a Guest userspace process hits an unmapped page we switch back to the Host, - * walk the page tables, find it's not mapped, switch back to the Guest page - * fault handler, which calls a hypercall to set the page table entry, then - * finally returns to userspace. That's two round-trips. - * - * If we had a small walker in the Switcher, we could quickly check the Guest - * page table and if the page isn't mapped, immediately reflect the fault back - * into the Guest. This means the Switcher would have to know the top of the - * Guest page table and the page fault handler address. - * - * For simplicity, the Guest should only handle the case where the privilege - * level of the fault is 3 and probably only not present or write faults. It - * should also detect recursive faults, and hand the original fault to the - * Host (which is actually really easy). - * - * Two questions remain. Would the performance gain outweigh the complexity? - * And who would write the verse documenting it? :*/ - -/*M:011 Lguest64 handles NMI. This gave me NMI envy (until I looked at their - * code). It's worth doing though, since it would let us use oprofile in the - * Host when a Guest is running. :*/ - /*S:100 * Welcome to the Switcher itself! * @@ -119,7 +88,7 @@ ENTRY(switch_to_guest) // All saved and there's now five steps before us: // Stack, GDT, IDT, TSS - // Then last of all the page tables are flipped. + // And last of all the page tables are flipped. // Yet beware that our stack pointer must be // Always valid lest an NMI hits @@ -134,25 +103,25 @@ ENTRY(switch_to_guest) lgdt LGUEST_PAGES_guest_gdt_desc(%eax) // The Guest's IDT we did partially - // Copy to "struct lguest_pages" as well. + // Move to the "struct lguest_pages" as well. lidt LGUEST_PAGES_guest_idt_desc(%eax) // The TSS entry which controls traps // Must be loaded up with "ltr" now: - // The GDT entry that TSS uses - // Changes type when we load it: damn Intel! // For after we switch over our page tables - // That entry will be read-only: we'd crash. + // It (as the rest) will be writable no more. + // (The GDT entry TSS needs + // Changes type when we load it: damn Intel!) movl $(GDT_ENTRY_TSS*8), %edx ltr %dx // Look back now, before we take this last step! // The Host's TSS entry was also marked used; - // Let's clear it again for our return. + // Let's clear it again, ere we return. // The GDT descriptor of the Host // Points to the table after two "size" bytes movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx - // Clear "used" from type field (byte 5, bit 2) + // Clear the type field of "used" (byte 5, bit 2) andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx) // Once our page table's switched, the Guest is live! @@ -162,7 +131,7 @@ ENTRY(switch_to_guest) // The page table change did one tricky thing: // The Guest's register page has been mapped - // Writable under our %esp (stack) -- + // Writable onto our %esp (stack) -- // We can simply pop off all Guest regs. popl %eax popl %ebx @@ -183,15 +152,16 @@ ENTRY(switch_to_guest) addl $8, %esp // The last five stack slots hold return address - // And everything needed to switch privilege - // From Switcher's level 0 to Guest's 1, + // And everything needed to change privilege + // Into the Guest privilege level of 1, // And the stack where the Guest had last left it. // Interrupts are turned back on: we are Guest. iret -// We treat two paths to switch back to the Host -// Yet both must save Guest state and restore Host +// There are two paths where we switch to the Host // So we put the routine in a macro. +// We are on our way home, back to the Host +// Interrupted out of the Guest, we come here. #define SWITCH_TO_HOST \ /* We save the Guest state: all registers first \ * Laid out just as "struct lguest_regs" defines */ \ @@ -224,7 +194,7 @@ ENTRY(switch_to_guest) movl %esp, %eax; \ andl $(~(1 << PAGE_SHIFT - 1)), %eax; \ /* Save our trap number: the switch will obscure it \ - * (In the Host the Guest regs are not mapped here) \ + * (The Guest regs are not mapped here in the Host) \ * %ebx holds it safe for deliver_to_host */ \ movl LGUEST_PAGES_regs_trapnum(%eax), %ebx; \ /* The Host GDT, IDT and stack! \ @@ -240,9 +210,9 @@ ENTRY(switch_to_guest) /* Switch to Host's GDT, IDT. */ \ lgdt LGUEST_PAGES_host_gdt_desc(%eax); \ lidt LGUEST_PAGES_host_idt_desc(%eax); \ - /* Restore the Host's stack where its saved regs lie */ \ + /* Restore the Host's stack where it's saved regs lie */ \ movl LGUEST_PAGES_host_sp(%eax), %esp; \ - /* Last the TSS: our Host is returned */ \ + /* Last the TSS: our Host is complete */ \ movl $(GDT_ENTRY_TSS*8), %edx; \ ltr %dx; \ /* Restore now the regs saved right at the first. */ \ @@ -252,15 +222,14 @@ ENTRY(switch_to_guest) popl %ds; \ popl %es -// The first path is trod when the Guest has trapped: -// (Which trap it was has been pushed on the stack). +// Here's where we come when the Guest has just trapped: +// (Which trap we'll see has been pushed on the stack). // We need only switch back, and the Host will decode // Why we came home, and what needs to be done. return_to_host: SWITCH_TO_HOST iret -// We are lead to the second path like so: // An interrupt, with some cause external // Has ajerked us rudely from the Guest's code // Again we must return home to the Host @@ -269,7 +238,7 @@ deliver_to_host: // But now we must go home via that place // Where that interrupt was supposed to go // Had we not been ensconced, running the Guest. - // Here we see the trickness of run_guest_once(): + // Here we see the cleverness of our stack: // The Host stack is formed like an interrupt // With EIP, CS and EFLAGS layered. // Interrupt handlers end with "iret" @@ -294,7 +263,7 @@ deliver_to_host: xorw %ax, %ax orl %eax, %edx // Now the address of the handler's in %edx - // We call it now: its "iret" drops us home. + // We call it now: its "iret" takes us home. jmp *%edx // Every interrupt can come to us here diff --git a/trunk/drivers/md/dm-crypt.c b/trunk/drivers/md/dm-crypt.c index 28c6ae095c56..ac54f697c508 100644 --- a/trunk/drivers/md/dm-crypt.c +++ b/trunk/drivers/md/dm-crypt.c @@ -168,7 +168,7 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti, return -ENOMEM; } - sg_init_one(&sg, cc->key, cc->key_size); + sg_set_buf(&sg, cc->key, cc->key_size); desc.tfm = hash_tfm; desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP; err = crypto_hash_digest(&desc, &sg, cc->key_size, salt); @@ -351,10 +351,14 @@ static int crypt_convert(struct crypt_config *cc, struct scatterlist sg_in, sg_out; sg_init_table(&sg_in, 1); - sg_set_page(&sg_in, bv_in->bv_page, 1 << SECTOR_SHIFT, bv_in->bv_offset + ctx->offset_in); + sg_set_page(&sg_in, bv_in->bv_page); + sg_in.offset = bv_in->bv_offset + ctx->offset_in; + sg_in.length = 1 << SECTOR_SHIFT; sg_init_table(&sg_out, 1); - sg_set_page(&sg_out, bv_out->bv_page, 1 << SECTOR_SHIFT, bv_out->bv_offset + ctx->offset_out); + sg_set_page(&sg_out, bv_out->bv_page); + sg_out.offset = bv_out->bv_offset + ctx->offset_out; + sg_out.length = 1 << SECTOR_SHIFT; ctx->offset_in += sg_in.length; if (ctx->offset_in >= bv_in->bv_len) { diff --git a/trunk/drivers/md/raid6algos.c b/trunk/drivers/md/raid6algos.c index 77a6e4bf503d..926576156578 100644 --- a/trunk/drivers/md/raid6algos.c +++ b/trunk/drivers/md/raid6algos.c @@ -52,7 +52,7 @@ const struct raid6_calls * const raid6_algos[] = { &raid6_intx16, &raid6_intx32, #endif -#if defined(__i386__) && !defined(__arch_um__) +#if defined(__i386__) &raid6_mmxx1, &raid6_mmxx2, &raid6_sse1x1, @@ -60,7 +60,7 @@ const struct raid6_calls * const raid6_algos[] = { &raid6_sse2x1, &raid6_sse2x2, #endif -#if defined(__x86_64__) && !defined(__arch_um__) +#if defined(__x86_64__) &raid6_sse2x1, &raid6_sse2x2, &raid6_sse2x4, diff --git a/trunk/drivers/md/raid6mmx.c b/trunk/drivers/md/raid6mmx.c index d4e4a1bd70ad..6181a5a3365a 100644 --- a/trunk/drivers/md/raid6mmx.c +++ b/trunk/drivers/md/raid6mmx.c @@ -16,7 +16,7 @@ * MMX implementation of RAID-6 syndrome functions */ -#if defined(__i386__) && !defined(__arch_um__) +#if defined(__i386__) #include "raid6.h" #include "raid6x86.h" diff --git a/trunk/drivers/md/raid6sse1.c b/trunk/drivers/md/raid6sse1.c index 0666237276ff..f0a1ba8f40ba 100644 --- a/trunk/drivers/md/raid6sse1.c +++ b/trunk/drivers/md/raid6sse1.c @@ -21,7 +21,7 @@ * worthwhile as a separate implementation. */ -#if defined(__i386__) && !defined(__arch_um__) +#if defined(__i386__) #include "raid6.h" #include "raid6x86.h" diff --git a/trunk/drivers/md/raid6sse2.c b/trunk/drivers/md/raid6sse2.c index b034ad868039..0f019762a7c3 100644 --- a/trunk/drivers/md/raid6sse2.c +++ b/trunk/drivers/md/raid6sse2.c @@ -17,7 +17,7 @@ * */ -#if (defined(__i386__) || defined(__x86_64__)) && !defined(__arch_um__) +#if defined(__i386__) || defined(__x86_64__) #include "raid6.h" #include "raid6x86.h" @@ -161,7 +161,7 @@ const struct raid6_calls raid6_sse2x2 = { #endif -#if defined(__x86_64__) && !defined(__arch_um__) +#ifdef __x86_64__ /* * Unrolled-by-4 SSE2 implementation diff --git a/trunk/drivers/md/raid6x86.h b/trunk/drivers/md/raid6x86.h index 99fea7a70ca7..9111950414ff 100644 --- a/trunk/drivers/md/raid6x86.h +++ b/trunk/drivers/md/raid6x86.h @@ -19,7 +19,7 @@ #ifndef LINUX_RAID_RAID6X86_H #define LINUX_RAID_RAID6X86_H -#if (defined(__i386__) || defined(__x86_64__)) && !defined(__arch_um__) +#if defined(__i386__) || defined(__x86_64__) #ifdef __KERNEL__ /* Real code */ diff --git a/trunk/drivers/media/common/saa7146_core.c b/trunk/drivers/media/common/saa7146_core.c index cb034ead95ab..2b1f8b4be00a 100644 --- a/trunk/drivers/media/common/saa7146_core.c +++ b/trunk/drivers/media/common/saa7146_core.c @@ -118,7 +118,8 @@ static struct scatterlist* vmalloc_to_sg(unsigned char *virt, int nr_pages) if (NULL == pg) goto err; BUG_ON(PageHighMem(pg)); - sg_set_page(&sglist[i], pg, PAGE_SIZE, 0); + sg_set_page(&sglist[i], pg); + sglist[i].length = PAGE_SIZE; } return sglist; diff --git a/trunk/drivers/media/video/ivtv/ivtv-driver.h b/trunk/drivers/media/video/ivtv/ivtv-driver.h index 49ce14d14a54..3bda1df63cb6 100644 --- a/trunk/drivers/media/video/ivtv/ivtv-driver.h +++ b/trunk/drivers/media/video/ivtv/ivtv-driver.h @@ -51,7 +51,6 @@ #include #include #include -#include #include #include #include diff --git a/trunk/drivers/media/video/ivtv/ivtv-udma.c b/trunk/drivers/media/video/ivtv/ivtv-udma.c index 460db03b0ba0..912b424e5204 100644 --- a/trunk/drivers/media/video/ivtv/ivtv-udma.c +++ b/trunk/drivers/media/video/ivtv/ivtv-udma.c @@ -49,6 +49,8 @@ int ivtv_udma_fill_sg_list (struct ivtv_user_dma *dma, struct ivtv_dma_page_info unsigned int len = (i == dma_page->page_count - 1) ? dma_page->tail : PAGE_SIZE - offset; + dma->SGlist[map_offset].length = len; + dma->SGlist[map_offset].offset = offset; if (PageHighMem(dma->map[map_offset])) { void *src; @@ -61,10 +63,10 @@ int ivtv_udma_fill_sg_list (struct ivtv_user_dma *dma, struct ivtv_dma_page_info memcpy(page_address(dma->bouncemap[map_offset]) + offset, src, len); kunmap_atomic(src, KM_BOUNCE_READ); local_irq_restore(flags); - sg_set_page(&dma->SGlist[map_offset], dma->bouncemap[map_offset], len, offset); + sg_set_page(&dma->SGlist[map_offset], dma->bouncemap[map_offset]); } else { - sg_set_page(&dma->SGlist[map_offset], dma->map[map_offset], len, offset); + sg_set_page(&dma->SGlist[map_offset], dma->map[map_offset]); } offset = 0; map_offset++; diff --git a/trunk/drivers/media/video/videobuf-dma-sg.c b/trunk/drivers/media/video/videobuf-dma-sg.c index 44ee408e145f..0a18286279d3 100644 --- a/trunk/drivers/media/video/videobuf-dma-sg.c +++ b/trunk/drivers/media/video/videobuf-dma-sg.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include @@ -67,7 +66,8 @@ videobuf_vmalloc_to_sg(unsigned char *virt, int nr_pages) if (NULL == pg) goto err; BUG_ON(PageHighMem(pg)); - sg_set_page(&sglist[i], pg, PAGE_SIZE, 0); + sg_set_page(&sglist[i], pg); + sglist[i].length = PAGE_SIZE; } return sglist; @@ -94,13 +94,16 @@ videobuf_pages_to_sg(struct page **pages, int nr_pages, int offset) if (PageHighMem(pages[0])) /* DMA to highmem pages might not work */ goto highmem; - sg_set_page(&sglist[0], pages[0], PAGE_SIZE - offset, offset); + sg_set_page(&sglist[0], pages[0]); + sglist[0].offset = offset; + sglist[0].length = PAGE_SIZE - offset; for (i = 1; i < nr_pages; i++) { if (NULL == pages[i]) goto nopage; if (PageHighMem(pages[i])) goto highmem; - sg_set_page(&sglist[i], pages[i], PAGE_SIZE, 0); + sg_set_page(&sglist[i], pages[i]); + sglist[i].length = PAGE_SIZE; } return sglist; diff --git a/trunk/drivers/message/i2o/i2o_block.c b/trunk/drivers/message/i2o/i2o_block.c index 682406168de9..d602ba6d5417 100644 --- a/trunk/drivers/message/i2o/i2o_block.c +++ b/trunk/drivers/message/i2o/i2o_block.c @@ -284,7 +284,6 @@ static inline struct i2o_block_request *i2o_block_request_alloc(void) return ERR_PTR(-ENOMEM); INIT_LIST_HEAD(&ireq->queue); - sg_init_table(ireq->sg_table, I2O_MAX_PHYS_SEGMENTS); return ireq; }; diff --git a/trunk/drivers/misc/fujitsu-laptop.c b/trunk/drivers/misc/fujitsu-laptop.c index c8d62c268b11..d366a6cc1fd9 100644 --- a/trunk/drivers/misc/fujitsu-laptop.c +++ b/trunk/drivers/misc/fujitsu-laptop.c @@ -122,6 +122,9 @@ static int get_lcd_level(void) else fujitsu->brightness_changed = 0; + if (status < 0) + return status; + return fujitsu->brightness_level; } @@ -195,7 +198,7 @@ static struct platform_driver fujitsupf_driver = { /* ACPI device */ -static int acpi_fujitsu_add(struct acpi_device *device) +int acpi_fujitsu_add(struct acpi_device *device) { int result = 0; int state = 0; @@ -226,7 +229,7 @@ static int acpi_fujitsu_add(struct acpi_device *device) return result; } -static int acpi_fujitsu_remove(struct acpi_device *device, int type) +int acpi_fujitsu_remove(struct acpi_device *device, int type) { ACPI_FUNCTION_TRACE("acpi_fujitsu_remove"); diff --git a/trunk/drivers/mmc/core/mmc_ops.c b/trunk/drivers/mmc/core/mmc_ops.c index 7471d49909b2..bf4bc6adcfef 100644 --- a/trunk/drivers/mmc/core/mmc_ops.c +++ b/trunk/drivers/mmc/core/mmc_ops.c @@ -267,26 +267,15 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host, int mmc_send_csd(struct mmc_card *card, u32 *csd) { - int ret, i; - if (!mmc_host_is_spi(card->host)) return mmc_send_cxd_native(card->host, card->rca << 16, csd, MMC_SEND_CSD); - ret = mmc_send_cxd_data(card, card->host, MMC_SEND_CSD, csd, 16); - if (ret) - return ret; - - for (i = 0;i < 4;i++) - csd[i] = be32_to_cpu(csd[i]); - - return 0; + return mmc_send_cxd_data(card, card->host, MMC_SEND_CSD, csd, 16); } int mmc_send_cid(struct mmc_host *host, u32 *cid) { - int ret, i; - if (!mmc_host_is_spi(host)) { if (!host->card) return -EINVAL; @@ -294,14 +283,7 @@ int mmc_send_cid(struct mmc_host *host, u32 *cid) cid, MMC_SEND_CID); } - ret = mmc_send_cxd_data(NULL, host, MMC_SEND_CID, cid, 16); - if (ret) - return ret; - - for (i = 0;i < 4;i++) - cid[i] = be32_to_cpu(cid[i]); - - return 0; + return mmc_send_cxd_data(NULL, host, MMC_SEND_CID, cid, 16); } int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd) diff --git a/trunk/drivers/mmc/core/sd_ops.c b/trunk/drivers/mmc/core/sd_ops.c index a6dafe62b992..ee4029a24efd 100644 --- a/trunk/drivers/mmc/core/sd_ops.c +++ b/trunk/drivers/mmc/core/sd_ops.c @@ -294,8 +294,8 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr) if (data.error) return data.error; - scr[0] = be32_to_cpu(scr[0]); - scr[1] = be32_to_cpu(scr[1]); + scr[0] = ntohl(scr[0]); + scr[1] = ntohl(scr[1]); return 0; } diff --git a/trunk/drivers/mmc/host/au1xmmc.c b/trunk/drivers/mmc/host/au1xmmc.c index c3926eb3bf43..bcbb6d247bf7 100644 --- a/trunk/drivers/mmc/host/au1xmmc.c +++ b/trunk/drivers/mmc/host/au1xmmc.c @@ -40,13 +40,13 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include "au1xmmc.h" @@ -212,12 +212,12 @@ static int au1xmmc_send_command(struct au1xmmc_host *host, int wait, } if (data) { - if (data->flags & MMC_DATA_READ) { + if (flags & MMC_DATA_READ) { if (data->blocks > 1) mmccmd |= SD_CMD_CT_4; else mmccmd |= SD_CMD_CT_2; - } else if (data->flags & MMC_DATA_WRITE) { + } else if (flags & MMC_DATA_WRITE) { if (data->blocks > 1) mmccmd |= SD_CMD_CT_3; else diff --git a/trunk/drivers/mmc/host/imxmmc.c b/trunk/drivers/mmc/host/imxmmc.c index f2070a19cfa7..fc72e1fadb6a 100644 --- a/trunk/drivers/mmc/host/imxmmc.c +++ b/trunk/drivers/mmc/host/imxmmc.c @@ -262,7 +262,7 @@ static void imxmci_setup_data(struct imxmci_host *host, struct mmc_data *data) } /* Convert back to virtual address */ - host->data_ptr = (u16*)sg_virt(data->sg); + host->data_ptr = (u16*)sg_virt(sg); host->data_cnt = 0; clear_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events); diff --git a/trunk/drivers/mmc/host/mmc_spi.c b/trunk/drivers/mmc/host/mmc_spi.c index a6469218f194..12c2d807c145 100644 --- a/trunk/drivers/mmc/host/mmc_spi.c +++ b/trunk/drivers/mmc/host/mmc_spi.c @@ -1165,23 +1165,6 @@ mmc_spi_detect_irq(int irq, void *mmc) return IRQ_HANDLED; } -struct count_children { - unsigned n; - struct bus_type *bus; -}; - -static int maybe_count_child(struct device *dev, void *c) -{ - struct count_children *ccp = c; - - if (dev->bus == ccp->bus) { - if (ccp->n) - return -EBUSY; - ccp->n++; - } - return 0; -} - static int mmc_spi_probe(struct spi_device *spi) { void *ones; @@ -1205,30 +1188,33 @@ static int mmc_spi_probe(struct spi_device *spi) return status; } - /* We can use the bus safely iff nobody else will interfere with us. - * Most commands consist of one SPI message to issue a command, then - * several more to collect its response, then possibly more for data - * transfer. Clocking access to other devices during that period will - * corrupt the command execution. - * - * Until we have software primitives which guarantee non-interference, - * we'll aim for a hardware-level guarantee. - * - * REVISIT we can't guarantee another device won't be added later... + /* We can use the bus safely iff nobody else will interfere with + * us. That is, either we have the experimental exclusive access + * primitives ... or else there's nobody to share it with. */ if (spi->master->num_chipselect > 1) { - struct count_children cc; + struct device *parent = spi->dev.parent; - cc.n = 0; - cc.bus = spi->dev.bus; - status = device_for_each_child(spi->dev.parent, &cc, - maybe_count_child); + /* If there are multiple devices on this bus, we + * can't proceed. + */ + spin_lock(&parent->klist_children.k_lock); + if (parent->klist_children.k_list.next + != parent->klist_children.k_list.prev) + status = -EMLINK; + else + status = 0; + spin_unlock(&parent->klist_children.k_lock); if (status < 0) { dev_err(&spi->dev, "can't share SPI bus\n"); return status; } - dev_warn(&spi->dev, "ASSUMING SPI bus stays unshared!\n"); + /* REVISIT we can't guarantee another device won't + * be added later. It's uncommon though ... for now, + * work as if this is safe. + */ + dev_warn(&spi->dev, "ASSUMING unshared SPI bus!\n"); } /* We need a supply of ones to transmit. This is the only time diff --git a/trunk/drivers/mmc/host/mmci.c b/trunk/drivers/mmc/host/mmci.c index 95244a7e7353..d0eb0a2abf4d 100644 --- a/trunk/drivers/mmc/host/mmci.c +++ b/trunk/drivers/mmc/host/mmci.c @@ -20,11 +20,11 @@ #include #include #include -#include #include #include #include +#include #include #include @@ -167,7 +167,7 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data, * partially written to a page is properly coherent. */ if (host->sg_len && data->flags & MMC_DATA_READ) - flush_dcache_page(sg_page(host->sg_ptr)); + flush_dcache_page(host->sg_ptr->page); } if (status & MCI_DATAEND) { mmci_stop_data(host); @@ -319,7 +319,7 @@ static irqreturn_t mmci_pio_irq(int irq, void *dev_id) * page, ensure that the data cache is coherent. */ if (status & MCI_RXACTIVE) - flush_dcache_page(sg_page(host->sg_ptr)); + flush_dcache_page(host->sg_ptr->page); if (!mmci_next_sg(host)) break; diff --git a/trunk/drivers/mmc/host/mmci.h b/trunk/drivers/mmc/host/mmci.h index 0f39c490f022..000e6a919782 100644 --- a/trunk/drivers/mmc/host/mmci.h +++ b/trunk/drivers/mmc/host/mmci.h @@ -169,7 +169,7 @@ static inline char *mmci_kmap_atomic(struct mmci_host *host, unsigned long *flag struct scatterlist *sg = host->sg_ptr; local_irq_save(*flags); - return kmap_atomic(sg_page(sg), KM_BIO_SRC_IRQ) + sg->offset; + return kmap_atomic(sg->page, KM_BIO_SRC_IRQ) + sg->offset; } static inline void mmci_kunmap_atomic(struct mmci_host *host, void *buffer, unsigned long *flags) diff --git a/trunk/drivers/mmc/host/pxamci.c b/trunk/drivers/mmc/host/pxamci.c index a25ee71998a9..0601e01aa2c2 100644 --- a/trunk/drivers/mmc/host/pxamci.c +++ b/trunk/drivers/mmc/host/pxamci.c @@ -29,6 +29,7 @@ #include #include +#include #include #include diff --git a/trunk/drivers/mmc/host/sdhci.c b/trunk/drivers/mmc/host/sdhci.c index 6b80bf77a4ef..0db837e44b77 100644 --- a/trunk/drivers/mmc/host/sdhci.c +++ b/trunk/drivers/mmc/host/sdhci.c @@ -13,10 +13,11 @@ #include #include #include -#include #include +#include + #include "sdhci.h" #define DRIVER_NAME "sdhci" diff --git a/trunk/drivers/mmc/host/wbsd.c b/trunk/drivers/mmc/host/wbsd.c index 4d5f37421874..fa4c8c53cc7a 100644 --- a/trunk/drivers/mmc/host/wbsd.c +++ b/trunk/drivers/mmc/host/wbsd.c @@ -33,10 +33,10 @@ #include #include #include -#include #include #include +#include #include "wbsd.h" diff --git a/trunk/drivers/mtd/onenand/onenand_base.c b/trunk/drivers/mtd/onenand/onenand_base.c index 1b0b32011415..dd2835569092 100644 --- a/trunk/drivers/mtd/onenand/onenand_base.c +++ b/trunk/drivers/mtd/onenand/onenand_base.c @@ -359,7 +359,7 @@ static int onenand_wait(struct mtd_info *mtd, int state) */ static irqreturn_t onenand_interrupt(int irq, void *data) { - struct onenand_chip *this = data; + struct onenand_chip *this = (struct onenand_chip *) data; /* To handle shared interrupt */ if (!this->complete.done) diff --git a/trunk/drivers/net/Kconfig b/trunk/drivers/net/Kconfig index 867cb7345b5f..2538816817aa 100644 --- a/trunk/drivers/net/Kconfig +++ b/trunk/drivers/net/Kconfig @@ -166,14 +166,13 @@ config NET_SB1000 If you don't have this card, of course say N. config IP1000 - tristate "IP1000 Gigabit Ethernet support" - depends on PCI && EXPERIMENTAL - select MII - ---help--- - This driver supports IP1000 gigabit Ethernet cards. + tristate "IP1000 Gigabit Ethernet support" + depends on PCI && EXPERIMENTAL + ---help--- + This driver supports IP1000 gigabit Ethernet cards. - To compile this driver as a module, choose M here: the module - will be called ipg. This is recommended. + To compile this driver as a module, choose M here: the module + will be called ipg. This is recommended. source "drivers/net/arcnet/Kconfig" @@ -1881,30 +1880,6 @@ config FEC2 Say Y here if you want to use the second built-in 10/100 Fast ethernet controller on some Motorola ColdFire processors. -config FEC_MPC52xx - tristate "MPC52xx FEC driver" - depends on PPC_MPC52xx - select PPC_BESTCOMM - select PPC_BESTCOMM_FEC - select CRC32 - select PHYLIB - ---help--- - This option enables support for the MPC5200's on-chip - Fast Ethernet Controller - If compiled as module, it will be called 'fec_mpc52xx.ko'. - -config FEC_MPC52xx_MDIO - bool "MPC52xx FEC MDIO bus driver" - depends on FEC_MPC52xx - default y - ---help--- - The MPC5200's FEC can connect to the Ethernet either with - an external MII PHY chip or 10 Mbps 7-wire interface - (Motorola? industry standard). - If your board uses an external PHY connected to FEC, enable this. - If not sure, enable. - If compiled as module, it will be called 'fec_mpc52xx_phy.ko'. - config NE_H8300 tristate "NE2000 compatible support for H8/300" depends on H8300 @@ -2396,16 +2371,13 @@ config UGETH_TX_ON_DEMAND depends on UCC_GETH config MV643XX_ETH - tristate "Marvell Discovery (643XX) and Orion ethernet support" - depends on MV64360 || MV64X60 || (PPC_MULTIPLATFORM && PPC32) || ARCH_ORION + tristate "MV-643XX Ethernet support" + depends on MV64360 || MV64X60 || (PPC_MULTIPLATFORM && PPC32) select MII help - This driver supports the gigabit ethernet MACs in the - Marvell Discovery PPC/MIPS chipset family (MV643XX) and - in the Marvell Orion ARM SoC family. - - Some boards that use the Discovery chipset are the Momenco - Ocelot C and Jaguar ATX and Pegasos II. + This driver supports the gigabit Ethernet on the Marvell MV643XX + chipset which is used in the Momenco Ocelot C and Jaguar ATX and + Pegasos II, amongst other PPC and MIPS boards. config QLA3XXX tristate "QLogic QLA3XXX Network Driver Support" diff --git a/trunk/drivers/net/Makefile b/trunk/drivers/net/Makefile index 0e5fde4a1b2c..593262065c9b 100644 --- a/trunk/drivers/net/Makefile +++ b/trunk/drivers/net/Makefile @@ -96,10 +96,6 @@ obj-$(CONFIG_SHAPER) += shaper.o obj-$(CONFIG_HP100) += hp100.o obj-$(CONFIG_SMC9194) += smc9194.o obj-$(CONFIG_FEC) += fec.o -obj-$(CONFIG_FEC_MPC52xx) += fec_mpc52xx.o -ifeq ($(CONFIG_FEC_MPC52xx_MDIO),y) - obj-$(CONFIG_FEC_MPC52xx) += fec_mpc52xx_phy.o -endif obj-$(CONFIG_68360_ENET) += 68360enet.o obj-$(CONFIG_WD80x3) += wd.o 8390.o obj-$(CONFIG_EL2) += 3c503.o 8390.o diff --git a/trunk/drivers/net/bfin_mac.c b/trunk/drivers/net/bfin_mac.c index 084acfd6fc5f..53fe7ded5d50 100644 --- a/trunk/drivers/net/bfin_mac.c +++ b/trunk/drivers/net/bfin_mac.c @@ -371,6 +371,7 @@ static void bf537_adjust_link(struct net_device *dev) if (phydev->speed != lp->old_speed) { #if defined(CONFIG_BFIN_MAC_RMII) u32 opmode = bfin_read_EMAC_OPMODE(); + bf537mac_disable(); switch (phydev->speed) { case 10: opmode |= RMII_10; @@ -385,6 +386,7 @@ static void bf537_adjust_link(struct net_device *dev) break; } bfin_write_EMAC_OPMODE(opmode); + bf537mac_enable(); #endif new_state = 1; diff --git a/trunk/drivers/net/bonding/bond_3ad.c b/trunk/drivers/net/bonding/bond_3ad.c index cb3c6faa7888..084f0292ea6e 100644 --- a/trunk/drivers/net/bonding/bond_3ad.c +++ b/trunk/drivers/net/bonding/bond_3ad.c @@ -2076,10 +2076,8 @@ void bond_3ad_unbind_slave(struct slave *slave) * times out, and it selects an aggregator for the ports that are yet not * related to any aggregator, and selects the active aggregator for a bond. */ -void bond_3ad_state_machine_handler(struct work_struct *work) +void bond_3ad_state_machine_handler(struct bonding *bond) { - struct bonding *bond = container_of(work, struct bonding, - ad_work.work); struct port *port; struct aggregator *aggregator; @@ -2130,7 +2128,7 @@ void bond_3ad_state_machine_handler(struct work_struct *work) } re_arm: - queue_delayed_work(bond->wq, &bond->ad_work, ad_delta_in_ticks); + mod_timer(&(BOND_AD_INFO(bond).ad_timer), jiffies + ad_delta_in_ticks); out: read_unlock(&bond->lock); } diff --git a/trunk/drivers/net/bonding/bond_3ad.h b/trunk/drivers/net/bonding/bond_3ad.h index b5ee45f6d55a..f16557264944 100644 --- a/trunk/drivers/net/bonding/bond_3ad.h +++ b/trunk/drivers/net/bonding/bond_3ad.h @@ -276,7 +276,7 @@ struct ad_slave_info { void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution, int lacp_fast); int bond_3ad_bind_slave(struct slave *slave); void bond_3ad_unbind_slave(struct slave *slave); -void bond_3ad_state_machine_handler(struct work_struct *); +void bond_3ad_state_machine_handler(struct bonding *bond); void bond_3ad_adapter_speed_changed(struct slave *slave); void bond_3ad_adapter_duplex_changed(struct slave *slave); void bond_3ad_handle_link_change(struct slave *slave, char link); diff --git a/trunk/drivers/net/bonding/bond_alb.c b/trunk/drivers/net/bonding/bond_alb.c index 25b8dbf6cfd7..aea2217c56eb 100644 --- a/trunk/drivers/net/bonding/bond_alb.c +++ b/trunk/drivers/net/bonding/bond_alb.c @@ -128,12 +128,12 @@ static inline u8 _simple_hash(const u8 *hash_start, int hash_size) static inline void _lock_tx_hashtbl(struct bonding *bond) { - spin_lock_bh(&(BOND_ALB_INFO(bond).tx_hashtbl_lock)); + spin_lock(&(BOND_ALB_INFO(bond).tx_hashtbl_lock)); } static inline void _unlock_tx_hashtbl(struct bonding *bond) { - spin_unlock_bh(&(BOND_ALB_INFO(bond).tx_hashtbl_lock)); + spin_unlock(&(BOND_ALB_INFO(bond).tx_hashtbl_lock)); } /* Caller must hold tx_hashtbl lock */ @@ -305,12 +305,12 @@ static struct slave *tlb_choose_channel(struct bonding *bond, u32 hash_index, u3 /*********************** rlb specific functions ***************************/ static inline void _lock_rx_hashtbl(struct bonding *bond) { - spin_lock_bh(&(BOND_ALB_INFO(bond).rx_hashtbl_lock)); + spin_lock(&(BOND_ALB_INFO(bond).rx_hashtbl_lock)); } static inline void _unlock_rx_hashtbl(struct bonding *bond) { - spin_unlock_bh(&(BOND_ALB_INFO(bond).rx_hashtbl_lock)); + spin_unlock(&(BOND_ALB_INFO(bond).rx_hashtbl_lock)); } /* when an ARP REPLY is received from a client update its info @@ -472,13 +472,13 @@ static void rlb_clear_slave(struct bonding *bond, struct slave *slave) _unlock_rx_hashtbl(bond); - write_lock_bh(&bond->curr_slave_lock); + write_lock(&bond->curr_slave_lock); if (slave != bond->curr_active_slave) { rlb_teach_disabled_mac_on_primary(bond, slave->dev->dev_addr); } - write_unlock_bh(&bond->curr_slave_lock); + write_unlock(&bond->curr_slave_lock); } static void rlb_update_client(struct rlb_client_info *client_info) @@ -959,34 +959,19 @@ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[], int hw) return 0; } -/* - * Swap MAC addresses between two slaves. - * - * Called with RTNL held, and no other locks. - * - */ - +/* Caller must hold bond lock for write or curr_slave_lock for write*/ static void alb_swap_mac_addr(struct bonding *bond, struct slave *slave1, struct slave *slave2) { + struct slave *disabled_slave = NULL; u8 tmp_mac_addr[ETH_ALEN]; + int slaves_state_differ; + + slaves_state_differ = (SLAVE_IS_OK(slave1) != SLAVE_IS_OK(slave2)); memcpy(tmp_mac_addr, slave1->dev->dev_addr, ETH_ALEN); alb_set_slave_mac_addr(slave1, slave2->dev->dev_addr, bond->alb_info.rlb_enabled); alb_set_slave_mac_addr(slave2, tmp_mac_addr, bond->alb_info.rlb_enabled); -} - -/* - * Send learning packets after MAC address swap. - * - * Called with RTNL and bond->lock held for read. - */ -static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1, - struct slave *slave2) -{ - int slaves_state_differ = (SLAVE_IS_OK(slave1) != SLAVE_IS_OK(slave2)); - struct slave *disabled_slave = NULL; - /* fasten the change in the switch */ if (SLAVE_IS_OK(slave1)) { alb_send_learning_packets(slave1, slave1->dev->dev_addr); @@ -1059,9 +1044,7 @@ static void alb_change_hw_addr_on_detach(struct bonding *bond, struct slave *sla } if (found) { - /* locking: needs RTNL and nothing else */ alb_swap_mac_addr(bond, slave, tmp_slave); - alb_fasten_mac_swap(bond, slave, tmp_slave); } } } @@ -1392,10 +1375,8 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) return 0; } -void bond_alb_monitor(struct work_struct *work) +void bond_alb_monitor(struct bonding *bond) { - struct bonding *bond = container_of(work, struct bonding, - alb_work.work); struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); struct slave *slave; int i; @@ -1455,16 +1436,16 @@ void bond_alb_monitor(struct work_struct *work) /* handle rlb stuff */ if (bond_info->rlb_enabled) { + /* the following code changes the promiscuity of the + * the curr_active_slave. It needs to be locked with a + * write lock to protect from other code that also + * sets the promiscuity. + */ + write_lock_bh(&bond->curr_slave_lock); + if (bond_info->primary_is_promisc && (++bond_info->rlb_promisc_timeout_counter >= RLB_PROMISC_TIMEOUT)) { - /* - * dev_set_promiscuity requires rtnl and - * nothing else. - */ - read_unlock(&bond->lock); - rtnl_lock(); - bond_info->rlb_promisc_timeout_counter = 0; /* If the primary was set to promiscuous mode @@ -1473,11 +1454,10 @@ void bond_alb_monitor(struct work_struct *work) */ dev_set_promiscuity(bond->curr_active_slave->dev, -1); bond_info->primary_is_promisc = 0; - - rtnl_unlock(); - read_lock(&bond->lock); } + write_unlock_bh(&bond->curr_slave_lock); + if (bond_info->rlb_rebalance) { bond_info->rlb_rebalance = 0; rlb_rebalance(bond); @@ -1499,7 +1479,7 @@ void bond_alb_monitor(struct work_struct *work) } re_arm: - queue_delayed_work(bond->wq, &bond->alb_work, alb_delta_in_ticks); + mod_timer(&(bond_info->alb_timer), jiffies + alb_delta_in_ticks); out: read_unlock(&bond->lock); } @@ -1520,11 +1500,11 @@ int bond_alb_init_slave(struct bonding *bond, struct slave *slave) /* caller must hold the bond lock for write since the mac addresses * are compared and may be swapped. */ - read_lock(&bond->lock); + write_lock_bh(&bond->lock); res = alb_handle_addr_collision_on_attach(bond, slave); - read_unlock(&bond->lock); + write_unlock_bh(&bond->lock); if (res) { return res; @@ -1589,21 +1569,13 @@ void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char * Set the bond->curr_active_slave to @new_slave and handle * mac address swapping and promiscuity changes as needed. * - * If new_slave is NULL, caller must hold curr_slave_lock or - * bond->lock for write. - * - * If new_slave is not NULL, caller must hold RTNL, bond->lock for - * read and curr_slave_lock for write. Processing here may sleep, so - * no other locks may be held. + * Caller must hold bond curr_slave_lock for write (or bond lock for write) */ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave) { struct slave *swap_slave; int i; - if (new_slave) - ASSERT_RTNL(); - if (bond->curr_active_slave == new_slave) { return; } @@ -1636,19 +1608,6 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave } } - /* - * Arrange for swap_slave and new_slave to temporarily be - * ignored so we can mess with their MAC addresses without - * fear of interference from transmit activity. - */ - if (swap_slave) { - tlb_clear_slave(bond, swap_slave, 1); - } - tlb_clear_slave(bond, new_slave, 1); - - write_unlock_bh(&bond->curr_slave_lock); - read_unlock(&bond->lock); - /* curr_active_slave must be set before calling alb_swap_mac_addr */ if (swap_slave) { /* swap mac address */ @@ -1657,23 +1616,11 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave /* set the new_slave to the bond mac address */ alb_set_slave_mac_addr(new_slave, bond->dev->dev_addr, bond->alb_info.rlb_enabled); - } - - read_lock(&bond->lock); - - if (swap_slave) { - alb_fasten_mac_swap(bond, swap_slave, new_slave); - } else { /* fasten bond mac on new current slave */ alb_send_learning_packets(new_slave, bond->dev->dev_addr); } - - write_lock_bh(&bond->curr_slave_lock); } -/* - * Called with RTNL - */ int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr) { struct bonding *bond = bond_dev->priv; @@ -1710,12 +1657,8 @@ int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr) } } - write_unlock_bh(&bond->curr_slave_lock); - read_unlock(&bond->lock); - if (swap_slave) { alb_swap_mac_addr(bond, swap_slave, bond->curr_active_slave); - alb_fasten_mac_swap(bond, swap_slave, bond->curr_active_slave); } else { alb_set_slave_mac_addr(bond->curr_active_slave, bond_dev->dev_addr, bond->alb_info.rlb_enabled); @@ -1727,9 +1670,6 @@ int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr) } } - read_lock(&bond->lock); - write_lock_bh(&bond->curr_slave_lock); - return 0; } diff --git a/trunk/drivers/net/bonding/bond_alb.h b/trunk/drivers/net/bonding/bond_alb.h index 50968f8196cf..fd8726429890 100644 --- a/trunk/drivers/net/bonding/bond_alb.h +++ b/trunk/drivers/net/bonding/bond_alb.h @@ -125,7 +125,7 @@ void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave); void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link); void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave); int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev); -void bond_alb_monitor(struct work_struct *); +void bond_alb_monitor(struct bonding *bond); int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr); void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id); #endif /* __BOND_ALB_H__ */ diff --git a/trunk/drivers/net/bonding/bond_main.c b/trunk/drivers/net/bonding/bond_main.c index 6937ef0e7275..6f85cc31f8a2 100644 --- a/trunk/drivers/net/bonding/bond_main.c +++ b/trunk/drivers/net/bonding/bond_main.c @@ -188,7 +188,6 @@ struct bond_parm_tbl arp_validate_tbl[] = { /*-------------------------- Forward declarations ---------------------------*/ static void bond_send_gratuitous_arp(struct bonding *bond); -static void bond_deinit(struct net_device *bond_dev); /*---------------------------- General routines -----------------------------*/ @@ -1591,7 +1590,15 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) case BOND_MODE_TLB: case BOND_MODE_ALB: new_slave->state = BOND_STATE_ACTIVE; - bond_set_slave_inactive_flags(new_slave); + if ((!bond->curr_active_slave) && + (new_slave->link != BOND_LINK_DOWN)) { + /* first slave or no active slave yet, and this link + * is OK, so make this interface the active one + */ + bond_change_active_slave(bond, new_slave); + } else { + bond_set_slave_inactive_flags(new_slave); + } break; default: dprintk("This slave is always active in trunk mode\n"); @@ -1747,23 +1754,9 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) bond_alb_deinit_slave(bond, slave); } - if (oldcurrent == slave) { - /* - * Note that we hold RTNL over this sequence, so there - * is no concern that another slave add/remove event - * will interfere. - */ - write_unlock_bh(&bond->lock); - read_lock(&bond->lock); - write_lock_bh(&bond->curr_slave_lock); - + if (oldcurrent == slave) bond_select_active_slave(bond); - write_unlock_bh(&bond->curr_slave_lock); - read_unlock(&bond->lock); - write_lock_bh(&bond->lock); - } - if (bond->slave_cnt == 0) { bond_set_carrier(bond); @@ -1847,9 +1840,9 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) */ void bond_destroy(struct bonding *bond) { - unregister_netdevice(bond->dev); bond_deinit(bond->dev); bond_destroy_sysfs_entry(bond); + unregister_netdevice(bond->dev); } /* @@ -2019,19 +2012,16 @@ static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_devi return -EINVAL; } - read_lock(&bond->lock); + write_lock_bh(&bond->lock); - read_lock(&bond->curr_slave_lock); old_active = bond->curr_active_slave; - read_unlock(&bond->curr_slave_lock); - new_active = bond_get_slave_by_dev(bond, slave_dev); /* * Changing to the current active: do nothing; return success. */ if (new_active && (new_active == old_active)) { - read_unlock(&bond->lock); + write_unlock_bh(&bond->lock); return 0; } @@ -2039,14 +2029,12 @@ static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_devi (old_active) && (new_active->link == BOND_LINK_UP) && IS_UP(new_active->dev)) { - write_lock_bh(&bond->curr_slave_lock); bond_change_active_slave(bond, new_active); - write_unlock_bh(&bond->curr_slave_lock); } else { res = -EINVAL; } - read_unlock(&bond->lock); + write_unlock_bh(&bond->lock); return res; } @@ -2058,9 +2046,9 @@ static int bond_info_query(struct net_device *bond_dev, struct ifbond *info) info->bond_mode = bond->params.mode; info->miimon = bond->params.miimon; - read_lock(&bond->lock); + read_lock_bh(&bond->lock); info->num_slaves = bond->slave_cnt; - read_unlock(&bond->lock); + read_unlock_bh(&bond->lock); return 0; } @@ -2075,7 +2063,7 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in return -ENODEV; } - read_lock(&bond->lock); + read_lock_bh(&bond->lock); bond_for_each_slave(bond, slave, i) { if (i == (int)info->slave_id) { @@ -2084,7 +2072,7 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in } } - read_unlock(&bond->lock); + read_unlock_bh(&bond->lock); if (found) { strcpy(info->slave_name, slave->dev->name); @@ -2100,25 +2088,26 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in /*-------------------------------- Monitoring -------------------------------*/ -/* - * if !have_locks, return nonzero if a failover is necessary. if - * have_locks, do whatever failover activities are needed. - * - * This is to separate the inspection and failover steps for locking - * purposes; failover requires rtnl, but acquiring it for every - * inspection is undesirable, so a wrapper first does inspection, and - * the acquires the necessary locks and calls again to perform - * failover if needed. Since all locks are dropped, a complete - * restart is needed between calls. - */ -static int __bond_mii_monitor(struct bonding *bond, int have_locks) +/* this function is called regularly to monitor each slave's link. */ +void bond_mii_monitor(struct net_device *bond_dev) { + struct bonding *bond = bond_dev->priv; struct slave *slave, *oldcurrent; int do_failover = 0; + int delta_in_ticks; int i; - if (bond->slave_cnt == 0) + read_lock(&bond->lock); + + delta_in_ticks = (bond->params.miimon * HZ) / 1000; + + if (bond->kill_timers) { goto out; + } + + if (bond->slave_cnt == 0) { + goto re_arm; + } /* we will try to read the link status of each of our slaves, and * set their IFF_RUNNING flag appropriately. For each slave not @@ -2152,11 +2141,7 @@ static int __bond_mii_monitor(struct bonding *bond, int have_locks) switch (slave->link) { case BOND_LINK_UP: /* the link was up */ if (link_state == BMSR_LSTATUS) { - if (!oldcurrent) { - if (!have_locks) - return 1; - do_failover = 1; - } + /* link stays up, nothing more to do */ break; } else { /* link going down */ slave->link = BOND_LINK_FAIL; @@ -2171,7 +2156,7 @@ static int __bond_mii_monitor(struct bonding *bond, int have_locks) ": %s: link status down for %s " "interface %s, disabling it in " "%d ms.\n", - bond->dev->name, + bond_dev->name, IS_UP(slave_dev) ? ((bond->params.mode == BOND_MODE_ACTIVEBACKUP) ? ((slave == oldcurrent) @@ -2189,9 +2174,6 @@ static int __bond_mii_monitor(struct bonding *bond, int have_locks) if (link_state != BMSR_LSTATUS) { /* link stays down */ if (slave->delay <= 0) { - if (!have_locks) - return 1; - /* link down for too long time */ slave->link = BOND_LINK_DOWN; @@ -2207,7 +2189,7 @@ static int __bond_mii_monitor(struct bonding *bond, int have_locks) ": %s: link status definitely " "down for interface %s, " "disabling it\n", - bond->dev->name, + bond_dev->name, slave_dev->name); /* notify ad that the link status has changed */ @@ -2233,7 +2215,7 @@ static int __bond_mii_monitor(struct bonding *bond, int have_locks) printk(KERN_INFO DRV_NAME ": %s: link status up again after %d " "ms for interface %s.\n", - bond->dev->name, + bond_dev->name, (bond->params.downdelay - slave->delay) * bond->params.miimon, slave_dev->name); } @@ -2253,7 +2235,7 @@ static int __bond_mii_monitor(struct bonding *bond, int have_locks) ": %s: link status up for " "interface %s, enabling it " "in %d ms.\n", - bond->dev->name, + bond_dev->name, slave_dev->name, bond->params.updelay * bond->params.miimon); } @@ -2269,15 +2251,12 @@ static int __bond_mii_monitor(struct bonding *bond, int have_locks) printk(KERN_INFO DRV_NAME ": %s: link status down again after %d " "ms for interface %s.\n", - bond->dev->name, + bond_dev->name, (bond->params.updelay - slave->delay) * bond->params.miimon, slave_dev->name); } else { /* link stays up */ if (slave->delay == 0) { - if (!have_locks) - return 1; - /* now the link has been up for long time enough */ slave->link = BOND_LINK_UP; slave->jiffies = jiffies; @@ -2296,7 +2275,7 @@ static int __bond_mii_monitor(struct bonding *bond, int have_locks) printk(KERN_INFO DRV_NAME ": %s: link status definitely " "up for interface %s.\n", - bond->dev->name, + bond_dev->name, slave_dev->name); /* notify ad that the link status has changed */ @@ -2322,7 +2301,7 @@ static int __bond_mii_monitor(struct bonding *bond, int have_locks) /* Should not happen */ printk(KERN_ERR DRV_NAME ": %s: Error: %s Illegal value (link=%d)\n", - bond->dev->name, + bond_dev->name, slave->dev->name, slave->link); goto out; @@ -2343,53 +2322,23 @@ static int __bond_mii_monitor(struct bonding *bond, int have_locks) } /* end of for */ if (do_failover) { - ASSERT_RTNL(); - - write_lock_bh(&bond->curr_slave_lock); + write_lock(&bond->curr_slave_lock); bond_select_active_slave(bond); - write_unlock_bh(&bond->curr_slave_lock); - + write_unlock(&bond->curr_slave_lock); } else bond_set_carrier(bond); -out: - return 0; -} - -/* - * bond_mii_monitor - * - * Really a wrapper that splits the mii monitor into two phases: an - * inspection, then (if inspection indicates something needs to be - * done) an acquisition of appropriate locks followed by another pass - * to implement whatever link state changes are indicated. - */ -void bond_mii_monitor(struct work_struct *work) -{ - struct bonding *bond = container_of(work, struct bonding, - mii_work.work); - unsigned long delay; - - read_lock(&bond->lock); - if (bond->kill_timers) { - read_unlock(&bond->lock); - return; - } - if (__bond_mii_monitor(bond, 0)) { - read_unlock(&bond->lock); - rtnl_lock(); - read_lock(&bond->lock); - __bond_mii_monitor(bond, 1); - rtnl_unlock(); +re_arm: + if (bond->params.miimon) { + mod_timer(&bond->mii_timer, jiffies + delta_in_ticks); } - - delay = ((bond->params.miimon * HZ) / 1000) ? : 1; +out: read_unlock(&bond->lock); - queue_delayed_work(bond->wq, &bond->mii_work, delay); } + static __be32 bond_glean_dev_ip(struct net_device *dev) { struct in_device *idev; @@ -2687,10 +2636,9 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack * arp is transmitted to generate traffic. see activebackup_arp_monitor for * arp monitoring in active backup mode. */ -void bond_loadbalance_arp_mon(struct work_struct *work) +void bond_loadbalance_arp_mon(struct net_device *bond_dev) { - struct bonding *bond = container_of(work, struct bonding, - arp_work.work); + struct bonding *bond = bond_dev->priv; struct slave *slave, *oldcurrent; int do_failover = 0; int delta_in_ticks; @@ -2737,13 +2685,13 @@ void bond_loadbalance_arp_mon(struct work_struct *work) printk(KERN_INFO DRV_NAME ": %s: link status definitely " "up for interface %s, ", - bond->dev->name, + bond_dev->name, slave->dev->name); do_failover = 1; } else { printk(KERN_INFO DRV_NAME ": %s: interface %s is now up\n", - bond->dev->name, + bond_dev->name, slave->dev->name); } } @@ -2767,7 +2715,7 @@ void bond_loadbalance_arp_mon(struct work_struct *work) printk(KERN_INFO DRV_NAME ": %s: interface %s is now down.\n", - bond->dev->name, + bond_dev->name, slave->dev->name); if (slave == oldcurrent) { @@ -2789,19 +2737,17 @@ void bond_loadbalance_arp_mon(struct work_struct *work) } if (do_failover) { - rtnl_lock(); - write_lock_bh(&bond->curr_slave_lock); + write_lock(&bond->curr_slave_lock); bond_select_active_slave(bond); - write_unlock_bh(&bond->curr_slave_lock); - rtnl_unlock(); - + write_unlock(&bond->curr_slave_lock); } re_arm: - if (bond->params.arp_interval) - queue_delayed_work(bond->wq, &bond->arp_work, delta_in_ticks); + if (bond->params.arp_interval) { + mod_timer(&bond->arp_timer, jiffies + delta_in_ticks); + } out: read_unlock(&bond->lock); } @@ -2821,10 +2767,9 @@ void bond_loadbalance_arp_mon(struct work_struct *work) * may have received. * see loadbalance_arp_monitor for arp monitoring in load balancing mode */ -void bond_activebackup_arp_mon(struct work_struct *work) +void bond_activebackup_arp_mon(struct net_device *bond_dev) { - struct bonding *bond = container_of(work, struct bonding, - arp_work.work); + struct bonding *bond = bond_dev->priv; struct slave *slave; int delta_in_ticks; int i; @@ -2853,9 +2798,7 @@ void bond_activebackup_arp_mon(struct work_struct *work) slave->link = BOND_LINK_UP; - rtnl_lock(); - - write_lock_bh(&bond->curr_slave_lock); + write_lock(&bond->curr_slave_lock); if ((!bond->curr_active_slave) && ((jiffies - slave->dev->trans_start) <= delta_in_ticks)) { @@ -2878,19 +2821,18 @@ void bond_activebackup_arp_mon(struct work_struct *work) printk(KERN_INFO DRV_NAME ": %s: %s is up and now the " "active interface\n", - bond->dev->name, + bond_dev->name, slave->dev->name); netif_carrier_on(bond->dev); } else { printk(KERN_INFO DRV_NAME ": %s: backup interface %s is " "now up\n", - bond->dev->name, + bond_dev->name, slave->dev->name); } - write_unlock_bh(&bond->curr_slave_lock); - rtnl_unlock(); + write_unlock(&bond->curr_slave_lock); } } else { read_lock(&bond->curr_slave_lock); @@ -2922,7 +2864,7 @@ void bond_activebackup_arp_mon(struct work_struct *work) printk(KERN_INFO DRV_NAME ": %s: backup interface %s is now down\n", - bond->dev->name, + bond_dev->name, slave->dev->name); } else { read_unlock(&bond->curr_slave_lock); @@ -2957,18 +2899,15 @@ void bond_activebackup_arp_mon(struct work_struct *work) printk(KERN_INFO DRV_NAME ": %s: link status down for active interface " "%s, disabling it\n", - bond->dev->name, + bond_dev->name, slave->dev->name); - rtnl_lock(); - write_lock_bh(&bond->curr_slave_lock); + write_lock(&bond->curr_slave_lock); bond_select_active_slave(bond); slave = bond->curr_active_slave; - write_unlock_bh(&bond->curr_slave_lock); - - rtnl_unlock(); + write_unlock(&bond->curr_slave_lock); bond->current_arp_slave = slave; @@ -2982,17 +2921,14 @@ void bond_activebackup_arp_mon(struct work_struct *work) printk(KERN_INFO DRV_NAME ": %s: changing from interface %s to primary " "interface %s\n", - bond->dev->name, + bond_dev->name, slave->dev->name, bond->primary_slave->dev->name); /* primary is up so switch to it */ - rtnl_lock(); - write_lock_bh(&bond->curr_slave_lock); + write_lock(&bond->curr_slave_lock); bond_change_active_slave(bond, bond->primary_slave); - write_unlock_bh(&bond->curr_slave_lock); - - rtnl_unlock(); + write_unlock(&bond->curr_slave_lock); slave = bond->primary_slave; slave->jiffies = jiffies; @@ -3049,7 +2985,7 @@ void bond_activebackup_arp_mon(struct work_struct *work) printk(KERN_INFO DRV_NAME ": %s: backup interface %s is " "now down.\n", - bond->dev->name, + bond_dev->name, slave->dev->name); } } @@ -3058,7 +2994,7 @@ void bond_activebackup_arp_mon(struct work_struct *work) re_arm: if (bond->params.arp_interval) { - queue_delayed_work(bond->wq, &bond->arp_work, delta_in_ticks); + mod_timer(&bond->arp_timer, jiffies + delta_in_ticks); } out: read_unlock(&bond->lock); @@ -3079,7 +3015,7 @@ static void *bond_info_seq_start(struct seq_file *seq, loff_t *pos) /* make sure the bond won't be taken away */ read_lock(&dev_base_lock); - read_lock(&bond->lock); + read_lock_bh(&bond->lock); if (*pos == 0) { return SEQ_START_TOKEN; @@ -3113,7 +3049,7 @@ static void bond_info_seq_stop(struct seq_file *seq, void *v) { struct bonding *bond = seq->private; - read_unlock(&bond->lock); + read_unlock_bh(&bond->lock); read_unlock(&dev_base_lock); } @@ -3646,11 +3582,15 @@ static int bond_xmit_hash_policy_l2(struct sk_buff *skb, static int bond_open(struct net_device *bond_dev) { struct bonding *bond = bond_dev->priv; + struct timer_list *mii_timer = &bond->mii_timer; + struct timer_list *arp_timer = &bond->arp_timer; bond->kill_timers = 0; if ((bond->params.mode == BOND_MODE_TLB) || (bond->params.mode == BOND_MODE_ALB)) { + struct timer_list *alb_timer = &(BOND_ALB_INFO(bond).alb_timer); + /* bond_alb_initialize must be called before the timer * is started. */ @@ -3659,31 +3599,44 @@ static int bond_open(struct net_device *bond_dev) return -1; } - INIT_DELAYED_WORK(&bond->alb_work, bond_alb_monitor); - queue_delayed_work(bond->wq, &bond->alb_work, 0); + init_timer(alb_timer); + alb_timer->expires = jiffies + 1; + alb_timer->data = (unsigned long)bond; + alb_timer->function = (void *)&bond_alb_monitor; + add_timer(alb_timer); } if (bond->params.miimon) { /* link check interval, in milliseconds. */ - INIT_DELAYED_WORK(&bond->mii_work, bond_mii_monitor); - queue_delayed_work(bond->wq, &bond->mii_work, 0); + init_timer(mii_timer); + mii_timer->expires = jiffies + 1; + mii_timer->data = (unsigned long)bond_dev; + mii_timer->function = (void *)&bond_mii_monitor; + add_timer(mii_timer); } if (bond->params.arp_interval) { /* arp interval, in milliseconds. */ - if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) - INIT_DELAYED_WORK(&bond->arp_work, - bond_activebackup_arp_mon); - else - INIT_DELAYED_WORK(&bond->arp_work, - bond_loadbalance_arp_mon); - - queue_delayed_work(bond->wq, &bond->arp_work, 0); + init_timer(arp_timer); + arp_timer->expires = jiffies + 1; + arp_timer->data = (unsigned long)bond_dev; + if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) { + arp_timer->function = (void *)&bond_activebackup_arp_mon; + } else { + arp_timer->function = (void *)&bond_loadbalance_arp_mon; + } if (bond->params.arp_validate) bond_register_arp(bond); + + add_timer(arp_timer); } if (bond->params.mode == BOND_MODE_8023AD) { - INIT_DELAYED_WORK(&bond->ad_work, bond_3ad_state_machine_handler); - queue_delayed_work(bond->wq, &bond->ad_work, 0); + struct timer_list *ad_timer = &(BOND_AD_INFO(bond).ad_timer); + init_timer(ad_timer); + ad_timer->expires = jiffies + 1; + ad_timer->data = (unsigned long)bond; + ad_timer->function = (void *)&bond_3ad_state_machine_handler; + add_timer(ad_timer); + /* register to receive LACPDUs */ bond_register_lacpdu(bond); } @@ -3711,21 +3664,25 @@ static int bond_close(struct net_device *bond_dev) write_unlock_bh(&bond->lock); + /* del_timer_sync must run without holding the bond->lock + * because a running timer might be trying to hold it too + */ + if (bond->params.miimon) { /* link check interval, in milliseconds. */ - cancel_delayed_work(&bond->mii_work); + del_timer_sync(&bond->mii_timer); } if (bond->params.arp_interval) { /* arp interval, in milliseconds. */ - cancel_delayed_work(&bond->arp_work); + del_timer_sync(&bond->arp_timer); } switch (bond->params.mode) { case BOND_MODE_8023AD: - cancel_delayed_work(&bond->ad_work); + del_timer_sync(&(BOND_AD_INFO(bond).ad_timer)); break; case BOND_MODE_TLB: case BOND_MODE_ALB: - cancel_delayed_work(&bond->alb_work); + del_timer_sync(&(BOND_ALB_INFO(bond).alb_timer)); break; default: break; @@ -3822,13 +3779,13 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd if (mii->reg_num == 1) { struct bonding *bond = bond_dev->priv; mii->val_out = 0; - read_lock(&bond->lock); + read_lock_bh(&bond->lock); read_lock(&bond->curr_slave_lock); if (netif_carrier_ok(bond->dev)) { mii->val_out = BMSR_LSTATUS; } read_unlock(&bond->curr_slave_lock); - read_unlock(&bond->lock); + read_unlock_bh(&bond->lock); } return 0; @@ -4120,7 +4077,8 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev { struct bonding *bond = bond_dev->priv; struct slave *slave, *start_at; - int i, slave_no, res = 1; + int i; + int res = 1; read_lock(&bond->lock); @@ -4128,29 +4086,29 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev goto out; } - /* - * Concurrent TX may collide on rr_tx_counter; we accept that - * as being rare enough not to justify using an atomic op here - */ - slave_no = bond->rr_tx_counter++ % bond->slave_cnt; + read_lock(&bond->curr_slave_lock); + slave = start_at = bond->curr_active_slave; + read_unlock(&bond->curr_slave_lock); - bond_for_each_slave(bond, slave, i) { - slave_no--; - if (slave_no < 0) { - break; - } + if (!slave) { + goto out; } - start_at = slave; bond_for_each_slave_from(bond, slave, i, start_at) { if (IS_UP(slave->dev) && (slave->link == BOND_LINK_UP) && (slave->state == BOND_STATE_ACTIVE)) { res = bond_dev_queue_xmit(bond, skb, slave->dev); + + write_lock(&bond->curr_slave_lock); + bond->curr_active_slave = slave->next; + write_unlock(&bond->curr_slave_lock); + break; } } + out: if (res) { /* no suitable interface, frame not sent */ @@ -4382,10 +4340,6 @@ static int bond_init(struct net_device *bond_dev, struct bond_params *params) bond->params = *params; /* copy params struct */ - bond->wq = create_singlethread_workqueue(bond_dev->name); - if (!bond->wq) - return -ENOMEM; - /* Initialize pointers */ bond->first_slave = NULL; bond->curr_active_slave = NULL; @@ -4450,7 +4404,7 @@ static int bond_init(struct net_device *bond_dev, struct bond_params *params) /* De-initialize device specific data. * Caller must hold rtnl_lock. */ -static void bond_deinit(struct net_device *bond_dev) +void bond_deinit(struct net_device *bond_dev) { struct bonding *bond = bond_dev->priv; @@ -4474,8 +4428,8 @@ static void bond_free_all(void) bond_mc_list_destroy(bond); /* Release the bonded slaves */ bond_release_all(bond_dev); - unregister_netdevice(bond_dev); bond_deinit(bond_dev); + unregister_netdevice(bond_dev); } #ifdef CONFIG_PROC_FS @@ -4872,32 +4826,10 @@ int bond_create(char *name, struct bond_params *params, struct bonding **newbond return res; } -static void bond_work_cancel_all(struct bonding *bond) -{ - write_lock_bh(&bond->lock); - bond->kill_timers = 1; - write_unlock_bh(&bond->lock); - - if (bond->params.miimon && delayed_work_pending(&bond->mii_work)) - cancel_delayed_work(&bond->mii_work); - - if (bond->params.arp_interval && delayed_work_pending(&bond->arp_work)) - cancel_delayed_work(&bond->arp_work); - - if (bond->params.mode == BOND_MODE_ALB && - delayed_work_pending(&bond->alb_work)) - cancel_delayed_work(&bond->alb_work); - - if (bond->params.mode == BOND_MODE_8023AD && - delayed_work_pending(&bond->ad_work)) - cancel_delayed_work(&bond->ad_work); -} - static int __init bonding_init(void) { int i; int res; - struct bonding *bond, *nxt; printk(KERN_INFO "%s", version); @@ -4924,11 +4856,6 @@ static int __init bonding_init(void) goto out; err: - list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) { - bond_work_cancel_all(bond); - destroy_workqueue(bond->wq); - } - rtnl_lock(); bond_free_all(); bond_destroy_sysfs(); diff --git a/trunk/drivers/net/bonding/bond_sysfs.c b/trunk/drivers/net/bonding/bond_sysfs.c index 7a06ade85b02..855dc10ffa1b 100644 --- a/trunk/drivers/net/bonding/bond_sysfs.c +++ b/trunk/drivers/net/bonding/bond_sysfs.c @@ -229,7 +229,7 @@ static ssize_t bonding_show_slaves(struct device *d, int i, res = 0; struct bonding *bond = to_bond(d); - read_lock(&bond->lock); + read_lock_bh(&bond->lock); bond_for_each_slave(bond, slave, i) { if (res > (PAGE_SIZE - IFNAMSIZ)) { /* not enough space for another interface name */ @@ -240,7 +240,7 @@ static ssize_t bonding_show_slaves(struct device *d, } res += sprintf(buf + res, "%s ", slave->dev->name); } - read_unlock(&bond->lock); + read_unlock_bh(&bond->lock); res += sprintf(buf + res, "\n"); res++; return res; @@ -282,18 +282,18 @@ static ssize_t bonding_store_slaves(struct device *d, /* Got a slave name in ifname. Is it already in the list? */ found = 0; - read_lock(&bond->lock); + read_lock_bh(&bond->lock); bond_for_each_slave(bond, slave, i) if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) { printk(KERN_ERR DRV_NAME ": %s: Interface %s is already enslaved!\n", bond->dev->name, ifname); ret = -EPERM; - read_unlock(&bond->lock); + read_unlock_bh(&bond->lock); goto out; } - read_unlock(&bond->lock); + read_unlock_bh(&bond->lock); printk(KERN_INFO DRV_NAME ": %s: Adding slave %s.\n", bond->dev->name, ifname); dev = dev_get_by_name(&init_net, ifname); @@ -662,9 +662,12 @@ static ssize_t bonding_store_arp_interval(struct device *d, "%s Disabling MII monitoring.\n", bond->dev->name, bond->dev->name); bond->params.miimon = 0; - if (delayed_work_pending(&bond->mii_work)) { - cancel_delayed_work(&bond->mii_work); - flush_workqueue(bond->wq); + /* Kill MII timer, else it brings bond's link down */ + if (bond->arp_timer.function) { + printk(KERN_INFO DRV_NAME + ": %s: Kill MII timer, else it brings bond's link down...\n", + bond->dev->name); + del_timer_sync(&bond->mii_timer); } } if (!bond->params.arp_targets[0]) { @@ -679,15 +682,25 @@ static ssize_t bonding_store_arp_interval(struct device *d, * timer will get fired off when the open function * is called. */ - if (!delayed_work_pending(&bond->arp_work)) { - if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) - INIT_DELAYED_WORK(&bond->arp_work, - bond_activebackup_arp_mon); - else - INIT_DELAYED_WORK(&bond->arp_work, - bond_loadbalance_arp_mon); - - queue_delayed_work(bond->wq, &bond->arp_work, 0); + if (bond->arp_timer.function) { + /* The timer's already set up, so fire it off */ + mod_timer(&bond->arp_timer, jiffies + 1); + } else { + /* Set up the timer. */ + init_timer(&bond->arp_timer); + bond->arp_timer.expires = jiffies + 1; + bond->arp_timer.data = + (unsigned long) bond->dev; + if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) { + bond->arp_timer.function = + (void *) + &bond_activebackup_arp_mon; + } else { + bond->arp_timer.function = + (void *) + &bond_loadbalance_arp_mon; + } + add_timer(&bond->arp_timer); } } @@ -1043,9 +1056,12 @@ static ssize_t bonding_store_miimon(struct device *d, bond->params.arp_validate = BOND_ARP_VALIDATE_NONE; } - if (delayed_work_pending(&bond->arp_work)) { - cancel_delayed_work(&bond->arp_work); - flush_workqueue(bond->wq); + /* Kill ARP timer, else it brings bond's link down */ + if (bond->mii_timer.function) { + printk(KERN_INFO DRV_NAME + ": %s: Kill ARP timer, else it brings bond's link down...\n", + bond->dev->name); + del_timer_sync(&bond->arp_timer); } } @@ -1055,11 +1071,18 @@ static ssize_t bonding_store_miimon(struct device *d, * timer will get fired off when the open function * is called. */ - if (!delayed_work_pending(&bond->mii_work)) { - INIT_DELAYED_WORK(&bond->mii_work, - bond_mii_monitor); - queue_delayed_work(bond->wq, - &bond->mii_work, 0); + if (bond->mii_timer.function) { + /* The timer's already set up, so fire it off */ + mod_timer(&bond->mii_timer, jiffies + 1); + } else { + /* Set up the timer. */ + init_timer(&bond->mii_timer); + bond->mii_timer.expires = jiffies + 1; + bond->mii_timer.data = + (unsigned long) bond->dev; + bond->mii_timer.function = + (void *) &bond_mii_monitor; + add_timer(&bond->mii_timer); } } } @@ -1133,9 +1156,6 @@ static ssize_t bonding_store_primary(struct device *d, } out: write_unlock_bh(&bond->lock); - - rtnl_unlock(); - return count; } static DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, bonding_show_primary, bonding_store_primary); @@ -1193,7 +1213,6 @@ static ssize_t bonding_show_active_slave(struct device *d, struct bonding *bond = to_bond(d); int count; - rtnl_lock(); read_lock(&bond->curr_slave_lock); curr = bond->curr_active_slave; @@ -1273,8 +1292,6 @@ static ssize_t bonding_store_active_slave(struct device *d, } out: write_unlock_bh(&bond->lock); - rtnl_unlock(); - return count; } diff --git a/trunk/drivers/net/bonding/bonding.h b/trunk/drivers/net/bonding/bonding.h index 61c1b4536d34..b8180600a309 100644 --- a/trunk/drivers/net/bonding/bonding.h +++ b/trunk/drivers/net/bonding/bonding.h @@ -184,6 +184,8 @@ struct bonding { s32 slave_cnt; /* never change this value outside the attach/detach wrappers */ rwlock_t lock; rwlock_t curr_slave_lock; + struct timer_list mii_timer; + struct timer_list arp_timer; s8 kill_timers; s8 send_grat_arp; s8 setup_by_slave; @@ -197,18 +199,12 @@ struct bonding { int (*xmit_hash_policy)(struct sk_buff *, struct net_device *, int); __be32 master_ip; u16 flags; - u16 rr_tx_counter; struct ad_bond_info ad_info; struct alb_bond_info alb_info; struct bond_params params; struct list_head vlan_list; struct vlan_group *vlgrp; struct packet_type arp_mon_pt; - struct workqueue_struct *wq; - struct delayed_work mii_work; - struct delayed_work arp_work; - struct delayed_work alb_work; - struct delayed_work ad_work; }; /** @@ -302,6 +298,7 @@ int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_de int bond_create(char *name, struct bond_params *params, struct bonding **newbond); void bond_destroy(struct bonding *bond); int bond_release_and_destroy(struct net_device *bond_dev, struct net_device *slave_dev); +void bond_deinit(struct net_device *bond_dev); int bond_create_sysfs(void); void bond_destroy_sysfs(void); void bond_destroy_sysfs_entry(struct bonding *bond); @@ -310,9 +307,9 @@ int bond_create_slave_symlinks(struct net_device *master, struct net_device *sla void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave); int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev); int bond_release(struct net_device *bond_dev, struct net_device *slave_dev); -void bond_mii_monitor(struct work_struct *); -void bond_loadbalance_arp_mon(struct work_struct *); -void bond_activebackup_arp_mon(struct work_struct *); +void bond_mii_monitor(struct net_device *bond_dev); +void bond_loadbalance_arp_mon(struct net_device *bond_dev); +void bond_activebackup_arp_mon(struct net_device *bond_dev); void bond_set_mode_ops(struct bonding *bond, int mode); int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl); void bond_select_active_slave(struct bonding *bond); diff --git a/trunk/drivers/net/cpmac.c b/trunk/drivers/net/cpmac.c index 6fd95a2c8cec..ae419736158e 100644 --- a/trunk/drivers/net/cpmac.c +++ b/trunk/drivers/net/cpmac.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -54,6 +53,12 @@ MODULE_PARM_DESC(debug_level, "Number of NETIF_MSG bits to enable"); MODULE_PARM_DESC(dumb_switch, "Assume switch is not connected to MDIO bus"); #define CPMAC_VERSION "0.5.0" +/* stolen from net/ieee80211.h */ +#ifndef MAC_FMT +#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" +#define MAC_ARG(x) ((u8*)(x))[0], ((u8*)(x))[1], ((u8*)(x))[2], \ + ((u8*)(x))[3], ((u8*)(x))[4], ((u8*)(x))[5] +#endif /* frame size + 802.1q tag */ #define CPMAC_SKB_SIZE (ETH_FRAME_LEN + 4) #define CPMAC_QUEUES 8 @@ -206,7 +211,6 @@ struct cpmac_priv { struct net_device *dev; struct work_struct reset_work; struct platform_device *pdev; - struct napi_struct napi; }; static irqreturn_t cpmac_irq(int, void *); @@ -358,48 +362,47 @@ static void cpmac_set_multicast_list(struct net_device *dev) } } -static struct sk_buff *cpmac_rx_one(struct cpmac_priv *priv, +static struct sk_buff *cpmac_rx_one(struct net_device *dev, + struct cpmac_priv *priv, struct cpmac_desc *desc) { struct sk_buff *skb, *result = NULL; if (unlikely(netif_msg_hw(priv))) - cpmac_dump_desc(priv->dev, desc); + cpmac_dump_desc(dev, desc); cpmac_write(priv->regs, CPMAC_RX_ACK(0), (u32)desc->mapping); if (unlikely(!desc->datalen)) { if (netif_msg_rx_err(priv) && net_ratelimit()) printk(KERN_WARNING "%s: rx: spurious interrupt\n", - priv->dev->name); + dev->name); return NULL; } - skb = netdev_alloc_skb(priv->dev, CPMAC_SKB_SIZE); + skb = netdev_alloc_skb(dev, CPMAC_SKB_SIZE); if (likely(skb)) { skb_reserve(skb, 2); skb_put(desc->skb, desc->datalen); - desc->skb->protocol = eth_type_trans(desc->skb, priv->dev); + desc->skb->protocol = eth_type_trans(desc->skb, dev); desc->skb->ip_summed = CHECKSUM_NONE; - priv->dev->stats.rx_packets++; - priv->dev->stats.rx_bytes += desc->datalen; + dev->stats.rx_packets++; + dev->stats.rx_bytes += desc->datalen; result = desc->skb; - dma_unmap_single(&priv->dev->dev, desc->data_mapping, - CPMAC_SKB_SIZE, DMA_FROM_DEVICE); + dma_unmap_single(&dev->dev, desc->data_mapping, CPMAC_SKB_SIZE, + DMA_FROM_DEVICE); desc->skb = skb; - desc->data_mapping = dma_map_single(&priv->dev->dev, skb->data, + desc->data_mapping = dma_map_single(&dev->dev, skb->data, CPMAC_SKB_SIZE, DMA_FROM_DEVICE); desc->hw_data = (u32)desc->data_mapping; if (unlikely(netif_msg_pktdata(priv))) { - printk(KERN_DEBUG "%s: received packet:\n", - priv->dev->name); - cpmac_dump_skb(priv->dev, result); + printk(KERN_DEBUG "%s: received packet:\n", dev->name); + cpmac_dump_skb(dev, result); } } else { if (netif_msg_rx_err(priv) && net_ratelimit()) printk(KERN_WARNING - "%s: low on skbs, dropping packet\n", - priv->dev->name); - priv->dev->stats.rx_dropped++; + "%s: low on skbs, dropping packet\n", dev->name); + dev->stats.rx_dropped++; } desc->buflen = CPMAC_SKB_SIZE; @@ -408,25 +411,25 @@ static struct sk_buff *cpmac_rx_one(struct cpmac_priv *priv, return result; } -static int cpmac_poll(struct napi_struct *napi, int budget) +static int cpmac_poll(struct net_device *dev, int *budget) { struct sk_buff *skb; struct cpmac_desc *desc; - int received = 0; - struct cpmac_priv *priv = container_of(napi, struct cpmac_priv, napi); + int received = 0, quota = min(dev->quota, *budget); + struct cpmac_priv *priv = netdev_priv(dev); spin_lock(&priv->rx_lock); if (unlikely(!priv->rx_head)) { if (netif_msg_rx_err(priv) && net_ratelimit()) printk(KERN_WARNING "%s: rx: polling, but no queue\n", - priv->dev->name); - netif_rx_complete(priv->dev, napi); + dev->name); + netif_rx_complete(dev); return 0; } desc = priv->rx_head; - while (((desc->dataflags & CPMAC_OWN) == 0) && (received < budget)) { - skb = cpmac_rx_one(priv, desc); + while ((received < quota) && ((desc->dataflags & CPMAC_OWN) == 0)) { + skb = cpmac_rx_one(dev, priv, desc); if (likely(skb)) { netif_receive_skb(skb); received++; @@ -436,11 +439,13 @@ static int cpmac_poll(struct napi_struct *napi, int budget) priv->rx_head = desc; spin_unlock(&priv->rx_lock); + *budget -= received; + dev->quota -= received; if (unlikely(netif_msg_rx_status(priv))) - printk(KERN_DEBUG "%s: poll processed %d packets\n", - priv->dev->name, received); + printk(KERN_DEBUG "%s: poll processed %d packets\n", dev->name, + received); if (desc->dataflags & CPMAC_OWN) { - netif_rx_complete(priv->dev, napi); + netif_rx_complete(dev); cpmac_write(priv->regs, CPMAC_RX_PTR(0), (u32)desc->mapping); cpmac_write(priv->regs, CPMAC_RX_INT_ENABLE, 1); return 0; @@ -455,11 +460,18 @@ static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev) struct cpmac_desc *desc; struct cpmac_priv *priv = netdev_priv(dev); - if (unlikely(skb_padto(skb, ETH_ZLEN))) - return NETDEV_TX_OK; + if (unlikely(skb_padto(skb, ETH_ZLEN))) { + if (netif_msg_tx_err(priv) && net_ratelimit()) + printk(KERN_WARNING + "%s: tx: padding failed, dropping\n", dev->name); + spin_lock(&priv->lock); + dev->stats.tx_dropped++; + spin_unlock(&priv->lock); + return -ENOMEM; + } len = max(skb->len, ETH_ZLEN); - queue = skb->queue_mapping; + queue = skb_get_queue_mapping(skb); #ifdef CONFIG_NETDEVICES_MULTIQUEUE netif_stop_subqueue(dev, queue); #else @@ -469,9 +481,13 @@ static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev) desc = &priv->desc_ring[queue]; if (unlikely(desc->dataflags & CPMAC_OWN)) { if (netif_msg_tx_err(priv) && net_ratelimit()) - printk(KERN_WARNING "%s: tx dma ring full\n", + printk(KERN_WARNING "%s: tx dma ring full, dropping\n", dev->name); - return NETDEV_TX_BUSY; + spin_lock(&priv->lock); + dev->stats.tx_dropped++; + spin_unlock(&priv->lock); + dev_kfree_skb_any(skb); + return -ENOMEM; } spin_lock(&priv->lock); @@ -493,7 +509,7 @@ static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev) cpmac_dump_skb(dev, skb); cpmac_write(priv->regs, CPMAC_TX_PTR(queue), (u32)desc->mapping); - return NETDEV_TX_OK; + return 0; } static void cpmac_end_xmit(struct net_device *dev, int queue) @@ -630,14 +646,12 @@ static void cpmac_clear_tx(struct net_device *dev) int i; if (unlikely(!priv->desc_ring)) return; - for (i = 0; i < CPMAC_QUEUES; i++) { - priv->desc_ring[i].dataflags = 0; + for (i = 0; i < CPMAC_QUEUES; i++) if (priv->desc_ring[i].skb) { dev_kfree_skb_any(priv->desc_ring[i].skb); if (netif_subqueue_stopped(dev, i)) netif_wake_subqueue(dev, i); } - } } static void cpmac_hw_error(struct work_struct *work) @@ -650,7 +664,6 @@ static void cpmac_hw_error(struct work_struct *work) spin_unlock(&priv->rx_lock); cpmac_clear_tx(priv->dev); cpmac_hw_start(priv->dev); - napi_enable(&priv->napi); netif_start_queue(priv->dev); } @@ -677,10 +690,8 @@ static irqreturn_t cpmac_irq(int irq, void *dev_id) if (status & MAC_INT_RX) { queue = (status >> 8) & 7; - if (netif_rx_schedule_prep(dev, &priv->napi)) { - cpmac_write(priv->regs, CPMAC_RX_INT_CLEAR, 1 << queue); - __netif_rx_schedule(dev, &priv->napi); - } + netif_rx_schedule(dev); + cpmac_write(priv->regs, CPMAC_RX_INT_CLEAR, 1 << queue); } cpmac_write(priv->regs, CPMAC_MAC_EOI_VECTOR, 0); @@ -690,7 +701,6 @@ static irqreturn_t cpmac_irq(int irq, void *dev_id) printk(KERN_ERR "%s: hw error, resetting...\n", dev->name); netif_stop_queue(dev); - napi_disable(&priv->napi); cpmac_hw_stop(dev); schedule_work(&priv->reset_work); if (unlikely(netif_msg_hw(priv))) @@ -717,13 +727,11 @@ static void cpmac_tx_timeout(struct net_device *dev) #ifdef CONFIG_NETDEVICES_MULTIQUEUE for (i = 0; i < CPMAC_QUEUES; i++) if (priv->desc_ring[i].skb) { - priv->desc_ring[i].dataflags = 0; dev_kfree_skb_any(priv->desc_ring[i].skb); netif_wake_subqueue(dev, i); break; } #else - priv->desc_ring[0].dataflags = 0; if (priv->desc_ring[0].skb) dev_kfree_skb_any(priv->desc_ring[0].skb); netif_wake_queue(dev); @@ -786,7 +794,7 @@ static int cpmac_set_ringparam(struct net_device *dev, struct ethtool_ringparam* { struct cpmac_priv *priv = netdev_priv(dev); - if (netif_running(dev)) + if (dev->flags && IFF_UP) return -EBUSY; priv->ring_size = ring->rx_pending; return 0; @@ -848,15 +856,6 @@ static void cpmac_adjust_link(struct net_device *dev) spin_unlock(&priv->lock); } -static int cpmac_link_update(struct net_device *dev, - struct fixed_phy_status *status) -{ - status->link = 1; - status->speed = 100; - status->duplex = 1; - return 0; -} - static int cpmac_open(struct net_device *dev) { int i, size, res; @@ -865,6 +864,15 @@ static int cpmac_open(struct net_device *dev) struct cpmac_desc *desc; struct sk_buff *skb; + priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, + 0, PHY_INTERFACE_MODE_MII); + if (IS_ERR(priv->phy)) { + if (netif_msg_drv(priv)) + printk(KERN_ERR "%s: Could not attach to PHY\n", + dev->name); + return PTR_ERR(priv->phy); + } + mem = platform_get_resource_byname(priv->pdev, IORESOURCE_MEM, "regs"); if (!request_mem_region(mem->start, mem->end - mem->start, dev->name)) { if (netif_msg_drv(priv)) @@ -926,7 +934,6 @@ static int cpmac_open(struct net_device *dev) INIT_WORK(&priv->reset_work, cpmac_hw_error); cpmac_hw_start(dev); - napi_enable(&priv->napi); priv->phy->state = PHY_CHANGELINK; phy_start(priv->phy); @@ -951,6 +958,8 @@ static int cpmac_open(struct net_device *dev) release_mem_region(mem->start, mem->end - mem->start); fail_reserve: + phy_disconnect(priv->phy); + return res; } @@ -963,8 +972,9 @@ static int cpmac_stop(struct net_device *dev) netif_stop_queue(dev); cancel_work_sync(&priv->reset_work); - napi_disable(&priv->napi); phy_stop(priv->phy); + phy_disconnect(priv->phy); + priv->phy = NULL; cpmac_hw_stop(dev); @@ -998,13 +1008,11 @@ static int external_switch; static int __devinit cpmac_probe(struct platform_device *pdev) { - int rc, phy_id, i; + int rc, phy_id; struct resource *mem; struct cpmac_priv *priv; struct net_device *dev; struct plat_cpmac_data *pdata; - struct fixed_info *fixed_phy; - DECLARE_MAC_BUF(mac); pdata = pdev->dev.platform_data; @@ -1052,51 +1060,21 @@ static int __devinit cpmac_probe(struct platform_device *pdev) dev->set_multicast_list = cpmac_set_multicast_list; dev->tx_timeout = cpmac_tx_timeout; dev->ethtool_ops = &cpmac_ethtool_ops; + dev->poll = cpmac_poll; + dev->weight = 64; dev->features |= NETIF_F_MULTI_QUEUE; - netif_napi_add(dev, &priv->napi, cpmac_poll, 64); - spin_lock_init(&priv->lock); spin_lock_init(&priv->rx_lock); priv->dev = dev; priv->ring_size = 64; priv->msg_enable = netif_msg_init(debug_level, 0xff); memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr)); - if (phy_id == 31) { - snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, cpmac_mii.id, - phy_id); - } else { - /* Let's try to get a free fixed phy... */ - for (i = 0; i < MAX_PHY_AMNT; i++) { - fixed_phy = fixed_mdio_get_phydev(i); - if (!fixed_phy) - continue; - if (!fixed_phy->phydev->attached_dev) { - strncpy(priv->phy_name, - fixed_phy->phydev->dev.bus_id, - BUS_ID_SIZE); - fixed_mdio_set_link_update(fixed_phy->phydev, - &cpmac_link_update); - goto phy_found; - } - } - if (netif_msg_drv(priv)) - printk(KERN_ERR "%s: Could not find fixed PHY\n", - dev->name); - rc = -ENODEV; - goto fail; - } - -phy_found: - priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, 0, - PHY_INTERFACE_MODE_MII); - if (IS_ERR(priv->phy)) { - if (netif_msg_drv(priv)) - printk(KERN_ERR "%s: Could not attach to PHY\n", - dev->name); - return PTR_ERR(priv->phy); - } + snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, + cpmac_mii.id, phy_id); + } else + snprintf(priv->phy_name, BUS_ID_SIZE, "fixed@%d:%d", 100, 1); if ((rc = register_netdev(dev))) { printk(KERN_ERR "cpmac: error %i registering device %s\n", rc, @@ -1106,9 +1084,9 @@ static int __devinit cpmac_probe(struct platform_device *pdev) if (netif_msg_probe(priv)) { printk(KERN_INFO - "cpmac: device %s (regs: %p, irq: %d, phy: %s, " - "mac: %s)\n", dev->name, (void *)mem->start, dev->irq, - priv->phy_name, print_mac(mac, dev->dev_addr)); + "cpmac: device %s (regs: %p, irq: %d, phy: %s, mac: " + MAC_FMT ")\n", dev->name, (void *)mem->start, dev->irq, + priv->phy_name, MAC_ARG(dev->dev_addr)); } return 0; diff --git a/trunk/drivers/net/cxgb3/adapter.h b/trunk/drivers/net/cxgb3/adapter.h index 60a62f510db7..2a3df145850d 100644 --- a/trunk/drivers/net/cxgb3/adapter.h +++ b/trunk/drivers/net/cxgb3/adapter.h @@ -46,6 +46,8 @@ #include #include +typedef irqreturn_t(*intr_handler_t) (int, void *); + struct vlan_group; struct adapter; struct sge_qset; @@ -268,7 +270,7 @@ void t3_sge_start(struct adapter *adap); void t3_sge_stop(struct adapter *adap); void t3_free_sge_resources(struct adapter *adap); void t3_sge_err_intr_handler(struct adapter *adapter); -irq_handler_t t3_intr_handler(struct adapter *adap, int polling); +intr_handler_t t3_intr_handler(struct adapter *adap, int polling); int t3_eth_xmit(struct sk_buff *skb, struct net_device *dev); int t3_mgmt_tx(struct adapter *adap, struct sk_buff *skb); void t3_update_qset_coalesce(struct sge_qset *qs, const struct qset_params *p); diff --git a/trunk/drivers/net/cxgb3/sge.c b/trunk/drivers/net/cxgb3/sge.c index c15e43a8543b..994b5d6404df 100644 --- a/trunk/drivers/net/cxgb3/sge.c +++ b/trunk/drivers/net/cxgb3/sge.c @@ -2431,7 +2431,7 @@ static irqreturn_t t3b_intr_napi(int irq, void *cookie) * (MSI-X, MSI, or legacy) and whether NAPI will be used to service the * response queues. */ -irq_handler_t t3_intr_handler(struct adapter *adap, int polling) +intr_handler_t t3_intr_handler(struct adapter *adap, int polling) { if (adap->flags & USING_MSIX) return polling ? t3_sge_intr_msix_napi : t3_sge_intr_msix; diff --git a/trunk/drivers/net/defxx.c b/trunk/drivers/net/defxx.c index ddc30c4bf34a..b07613e61f53 100644 --- a/trunk/drivers/net/defxx.c +++ b/trunk/drivers/net/defxx.c @@ -805,7 +805,7 @@ static void __devinit dfx_bus_init(struct net_device *dev) * Interrupts are disabled at the adapter bus-specific logic. */ -static void __devexit dfx_bus_uninit(struct net_device *dev) +static void __devinit dfx_bus_uninit(struct net_device *dev) { DFX_board_t *bp = netdev_priv(dev); struct device *bdev = bp->bus_dev; diff --git a/trunk/drivers/net/e1000/e1000.h b/trunk/drivers/net/e1000/e1000.h index 3b840283a9c3..781ed9968489 100644 --- a/trunk/drivers/net/e1000/e1000.h +++ b/trunk/drivers/net/e1000/e1000.h @@ -351,12 +351,4 @@ enum e1000_state_t { __E1000_DOWN }; -extern char e1000_driver_name[]; -extern const char e1000_driver_version[]; - -extern void e1000_power_up_phy(struct e1000_adapter *); -extern void e1000_set_ethtool_ops(struct net_device *netdev); -extern void e1000_check_options(struct e1000_adapter *adapter); - - #endif /* _E1000_H_ */ diff --git a/trunk/drivers/net/e1000/e1000_ethtool.c b/trunk/drivers/net/e1000/e1000_ethtool.c index 667f18bcc172..6c9a643426f5 100644 --- a/trunk/drivers/net/e1000/e1000_ethtool.c +++ b/trunk/drivers/net/e1000/e1000_ethtool.c @@ -32,6 +32,9 @@ #include +extern char e1000_driver_name[]; +extern char e1000_driver_version[]; + extern int e1000_up(struct e1000_adapter *adapter); extern void e1000_down(struct e1000_adapter *adapter); extern void e1000_reinit_locked(struct e1000_adapter *adapter); @@ -730,16 +733,16 @@ e1000_set_ringparam(struct net_device *netdev, #define REG_PATTERN_TEST(R, M, W) \ { \ - uint32_t pat, val; \ - const uint32_t test[] = \ + uint32_t pat, value; \ + uint32_t test[] = \ {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; \ - for (pat = 0; pat < ARRAY_SIZE(test); pat++) { \ + for (pat = 0; pat < ARRAY_SIZE(test); pat++) { \ E1000_WRITE_REG(&adapter->hw, R, (test[pat] & W)); \ - val = E1000_READ_REG(&adapter->hw, R); \ - if (val != (test[pat] & W & M)) { \ + value = E1000_READ_REG(&adapter->hw, R); \ + if (value != (test[pat] & W & M)) { \ DPRINTK(DRV, ERR, "pattern test reg %04X failed: got " \ "0x%08X expected 0x%08X\n", \ - E1000_##R, val, (test[pat] & W & M)); \ + E1000_##R, value, (test[pat] & W & M)); \ *data = (adapter->hw.mac_type < e1000_82543) ? \ E1000_82542_##R : E1000_##R; \ return 1; \ @@ -749,12 +752,12 @@ e1000_set_ringparam(struct net_device *netdev, #define REG_SET_AND_CHECK(R, M, W) \ { \ - uint32_t val; \ + uint32_t value; \ E1000_WRITE_REG(&adapter->hw, R, W & M); \ - val = E1000_READ_REG(&adapter->hw, R); \ - if ((W & M) != (val & M)) { \ + value = E1000_READ_REG(&adapter->hw, R); \ + if ((W & M) != (value & M)) { \ DPRINTK(DRV, ERR, "set/check reg %04X test failed: got 0x%08X "\ - "expected 0x%08X\n", E1000_##R, (val & M), (W & M)); \ + "expected 0x%08X\n", E1000_##R, (value & M), (W & M)); \ *data = (adapter->hw.mac_type < e1000_82543) ? \ E1000_82542_##R : E1000_##R; \ return 1; \ @@ -1618,6 +1621,8 @@ e1000_get_sset_count(struct net_device *netdev, int sset) } } +extern void e1000_power_up_phy(struct e1000_adapter *); + static void e1000_diag_test(struct net_device *netdev, struct ethtool_test *eth_test, uint64_t *data) @@ -1854,8 +1859,8 @@ e1000_phys_id(struct net_device *netdev, uint32_t data) { struct e1000_adapter *adapter = netdev_priv(netdev); - if (!data) - data = INT_MAX; + if (!data || data > (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ)) + data = (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ); if (adapter->hw.mac_type < e1000_82571) { if (!adapter->blink_timer.function) { diff --git a/trunk/drivers/net/e1000/e1000_hw.c b/trunk/drivers/net/e1000/e1000_hw.c index 7c6888c58c21..8fa0fe4009d5 100644 --- a/trunk/drivers/net/e1000/e1000_hw.c +++ b/trunk/drivers/net/e1000/e1000_hw.c @@ -8607,7 +8607,7 @@ e1000_read_ich8_data(struct e1000_hw *hw, uint32_t index, DEBUGFUNC("e1000_read_ich8_data"); - if (size < 1 || size > 2 || data == NULL || + if (size < 1 || size > 2 || data == 0x0 || index > ICH_FLASH_LINEAR_ADDR_MASK) return error; @@ -8841,7 +8841,7 @@ e1000_read_ich8_word(struct e1000_hw *hw, uint32_t index, uint16_t *data) * amount of NVM used in each bank is a *minimum* of 4 KBytes, but in fact the * bank size may be 4, 8 or 64 KBytes *****************************************************************************/ -static int32_t +int32_t e1000_erase_ich8_4k_segment(struct e1000_hw *hw, uint32_t bank) { union ich8_hws_flash_status hsfsts; diff --git a/trunk/drivers/net/e1000/e1000_main.c b/trunk/drivers/net/e1000/e1000_main.c index 72deff0d4d90..f1ce348470cc 100644 --- a/trunk/drivers/net/e1000/e1000_main.c +++ b/trunk/drivers/net/e1000/e1000_main.c @@ -37,8 +37,8 @@ static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver"; #define DRIVERNAPI "-NAPI" #endif #define DRV_VERSION "7.3.20-k2"DRIVERNAPI -const char e1000_driver_version[] = DRV_VERSION; -static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation."; +char e1000_driver_version[] = DRV_VERSION; +static char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation."; /* e1000_pci_tbl - PCI Device ID Table * @@ -188,6 +188,7 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter, static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd); static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd); +void e1000_set_ethtool_ops(struct net_device *netdev); static void e1000_enter_82542_rst(struct e1000_adapter *adapter); static void e1000_leave_82542_rst(struct e1000_adapter *adapter); static void e1000_tx_timeout(struct net_device *dev); @@ -212,6 +213,8 @@ static void e1000_shutdown(struct pci_dev *pdev); static void e1000_netpoll (struct net_device *netdev); #endif +extern void e1000_check_options(struct e1000_adapter *adapter); + #define COPYBREAK_DEFAULT 256 static unsigned int copybreak __read_mostly = COPYBREAK_DEFAULT; module_param(copybreak, uint, 0644); diff --git a/trunk/drivers/net/e1000/e1000_param.c b/trunk/drivers/net/e1000/e1000_param.c index e6565ce686bc..f485874a63f5 100644 --- a/trunk/drivers/net/e1000/e1000_param.c +++ b/trunk/drivers/net/e1000/e1000_param.c @@ -46,7 +46,7 @@ #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET } #define E1000_PARAM(X, desc) \ static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \ - static unsigned int num_##X; \ + static int num_##X = 0; \ module_param_array_named(X, X, int, &num_##X, 0); \ MODULE_PARM_DESC(X, desc); @@ -198,9 +198,9 @@ E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround"); struct e1000_option { enum { enable_option, range_option, list_option } type; - const char *name; - const char *err; - int def; + char *name; + char *err; + int def; union { struct { /* range_option info */ int min; @@ -214,9 +214,8 @@ struct e1000_option { }; static int __devinit -e1000_validate_option(unsigned int *value, - const struct e1000_option *opt, - struct e1000_adapter *adapter) +e1000_validate_option(int *value, struct e1000_option *opt, + struct e1000_adapter *adapter) { if (*value == OPTION_UNSET) { *value = opt->def; @@ -349,7 +348,7 @@ e1000_check_options(struct e1000_adapter *adapter) }; if (num_XsumRX > bd) { - unsigned int rx_csum = XsumRX[bd]; + int rx_csum = XsumRX[bd]; e1000_validate_option(&rx_csum, &opt, adapter); adapter->rx_csum = rx_csum; } else { @@ -375,7 +374,7 @@ e1000_check_options(struct e1000_adapter *adapter) }; if (num_FlowControl > bd) { - unsigned int fc = FlowControl[bd]; + int fc = FlowControl[bd]; e1000_validate_option(&fc, &opt, adapter); adapter->hw.fc = adapter->hw.original_fc = fc; } else { @@ -507,7 +506,7 @@ e1000_check_options(struct e1000_adapter *adapter) }; if (num_SmartPowerDownEnable > bd) { - unsigned int spd = SmartPowerDownEnable[bd]; + int spd = SmartPowerDownEnable[bd]; e1000_validate_option(&spd, &opt, adapter); adapter->smart_power_down = spd; } else { @@ -523,7 +522,7 @@ e1000_check_options(struct e1000_adapter *adapter) }; if (num_KumeranLockLoss > bd) { - unsigned int kmrn_lock_loss = KumeranLockLoss[bd]; + int kmrn_lock_loss = KumeranLockLoss[bd]; e1000_validate_option(&kmrn_lock_loss, &opt, adapter); adapter->hw.kmrn_lock_loss_workaround_disabled = !kmrn_lock_loss; } else { @@ -582,7 +581,7 @@ e1000_check_fiber_options(struct e1000_adapter *adapter) static void __devinit e1000_check_copper_options(struct e1000_adapter *adapter) { - unsigned int speed, dplx, an; + int speed, dplx, an; int bd = adapter->bd_number; { /* Speed */ diff --git a/trunk/drivers/net/e1000e/82571.c b/trunk/drivers/net/e1000e/82571.c index 14141a55eaa6..cf70522fc851 100644 --- a/trunk/drivers/net/e1000e/82571.c +++ b/trunk/drivers/net/e1000e/82571.c @@ -283,7 +283,7 @@ static s32 e1000_get_invariants_82571(struct e1000_adapter *adapter) adapter->flags &= ~FLAG_HAS_WOL; /* quad ports only support WoL on port A */ if (adapter->flags & FLAG_IS_QUAD_PORT && - (!(adapter->flags & FLAG_IS_QUAD_PORT_A))) + (!adapter->flags & FLAG_IS_QUAD_PORT_A)) adapter->flags &= ~FLAG_HAS_WOL; break; diff --git a/trunk/drivers/net/e1000e/e1000.h b/trunk/drivers/net/e1000e/e1000.h index 473f78de4be0..d2499bb07c13 100644 --- a/trunk/drivers/net/e1000e/e1000.h +++ b/trunk/drivers/net/e1000e/e1000.h @@ -122,8 +122,7 @@ struct e1000_buffer { u16 next_to_watch; }; /* RX */ - /* arrays of page information for packet split */ - struct e1000_ps_page *ps_pages; + struct page *page; }; }; @@ -143,6 +142,8 @@ struct e1000_ring { /* array of buffer information structs */ struct e1000_buffer *buffer_info; + /* arrays of page information for packet split */ + struct e1000_ps_page *ps_pages; struct sk_buff *rx_skb_top; struct e1000_queue_stats stats; diff --git a/trunk/drivers/net/e1000e/ethtool.c b/trunk/drivers/net/e1000e/ethtool.c index 6a39784e7ee2..0666e62e9ad2 100644 --- a/trunk/drivers/net/e1000e/ethtool.c +++ b/trunk/drivers/net/e1000e/ethtool.c @@ -1680,8 +1680,8 @@ static int e1000_phys_id(struct net_device *netdev, u32 data) { struct e1000_adapter *adapter = netdev_priv(netdev); - if (!data) - data = INT_MAX; + if (!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ)) + data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ); if (adapter->hw.phy.type == e1000_phy_ife) { if (!adapter->blink_timer.function) { diff --git a/trunk/drivers/net/e1000e/netdev.c b/trunk/drivers/net/e1000e/netdev.c index 4fd2e23720b6..033e124d1c1f 100644 --- a/trunk/drivers/net/e1000e/netdev.c +++ b/trunk/drivers/net/e1000e/netdev.c @@ -245,36 +245,37 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter, rx_desc = E1000_RX_DESC_PS(*rx_ring, i); for (j = 0; j < PS_PAGE_BUFFERS; j++) { - ps_page = &buffer_info->ps_pages[j]; - if (j >= adapter->rx_ps_pages) { - /* all unused desc entries get hw null ptr */ - rx_desc->read.buffer_addr[j+1] = ~0; - continue; - } - if (!ps_page->page) { - ps_page->page = alloc_page(GFP_ATOMIC); + ps_page = &rx_ring->ps_pages[(i * PS_PAGE_BUFFERS) + + j]; + if (j < adapter->rx_ps_pages) { if (!ps_page->page) { - adapter->alloc_rx_buff_failed++; - goto no_buffers; - } - ps_page->dma = pci_map_page(pdev, - ps_page->page, - 0, PAGE_SIZE, - PCI_DMA_FROMDEVICE); - if (pci_dma_mapping_error(ps_page->dma)) { - dev_err(&adapter->pdev->dev, - "RX DMA page map failed\n"); - adapter->rx_dma_failed++; - goto no_buffers; + ps_page->page = alloc_page(GFP_ATOMIC); + if (!ps_page->page) { + adapter->alloc_rx_buff_failed++; + goto no_buffers; + } + ps_page->dma = pci_map_page(pdev, + ps_page->page, + 0, PAGE_SIZE, + PCI_DMA_FROMDEVICE); + if (pci_dma_mapping_error( + ps_page->dma)) { + dev_err(&adapter->pdev->dev, + "RX DMA page map failed\n"); + adapter->rx_dma_failed++; + goto no_buffers; + } } + /* + * Refresh the desc even if buffer_addrs + * didn't change because each write-back + * erases this info. + */ + rx_desc->read.buffer_addr[j+1] = + cpu_to_le64(ps_page->dma); + } else { + rx_desc->read.buffer_addr[j+1] = ~0; } - /* - * Refresh the desc even if buffer_addrs - * didn't change because each write-back - * erases this info. - */ - rx_desc->read.buffer_addr[j+1] = - cpu_to_le64(ps_page->dma); } skb = netdev_alloc_skb(netdev, @@ -332,6 +333,94 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter, } } +/** + * e1000_alloc_rx_buffers_jumbo - Replace used jumbo receive buffers + * + * @adapter: address of board private structure + * @cleaned_count: number of buffers to allocate this pass + **/ +static void e1000_alloc_rx_buffers_jumbo(struct e1000_adapter *adapter, + int cleaned_count) +{ + struct net_device *netdev = adapter->netdev; + struct pci_dev *pdev = adapter->pdev; + struct e1000_ring *rx_ring = adapter->rx_ring; + struct e1000_rx_desc *rx_desc; + struct e1000_buffer *buffer_info; + struct sk_buff *skb; + unsigned int i; + unsigned int bufsz = 256 - + 16 /*for skb_reserve */ - + NET_IP_ALIGN; + + i = rx_ring->next_to_use; + buffer_info = &rx_ring->buffer_info[i]; + + while (cleaned_count--) { + skb = buffer_info->skb; + if (skb) { + skb_trim(skb, 0); + goto check_page; + } + + skb = netdev_alloc_skb(netdev, bufsz); + if (!skb) { + /* Better luck next round */ + adapter->alloc_rx_buff_failed++; + break; + } + + /* Make buffer alignment 2 beyond a 16 byte boundary + * this will result in a 16 byte aligned IP header after + * the 14 byte MAC header is removed + */ + skb_reserve(skb, NET_IP_ALIGN); + + buffer_info->skb = skb; +check_page: + /* allocate a new page if necessary */ + if (!buffer_info->page) { + buffer_info->page = alloc_page(GFP_ATOMIC); + if (!buffer_info->page) { + adapter->alloc_rx_buff_failed++; + break; + } + } + + if (!buffer_info->dma) + buffer_info->dma = pci_map_page(pdev, + buffer_info->page, 0, + PAGE_SIZE, + PCI_DMA_FROMDEVICE); + if (pci_dma_mapping_error(buffer_info->dma)) { + dev_err(&adapter->pdev->dev, "RX DMA page map failed\n"); + adapter->rx_dma_failed++; + break; + } + + rx_desc = E1000_RX_DESC(*rx_ring, i); + rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma); + + i++; + if (i == rx_ring->count) + i = 0; + buffer_info = &rx_ring->buffer_info[i]; + } + + if (rx_ring->next_to_use != i) { + rx_ring->next_to_use = i; + if (i-- == 0) + i = (rx_ring->count - 1); + + /* Force memory writes to complete before letting h/w + * know there are new descriptors to fetch. (Only + * applicable for weak-ordered memory model archs, + * such as IA-64). */ + wmb(); + writel(i, adapter->hw.hw_addr + rx_ring->tail); + } +} + /** * e1000_clean_rx_irq - Send received data up the network stack; legacy * @adapter: board private structure @@ -406,6 +495,10 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, goto next_desc; } + /* adjust length to remove Ethernet CRC */ + length -= 4; + + /* probably a little skewed due to removing CRC */ total_rx_bytes += length; total_rx_packets++; @@ -461,6 +554,15 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, return cleaned; } +static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb, + u16 length) +{ + bi->page = NULL; + skb->len += length; + skb->data_len += length; + skb->truesize += length; +} + static void e1000_put_txbuf(struct e1000_adapter *adapter, struct e1000_buffer *buffer_info) { @@ -596,6 +698,174 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter) return cleaned; } +/** + * e1000_clean_rx_irq_jumbo - Send received data up the network stack; legacy + * @adapter: board private structure + * + * the return value indicates whether actual cleaning was done, there + * is no guarantee that everything was cleaned + **/ +static bool e1000_clean_rx_irq_jumbo(struct e1000_adapter *adapter, + int *work_done, int work_to_do) +{ + struct net_device *netdev = adapter->netdev; + struct pci_dev *pdev = adapter->pdev; + struct e1000_ring *rx_ring = adapter->rx_ring; + struct e1000_rx_desc *rx_desc, *next_rxd; + struct e1000_buffer *buffer_info, *next_buffer; + u32 length; + unsigned int i; + int cleaned_count = 0; + bool cleaned = 0; + unsigned int total_rx_bytes = 0, total_rx_packets = 0; + + i = rx_ring->next_to_clean; + rx_desc = E1000_RX_DESC(*rx_ring, i); + buffer_info = &rx_ring->buffer_info[i]; + + while (rx_desc->status & E1000_RXD_STAT_DD) { + struct sk_buff *skb; + u8 status; + + if (*work_done >= work_to_do) + break; + (*work_done)++; + + status = rx_desc->status; + skb = buffer_info->skb; + buffer_info->skb = NULL; + + i++; + if (i == rx_ring->count) + i = 0; + next_rxd = E1000_RX_DESC(*rx_ring, i); + prefetch(next_rxd); + + next_buffer = &rx_ring->buffer_info[i]; + + cleaned = 1; + cleaned_count++; + pci_unmap_page(pdev, + buffer_info->dma, + PAGE_SIZE, + PCI_DMA_FROMDEVICE); + buffer_info->dma = 0; + + length = le16_to_cpu(rx_desc->length); + + /* errors is only valid for DD + EOP descriptors */ + if ((status & E1000_RXD_STAT_EOP) && + (rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) { + /* recycle both page and skb */ + buffer_info->skb = skb; + /* an error means any chain goes out the window too */ + if (rx_ring->rx_skb_top) + dev_kfree_skb(rx_ring->rx_skb_top); + rx_ring->rx_skb_top = NULL; + goto next_desc; + } + +#define rxtop rx_ring->rx_skb_top + if (!(status & E1000_RXD_STAT_EOP)) { + /* this descriptor is only the beginning (or middle) */ + if (!rxtop) { + /* this is the beginning of a chain */ + rxtop = skb; + skb_fill_page_desc(rxtop, 0, buffer_info->page, + 0, length); + } else { + /* this is the middle of a chain */ + skb_fill_page_desc(rxtop, + skb_shinfo(rxtop)->nr_frags, + buffer_info->page, 0, + length); + /* re-use the skb, only consumed the page */ + buffer_info->skb = skb; + } + e1000_consume_page(buffer_info, rxtop, length); + goto next_desc; + } else { + if (rxtop) { + /* end of the chain */ + skb_fill_page_desc(rxtop, + skb_shinfo(rxtop)->nr_frags, + buffer_info->page, 0, length); + /* re-use the current skb, we only consumed the + * page */ + buffer_info->skb = skb; + skb = rxtop; + rxtop = NULL; + e1000_consume_page(buffer_info, skb, length); + } else { + /* no chain, got EOP, this buf is the packet + * copybreak to save the put_page/alloc_page */ + if (length <= copybreak && + skb_tailroom(skb) >= length) { + u8 *vaddr; + vaddr = kmap_atomic(buffer_info->page, + KM_SKB_DATA_SOFTIRQ); + memcpy(skb_tail_pointer(skb), + vaddr, length); + kunmap_atomic(vaddr, + KM_SKB_DATA_SOFTIRQ); + /* re-use the page, so don't erase + * buffer_info->page */ + skb_put(skb, length); + } else { + skb_fill_page_desc(skb, 0, + buffer_info->page, 0, + length); + e1000_consume_page(buffer_info, skb, + length); + } + } + } + + /* Receive Checksum Offload XXX recompute due to CRC strip? */ + e1000_rx_checksum(adapter, + (u32)(status) | + ((u32)(rx_desc->errors) << 24), + le16_to_cpu(rx_desc->csum), skb); + + pskb_trim(skb, skb->len - 4); + + /* probably a little skewed due to removing CRC */ + total_rx_bytes += skb->len; + total_rx_packets++; + + /* eth type trans needs skb->data to point to something */ + if (!pskb_may_pull(skb, ETH_HLEN)) { + ndev_err(netdev, "__pskb_pull_tail failed.\n"); + dev_kfree_skb(skb); + goto next_desc; + } + + e1000_receive_skb(adapter, netdev, skb,status,rx_desc->special); + +next_desc: + rx_desc->status = 0; + + /* return some buffers to hardware, one at a time is too slow */ + if (cleaned_count >= E1000_RX_BUFFER_WRITE) { + adapter->alloc_rx_buf(adapter, cleaned_count); + cleaned_count = 0; + } + + /* use prefetched values */ + rx_desc = next_rxd; + buffer_info = next_buffer; + } + rx_ring->next_to_clean = i; + + cleaned_count = e1000_desc_unused(rx_ring); + if (cleaned_count) + adapter->alloc_rx_buf(adapter, cleaned_count); + + adapter->total_rx_packets += total_rx_packets; + adapter->total_rx_bytes += total_rx_bytes; + return cleaned; +} + /** * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split * @adapter: board private structure @@ -683,7 +953,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, ((length + l1) <= adapter->rx_ps_bsize0)) { u8 *vaddr; - ps_page = &buffer_info->ps_pages[0]; + ps_page = &rx_ring->ps_pages[i * PS_PAGE_BUFFERS]; /* there is no documentation about how to call * kmap_atomic, so we can't hold the mapping @@ -695,7 +965,8 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ); pci_dma_sync_single_for_device(pdev, ps_page->dma, PAGE_SIZE, PCI_DMA_FROMDEVICE); - + /* remove the CRC */ + l1 -= 4; skb_put(skb, l1); goto copydone; } /* if */ @@ -706,7 +977,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, if (!length) break; - ps_page = &buffer_info->ps_pages[j]; + ps_page = &rx_ring->ps_pages[(i * PS_PAGE_BUFFERS) + j]; pci_unmap_page(pdev, ps_page->dma, PAGE_SIZE, PCI_DMA_FROMDEVICE); ps_page->dma = 0; @@ -717,6 +988,10 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, skb->truesize += length; } + /* strip the ethernet crc, problem is we're using pages now so + * this whole operation can get a little cpu intensive */ + pskb_trim(skb, skb->len - 4); + copydone: total_rx_bytes += skb->len; total_rx_packets++; @@ -768,6 +1043,7 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter) struct e1000_buffer *buffer_info; struct e1000_ps_page *ps_page; struct pci_dev *pdev = adapter->pdev; + unsigned long size; unsigned int i, j; /* Free all the Rx ring sk_buffs */ @@ -778,6 +1054,9 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter) pci_unmap_single(pdev, buffer_info->dma, adapter->rx_buffer_len, PCI_DMA_FROMDEVICE); + else if (adapter->clean_rx == e1000_clean_rx_irq_jumbo) + pci_unmap_page(pdev, buffer_info->dma, + PAGE_SIZE, PCI_DMA_FROMDEVICE); else if (adapter->clean_rx == e1000_clean_rx_irq_ps) pci_unmap_single(pdev, buffer_info->dma, adapter->rx_ps_bsize0, @@ -785,13 +1064,19 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter) buffer_info->dma = 0; } + if (buffer_info->page) { + put_page(buffer_info->page); + buffer_info->page = NULL; + } + if (buffer_info->skb) { dev_kfree_skb(buffer_info->skb); buffer_info->skb = NULL; } for (j = 0; j < PS_PAGE_BUFFERS; j++) { - ps_page = &buffer_info->ps_pages[j]; + ps_page = &rx_ring->ps_pages[(i * PS_PAGE_BUFFERS) + + j]; if (!ps_page->page) break; pci_unmap_page(pdev, ps_page->dma, PAGE_SIZE, @@ -808,6 +1093,12 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter) rx_ring->rx_skb_top = NULL; } + size = sizeof(struct e1000_buffer) * rx_ring->count; + memset(rx_ring->buffer_info, 0, size); + size = sizeof(struct e1000_ps_page) + * (rx_ring->count * PS_PAGE_BUFFERS); + memset(rx_ring->ps_pages, 0, size); + /* Zero out the descriptor ring */ memset(rx_ring->desc, 0, rx_ring->size); @@ -1130,8 +1421,7 @@ int e1000e_setup_tx_resources(struct e1000_adapter *adapter) int e1000e_setup_rx_resources(struct e1000_adapter *adapter) { struct e1000_ring *rx_ring = adapter->rx_ring; - struct e1000_buffer *buffer_info; - int i, size, desc_len, err = -ENOMEM; + int size, desc_len, err = -ENOMEM; size = sizeof(struct e1000_buffer) * rx_ring->count; rx_ring->buffer_info = vmalloc(size); @@ -1139,14 +1429,11 @@ int e1000e_setup_rx_resources(struct e1000_adapter *adapter) goto err; memset(rx_ring->buffer_info, 0, size); - for (i = 0; i < rx_ring->count; i++) { - buffer_info = &rx_ring->buffer_info[i]; - buffer_info->ps_pages = kcalloc(PS_PAGE_BUFFERS, - sizeof(struct e1000_ps_page), - GFP_KERNEL); - if (!buffer_info->ps_pages) - goto err_pages; - } + rx_ring->ps_pages = kcalloc(rx_ring->count * PS_PAGE_BUFFERS, + sizeof(struct e1000_ps_page), + GFP_KERNEL); + if (!rx_ring->ps_pages) + goto err; desc_len = sizeof(union e1000_rx_desc_packet_split); @@ -1156,21 +1443,16 @@ int e1000e_setup_rx_resources(struct e1000_adapter *adapter) err = e1000_alloc_ring_dma(adapter, rx_ring); if (err) - goto err_pages; + goto err; rx_ring->next_to_clean = 0; rx_ring->next_to_use = 0; rx_ring->rx_skb_top = NULL; return 0; - -err_pages: - for (i = 0; i < rx_ring->count; i++) { - buffer_info = &rx_ring->buffer_info[i]; - kfree(buffer_info->ps_pages); - } err: vfree(rx_ring->buffer_info); + kfree(rx_ring->ps_pages); ndev_err(adapter->netdev, "Unable to allocate memory for the transmit descriptor ring\n"); return err; @@ -1236,17 +1518,15 @@ void e1000e_free_rx_resources(struct e1000_adapter *adapter) { struct pci_dev *pdev = adapter->pdev; struct e1000_ring *rx_ring = adapter->rx_ring; - int i; e1000_clean_rx_ring(adapter); - for (i = 0; i < rx_ring->count; i++) { - kfree(rx_ring->buffer_info[i].ps_pages); - } - vfree(rx_ring->buffer_info); rx_ring->buffer_info = NULL; + kfree(rx_ring->ps_pages); + rx_ring->ps_pages = NULL; + dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc, rx_ring->dma); rx_ring->desc = NULL; @@ -1752,11 +2032,9 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter) ew32(RFCTL, rfctl); - /* Enable Packet split descriptors */ - rctl |= E1000_RCTL_DTYP_PS; - - /* Enable hardware CRC frame stripping */ - rctl |= E1000_RCTL_SECRC; + /* disable the stripping of CRC because it breaks + * BMC firmware connected over SMBUS */ + rctl |= E1000_RCTL_DTYP_PS /* | E1000_RCTL_SECRC */; psrctl |= adapter->rx_ps_bsize0 >> E1000_PSRCTL_BSIZE0_SHIFT; @@ -1799,6 +2077,11 @@ static void e1000_configure_rx(struct e1000_adapter *adapter) sizeof(union e1000_rx_desc_packet_split); adapter->clean_rx = e1000_clean_rx_irq_ps; adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps; + } else if (adapter->netdev->mtu > ETH_FRAME_LEN + VLAN_HLEN + 4) { + rdlen = rx_ring->count * + sizeof(struct e1000_rx_desc); + adapter->clean_rx = e1000_clean_rx_irq_jumbo; + adapter->alloc_rx_buf = e1000_alloc_rx_buffers_jumbo; } else { rdlen = rx_ring->count * sizeof(struct e1000_rx_desc); @@ -2043,11 +2326,8 @@ void e1000e_reset(struct e1000_adapter *adapter) struct e1000_mac_info *mac = &adapter->hw.mac; struct e1000_hw *hw = &adapter->hw; u32 tx_space, min_tx_space, min_rx_space; - u32 pba; u16 hwm; - ew32(PBA, adapter->pba); - if (mac->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN ) { /* To maintain wire speed transmits, the Tx FIFO should be * large enough to accommodate two full transmit packets, @@ -2055,11 +2335,11 @@ void e1000e_reset(struct e1000_adapter *adapter) * the Rx FIFO should be large enough to accommodate at least * one full receive packet and is similarly rounded up and * expressed in KB. */ - pba = er32(PBA); + adapter->pba = er32(PBA); /* upper 16 bits has Tx packet buffer allocation size in KB */ - tx_space = pba >> 16; + tx_space = adapter->pba >> 16; /* lower 16 bits has Rx packet buffer allocation size in KB */ - pba &= 0xffff; + adapter->pba &= 0xffff; /* the tx fifo also stores 16 bytes of information about the tx * but don't include ethernet FCS because hardware appends it */ min_tx_space = (mac->max_frame_size + @@ -2075,21 +2355,20 @@ void e1000e_reset(struct e1000_adapter *adapter) /* If current Tx allocation is less than the min Tx FIFO size, * and the min Tx FIFO size is less than the current Rx FIFO * allocation, take space away from current Rx allocation */ - if ((tx_space < min_tx_space) && - ((min_tx_space - tx_space) < pba)) { - pba -= min_tx_space - tx_space; + if (tx_space < min_tx_space && + ((min_tx_space - tx_space) < adapter->pba)) { + adapter->pba -= - (min_tx_space - tx_space); /* if short on rx space, rx wins and must trump tx * adjustment or use Early Receive if available */ - if ((pba < min_rx_space) && + if ((adapter->pba < min_rx_space) && (!(adapter->flags & FLAG_HAS_ERT))) /* ERT enabled in e1000_configure_rx */ - pba = min_rx_space; + adapter->pba = min_rx_space; } - - ew32(PBA, pba); } + ew32(PBA, adapter->pba); /* flow control settings */ /* The high water mark must be low enough to fit one full frame @@ -3345,7 +3624,9 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu) /* NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN * means we reserve 2 more, this pushes us to allocate from the next * larger slab size. - * i.e. RXBUFFER_2048 --> size-4096 slab */ + * i.e. RXBUFFER_2048 --> size-4096 slab + * however with the new *_jumbo* routines, jumbo receives will use + * fragmented skbs */ if (max_frame <= 256) adapter->rx_buffer_len = 256; diff --git a/trunk/drivers/net/e1000e/param.c b/trunk/drivers/net/e1000e/param.c index 332789238b9c..e4e655efb23c 100644 --- a/trunk/drivers/net/e1000e/param.c +++ b/trunk/drivers/net/e1000e/param.c @@ -52,11 +52,10 @@ MODULE_PARM_DESC(copybreak, */ #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET } -#define E1000_PARAM(X, desc) \ - static int __devinitdata X[E1000_MAX_NIC+1] \ - = E1000_PARAM_INIT; \ - static unsigned int num_##X; \ - module_param_array_named(X, X, int, &num_##X, 0); \ +#define E1000_PARAM(X, desc) \ + static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \ + static int num_##X; \ + module_param_array_named(X, X, int, &num_##X, 0); \ MODULE_PARM_DESC(X, desc); @@ -125,9 +124,9 @@ E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround"); struct e1000_option { enum { enable_option, range_option, list_option } type; - const char *name; - const char *err; - int def; + char *name; + char *err; + int def; union { struct { /* range_option info */ int min; @@ -140,8 +139,8 @@ struct e1000_option { } arg; }; -static int __devinit e1000_validate_option(unsigned int *value, - const struct e1000_option *opt, +static int __devinit e1000_validate_option(int *value, + struct e1000_option *opt, struct e1000_adapter *adapter) { if (*value == OPTION_UNSET) { @@ -214,7 +213,7 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter) } { /* Transmit Interrupt Delay */ - const struct e1000_option opt = { + struct e1000_option opt = { .type = range_option, .name = "Transmit Interrupt Delay", .err = "using default of " @@ -233,7 +232,7 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter) } } { /* Transmit Absolute Interrupt Delay */ - const struct e1000_option opt = { + struct e1000_option opt = { .type = range_option, .name = "Transmit Absolute Interrupt Delay", .err = "using default of " @@ -278,7 +277,7 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter) } } { /* Receive Absolute Interrupt Delay */ - const struct e1000_option opt = { + struct e1000_option opt = { .type = range_option, .name = "Receive Absolute Interrupt Delay", .err = "using default of " @@ -297,7 +296,7 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter) } } { /* Interrupt Throttling Rate */ - const struct e1000_option opt = { + struct e1000_option opt = { .type = range_option, .name = "Interrupt Throttling Rate (ints/sec)", .err = "using default of " @@ -345,7 +344,7 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter) } } { /* Smart Power Down */ - const struct e1000_option opt = { + struct e1000_option opt = { .type = enable_option, .name = "PHY Smart Power Down", .err = "defaulting to Disabled", @@ -353,7 +352,7 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter) }; if (num_SmartPowerDownEnable > bd) { - unsigned int spd = SmartPowerDownEnable[bd]; + int spd = SmartPowerDownEnable[bd]; e1000_validate_option(&spd, &opt, adapter); if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN) && spd) @@ -361,7 +360,7 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter) } } { /* Kumeran Lock Loss Workaround */ - const struct e1000_option opt = { + struct e1000_option opt = { .type = enable_option, .name = "Kumeran Lock Loss Workaround", .err = "defaulting to Enabled", @@ -369,7 +368,7 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter) }; if (num_KumeranLockLoss > bd) { - unsigned int kmrn_lock_loss = KumeranLockLoss[bd]; + int kmrn_lock_loss = KumeranLockLoss[bd]; e1000_validate_option(&kmrn_lock_loss, &opt, adapter); if (hw->mac.type == e1000_ich8lan) e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, diff --git a/trunk/drivers/net/eexpress.c b/trunk/drivers/net/eexpress.c index 70509ed6c11d..9c85e50014b4 100644 --- a/trunk/drivers/net/eexpress.c +++ b/trunk/drivers/net/eexpress.c @@ -651,9 +651,9 @@ static void eexp_timeout(struct net_device *dev) */ static int eexp_xmit(struct sk_buff *buf, struct net_device *dev) { + struct net_local *lp = netdev_priv(dev); short length = buf->len; #ifdef CONFIG_SMP - struct net_local *lp = netdev_priv(dev); unsigned long flags; #endif diff --git a/trunk/drivers/net/ehea/ehea.h b/trunk/drivers/net/ehea/ehea.h index f78e5bf7cb33..b557bb44a36f 100644 --- a/trunk/drivers/net/ehea/ehea.h +++ b/trunk/drivers/net/ehea/ehea.h @@ -40,7 +40,7 @@ #include #define DRV_NAME "ehea" -#define DRV_VERSION "EHEA_0080" +#define DRV_VERSION "EHEA_0078" /* eHEA capability flags */ #define DLPAR_PORT_ADD_REM 1 diff --git a/trunk/drivers/net/ehea/ehea_main.c b/trunk/drivers/net/ehea/ehea_main.c index f0319f1e8e05..2809c99906e0 100644 --- a/trunk/drivers/net/ehea/ehea_main.c +++ b/trunk/drivers/net/ehea/ehea_main.c @@ -33,9 +33,6 @@ #include #include #include -#include -#include - #include #include "ehea.h" @@ -2332,7 +2329,7 @@ static void port_napi_disable(struct ehea_port *port) { int i; - for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) + for (i = 0; i < port->num_def_qps; i++) napi_disable(&port->port_res[i].napi); } @@ -2340,7 +2337,7 @@ static void port_napi_enable(struct ehea_port *port) { int i; - for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) + for (i = 0; i < port->num_def_qps; i++) napi_enable(&port->port_res[i].napi); } @@ -2376,6 +2373,8 @@ static int ehea_down(struct net_device *dev) ehea_drop_multicast_list(dev); ehea_free_interrupts(dev); + port_napi_disable(port); + port->state = EHEA_PORT_DOWN; ret = ehea_clean_all_portres(port); @@ -2397,7 +2396,6 @@ static int ehea_stop(struct net_device *dev) flush_scheduled_work(); down(&port->port_lock); netif_stop_queue(dev); - port_napi_disable(port); ret = ehea_down(dev); up(&port->port_lock); return ret; @@ -3298,20 +3296,6 @@ static int __devexit ehea_remove(struct of_device *dev) return 0; } -static int ehea_reboot_notifier(struct notifier_block *nb, - unsigned long action, void *unused) -{ - if (action == SYS_RESTART) { - ehea_info("Reboot: freeing all eHEA resources"); - ibmebus_unregister_driver(&ehea_driver); - } - return NOTIFY_DONE; -} - -static struct notifier_block ehea_reboot_nb = { - .notifier_call = ehea_reboot_notifier, -}; - static int check_module_parm(void) { int ret = 0; @@ -3368,8 +3352,6 @@ int __init ehea_module_init(void) if (ret) goto out; - register_reboot_notifier(&ehea_reboot_nb); - ret = ibmebus_register_driver(&ehea_driver); if (ret) { ehea_error("failed registering eHEA device driver on ebus"); @@ -3381,7 +3363,6 @@ int __init ehea_module_init(void) if (ret) { ehea_error("failed to register capabilities attribute, ret=%d", ret); - unregister_reboot_notifier(&ehea_reboot_nb); ibmebus_unregister_driver(&ehea_driver); goto out; } @@ -3395,7 +3376,6 @@ static void __exit ehea_module_exit(void) flush_scheduled_work(); driver_remove_file(&ehea_driver.driver, &driver_attr_capabilities); ibmebus_unregister_driver(&ehea_driver); - unregister_reboot_notifier(&ehea_reboot_nb); ehea_destroy_busmap(); } diff --git a/trunk/drivers/net/fec_mpc52xx.c b/trunk/drivers/net/fec_mpc52xx.c deleted file mode 100644 index fc1cf0b742b0..000000000000 --- a/trunk/drivers/net/fec_mpc52xx.c +++ /dev/null @@ -1,1112 +0,0 @@ -/* - * Driver for the MPC5200 Fast Ethernet Controller - * - * Originally written by Dale Farnsworth and - * now maintained by Sylvain Munaut - * - * Copyright (C) 2007 Domen Puncer, Telargo, Inc. - * Copyright (C) 2007 Sylvain Munaut - * Copyright (C) 2003-2004 MontaVista, Software, Inc. - * - * This file is licensed under the terms of the GNU General Public License - * version 2. This program is licensed "as is" without any warranty of any - * kind, whether express or implied. - * - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include "fec_mpc52xx.h" - -#define DRIVER_NAME "mpc52xx-fec" - -static irqreturn_t mpc52xx_fec_interrupt(int, void *); -static irqreturn_t mpc52xx_fec_rx_interrupt(int, void *); -static irqreturn_t mpc52xx_fec_tx_interrupt(int, void *); -static void mpc52xx_fec_stop(struct net_device *dev); -static void mpc52xx_fec_start(struct net_device *dev); -static void mpc52xx_fec_reset(struct net_device *dev); - -static u8 mpc52xx_fec_mac_addr[6]; -module_param_array_named(mac, mpc52xx_fec_mac_addr, byte, NULL, 0); -MODULE_PARM_DESC(mac, "six hex digits, ie. 0x1,0x2,0xc0,0x01,0xba,0xbe"); - -#define MPC52xx_MESSAGES_DEFAULT ( NETIF_MSG_DRV | NETIF_MSG_PROBE | \ - NETIF_MSG_LINK | NETIF_MSG_IFDOWN | NETIF_MSG_IFDOWN ) -static int debug = -1; /* the above default */ -module_param(debug, int, 0); -MODULE_PARM_DESC(debug, "debugging messages level"); - -static void mpc52xx_fec_tx_timeout(struct net_device *dev) -{ - dev_warn(&dev->dev, "transmit timed out\n"); - - mpc52xx_fec_reset(dev); - - dev->stats.tx_errors++; - - netif_wake_queue(dev); -} - -static void mpc52xx_fec_set_paddr(struct net_device *dev, u8 *mac) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - struct mpc52xx_fec __iomem *fec = priv->fec; - - out_be32(&fec->paddr1, *(u32 *)(&mac[0])); - out_be32(&fec->paddr2, (*(u16 *)(&mac[4]) << 16) | FEC_PADDR2_TYPE); -} - -static void mpc52xx_fec_get_paddr(struct net_device *dev, u8 *mac) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - struct mpc52xx_fec __iomem *fec = priv->fec; - - *(u32 *)(&mac[0]) = in_be32(&fec->paddr1); - *(u16 *)(&mac[4]) = in_be32(&fec->paddr2) >> 16; -} - -static int mpc52xx_fec_set_mac_address(struct net_device *dev, void *addr) -{ - struct sockaddr *sock = addr; - - memcpy(dev->dev_addr, sock->sa_data, dev->addr_len); - - mpc52xx_fec_set_paddr(dev, sock->sa_data); - return 0; -} - -static void mpc52xx_fec_free_rx_buffers(struct net_device *dev, struct bcom_task *s) -{ - while (!bcom_queue_empty(s)) { - struct bcom_fec_bd *bd; - struct sk_buff *skb; - - skb = bcom_retrieve_buffer(s, NULL, (struct bcom_bd **)&bd); - dma_unmap_single(&dev->dev, bd->skb_pa, skb->len, DMA_FROM_DEVICE); - kfree_skb(skb); - } -} - -static int mpc52xx_fec_alloc_rx_buffers(struct net_device *dev, struct bcom_task *rxtsk) -{ - while (!bcom_queue_full(rxtsk)) { - struct sk_buff *skb; - struct bcom_fec_bd *bd; - - skb = dev_alloc_skb(FEC_RX_BUFFER_SIZE); - if (skb == NULL) - return -EAGAIN; - - /* zero out the initial receive buffers to aid debugging */ - memset(skb->data, 0, FEC_RX_BUFFER_SIZE); - - bd = (struct bcom_fec_bd *)bcom_prepare_next_buffer(rxtsk); - - bd->status = FEC_RX_BUFFER_SIZE; - bd->skb_pa = dma_map_single(&dev->dev, skb->data, - FEC_RX_BUFFER_SIZE, DMA_FROM_DEVICE); - - bcom_submit_next_buffer(rxtsk, skb); - } - - return 0; -} - -/* based on generic_adjust_link from fs_enet-main.c */ -static void mpc52xx_fec_adjust_link(struct net_device *dev) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - struct phy_device *phydev = priv->phydev; - int new_state = 0; - - if (phydev->link != PHY_DOWN) { - if (phydev->duplex != priv->duplex) { - struct mpc52xx_fec __iomem *fec = priv->fec; - u32 rcntrl; - u32 tcntrl; - - new_state = 1; - priv->duplex = phydev->duplex; - - rcntrl = in_be32(&fec->r_cntrl); - tcntrl = in_be32(&fec->x_cntrl); - - rcntrl &= ~FEC_RCNTRL_DRT; - tcntrl &= ~FEC_TCNTRL_FDEN; - if (phydev->duplex == DUPLEX_FULL) - tcntrl |= FEC_TCNTRL_FDEN; /* FD enable */ - else - rcntrl |= FEC_RCNTRL_DRT; /* disable Rx on Tx (HD) */ - - out_be32(&fec->r_cntrl, rcntrl); - out_be32(&fec->x_cntrl, tcntrl); - } - - if (phydev->speed != priv->speed) { - new_state = 1; - priv->speed = phydev->speed; - } - - if (priv->link == PHY_DOWN) { - new_state = 1; - priv->link = phydev->link; - netif_schedule(dev); - netif_carrier_on(dev); - netif_start_queue(dev); - } - - } else if (priv->link) { - new_state = 1; - priv->link = PHY_DOWN; - priv->speed = 0; - priv->duplex = -1; - netif_stop_queue(dev); - netif_carrier_off(dev); - } - - if (new_state && netif_msg_link(priv)) - phy_print_status(phydev); -} - -static int mpc52xx_fec_init_phy(struct net_device *dev) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - struct phy_device *phydev; - char phy_id[BUS_ID_SIZE]; - - snprintf(phy_id, BUS_ID_SIZE, PHY_ID_FMT, - (unsigned int)dev->base_addr, priv->phy_addr); - - priv->link = PHY_DOWN; - priv->speed = 0; - priv->duplex = -1; - - phydev = phy_connect(dev, phy_id, &mpc52xx_fec_adjust_link, 0, PHY_INTERFACE_MODE_MII); - if (IS_ERR(phydev)) { - dev_err(&dev->dev, "phy_connect failed\n"); - return PTR_ERR(phydev); - } - dev_info(&dev->dev, "attached phy %i to driver %s\n", - phydev->addr, phydev->drv->name); - - priv->phydev = phydev; - - return 0; -} - -static int mpc52xx_fec_phy_start(struct net_device *dev) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - int err; - - if (!priv->has_phy) - return 0; - - err = mpc52xx_fec_init_phy(dev); - if (err) { - dev_err(&dev->dev, "mpc52xx_fec_init_phy failed\n"); - return err; - } - - /* reset phy - this also wakes it from PDOWN */ - phy_write(priv->phydev, MII_BMCR, BMCR_RESET); - phy_start(priv->phydev); - - return 0; -} - -static void mpc52xx_fec_phy_stop(struct net_device *dev) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - - if (!priv->has_phy) - return; - - phy_disconnect(priv->phydev); - /* power down phy */ - phy_stop(priv->phydev); - phy_write(priv->phydev, MII_BMCR, BMCR_PDOWN); -} - -static int mpc52xx_fec_phy_mii_ioctl(struct mpc52xx_fec_priv *priv, - struct mii_ioctl_data *mii_data, int cmd) -{ - if (!priv->has_phy) - return -ENOTSUPP; - - return phy_mii_ioctl(priv->phydev, mii_data, cmd); -} - -static void mpc52xx_fec_phy_hw_init(struct mpc52xx_fec_priv *priv) -{ - struct mpc52xx_fec __iomem *fec = priv->fec; - - if (!priv->has_phy) - return; - - out_be32(&fec->mii_speed, priv->phy_speed); -} - -static int mpc52xx_fec_open(struct net_device *dev) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - int err = -EBUSY; - - if (request_irq(dev->irq, &mpc52xx_fec_interrupt, IRQF_SHARED, - DRIVER_NAME "_ctrl", dev)) { - dev_err(&dev->dev, "ctrl interrupt request failed\n"); - goto out; - } - if (request_irq(priv->r_irq, &mpc52xx_fec_rx_interrupt, 0, - DRIVER_NAME "_rx", dev)) { - dev_err(&dev->dev, "rx interrupt request failed\n"); - goto free_ctrl_irq; - } - if (request_irq(priv->t_irq, &mpc52xx_fec_tx_interrupt, 0, - DRIVER_NAME "_tx", dev)) { - dev_err(&dev->dev, "tx interrupt request failed\n"); - goto free_2irqs; - } - - bcom_fec_rx_reset(priv->rx_dmatsk); - bcom_fec_tx_reset(priv->tx_dmatsk); - - err = mpc52xx_fec_alloc_rx_buffers(dev, priv->rx_dmatsk); - if (err) { - dev_err(&dev->dev, "mpc52xx_fec_alloc_rx_buffers failed\n"); - goto free_irqs; - } - - err = mpc52xx_fec_phy_start(dev); - if (err) - goto free_skbs; - - bcom_enable(priv->rx_dmatsk); - bcom_enable(priv->tx_dmatsk); - - mpc52xx_fec_start(dev); - - netif_start_queue(dev); - - return 0; - - free_skbs: - mpc52xx_fec_free_rx_buffers(dev, priv->rx_dmatsk); - - free_irqs: - free_irq(priv->t_irq, dev); - free_2irqs: - free_irq(priv->r_irq, dev); - free_ctrl_irq: - free_irq(dev->irq, dev); - out: - - return err; -} - -static int mpc52xx_fec_close(struct net_device *dev) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - - netif_stop_queue(dev); - - mpc52xx_fec_stop(dev); - - mpc52xx_fec_free_rx_buffers(dev, priv->rx_dmatsk); - - free_irq(dev->irq, dev); - free_irq(priv->r_irq, dev); - free_irq(priv->t_irq, dev); - - mpc52xx_fec_phy_stop(dev); - - return 0; -} - -/* This will only be invoked if your driver is _not_ in XOFF state. - * What this means is that you need not check it, and that this - * invariant will hold if you make sure that the netif_*_queue() - * calls are done at the proper times. - */ -static int mpc52xx_fec_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - struct bcom_fec_bd *bd; - - if (bcom_queue_full(priv->tx_dmatsk)) { - if (net_ratelimit()) - dev_err(&dev->dev, "transmit queue overrun\n"); - return 1; - } - - spin_lock_irq(&priv->lock); - dev->trans_start = jiffies; - - bd = (struct bcom_fec_bd *) - bcom_prepare_next_buffer(priv->tx_dmatsk); - - bd->status = skb->len | BCOM_FEC_TX_BD_TFD | BCOM_FEC_TX_BD_TC; - bd->skb_pa = dma_map_single(&dev->dev, skb->data, skb->len, DMA_TO_DEVICE); - - bcom_submit_next_buffer(priv->tx_dmatsk, skb); - - if (bcom_queue_full(priv->tx_dmatsk)) { - netif_stop_queue(dev); - } - - spin_unlock_irq(&priv->lock); - - return 0; -} - -/* This handles BestComm transmit task interrupts - */ -static irqreturn_t mpc52xx_fec_tx_interrupt(int irq, void *dev_id) -{ - struct net_device *dev = dev_id; - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - - spin_lock(&priv->lock); - - while (bcom_buffer_done(priv->tx_dmatsk)) { - struct sk_buff *skb; - struct bcom_fec_bd *bd; - skb = bcom_retrieve_buffer(priv->tx_dmatsk, NULL, - (struct bcom_bd **)&bd); - dma_unmap_single(&dev->dev, bd->skb_pa, skb->len, DMA_TO_DEVICE); - - dev_kfree_skb_irq(skb); - } - - netif_wake_queue(dev); - - spin_unlock(&priv->lock); - - return IRQ_HANDLED; -} - -static irqreturn_t mpc52xx_fec_rx_interrupt(int irq, void *dev_id) -{ - struct net_device *dev = dev_id; - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - - while (bcom_buffer_done(priv->rx_dmatsk)) { - struct sk_buff *skb; - struct sk_buff *rskb; - struct bcom_fec_bd *bd; - u32 status; - - rskb = bcom_retrieve_buffer(priv->rx_dmatsk, &status, - (struct bcom_bd **)&bd); - dma_unmap_single(&dev->dev, bd->skb_pa, skb->len, DMA_FROM_DEVICE); - - /* Test for errors in received frame */ - if (status & BCOM_FEC_RX_BD_ERRORS) { - /* Drop packet and reuse the buffer */ - bd = (struct bcom_fec_bd *) - bcom_prepare_next_buffer(priv->rx_dmatsk); - - bd->status = FEC_RX_BUFFER_SIZE; - bd->skb_pa = dma_map_single(&dev->dev, rskb->data, - FEC_RX_BUFFER_SIZE, DMA_FROM_DEVICE); - - bcom_submit_next_buffer(priv->rx_dmatsk, rskb); - - dev->stats.rx_dropped++; - - continue; - } - - /* skbs are allocated on open, so now we allocate a new one, - * and remove the old (with the packet) */ - skb = dev_alloc_skb(FEC_RX_BUFFER_SIZE); - if (skb) { - /* Process the received skb */ - int length = status & BCOM_FEC_RX_BD_LEN_MASK; - - skb_put(rskb, length - 4); /* length without CRC32 */ - - rskb->dev = dev; - rskb->protocol = eth_type_trans(rskb, dev); - - netif_rx(rskb); - dev->last_rx = jiffies; - } else { - /* Can't get a new one : reuse the same & drop pkt */ - dev_notice(&dev->dev, "Memory squeeze, dropping packet.\n"); - dev->stats.rx_dropped++; - - skb = rskb; - } - - bd = (struct bcom_fec_bd *) - bcom_prepare_next_buffer(priv->rx_dmatsk); - - bd->status = FEC_RX_BUFFER_SIZE; - bd->skb_pa = dma_map_single(&dev->dev, rskb->data, - FEC_RX_BUFFER_SIZE, DMA_FROM_DEVICE); - - bcom_submit_next_buffer(priv->rx_dmatsk, skb); - } - - return IRQ_HANDLED; -} - -static irqreturn_t mpc52xx_fec_interrupt(int irq, void *dev_id) -{ - struct net_device *dev = dev_id; - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - struct mpc52xx_fec __iomem *fec = priv->fec; - u32 ievent; - - ievent = in_be32(&fec->ievent); - - ievent &= ~FEC_IEVENT_MII; /* mii is handled separately */ - if (!ievent) - return IRQ_NONE; - - out_be32(&fec->ievent, ievent); /* clear pending events */ - - if (ievent & ~(FEC_IEVENT_RFIFO_ERROR | FEC_IEVENT_XFIFO_ERROR)) { - if (ievent & ~FEC_IEVENT_TFINT) - dev_dbg(&dev->dev, "ievent: %08x\n", ievent); - return IRQ_HANDLED; - } - - if (net_ratelimit() && (ievent & FEC_IEVENT_RFIFO_ERROR)) - dev_warn(&dev->dev, "FEC_IEVENT_RFIFO_ERROR\n"); - if (net_ratelimit() && (ievent & FEC_IEVENT_XFIFO_ERROR)) - dev_warn(&dev->dev, "FEC_IEVENT_XFIFO_ERROR\n"); - - mpc52xx_fec_reset(dev); - - netif_wake_queue(dev); - return IRQ_HANDLED; -} - -/* - * Get the current statistics. - * This may be called with the card open or closed. - */ -static struct net_device_stats *mpc52xx_fec_get_stats(struct net_device *dev) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - struct net_device_stats *stats = &dev->stats; - struct mpc52xx_fec __iomem *fec = priv->fec; - - stats->rx_bytes = in_be32(&fec->rmon_r_octets); - stats->rx_packets = in_be32(&fec->rmon_r_packets); - stats->rx_errors = in_be32(&fec->rmon_r_crc_align) + - in_be32(&fec->rmon_r_undersize) + - in_be32(&fec->rmon_r_oversize) + - in_be32(&fec->rmon_r_frag) + - in_be32(&fec->rmon_r_jab); - - stats->tx_bytes = in_be32(&fec->rmon_t_octets); - stats->tx_packets = in_be32(&fec->rmon_t_packets); - stats->tx_errors = in_be32(&fec->rmon_t_crc_align) + - in_be32(&fec->rmon_t_undersize) + - in_be32(&fec->rmon_t_oversize) + - in_be32(&fec->rmon_t_frag) + - in_be32(&fec->rmon_t_jab); - - stats->multicast = in_be32(&fec->rmon_r_mc_pkt); - stats->collisions = in_be32(&fec->rmon_t_col); - - /* detailed rx_errors: */ - stats->rx_length_errors = in_be32(&fec->rmon_r_undersize) - + in_be32(&fec->rmon_r_oversize) - + in_be32(&fec->rmon_r_frag) - + in_be32(&fec->rmon_r_jab); - stats->rx_over_errors = in_be32(&fec->r_macerr); - stats->rx_crc_errors = in_be32(&fec->ieee_r_crc); - stats->rx_frame_errors = in_be32(&fec->ieee_r_align); - stats->rx_fifo_errors = in_be32(&fec->rmon_r_drop); - stats->rx_missed_errors = in_be32(&fec->rmon_r_drop); - - /* detailed tx_errors: */ - stats->tx_aborted_errors = 0; - stats->tx_carrier_errors = in_be32(&fec->ieee_t_cserr); - stats->tx_fifo_errors = in_be32(&fec->rmon_t_drop); - stats->tx_heartbeat_errors = in_be32(&fec->ieee_t_sqe); - stats->tx_window_errors = in_be32(&fec->ieee_t_lcol); - - return stats; -} - -/* - * Read MIB counters in order to reset them, - * then zero all the stats fields in memory - */ -static void mpc52xx_fec_reset_stats(struct net_device *dev) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - struct mpc52xx_fec __iomem *fec = priv->fec; - - out_be32(&fec->mib_control, FEC_MIB_DISABLE); - memset_io(&fec->rmon_t_drop, 0, (__force u32)&fec->reserved10 - - (__force u32)&fec->rmon_t_drop); - out_be32(&fec->mib_control, 0); - - memset(&dev->stats, 0, sizeof(dev->stats)); -} - -/* - * Set or clear the multicast filter for this adaptor. - */ -static void mpc52xx_fec_set_multicast_list(struct net_device *dev) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - struct mpc52xx_fec __iomem *fec = priv->fec; - u32 rx_control; - - rx_control = in_be32(&fec->r_cntrl); - - if (dev->flags & IFF_PROMISC) { - rx_control |= FEC_RCNTRL_PROM; - out_be32(&fec->r_cntrl, rx_control); - } else { - rx_control &= ~FEC_RCNTRL_PROM; - out_be32(&fec->r_cntrl, rx_control); - - if (dev->flags & IFF_ALLMULTI) { - out_be32(&fec->gaddr1, 0xffffffff); - out_be32(&fec->gaddr2, 0xffffffff); - } else { - u32 crc; - int i; - struct dev_mc_list *dmi; - u32 gaddr1 = 0x00000000; - u32 gaddr2 = 0x00000000; - - dmi = dev->mc_list; - for (i=0; imc_count; i++) { - crc = ether_crc_le(6, dmi->dmi_addr) >> 26; - if (crc >= 32) - gaddr1 |= 1 << (crc-32); - else - gaddr2 |= 1 << crc; - dmi = dmi->next; - } - out_be32(&fec->gaddr1, gaddr1); - out_be32(&fec->gaddr2, gaddr2); - } - } -} - -/** - * mpc52xx_fec_hw_init - * @dev: network device - * - * Setup various hardware setting, only needed once on start - */ -static void mpc52xx_fec_hw_init(struct net_device *dev) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - struct mpc52xx_fec __iomem *fec = priv->fec; - int i; - - /* Whack a reset. We should wait for this. */ - out_be32(&fec->ecntrl, FEC_ECNTRL_RESET); - for (i = 0; i < FEC_RESET_DELAY; ++i) { - if ((in_be32(&fec->ecntrl) & FEC_ECNTRL_RESET) == 0) - break; - udelay(1); - } - if (i == FEC_RESET_DELAY) - dev_err(&dev->dev, "FEC Reset timeout!\n"); - - /* set pause to 0x20 frames */ - out_be32(&fec->op_pause, FEC_OP_PAUSE_OPCODE | 0x20); - - /* high service request will be deasserted when there's < 7 bytes in fifo - * low service request will be deasserted when there's < 4*7 bytes in fifo - */ - out_be32(&fec->rfifo_cntrl, FEC_FIFO_CNTRL_FRAME | FEC_FIFO_CNTRL_LTG_7); - out_be32(&fec->tfifo_cntrl, FEC_FIFO_CNTRL_FRAME | FEC_FIFO_CNTRL_LTG_7); - - /* alarm when <= x bytes in FIFO */ - out_be32(&fec->rfifo_alarm, 0x0000030c); - out_be32(&fec->tfifo_alarm, 0x00000100); - - /* begin transmittion when 256 bytes are in FIFO (or EOF or FIFO full) */ - out_be32(&fec->x_wmrk, FEC_FIFO_WMRK_256B); - - /* enable crc generation */ - out_be32(&fec->xmit_fsm, FEC_XMIT_FSM_APPEND_CRC | FEC_XMIT_FSM_ENABLE_CRC); - out_be32(&fec->iaddr1, 0x00000000); /* No individual filter */ - out_be32(&fec->iaddr2, 0x00000000); /* No individual filter */ - - /* set phy speed. - * this can't be done in phy driver, since it needs to be called - * before fec stuff (even on resume) */ - mpc52xx_fec_phy_hw_init(priv); -} - -/** - * mpc52xx_fec_start - * @dev: network device - * - * This function is called to start or restart the FEC during a link - * change. This happens on fifo errors or when switching between half - * and full duplex. - */ -static void mpc52xx_fec_start(struct net_device *dev) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - struct mpc52xx_fec __iomem *fec = priv->fec; - u32 rcntrl; - u32 tcntrl; - u32 tmp; - - /* clear sticky error bits */ - tmp = FEC_FIFO_STATUS_ERR | FEC_FIFO_STATUS_UF | FEC_FIFO_STATUS_OF; - out_be32(&fec->rfifo_status, in_be32(&fec->rfifo_status) & tmp); - out_be32(&fec->tfifo_status, in_be32(&fec->tfifo_status) & tmp); - - /* FIFOs will reset on mpc52xx_fec_enable */ - out_be32(&fec->reset_cntrl, FEC_RESET_CNTRL_ENABLE_IS_RESET); - - /* Set station address. */ - mpc52xx_fec_set_paddr(dev, dev->dev_addr); - - mpc52xx_fec_set_multicast_list(dev); - - /* set max frame len, enable flow control, select mii mode */ - rcntrl = FEC_RX_BUFFER_SIZE << 16; /* max frame length */ - rcntrl |= FEC_RCNTRL_FCE; - - if (priv->has_phy) - rcntrl |= FEC_RCNTRL_MII_MODE; - - if (priv->duplex == DUPLEX_FULL) - tcntrl = FEC_TCNTRL_FDEN; /* FD enable */ - else { - rcntrl |= FEC_RCNTRL_DRT; /* disable Rx on Tx (HD) */ - tcntrl = 0; - } - out_be32(&fec->r_cntrl, rcntrl); - out_be32(&fec->x_cntrl, tcntrl); - - /* Clear any outstanding interrupt. */ - out_be32(&fec->ievent, 0xffffffff); - - /* Enable interrupts we wish to service. */ - out_be32(&fec->imask, FEC_IMASK_ENABLE); - - /* And last, enable the transmit and receive processing. */ - out_be32(&fec->ecntrl, FEC_ECNTRL_ETHER_EN); - out_be32(&fec->r_des_active, 0x01000000); -} - -/** - * mpc52xx_fec_stop - * @dev: network device - * - * stop all activity on fec and empty dma buffers - */ -static void mpc52xx_fec_stop(struct net_device *dev) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - struct mpc52xx_fec __iomem *fec = priv->fec; - unsigned long timeout; - - /* disable all interrupts */ - out_be32(&fec->imask, 0); - - /* Disable the rx task. */ - bcom_disable(priv->rx_dmatsk); - - /* Wait for tx queue to drain, but only if we're in process context */ - if (!in_interrupt()) { - timeout = jiffies + msecs_to_jiffies(2000); - while (time_before(jiffies, timeout) && - !bcom_queue_empty(priv->tx_dmatsk)) - msleep(100); - - if (time_after_eq(jiffies, timeout)) - dev_err(&dev->dev, "queues didn't drain\n"); -#if 1 - if (time_after_eq(jiffies, timeout)) { - dev_err(&dev->dev, " tx: index: %i, outdex: %i\n", - priv->tx_dmatsk->index, - priv->tx_dmatsk->outdex); - dev_err(&dev->dev, " rx: index: %i, outdex: %i\n", - priv->rx_dmatsk->index, - priv->rx_dmatsk->outdex); - } -#endif - } - - bcom_disable(priv->tx_dmatsk); - - /* Stop FEC */ - out_be32(&fec->ecntrl, in_be32(&fec->ecntrl) & ~FEC_ECNTRL_ETHER_EN); - - return; -} - -/* reset fec and bestcomm tasks */ -static void mpc52xx_fec_reset(struct net_device *dev) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - struct mpc52xx_fec __iomem *fec = priv->fec; - - mpc52xx_fec_stop(dev); - - out_be32(&fec->rfifo_status, in_be32(&fec->rfifo_status)); - out_be32(&fec->reset_cntrl, FEC_RESET_CNTRL_RESET_FIFO); - - mpc52xx_fec_free_rx_buffers(dev, priv->rx_dmatsk); - - mpc52xx_fec_hw_init(dev); - - phy_stop(priv->phydev); - phy_write(priv->phydev, MII_BMCR, BMCR_RESET); - phy_start(priv->phydev); - - bcom_fec_rx_reset(priv->rx_dmatsk); - bcom_fec_tx_reset(priv->tx_dmatsk); - - mpc52xx_fec_alloc_rx_buffers(dev, priv->rx_dmatsk); - - bcom_enable(priv->rx_dmatsk); - bcom_enable(priv->tx_dmatsk); - - mpc52xx_fec_start(dev); -} - - -/* ethtool interface */ -static void mpc52xx_fec_get_drvinfo(struct net_device *dev, - struct ethtool_drvinfo *info) -{ - strcpy(info->driver, DRIVER_NAME); -} - -static int mpc52xx_fec_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - return phy_ethtool_gset(priv->phydev, cmd); -} - -static int mpc52xx_fec_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - return phy_ethtool_sset(priv->phydev, cmd); -} - -static u32 mpc52xx_fec_get_msglevel(struct net_device *dev) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - return priv->msg_enable; -} - -static void mpc52xx_fec_set_msglevel(struct net_device *dev, u32 level) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - priv->msg_enable = level; -} - -static const struct ethtool_ops mpc52xx_fec_ethtool_ops = { - .get_drvinfo = mpc52xx_fec_get_drvinfo, - .get_settings = mpc52xx_fec_get_settings, - .set_settings = mpc52xx_fec_set_settings, - .get_link = ethtool_op_get_link, - .get_msglevel = mpc52xx_fec_get_msglevel, - .set_msglevel = mpc52xx_fec_set_msglevel, -}; - - -static int mpc52xx_fec_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) -{ - struct mpc52xx_fec_priv *priv = netdev_priv(dev); - - return mpc52xx_fec_phy_mii_ioctl(priv, if_mii(rq), cmd); -} - -/* ======================================================================== */ -/* OF Driver */ -/* ======================================================================== */ - -static int __devinit -mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match) -{ - int rv; - struct net_device *ndev; - struct mpc52xx_fec_priv *priv = NULL; - struct resource mem; - const phandle *ph; - - phys_addr_t rx_fifo; - phys_addr_t tx_fifo; - - /* Get the ether ndev & it's private zone */ - ndev = alloc_etherdev(sizeof(struct mpc52xx_fec_priv)); - if (!ndev) - return -ENOMEM; - - priv = netdev_priv(ndev); - - /* Reserve FEC control zone */ - rv = of_address_to_resource(op->node, 0, &mem); - if (rv) { - printk(KERN_ERR DRIVER_NAME ": " - "Error while parsing device node resource\n" ); - return rv; - } - if ((mem.end - mem.start + 1) != sizeof(struct mpc52xx_fec)) { - printk(KERN_ERR DRIVER_NAME - " - invalid resource size (%lx != %x), check mpc52xx_devices.c\n", - (unsigned long)(mem.end - mem.start + 1), sizeof(struct mpc52xx_fec)); - return -EINVAL; - } - - if (!request_mem_region(mem.start, sizeof(struct mpc52xx_fec), DRIVER_NAME)) - return -EBUSY; - - /* Init ether ndev with what we have */ - ndev->open = mpc52xx_fec_open; - ndev->stop = mpc52xx_fec_close; - ndev->hard_start_xmit = mpc52xx_fec_hard_start_xmit; - ndev->do_ioctl = mpc52xx_fec_ioctl; - ndev->ethtool_ops = &mpc52xx_fec_ethtool_ops; - ndev->get_stats = mpc52xx_fec_get_stats; - ndev->set_mac_address = mpc52xx_fec_set_mac_address; - ndev->set_multicast_list = mpc52xx_fec_set_multicast_list; - ndev->tx_timeout = mpc52xx_fec_tx_timeout; - ndev->watchdog_timeo = FEC_WATCHDOG_TIMEOUT; - ndev->base_addr = mem.start; - - priv->t_irq = priv->r_irq = ndev->irq = NO_IRQ; /* IRQ are free for now */ - - spin_lock_init(&priv->lock); - - /* ioremap the zones */ - priv->fec = ioremap(mem.start, sizeof(struct mpc52xx_fec)); - - if (!priv->fec) { - rv = -ENOMEM; - goto probe_error; - } - - /* Bestcomm init */ - rx_fifo = ndev->base_addr + offsetof(struct mpc52xx_fec, rfifo_data); - tx_fifo = ndev->base_addr + offsetof(struct mpc52xx_fec, tfifo_data); - - priv->rx_dmatsk = bcom_fec_rx_init(FEC_RX_NUM_BD, rx_fifo, FEC_RX_BUFFER_SIZE); - priv->tx_dmatsk = bcom_fec_tx_init(FEC_TX_NUM_BD, tx_fifo); - - if (!priv->rx_dmatsk || !priv->tx_dmatsk) { - printk(KERN_ERR DRIVER_NAME ": Can not init SDMA tasks\n" ); - rv = -ENOMEM; - goto probe_error; - } - - /* Get the IRQ we need one by one */ - /* Control */ - ndev->irq = irq_of_parse_and_map(op->node, 0); - - /* RX */ - priv->r_irq = bcom_get_task_irq(priv->rx_dmatsk); - - /* TX */ - priv->t_irq = bcom_get_task_irq(priv->tx_dmatsk); - - /* MAC address init */ - if (!is_zero_ether_addr(mpc52xx_fec_mac_addr)) - memcpy(ndev->dev_addr, mpc52xx_fec_mac_addr, 6); - else - mpc52xx_fec_get_paddr(ndev, ndev->dev_addr); - - priv->msg_enable = netif_msg_init(debug, MPC52xx_MESSAGES_DEFAULT); - priv->duplex = DUPLEX_FULL; - - /* is the phy present in device tree? */ - ph = of_get_property(op->node, "phy-handle", NULL); - if (ph) { - const unsigned int *prop; - struct device_node *phy_dn; - priv->has_phy = 1; - - phy_dn = of_find_node_by_phandle(*ph); - prop = of_get_property(phy_dn, "reg", NULL); - priv->phy_addr = *prop; - - of_node_put(phy_dn); - - /* Phy speed */ - priv->phy_speed = ((mpc52xx_find_ipb_freq(op->node) >> 20) / 5) << 1; - } else { - dev_info(&ndev->dev, "can't find \"phy-handle\" in device" - " tree, using 7-wire mode\n"); - } - - /* Hardware init */ - mpc52xx_fec_hw_init(ndev); - - mpc52xx_fec_reset_stats(ndev); - - /* Register the new network device */ - rv = register_netdev(ndev); - if (rv < 0) - goto probe_error; - - /* We're done ! */ - dev_set_drvdata(&op->dev, ndev); - - return 0; - - - /* Error handling - free everything that might be allocated */ -probe_error: - - irq_dispose_mapping(ndev->irq); - - if (priv->rx_dmatsk) - bcom_fec_rx_release(priv->rx_dmatsk); - if (priv->tx_dmatsk) - bcom_fec_tx_release(priv->tx_dmatsk); - - if (priv->fec) - iounmap(priv->fec); - - release_mem_region(mem.start, sizeof(struct mpc52xx_fec)); - - free_netdev(ndev); - - return rv; -} - -static int -mpc52xx_fec_remove(struct of_device *op) -{ - struct net_device *ndev; - struct mpc52xx_fec_priv *priv; - - ndev = dev_get_drvdata(&op->dev); - priv = netdev_priv(ndev); - - unregister_netdev(ndev); - - irq_dispose_mapping(ndev->irq); - - bcom_fec_rx_release(priv->rx_dmatsk); - bcom_fec_tx_release(priv->tx_dmatsk); - - iounmap(priv->fec); - - release_mem_region(ndev->base_addr, sizeof(struct mpc52xx_fec)); - - free_netdev(ndev); - - dev_set_drvdata(&op->dev, NULL); - return 0; -} - -#ifdef CONFIG_PM -static int mpc52xx_fec_of_suspend(struct of_device *op, pm_message_t state) -{ - struct net_device *dev = dev_get_drvdata(&op->dev); - - if (netif_running(dev)) - mpc52xx_fec_close(dev); - - return 0; -} - -static int mpc52xx_fec_of_resume(struct of_device *op) -{ - struct net_device *dev = dev_get_drvdata(&op->dev); - - mpc52xx_fec_hw_init(dev); - mpc52xx_fec_reset_stats(dev); - - if (netif_running(dev)) - mpc52xx_fec_open(dev); - - return 0; -} -#endif - -static struct of_device_id mpc52xx_fec_match[] = { - { - .type = "network", - .compatible = "mpc5200-fec", - }, - { } -}; - -MODULE_DEVICE_TABLE(of, mpc52xx_fec_match); - -static struct of_platform_driver mpc52xx_fec_driver = { - .owner = THIS_MODULE, - .name = DRIVER_NAME, - .match_table = mpc52xx_fec_match, - .probe = mpc52xx_fec_probe, - .remove = mpc52xx_fec_remove, -#ifdef CONFIG_PM - .suspend = mpc52xx_fec_of_suspend, - .resume = mpc52xx_fec_of_resume, -#endif -}; - - -/* ======================================================================== */ -/* Module */ -/* ======================================================================== */ - -static int __init -mpc52xx_fec_init(void) -{ -#ifdef CONFIG_FEC_MPC52xx_MDIO - int ret; - ret = of_register_platform_driver(&mpc52xx_fec_mdio_driver); - if (ret) { - printk(KERN_ERR DRIVER_NAME ": failed to register mdio driver\n"); - return ret; - } -#endif - return of_register_platform_driver(&mpc52xx_fec_driver); -} - -static void __exit -mpc52xx_fec_exit(void) -{ - of_unregister_platform_driver(&mpc52xx_fec_driver); -#ifdef CONFIG_FEC_MPC52xx_MDIO - of_unregister_platform_driver(&mpc52xx_fec_mdio_driver); -#endif -} - - -module_init(mpc52xx_fec_init); -module_exit(mpc52xx_fec_exit); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Dale Farnsworth"); -MODULE_DESCRIPTION("Ethernet driver for the Freescale MPC52xx FEC"); diff --git a/trunk/drivers/net/fec_mpc52xx.h b/trunk/drivers/net/fec_mpc52xx.h deleted file mode 100644 index 8b1f75397b9a..000000000000 --- a/trunk/drivers/net/fec_mpc52xx.h +++ /dev/null @@ -1,313 +0,0 @@ -/* - * drivers/drivers/net/fec_mpc52xx/fec.h - * - * Driver for the MPC5200 Fast Ethernet Controller - * - * Author: Dale Farnsworth - * - * 2003-2004 (c) MontaVista, Software, Inc. This file is licensed under - * the terms of the GNU General Public License version 2. This program - * is licensed "as is" without any warranty of any kind, whether express - * or implied. - */ - -#ifndef __DRIVERS_NET_MPC52XX_FEC_H__ -#define __DRIVERS_NET_MPC52XX_FEC_H__ - -#include - -/* Tunable constant */ -/* FEC_RX_BUFFER_SIZE includes 4 bytes for CRC32 */ -#define FEC_RX_BUFFER_SIZE 1522 /* max receive packet size */ -#define FEC_RX_NUM_BD 256 -#define FEC_TX_NUM_BD 64 - -#define FEC_RESET_DELAY 50 /* uS */ - -#define FEC_WATCHDOG_TIMEOUT ((400*HZ)/1000) - -struct mpc52xx_fec_priv { - int duplex; - int r_irq; - int t_irq; - struct mpc52xx_fec __iomem *fec; - struct bcom_task *rx_dmatsk; - struct bcom_task *tx_dmatsk; - spinlock_t lock; - int msg_enable; - - int has_phy; - unsigned int phy_speed; - unsigned int phy_addr; - struct phy_device *phydev; - enum phy_state link; - int speed; -}; - - -/* ======================================================================== */ -/* Hardware register sets & bits */ -/* ======================================================================== */ - -struct mpc52xx_fec { - u32 fec_id; /* FEC + 0x000 */ - u32 ievent; /* FEC + 0x004 */ - u32 imask; /* FEC + 0x008 */ - - u32 reserved0[1]; /* FEC + 0x00C */ - u32 r_des_active; /* FEC + 0x010 */ - u32 x_des_active; /* FEC + 0x014 */ - u32 r_des_active_cl; /* FEC + 0x018 */ - u32 x_des_active_cl; /* FEC + 0x01C */ - u32 ivent_set; /* FEC + 0x020 */ - u32 ecntrl; /* FEC + 0x024 */ - - u32 reserved1[6]; /* FEC + 0x028-03C */ - u32 mii_data; /* FEC + 0x040 */ - u32 mii_speed; /* FEC + 0x044 */ - u32 mii_status; /* FEC + 0x048 */ - - u32 reserved2[5]; /* FEC + 0x04C-05C */ - u32 mib_data; /* FEC + 0x060 */ - u32 mib_control; /* FEC + 0x064 */ - - u32 reserved3[6]; /* FEC + 0x068-7C */ - u32 r_activate; /* FEC + 0x080 */ - u32 r_cntrl; /* FEC + 0x084 */ - u32 r_hash; /* FEC + 0x088 */ - u32 r_data; /* FEC + 0x08C */ - u32 ar_done; /* FEC + 0x090 */ - u32 r_test; /* FEC + 0x094 */ - u32 r_mib; /* FEC + 0x098 */ - u32 r_da_low; /* FEC + 0x09C */ - u32 r_da_high; /* FEC + 0x0A0 */ - - u32 reserved4[7]; /* FEC + 0x0A4-0BC */ - u32 x_activate; /* FEC + 0x0C0 */ - u32 x_cntrl; /* FEC + 0x0C4 */ - u32 backoff; /* FEC + 0x0C8 */ - u32 x_data; /* FEC + 0x0CC */ - u32 x_status; /* FEC + 0x0D0 */ - u32 x_mib; /* FEC + 0x0D4 */ - u32 x_test; /* FEC + 0x0D8 */ - u32 fdxfc_da1; /* FEC + 0x0DC */ - u32 fdxfc_da2; /* FEC + 0x0E0 */ - u32 paddr1; /* FEC + 0x0E4 */ - u32 paddr2; /* FEC + 0x0E8 */ - u32 op_pause; /* FEC + 0x0EC */ - - u32 reserved5[4]; /* FEC + 0x0F0-0FC */ - u32 instr_reg; /* FEC + 0x100 */ - u32 context_reg; /* FEC + 0x104 */ - u32 test_cntrl; /* FEC + 0x108 */ - u32 acc_reg; /* FEC + 0x10C */ - u32 ones; /* FEC + 0x110 */ - u32 zeros; /* FEC + 0x114 */ - u32 iaddr1; /* FEC + 0x118 */ - u32 iaddr2; /* FEC + 0x11C */ - u32 gaddr1; /* FEC + 0x120 */ - u32 gaddr2; /* FEC + 0x124 */ - u32 random; /* FEC + 0x128 */ - u32 rand1; /* FEC + 0x12C */ - u32 tmp; /* FEC + 0x130 */ - - u32 reserved6[3]; /* FEC + 0x134-13C */ - u32 fifo_id; /* FEC + 0x140 */ - u32 x_wmrk; /* FEC + 0x144 */ - u32 fcntrl; /* FEC + 0x148 */ - u32 r_bound; /* FEC + 0x14C */ - u32 r_fstart; /* FEC + 0x150 */ - u32 r_count; /* FEC + 0x154 */ - u32 r_lag; /* FEC + 0x158 */ - u32 r_read; /* FEC + 0x15C */ - u32 r_write; /* FEC + 0x160 */ - u32 x_count; /* FEC + 0x164 */ - u32 x_lag; /* FEC + 0x168 */ - u32 x_retry; /* FEC + 0x16C */ - u32 x_write; /* FEC + 0x170 */ - u32 x_read; /* FEC + 0x174 */ - - u32 reserved7[2]; /* FEC + 0x178-17C */ - u32 fm_cntrl; /* FEC + 0x180 */ - u32 rfifo_data; /* FEC + 0x184 */ - u32 rfifo_status; /* FEC + 0x188 */ - u32 rfifo_cntrl; /* FEC + 0x18C */ - u32 rfifo_lrf_ptr; /* FEC + 0x190 */ - u32 rfifo_lwf_ptr; /* FEC + 0x194 */ - u32 rfifo_alarm; /* FEC + 0x198 */ - u32 rfifo_rdptr; /* FEC + 0x19C */ - u32 rfifo_wrptr; /* FEC + 0x1A0 */ - u32 tfifo_data; /* FEC + 0x1A4 */ - u32 tfifo_status; /* FEC + 0x1A8 */ - u32 tfifo_cntrl; /* FEC + 0x1AC */ - u32 tfifo_lrf_ptr; /* FEC + 0x1B0 */ - u32 tfifo_lwf_ptr; /* FEC + 0x1B4 */ - u32 tfifo_alarm; /* FEC + 0x1B8 */ - u32 tfifo_rdptr; /* FEC + 0x1BC */ - u32 tfifo_wrptr; /* FEC + 0x1C0 */ - - u32 reset_cntrl; /* FEC + 0x1C4 */ - u32 xmit_fsm; /* FEC + 0x1C8 */ - - u32 reserved8[3]; /* FEC + 0x1CC-1D4 */ - u32 rdes_data0; /* FEC + 0x1D8 */ - u32 rdes_data1; /* FEC + 0x1DC */ - u32 r_length; /* FEC + 0x1E0 */ - u32 x_length; /* FEC + 0x1E4 */ - u32 x_addr; /* FEC + 0x1E8 */ - u32 cdes_data; /* FEC + 0x1EC */ - u32 status; /* FEC + 0x1F0 */ - u32 dma_control; /* FEC + 0x1F4 */ - u32 des_cmnd; /* FEC + 0x1F8 */ - u32 data; /* FEC + 0x1FC */ - - u32 rmon_t_drop; /* FEC + 0x200 */ - u32 rmon_t_packets; /* FEC + 0x204 */ - u32 rmon_t_bc_pkt; /* FEC + 0x208 */ - u32 rmon_t_mc_pkt; /* FEC + 0x20C */ - u32 rmon_t_crc_align; /* FEC + 0x210 */ - u32 rmon_t_undersize; /* FEC + 0x214 */ - u32 rmon_t_oversize; /* FEC + 0x218 */ - u32 rmon_t_frag; /* FEC + 0x21C */ - u32 rmon_t_jab; /* FEC + 0x220 */ - u32 rmon_t_col; /* FEC + 0x224 */ - u32 rmon_t_p64; /* FEC + 0x228 */ - u32 rmon_t_p65to127; /* FEC + 0x22C */ - u32 rmon_t_p128to255; /* FEC + 0x230 */ - u32 rmon_t_p256to511; /* FEC + 0x234 */ - u32 rmon_t_p512to1023; /* FEC + 0x238 */ - u32 rmon_t_p1024to2047; /* FEC + 0x23C */ - u32 rmon_t_p_gte2048; /* FEC + 0x240 */ - u32 rmon_t_octets; /* FEC + 0x244 */ - u32 ieee_t_drop; /* FEC + 0x248 */ - u32 ieee_t_frame_ok; /* FEC + 0x24C */ - u32 ieee_t_1col; /* FEC + 0x250 */ - u32 ieee_t_mcol; /* FEC + 0x254 */ - u32 ieee_t_def; /* FEC + 0x258 */ - u32 ieee_t_lcol; /* FEC + 0x25C */ - u32 ieee_t_excol; /* FEC + 0x260 */ - u32 ieee_t_macerr; /* FEC + 0x264 */ - u32 ieee_t_cserr; /* FEC + 0x268 */ - u32 ieee_t_sqe; /* FEC + 0x26C */ - u32 t_fdxfc; /* FEC + 0x270 */ - u32 ieee_t_octets_ok; /* FEC + 0x274 */ - - u32 reserved9[2]; /* FEC + 0x278-27C */ - u32 rmon_r_drop; /* FEC + 0x280 */ - u32 rmon_r_packets; /* FEC + 0x284 */ - u32 rmon_r_bc_pkt; /* FEC + 0x288 */ - u32 rmon_r_mc_pkt; /* FEC + 0x28C */ - u32 rmon_r_crc_align; /* FEC + 0x290 */ - u32 rmon_r_undersize; /* FEC + 0x294 */ - u32 rmon_r_oversize; /* FEC + 0x298 */ - u32 rmon_r_frag; /* FEC + 0x29C */ - u32 rmon_r_jab; /* FEC + 0x2A0 */ - - u32 rmon_r_resvd_0; /* FEC + 0x2A4 */ - - u32 rmon_r_p64; /* FEC + 0x2A8 */ - u32 rmon_r_p65to127; /* FEC + 0x2AC */ - u32 rmon_r_p128to255; /* FEC + 0x2B0 */ - u32 rmon_r_p256to511; /* FEC + 0x2B4 */ - u32 rmon_r_p512to1023; /* FEC + 0x2B8 */ - u32 rmon_r_p1024to2047; /* FEC + 0x2BC */ - u32 rmon_r_p_gte2048; /* FEC + 0x2C0 */ - u32 rmon_r_octets; /* FEC + 0x2C4 */ - u32 ieee_r_drop; /* FEC + 0x2C8 */ - u32 ieee_r_frame_ok; /* FEC + 0x2CC */ - u32 ieee_r_crc; /* FEC + 0x2D0 */ - u32 ieee_r_align; /* FEC + 0x2D4 */ - u32 r_macerr; /* FEC + 0x2D8 */ - u32 r_fdxfc; /* FEC + 0x2DC */ - u32 ieee_r_octets_ok; /* FEC + 0x2E0 */ - - u32 reserved10[7]; /* FEC + 0x2E4-2FC */ - - u32 reserved11[64]; /* FEC + 0x300-3FF */ -}; - -#define FEC_MIB_DISABLE 0x80000000 - -#define FEC_IEVENT_HBERR 0x80000000 -#define FEC_IEVENT_BABR 0x40000000 -#define FEC_IEVENT_BABT 0x20000000 -#define FEC_IEVENT_GRA 0x10000000 -#define FEC_IEVENT_TFINT 0x08000000 -#define FEC_IEVENT_MII 0x00800000 -#define FEC_IEVENT_LATE_COL 0x00200000 -#define FEC_IEVENT_COL_RETRY_LIM 0x00100000 -#define FEC_IEVENT_XFIFO_UN 0x00080000 -#define FEC_IEVENT_XFIFO_ERROR 0x00040000 -#define FEC_IEVENT_RFIFO_ERROR 0x00020000 - -#define FEC_IMASK_HBERR 0x80000000 -#define FEC_IMASK_BABR 0x40000000 -#define FEC_IMASK_BABT 0x20000000 -#define FEC_IMASK_GRA 0x10000000 -#define FEC_IMASK_MII 0x00800000 -#define FEC_IMASK_LATE_COL 0x00200000 -#define FEC_IMASK_COL_RETRY_LIM 0x00100000 -#define FEC_IMASK_XFIFO_UN 0x00080000 -#define FEC_IMASK_XFIFO_ERROR 0x00040000 -#define FEC_IMASK_RFIFO_ERROR 0x00020000 - -/* all but MII, which is enabled separately */ -#define FEC_IMASK_ENABLE (FEC_IMASK_HBERR | FEC_IMASK_BABR | \ - FEC_IMASK_BABT | FEC_IMASK_GRA | FEC_IMASK_LATE_COL | \ - FEC_IMASK_COL_RETRY_LIM | FEC_IMASK_XFIFO_UN | \ - FEC_IMASK_XFIFO_ERROR | FEC_IMASK_RFIFO_ERROR) - -#define FEC_RCNTRL_MAX_FL_SHIFT 16 -#define FEC_RCNTRL_LOOP 0x01 -#define FEC_RCNTRL_DRT 0x02 -#define FEC_RCNTRL_MII_MODE 0x04 -#define FEC_RCNTRL_PROM 0x08 -#define FEC_RCNTRL_BC_REJ 0x10 -#define FEC_RCNTRL_FCE 0x20 - -#define FEC_TCNTRL_GTS 0x00000001 -#define FEC_TCNTRL_HBC 0x00000002 -#define FEC_TCNTRL_FDEN 0x00000004 -#define FEC_TCNTRL_TFC_PAUSE 0x00000008 -#define FEC_TCNTRL_RFC_PAUSE 0x00000010 - -#define FEC_ECNTRL_RESET 0x00000001 -#define FEC_ECNTRL_ETHER_EN 0x00000002 - -#define FEC_MII_DATA_ST 0x40000000 /* Start frame */ -#define FEC_MII_DATA_OP_RD 0x20000000 /* Perform read */ -#define FEC_MII_DATA_OP_WR 0x10000000 /* Perform write */ -#define FEC_MII_DATA_PA_MSK 0x0f800000 /* PHY Address mask */ -#define FEC_MII_DATA_RA_MSK 0x007c0000 /* PHY Register mask */ -#define FEC_MII_DATA_TA 0x00020000 /* Turnaround */ -#define FEC_MII_DATA_DATAMSK 0x0000ffff /* PHY data mask */ - -#define FEC_MII_READ_FRAME (FEC_MII_DATA_ST | FEC_MII_DATA_OP_RD | FEC_MII_DATA_TA) -#define FEC_MII_WRITE_FRAME (FEC_MII_DATA_ST | FEC_MII_DATA_OP_WR | FEC_MII_DATA_TA) - -#define FEC_MII_DATA_RA_SHIFT 0x12 /* MII reg addr bits */ -#define FEC_MII_DATA_PA_SHIFT 0x17 /* MII PHY addr bits */ - -#define FEC_PADDR2_TYPE 0x8808 - -#define FEC_OP_PAUSE_OPCODE 0x00010000 - -#define FEC_FIFO_WMRK_256B 0x3 - -#define FEC_FIFO_STATUS_ERR 0x00400000 -#define FEC_FIFO_STATUS_UF 0x00200000 -#define FEC_FIFO_STATUS_OF 0x00100000 - -#define FEC_FIFO_CNTRL_FRAME 0x08000000 -#define FEC_FIFO_CNTRL_LTG_7 0x07000000 - -#define FEC_RESET_CNTRL_RESET_FIFO 0x02000000 -#define FEC_RESET_CNTRL_ENABLE_IS_RESET 0x01000000 - -#define FEC_XMIT_FSM_APPEND_CRC 0x02000000 -#define FEC_XMIT_FSM_ENABLE_CRC 0x01000000 - - -extern struct of_platform_driver mpc52xx_fec_mdio_driver; - -#endif /* __DRIVERS_NET_MPC52XX_FEC_H__ */ diff --git a/trunk/drivers/net/fec_mpc52xx_phy.c b/trunk/drivers/net/fec_mpc52xx_phy.c deleted file mode 100644 index ba6e8b218e0a..000000000000 --- a/trunk/drivers/net/fec_mpc52xx_phy.c +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Driver for the MPC5200 Fast Ethernet Controller - MDIO bus driver - * - * Copyright (C) 2007 Domen Puncer, Telargo, Inc. - * - * This file is licensed under the terms of the GNU General Public License - * version 2. This program is licensed "as is" without any warranty of any - * kind, whether express or implied. - */ - -#include -#include -#include -#include -#include -#include -#include -#include "fec_mpc52xx.h" - -struct mpc52xx_fec_mdio_priv { - struct mpc52xx_fec __iomem *regs; -}; - -static int mpc52xx_fec_mdio_read(struct mii_bus *bus, int phy_id, int reg) -{ - struct mpc52xx_fec_mdio_priv *priv = bus->priv; - struct mpc52xx_fec __iomem *fec; - int tries = 100; - u32 request = FEC_MII_READ_FRAME; - - fec = priv->regs; - out_be32(&fec->ievent, FEC_IEVENT_MII); - - request |= (phy_id << FEC_MII_DATA_PA_SHIFT) & FEC_MII_DATA_PA_MSK; - request |= (reg << FEC_MII_DATA_RA_SHIFT) & FEC_MII_DATA_RA_MSK; - - out_be32(&priv->regs->mii_data, request); - - /* wait for it to finish, this takes about 23 us on lite5200b */ - while (!(in_be32(&fec->ievent) & FEC_IEVENT_MII) && --tries) - udelay(5); - - if (tries == 0) - return -ETIMEDOUT; - - return in_be32(&priv->regs->mii_data) & FEC_MII_DATA_DATAMSK; -} - -static int mpc52xx_fec_mdio_write(struct mii_bus *bus, int phy_id, int reg, u16 data) -{ - struct mpc52xx_fec_mdio_priv *priv = bus->priv; - struct mpc52xx_fec __iomem *fec; - u32 value = data; - int tries = 100; - - fec = priv->regs; - out_be32(&fec->ievent, FEC_IEVENT_MII); - - value |= FEC_MII_WRITE_FRAME; - value |= (phy_id << FEC_MII_DATA_PA_SHIFT) & FEC_MII_DATA_PA_MSK; - value |= (reg << FEC_MII_DATA_RA_SHIFT) & FEC_MII_DATA_RA_MSK; - - out_be32(&priv->regs->mii_data, value); - - /* wait for request to finish */ - while (!(in_be32(&fec->ievent) & FEC_IEVENT_MII) && --tries) - udelay(5); - - if (tries == 0) - return -ETIMEDOUT; - - return 0; -} - -static int mpc52xx_fec_mdio_probe(struct of_device *of, const struct of_device_id *match) -{ - struct device *dev = &of->dev; - struct device_node *np = of->node; - struct device_node *child = NULL; - struct mii_bus *bus; - struct mpc52xx_fec_mdio_priv *priv; - struct resource res = {}; - int err; - int i; - - bus = kzalloc(sizeof(*bus), GFP_KERNEL); - if (bus == NULL) - return -ENOMEM; - priv = kzalloc(sizeof(*priv), GFP_KERNEL); - if (priv == NULL) { - err = -ENOMEM; - goto out_free; - } - - bus->name = "mpc52xx MII bus"; - bus->read = mpc52xx_fec_mdio_read; - bus->write = mpc52xx_fec_mdio_write; - - /* setup irqs */ - bus->irq = kmalloc(sizeof(bus->irq[0]) * PHY_MAX_ADDR, GFP_KERNEL); - if (bus->irq == NULL) { - err = -ENOMEM; - goto out_free; - } - for (i=0; iirq[i] = PHY_POLL; - - while ((child = of_get_next_child(np, child)) != NULL) { - int irq = irq_of_parse_and_map(child, 0); - if (irq != NO_IRQ) { - const u32 *id = of_get_property(child, "reg", NULL); - bus->irq[*id] = irq; - } - } - - /* setup registers */ - err = of_address_to_resource(np, 0, &res); - if (err) - goto out_free; - priv->regs = ioremap(res.start, res.end - res.start + 1); - if (priv->regs == NULL) { - err = -ENOMEM; - goto out_free; - } - - bus->id = res.start; - bus->priv = priv; - - bus->dev = dev; - dev_set_drvdata(dev, bus); - - /* set MII speed */ - out_be32(&priv->regs->mii_speed, ((mpc52xx_find_ipb_freq(of->node) >> 20) / 5) << 1); - - /* enable MII interrupt */ - out_be32(&priv->regs->imask, in_be32(&priv->regs->imask) | FEC_IMASK_MII); - - err = mdiobus_register(bus); - if (err) - goto out_unmap; - - return 0; - - out_unmap: - iounmap(priv->regs); - out_free: - for (i=0; iirq[i] != PHY_POLL) - irq_dispose_mapping(bus->irq[i]); - kfree(bus->irq); - kfree(priv); - kfree(bus); - - return err; -} - -static int mpc52xx_fec_mdio_remove(struct of_device *of) -{ - struct device *dev = &of->dev; - struct mii_bus *bus = dev_get_drvdata(dev); - struct mpc52xx_fec_mdio_priv *priv = bus->priv; - int i; - - mdiobus_unregister(bus); - dev_set_drvdata(dev, NULL); - - iounmap(priv->regs); - for (i=0; iirq[i]) - irq_dispose_mapping(bus->irq[i]); - kfree(priv); - kfree(bus->irq); - kfree(bus); - - return 0; -} - - -static struct of_device_id mpc52xx_fec_mdio_match[] = { - { - .type = "mdio", - .compatible = "mpc5200b-fec-phy", - }, - {}, -}; - -struct of_platform_driver mpc52xx_fec_mdio_driver = { - .name = "mpc5200b-fec-phy", - .probe = mpc52xx_fec_mdio_probe, - .remove = mpc52xx_fec_mdio_remove, - .match_table = mpc52xx_fec_mdio_match, -}; - -/* let fec driver call it, since this has to be registered before it */ -EXPORT_SYMBOL_GPL(mpc52xx_fec_mdio_driver); - - -MODULE_LICENSE("Dual BSD/GPL"); diff --git a/trunk/drivers/net/forcedeth.c b/trunk/drivers/net/forcedeth.c index 92ce2e38f0d5..70ddf1acfd88 100644 --- a/trunk/drivers/net/forcedeth.c +++ b/trunk/drivers/net/forcedeth.c @@ -5597,22 +5597,6 @@ static struct pci_device_id pci_tbl[] = { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_31), .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, }, - { /* MCP77 Ethernet Controller */ - PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_32), - .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, - }, - { /* MCP77 Ethernet Controller */ - PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_33), - .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, - }, - { /* MCP77 Ethernet Controller */ - PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_34), - .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, - }, - { /* MCP77 Ethernet Controller */ - PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_35), - .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, - }, {0,}, }; diff --git a/trunk/drivers/net/hamradio/baycom_epp.c b/trunk/drivers/net/hamradio/baycom_epp.c index dde9c7e6408a..1a5a75acf73e 100644 --- a/trunk/drivers/net/hamradio/baycom_epp.c +++ b/trunk/drivers/net/hamradio/baycom_epp.c @@ -325,6 +325,12 @@ static int eppconfig(struct baycom_state *bc) /* ---------------------------------------------------------------------- */ +static void epp_interrupt(int irq, void *dev_id) +{ +} + +/* ---------------------------------------------------------------------- */ + static inline void do_kiss_params(struct baycom_state *bc, unsigned char *data, unsigned long len) { @@ -865,7 +871,7 @@ static int epp_open(struct net_device *dev) } memset(&bc->modem, 0, sizeof(bc->modem)); bc->pdev = parport_register_device(pp, dev->name, NULL, epp_wakeup, - NULL, PARPORT_DEV_EXCL, dev); + epp_interrupt, PARPORT_DEV_EXCL, dev); parport_put_port(pp); if (!bc->pdev) { printk(KERN_ERR "%s: cannot register parport at 0x%lx\n", bc_drvname, pp->base); diff --git a/trunk/drivers/net/hamradio/baycom_par.c b/trunk/drivers/net/hamradio/baycom_par.c index 2e6fc4dc74b1..5930aeb35015 100644 --- a/trunk/drivers/net/hamradio/baycom_par.c +++ b/trunk/drivers/net/hamradio/baycom_par.c @@ -270,9 +270,9 @@ static __inline__ void par96_rx(struct net_device *dev, struct baycom_state *bc) /* --------------------------------------------------------------------- */ -static void par96_interrupt(void *dev_id) +static void par96_interrupt(int irq, void *dev_id) { - struct net_device *dev = dev_id; + struct net_device *dev = (struct net_device *)dev_id; struct baycom_state *bc = netdev_priv(dev); baycom_int_freq(bc); diff --git a/trunk/drivers/net/ipg.c b/trunk/drivers/net/ipg.c index dbd23bb65d1e..68887235d7e9 100644 --- a/trunk/drivers/net/ipg.c +++ b/trunk/drivers/net/ipg.c @@ -55,26 +55,6 @@ MODULE_DESCRIPTION("IC Plus IP1000 Gigabit Ethernet Adapter Linux Driver " DrvVer); MODULE_LICENSE("GPL"); -//variable record -- index by leading revision/length -//Revision/Length(=N*4), Address1, Data1, Address2, Data2,...,AddressN,DataN -static unsigned short DefaultPhyParam[] = { - // 11/12/03 IP1000A v1-3 rev=0x40 - /*-------------------------------------------------------------------------- - (0x4000|(15*4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 22, 0x85bd, 24, 0xfff2, - 27, 0x0c10, 28, 0x0c10, 29, 0x2c10, 31, 0x0003, 23, 0x92f6, - 31, 0x0000, 23, 0x003d, 30, 0x00de, 20, 0x20e7, 9, 0x0700, - --------------------------------------------------------------------------*/ - // 12/17/03 IP1000A v1-4 rev=0x40 - (0x4000 | (07 * 4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 27, 0xeb8e, 31, - 0x0000, - 30, 0x005e, 9, 0x0700, - // 01/09/04 IP1000A v1-5 rev=0x41 - (0x4100 | (07 * 4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 27, 0xeb8e, 31, - 0x0000, - 30, 0x005e, 9, 0x0700, - 0x0000 -}; - static const char *ipg_brand_name[] = { "IC PLUS IP1000 1000/100/10 based NIC", "Sundance Technology ST2021 based NIC", @@ -1010,7 +990,7 @@ static void ipg_nic_txcleanup(struct net_device *dev) } /* Provides statistical information about the IPG NIC. */ -static struct net_device_stats *ipg_nic_get_stats(struct net_device *dev) +struct net_device_stats *ipg_nic_get_stats(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); void __iomem *ioaddr = sp->ioaddr; diff --git a/trunk/drivers/net/ipg.h b/trunk/drivers/net/ipg.h index d5d092c9d0af..e418b9035cac 100644 --- a/trunk/drivers/net/ipg.h +++ b/trunk/drivers/net/ipg.h @@ -833,4 +833,24 @@ struct ipg_nic_private { struct delayed_work task; }; +//variable record -- index by leading revision/length +//Revision/Length(=N*4), Address1, Data1, Address2, Data2,...,AddressN,DataN +unsigned short DefaultPhyParam[] = { + // 11/12/03 IP1000A v1-3 rev=0x40 + /*-------------------------------------------------------------------------- + (0x4000|(15*4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 22, 0x85bd, 24, 0xfff2, + 27, 0x0c10, 28, 0x0c10, 29, 0x2c10, 31, 0x0003, 23, 0x92f6, + 31, 0x0000, 23, 0x003d, 30, 0x00de, 20, 0x20e7, 9, 0x0700, + --------------------------------------------------------------------------*/ + // 12/17/03 IP1000A v1-4 rev=0x40 + (0x4000 | (07 * 4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 27, 0xeb8e, 31, + 0x0000, + 30, 0x005e, 9, 0x0700, + // 01/09/04 IP1000A v1-5 rev=0x41 + (0x4100 | (07 * 4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 27, 0xeb8e, 31, + 0x0000, + 30, 0x005e, 9, 0x0700, + 0x0000 +}; + #endif /* __LINUX_IPG_H */ diff --git a/trunk/drivers/net/irda/au1k_ir.c b/trunk/drivers/net/irda/au1k_ir.c index a1e4508717c8..4dbdfaaf37bf 100644 --- a/trunk/drivers/net/irda/au1k_ir.c +++ b/trunk/drivers/net/irda/au1k_ir.c @@ -627,16 +627,19 @@ static int au1k_irda_rx(struct net_device *dev) } -static irqreturn_t au1k_irda_interrupt(int dummy, void *dev_id) +void au1k_irda_interrupt(int irq, void *dev_id) { - struct net_device *dev = dev_id; + struct net_device *dev = (struct net_device *) dev_id; + + if (dev == NULL) { + printk(KERN_ERR "%s: isr: null dev ptr\n", dev->name); + return; + } writel(0, IR_INT_CLEAR); /* ack irda interrupts */ au1k_irda_rx(dev); au1k_tx_ack(dev); - - return IRQ_HANDLED; } diff --git a/trunk/drivers/net/ixgb/ixgb.h b/trunk/drivers/net/ixgb/ixgb.h index 3d2e7217e9af..1eee8894c732 100644 --- a/trunk/drivers/net/ixgb/ixgb.h +++ b/trunk/drivers/net/ixgb/ixgb.h @@ -196,11 +196,4 @@ struct ixgb_adapter { uint32_t alloc_rx_buff_failed; boolean_t have_msi; }; - -/* Exported from other modules */ -extern void ixgb_check_options(struct ixgb_adapter *adapter); -extern void ixgb_set_ethtool_ops(struct net_device *netdev); -extern char ixgb_driver_name[]; -extern const char ixgb_driver_version[]; - #endif /* _IXGB_H_ */ diff --git a/trunk/drivers/net/ixgb/ixgb_ethtool.c b/trunk/drivers/net/ixgb/ixgb_ethtool.c index a267dd862520..fddd5844168d 100644 --- a/trunk/drivers/net/ixgb/ixgb_ethtool.c +++ b/trunk/drivers/net/ixgb/ixgb_ethtool.c @@ -32,6 +32,9 @@ #include +extern char ixgb_driver_name[]; +extern char ixgb_driver_version[]; + extern int ixgb_up(struct ixgb_adapter *adapter); extern void ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog); extern void ixgb_reset(struct ixgb_adapter *adapter); @@ -636,8 +639,8 @@ ixgb_phys_id(struct net_device *netdev, uint32_t data) { struct ixgb_adapter *adapter = netdev_priv(netdev); - if (!data) - data = INT_MAX; + if(!data || data > (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ)) + data = (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ); if(!adapter->blink_timer.function) { init_timer(&adapter->blink_timer); diff --git a/trunk/drivers/net/ixgb/ixgb_hw.c b/trunk/drivers/net/ixgb/ixgb_hw.c index 2c6367ace3cd..ecbf45861c68 100644 --- a/trunk/drivers/net/ixgb/ixgb_hw.c +++ b/trunk/drivers/net/ixgb/ixgb_hw.c @@ -1174,7 +1174,7 @@ mac_addr_valid(uint8_t *mac_addr) * * hw - Struct containing variables accessed by shared code *****************************************************************************/ -static boolean_t +boolean_t ixgb_link_reset(struct ixgb_hw *hw) { boolean_t link_status = FALSE; @@ -1205,7 +1205,7 @@ ixgb_link_reset(struct ixgb_hw *hw) * * hw - Struct containing variables accessed by shared code *****************************************************************************/ -static void +void ixgb_optics_reset(struct ixgb_hw *hw) { if (hw->phy_type == ixgb_phy_type_txn17401) { diff --git a/trunk/drivers/net/ixgb/ixgb_main.c b/trunk/drivers/net/ixgb/ixgb_main.c index 3021234b1e17..d444de58ba34 100644 --- a/trunk/drivers/net/ixgb/ixgb_main.c +++ b/trunk/drivers/net/ixgb/ixgb_main.c @@ -37,8 +37,8 @@ static char ixgb_driver_string[] = "Intel(R) PRO/10GbE Network Driver"; #define DRIVERNAPI "-NAPI" #endif #define DRV_VERSION "1.0.126-k2"DRIVERNAPI -const char ixgb_driver_version[] = DRV_VERSION; -static const char ixgb_copyright[] = "Copyright (c) 1999-2006 Intel Corporation."; +char ixgb_driver_version[] = DRV_VERSION; +static char ixgb_copyright[] = "Copyright (c) 1999-2006 Intel Corporation."; /* ixgb_pci_tbl - PCI Device ID Table * @@ -104,6 +104,7 @@ static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter, static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter); #endif static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter); +void ixgb_set_ethtool_ops(struct net_device *netdev); static void ixgb_tx_timeout(struct net_device *dev); static void ixgb_tx_timeout_task(struct work_struct *work); static void ixgb_vlan_rx_register(struct net_device *netdev, @@ -122,6 +123,9 @@ static pci_ers_result_t ixgb_io_error_detected (struct pci_dev *pdev, static pci_ers_result_t ixgb_io_slot_reset (struct pci_dev *pdev); static void ixgb_io_resume (struct pci_dev *pdev); +/* Exported from other modules */ +extern void ixgb_check_options(struct ixgb_adapter *adapter); + static struct pci_error_handlers ixgb_err_handler = { .error_detected = ixgb_io_error_detected, .slot_reset = ixgb_io_slot_reset, @@ -1081,8 +1085,7 @@ ixgb_set_multi(struct net_device *netdev) rctl |= IXGB_RCTL_MPE; IXGB_WRITE_REG(hw, RCTL, rctl); } else { - uint8_t mta[IXGB_MAX_NUM_MULTICAST_ADDRESSES * - IXGB_ETH_LENGTH_OF_ADDRESS]; + uint8_t mta[netdev->mc_count * IXGB_ETH_LENGTH_OF_ADDRESS]; IXGB_WRITE_REG(hw, RCTL, rctl); @@ -1321,8 +1324,8 @@ ixgb_tx_map(struct ixgb_adapter *adapter, struct sk_buff *skb, /* Workaround for premature desc write-backs * in TSO mode. Append 4-byte sentinel desc */ - if (unlikely(mss && (f == (nr_frags - 1)) - && size == len && size > 8)) + if (unlikely(mss && !nr_frags && size == len + && size > 8)) size -= 4; buffer_info->length = size; diff --git a/trunk/drivers/net/ixgb/ixgb_param.c b/trunk/drivers/net/ixgb/ixgb_param.c index 865d14d6e5a7..5d5ddabf4360 100644 --- a/trunk/drivers/net/ixgb/ixgb_param.c +++ b/trunk/drivers/net/ixgb/ixgb_param.c @@ -44,11 +44,10 @@ */ #define IXGB_PARAM_INIT { [0 ... IXGB_MAX_NIC] = OPTION_UNSET } -#define IXGB_PARAM(X, desc) \ - static int __devinitdata X[IXGB_MAX_NIC+1] \ - = IXGB_PARAM_INIT; \ - static unsigned int num_##X = 0; \ - module_param_array_named(X, X, int, &num_##X, 0); \ +#define IXGB_PARAM(X, desc) \ + static int __devinitdata X[IXGB_MAX_NIC+1] = IXGB_PARAM_INIT; \ + static int num_##X = 0; \ + module_param_array_named(X, X, int, &num_##X, 0); \ MODULE_PARM_DESC(X, desc); /* Transmit Descriptor Count @@ -179,8 +178,8 @@ IXGB_PARAM(IntDelayEnable, "Transmit Interrupt Delay Enable"); struct ixgb_option { enum { enable_option, range_option, list_option } type; - const char *name; - const char *err; + char *name; + char *err; int def; union { struct { /* range_option info */ @@ -198,7 +197,7 @@ struct ixgb_option { }; static int __devinit -ixgb_validate_option(unsigned int *value, const struct ixgb_option *opt) +ixgb_validate_option(int *value, struct ixgb_option *opt) { if(*value == OPTION_UNSET) { *value = opt->def; @@ -267,7 +266,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) } { /* Transmit Descriptor Count */ - const struct ixgb_option opt = { + struct ixgb_option opt = { .type = range_option, .name = "Transmit Descriptors", .err = "using default of " __MODULE_STRING(DEFAULT_TXD), @@ -286,7 +285,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) tx_ring->count = ALIGN(tx_ring->count, IXGB_REQ_TX_DESCRIPTOR_MULTIPLE); } { /* Receive Descriptor Count */ - const struct ixgb_option opt = { + struct ixgb_option opt = { .type = range_option, .name = "Receive Descriptors", .err = "using default of " __MODULE_STRING(DEFAULT_RXD), @@ -305,7 +304,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) rx_ring->count = ALIGN(rx_ring->count, IXGB_REQ_RX_DESCRIPTOR_MULTIPLE); } { /* Receive Checksum Offload Enable */ - const struct ixgb_option opt = { + struct ixgb_option opt = { .type = enable_option, .name = "Receive Checksum Offload", .err = "defaulting to Enabled", @@ -313,7 +312,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) }; if(num_XsumRX > bd) { - unsigned int rx_csum = XsumRX[bd]; + int rx_csum = XsumRX[bd]; ixgb_validate_option(&rx_csum, &opt); adapter->rx_csum = rx_csum; } else { @@ -329,7 +328,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) { ixgb_fc_full, "Flow Control Enabled" }, { ixgb_fc_default, "Flow Control Hardware Default" }}; - const struct ixgb_option opt = { + struct ixgb_option opt = { .type = list_option, .name = "Flow Control", .err = "reading default settings from EEPROM", @@ -339,7 +338,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) }; if(num_FlowControl > bd) { - unsigned int fc = FlowControl[bd]; + int fc = FlowControl[bd]; ixgb_validate_option(&fc, &opt); adapter->hw.fc.type = fc; } else { @@ -347,7 +346,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) } } { /* Receive Flow Control High Threshold */ - const struct ixgb_option opt = { + struct ixgb_option opt = { .type = range_option, .name = "Rx Flow Control High Threshold", .err = "using default of " __MODULE_STRING(DEFAULT_FCRTH), @@ -367,7 +366,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) "Ignoring RxFCHighThresh when no RxFC\n"); } { /* Receive Flow Control Low Threshold */ - const struct ixgb_option opt = { + struct ixgb_option opt = { .type = range_option, .name = "Rx Flow Control Low Threshold", .err = "using default of " __MODULE_STRING(DEFAULT_FCRTL), @@ -387,7 +386,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) "Ignoring RxFCLowThresh when no RxFC\n"); } { /* Flow Control Pause Time Request*/ - const struct ixgb_option opt = { + struct ixgb_option opt = { .type = range_option, .name = "Flow Control Pause Time Request", .err = "using default of "__MODULE_STRING(DEFAULT_FCPAUSE), @@ -397,7 +396,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) }; if(num_FCReqTimeout > bd) { - unsigned int pause_time = FCReqTimeout[bd]; + int pause_time = FCReqTimeout[bd]; ixgb_validate_option(&pause_time, &opt); adapter->hw.fc.pause_time = pause_time; } else { @@ -420,7 +419,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) } } { /* Receive Interrupt Delay */ - const struct ixgb_option opt = { + struct ixgb_option opt = { .type = range_option, .name = "Receive Interrupt Delay", .err = "using default of " __MODULE_STRING(DEFAULT_RDTR), @@ -437,7 +436,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) } } { /* Transmit Interrupt Delay */ - const struct ixgb_option opt = { + struct ixgb_option opt = { .type = range_option, .name = "Transmit Interrupt Delay", .err = "using default of " __MODULE_STRING(DEFAULT_TIDV), @@ -455,7 +454,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) } { /* Transmit Interrupt Delay Enable */ - const struct ixgb_option opt = { + struct ixgb_option opt = { .type = enable_option, .name = "Tx Interrupt Delay Enable", .err = "defaulting to Enabled", @@ -463,7 +462,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) }; if(num_IntDelayEnable > bd) { - unsigned int ide = IntDelayEnable[bd]; + int ide = IntDelayEnable[bd]; ixgb_validate_option(&ide, &opt); adapter->tx_int_delay_enable = ide; } else { diff --git a/trunk/drivers/net/ixgbe/ixgbe.h b/trunk/drivers/net/ixgbe/ixgbe.h index bc51432b8d26..c160a7d91e21 100644 --- a/trunk/drivers/net/ixgbe/ixgbe.h +++ b/trunk/drivers/net/ixgbe/ixgbe.h @@ -244,7 +244,7 @@ extern struct ixgbe_info ixgbe_82598EB_info; extern struct ixgbe_info ixgbe_82598AT_info; extern char ixgbe_driver_name[]; -extern const char ixgbe_driver_version[]; +extern char ixgbe_driver_version[]; extern int ixgbe_up(struct ixgbe_adapter *adapter); extern void ixgbe_down(struct ixgbe_adapter *adapter); diff --git a/trunk/drivers/net/ixgbe/ixgbe_82598.c b/trunk/drivers/net/ixgbe/ixgbe_82598.c index 4d64673164ca..00ee20125ca9 100644 --- a/trunk/drivers/net/ixgbe/ixgbe_82598.c +++ b/trunk/drivers/net/ixgbe/ixgbe_82598.c @@ -30,7 +30,8 @@ #include #include -#include "ixgbe.h" +#include "ixgbe_type.h" +#include "ixgbe_common.h" #include "ixgbe_phy.h" #define IXGBE_82598_MAX_TX_QUEUES 32 diff --git a/trunk/drivers/net/ixgbe/ixgbe_main.c b/trunk/drivers/net/ixgbe/ixgbe_main.c index 00bc525c6560..b75f1c6efc42 100644 --- a/trunk/drivers/net/ixgbe/ixgbe_main.c +++ b/trunk/drivers/net/ixgbe/ixgbe_main.c @@ -45,13 +45,12 @@ #include "ixgbe_common.h" char ixgbe_driver_name[] = "ixgbe"; -static const char ixgbe_driver_string[] = - "Intel(R) 10 Gigabit PCI Express Network Driver"; +static char ixgbe_driver_string[] = + "Intel(R) 10 Gigabit PCI Express Network Driver"; #define DRV_VERSION "1.1.18" -const char ixgbe_driver_version[] = DRV_VERSION; -static const char ixgbe_copyright[] = - "Copyright (c) 1999-2007 Intel Corporation."; +char ixgbe_driver_version[] = DRV_VERSION; +static char ixgbe_copyright[] = "Copyright (c) 1999-2007 Intel Corporation."; static const struct ixgbe_info *ixgbe_info_tbl[] = { [board_82598AF] = &ixgbe_82598AF_info, diff --git a/trunk/drivers/net/lib82596.c b/trunk/drivers/net/lib82596.c index 9a855e512147..ffaa14f2cd01 100644 --- a/trunk/drivers/net/lib82596.c +++ b/trunk/drivers/net/lib82596.c @@ -1124,6 +1124,12 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id) struct i596_dma *dma; unsigned short status, ack_cmd = 0; + if (dev == NULL) { + printk(KERN_WARNING "%s: irq %d for unknown device.\n", + __FUNCTION__, irq); + return IRQ_NONE; + } + lp = netdev_priv(dev); dma = lp->dma; @@ -1134,7 +1140,7 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id) DEB(DEB_INTS, printk(KERN_DEBUG "%s: i596 interrupt, IRQ %d, status %4.4x.\n", - dev->name, dev->irq, status)); + dev->name, irq, status)); ack_cmd = status & 0xf000; diff --git a/trunk/drivers/net/loopback.c b/trunk/drivers/net/loopback.c index 45f30a2974b8..662b8d16803c 100644 --- a/trunk/drivers/net/loopback.c +++ b/trunk/drivers/net/loopback.c @@ -284,7 +284,7 @@ static __net_exit void loopback_net_exit(struct net *net) unregister_netdev(dev); } -static struct pernet_operations loopback_net_ops = { +static struct pernet_operations __net_initdata loopback_net_ops = { .init = loopback_net_init, .exit = loopback_net_exit, }; diff --git a/trunk/drivers/net/mipsnet.c b/trunk/drivers/net/mipsnet.c index aafc3ce59cbb..37707a0c0498 100644 --- a/trunk/drivers/net/mipsnet.c +++ b/trunk/drivers/net/mipsnet.c @@ -30,7 +30,6 @@ static int ioiocpy_frommipsnet(struct net_device *dev, unsigned char *kdata, int len) { uint32_t available_len = inl(mipsnet_reg_address(dev, rxDataCount)); - if (available_len < len) return -EFAULT; @@ -46,8 +45,14 @@ static inline ssize_t mipsnet_put_todevice(struct net_device *dev, int count_to_go = skb->len; char *buf_ptr = skb->data; + pr_debug("%s: %s(): telling MIPSNET txDataCount(%d)\n", + dev->name, __FUNCTION__, skb->len); + outl(skb->len, mipsnet_reg_address(dev, txDataCount)); + pr_debug("%s: %s(): sending data to MIPSNET txDataBuffer(%d)\n", + dev->name, __FUNCTION__, skb->len); + for (; count_to_go; buf_ptr++, count_to_go--) outb(*buf_ptr, mipsnet_reg_address(dev, txDataBuffer)); @@ -59,8 +64,10 @@ static inline ssize_t mipsnet_put_todevice(struct net_device *dev, static int mipsnet_xmit(struct sk_buff *skb, struct net_device *dev) { - /* - * Only one packet at a time. Once TXDONE interrupt is serviced, the + pr_debug("%s:%s(): transmitting %d bytes\n", + dev->name, __FUNCTION__, skb->len); + + /* Only one packet at a time. Once TXDONE interrupt is serviced, the * queue will be restarted. */ netif_stop_queue(dev); @@ -87,6 +94,8 @@ static inline ssize_t mipsnet_get_fromdev(struct net_device *dev, size_t count) skb->protocol = eth_type_trans(skb, dev); skb->ip_summed = CHECKSUM_UNNECESSARY; + pr_debug("%s:%s(): pushing RXed data to kernel\n", + dev->name, __FUNCTION__); netif_rx(skb); dev->stats.rx_packets++; @@ -103,29 +112,44 @@ static irqreturn_t mipsnet_interrupt(int irq, void *dev_id) uint64_t interruptFlags; if (irq == dev->irq) { + pr_debug("%s:%s(): irq %d for device\n", + dev->name, __FUNCTION__, irq); + retval = IRQ_HANDLED; interruptFlags = inl(mipsnet_reg_address(dev, interruptControl)); + pr_debug("%s:%s(): intCtl=0x%016llx\n", dev->name, + __FUNCTION__, interruptFlags); if (interruptFlags & MIPSNET_INTCTL_TXDONE) { + pr_debug("%s:%s(): got TXDone\n", + dev->name, __FUNCTION__); outl(MIPSNET_INTCTL_TXDONE, mipsnet_reg_address(dev, interruptControl)); /* only one packet at a time, we are done. */ netif_wake_queue(dev); } else if (interruptFlags & MIPSNET_INTCTL_RXDONE) { + pr_debug("%s:%s(): got RX data\n", + dev->name, __FUNCTION__); mipsnet_get_fromdev(dev, inl(mipsnet_reg_address(dev, rxDataCount))); + pr_debug("%s:%s(): clearing RX int\n", + dev->name, __FUNCTION__); outl(MIPSNET_INTCTL_RXDONE, mipsnet_reg_address(dev, interruptControl)); } else if (interruptFlags & MIPSNET_INTCTL_TESTBIT) { + pr_debug("%s:%s(): got test interrupt\n", + dev->name, __FUNCTION__); /* * TESTBIT is cleared on read. * And takes effect after a write with 0 */ outl(0, mipsnet_reg_address(dev, interruptControl)); } else { + pr_debug("%s:%s(): no valid fags 0x%016llx\n", + dev->name, __FUNCTION__, interruptFlags); /* Maybe shared IRQ, just ignore, no clearing. */ retval = IRQ_NONE; } @@ -141,15 +165,22 @@ static irqreturn_t mipsnet_interrupt(int irq, void *dev_id) static int mipsnet_open(struct net_device *dev) { int err; + pr_debug("%s: mipsnet_open\n", dev->name); err = request_irq(dev->irq, &mipsnet_interrupt, IRQF_SHARED, dev->name, (void *) dev); if (err) { + pr_debug("%s: %s(): can't get irq %d\n", + dev->name, __FUNCTION__, dev->irq); release_region(dev->base_addr, MIPSNET_IO_EXTENT); return err; } + pr_debug("%s: %s(): got IO region at 0x%04lx and irq %d for dev.\n", + dev->name, __FUNCTION__, dev->base_addr, dev->irq); + + netif_start_queue(dev); /* test interrupt handler */ @@ -162,8 +193,8 @@ static int mipsnet_open(struct net_device *dev) static int mipsnet_close(struct net_device *dev) { + pr_debug("%s: %s()\n", dev->name, __FUNCTION__); netif_stop_queue(dev); - return 0; } @@ -198,6 +229,9 @@ static int __init mipsnet_probe(struct device *dev) /* Get the io region now, get irq on open() */ if (!request_region(netdev->base_addr, MIPSNET_IO_EXTENT, "mipsnet")) { + pr_debug("%s: %s(): IO region {start: 0x%04lux, len: %d} " + "for dev is not availble.\n", netdev->name, + __FUNCTION__, netdev->base_addr, MIPSNET_IO_EXTENT); err = -EBUSY; goto out_free_netdev; } @@ -261,6 +295,8 @@ static int __init mipsnet_init_module(void) static void __exit mipsnet_exit_module(void) { + pr_debug("MIPSNet Ethernet driver exiting\n"); + driver_unregister(&mipsnet_driver); } diff --git a/trunk/drivers/net/mlx4/icm.c b/trunk/drivers/net/mlx4/icm.c index 2a5bef6388fe..887633b207d9 100644 --- a/trunk/drivers/net/mlx4/icm.c +++ b/trunk/drivers/net/mlx4/icm.c @@ -101,7 +101,9 @@ static int mlx4_alloc_icm_pages(struct scatterlist *mem, int order, gfp_t gfp_ma if (!page) return -ENOMEM; - sg_set_page(mem, page, PAGE_SIZE << order, 0); + sg_set_page(mem, page); + mem->length = PAGE_SIZE << order; + mem->offset = 0; return 0; } diff --git a/trunk/drivers/net/mv643xx_eth.c b/trunk/drivers/net/mv643xx_eth.c index 651c2699d5e1..84f2d6382f1e 100644 --- a/trunk/drivers/net/mv643xx_eth.c +++ b/trunk/drivers/net/mv643xx_eth.c @@ -1,5 +1,5 @@ /* - * Driver for Marvell Discovery (MV643XX) and Marvell Orion ethernet ports + * drivers/net/mv643xx_eth.c - Driver for MV643XX ethernet ports * Copyright (C) 2002 Matthew Dharm * * Based on the 64360 driver from: @@ -43,567 +43,14 @@ #include #include -#include -#include -#include -#include -#include - -#include - #include #include #include #include #include -#include - -#define MV643XX_CHECKSUM_OFFLOAD_TX -#define MV643XX_NAPI -#define MV643XX_TX_FAST_REFILL -#undef MV643XX_COAL - -/* - * Number of RX / TX descriptors on RX / TX rings. - * Note that allocating RX descriptors is done by allocating the RX - * ring AND a preallocated RX buffers (skb's) for each descriptor. - * The TX descriptors only allocates the TX descriptors ring, - * with no pre allocated TX buffers (skb's are allocated by higher layers. - */ - -/* Default TX ring size is 1000 descriptors */ -#define MV643XX_DEFAULT_TX_QUEUE_SIZE 1000 - -/* Default RX ring size is 400 descriptors */ -#define MV643XX_DEFAULT_RX_QUEUE_SIZE 400 - -#define MV643XX_TX_COAL 100 -#ifdef MV643XX_COAL -#define MV643XX_RX_COAL 100 -#endif - -#ifdef MV643XX_CHECKSUM_OFFLOAD_TX -#define MAX_DESCS_PER_SKB (MAX_SKB_FRAGS + 1) -#else -#define MAX_DESCS_PER_SKB 1 -#endif - -#define ETH_VLAN_HLEN 4 -#define ETH_FCS_LEN 4 -#define ETH_HW_IP_ALIGN 2 /* hw aligns IP header */ -#define ETH_WRAPPER_LEN (ETH_HW_IP_ALIGN + ETH_HLEN + \ - ETH_VLAN_HLEN + ETH_FCS_LEN) -#define ETH_RX_SKB_SIZE (dev->mtu + ETH_WRAPPER_LEN + \ - dma_get_cache_alignment()) - -/* - * Registers shared between all ports. - */ -#define PHY_ADDR_REG 0x0000 -#define SMI_REG 0x0004 - -/* - * Per-port registers. - */ -#define PORT_CONFIG_REG(p) (0x0400 + ((p) << 10)) -#define PORT_CONFIG_EXTEND_REG(p) (0x0404 + ((p) << 10)) -#define MAC_ADDR_LOW(p) (0x0414 + ((p) << 10)) -#define MAC_ADDR_HIGH(p) (0x0418 + ((p) << 10)) -#define SDMA_CONFIG_REG(p) (0x041c + ((p) << 10)) -#define PORT_SERIAL_CONTROL_REG(p) (0x043c + ((p) << 10)) -#define PORT_STATUS_REG(p) (0x0444 + ((p) << 10)) -#define TRANSMIT_QUEUE_COMMAND_REG(p) (0x0448 + ((p) << 10)) -#define MAXIMUM_TRANSMIT_UNIT(p) (0x0458 + ((p) << 10)) -#define INTERRUPT_CAUSE_REG(p) (0x0460 + ((p) << 10)) -#define INTERRUPT_CAUSE_EXTEND_REG(p) (0x0464 + ((p) << 10)) -#define INTERRUPT_MASK_REG(p) (0x0468 + ((p) << 10)) -#define INTERRUPT_EXTEND_MASK_REG(p) (0x046c + ((p) << 10)) -#define TX_FIFO_URGENT_THRESHOLD_REG(p) (0x0474 + ((p) << 10)) -#define RX_CURRENT_QUEUE_DESC_PTR_0(p) (0x060c + ((p) << 10)) -#define RECEIVE_QUEUE_COMMAND_REG(p) (0x0680 + ((p) << 10)) -#define TX_CURRENT_QUEUE_DESC_PTR_0(p) (0x06c0 + ((p) << 10)) -#define MIB_COUNTERS_BASE(p) (0x1000 + ((p) << 7)) -#define DA_FILTER_SPECIAL_MULTICAST_TABLE_BASE(p) (0x1400 + ((p) << 10)) -#define DA_FILTER_OTHER_MULTICAST_TABLE_BASE(p) (0x1500 + ((p) << 10)) -#define DA_FILTER_UNICAST_TABLE_BASE(p) (0x1600 + ((p) << 10)) - -/* These macros describe Ethernet Port configuration reg (Px_cR) bits */ -#define UNICAST_NORMAL_MODE (0 << 0) -#define UNICAST_PROMISCUOUS_MODE (1 << 0) -#define DEFAULT_RX_QUEUE(queue) ((queue) << 1) -#define DEFAULT_RX_ARP_QUEUE(queue) ((queue) << 4) -#define RECEIVE_BC_IF_NOT_IP_OR_ARP (0 << 7) -#define REJECT_BC_IF_NOT_IP_OR_ARP (1 << 7) -#define RECEIVE_BC_IF_IP (0 << 8) -#define REJECT_BC_IF_IP (1 << 8) -#define RECEIVE_BC_IF_ARP (0 << 9) -#define REJECT_BC_IF_ARP (1 << 9) -#define TX_AM_NO_UPDATE_ERROR_SUMMARY (1 << 12) -#define CAPTURE_TCP_FRAMES_DIS (0 << 14) -#define CAPTURE_TCP_FRAMES_EN (1 << 14) -#define CAPTURE_UDP_FRAMES_DIS (0 << 15) -#define CAPTURE_UDP_FRAMES_EN (1 << 15) -#define DEFAULT_RX_TCP_QUEUE(queue) ((queue) << 16) -#define DEFAULT_RX_UDP_QUEUE(queue) ((queue) << 19) -#define DEFAULT_RX_BPDU_QUEUE(queue) ((queue) << 22) - -#define PORT_CONFIG_DEFAULT_VALUE \ - UNICAST_NORMAL_MODE | \ - DEFAULT_RX_QUEUE(0) | \ - DEFAULT_RX_ARP_QUEUE(0) | \ - RECEIVE_BC_IF_NOT_IP_OR_ARP | \ - RECEIVE_BC_IF_IP | \ - RECEIVE_BC_IF_ARP | \ - CAPTURE_TCP_FRAMES_DIS | \ - CAPTURE_UDP_FRAMES_DIS | \ - DEFAULT_RX_TCP_QUEUE(0) | \ - DEFAULT_RX_UDP_QUEUE(0) | \ - DEFAULT_RX_BPDU_QUEUE(0) - -/* These macros describe Ethernet Port configuration extend reg (Px_cXR) bits*/ -#define CLASSIFY_EN (1 << 0) -#define SPAN_BPDU_PACKETS_AS_NORMAL (0 << 1) -#define SPAN_BPDU_PACKETS_TO_RX_QUEUE_7 (1 << 1) -#define PARTITION_DISABLE (0 << 2) -#define PARTITION_ENABLE (1 << 2) - -#define PORT_CONFIG_EXTEND_DEFAULT_VALUE \ - SPAN_BPDU_PACKETS_AS_NORMAL | \ - PARTITION_DISABLE - -/* These macros describe Ethernet Port Sdma configuration reg (SDCR) bits */ -#define RIFB (1 << 0) -#define RX_BURST_SIZE_1_64BIT (0 << 1) -#define RX_BURST_SIZE_2_64BIT (1 << 1) -#define RX_BURST_SIZE_4_64BIT (2 << 1) -#define RX_BURST_SIZE_8_64BIT (3 << 1) -#define RX_BURST_SIZE_16_64BIT (4 << 1) -#define BLM_RX_NO_SWAP (1 << 4) -#define BLM_RX_BYTE_SWAP (0 << 4) -#define BLM_TX_NO_SWAP (1 << 5) -#define BLM_TX_BYTE_SWAP (0 << 5) -#define DESCRIPTORS_BYTE_SWAP (1 << 6) -#define DESCRIPTORS_NO_SWAP (0 << 6) -#define IPG_INT_RX(value) (((value) & 0x3fff) << 8) -#define TX_BURST_SIZE_1_64BIT (0 << 22) -#define TX_BURST_SIZE_2_64BIT (1 << 22) -#define TX_BURST_SIZE_4_64BIT (2 << 22) -#define TX_BURST_SIZE_8_64BIT (3 << 22) -#define TX_BURST_SIZE_16_64BIT (4 << 22) - -#if defined(__BIG_ENDIAN) -#define PORT_SDMA_CONFIG_DEFAULT_VALUE \ - RX_BURST_SIZE_4_64BIT | \ - IPG_INT_RX(0) | \ - TX_BURST_SIZE_4_64BIT -#elif defined(__LITTLE_ENDIAN) -#define PORT_SDMA_CONFIG_DEFAULT_VALUE \ - RX_BURST_SIZE_4_64BIT | \ - BLM_RX_NO_SWAP | \ - BLM_TX_NO_SWAP | \ - IPG_INT_RX(0) | \ - TX_BURST_SIZE_4_64BIT -#else -#error One of __BIG_ENDIAN or __LITTLE_ENDIAN must be defined -#endif - -/* These macros describe Ethernet Port serial control reg (PSCR) bits */ -#define SERIAL_PORT_DISABLE (0 << 0) -#define SERIAL_PORT_ENABLE (1 << 0) -#define DO_NOT_FORCE_LINK_PASS (0 << 1) -#define FORCE_LINK_PASS (1 << 1) -#define ENABLE_AUTO_NEG_FOR_DUPLX (0 << 2) -#define DISABLE_AUTO_NEG_FOR_DUPLX (1 << 2) -#define ENABLE_AUTO_NEG_FOR_FLOW_CTRL (0 << 3) -#define DISABLE_AUTO_NEG_FOR_FLOW_CTRL (1 << 3) -#define ADV_NO_FLOW_CTRL (0 << 4) -#define ADV_SYMMETRIC_FLOW_CTRL (1 << 4) -#define FORCE_FC_MODE_NO_PAUSE_DIS_TX (0 << 5) -#define FORCE_FC_MODE_TX_PAUSE_DIS (1 << 5) -#define FORCE_BP_MODE_NO_JAM (0 << 7) -#define FORCE_BP_MODE_JAM_TX (1 << 7) -#define FORCE_BP_MODE_JAM_TX_ON_RX_ERR (2 << 7) -#define SERIAL_PORT_CONTROL_RESERVED (1 << 9) -#define FORCE_LINK_FAIL (0 << 10) -#define DO_NOT_FORCE_LINK_FAIL (1 << 10) -#define RETRANSMIT_16_ATTEMPTS (0 << 11) -#define RETRANSMIT_FOREVER (1 << 11) -#define ENABLE_AUTO_NEG_SPEED_GMII (0 << 13) -#define DISABLE_AUTO_NEG_SPEED_GMII (1 << 13) -#define DTE_ADV_0 (0 << 14) -#define DTE_ADV_1 (1 << 14) -#define DISABLE_AUTO_NEG_BYPASS (0 << 15) -#define ENABLE_AUTO_NEG_BYPASS (1 << 15) -#define AUTO_NEG_NO_CHANGE (0 << 16) -#define RESTART_AUTO_NEG (1 << 16) -#define MAX_RX_PACKET_1518BYTE (0 << 17) -#define MAX_RX_PACKET_1522BYTE (1 << 17) -#define MAX_RX_PACKET_1552BYTE (2 << 17) -#define MAX_RX_PACKET_9022BYTE (3 << 17) -#define MAX_RX_PACKET_9192BYTE (4 << 17) -#define MAX_RX_PACKET_9700BYTE (5 << 17) -#define MAX_RX_PACKET_MASK (7 << 17) -#define CLR_EXT_LOOPBACK (0 << 20) -#define SET_EXT_LOOPBACK (1 << 20) -#define SET_HALF_DUPLEX_MODE (0 << 21) -#define SET_FULL_DUPLEX_MODE (1 << 21) -#define DISABLE_FLOW_CTRL_TX_RX_IN_FULL_DUPLEX (0 << 22) -#define ENABLE_FLOW_CTRL_TX_RX_IN_FULL_DUPLEX (1 << 22) -#define SET_GMII_SPEED_TO_10_100 (0 << 23) -#define SET_GMII_SPEED_TO_1000 (1 << 23) -#define SET_MII_SPEED_TO_10 (0 << 24) -#define SET_MII_SPEED_TO_100 (1 << 24) - -#define PORT_SERIAL_CONTROL_DEFAULT_VALUE \ - DO_NOT_FORCE_LINK_PASS | \ - ENABLE_AUTO_NEG_FOR_DUPLX | \ - DISABLE_AUTO_NEG_FOR_FLOW_CTRL | \ - ADV_SYMMETRIC_FLOW_CTRL | \ - FORCE_FC_MODE_NO_PAUSE_DIS_TX | \ - FORCE_BP_MODE_NO_JAM | \ - (1 << 9) /* reserved */ | \ - DO_NOT_FORCE_LINK_FAIL | \ - RETRANSMIT_16_ATTEMPTS | \ - ENABLE_AUTO_NEG_SPEED_GMII | \ - DTE_ADV_0 | \ - DISABLE_AUTO_NEG_BYPASS | \ - AUTO_NEG_NO_CHANGE | \ - MAX_RX_PACKET_9700BYTE | \ - CLR_EXT_LOOPBACK | \ - SET_FULL_DUPLEX_MODE | \ - ENABLE_FLOW_CTRL_TX_RX_IN_FULL_DUPLEX - -/* These macros describe Ethernet Serial Status reg (PSR) bits */ -#define PORT_STATUS_MODE_10_BIT (1 << 0) -#define PORT_STATUS_LINK_UP (1 << 1) -#define PORT_STATUS_FULL_DUPLEX (1 << 2) -#define PORT_STATUS_FLOW_CONTROL (1 << 3) -#define PORT_STATUS_GMII_1000 (1 << 4) -#define PORT_STATUS_MII_100 (1 << 5) -/* PSR bit 6 is undocumented */ -#define PORT_STATUS_TX_IN_PROGRESS (1 << 7) -#define PORT_STATUS_AUTONEG_BYPASSED (1 << 8) -#define PORT_STATUS_PARTITION (1 << 9) -#define PORT_STATUS_TX_FIFO_EMPTY (1 << 10) -/* PSR bits 11-31 are reserved */ - -#define PORT_DEFAULT_TRANSMIT_QUEUE_SIZE 800 -#define PORT_DEFAULT_RECEIVE_QUEUE_SIZE 400 - -#define DESC_SIZE 64 - -#define ETH_RX_QUEUES_ENABLED (1 << 0) /* use only Q0 for receive */ -#define ETH_TX_QUEUES_ENABLED (1 << 0) /* use only Q0 for transmit */ - -#define ETH_INT_CAUSE_RX_DONE (ETH_RX_QUEUES_ENABLED << 2) -#define ETH_INT_CAUSE_RX_ERROR (ETH_RX_QUEUES_ENABLED << 9) -#define ETH_INT_CAUSE_RX (ETH_INT_CAUSE_RX_DONE | ETH_INT_CAUSE_RX_ERROR) -#define ETH_INT_CAUSE_EXT 0x00000002 -#define ETH_INT_UNMASK_ALL (ETH_INT_CAUSE_RX | ETH_INT_CAUSE_EXT) - -#define ETH_INT_CAUSE_TX_DONE (ETH_TX_QUEUES_ENABLED << 0) -#define ETH_INT_CAUSE_TX_ERROR (ETH_TX_QUEUES_ENABLED << 8) -#define ETH_INT_CAUSE_TX (ETH_INT_CAUSE_TX_DONE | ETH_INT_CAUSE_TX_ERROR) -#define ETH_INT_CAUSE_PHY 0x00010000 -#define ETH_INT_CAUSE_STATE 0x00100000 -#define ETH_INT_UNMASK_ALL_EXT (ETH_INT_CAUSE_TX | ETH_INT_CAUSE_PHY | \ - ETH_INT_CAUSE_STATE) - -#define ETH_INT_MASK_ALL 0x00000000 -#define ETH_INT_MASK_ALL_EXT 0x00000000 - -#define PHY_WAIT_ITERATIONS 1000 /* 1000 iterations * 10uS = 10mS max */ -#define PHY_WAIT_MICRO_SECONDS 10 - -/* Buffer offset from buffer pointer */ -#define RX_BUF_OFFSET 0x2 - -/* Gigabit Ethernet Unit Global Registers */ - -/* MIB Counters register definitions */ -#define ETH_MIB_GOOD_OCTETS_RECEIVED_LOW 0x0 -#define ETH_MIB_GOOD_OCTETS_RECEIVED_HIGH 0x4 -#define ETH_MIB_BAD_OCTETS_RECEIVED 0x8 -#define ETH_MIB_INTERNAL_MAC_TRANSMIT_ERR 0xc -#define ETH_MIB_GOOD_FRAMES_RECEIVED 0x10 -#define ETH_MIB_BAD_FRAMES_RECEIVED 0x14 -#define ETH_MIB_BROADCAST_FRAMES_RECEIVED 0x18 -#define ETH_MIB_MULTICAST_FRAMES_RECEIVED 0x1c -#define ETH_MIB_FRAMES_64_OCTETS 0x20 -#define ETH_MIB_FRAMES_65_TO_127_OCTETS 0x24 -#define ETH_MIB_FRAMES_128_TO_255_OCTETS 0x28 -#define ETH_MIB_FRAMES_256_TO_511_OCTETS 0x2c -#define ETH_MIB_FRAMES_512_TO_1023_OCTETS 0x30 -#define ETH_MIB_FRAMES_1024_TO_MAX_OCTETS 0x34 -#define ETH_MIB_GOOD_OCTETS_SENT_LOW 0x38 -#define ETH_MIB_GOOD_OCTETS_SENT_HIGH 0x3c -#define ETH_MIB_GOOD_FRAMES_SENT 0x40 -#define ETH_MIB_EXCESSIVE_COLLISION 0x44 -#define ETH_MIB_MULTICAST_FRAMES_SENT 0x48 -#define ETH_MIB_BROADCAST_FRAMES_SENT 0x4c -#define ETH_MIB_UNREC_MAC_CONTROL_RECEIVED 0x50 -#define ETH_MIB_FC_SENT 0x54 -#define ETH_MIB_GOOD_FC_RECEIVED 0x58 -#define ETH_MIB_BAD_FC_RECEIVED 0x5c -#define ETH_MIB_UNDERSIZE_RECEIVED 0x60 -#define ETH_MIB_FRAGMENTS_RECEIVED 0x64 -#define ETH_MIB_OVERSIZE_RECEIVED 0x68 -#define ETH_MIB_JABBER_RECEIVED 0x6c -#define ETH_MIB_MAC_RECEIVE_ERROR 0x70 -#define ETH_MIB_BAD_CRC_EVENT 0x74 -#define ETH_MIB_COLLISION 0x78 -#define ETH_MIB_LATE_COLLISION 0x7c - -/* Port serial status reg (PSR) */ -#define ETH_INTERFACE_PCM 0x00000001 -#define ETH_LINK_IS_UP 0x00000002 -#define ETH_PORT_AT_FULL_DUPLEX 0x00000004 -#define ETH_RX_FLOW_CTRL_ENABLED 0x00000008 -#define ETH_GMII_SPEED_1000 0x00000010 -#define ETH_MII_SPEED_100 0x00000020 -#define ETH_TX_IN_PROGRESS 0x00000080 -#define ETH_BYPASS_ACTIVE 0x00000100 -#define ETH_PORT_AT_PARTITION_STATE 0x00000200 -#define ETH_PORT_TX_FIFO_EMPTY 0x00000400 - -/* SMI reg */ -#define ETH_SMI_BUSY 0x10000000 /* 0 - Write, 1 - Read */ -#define ETH_SMI_READ_VALID 0x08000000 /* 0 - Write, 1 - Read */ -#define ETH_SMI_OPCODE_WRITE 0 /* Completion of Read */ -#define ETH_SMI_OPCODE_READ 0x04000000 /* Operation is in progress */ - -/* Interrupt Cause Register Bit Definitions */ - -/* SDMA command status fields macros */ - -/* Tx & Rx descriptors status */ -#define ETH_ERROR_SUMMARY 0x00000001 - -/* Tx & Rx descriptors command */ -#define ETH_BUFFER_OWNED_BY_DMA 0x80000000 - -/* Tx descriptors status */ -#define ETH_LC_ERROR 0 -#define ETH_UR_ERROR 0x00000002 -#define ETH_RL_ERROR 0x00000004 -#define ETH_LLC_SNAP_FORMAT 0x00000200 - -/* Rx descriptors status */ -#define ETH_OVERRUN_ERROR 0x00000002 -#define ETH_MAX_FRAME_LENGTH_ERROR 0x00000004 -#define ETH_RESOURCE_ERROR 0x00000006 -#define ETH_VLAN_TAGGED 0x00080000 -#define ETH_BPDU_FRAME 0x00100000 -#define ETH_UDP_FRAME_OVER_IP_V_4 0x00200000 -#define ETH_OTHER_FRAME_TYPE 0x00400000 -#define ETH_LAYER_2_IS_ETH_V_2 0x00800000 -#define ETH_FRAME_TYPE_IP_V_4 0x01000000 -#define ETH_FRAME_HEADER_OK 0x02000000 -#define ETH_RX_LAST_DESC 0x04000000 -#define ETH_RX_FIRST_DESC 0x08000000 -#define ETH_UNKNOWN_DESTINATION_ADDR 0x10000000 -#define ETH_RX_ENABLE_INTERRUPT 0x20000000 -#define ETH_LAYER_4_CHECKSUM_OK 0x40000000 - -/* Rx descriptors byte count */ -#define ETH_FRAME_FRAGMENTED 0x00000004 - -/* Tx descriptors command */ -#define ETH_LAYER_4_CHECKSUM_FIRST_DESC 0x00000400 -#define ETH_FRAME_SET_TO_VLAN 0x00008000 -#define ETH_UDP_FRAME 0x00010000 -#define ETH_GEN_TCP_UDP_CHECKSUM 0x00020000 -#define ETH_GEN_IP_V_4_CHECKSUM 0x00040000 -#define ETH_ZERO_PADDING 0x00080000 -#define ETH_TX_LAST_DESC 0x00100000 -#define ETH_TX_FIRST_DESC 0x00200000 -#define ETH_GEN_CRC 0x00400000 -#define ETH_TX_ENABLE_INTERRUPT 0x00800000 -#define ETH_AUTO_MODE 0x40000000 - -#define ETH_TX_IHL_SHIFT 11 - -/* typedefs */ - -typedef enum _eth_func_ret_status { - ETH_OK, /* Returned as expected. */ - ETH_ERROR, /* Fundamental error. */ - ETH_RETRY, /* Could not process request. Try later.*/ - ETH_END_OF_JOB, /* Ring has nothing to process. */ - ETH_QUEUE_FULL, /* Ring resource error. */ - ETH_QUEUE_LAST_RESOURCE /* Ring resources about to exhaust. */ -} ETH_FUNC_RET_STATUS; - -typedef enum _eth_target { - ETH_TARGET_DRAM, - ETH_TARGET_DEVICE, - ETH_TARGET_CBS, - ETH_TARGET_PCI0, - ETH_TARGET_PCI1 -} ETH_TARGET; - -/* These are for big-endian machines. Little endian needs different - * definitions. - */ -#if defined(__BIG_ENDIAN) -struct eth_rx_desc { - u16 byte_cnt; /* Descriptor buffer byte count */ - u16 buf_size; /* Buffer size */ - u32 cmd_sts; /* Descriptor command status */ - u32 next_desc_ptr; /* Next descriptor pointer */ - u32 buf_ptr; /* Descriptor buffer pointer */ -}; - -struct eth_tx_desc { - u16 byte_cnt; /* buffer byte count */ - u16 l4i_chk; /* CPU provided TCP checksum */ - u32 cmd_sts; /* Command/status field */ - u32 next_desc_ptr; /* Pointer to next descriptor */ - u32 buf_ptr; /* pointer to buffer for this descriptor*/ -}; -#elif defined(__LITTLE_ENDIAN) -struct eth_rx_desc { - u32 cmd_sts; /* Descriptor command status */ - u16 buf_size; /* Buffer size */ - u16 byte_cnt; /* Descriptor buffer byte count */ - u32 buf_ptr; /* Descriptor buffer pointer */ - u32 next_desc_ptr; /* Next descriptor pointer */ -}; - -struct eth_tx_desc { - u32 cmd_sts; /* Command/status field */ - u16 l4i_chk; /* CPU provided TCP checksum */ - u16 byte_cnt; /* buffer byte count */ - u32 buf_ptr; /* pointer to buffer for this descriptor*/ - u32 next_desc_ptr; /* Pointer to next descriptor */ -}; -#else -#error One of __BIG_ENDIAN or __LITTLE_ENDIAN must be defined -#endif - -/* Unified struct for Rx and Tx operations. The user is not required to */ -/* be familier with neither Tx nor Rx descriptors. */ -struct pkt_info { - unsigned short byte_cnt; /* Descriptor buffer byte count */ - unsigned short l4i_chk; /* Tx CPU provided TCP Checksum */ - unsigned int cmd_sts; /* Descriptor command status */ - dma_addr_t buf_ptr; /* Descriptor buffer pointer */ - struct sk_buff *return_info; /* User resource return information */ -}; - -/* Ethernet port specific information */ -struct mv643xx_mib_counters { - u64 good_octets_received; - u32 bad_octets_received; - u32 internal_mac_transmit_err; - u32 good_frames_received; - u32 bad_frames_received; - u32 broadcast_frames_received; - u32 multicast_frames_received; - u32 frames_64_octets; - u32 frames_65_to_127_octets; - u32 frames_128_to_255_octets; - u32 frames_256_to_511_octets; - u32 frames_512_to_1023_octets; - u32 frames_1024_to_max_octets; - u64 good_octets_sent; - u32 good_frames_sent; - u32 excessive_collision; - u32 multicast_frames_sent; - u32 broadcast_frames_sent; - u32 unrec_mac_control_received; - u32 fc_sent; - u32 good_fc_received; - u32 bad_fc_received; - u32 undersize_received; - u32 fragments_received; - u32 oversize_received; - u32 jabber_received; - u32 mac_receive_error; - u32 bad_crc_event; - u32 collision; - u32 late_collision; -}; - -struct mv643xx_private { - int port_num; /* User Ethernet port number */ - - u32 rx_sram_addr; /* Base address of rx sram area */ - u32 rx_sram_size; /* Size of rx sram area */ - u32 tx_sram_addr; /* Base address of tx sram area */ - u32 tx_sram_size; /* Size of tx sram area */ - - int rx_resource_err; /* Rx ring resource error flag */ - - /* Tx/Rx rings managment indexes fields. For driver use */ - - /* Next available and first returning Rx resource */ - int rx_curr_desc_q, rx_used_desc_q; - - /* Next available and first returning Tx resource */ - int tx_curr_desc_q, tx_used_desc_q; - -#ifdef MV643XX_TX_FAST_REFILL - u32 tx_clean_threshold; -#endif - - struct eth_rx_desc *p_rx_desc_area; - dma_addr_t rx_desc_dma; - int rx_desc_area_size; - struct sk_buff **rx_skb; - - struct eth_tx_desc *p_tx_desc_area; - dma_addr_t tx_desc_dma; - int tx_desc_area_size; - struct sk_buff **tx_skb; - - struct work_struct tx_timeout_task; - - struct net_device *dev; - struct napi_struct napi; - struct net_device_stats stats; - struct mv643xx_mib_counters mib_counters; - spinlock_t lock; - /* Size of Tx Ring per queue */ - int tx_ring_size; - /* Number of tx descriptors in use */ - int tx_desc_count; - /* Size of Rx Ring per queue */ - int rx_ring_size; - /* Number of rx descriptors in use */ - int rx_desc_count; - - /* - * Used in case RX Ring is empty, which can be caused when - * system does not have resources (skb's) - */ - struct timer_list timeout; - - u32 rx_int_coal; - u32 tx_int_coal; - struct mii_if_info mii; -}; +#include "mv643xx_eth.h" /* Static function declarations */ -static void eth_port_init(struct mv643xx_private *mp); -static void eth_port_reset(unsigned int eth_port_num); -static void eth_port_start(struct net_device *dev); - -static void ethernet_phy_reset(unsigned int eth_port_num); - -static void eth_port_write_smi_reg(unsigned int eth_port_num, - unsigned int phy_reg, unsigned int value); - -static void eth_port_read_smi_reg(unsigned int eth_port_num, - unsigned int phy_reg, unsigned int *value); - -static void eth_clear_mib_counters(unsigned int eth_port_num); - -static ETH_FUNC_RET_STATUS eth_port_receive(struct mv643xx_private *mp, - struct pkt_info *p_pkt_info); -static ETH_FUNC_RET_STATUS eth_rx_return_buff(struct mv643xx_private *mp, - struct pkt_info *p_pkt_info); - static void eth_port_uc_addr_get(unsigned int port_num, unsigned char *p_addr); static void eth_port_uc_addr_set(unsigned int port_num, unsigned char *p_addr); static void eth_port_set_multicast_list(struct net_device *); @@ -631,19 +78,26 @@ static const struct ethtool_ops mv643xx_ethtool_ops; static char mv643xx_driver_name[] = "mv643xx_eth"; static char mv643xx_driver_version[] = "1.0"; -static void __iomem *mv643xx_eth_base; +static void __iomem *mv643xx_eth_shared_base; -/* used to protect SMI_REG, which is shared across ports */ +/* used to protect MV643XX_ETH_SMI_REG, which is shared across ports */ static DEFINE_SPINLOCK(mv643xx_eth_phy_lock); static inline u32 mv_read(int offset) { - return readl(mv643xx_eth_base + offset); + void __iomem *reg_base; + + reg_base = mv643xx_eth_shared_base - MV643XX_ETH_SHARED_REGS; + + return readl(reg_base + offset); } static inline void mv_write(int offset, u32 data) { - writel(data, mv643xx_eth_base + offset); + void __iomem *reg_base; + + reg_base = mv643xx_eth_shared_base - MV643XX_ETH_SHARED_REGS; + writel(data, reg_base + offset); } /* @@ -767,12 +221,12 @@ static void mv643xx_eth_set_rx_mode(struct net_device *dev) struct mv643xx_private *mp = netdev_priv(dev); u32 config_reg; - config_reg = mv_read(PORT_CONFIG_REG(mp->port_num)); + config_reg = mv_read(MV643XX_ETH_PORT_CONFIG_REG(mp->port_num)); if (dev->flags & IFF_PROMISC) - config_reg |= (u32) UNICAST_PROMISCUOUS_MODE; + config_reg |= (u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE; else - config_reg &= ~(u32) UNICAST_PROMISCUOUS_MODE; - mv_write(PORT_CONFIG_REG(mp->port_num), config_reg); + config_reg &= ~(u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE; + mv_write(MV643XX_ETH_PORT_CONFIG_REG(mp->port_num), config_reg); eth_port_set_multicast_list(dev); } @@ -1008,37 +462,41 @@ static void mv643xx_eth_update_pscr(struct net_device *dev, u32 o_pscr, n_pscr; unsigned int queues; - o_pscr = mv_read(PORT_SERIAL_CONTROL_REG(port_num)); + o_pscr = mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num)); n_pscr = o_pscr; /* clear speed, duplex and rx buffer size fields */ - n_pscr &= ~(SET_MII_SPEED_TO_100 | - SET_GMII_SPEED_TO_1000 | - SET_FULL_DUPLEX_MODE | - MAX_RX_PACKET_MASK); + n_pscr &= ~(MV643XX_ETH_SET_MII_SPEED_TO_100 | + MV643XX_ETH_SET_GMII_SPEED_TO_1000 | + MV643XX_ETH_SET_FULL_DUPLEX_MODE | + MV643XX_ETH_MAX_RX_PACKET_MASK); if (ecmd->duplex == DUPLEX_FULL) - n_pscr |= SET_FULL_DUPLEX_MODE; + n_pscr |= MV643XX_ETH_SET_FULL_DUPLEX_MODE; if (ecmd->speed == SPEED_1000) - n_pscr |= SET_GMII_SPEED_TO_1000 | - MAX_RX_PACKET_9700BYTE; + n_pscr |= MV643XX_ETH_SET_GMII_SPEED_TO_1000 | + MV643XX_ETH_MAX_RX_PACKET_9700BYTE; else { if (ecmd->speed == SPEED_100) - n_pscr |= SET_MII_SPEED_TO_100; - n_pscr |= MAX_RX_PACKET_1522BYTE; + n_pscr |= MV643XX_ETH_SET_MII_SPEED_TO_100; + n_pscr |= MV643XX_ETH_MAX_RX_PACKET_1522BYTE; } if (n_pscr != o_pscr) { - if ((o_pscr & SERIAL_PORT_ENABLE) == 0) - mv_write(PORT_SERIAL_CONTROL_REG(port_num), n_pscr); + if ((o_pscr & MV643XX_ETH_SERIAL_PORT_ENABLE) == 0) + mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), + n_pscr); else { queues = mv643xx_eth_port_disable_tx(port_num); - o_pscr &= ~SERIAL_PORT_ENABLE; - mv_write(PORT_SERIAL_CONTROL_REG(port_num), o_pscr); - mv_write(PORT_SERIAL_CONTROL_REG(port_num), n_pscr); - mv_write(PORT_SERIAL_CONTROL_REG(port_num), n_pscr); + o_pscr &= ~MV643XX_ETH_SERIAL_PORT_ENABLE; + mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), + o_pscr); + mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), + n_pscr); + mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), + n_pscr); if (queues) mv643xx_eth_port_enable_tx(port_num, queues); } @@ -1064,13 +522,13 @@ static irqreturn_t mv643xx_eth_int_handler(int irq, void *dev_id) unsigned int port_num = mp->port_num; /* Read interrupt cause registers */ - eth_int_cause = mv_read(INTERRUPT_CAUSE_REG(port_num)) & + eth_int_cause = mv_read(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num)) & ETH_INT_UNMASK_ALL; if (eth_int_cause & ETH_INT_CAUSE_EXT) { eth_int_cause_ext = mv_read( - INTERRUPT_CAUSE_EXTEND_REG(port_num)) & + MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num)) & ETH_INT_UNMASK_ALL_EXT; - mv_write(INTERRUPT_CAUSE_EXTEND_REG(port_num), + mv_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num), ~eth_int_cause_ext); } @@ -1098,10 +556,10 @@ static irqreturn_t mv643xx_eth_int_handler(int irq, void *dev_id) #ifdef MV643XX_NAPI if (eth_int_cause & ETH_INT_CAUSE_RX) { /* schedule the NAPI poll routine to maintain port */ - mv_write(INTERRUPT_MASK_REG(port_num), ETH_INT_MASK_ALL); - + mv_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num), + ETH_INT_MASK_ALL); /* wait for previous write to complete */ - mv_read(INTERRUPT_MASK_REG(port_num)); + mv_read(MV643XX_ETH_INTERRUPT_MASK_REG(port_num)); netif_rx_schedule(dev, &mp->napi); } @@ -1153,9 +611,9 @@ static unsigned int eth_port_set_rx_coal(unsigned int eth_port_num, unsigned int coal = ((t_clk / 1000000) * delay) / 64; /* Set RX Coalescing mechanism */ - mv_write(SDMA_CONFIG_REG(eth_port_num), + mv_write(MV643XX_ETH_SDMA_CONFIG_REG(eth_port_num), ((coal & 0x3fff) << 8) | - (mv_read(SDMA_CONFIG_REG(eth_port_num)) + (mv_read(MV643XX_ETH_SDMA_CONFIG_REG(eth_port_num)) & 0xffc000ff)); return coal; @@ -1191,7 +649,8 @@ static unsigned int eth_port_set_tx_coal(unsigned int eth_port_num, unsigned int coal; coal = ((t_clk / 1000000) * delay) / 64; /* Set TX Coalescing mechanism */ - mv_write(TX_FIFO_URGENT_THRESHOLD_REG(eth_port_num), coal << 4); + mv_write(MV643XX_ETH_TX_FIFO_URGENT_THRESHOLD_REG(eth_port_num), + coal << 4); return coal; } @@ -1327,10 +786,10 @@ static int mv643xx_eth_open(struct net_device *dev) int err; /* Clear any pending ethernet port interrupts */ - mv_write(INTERRUPT_CAUSE_REG(port_num), 0); - mv_write(INTERRUPT_CAUSE_EXTEND_REG(port_num), 0); + mv_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num), 0); + mv_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num), 0); /* wait for previous write to complete */ - mv_read (INTERRUPT_CAUSE_EXTEND_REG(port_num)); + mv_read (MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num)); err = request_irq(dev->irq, mv643xx_eth_int_handler, IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name, dev); @@ -1437,10 +896,11 @@ static int mv643xx_eth_open(struct net_device *dev) eth_port_set_tx_coal(port_num, 133000000, MV643XX_TX_COAL); /* Unmask phy and link status changes interrupts */ - mv_write(INTERRUPT_EXTEND_MASK_REG(port_num), ETH_INT_UNMASK_ALL_EXT); + mv_write(MV643XX_ETH_INTERRUPT_EXTEND_MASK_REG(port_num), + ETH_INT_UNMASK_ALL_EXT); /* Unmask RX buffer and TX end interrupt */ - mv_write(INTERRUPT_MASK_REG(port_num), ETH_INT_UNMASK_ALL); + mv_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num), ETH_INT_UNMASK_ALL); return 0; @@ -1520,9 +980,9 @@ static int mv643xx_eth_stop(struct net_device *dev) unsigned int port_num = mp->port_num; /* Mask all interrupts on ethernet port */ - mv_write(INTERRUPT_MASK_REG(port_num), ETH_INT_MASK_ALL); + mv_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num), ETH_INT_MASK_ALL); /* wait for previous write to complete */ - mv_read(INTERRUPT_MASK_REG(port_num)); + mv_read(MV643XX_ETH_INTERRUPT_MASK_REG(port_num)); #ifdef MV643XX_NAPI napi_disable(&mp->napi); @@ -1561,15 +1021,16 @@ static int mv643xx_poll(struct napi_struct *napi, int budget) #endif work_done = 0; - if ((mv_read(RX_CURRENT_QUEUE_DESC_PTR_0(port_num))) + if ((mv_read(MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_0(port_num))) != (u32) mp->rx_used_desc_q) work_done = mv643xx_eth_receive_queue(dev, budget); if (work_done < budget) { netif_rx_complete(dev, napi); - mv_write(INTERRUPT_CAUSE_REG(port_num), 0); - mv_write(INTERRUPT_CAUSE_EXTEND_REG(port_num), 0); - mv_write(INTERRUPT_MASK_REG(port_num), ETH_INT_UNMASK_ALL); + mv_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num), 0); + mv_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num), 0); + mv_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num), + ETH_INT_UNMASK_ALL); } return work_done; @@ -1772,13 +1233,13 @@ static void mv643xx_netpoll(struct net_device *netdev) struct mv643xx_private *mp = netdev_priv(netdev); int port_num = mp->port_num; - mv_write(INTERRUPT_MASK_REG(port_num), ETH_INT_MASK_ALL); + mv_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num), ETH_INT_MASK_ALL); /* wait for previous write to complete */ - mv_read(INTERRUPT_MASK_REG(port_num)); + mv_read(MV643XX_ETH_INTERRUPT_MASK_REG(port_num)); mv643xx_eth_int_handler(netdev->irq, netdev); - mv_write(INTERRUPT_MASK_REG(port_num), ETH_INT_UNMASK_ALL); + mv_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num), ETH_INT_UNMASK_ALL); } #endif @@ -1896,8 +1357,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev) /* set default config values */ eth_port_uc_addr_get(port_num, dev->dev_addr); - mp->rx_ring_size = PORT_DEFAULT_RECEIVE_QUEUE_SIZE; - mp->tx_ring_size = PORT_DEFAULT_TRANSMIT_QUEUE_SIZE; + mp->rx_ring_size = MV643XX_ETH_PORT_DEFAULT_RECEIVE_QUEUE_SIZE; + mp->tx_ring_size = MV643XX_ETH_PORT_DEFAULT_TRANSMIT_QUEUE_SIZE; if (is_valid_ether_addr(pd->mac_addr)) memcpy(dev->dev_addr, pd->mac_addr, 6); @@ -2009,8 +1470,9 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev) if (res == NULL) return -ENODEV; - mv643xx_eth_base = ioremap(res->start, res->end - res->start + 1); - if (mv643xx_eth_base == NULL) + mv643xx_eth_shared_base = ioremap(res->start, + MV643XX_ETH_SHARED_REGS_SIZE); + if (mv643xx_eth_shared_base == NULL) return -ENOMEM; return 0; @@ -2019,8 +1481,8 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev) static int mv643xx_eth_shared_remove(struct platform_device *pdev) { - iounmap(mv643xx_eth_base); - mv643xx_eth_base = NULL; + iounmap(mv643xx_eth_shared_base); + mv643xx_eth_shared_base = NULL; return 0; } @@ -2032,8 +1494,8 @@ static void mv643xx_eth_shutdown(struct platform_device *pdev) unsigned int port_num = mp->port_num; /* Mask all interrupts on ethernet port */ - mv_write(INTERRUPT_MASK_REG(port_num), 0); - mv_read (INTERRUPT_MASK_REG(port_num)); + mv_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num), 0); + mv_read (MV643XX_ETH_INTERRUPT_MASK_REG(port_num)); eth_port_reset(port_num); } @@ -2300,49 +1762,49 @@ static void eth_port_start(struct net_device *dev) /* Assignment of Tx CTRP of given queue */ tx_curr_desc = mp->tx_curr_desc_q; - mv_write(TX_CURRENT_QUEUE_DESC_PTR_0(port_num), + mv_write(MV643XX_ETH_TX_CURRENT_QUEUE_DESC_PTR_0(port_num), (u32)((struct eth_tx_desc *)mp->tx_desc_dma + tx_curr_desc)); /* Assignment of Rx CRDP of given queue */ rx_curr_desc = mp->rx_curr_desc_q; - mv_write(RX_CURRENT_QUEUE_DESC_PTR_0(port_num), + mv_write(MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_0(port_num), (u32)((struct eth_rx_desc *)mp->rx_desc_dma + rx_curr_desc)); /* Add the assigned Ethernet address to the port's address table */ eth_port_uc_addr_set(port_num, dev->dev_addr); /* Assign port configuration and command. */ - mv_write(PORT_CONFIG_REG(port_num), - PORT_CONFIG_DEFAULT_VALUE); + mv_write(MV643XX_ETH_PORT_CONFIG_REG(port_num), + MV643XX_ETH_PORT_CONFIG_DEFAULT_VALUE); - mv_write(PORT_CONFIG_EXTEND_REG(port_num), - PORT_CONFIG_EXTEND_DEFAULT_VALUE); + mv_write(MV643XX_ETH_PORT_CONFIG_EXTEND_REG(port_num), + MV643XX_ETH_PORT_CONFIG_EXTEND_DEFAULT_VALUE); - pscr = mv_read(PORT_SERIAL_CONTROL_REG(port_num)); + pscr = mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num)); - pscr &= ~(SERIAL_PORT_ENABLE | FORCE_LINK_PASS); - mv_write(PORT_SERIAL_CONTROL_REG(port_num), pscr); + pscr &= ~(MV643XX_ETH_SERIAL_PORT_ENABLE | MV643XX_ETH_FORCE_LINK_PASS); + mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), pscr); - pscr |= DISABLE_AUTO_NEG_FOR_FLOW_CTRL | - DISABLE_AUTO_NEG_SPEED_GMII | - DISABLE_AUTO_NEG_FOR_DUPLX | - DO_NOT_FORCE_LINK_FAIL | - SERIAL_PORT_CONTROL_RESERVED; + pscr |= MV643XX_ETH_DISABLE_AUTO_NEG_FOR_FLOW_CTRL | + MV643XX_ETH_DISABLE_AUTO_NEG_SPEED_GMII | + MV643XX_ETH_DISABLE_AUTO_NEG_FOR_DUPLX | + MV643XX_ETH_DO_NOT_FORCE_LINK_FAIL | + MV643XX_ETH_SERIAL_PORT_CONTROL_RESERVED; - mv_write(PORT_SERIAL_CONTROL_REG(port_num), pscr); + mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), pscr); - pscr |= SERIAL_PORT_ENABLE; - mv_write(PORT_SERIAL_CONTROL_REG(port_num), pscr); + pscr |= MV643XX_ETH_SERIAL_PORT_ENABLE; + mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), pscr); /* Assign port SDMA configuration */ - mv_write(SDMA_CONFIG_REG(port_num), - PORT_SDMA_CONFIG_DEFAULT_VALUE); + mv_write(MV643XX_ETH_SDMA_CONFIG_REG(port_num), + MV643XX_ETH_PORT_SDMA_CONFIG_DEFAULT_VALUE); /* Enable port Rx. */ mv643xx_eth_port_enable_rx(port_num, ETH_RX_QUEUES_ENABLED); /* Disable port bandwidth limits by clearing MTU register */ - mv_write(MAXIMUM_TRANSMIT_UNIT(port_num), 0); + mv_write(MV643XX_ETH_MAXIMUM_TRANSMIT_UNIT(port_num), 0); /* save phy settings across reset */ mv643xx_get_settings(dev, ðtool_cmd); @@ -2363,11 +1825,11 @@ static void eth_port_uc_addr_set(unsigned int port_num, unsigned char *p_addr) mac_h = (p_addr[0] << 24) | (p_addr[1] << 16) | (p_addr[2] << 8) | (p_addr[3] << 0); - mv_write(MAC_ADDR_LOW(port_num), mac_l); - mv_write(MAC_ADDR_HIGH(port_num), mac_h); + mv_write(MV643XX_ETH_MAC_ADDR_LOW(port_num), mac_l); + mv_write(MV643XX_ETH_MAC_ADDR_HIGH(port_num), mac_h); /* Accept frames with this address */ - table = DA_FILTER_UNICAST_TABLE_BASE(port_num); + table = MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE(port_num); eth_port_set_filter_table_entry(table, p_addr[5] & 0x0f); } @@ -2379,8 +1841,8 @@ static void eth_port_uc_addr_get(unsigned int port_num, unsigned char *p_addr) unsigned int mac_h; unsigned int mac_l; - mac_h = mv_read(MAC_ADDR_HIGH(port_num)); - mac_l = mv_read(MAC_ADDR_LOW(port_num)); + mac_h = mv_read(MV643XX_ETH_MAC_ADDR_HIGH(port_num)); + mac_l = mv_read(MV643XX_ETH_MAC_ADDR_LOW(port_num)); p_addr[0] = (mac_h >> 24) & 0xff; p_addr[1] = (mac_h >> 16) & 0xff; @@ -2440,7 +1902,7 @@ static void eth_port_mc_addr(unsigned int eth_port_num, unsigned char *p_addr) if ((p_addr[0] == 0x01) && (p_addr[1] == 0x00) && (p_addr[2] == 0x5E) && (p_addr[3] == 0x00) && (p_addr[4] == 0x00)) { - table = DA_FILTER_SPECIAL_MULTICAST_TABLE_BASE + table = MV643XX_ETH_DA_FILTER_SPECIAL_MULTICAST_TABLE_BASE (eth_port_num); eth_port_set_filter_table_entry(table, p_addr[5]); return; @@ -2514,7 +1976,7 @@ static void eth_port_mc_addr(unsigned int eth_port_num, unsigned char *p_addr) for (i = 0; i < 8; i++) crc_result = crc_result | (crc[i] << i); - table = DA_FILTER_OTHER_MULTICAST_TABLE_BASE(eth_port_num); + table = MV643XX_ETH_DA_FILTER_OTHER_MULTICAST_TABLE_BASE(eth_port_num); eth_port_set_filter_table_entry(table, crc_result); } @@ -2544,7 +2006,7 @@ static void eth_port_set_multicast_list(struct net_device *dev) * 3-1 Queue ETH_Q0=0 * 7-4 Reserved = 0; */ - mv_write(DA_FILTER_SPECIAL_MULTICAST_TABLE_BASE(eth_port_num) + table_index, 0x01010101); + mv_write(MV643XX_ETH_DA_FILTER_SPECIAL_MULTICAST_TABLE_BASE(eth_port_num) + table_index, 0x01010101); /* Set all entries in DA filter other multicast * table (Ex_dFOMT) @@ -2554,7 +2016,7 @@ static void eth_port_set_multicast_list(struct net_device *dev) * 3-1 Queue ETH_Q0=0 * 7-4 Reserved = 0; */ - mv_write(DA_FILTER_OTHER_MULTICAST_TABLE_BASE(eth_port_num) + table_index, 0x01010101); + mv_write(MV643XX_ETH_DA_FILTER_OTHER_MULTICAST_TABLE_BASE(eth_port_num) + table_index, 0x01010101); } return; } @@ -2564,11 +2026,11 @@ static void eth_port_set_multicast_list(struct net_device *dev) */ for (table_index = 0; table_index <= 0xFC; table_index += 4) { /* Clear DA filter special multicast table (Ex_dFSMT) */ - mv_write(DA_FILTER_SPECIAL_MULTICAST_TABLE_BASE + mv_write(MV643XX_ETH_DA_FILTER_SPECIAL_MULTICAST_TABLE_BASE (eth_port_num) + table_index, 0); /* Clear DA filter other multicast table (Ex_dFOMT) */ - mv_write(DA_FILTER_OTHER_MULTICAST_TABLE_BASE + mv_write(MV643XX_ETH_DA_FILTER_OTHER_MULTICAST_TABLE_BASE (eth_port_num) + table_index, 0); } @@ -2602,15 +2064,15 @@ static void eth_port_init_mac_tables(unsigned int eth_port_num) /* Clear DA filter unicast table (Ex_dFUT) */ for (table_index = 0; table_index <= 0xC; table_index += 4) - mv_write(DA_FILTER_UNICAST_TABLE_BASE + mv_write(MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE (eth_port_num) + table_index, 0); for (table_index = 0; table_index <= 0xFC; table_index += 4) { /* Clear DA filter special multicast table (Ex_dFSMT) */ - mv_write(DA_FILTER_SPECIAL_MULTICAST_TABLE_BASE + mv_write(MV643XX_ETH_DA_FILTER_SPECIAL_MULTICAST_TABLE_BASE (eth_port_num) + table_index, 0); /* Clear DA filter other multicast table (Ex_dFOMT) */ - mv_write(DA_FILTER_OTHER_MULTICAST_TABLE_BASE + mv_write(MV643XX_ETH_DA_FILTER_OTHER_MULTICAST_TABLE_BASE (eth_port_num) + table_index, 0); } } @@ -2639,12 +2101,12 @@ static void eth_clear_mib_counters(unsigned int eth_port_num) /* Perform dummy reads from MIB counters */ for (i = ETH_MIB_GOOD_OCTETS_RECEIVED_LOW; i < ETH_MIB_LATE_COLLISION; i += 4) - mv_read(MIB_COUNTERS_BASE(eth_port_num) + i); + mv_read(MV643XX_ETH_MIB_COUNTERS_BASE(eth_port_num) + i); } static inline u32 read_mib(struct mv643xx_private *mp, int offset) { - return mv_read(MIB_COUNTERS_BASE(mp->port_num) + offset); + return mv_read(MV643XX_ETH_MIB_COUNTERS_BASE(mp->port_num) + offset); } static void eth_update_mib_counters(struct mv643xx_private *mp) @@ -2729,7 +2191,7 @@ static int ethernet_phy_get(unsigned int eth_port_num) { unsigned int reg_data; - reg_data = mv_read(PHY_ADDR_REG); + reg_data = mv_read(MV643XX_ETH_PHY_ADDR_REG); return ((reg_data >> (5 * eth_port_num)) & 0x1f); } @@ -2756,10 +2218,10 @@ static void ethernet_phy_set(unsigned int eth_port_num, int phy_addr) u32 reg_data; int addr_shift = 5 * eth_port_num; - reg_data = mv_read(PHY_ADDR_REG); + reg_data = mv_read(MV643XX_ETH_PHY_ADDR_REG); reg_data &= ~(0x1f << addr_shift); reg_data |= (phy_addr & 0x1f) << addr_shift; - mv_write(PHY_ADDR_REG, reg_data); + mv_write(MV643XX_ETH_PHY_ADDR_REG, reg_data); } /* @@ -2797,13 +2259,13 @@ static void ethernet_phy_reset(unsigned int eth_port_num) static void mv643xx_eth_port_enable_tx(unsigned int port_num, unsigned int queues) { - mv_write(TRANSMIT_QUEUE_COMMAND_REG(port_num), queues); + mv_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num), queues); } static void mv643xx_eth_port_enable_rx(unsigned int port_num, unsigned int queues) { - mv_write(RECEIVE_QUEUE_COMMAND_REG(port_num), queues); + mv_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num), queues); } static unsigned int mv643xx_eth_port_disable_tx(unsigned int port_num) @@ -2811,18 +2273,21 @@ static unsigned int mv643xx_eth_port_disable_tx(unsigned int port_num) u32 queues; /* Stop Tx port activity. Check port Tx activity. */ - queues = mv_read(TRANSMIT_QUEUE_COMMAND_REG(port_num)) & 0xFF; + queues = mv_read(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num)) + & 0xFF; if (queues) { /* Issue stop command for active queues only */ - mv_write(TRANSMIT_QUEUE_COMMAND_REG(port_num), (queues << 8)); + mv_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num), + (queues << 8)); /* Wait for all Tx activity to terminate. */ /* Check port cause register that all Tx queues are stopped */ - while (mv_read(TRANSMIT_QUEUE_COMMAND_REG(port_num)) & 0xFF) + while (mv_read(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num)) + & 0xFF) udelay(PHY_WAIT_MICRO_SECONDS); /* Wait for Tx FIFO to empty */ - while (mv_read(PORT_STATUS_REG(port_num)) & + while (mv_read(MV643XX_ETH_PORT_STATUS_REG(port_num)) & ETH_PORT_TX_FIFO_EMPTY) udelay(PHY_WAIT_MICRO_SECONDS); } @@ -2835,14 +2300,17 @@ static unsigned int mv643xx_eth_port_disable_rx(unsigned int port_num) u32 queues; /* Stop Rx port activity. Check port Rx activity. */ - queues = mv_read(RECEIVE_QUEUE_COMMAND_REG(port_num)) & 0xFF; + queues = mv_read(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num)) + & 0xFF; if (queues) { /* Issue stop command for active queues only */ - mv_write(RECEIVE_QUEUE_COMMAND_REG(port_num), (queues << 8)); + mv_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num), + (queues << 8)); /* Wait for all Rx activity to terminate. */ /* Check port cause register that all Rx queues are stopped */ - while (mv_read(RECEIVE_QUEUE_COMMAND_REG(port_num)) & 0xFF) + while (mv_read(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num)) + & 0xFF) udelay(PHY_WAIT_MICRO_SECONDS); } @@ -2878,11 +2346,11 @@ static void eth_port_reset(unsigned int port_num) eth_clear_mib_counters(port_num); /* Reset the Enable bit in the Configuration Register */ - reg_data = mv_read(PORT_SERIAL_CONTROL_REG(port_num)); - reg_data &= ~(SERIAL_PORT_ENABLE | - DO_NOT_FORCE_LINK_FAIL | - FORCE_LINK_PASS); - mv_write(PORT_SERIAL_CONTROL_REG(port_num), reg_data); + reg_data = mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num)); + reg_data &= ~(MV643XX_ETH_SERIAL_PORT_ENABLE | + MV643XX_ETH_DO_NOT_FORCE_LINK_FAIL | + MV643XX_ETH_FORCE_LINK_PASS); + mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), reg_data); } @@ -2917,7 +2385,7 @@ static void eth_port_read_smi_reg(unsigned int port_num, spin_lock_irqsave(&mv643xx_eth_phy_lock, flags); /* wait for the SMI register to become available */ - for (i = 0; mv_read(SMI_REG) & ETH_SMI_BUSY; i++) { + for (i = 0; mv_read(MV643XX_ETH_SMI_REG) & ETH_SMI_BUSY; i++) { if (i == PHY_WAIT_ITERATIONS) { printk("mv643xx PHY busy timeout, port %d\n", port_num); goto out; @@ -2925,11 +2393,11 @@ static void eth_port_read_smi_reg(unsigned int port_num, udelay(PHY_WAIT_MICRO_SECONDS); } - mv_write(SMI_REG, + mv_write(MV643XX_ETH_SMI_REG, (phy_addr << 16) | (phy_reg << 21) | ETH_SMI_OPCODE_READ); /* now wait for the data to be valid */ - for (i = 0; !(mv_read(SMI_REG) & ETH_SMI_READ_VALID); i++) { + for (i = 0; !(mv_read(MV643XX_ETH_SMI_REG) & ETH_SMI_READ_VALID); i++) { if (i == PHY_WAIT_ITERATIONS) { printk("mv643xx PHY read timeout, port %d\n", port_num); goto out; @@ -2937,7 +2405,7 @@ static void eth_port_read_smi_reg(unsigned int port_num, udelay(PHY_WAIT_MICRO_SECONDS); } - *value = mv_read(SMI_REG) & 0xffff; + *value = mv_read(MV643XX_ETH_SMI_REG) & 0xffff; out: spin_unlock_irqrestore(&mv643xx_eth_phy_lock, flags); } @@ -2975,7 +2443,7 @@ static void eth_port_write_smi_reg(unsigned int eth_port_num, spin_lock_irqsave(&mv643xx_eth_phy_lock, flags); /* wait for the SMI register to become available */ - for (i = 0; mv_read(SMI_REG) & ETH_SMI_BUSY; i++) { + for (i = 0; mv_read(MV643XX_ETH_SMI_REG) & ETH_SMI_BUSY; i++) { if (i == PHY_WAIT_ITERATIONS) { printk("mv643xx PHY busy timeout, port %d\n", eth_port_num); @@ -2984,7 +2452,7 @@ static void eth_port_write_smi_reg(unsigned int eth_port_num, udelay(PHY_WAIT_MICRO_SECONDS); } - mv_write(SMI_REG, (phy_addr << 16) | (phy_reg << 21) | + mv_write(MV643XX_ETH_SMI_REG, (phy_addr << 16) | (phy_reg << 21) | ETH_SMI_OPCODE_WRITE | (value & 0xffff)); out: spin_unlock_irqrestore(&mv643xx_eth_phy_lock, flags); @@ -3274,7 +2742,6 @@ static const struct ethtool_ops mv643xx_ethtool_ops = { .get_drvinfo = mv643xx_get_drvinfo, .get_link = mv643xx_eth_get_link, .set_sg = ethtool_op_set_sg, - .get_sset_count = mv643xx_get_sset_count, .get_ethtool_stats = mv643xx_get_ethtool_stats, .get_strings = mv643xx_get_strings, .nway_reset = mv643xx_eth_nway_restart, diff --git a/trunk/drivers/net/mv643xx_eth.h b/trunk/drivers/net/mv643xx_eth.h new file mode 100644 index 000000000000..be669eb23788 --- /dev/null +++ b/trunk/drivers/net/mv643xx_eth.h @@ -0,0 +1,370 @@ +#ifndef __MV643XX_ETH_H__ +#define __MV643XX_ETH_H__ + +#include +#include +#include +#include +#include + +#include + +#include + +/* Checksum offload for Tx works for most packets, but + * fails if previous packet sent did not use hw csum + */ +#define MV643XX_CHECKSUM_OFFLOAD_TX +#define MV643XX_NAPI +#define MV643XX_TX_FAST_REFILL +#undef MV643XX_COAL + +/* + * Number of RX / TX descriptors on RX / TX rings. + * Note that allocating RX descriptors is done by allocating the RX + * ring AND a preallocated RX buffers (skb's) for each descriptor. + * The TX descriptors only allocates the TX descriptors ring, + * with no pre allocated TX buffers (skb's are allocated by higher layers. + */ + +/* Default TX ring size is 1000 descriptors */ +#define MV643XX_DEFAULT_TX_QUEUE_SIZE 1000 + +/* Default RX ring size is 400 descriptors */ +#define MV643XX_DEFAULT_RX_QUEUE_SIZE 400 + +#define MV643XX_TX_COAL 100 +#ifdef MV643XX_COAL +#define MV643XX_RX_COAL 100 +#endif + +#ifdef MV643XX_CHECKSUM_OFFLOAD_TX +#define MAX_DESCS_PER_SKB (MAX_SKB_FRAGS + 1) +#else +#define MAX_DESCS_PER_SKB 1 +#endif + +#define ETH_VLAN_HLEN 4 +#define ETH_FCS_LEN 4 +#define ETH_HW_IP_ALIGN 2 /* hw aligns IP header */ +#define ETH_WRAPPER_LEN (ETH_HW_IP_ALIGN + ETH_HLEN + \ + ETH_VLAN_HLEN + ETH_FCS_LEN) +#define ETH_RX_SKB_SIZE (dev->mtu + ETH_WRAPPER_LEN + dma_get_cache_alignment()) + +#define ETH_RX_QUEUES_ENABLED (1 << 0) /* use only Q0 for receive */ +#define ETH_TX_QUEUES_ENABLED (1 << 0) /* use only Q0 for transmit */ + +#define ETH_INT_CAUSE_RX_DONE (ETH_RX_QUEUES_ENABLED << 2) +#define ETH_INT_CAUSE_RX_ERROR (ETH_RX_QUEUES_ENABLED << 9) +#define ETH_INT_CAUSE_RX (ETH_INT_CAUSE_RX_DONE | ETH_INT_CAUSE_RX_ERROR) +#define ETH_INT_CAUSE_EXT 0x00000002 +#define ETH_INT_UNMASK_ALL (ETH_INT_CAUSE_RX | ETH_INT_CAUSE_EXT) + +#define ETH_INT_CAUSE_TX_DONE (ETH_TX_QUEUES_ENABLED << 0) +#define ETH_INT_CAUSE_TX_ERROR (ETH_TX_QUEUES_ENABLED << 8) +#define ETH_INT_CAUSE_TX (ETH_INT_CAUSE_TX_DONE | ETH_INT_CAUSE_TX_ERROR) +#define ETH_INT_CAUSE_PHY 0x00010000 +#define ETH_INT_CAUSE_STATE 0x00100000 +#define ETH_INT_UNMASK_ALL_EXT (ETH_INT_CAUSE_TX | ETH_INT_CAUSE_PHY | \ + ETH_INT_CAUSE_STATE) + +#define ETH_INT_MASK_ALL 0x00000000 +#define ETH_INT_MASK_ALL_EXT 0x00000000 + +#define PHY_WAIT_ITERATIONS 1000 /* 1000 iterations * 10uS = 10mS max */ +#define PHY_WAIT_MICRO_SECONDS 10 + +/* Buffer offset from buffer pointer */ +#define RX_BUF_OFFSET 0x2 + +/* Gigabit Ethernet Unit Global Registers */ + +/* MIB Counters register definitions */ +#define ETH_MIB_GOOD_OCTETS_RECEIVED_LOW 0x0 +#define ETH_MIB_GOOD_OCTETS_RECEIVED_HIGH 0x4 +#define ETH_MIB_BAD_OCTETS_RECEIVED 0x8 +#define ETH_MIB_INTERNAL_MAC_TRANSMIT_ERR 0xc +#define ETH_MIB_GOOD_FRAMES_RECEIVED 0x10 +#define ETH_MIB_BAD_FRAMES_RECEIVED 0x14 +#define ETH_MIB_BROADCAST_FRAMES_RECEIVED 0x18 +#define ETH_MIB_MULTICAST_FRAMES_RECEIVED 0x1c +#define ETH_MIB_FRAMES_64_OCTETS 0x20 +#define ETH_MIB_FRAMES_65_TO_127_OCTETS 0x24 +#define ETH_MIB_FRAMES_128_TO_255_OCTETS 0x28 +#define ETH_MIB_FRAMES_256_TO_511_OCTETS 0x2c +#define ETH_MIB_FRAMES_512_TO_1023_OCTETS 0x30 +#define ETH_MIB_FRAMES_1024_TO_MAX_OCTETS 0x34 +#define ETH_MIB_GOOD_OCTETS_SENT_LOW 0x38 +#define ETH_MIB_GOOD_OCTETS_SENT_HIGH 0x3c +#define ETH_MIB_GOOD_FRAMES_SENT 0x40 +#define ETH_MIB_EXCESSIVE_COLLISION 0x44 +#define ETH_MIB_MULTICAST_FRAMES_SENT 0x48 +#define ETH_MIB_BROADCAST_FRAMES_SENT 0x4c +#define ETH_MIB_UNREC_MAC_CONTROL_RECEIVED 0x50 +#define ETH_MIB_FC_SENT 0x54 +#define ETH_MIB_GOOD_FC_RECEIVED 0x58 +#define ETH_MIB_BAD_FC_RECEIVED 0x5c +#define ETH_MIB_UNDERSIZE_RECEIVED 0x60 +#define ETH_MIB_FRAGMENTS_RECEIVED 0x64 +#define ETH_MIB_OVERSIZE_RECEIVED 0x68 +#define ETH_MIB_JABBER_RECEIVED 0x6c +#define ETH_MIB_MAC_RECEIVE_ERROR 0x70 +#define ETH_MIB_BAD_CRC_EVENT 0x74 +#define ETH_MIB_COLLISION 0x78 +#define ETH_MIB_LATE_COLLISION 0x7c + +/* Port serial status reg (PSR) */ +#define ETH_INTERFACE_PCM 0x00000001 +#define ETH_LINK_IS_UP 0x00000002 +#define ETH_PORT_AT_FULL_DUPLEX 0x00000004 +#define ETH_RX_FLOW_CTRL_ENABLED 0x00000008 +#define ETH_GMII_SPEED_1000 0x00000010 +#define ETH_MII_SPEED_100 0x00000020 +#define ETH_TX_IN_PROGRESS 0x00000080 +#define ETH_BYPASS_ACTIVE 0x00000100 +#define ETH_PORT_AT_PARTITION_STATE 0x00000200 +#define ETH_PORT_TX_FIFO_EMPTY 0x00000400 + +/* SMI reg */ +#define ETH_SMI_BUSY 0x10000000 /* 0 - Write, 1 - Read */ +#define ETH_SMI_READ_VALID 0x08000000 /* 0 - Write, 1 - Read */ +#define ETH_SMI_OPCODE_WRITE 0 /* Completion of Read */ +#define ETH_SMI_OPCODE_READ 0x04000000 /* Operation is in progress */ + +/* Interrupt Cause Register Bit Definitions */ + +/* SDMA command status fields macros */ + +/* Tx & Rx descriptors status */ +#define ETH_ERROR_SUMMARY 0x00000001 + +/* Tx & Rx descriptors command */ +#define ETH_BUFFER_OWNED_BY_DMA 0x80000000 + +/* Tx descriptors status */ +#define ETH_LC_ERROR 0 +#define ETH_UR_ERROR 0x00000002 +#define ETH_RL_ERROR 0x00000004 +#define ETH_LLC_SNAP_FORMAT 0x00000200 + +/* Rx descriptors status */ +#define ETH_OVERRUN_ERROR 0x00000002 +#define ETH_MAX_FRAME_LENGTH_ERROR 0x00000004 +#define ETH_RESOURCE_ERROR 0x00000006 +#define ETH_VLAN_TAGGED 0x00080000 +#define ETH_BPDU_FRAME 0x00100000 +#define ETH_UDP_FRAME_OVER_IP_V_4 0x00200000 +#define ETH_OTHER_FRAME_TYPE 0x00400000 +#define ETH_LAYER_2_IS_ETH_V_2 0x00800000 +#define ETH_FRAME_TYPE_IP_V_4 0x01000000 +#define ETH_FRAME_HEADER_OK 0x02000000 +#define ETH_RX_LAST_DESC 0x04000000 +#define ETH_RX_FIRST_DESC 0x08000000 +#define ETH_UNKNOWN_DESTINATION_ADDR 0x10000000 +#define ETH_RX_ENABLE_INTERRUPT 0x20000000 +#define ETH_LAYER_4_CHECKSUM_OK 0x40000000 + +/* Rx descriptors byte count */ +#define ETH_FRAME_FRAGMENTED 0x00000004 + +/* Tx descriptors command */ +#define ETH_LAYER_4_CHECKSUM_FIRST_DESC 0x00000400 +#define ETH_FRAME_SET_TO_VLAN 0x00008000 +#define ETH_UDP_FRAME 0x00010000 +#define ETH_GEN_TCP_UDP_CHECKSUM 0x00020000 +#define ETH_GEN_IP_V_4_CHECKSUM 0x00040000 +#define ETH_ZERO_PADDING 0x00080000 +#define ETH_TX_LAST_DESC 0x00100000 +#define ETH_TX_FIRST_DESC 0x00200000 +#define ETH_GEN_CRC 0x00400000 +#define ETH_TX_ENABLE_INTERRUPT 0x00800000 +#define ETH_AUTO_MODE 0x40000000 + +#define ETH_TX_IHL_SHIFT 11 + +/* typedefs */ + +typedef enum _eth_func_ret_status { + ETH_OK, /* Returned as expected. */ + ETH_ERROR, /* Fundamental error. */ + ETH_RETRY, /* Could not process request. Try later.*/ + ETH_END_OF_JOB, /* Ring has nothing to process. */ + ETH_QUEUE_FULL, /* Ring resource error. */ + ETH_QUEUE_LAST_RESOURCE /* Ring resources about to exhaust. */ +} ETH_FUNC_RET_STATUS; + +typedef enum _eth_target { + ETH_TARGET_DRAM, + ETH_TARGET_DEVICE, + ETH_TARGET_CBS, + ETH_TARGET_PCI0, + ETH_TARGET_PCI1 +} ETH_TARGET; + +/* These are for big-endian machines. Little endian needs different + * definitions. + */ +#if defined(__BIG_ENDIAN) +struct eth_rx_desc { + u16 byte_cnt; /* Descriptor buffer byte count */ + u16 buf_size; /* Buffer size */ + u32 cmd_sts; /* Descriptor command status */ + u32 next_desc_ptr; /* Next descriptor pointer */ + u32 buf_ptr; /* Descriptor buffer pointer */ +}; + +struct eth_tx_desc { + u16 byte_cnt; /* buffer byte count */ + u16 l4i_chk; /* CPU provided TCP checksum */ + u32 cmd_sts; /* Command/status field */ + u32 next_desc_ptr; /* Pointer to next descriptor */ + u32 buf_ptr; /* pointer to buffer for this descriptor*/ +}; + +#elif defined(__LITTLE_ENDIAN) +struct eth_rx_desc { + u32 cmd_sts; /* Descriptor command status */ + u16 buf_size; /* Buffer size */ + u16 byte_cnt; /* Descriptor buffer byte count */ + u32 buf_ptr; /* Descriptor buffer pointer */ + u32 next_desc_ptr; /* Next descriptor pointer */ +}; + +struct eth_tx_desc { + u32 cmd_sts; /* Command/status field */ + u16 l4i_chk; /* CPU provided TCP checksum */ + u16 byte_cnt; /* buffer byte count */ + u32 buf_ptr; /* pointer to buffer for this descriptor*/ + u32 next_desc_ptr; /* Pointer to next descriptor */ +}; +#else +#error One of __BIG_ENDIAN or __LITTLE_ENDIAN must be defined +#endif + +/* Unified struct for Rx and Tx operations. The user is not required to */ +/* be familier with neither Tx nor Rx descriptors. */ +struct pkt_info { + unsigned short byte_cnt; /* Descriptor buffer byte count */ + unsigned short l4i_chk; /* Tx CPU provided TCP Checksum */ + unsigned int cmd_sts; /* Descriptor command status */ + dma_addr_t buf_ptr; /* Descriptor buffer pointer */ + struct sk_buff *return_info; /* User resource return information */ +}; + +/* Ethernet port specific information */ + +struct mv643xx_mib_counters { + u64 good_octets_received; + u32 bad_octets_received; + u32 internal_mac_transmit_err; + u32 good_frames_received; + u32 bad_frames_received; + u32 broadcast_frames_received; + u32 multicast_frames_received; + u32 frames_64_octets; + u32 frames_65_to_127_octets; + u32 frames_128_to_255_octets; + u32 frames_256_to_511_octets; + u32 frames_512_to_1023_octets; + u32 frames_1024_to_max_octets; + u64 good_octets_sent; + u32 good_frames_sent; + u32 excessive_collision; + u32 multicast_frames_sent; + u32 broadcast_frames_sent; + u32 unrec_mac_control_received; + u32 fc_sent; + u32 good_fc_received; + u32 bad_fc_received; + u32 undersize_received; + u32 fragments_received; + u32 oversize_received; + u32 jabber_received; + u32 mac_receive_error; + u32 bad_crc_event; + u32 collision; + u32 late_collision; +}; + +struct mv643xx_private { + int port_num; /* User Ethernet port number */ + + u32 rx_sram_addr; /* Base address of rx sram area */ + u32 rx_sram_size; /* Size of rx sram area */ + u32 tx_sram_addr; /* Base address of tx sram area */ + u32 tx_sram_size; /* Size of tx sram area */ + + int rx_resource_err; /* Rx ring resource error flag */ + + /* Tx/Rx rings managment indexes fields. For driver use */ + + /* Next available and first returning Rx resource */ + int rx_curr_desc_q, rx_used_desc_q; + + /* Next available and first returning Tx resource */ + int tx_curr_desc_q, tx_used_desc_q; + +#ifdef MV643XX_TX_FAST_REFILL + u32 tx_clean_threshold; +#endif + + struct eth_rx_desc *p_rx_desc_area; + dma_addr_t rx_desc_dma; + int rx_desc_area_size; + struct sk_buff **rx_skb; + + struct eth_tx_desc *p_tx_desc_area; + dma_addr_t tx_desc_dma; + int tx_desc_area_size; + struct sk_buff **tx_skb; + + struct work_struct tx_timeout_task; + + struct net_device *dev; + struct napi_struct napi; + struct net_device_stats stats; + struct mv643xx_mib_counters mib_counters; + spinlock_t lock; + /* Size of Tx Ring per queue */ + int tx_ring_size; + /* Number of tx descriptors in use */ + int tx_desc_count; + /* Size of Rx Ring per queue */ + int rx_ring_size; + /* Number of rx descriptors in use */ + int rx_desc_count; + + /* + * Used in case RX Ring is empty, which can be caused when + * system does not have resources (skb's) + */ + struct timer_list timeout; + + u32 rx_int_coal; + u32 tx_int_coal; + struct mii_if_info mii; +}; + +/* Port operation control routines */ +static void eth_port_init(struct mv643xx_private *mp); +static void eth_port_reset(unsigned int eth_port_num); +static void eth_port_start(struct net_device *dev); + +/* PHY and MIB routines */ +static void ethernet_phy_reset(unsigned int eth_port_num); + +static void eth_port_write_smi_reg(unsigned int eth_port_num, + unsigned int phy_reg, unsigned int value); + +static void eth_port_read_smi_reg(unsigned int eth_port_num, + unsigned int phy_reg, unsigned int *value); + +static void eth_clear_mib_counters(unsigned int eth_port_num); + +/* Port data flow control routines */ +static ETH_FUNC_RET_STATUS eth_port_receive(struct mv643xx_private *mp, + struct pkt_info *p_pkt_info); +static ETH_FUNC_RET_STATUS eth_rx_return_buff(struct mv643xx_private *mp, + struct pkt_info *p_pkt_info); + +#endif /* __MV643XX_ETH_H__ */ diff --git a/trunk/drivers/net/natsemi.c b/trunk/drivers/net/natsemi.c index 87cde062fd63..953117152bbd 100644 --- a/trunk/drivers/net/natsemi.c +++ b/trunk/drivers/net/natsemi.c @@ -864,7 +864,6 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev, np = netdev_priv(dev); netif_napi_add(dev, &np->napi, natsemi_poll, 64); - np->dev = dev; np->pci_dev = pdev; pci_set_drvdata(pdev, dev); diff --git a/trunk/drivers/net/netxen/netxen_nic_main.c b/trunk/drivers/net/netxen/netxen_nic_main.c index a80f0cd6b528..601051c584e8 100644 --- a/trunk/drivers/net/netxen/netxen_nic_main.c +++ b/trunk/drivers/net/netxen/netxen_nic_main.c @@ -1268,10 +1268,17 @@ netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev) */ irqreturn_t netxen_intr(int irq, void *data) { - struct netxen_adapter *adapter = data; - struct net_device *netdev = adapter->netdev; + struct netxen_adapter *adapter; + struct net_device *netdev; u32 our_int = 0; + if (unlikely(!irq)) { + return IRQ_NONE; /* Not our interrupt */ + } + + adapter = (struct netxen_adapter *)data; + netdev = adapter->netdev; + if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) { our_int = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_INT_VECTOR)); /* not our interrupt */ diff --git a/trunk/drivers/net/ni5010.c b/trunk/drivers/net/ni5010.c index a20005c09e07..14a768fbce2e 100644 --- a/trunk/drivers/net/ni5010.c +++ b/trunk/drivers/net/ni5010.c @@ -518,6 +518,7 @@ static void dump_packet(void *buf, int len) /* We have a good packet, get it out of the buffer. */ static void ni5010_rx(struct net_device *dev) { + struct ni5010_local *lp = netdev_priv(dev); int ioaddr = dev->base_addr; unsigned char rcv_stat; struct sk_buff *skb; @@ -576,6 +577,7 @@ static void ni5010_rx(struct net_device *dev) PRINTK2((KERN_DEBUG "%s: Received packet, size=%#4.4x\n", dev->name, i_pkt_size)); + } static int process_xmt_interrupt(struct net_device *dev) diff --git a/trunk/drivers/net/pasemi_mac.c b/trunk/drivers/net/pasemi_mac.c index ab4d309a858f..9f9a421c99b3 100644 --- a/trunk/drivers/net/pasemi_mac.c +++ b/trunk/drivers/net/pasemi_mac.c @@ -550,7 +550,7 @@ static int pasemi_mac_clean_rx(struct pasemi_mac *mac, int limit) n = mac->rx->next_to_clean; - prefetch(&RX_RING(mac, n)); + prefetch(RX_RING(mac, n)); for (count = 0; count < limit; count++) { macrx = RX_RING(mac, n); diff --git a/trunk/drivers/net/pcmcia/3c574_cs.c b/trunk/drivers/net/pcmcia/3c574_cs.c index ad134a61302a..73dcbb7296da 100644 --- a/trunk/drivers/net/pcmcia/3c574_cs.c +++ b/trunk/drivers/net/pcmcia/3c574_cs.c @@ -274,7 +274,7 @@ static int tc574_probe(struct pcmcia_device *link) spin_lock_init(&lp->window_lock); link->io.NumPorts1 = 32; link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; - link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_HANDLE_PRESENT; + link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; link->irq.IRQInfo1 = IRQ_LEVEL_ID; link->irq.Handler = &el3_interrupt; link->irq.Instance = dev; diff --git a/trunk/drivers/net/pcmcia/3c589_cs.c b/trunk/drivers/net/pcmcia/3c589_cs.c index a98fe07cce70..32076ca6a9e1 100644 --- a/trunk/drivers/net/pcmcia/3c589_cs.c +++ b/trunk/drivers/net/pcmcia/3c589_cs.c @@ -188,7 +188,7 @@ static int tc589_probe(struct pcmcia_device *link) spin_lock_init(&lp->lock); link->io.NumPorts1 = 16; link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; - link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_HANDLE_PRESENT; + link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; link->irq.IRQInfo1 = IRQ_LEVEL_ID; link->irq.Handler = &el3_interrupt; link->irq.Instance = dev; diff --git a/trunk/drivers/net/pcmcia/axnet_cs.c b/trunk/drivers/net/pcmcia/axnet_cs.c index 8d910a372f89..a95a2cae6b23 100644 --- a/trunk/drivers/net/pcmcia/axnet_cs.c +++ b/trunk/drivers/net/pcmcia/axnet_cs.c @@ -158,7 +158,7 @@ static int axnet_probe(struct pcmcia_device *link) info = PRIV(dev); info->p_dev = link; link->priv = dev; - link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING; + link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; link->irq.IRQInfo1 = IRQ_LEVEL_ID; link->conf.Attributes = CONF_ENABLE_IRQ; link->conf.IntType = INT_MEMORY_AND_IO; diff --git a/trunk/drivers/net/pcmcia/fmvj18x_cs.c b/trunk/drivers/net/pcmcia/fmvj18x_cs.c index 8c719b4df544..62844677c784 100644 --- a/trunk/drivers/net/pcmcia/fmvj18x_cs.c +++ b/trunk/drivers/net/pcmcia/fmvj18x_cs.c @@ -249,7 +249,7 @@ static int fmvj18x_probe(struct pcmcia_device *link) link->io.IOAddrLines = 5; /* Interrupt setup */ - link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_HANDLE_PRESENT; + link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; link->irq.IRQInfo1 = IRQ_LEVEL_ID; link->irq.Handler = &fjn_interrupt; link->irq.Instance = dev; diff --git a/trunk/drivers/net/pcmcia/pcnet_cs.c b/trunk/drivers/net/pcmcia/pcnet_cs.c index db6a97d1d7b1..9d45e9696e16 100644 --- a/trunk/drivers/net/pcmcia/pcnet_cs.c +++ b/trunk/drivers/net/pcmcia/pcnet_cs.c @@ -254,7 +254,7 @@ static int pcnet_probe(struct pcmcia_device *link) info->p_dev = link; link->priv = dev; - link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING; + link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; link->irq.IRQInfo1 = IRQ_LEVEL_ID; link->conf.Attributes = CONF_ENABLE_IRQ; link->conf.IntType = INT_MEMORY_AND_IO; diff --git a/trunk/drivers/net/pcmcia/smc91c92_cs.c b/trunk/drivers/net/pcmcia/smc91c92_cs.c index c9868e9dac4c..58d716fd17cf 100644 --- a/trunk/drivers/net/pcmcia/smc91c92_cs.c +++ b/trunk/drivers/net/pcmcia/smc91c92_cs.c @@ -328,7 +328,7 @@ static int smc91c92_probe(struct pcmcia_device *link) link->io.NumPorts1 = 16; link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; link->io.IOAddrLines = 4; - link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_HANDLE_PRESENT; + link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; link->irq.IRQInfo1 = IRQ_LEVEL_ID; link->irq.Handler = &smc_interrupt; link->irq.Instance = dev; diff --git a/trunk/drivers/net/pcmcia/xirc2ps_cs.c b/trunk/drivers/net/pcmcia/xirc2ps_cs.c index 1f09bea6db5a..c3b69602e275 100644 --- a/trunk/drivers/net/pcmcia/xirc2ps_cs.c +++ b/trunk/drivers/net/pcmcia/xirc2ps_cs.c @@ -886,7 +886,7 @@ xirc2ps_config(struct pcmcia_device * link) } printk(KNOT_XIRC "no ports available\n"); } else { - link->irq.Attributes |= IRQ_TYPE_DYNAMIC_SHARING; + link->irq.Attributes |= IRQ_TYPE_EXCLUSIVE; link->io.NumPorts1 = 16; for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { link->io.BasePort1 = ioaddr; diff --git a/trunk/drivers/net/plip.c b/trunk/drivers/net/plip.c index 5071fcd8a0bd..b5e9981d1060 100644 --- a/trunk/drivers/net/plip.c +++ b/trunk/drivers/net/plip.c @@ -143,7 +143,7 @@ static void plip_bh(struct work_struct *work); static void plip_timer_bh(struct work_struct *work); /* Interrupt handler */ -static void plip_interrupt(void *dev_id); +static void plip_interrupt(int irq, void *dev_id); /* Functions for DEV methods */ static int plip_tx_packet(struct sk_buff *skb, struct net_device *dev); @@ -380,7 +380,7 @@ plip_timer_bh(struct work_struct *work) container_of(work, struct net_local, timer.work); if (!(atomic_read (&nl->kill_timer))) { - plip_interrupt (nl->dev); + plip_interrupt (-1, nl->dev); schedule_delayed_work(&nl->timer, 1); } @@ -897,7 +897,7 @@ plip_error(struct net_device *dev, struct net_local *nl, /* Handle the parallel port interrupts. */ static void -plip_interrupt(void *dev_id) +plip_interrupt(int irq, void *dev_id) { struct net_device *dev = dev_id; struct net_local *nl; diff --git a/trunk/drivers/net/ppp_mppe.c b/trunk/drivers/net/ppp_mppe.c index b35d79449500..bcb0885011c8 100644 --- a/trunk/drivers/net/ppp_mppe.c +++ b/trunk/drivers/net/ppp_mppe.c @@ -68,7 +68,7 @@ MODULE_VERSION("1.0.2"); static unsigned int setup_sg(struct scatterlist *sg, const void *address, unsigned int length) { - sg_set_buf(sg, address, length); + sg_init_one(sg, address, length); return length; } @@ -140,8 +140,6 @@ static void get_new_key_from_sha(struct ppp_mppe_state * state) struct scatterlist sg[4]; unsigned int nbytes; - sg_init_table(sg, 4); - nbytes = setup_sg(&sg[0], state->master_key, state->keylen); nbytes += setup_sg(&sg[1], sha_pad->sha_pad1, sizeof(sha_pad->sha_pad1)); @@ -168,8 +166,6 @@ static void mppe_rekey(struct ppp_mppe_state * state, int initial_key) if (!initial_key) { crypto_blkcipher_setkey(state->arc4, state->sha1_digest, state->keylen); - sg_init_table(sg_in, 1); - sg_init_table(sg_out, 1); setup_sg(sg_in, state->sha1_digest, state->keylen); setup_sg(sg_out, state->session_key, state->keylen); if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in, @@ -425,8 +421,6 @@ mppe_compress(void *arg, unsigned char *ibuf, unsigned char *obuf, isize -= 2; /* Encrypt packet */ - sg_init_table(sg_in, 1); - sg_init_table(sg_out, 1); setup_sg(sg_in, ibuf, isize); setup_sg(sg_out, obuf, osize); if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in, isize) != 0) { @@ -614,8 +608,6 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf, * Decrypt the first byte in order to check if it is * a compressed or uncompressed protocol field. */ - sg_init_table(sg_in, 1); - sg_init_table(sg_out, 1); setup_sg(sg_in, ibuf, 1); setup_sg(sg_out, obuf, 1); if (crypto_blkcipher_decrypt(&desc, sg_out, sg_in, 1) != 0) { diff --git a/trunk/drivers/net/r8169.c b/trunk/drivers/net/r8169.c index b94fa7ef1955..419c00cbe6e9 100644 --- a/trunk/drivers/net/r8169.c +++ b/trunk/drivers/net/r8169.c @@ -44,8 +44,7 @@ printk( "Assertion failed! %s,%s,%s,line=%d\n", \ #expr,__FILE__,__FUNCTION__,__LINE__); \ } -#define dprintk(fmt, args...) \ - do { printk(KERN_DEBUG PFX fmt, ## args); } while (0) +#define dprintk(fmt, args...) do { printk(PFX fmt, ## args); } while (0) #else #define assert(expr) do {} while (0) #define dprintk(fmt, args...) do {} while (0) @@ -112,15 +111,19 @@ enum mac_version { RTL_GIGA_MAC_VER_05 = 0x05, // 8110SCd RTL_GIGA_MAC_VER_06 = 0x06, // 8110SCe RTL_GIGA_MAC_VER_11 = 0x0b, // 8168Bb - RTL_GIGA_MAC_VER_12 = 0x0c, // 8168Be - RTL_GIGA_MAC_VER_13 = 0x0d, // 8101Eb - RTL_GIGA_MAC_VER_14 = 0x0e, // 8101 ? - RTL_GIGA_MAC_VER_15 = 0x0f, // 8101 ? - RTL_GIGA_MAC_VER_16 = 0x11, // 8101Ec - RTL_GIGA_MAC_VER_17 = 0x10, // 8168Bf - RTL_GIGA_MAC_VER_18 = 0x12, // 8168CP - RTL_GIGA_MAC_VER_19 = 0x13, // 8168C - RTL_GIGA_MAC_VER_20 = 0x14 // 8168C + RTL_GIGA_MAC_VER_12 = 0x0c, // 8168Be 8168Bf + RTL_GIGA_MAC_VER_13 = 0x0d, // 8101Eb 8101Ec + RTL_GIGA_MAC_VER_14 = 0x0e, // 8101 + RTL_GIGA_MAC_VER_15 = 0x0f // 8101 +}; + +enum phy_version { + RTL_GIGA_PHY_VER_C = 0x03, /* PHY Reg 0x03 bit0-3 == 0x0000 */ + RTL_GIGA_PHY_VER_D = 0x04, /* PHY Reg 0x03 bit0-3 == 0x0000 */ + RTL_GIGA_PHY_VER_E = 0x05, /* PHY Reg 0x03 bit0-3 == 0x0000 */ + RTL_GIGA_PHY_VER_F = 0x06, /* PHY Reg 0x03 bit0-3 == 0x0001 */ + RTL_GIGA_PHY_VER_G = 0x07, /* PHY Reg 0x03 bit0-3 == 0x0002 */ + RTL_GIGA_PHY_VER_H = 0x08, /* PHY Reg 0x03 bit0-3 == 0x0003 */ }; #define _R(NAME,MAC,MASK) \ @@ -141,12 +144,7 @@ static const struct { _R("RTL8168b/8111b", RTL_GIGA_MAC_VER_12, 0xff7e1880), // PCI-E _R("RTL8101e", RTL_GIGA_MAC_VER_13, 0xff7e1880), // PCI-E 8139 _R("RTL8100e", RTL_GIGA_MAC_VER_14, 0xff7e1880), // PCI-E 8139 - _R("RTL8100e", RTL_GIGA_MAC_VER_15, 0xff7e1880), // PCI-E 8139 - _R("RTL8168b/8111b", RTL_GIGA_MAC_VER_17, 0xff7e1880), // PCI-E - _R("RTL8101e", RTL_GIGA_MAC_VER_16, 0xff7e1880), // PCI-E - _R("RTL8168cp/8111cp", RTL_GIGA_MAC_VER_18, 0xff7e1880), // PCI-E - _R("RTL8168c/8111c", RTL_GIGA_MAC_VER_19, 0xff7e1880), // PCI-E - _R("RTL8168c/8111c", RTL_GIGA_MAC_VER_20, 0xff7e1880) // PCI-E + _R("RTL8100e", RTL_GIGA_MAC_VER_15, 0xff7e1880) // PCI-E 8139 }; #undef _R @@ -167,7 +165,7 @@ static struct pci_device_id rtl8169_pci_tbl[] = { { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168), 0, 0, RTL_CFG_1 }, { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), 0, 0, RTL_CFG_0 }, { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4300), 0, 0, RTL_CFG_0 }, - { PCI_DEVICE(PCI_VENDOR_ID_AT, 0xc107), 0, 0, RTL_CFG_0 }, + { PCI_DEVICE(0x1259, 0xc107), 0, 0, RTL_CFG_0 }, { PCI_DEVICE(0x16ec, 0x0116), 0, 0, RTL_CFG_0 }, { PCI_VENDOR_ID_LINKSYS, 0x1032, PCI_ANY_ID, 0x0024, 0, 0, RTL_CFG_0 }, @@ -279,7 +277,6 @@ enum rtl_register_content { TxDMAShift = 8, /* DMA burst value (0-7) is shift this many bits */ /* Config1 register p.24 */ - MSIEnable = (1 << 5), /* Enable Message Signaled Interrupt */ PMEnable = (1 << 0), /* Power Management Enable */ /* Config2 register p. 25 */ @@ -383,22 +380,17 @@ struct ring_info { u8 __pad[sizeof(void *) - sizeof(u32)]; }; -enum features { - RTL_FEATURE_WOL = (1 << 0), - RTL_FEATURE_MSI = (1 << 1), -}; - struct rtl8169_private { void __iomem *mmio_addr; /* memory map physical address */ struct pci_dev *pci_dev; /* Index of PCI device */ struct net_device *dev; -#ifdef CONFIG_R8169_NAPI struct napi_struct napi; -#endif + struct net_device_stats stats; /* statistics of net device */ spinlock_t lock; /* spin lock flag */ u32 msg_enable; int chipset; int mac_version; + int phy_version; u32 cur_rx; /* Index into the Rx descriptor buffer of next Rx pkt. */ u32 cur_tx; /* Index into the Tx descriptor buffer of next Rx pkt. */ u32 dirty_rx; @@ -428,7 +420,7 @@ struct rtl8169_private { unsigned int (*phy_reset_pending)(void __iomem *); unsigned int (*link_ok)(void __iomem *); struct delayed_work task; - unsigned features; + unsigned wol_enabled : 1; }; MODULE_AUTHOR("Realtek and the Linux r8169 crew "); @@ -634,10 +626,7 @@ static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) RTL_W8(Cfg9346, Cfg9346_Lock); - if (wol->wolopts) - tp->features |= RTL_FEATURE_WOL; - else - tp->features &= ~RTL_FEATURE_WOL; + tp->wol_enabled = (wol->wolopts) ? 1 : 0; spin_unlock_irq(&tp->lock); @@ -718,8 +707,7 @@ static int rtl8169_set_speed_xmii(struct net_device *dev, /* This tweak comes straight from Realtek's driver. */ if ((speed == SPEED_100) && (duplex == DUPLEX_HALF) && - ((tp->mac_version == RTL_GIGA_MAC_VER_13) || - (tp->mac_version == RTL_GIGA_MAC_VER_16))) { + (tp->mac_version == RTL_GIGA_MAC_VER_13)) { auto_nego = ADVERTISE_100HALF | ADVERTISE_CSMA; } } @@ -727,8 +715,7 @@ static int rtl8169_set_speed_xmii(struct net_device *dev, /* The 8100e/8101e do Fast Ethernet only. */ if ((tp->mac_version == RTL_GIGA_MAC_VER_13) || (tp->mac_version == RTL_GIGA_MAC_VER_14) || - (tp->mac_version == RTL_GIGA_MAC_VER_15) || - (tp->mac_version == RTL_GIGA_MAC_VER_16)) { + (tp->mac_version == RTL_GIGA_MAC_VER_15)) { if ((giga_ctrl & (ADVERTISE_1000FULL | ADVERTISE_1000HALF)) && netif_msg_link(tp)) { printk(KERN_INFO "%s: PHY does not support 1000Mbps.\n", @@ -739,8 +726,7 @@ static int rtl8169_set_speed_xmii(struct net_device *dev, auto_nego |= ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM; - if ((tp->mac_version == RTL_GIGA_MAC_VER_12) || - (tp->mac_version == RTL_GIGA_MAC_VER_17)) { + if (tp->mac_version == RTL_GIGA_MAC_VER_12) { /* Vendor specific (0x1f) and reserved (0x0e) MII registers. */ mdio_write(ioaddr, 0x1f, 0x0000); mdio_write(ioaddr, 0x0e, 0x0000); @@ -1118,51 +1104,26 @@ static void rtl8169_get_mac_version(struct rtl8169_private *tp, */ const struct { u32 mask; - u32 val; int mac_version; } mac_info[] = { - /* 8168B family. */ - { 0x7c800000, 0x3c800000, RTL_GIGA_MAC_VER_18 }, - { 0x7cf00000, 0x3c000000, RTL_GIGA_MAC_VER_19 }, - { 0x7cf00000, 0x3c200000, RTL_GIGA_MAC_VER_20 }, - { 0x7c800000, 0x3c000000, RTL_GIGA_MAC_VER_20 }, - - /* 8168B family. */ - { 0x7cf00000, 0x38000000, RTL_GIGA_MAC_VER_12 }, - { 0x7cf00000, 0x38500000, RTL_GIGA_MAC_VER_17 }, - { 0x7c800000, 0x38000000, RTL_GIGA_MAC_VER_17 }, - { 0x7c800000, 0x30000000, RTL_GIGA_MAC_VER_11 }, - - /* 8101 family. */ - { 0x7cf00000, 0x34000000, RTL_GIGA_MAC_VER_13 }, - { 0x7cf00000, 0x34200000, RTL_GIGA_MAC_VER_16 }, - { 0x7c800000, 0x34000000, RTL_GIGA_MAC_VER_16 }, - /* FIXME: where did these entries come from ? -- FR */ - { 0xfc800000, 0x38800000, RTL_GIGA_MAC_VER_15 }, - { 0xfc800000, 0x30800000, RTL_GIGA_MAC_VER_14 }, - - /* 8110 family. */ - { 0xfc800000, 0x98000000, RTL_GIGA_MAC_VER_06 }, - { 0xfc800000, 0x18000000, RTL_GIGA_MAC_VER_05 }, - { 0xfc800000, 0x10000000, RTL_GIGA_MAC_VER_04 }, - { 0xfc800000, 0x04000000, RTL_GIGA_MAC_VER_03 }, - { 0xfc800000, 0x00800000, RTL_GIGA_MAC_VER_02 }, - { 0xfc800000, 0x00000000, RTL_GIGA_MAC_VER_01 }, - - { 0x00000000, 0x00000000, RTL_GIGA_MAC_VER_01 } /* Catch-all */ + { 0x38800000, RTL_GIGA_MAC_VER_15 }, + { 0x38000000, RTL_GIGA_MAC_VER_12 }, + { 0x34000000, RTL_GIGA_MAC_VER_13 }, + { 0x30800000, RTL_GIGA_MAC_VER_14 }, + { 0x30000000, RTL_GIGA_MAC_VER_11 }, + { 0x98000000, RTL_GIGA_MAC_VER_06 }, + { 0x18000000, RTL_GIGA_MAC_VER_05 }, + { 0x10000000, RTL_GIGA_MAC_VER_04 }, + { 0x04000000, RTL_GIGA_MAC_VER_03 }, + { 0x00800000, RTL_GIGA_MAC_VER_02 }, + { 0x00000000, RTL_GIGA_MAC_VER_01 } /* Catch-all */ }, *p = mac_info; u32 reg; - reg = RTL_R32(TxConfig); - while ((reg & p->mask) != p->val) + reg = RTL_R32(TxConfig) & 0xfc800000; + while ((reg & p->mask) != p->mask) p++; tp->mac_version = p->mac_version; - - if (p->mask == 0x00000000) { - struct pci_dev *pdev = tp->pci_dev; - - dev_info(&pdev->dev, "unknown MAC (%08x)\n", reg); - } } static void rtl8169_print_mac_version(struct rtl8169_private *tp) @@ -1170,21 +1131,54 @@ static void rtl8169_print_mac_version(struct rtl8169_private *tp) dprintk("mac_version = 0x%02x\n", tp->mac_version); } -struct phy_reg { +static void rtl8169_get_phy_version(struct rtl8169_private *tp, + void __iomem *ioaddr) +{ + const struct { + u16 mask; + u16 set; + int phy_version; + } phy_info[] = { + { 0x000f, 0x0002, RTL_GIGA_PHY_VER_G }, + { 0x000f, 0x0001, RTL_GIGA_PHY_VER_F }, + { 0x000f, 0x0000, RTL_GIGA_PHY_VER_E }, + { 0x0000, 0x0000, RTL_GIGA_PHY_VER_D } /* Catch-all */ + }, *p = phy_info; u16 reg; - u16 val; -}; -static void rtl_phy_write(void __iomem *ioaddr, struct phy_reg *regs, int len) + reg = mdio_read(ioaddr, MII_PHYSID2) & 0xffff; + while ((reg & p->mask) != p->set) + p++; + tp->phy_version = p->phy_version; +} + +static void rtl8169_print_phy_version(struct rtl8169_private *tp) { - while (len-- > 0) { - mdio_write(ioaddr, regs->reg, regs->val); - regs++; + struct { + int version; + char *msg; + u32 reg; + } phy_print[] = { + { RTL_GIGA_PHY_VER_G, "RTL_GIGA_PHY_VER_G", 0x0002 }, + { RTL_GIGA_PHY_VER_F, "RTL_GIGA_PHY_VER_F", 0x0001 }, + { RTL_GIGA_PHY_VER_E, "RTL_GIGA_PHY_VER_E", 0x0000 }, + { RTL_GIGA_PHY_VER_D, "RTL_GIGA_PHY_VER_D", 0x0000 }, + { 0, NULL, 0x0000 } + }, *p; + + for (p = phy_print; p->msg; p++) { + if (tp->phy_version == p->version) { + dprintk("phy_version == %s (%04x)\n", p->msg, p->reg); + return; + } } + dprintk("phy_version == Unknown\n"); } -static void rtl8169s_hw_phy_config(void __iomem *ioaddr) +static void rtl8169_hw_phy_config(struct net_device *dev) { + struct rtl8169_private *tp = netdev_priv(dev); + void __iomem *ioaddr = tp->mmio_addr; struct { u16 regs[5]; /* Beware of bit-sign propagation */ } phy_magic[5] = { { @@ -1217,9 +1211,33 @@ static void rtl8169s_hw_phy_config(void __iomem *ioaddr) }, *p = phy_magic; unsigned int i; - mdio_write(ioaddr, 0x1f, 0x0001); //w 31 2 0 1 - mdio_write(ioaddr, 0x15, 0x1000); //w 21 15 0 1000 - mdio_write(ioaddr, 0x18, 0x65c7); //w 24 15 0 65c7 + rtl8169_print_mac_version(tp); + rtl8169_print_phy_version(tp); + + if (tp->mac_version <= RTL_GIGA_MAC_VER_01) + return; + if (tp->phy_version >= RTL_GIGA_PHY_VER_H) + return; + + dprintk("MAC version != 0 && PHY version == 0 or 1\n"); + dprintk("Do final_reg2.cfg\n"); + + /* Shazam ! */ + + if (tp->mac_version == RTL_GIGA_MAC_VER_04) { + mdio_write(ioaddr, 31, 0x0002); + mdio_write(ioaddr, 1, 0x90d0); + mdio_write(ioaddr, 31, 0x0000); + return; + } + + if ((tp->mac_version != RTL_GIGA_MAC_VER_02) && + (tp->mac_version != RTL_GIGA_MAC_VER_03)) + return; + + mdio_write(ioaddr, 31, 0x0001); //w 31 2 0 1 + mdio_write(ioaddr, 21, 0x1000); //w 21 15 0 1000 + mdio_write(ioaddr, 24, 0x65c7); //w 24 15 0 65c7 rtl8169_write_gmii_reg_bit(ioaddr, 4, 11, 0); //w 4 11 11 0 for (i = 0; i < ARRAY_SIZE(phy_magic); i++, p++) { @@ -1232,115 +1250,7 @@ static void rtl8169s_hw_phy_config(void __iomem *ioaddr) rtl8169_write_gmii_reg_bit(ioaddr, 4, 11, 1); //w 4 11 11 1 rtl8169_write_gmii_reg_bit(ioaddr, 4, 11, 0); //w 4 11 11 0 } - mdio_write(ioaddr, 0x1f, 0x0000); //w 31 2 0 0 -} - -static void rtl8169sb_hw_phy_config(void __iomem *ioaddr) -{ - struct phy_reg phy_reg_init[] = { - { 0x1f, 0x0002 }, - { 0x01, 0x90d0 }, - { 0x1f, 0x0000 } - }; - - rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); -} -static void rtl8168b_hw_phy_config(void __iomem *ioaddr) -{ - struct phy_reg phy_reg_init[] = { - { 0x1f, 0x0000 }, - { 0x10, 0xf41b }, - { 0x1f, 0x0000 } - }; - - rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); -} - -static void rtl8168cp_hw_phy_config(void __iomem *ioaddr) -{ - struct phy_reg phy_reg_init[] = { - { 0x1f, 0x0000 }, - { 0x1d, 0x0f00 }, - { 0x1f, 0x0002 }, - { 0x0c, 0x1ec8 }, - { 0x1f, 0x0000 } - }; - - rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); -} - -static void rtl8168c_hw_phy_config(void __iomem *ioaddr) -{ - struct phy_reg phy_reg_init[] = { - { 0x1f, 0x0001 }, - { 0x12, 0x2300 }, - { 0x1f, 0x0002 }, - { 0x00, 0x88d4 }, - { 0x01, 0x82b1 }, - { 0x03, 0x7002 }, - { 0x08, 0x9e30 }, - { 0x09, 0x01f0 }, - { 0x0a, 0x5500 }, - { 0x0c, 0x00c8 }, - { 0x1f, 0x0003 }, - { 0x12, 0xc096 }, - { 0x16, 0x000a }, - { 0x1f, 0x0000 } - }; - - rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); -} - -static void rtl8168cx_hw_phy_config(void __iomem *ioaddr) -{ - struct phy_reg phy_reg_init[] = { - { 0x1f, 0x0000 }, - { 0x12, 0x2300 }, - { 0x1f, 0x0003 }, - { 0x16, 0x0f0a }, - { 0x1f, 0x0000 }, - { 0x1f, 0x0002 }, - { 0x0c, 0x7eb8 }, - { 0x1f, 0x0000 } - }; - - rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); -} - -static void rtl_hw_phy_config(struct net_device *dev) -{ - struct rtl8169_private *tp = netdev_priv(dev); - void __iomem *ioaddr = tp->mmio_addr; - - rtl8169_print_mac_version(tp); - - switch (tp->mac_version) { - case RTL_GIGA_MAC_VER_01: - break; - case RTL_GIGA_MAC_VER_02: - case RTL_GIGA_MAC_VER_03: - rtl8169s_hw_phy_config(ioaddr); - break; - case RTL_GIGA_MAC_VER_04: - rtl8169sb_hw_phy_config(ioaddr); - break; - case RTL_GIGA_MAC_VER_11: - case RTL_GIGA_MAC_VER_12: - case RTL_GIGA_MAC_VER_17: - rtl8168b_hw_phy_config(ioaddr); - break; - case RTL_GIGA_MAC_VER_18: - rtl8168cp_hw_phy_config(ioaddr); - break; - case RTL_GIGA_MAC_VER_19: - rtl8168c_hw_phy_config(ioaddr); - break; - case RTL_GIGA_MAC_VER_20: - rtl8168cx_hw_phy_config(ioaddr); - break; - default: - break; - } + mdio_write(ioaddr, 31, 0x0000); //w 31 2 0 0 } static void rtl8169_phy_timer(unsigned long __opaque) @@ -1352,6 +1262,7 @@ static void rtl8169_phy_timer(unsigned long __opaque) unsigned long timeout = RTL8169_PHY_TIMEOUT; assert(tp->mac_version > RTL_GIGA_MAC_VER_01); + assert(tp->phy_version < RTL_GIGA_PHY_VER_H); if (!(tp->phy_1000_ctrl_reg & ADVERTISE_1000FULL)) return; @@ -1386,7 +1297,8 @@ static inline void rtl8169_delete_timer(struct net_device *dev) struct rtl8169_private *tp = netdev_priv(dev); struct timer_list *timer = &tp->timer; - if (tp->mac_version <= RTL_GIGA_MAC_VER_01) + if ((tp->mac_version <= RTL_GIGA_MAC_VER_01) || + (tp->phy_version >= RTL_GIGA_PHY_VER_H)) return; del_timer_sync(timer); @@ -1397,7 +1309,8 @@ static inline void rtl8169_request_timer(struct net_device *dev) struct rtl8169_private *tp = netdev_priv(dev); struct timer_list *timer = &tp->timer; - if (tp->mac_version <= RTL_GIGA_MAC_VER_01) + if ((tp->mac_version <= RTL_GIGA_MAC_VER_01) || + (tp->phy_version >= RTL_GIGA_PHY_VER_H)) return; mod_timer(timer, jiffies + RTL8169_PHY_TIMEOUT); @@ -1449,7 +1362,7 @@ static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp) { void __iomem *ioaddr = tp->mmio_addr; - rtl_hw_phy_config(dev); + rtl8169_hw_phy_config(dev); dprintk("Set MAC Reg C+CR Offset 0x82h = 0x01h\n"); RTL_W8(0x82, 0x01); @@ -1544,7 +1457,6 @@ static const struct rtl_cfg_info { unsigned int align; u16 intr_event; u16 napi_event; - unsigned msi; } rtl_cfg_infos [] = { [RTL_CFG_0] = { .hw_start = rtl_hw_start_8169, @@ -1552,8 +1464,7 @@ static const struct rtl_cfg_info { .align = 0, .intr_event = SYSErr | LinkChg | RxOverflow | RxFIFOOver | TxErr | TxOK | RxOK | RxErr, - .napi_event = RxFIFOOver | TxErr | TxOK | RxOK | RxOverflow, - .msi = 0 + .napi_event = RxFIFOOver | TxErr | TxOK | RxOK | RxOverflow }, [RTL_CFG_1] = { .hw_start = rtl_hw_start_8168, @@ -1561,8 +1472,7 @@ static const struct rtl_cfg_info { .align = 8, .intr_event = SYSErr | LinkChg | RxOverflow | TxErr | TxOK | RxOK | RxErr, - .napi_event = TxErr | TxOK | RxOK | RxOverflow, - .msi = RTL_FEATURE_MSI + .napi_event = TxErr | TxOK | RxOK | RxOverflow }, [RTL_CFG_2] = { .hw_start = rtl_hw_start_8101, @@ -1570,39 +1480,10 @@ static const struct rtl_cfg_info { .align = 8, .intr_event = SYSErr | LinkChg | RxOverflow | PCSTimeout | RxFIFOOver | TxErr | TxOK | RxOK | RxErr, - .napi_event = RxFIFOOver | TxErr | TxOK | RxOK | RxOverflow, - .msi = RTL_FEATURE_MSI + .napi_event = RxFIFOOver | TxErr | TxOK | RxOK | RxOverflow } }; -/* Cfg9346_Unlock assumed. */ -static unsigned rtl_try_msi(struct pci_dev *pdev, void __iomem *ioaddr, - const struct rtl_cfg_info *cfg) -{ - unsigned msi = 0; - u8 cfg2; - - cfg2 = RTL_R8(Config2) & ~MSIEnable; - if (cfg->msi) { - if (pci_enable_msi(pdev)) { - dev_info(&pdev->dev, "no MSI. Back to INTx.\n"); - } else { - cfg2 |= MSIEnable; - msi = RTL_FEATURE_MSI; - } - } - RTL_W8(Config2, cfg2); - return msi; -} - -static void rtl_disable_msi(struct pci_dev *pdev, struct rtl8169_private *tp) -{ - if (tp->features & RTL_FEATURE_MSI) { - pci_disable_msi(pdev); - tp->features &= ~RTL_FEATURE_MSI; - } -} - static int __devinit rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -1715,8 +1596,10 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) /* Identify chip attached to board */ rtl8169_get_mac_version(tp, ioaddr); + rtl8169_get_phy_version(tp, ioaddr); rtl8169_print_mac_version(tp); + rtl8169_print_phy_version(tp); for (i = ARRAY_SIZE(rtl_chip_info) - 1; i >= 0; i--) { if (tp->mac_version == rtl_chip_info[i].mac_version) @@ -1736,7 +1619,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) RTL_W8(Cfg9346, Cfg9346_Unlock); RTL_W8(Config1, RTL_R8(Config1) | PMEnable); RTL_W8(Config5, RTL_R8(Config5) & PMEStatus); - tp->features |= rtl_try_msi(pdev, ioaddr, cfg); RTL_W8(Cfg9346, Cfg9346_Lock); if (RTL_R8(PHYstatus) & TBI_Enable) { @@ -1804,7 +1686,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) rc = register_netdev(dev); if (rc < 0) - goto err_out_msi_5; + goto err_out_unmap_5; pci_set_drvdata(pdev, dev); @@ -1827,8 +1709,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) out: return rc; -err_out_msi_5: - rtl_disable_msi(pdev, tp); +err_out_unmap_5: iounmap(ioaddr); err_out_free_res_4: pci_release_regions(pdev); @@ -1849,7 +1730,6 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev) flush_scheduled_work(); unregister_netdev(dev); - rtl_disable_msi(pdev, tp); rtl8169_release_board(pdev, dev, tp->mmio_addr); pci_set_drvdata(pdev, NULL); } @@ -1893,8 +1773,7 @@ static int rtl8169_open(struct net_device *dev) smp_mb(); - retval = request_irq(dev->irq, rtl8169_interrupt, - (tp->features & RTL_FEATURE_MSI) ? 0 : IRQF_SHARED, + retval = request_irq(dev->irq, rtl8169_interrupt, IRQF_SHARED, dev->name, dev); if (retval < 0) goto err_release_ring_2; @@ -2054,7 +1933,7 @@ static void rtl_hw_start_8169(struct net_device *dev) if ((tp->mac_version == RTL_GIGA_MAC_VER_02) || (tp->mac_version == RTL_GIGA_MAC_VER_03)) { - dprintk("Set MAC Reg C+CR Offset 0xE0. " + dprintk(KERN_INFO PFX "Set MAC Reg C+CR Offset 0xE0. " "Bit-3 and bit-14 MUST be 1\n"); tp->cp_cmd |= (1 << 14); } @@ -2150,8 +2029,7 @@ static void rtl_hw_start_8101(struct net_device *dev) void __iomem *ioaddr = tp->mmio_addr; struct pci_dev *pdev = tp->pci_dev; - if ((tp->mac_version == RTL_GIGA_MAC_VER_13) || - (tp->mac_version == RTL_GIGA_MAC_VER_16)) { + if (tp->mac_version == RTL_GIGA_MAC_VER_13) { pci_write_config_word(pdev, 0x68, 0x00); pci_write_config_word(pdev, 0x69, 0x08); } @@ -2381,7 +2259,7 @@ static void rtl8169_tx_clear(struct rtl8169_private *tp) dev_kfree_skb(skb); tx_skb->skb = NULL; } - tp->dev->stats.tx_dropped++; + tp->stats.tx_dropped++; } } tp->cur_tx = tp->dirty_tx = 0; @@ -2432,7 +2310,7 @@ static void rtl8169_reinit_task(struct work_struct *work) ret = rtl8169_open(dev); if (unlikely(ret < 0)) { if (net_ratelimit() && netif_msg_drv(tp)) { - printk(KERN_ERR PFX "%s: reinit failure (status = %d)." + printk(PFX KERN_ERR "%s: reinit failure (status = %d)." " Rescheduling.\n", dev->name, ret); } rtl8169_schedule_work(dev, rtl8169_reinit_task); @@ -2462,10 +2340,9 @@ static void rtl8169_reset_task(struct work_struct *work) rtl8169_init_ring_indexes(tp); rtl_hw_start(dev); netif_wake_queue(dev); - rtl8169_check_link_status(dev, tp, tp->mmio_addr); } else { if (net_ratelimit() && netif_msg_intr(tp)) { - printk(KERN_EMERG PFX "%s: Rx buffers shortage\n", + printk(PFX KERN_EMERG "%s: Rx buffers shortage\n", dev->name); } rtl8169_schedule_work(dev, rtl8169_reset_task); @@ -2619,7 +2496,7 @@ static int rtl8169_start_xmit(struct sk_buff *skb, struct net_device *dev) netif_stop_queue(dev); ret = NETDEV_TX_BUSY; err_update_stats: - dev->stats.tx_dropped++; + tp->stats.tx_dropped++; goto out; } @@ -2694,8 +2571,8 @@ static void rtl8169_tx_interrupt(struct net_device *dev, if (status & DescOwn) break; - dev->stats.tx_bytes += len; - dev->stats.tx_packets++; + tp->stats.tx_bytes += len; + tp->stats.tx_packets++; rtl8169_unmap_tx_skb(tp->pci_dev, tx_skb, tp->TxDescArray + entry); @@ -2795,14 +2672,14 @@ static int rtl8169_rx_interrupt(struct net_device *dev, "%s: Rx ERROR. status = %08x\n", dev->name, status); } - dev->stats.rx_errors++; + tp->stats.rx_errors++; if (status & (RxRWT | RxRUNT)) - dev->stats.rx_length_errors++; + tp->stats.rx_length_errors++; if (status & RxCRC) - dev->stats.rx_crc_errors++; + tp->stats.rx_crc_errors++; if (status & RxFOVF) { rtl8169_schedule_work(dev, rtl8169_reset_task); - dev->stats.rx_fifo_errors++; + tp->stats.rx_fifo_errors++; } rtl8169_mark_to_asic(desc, tp->rx_buf_sz); } else { @@ -2817,8 +2694,8 @@ static int rtl8169_rx_interrupt(struct net_device *dev, * sized frames. */ if (unlikely(rtl8169_fragmented_frame(status))) { - dev->stats.rx_dropped++; - dev->stats.rx_length_errors++; + tp->stats.rx_dropped++; + tp->stats.rx_length_errors++; rtl8169_mark_to_asic(desc, tp->rx_buf_sz); continue; } @@ -2842,8 +2719,8 @@ static int rtl8169_rx_interrupt(struct net_device *dev, rtl8169_rx_skb(skb); dev->last_rx = jiffies; - dev->stats.rx_bytes += pkt_size; - dev->stats.rx_packets++; + tp->stats.rx_bytes += pkt_size; + tp->stats.rx_packets++; } /* Work around for AMD plateform. */ @@ -2991,29 +2868,31 @@ static void rtl8169_down(struct net_device *dev) { struct rtl8169_private *tp = netdev_priv(dev); void __iomem *ioaddr = tp->mmio_addr; + unsigned int poll_locked = 0; unsigned int intrmask; rtl8169_delete_timer(dev); netif_stop_queue(dev); -#ifdef CONFIG_R8169_NAPI - napi_disable(&tp->napi); -#endif - core_down: spin_lock_irq(&tp->lock); rtl8169_asic_down(ioaddr); /* Update the error counts. */ - dev->stats.rx_missed_errors += RTL_R32(RxMissed); + tp->stats.rx_missed_errors += RTL_R32(RxMissed); RTL_W32(RxMissed, 0); spin_unlock_irq(&tp->lock); synchronize_irq(dev->irq); + if (!poll_locked) { + napi_disable(&tp->napi); + poll_locked++; + } + /* Give a racing hard_start_xmit a few cycles to complete. */ synchronize_sched(); /* FIXME: should this be synchronize_irq()? */ @@ -3105,9 +2984,7 @@ static void rtl_set_rx_mode(struct net_device *dev) (tp->mac_version == RTL_GIGA_MAC_VER_12) || (tp->mac_version == RTL_GIGA_MAC_VER_13) || (tp->mac_version == RTL_GIGA_MAC_VER_14) || - (tp->mac_version == RTL_GIGA_MAC_VER_15) || - (tp->mac_version == RTL_GIGA_MAC_VER_16) || - (tp->mac_version == RTL_GIGA_MAC_VER_17)) { + (tp->mac_version == RTL_GIGA_MAC_VER_15)) { mc_filter[0] = 0xffffffff; mc_filter[1] = 0xffffffff; } @@ -3134,12 +3011,12 @@ static struct net_device_stats *rtl8169_get_stats(struct net_device *dev) if (netif_running(dev)) { spin_lock_irqsave(&tp->lock, flags); - dev->stats.rx_missed_errors += RTL_R32(RxMissed); + tp->stats.rx_missed_errors += RTL_R32(RxMissed); RTL_W32(RxMissed, 0); spin_unlock_irqrestore(&tp->lock, flags); } - return &dev->stats; + return &tp->stats; } #ifdef CONFIG_PM @@ -3160,15 +3037,14 @@ static int rtl8169_suspend(struct pci_dev *pdev, pm_message_t state) rtl8169_asic_down(ioaddr); - dev->stats.rx_missed_errors += RTL_R32(RxMissed); + tp->stats.rx_missed_errors += RTL_R32(RxMissed); RTL_W32(RxMissed, 0); spin_unlock_irq(&tp->lock); out_pci_suspend: pci_save_state(pdev); - pci_enable_wake(pdev, pci_choose_state(pdev, state), - (tp->features & RTL_FEATURE_WOL) ? 1 : 0); + pci_enable_wake(pdev, pci_choose_state(pdev, state), tp->wol_enabled); pci_set_power_state(pdev, pci_choose_state(pdev, state)); return 0; diff --git a/trunk/drivers/net/rrunner.c b/trunk/drivers/net/rrunner.c index b822859c8de3..19152f54ef2b 100644 --- a/trunk/drivers/net/rrunner.c +++ b/trunk/drivers/net/rrunner.c @@ -79,10 +79,12 @@ static char version[] __devinitdata = "rrunner.c: v0.50 11/11/2002 Jes Sorensen */ /* - * sysctl_[wr]mem_max are checked at init time to see if they are at - * least 256KB and increased to 256KB if they are not. This is done to - * avoid ending up with socket buffers smaller than the MTU size, + * These are checked at init time to see if they are at least 256KB + * and increased to 256KB if they are not. This is done to avoid ending + * up with socket buffers smaller than the MTU size, */ +extern __u32 sysctl_wmem_max; +extern __u32 sysctl_rmem_max; static int __devinit rr_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) diff --git a/trunk/drivers/net/sky2.c b/trunk/drivers/net/sky2.c index c27c7d63b6a5..24cfb6275d9b 100644 --- a/trunk/drivers/net/sky2.c +++ b/trunk/drivers/net/sky2.c @@ -4271,7 +4271,7 @@ static void __devexit sky2_remove(struct pci_dev *pdev) del_timer_sync(&hw->watchdog_timer); cancel_work_sync(&hw->restart_work); - for (i = hw->ports-1; i >= 0; --i) + for (i = hw->ports; i >= 0; --i) unregister_netdev(hw->dev[i]); sky2_write32(hw, B0_IMSK, 0); @@ -4289,7 +4289,7 @@ static void __devexit sky2_remove(struct pci_dev *pdev) pci_release_regions(pdev); pci_disable_device(pdev); - for (i = hw->ports-1; i >= 0; --i) + for (i = hw->ports; i >= 0; --i) free_netdev(hw->dev[i]); iounmap(hw->regs); diff --git a/trunk/drivers/net/typhoon.c b/trunk/drivers/net/typhoon.c index 94ac5869bb18..72e5e9be7e99 100644 --- a/trunk/drivers/net/typhoon.c +++ b/trunk/drivers/net/typhoon.c @@ -1801,7 +1801,7 @@ typhoon_poll(struct napi_struct *napi, int budget) static irqreturn_t typhoon_interrupt(int irq, void *dev_instance) { - struct net_device *dev = dev_instance; + struct net_device *dev = (struct net_device *) dev_instance; struct typhoon *tp = dev->priv; void __iomem *ioaddr = tp->ioaddr; u32 intr_status; diff --git a/trunk/drivers/net/ucc_geth.c b/trunk/drivers/net/ucc_geth.c index a3ff270593f1..bec413ba9bca 100644 --- a/trunk/drivers/net/ucc_geth.c +++ b/trunk/drivers/net/ucc_geth.c @@ -2214,7 +2214,9 @@ static void ucc_geth_set_multi(struct net_device *dev) struct dev_mc_list *dmi; struct ucc_fast *uf_regs; struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt; - int i; + u8 tempaddr[6]; + u8 *mcptr, *tdptr; + int i, j; ugeth = netdev_priv(dev); @@ -2253,10 +2255,19 @@ static void ucc_geth_set_multi(struct net_device *dev) if (!(dmi->dmi_addr[0] & 1)) continue; + /* The address in dmi_addr is LSB first, + * and taddr is MSB first. We have to + * copy bytes MSB first from dmi_addr. + */ + mcptr = (u8 *) dmi->dmi_addr + 5; + tdptr = (u8 *) tempaddr; + for (j = 0; j < 6; j++) + *tdptr++ = *mcptr--; + /* Ask CPM to run CRC and set bit in * filter mask. */ - hw_add_addr_in_hash(ugeth, dmi->dmi_addr); + hw_add_addr_in_hash(ugeth, tempaddr); } } } @@ -3596,7 +3607,7 @@ static int ucc_geth_poll(struct napi_struct *napi, int budget) static irqreturn_t ucc_geth_irq_handler(int irq, void *info) { - struct net_device *dev = info; + struct net_device *dev = (struct net_device *)info; struct ucc_geth_private *ugeth = netdev_priv(dev); struct ucc_fast_private *uccf; struct ucc_geth_info *ug_info; diff --git a/trunk/drivers/net/usb/dm9601.c b/trunk/drivers/net/usb/dm9601.c index 2c685734b7a4..a2de32fabc17 100644 --- a/trunk/drivers/net/usb/dm9601.c +++ b/trunk/drivers/net/usb/dm9601.c @@ -586,10 +586,6 @@ static const struct usb_device_id products[] = { USB_DEVICE(0x0a46, 0x0268), /* ShanTou ST268 USB NIC */ .driver_info = (unsigned long)&dm9601_info, }, - { - USB_DEVICE(0x0a46, 0x8515), /* ADMtek ADM8515 USB NIC */ - .driver_info = (unsigned long)&dm9601_info, - }, {}, // END }; diff --git a/trunk/drivers/net/usb/rndis_host.c b/trunk/drivers/net/usb/rndis_host.c index 1ebe3259be0d..cd991a0f75bb 100644 --- a/trunk/drivers/net/usb/rndis_host.c +++ b/trunk/drivers/net/usb/rndis_host.c @@ -512,19 +512,11 @@ static int rndis_bind(struct usbnet *dev, struct usb_interface *intf) } tmp = le32_to_cpu(u.init_c->max_transfer_size); if (tmp < dev->hard_mtu) { - if (tmp <= net->hard_header_len) { - dev_err(&intf->dev, - "dev can't take %u byte packets (max %u)\n", - dev->hard_mtu, tmp); - retval = -EINVAL; - goto fail_and_release; - } - dev->hard_mtu = tmp; - net->mtu = dev->hard_mtu - net->hard_header_len; - dev_warn(&intf->dev, - "dev can't take %u byte packets (max %u), " - "adjusting MTU to %u\n", - dev->hard_mtu, tmp, net->mtu); + dev_err(&intf->dev, + "dev can't take %u byte packets (max %u)\n", + dev->hard_mtu, tmp); + retval = -EINVAL; + goto fail_and_release; } /* REVISIT: peripheral "alignment" request is ignored ... */ diff --git a/trunk/drivers/net/wan/lmc/lmc_main.c b/trunk/drivers/net/wan/lmc/lmc_main.c index 64eb57893602..5ea877221f46 100644 --- a/trunk/drivers/net/wan/lmc/lmc_main.c +++ b/trunk/drivers/net/wan/lmc/lmc_main.c @@ -142,10 +142,9 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ * To date internally, just copy this out to the user. */ case LMCIOCGINFO: /*fold01*/ - if (copy_to_user(ifr->ifr_data, &sc->ictl, sizeof(lmc_ctl_t))) - ret = -EFAULT; - else - ret = 0; + if (copy_to_user(ifr->ifr_data, &sc->ictl, sizeof (lmc_ctl_t))) + return -EFAULT; + ret = 0; break; case LMCIOCSINFO: /*fold01*/ @@ -160,10 +159,8 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ break; } - if (copy_from_user(&ctl, ifr->ifr_data, sizeof(lmc_ctl_t))) { - ret = -EFAULT; - break; - } + if (copy_from_user(&ctl, ifr->ifr_data, sizeof (lmc_ctl_t))) + return -EFAULT; sc->lmc_media->set_status (sc, &ctl); @@ -193,10 +190,8 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ break; } - if (copy_from_user(&new_type, ifr->ifr_data, sizeof(u_int16_t))) { - ret = -EFAULT; - break; - } + if (copy_from_user(&new_type, ifr->ifr_data, sizeof(u_int16_t))) + return -EFAULT; if (new_type == old_type) @@ -234,10 +229,9 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ sc->lmc_xinfo.Magic1 = 0xDEADBEEF; if (copy_to_user(ifr->ifr_data, &sc->lmc_xinfo, - sizeof(struct lmc_xinfo))) { - ret = -EFAULT; - else - ret = 0; + sizeof (struct lmc_xinfo))) + return -EFAULT; + ret = 0; break; @@ -268,9 +262,9 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ if (copy_to_user(ifr->ifr_data, &sc->stats, sizeof (struct lmc_statistics))) - ret = -EFAULT; - else - ret = 0; + return -EFAULT; + + ret = 0; break; case LMCIOCCLEARLMCSTATS: /*fold01*/ @@ -298,10 +292,8 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ break; } - if (copy_from_user(&ctl, ifr->ifr_data, sizeof(lmc_ctl_t))) { - ret = -EFAULT; - break; - } + if (copy_from_user(&ctl, ifr->ifr_data, sizeof (lmc_ctl_t))) + return -EFAULT; sc->lmc_media->set_circuit_type(sc, ctl.circuit_type); sc->ictl.circuit_type = ctl.circuit_type; ret = 0; @@ -326,15 +318,12 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ #ifdef DEBUG case LMCIOCDUMPEVENTLOG: - if (copy_to_user(ifr->ifr_data, &lmcEventLogIndex, sizeof(u32))) { - ret = -EFAULT; - break; - } + if (copy_to_user(ifr->ifr_data, &lmcEventLogIndex, sizeof (u32))) + return -EFAULT; if (copy_to_user(ifr->ifr_data + sizeof (u32), lmcEventLogBuf, sizeof (lmcEventLogBuf))) - ret = -EFAULT; - else - ret = 0; + return -EFAULT; + ret = 0; break; #endif /* end ifdef _DBG_EVENTLOG */ case LMCIOCT1CONTROL: /*fold01*/ @@ -357,10 +346,8 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ */ netif_stop_queue(dev); - if (copy_from_user(&xc, ifr->ifr_data, sizeof(struct lmc_xilinx_control))) { - ret = -EFAULT; - break; - } + if (copy_from_user(&xc, ifr->ifr_data, sizeof (struct lmc_xilinx_control))) + return -EFAULT; switch(xc.command){ case lmc_xilinx_reset: /*fold02*/ { diff --git a/trunk/drivers/net/wan/sbni.c b/trunk/drivers/net/wan/sbni.c index 2e8b5c2de887..76db40d200d8 100644 --- a/trunk/drivers/net/wan/sbni.c +++ b/trunk/drivers/net/wan/sbni.c @@ -502,8 +502,8 @@ sbni_start_xmit( struct sk_buff *skb, struct net_device *dev ) static irqreturn_t sbni_interrupt( int irq, void *dev_id ) { - struct net_device *dev = dev_id; - struct net_local *nl = dev->priv; + struct net_device *dev = (struct net_device *) dev_id; + struct net_local *nl = (struct net_local *) dev->priv; int repeat; spin_lock( &nl->lock ); diff --git a/trunk/drivers/net/wireless/b43/main.c b/trunk/drivers/net/wireless/b43/main.c index 5058e60e5703..9d9ff76a9bc6 100644 --- a/trunk/drivers/net/wireless/b43/main.c +++ b/trunk/drivers/net/wireless/b43/main.c @@ -2391,7 +2391,7 @@ static void b43_periodic_work_handler(struct work_struct *work) if (b43_debug(dev, B43_DBG_PWORK_FAST)) delay = msecs_to_jiffies(50); else - delay = round_jiffies_relative(HZ * 15); + delay = round_jiffies(HZ * 15); queue_delayed_work(wl->hw->workqueue, &dev->periodic_work, delay); out: mutex_unlock(&wl->mutex); diff --git a/trunk/drivers/net/wireless/b43legacy/main.c b/trunk/drivers/net/wireless/b43legacy/main.c index f0e56dfc9ecf..d09479e816cd 100644 --- a/trunk/drivers/net/wireless/b43legacy/main.c +++ b/trunk/drivers/net/wireless/b43legacy/main.c @@ -2260,7 +2260,7 @@ static void b43legacy_periodic_work_handler(struct work_struct *work) if (b43legacy_debug(dev, B43legacy_DBG_PWORK_FAST)) delay = msecs_to_jiffies(50); else - delay = round_jiffies_relative(HZ); + delay = round_jiffies(HZ); queue_delayed_work(dev->wl->hw->workqueue, &dev->periodic_work, delay); out: diff --git a/trunk/drivers/net/wireless/ipw2100.c b/trunk/drivers/net/wireless/ipw2100.c index 8d53d08b9691..a6c7904de282 100644 --- a/trunk/drivers/net/wireless/ipw2100.c +++ b/trunk/drivers/net/wireless/ipw2100.c @@ -1769,7 +1769,7 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred) if (priv->stop_rf_kill) { priv->stop_rf_kill = 0; queue_delayed_work(priv->workqueue, &priv->rf_kill, - round_jiffies_relative(HZ)); + round_jiffies(HZ)); } deferred = 1; @@ -2086,8 +2086,7 @@ static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status) /* Make sure the RF Kill check timer is running */ priv->stop_rf_kill = 0; cancel_delayed_work(&priv->rf_kill); - queue_delayed_work(priv->workqueue, &priv->rf_kill, - round_jiffies_relative(HZ)); + queue_delayed_work(priv->workqueue, &priv->rf_kill, round_jiffies(HZ)); } static void send_scan_event(void *data) @@ -2124,7 +2123,7 @@ static void isr_scan_complete(struct ipw2100_priv *priv, u32 status) if (!delayed_work_pending(&priv->scan_event_later)) queue_delayed_work(priv->workqueue, &priv->scan_event_later, - round_jiffies_relative(msecs_to_jiffies(4000))); + round_jiffies(msecs_to_jiffies(4000))); } else { priv->user_requested_scan = 0; cancel_delayed_work(&priv->scan_event_later); @@ -4243,7 +4242,7 @@ static int ipw_radio_kill_sw(struct ipw2100_priv *priv, int disable_radio) priv->stop_rf_kill = 0; cancel_delayed_work(&priv->rf_kill); queue_delayed_work(priv->workqueue, &priv->rf_kill, - round_jiffies_relative(HZ)); + round_jiffies(HZ)); } else schedule_reset(priv); } @@ -5982,7 +5981,7 @@ static void ipw2100_rf_kill(struct work_struct *work) IPW_DEBUG_RF_KILL("RF Kill active, rescheduling GPIO check\n"); if (!priv->stop_rf_kill) queue_delayed_work(priv->workqueue, &priv->rf_kill, - round_jiffies_relative(HZ)); + round_jiffies(HZ)); goto exit_unlock; } diff --git a/trunk/drivers/net/wireless/ipw2200.c b/trunk/drivers/net/wireless/ipw2200.c index 54f44e5473c0..e3c828401b9a 100644 --- a/trunk/drivers/net/wireless/ipw2200.c +++ b/trunk/drivers/net/wireless/ipw2200.c @@ -1753,7 +1753,7 @@ static int ipw_radio_kill_sw(struct ipw_priv *priv, int disable_radio) /* Make sure the RF_KILL check timer is running */ cancel_delayed_work(&priv->rf_kill); queue_delayed_work(priv->workqueue, &priv->rf_kill, - round_jiffies_relative(2 * HZ)); + round_jiffies(2 * HZ)); } else queue_work(priv->workqueue, &priv->up); } @@ -4364,7 +4364,7 @@ static void handle_scan_event(struct ipw_priv *priv) if (!priv->user_requested_scan) { if (!delayed_work_pending(&priv->scan_event)) queue_delayed_work(priv->workqueue, &priv->scan_event, - round_jiffies_relative(msecs_to_jiffies(4000))); + round_jiffies(msecs_to_jiffies(4000))); } else { union iwreq_data wrqu; @@ -4728,7 +4728,7 @@ static void ipw_rx_notification(struct ipw_priv *priv, && priv->status & STATUS_ASSOCIATED) queue_delayed_work(priv->workqueue, &priv->request_scan, - round_jiffies_relative(HZ)); + round_jiffies(HZ)); /* Send an empty event to user space. * We don't send the received data on the event because diff --git a/trunk/drivers/net/wireless/iwlwifi/Kconfig b/trunk/drivers/net/wireless/iwlwifi/Kconfig index 8d52a26c248a..25cfc6c32509 100644 --- a/trunk/drivers/net/wireless/iwlwifi/Kconfig +++ b/trunk/drivers/net/wireless/iwlwifi/Kconfig @@ -96,8 +96,8 @@ config IWL4965 If you want to compile the driver as a module ( = code which can be inserted in and remvoed from the running kernel whenever you want), - say M here and read . The - module will be called iwl4965.ko. + say M here and read . The module + will be called iwl4965.ko. config IWL3945 tristate "Intel PRO/Wireless 3945ABG/BG Network Connection" @@ -124,5 +124,5 @@ config IWL3945 If you want to compile the driver as a module ( = code which can be inserted in and remvoed from the running kernel whenever you want), - say M here and read . The - module will be called iwl3945.ko. + say M here and read . The module + will be called iwl3945.ko. diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-4965.c b/trunk/drivers/net/wireless/iwlwifi/iwl-4965.c index 891f90d2f019..557deebca1b9 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-4965.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-4965.c @@ -3232,7 +3232,9 @@ int iwl4965_tx_cmd(struct iwl_priv *priv, struct iwl_cmd *out_cmd, tx->rate_n_flags = iwl_hw_set_rate_n_flags(iwl_rates[rate_index].plcp, rate_flags); - if (ieee80211_is_back_request(fc)) + if (ieee80211_is_probe_request(fc)) + tx->tx_flags |= TX_CMD_FLG_TSF_MSK; + else if (ieee80211_is_back_request(fc)) tx->tx_flags |= TX_CMD_FLG_ACK_MSK | TX_CMD_FLG_IMM_BA_RSP_MASK; #ifdef CONFIG_IWLWIFI_HT @@ -3870,7 +3872,7 @@ static void iwl4965_rx_reply_rx(struct iwl_priv *priv, */ case IEEE80211_STYPE_ASSOC_RESP: case IEEE80211_STYPE_REASSOC_RESP: - if (network_packet) { + if (network_packet && iwl_is_associated(priv)) { #ifdef CONFIG_IWLWIFI_HT u8 *pos = NULL; struct ieee802_11_elems elems; diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl3945-base.c b/trunk/drivers/net/wireless/iwlwifi/iwl3945-base.c index 4f22a7174caf..83019d1d7ccc 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl3945-base.c @@ -6478,9 +6478,8 @@ static void iwl_bg_scan_check(struct work_struct *data) IWL_DEBUG(IWL_DL_INFO | IWL_DL_SCAN, "Scan completion watchdog resetting adapter (%dms)\n", jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG)); - if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) - iwl_send_scan_abort(priv); + queue_work(priv->workqueue, &priv->restart); } mutex_unlock(&priv->mutex); } @@ -6576,7 +6575,7 @@ static void iwl_bg_request_scan(struct work_struct *data) spin_unlock_irqrestore(&priv->lock, flags); scan->suspend_time = 0; - scan->max_out_time = cpu_to_le32(200 * 1024); + scan->max_out_time = cpu_to_le32(600 * 1024); if (!interval) interval = suspend_time; /* @@ -6606,7 +6605,7 @@ static void iwl_bg_request_scan(struct work_struct *data) memcpy(scan->direct_scan[0].ssid, priv->direct_ssid, priv->direct_ssid_len); direct_mask = 1; - } else if (!iwl_is_associated(priv) && priv->essid_len) { + } else if (!iwl_is_associated(priv)) { scan->direct_scan[0].id = WLAN_EID_SSID; scan->direct_scan[0].len = priv->essid_len; memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len); @@ -6745,12 +6744,6 @@ static void iwl_bg_post_associate(struct work_struct *data) mutex_lock(&priv->mutex); - if (!priv->interface_id || !priv->is_open) { - mutex_unlock(&priv->mutex); - return; - } - iwl_scan_cancel_timeout(priv, 200); - conf = ieee80211_get_hw_conf(priv->hw); priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; @@ -6889,19 +6882,9 @@ static void iwl_mac_stop(struct ieee80211_hw *hw) struct iwl_priv *priv = hw->priv; IWL_DEBUG_MAC80211("enter\n"); - - - mutex_lock(&priv->mutex); - /* stop mac, cancel any scan request and clear - * RXON_FILTER_ASSOC_MSK BIT - */ priv->is_open = 0; - iwl_scan_cancel_timeout(priv, 100); - cancel_delayed_work(&priv->post_associate); - priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - iwl_commit_rxon(priv); - mutex_unlock(&priv->mutex); - + /*netif_stop_queue(dev); */ + flush_workqueue(priv->workqueue); IWL_DEBUG_MAC80211("leave\n"); } @@ -7186,6 +7169,8 @@ static int iwl_mac_config_interface(struct ieee80211_hw *hw, int if_id, if (priv->iw_mode == IEEE80211_IF_TYPE_AP) iwl_config_ap(priv); else { + priv->staging_rxon.filter_flags |= + RXON_FILTER_ASSOC_MSK; rc = iwl_commit_rxon(priv); if ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && rc) iwl_add_station(priv, @@ -7193,7 +7178,6 @@ static int iwl_mac_config_interface(struct ieee80211_hw *hw, int if_id, } } else { - iwl_scan_cancel_timeout(priv, 100); priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; iwl_commit_rxon(priv); } @@ -7233,12 +7217,6 @@ static void iwl_mac_remove_interface(struct ieee80211_hw *hw, IWL_DEBUG_MAC80211("enter\n"); mutex_lock(&priv->mutex); - - iwl_scan_cancel_timeout(priv, 100); - cancel_delayed_work(&priv->post_associate); - priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - iwl_commit_rxon(priv); - if (priv->interface_id == conf->if_id) { priv->interface_id = 0; memset(priv->bssid, 0, ETH_ALEN); @@ -7260,7 +7238,6 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) IWL_DEBUG_MAC80211("enter\n"); - mutex_lock(&priv->mutex); spin_lock_irqsave(&priv->lock, flags); if (!iwl_is_ready_rf(priv)) { @@ -7291,8 +7268,7 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) priv->direct_ssid_len = (u8) min((u8) len, (u8) IW_ESSID_MAX_SIZE); memcpy(priv->direct_ssid, ssid, priv->direct_ssid_len); - } else - priv->one_direct_scan = 0; + } rc = iwl_scan_initiate(priv); @@ -7300,7 +7276,6 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) out_unlock: spin_unlock_irqrestore(&priv->lock, flags); - mutex_unlock(&priv->mutex); return rc; } @@ -7335,8 +7310,6 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, mutex_lock(&priv->mutex); - iwl_scan_cancel_timeout(priv, 100); - switch (cmd) { case SET_KEY: rc = iwl_update_sta_key_info(priv, key, sta_id); @@ -7506,18 +7479,8 @@ static void iwl_mac_reset_tsf(struct ieee80211_hw *hw) spin_unlock_irqrestore(&priv->lock, flags); - /* we are restarting association process - * clear RXON_FILTER_ASSOC_MSK bit - */ - if (priv->iw_mode != IEEE80211_IF_TYPE_AP) { - iwl_scan_cancel_timeout(priv, 100); - priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - iwl_commit_rxon(priv); - } - /* Per mac80211.h: This is only used in IBSS mode... */ if (priv->iw_mode != IEEE80211_IF_TYPE_IBSS) { - IWL_DEBUG_MAC80211("leave - not in IBSS\n"); mutex_unlock(&priv->mutex); return; @@ -8595,9 +8558,6 @@ static void iwl_pci_remove(struct pci_dev *pdev) iwl_rate_control_unregister(priv->hw); } - /*netif_stop_queue(dev); */ - flush_workqueue(priv->workqueue); - /* ieee80211_unregister_hw calls iwl_mac_stop, which flushes * priv->workqueue... so we can't take down the workqueue * until now... */ diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl4965-base.c b/trunk/drivers/net/wireless/iwlwifi/iwl4965-base.c index d60adcb9bd4a..5e1279263b22 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl4965-base.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl4965-base.c @@ -6845,9 +6845,8 @@ static void iwl_bg_scan_check(struct work_struct *data) IWL_DEBUG(IWL_DL_INFO | IWL_DL_SCAN, "Scan completion watchdog resetting adapter (%dms)\n", jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG)); - if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) - iwl_send_scan_abort(priv); + queue_work(priv->workqueue, &priv->restart); } mutex_unlock(&priv->mutex); } @@ -6943,7 +6942,7 @@ static void iwl_bg_request_scan(struct work_struct *data) spin_unlock_irqrestore(&priv->lock, flags); scan->suspend_time = 0; - scan->max_out_time = cpu_to_le32(200 * 1024); + scan->max_out_time = cpu_to_le32(600 * 1024); if (!interval) interval = suspend_time; @@ -6966,7 +6965,7 @@ static void iwl_bg_request_scan(struct work_struct *data) memcpy(scan->direct_scan[0].ssid, priv->direct_ssid, priv->direct_ssid_len); direct_mask = 1; - } else if (!iwl_is_associated(priv) && priv->essid_len) { + } else if (!iwl_is_associated(priv)) { scan->direct_scan[0].id = WLAN_EID_SSID; scan->direct_scan[0].len = priv->essid_len; memcpy(scan->direct_scan[0].ssid, priv->essid, priv->essid_len); @@ -7119,12 +7118,6 @@ static void iwl_bg_post_associate(struct work_struct *data) mutex_lock(&priv->mutex); - if (!priv->interface_id || !priv->is_open) { - mutex_unlock(&priv->mutex); - return; - } - iwl_scan_cancel_timeout(priv, 200); - conf = ieee80211_get_hw_conf(priv->hw); priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; @@ -7278,19 +7271,9 @@ static void iwl_mac_stop(struct ieee80211_hw *hw) struct iwl_priv *priv = hw->priv; IWL_DEBUG_MAC80211("enter\n"); - - - mutex_lock(&priv->mutex); - /* stop mac, cancel any scan request and clear - * RXON_FILTER_ASSOC_MSK BIT - */ priv->is_open = 0; - iwl_scan_cancel_timeout(priv, 100); - cancel_delayed_work(&priv->post_associate); - priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - iwl_commit_rxon(priv); - mutex_unlock(&priv->mutex); - + /*netif_stop_queue(dev); */ + flush_workqueue(priv->workqueue); IWL_DEBUG_MAC80211("leave\n"); } @@ -7590,6 +7573,8 @@ static int iwl_mac_config_interface(struct ieee80211_hw *hw, int if_id, if (priv->iw_mode == IEEE80211_IF_TYPE_AP) iwl_config_ap(priv); else { + priv->staging_rxon.filter_flags |= + RXON_FILTER_ASSOC_MSK; rc = iwl_commit_rxon(priv); if ((priv->iw_mode == IEEE80211_IF_TYPE_STA) && rc) iwl_rxon_add_station( @@ -7597,7 +7582,6 @@ static int iwl_mac_config_interface(struct ieee80211_hw *hw, int if_id, } } else { - iwl_scan_cancel_timeout(priv, 100); priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; iwl_commit_rxon(priv); } @@ -7637,12 +7621,6 @@ static void iwl_mac_remove_interface(struct ieee80211_hw *hw, IWL_DEBUG_MAC80211("enter\n"); mutex_lock(&priv->mutex); - - iwl_scan_cancel_timeout(priv, 100); - cancel_delayed_work(&priv->post_associate); - priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - iwl_commit_rxon(priv); - if (priv->interface_id == conf->if_id) { priv->interface_id = 0; memset(priv->bssid, 0, ETH_ALEN); @@ -7664,7 +7642,6 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) IWL_DEBUG_MAC80211("enter\n"); - mutex_lock(&priv->mutex); spin_lock_irqsave(&priv->lock, flags); if (!iwl_is_ready_rf(priv)) { @@ -7695,8 +7672,7 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) priv->direct_ssid_len = (u8) min((u8) len, (u8) IW_ESSID_MAX_SIZE); memcpy(priv->direct_ssid, ssid, priv->direct_ssid_len); - } else - priv->one_direct_scan = 0; + } rc = iwl_scan_initiate(priv); @@ -7704,7 +7680,6 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) out_unlock: spin_unlock_irqrestore(&priv->lock, flags); - mutex_unlock(&priv->mutex); return rc; } @@ -7738,8 +7713,6 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, mutex_lock(&priv->mutex); - iwl_scan_cancel_timeout(priv, 100); - switch (cmd) { case SET_KEY: rc = iwl_update_sta_key_info(priv, key, sta_id); @@ -7930,18 +7903,8 @@ static void iwl_mac_reset_tsf(struct ieee80211_hw *hw) spin_unlock_irqrestore(&priv->lock, flags); - /* we are restarting association process - * clear RXON_FILTER_ASSOC_MSK bit - */ - if (priv->iw_mode != IEEE80211_IF_TYPE_AP) { - iwl_scan_cancel_timeout(priv, 100); - priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - iwl_commit_rxon(priv); - } - /* Per mac80211.h: This is only used in IBSS mode... */ if (priv->iw_mode != IEEE80211_IF_TYPE_IBSS) { - IWL_DEBUG_MAC80211("leave - not in IBSS\n"); mutex_unlock(&priv->mutex); return; @@ -9189,9 +9152,6 @@ static void iwl_pci_remove(struct pci_dev *pdev) iwl_rate_control_unregister(priv->hw); } - /*netif_stop_queue(dev); */ - flush_workqueue(priv->workqueue); - /* ieee80211_unregister_hw calls iwl_mac_stop, which flushes * priv->workqueue... so we can't take down the workqueue * until now... */ diff --git a/trunk/drivers/net/wireless/rt2x00/rt2x00lib.h b/trunk/drivers/net/wireless/rt2x00/rt2x00lib.h index 06d9bc0015c0..298faa9d3f61 100644 --- a/trunk/drivers/net/wireless/rt2x00/rt2x00lib.h +++ b/trunk/drivers/net/wireless/rt2x00/rt2x00lib.h @@ -30,7 +30,7 @@ * Interval defines * Both the link tuner as the rfkill will be called once per second. */ -#define LINK_TUNE_INTERVAL ( round_jiffies_relative(HZ) ) +#define LINK_TUNE_INTERVAL ( round_jiffies(HZ) ) #define RFKILL_POLL_INTERVAL ( 1000 ) /* diff --git a/trunk/drivers/net/wireless/rtl8187_dev.c b/trunk/drivers/net/wireless/rtl8187_dev.c index e454ae83e97a..de61c8fe6492 100644 --- a/trunk/drivers/net/wireless/rtl8187_dev.c +++ b/trunk/drivers/net/wireless/rtl8187_dev.c @@ -433,9 +433,6 @@ static int rtl8187_start(struct ieee80211_hw *dev) rtl818x_iowrite16(priv, &priv->map->INT_MASK, 0xFFFF); - rtl818x_iowrite32(priv, &priv->map->MAR[0], ~0); - rtl818x_iowrite32(priv, &priv->map->MAR[1], ~0); - rtl8187_init_urbs(dev); reg = RTL818X_RX_CONF_ONLYERLPKT | @@ -585,31 +582,32 @@ static int rtl8187_config_interface(struct ieee80211_hw *dev, int if_id, static void rtl8187_configure_filter(struct ieee80211_hw *dev, unsigned int changed_flags, unsigned int *total_flags, - int mc_count, struct dev_addr_list *mclist) + int mc_count, struct dev_addr_list *mc_list) { struct rtl8187_priv *priv = dev->priv; + *total_flags = 0; + + if (changed_flags & FIF_ALLMULTI) + priv->rx_conf ^= RTL818X_RX_CONF_MULTICAST; if (changed_flags & FIF_FCSFAIL) priv->rx_conf ^= RTL818X_RX_CONF_FCS; if (changed_flags & FIF_CONTROL) priv->rx_conf ^= RTL818X_RX_CONF_CTRL; if (changed_flags & FIF_OTHER_BSS) priv->rx_conf ^= RTL818X_RX_CONF_MONITOR; - if (*total_flags & FIF_ALLMULTI || mc_count > 0) - priv->rx_conf |= RTL818X_RX_CONF_MULTICAST; - else - priv->rx_conf &= ~RTL818X_RX_CONF_MULTICAST; - *total_flags = 0; + if (mc_count > 0) + priv->rx_conf |= RTL818X_RX_CONF_MULTICAST; + if (priv->rx_conf & RTL818X_RX_CONF_MULTICAST) + *total_flags |= FIF_ALLMULTI; if (priv->rx_conf & RTL818X_RX_CONF_FCS) *total_flags |= FIF_FCSFAIL; if (priv->rx_conf & RTL818X_RX_CONF_CTRL) *total_flags |= FIF_CONTROL; if (priv->rx_conf & RTL818X_RX_CONF_MONITOR) *total_flags |= FIF_OTHER_BSS; - if (priv->rx_conf & RTL818X_RX_CONF_MULTICAST) - *total_flags |= FIF_ALLMULTI; rtl818x_iowrite32_async(priv, &priv->map->RX_CONF, priv->rx_conf); } diff --git a/trunk/drivers/parport/daisy.c b/trunk/drivers/parport/daisy.c index 3c8f06c3a5a0..5bbff2028f8f 100644 --- a/trunk/drivers/parport/daisy.c +++ b/trunk/drivers/parport/daisy.c @@ -199,6 +199,11 @@ void parport_daisy_fini(struct parport *port) * parport_open - find a device by canonical device number * @devnum: canonical device number * @name: name to associate with the device + * @pf: preemption callback + * @kf: kick callback + * @irqf: interrupt handler + * @flags: registration flags + * @handle: driver data * * This function is similar to parport_register_device(), except * that it locates a device by its number rather than by the port @@ -209,7 +214,10 @@ void parport_daisy_fini(struct parport *port) * for parport_register_device(). **/ -struct pardevice *parport_open(int devnum, const char *name) +struct pardevice *parport_open(int devnum, const char *name, + int (*pf) (void *), void (*kf) (void *), + void (*irqf) (int, void *), + int flags, void *handle) { struct daisydev *p = topology; struct parport *port; @@ -229,7 +237,8 @@ struct pardevice *parport_open(int devnum, const char *name) port = parport_get_port(p->port); spin_unlock(&topology_lock); - dev = parport_register_device(port, name, NULL, NULL, NULL, 0, NULL); + dev = parport_register_device(port, name, pf, kf, + irqf, flags, handle); parport_put_port(port); if (!dev) return NULL; diff --git a/trunk/drivers/parport/ieee1284.c b/trunk/drivers/parport/ieee1284.c index 54a6ef72906e..5accaa7bde31 100644 --- a/trunk/drivers/parport/ieee1284.c +++ b/trunk/drivers/parport/ieee1284.c @@ -571,7 +571,7 @@ static int parport_ieee1284_ack_data_avail (struct parport *port) #endif /* IEEE1284 support */ /* Handle an interrupt. */ -void parport_ieee1284_interrupt (void *handle) +void parport_ieee1284_interrupt (int which, void *handle) { struct parport *port = handle; parport_ieee1284_wakeup (port); diff --git a/trunk/drivers/parport/parport_amiga.c b/trunk/drivers/parport/parport_amiga.c index 1586e1caa2f5..a0afaee5ebe5 100644 --- a/trunk/drivers/parport/parport_amiga.c +++ b/trunk/drivers/parport/parport_amiga.c @@ -137,6 +137,13 @@ static unsigned char amiga_read_status(struct parport *p) return status; } +/* as this ports irq handling is already done, we use a generic funktion */ +static irqreturn_t amiga_interrupt(int irq, void *dev_id) +{ + parport_generic_irq(irq, (struct parport *) dev_id); + return IRQ_HANDLED; +} + static void amiga_enable_irq(struct parport *p) { enable_irq(IRQ_AMIGA_CIAA_FLG); @@ -248,7 +255,7 @@ static int __init parport_amiga_init(void) if (!p) goto out_port; - err = request_irq(IRQ_AMIGA_CIAA_FLG, parport_irq_handler, 0, p->name, p); + err = request_irq(IRQ_AMIGA_CIAA_FLG, amiga_interrupt, 0, p->name, p); if (err) goto out_irq; diff --git a/trunk/drivers/parport/parport_atari.c b/trunk/drivers/parport/parport_atari.c index ad4cdd256137..6ea9929b8c7f 100644 --- a/trunk/drivers/parport/parport_atari.c +++ b/trunk/drivers/parport/parport_atari.c @@ -103,6 +103,13 @@ parport_atari_restore_state(struct parport *p, struct parport_state *s) { } +static irqreturn_t +parport_atari_interrupt(int irq, void *dev_id) +{ + parport_generic_irq(irq, (struct parport *) dev_id); + return IRQ_HANDLED; +} + static void parport_atari_enable_irq(struct parport *p) { @@ -201,7 +208,7 @@ static int __init parport_atari_init(void) &parport_atari_ops); if (!p) return -ENODEV; - if (request_irq(IRQ_MFP_BUSY, parport_irq_handler, + if (request_irq(IRQ_MFP_BUSY, parport_atari_interrupt, IRQ_TYPE_SLOW, p->name, p)) { parport_put_port (p); return -ENODEV; diff --git a/trunk/drivers/parport/parport_ax88796.c b/trunk/drivers/parport/parport_ax88796.c index 4ec220b2eae7..74f4e9742c6c 100644 --- a/trunk/drivers/parport/parport_ax88796.c +++ b/trunk/drivers/parport/parport_ax88796.c @@ -232,6 +232,14 @@ parport_ax88796_restore_state(struct parport *p, struct parport_state *s) writeb(s->u.ax88796.cpr, dd->spp_cpr); } +static irqreturn_t +parport_ax88796_interrupt(int irq, void *dev_id) +{ + parport_generic_irq(irq, dev_id); + return IRQ_HANDLED; +} + + static struct parport_operations parport_ax88796_ops = { .write_data = parport_ax88796_write_data, .read_data = parport_ax88796_read_data, @@ -336,7 +344,7 @@ static int parport_ax88796_probe(struct platform_device *pdev) if (irq >= 0) { /* request irq */ - ret = request_irq(irq, parport_irq_handler, + ret = request_irq(irq, parport_ax88796_interrupt, IRQF_TRIGGER_FALLING, pdev->name, pp); if (ret < 0) diff --git a/trunk/drivers/parport/parport_gsc.c b/trunk/drivers/parport/parport_gsc.c index 0e77ae2b71a0..43652ba523eb 100644 --- a/trunk/drivers/parport/parport_gsc.c +++ b/trunk/drivers/parport/parport_gsc.c @@ -80,6 +80,12 @@ static int clear_epp_timeout(struct parport *pb) * of these are in parport_gsc.h. */ +static irqreturn_t parport_gsc_interrupt(int irq, void *dev_id) +{ + parport_generic_irq(irq, (struct parport *) dev_id); + return IRQ_HANDLED; +} + void parport_gsc_init_state(struct pardevice *dev, struct parport_state *s) { s->u.pc.ctr = 0xc | (dev->irq_func ? 0x10 : 0x0); @@ -318,7 +324,7 @@ struct parport *__devinit parport_gsc_probe_port (unsigned long base, printk("]\n"); if (p->irq != PARPORT_IRQ_NONE) { - if (request_irq (p->irq, parport_irq_handler, + if (request_irq (p->irq, parport_gsc_interrupt, 0, p->name, p)) { printk (KERN_WARNING "%s: irq %d in use, " "resorting to polled operation\n", diff --git a/trunk/drivers/parport/parport_ip32.c b/trunk/drivers/parport/parport_ip32.c index 6d58bf895b1a..ec44efdbb84e 100644 --- a/trunk/drivers/parport/parport_ip32.c +++ b/trunk/drivers/parport/parport_ip32.c @@ -778,16 +778,14 @@ static irqreturn_t parport_ip32_interrupt(int irq, void *dev_id) struct parport * const p = dev_id; struct parport_ip32_private * const priv = p->physport->private_data; enum parport_ip32_irq_mode irq_mode = priv->irq_mode; - switch (irq_mode) { case PARPORT_IP32_IRQ_FWD: - return parport_irq_handler(irq, dev_id); - + parport_generic_irq(irq, p); + break; case PARPORT_IP32_IRQ_HERE: parport_ip32_wakeup(p); break; } - return IRQ_HANDLED; } diff --git a/trunk/drivers/parport/parport_mfc3.c b/trunk/drivers/parport/parport_mfc3.c index 6dec9ba5ed28..77726fc49766 100644 --- a/trunk/drivers/parport/parport_mfc3.c +++ b/trunk/drivers/parport/parport_mfc3.c @@ -219,7 +219,7 @@ static irqreturn_t mfc3_interrupt(int irq, void *dev_id) if (this_port[i] != NULL) if (pia(this_port[i])->crb & 128) { /* Board caused interrupt */ dummy = pia(this_port[i])->pprb; /* clear irq bit */ - parport_generic_irq(this_port[i]); + parport_generic_irq(irq, this_port[i]); } return IRQ_HANDLED; } diff --git a/trunk/drivers/parport/parport_pc.c b/trunk/drivers/parport/parport_pc.c index e9743d3efaf6..e2be84001105 100644 --- a/trunk/drivers/parport/parport_pc.c +++ b/trunk/drivers/parport/parport_pc.c @@ -272,6 +272,13 @@ static int clear_epp_timeout(struct parport *pb) * of these are in parport_pc.h. */ +static irqreturn_t parport_pc_interrupt(int irq, void *dev_id) +{ + parport_generic_irq(irq, (struct parport *) dev_id); + /* FIXME! Was it really ours? */ + return IRQ_HANDLED; +} + static void parport_pc_init_state(struct pardevice *dev, struct parport_state *s) { s->u.pc.ctr = 0xc; @@ -2294,7 +2301,7 @@ struct parport *parport_pc_probe_port (unsigned long int base, EPP_res = NULL; } if (p->irq != PARPORT_IRQ_NONE) { - if (request_irq (p->irq, parport_irq_handler, + if (request_irq (p->irq, parport_pc_interrupt, 0, p->name, p)) { printk (KERN_WARNING "%s: irq %d in use, " "resorting to polled operation\n", diff --git a/trunk/drivers/parport/parport_sunbpp.c b/trunk/drivers/parport/parport_sunbpp.c index 9d595aa91e46..d27019c2f860 100644 --- a/trunk/drivers/parport/parport_sunbpp.c +++ b/trunk/drivers/parport/parport_sunbpp.c @@ -46,6 +46,12 @@ #define dprintk(x) #endif +static irqreturn_t parport_sunbpp_interrupt(int irq, void *dev_id) +{ + parport_generic_irq(irq, (struct parport *) dev_id); + return IRQ_HANDLED; +} + static void parport_sunbpp_disable_irq(struct parport *p) { struct bpp_regs __iomem *regs = (struct bpp_regs __iomem *)p->base; @@ -318,7 +324,7 @@ static int __devinit init_one_port(struct sbus_dev *sdev) p->size = size; p->dev = &sdev->ofdev.dev; - if ((err = request_irq(p->irq, parport_irq_handler, + if ((err = request_irq(p->irq, parport_sunbpp_interrupt, IRQF_SHARED, p->name, p)) != 0) { goto out_put_port; } diff --git a/trunk/drivers/parport/probe.c b/trunk/drivers/parport/probe.c index 853a15f44f88..ea83b70e0de2 100644 --- a/trunk/drivers/parport/probe.c +++ b/trunk/drivers/parport/probe.c @@ -255,7 +255,8 @@ static ssize_t parport_read_device_id (struct parport *port, char *buffer, ssize_t parport_device_id (int devnum, char *buffer, size_t count) { ssize_t retval = -ENXIO; - struct pardevice *dev = parport_open (devnum, "Device ID probe"); + struct pardevice *dev = parport_open (devnum, "Device ID probe", + NULL, NULL, NULL, 0, NULL); if (!dev) return -ENXIO; diff --git a/trunk/drivers/parport/share.c b/trunk/drivers/parport/share.c index a8a62bbbb576..cd66442acfee 100644 --- a/trunk/drivers/parport/share.c +++ b/trunk/drivers/parport/share.c @@ -524,7 +524,7 @@ void parport_remove_port(struct parport *port) struct pardevice * parport_register_device(struct parport *port, const char *name, int (*pf)(void *), void (*kf)(void *), - void (*irq_func)(void *), + void (*irq_func)(int, void *), int flags, void *handle) { struct pardevice *tmp; @@ -995,15 +995,6 @@ void parport_release(struct pardevice *dev) } } -irqreturn_t parport_irq_handler(int irq, void *dev_id) -{ - struct parport *port = dev_id; - - parport_generic_irq(port); - - return IRQ_HANDLED; -} - /* Exported symbols for modules. */ EXPORT_SYMBOL(parport_claim); @@ -1020,6 +1011,5 @@ EXPORT_SYMBOL(parport_get_port); EXPORT_SYMBOL(parport_put_port); EXPORT_SYMBOL(parport_find_number); EXPORT_SYMBOL(parport_find_base); -EXPORT_SYMBOL(parport_irq_handler); MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/pci/intel-iommu.c b/trunk/drivers/pci/intel-iommu.c index e079a5237c94..0c4ab3b07274 100644 --- a/trunk/drivers/pci/intel-iommu.c +++ b/trunk/drivers/pci/intel-iommu.c @@ -34,7 +34,7 @@ #include "intel-iommu.h" #include /* force_iommu in this header in x86-64*/ #include -#include +#include #include "pci.h" #define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY) @@ -745,12 +745,12 @@ static char *fault_reason_strings[] = "non-zero reserved fields in PTE", "Unknown" }; -#define MAX_FAULT_REASON_IDX ARRAY_SIZE(fault_reason_strings) - 1 +#define MAX_FAULT_REASON_IDX ARRAY_SIZE(fault_reason_strings) char *dmar_get_fault_reason(u8 fault_reason) { - if (fault_reason >= MAX_FAULT_REASON_IDX) - return fault_reason_strings[MAX_FAULT_REASON_IDX - 1]; + if (fault_reason > MAX_FAULT_REASON_IDX) + return fault_reason_strings[MAX_FAULT_REASON_IDX]; else return fault_reason_strings[fault_reason]; } @@ -995,6 +995,7 @@ static struct intel_iommu *alloc_iommu(struct dmar_drhd_unit *drhd) return iommu; error_unmap: iounmap(iommu->reg); + iommu->reg = 0; error: kfree(iommu); return NULL; @@ -1807,7 +1808,7 @@ get_valid_domain_for_dev(struct pci_dev *pdev) if (!domain) { printk(KERN_ERR "Allocating domain for %s failed", pci_name(pdev)); - return NULL; + return 0; } /* make sure context mapping is ok */ @@ -1817,7 +1818,7 @@ get_valid_domain_for_dev(struct pci_dev *pdev) printk(KERN_ERR "Domain context map for %s failed", pci_name(pdev)); - return NULL; + return 0; } } diff --git a/trunk/drivers/pci/intel-iommu.h b/trunk/drivers/pci/intel-iommu.h index 459ad1f9dc54..ee88dd2400cb 100644 --- a/trunk/drivers/pci/intel-iommu.h +++ b/trunk/drivers/pci/intel-iommu.h @@ -58,7 +58,7 @@ hi = readl(dmar + reg + 4); \ (((u64) hi) << 32) + lo; }) */ -static inline u64 dmar_readq(void __iomem *addr) +static inline u64 dmar_readq(void *addr) { u32 lo, hi; lo = readl(addr); diff --git a/trunk/drivers/pci/quirks.c b/trunk/drivers/pci/quirks.c index d0bb5b9d2120..59d4da2734c1 100644 --- a/trunk/drivers/pci/quirks.c +++ b/trunk/drivers/pci/quirks.c @@ -1230,7 +1230,7 @@ static void quirk_jmicron_ata(struct pci_dev *pdev) case PCI_DEVICE_ID_JMICRON_JMB363: /* Enable dual function mode, AHCI on fn 0, IDE fn1 */ /* Set the class codes correctly and then direct IDE 0 */ - conf1 |= 0x00C2A1B3; /* Set 0, 1, 4, 5, 7, 8, 13, 15, 17, 22, 23 */ + conf1 |= 0x00C2A102; /* Set 1, 8, 13, 15, 17, 22, 23 */ break; case PCI_DEVICE_ID_JMICRON_JMB368: diff --git a/trunk/drivers/rtc/rtc-s3c.c b/trunk/drivers/rtc/rtc-s3c.c index e2041b4d0c85..8c1012b432bb 100644 --- a/trunk/drivers/rtc/rtc-s3c.c +++ b/trunk/drivers/rtc/rtc-s3c.c @@ -542,6 +542,8 @@ static int s3c_rtc_probe(struct platform_device *pdev) /* RTC Power management control */ +static struct timespec s3c_rtc_delta; + static int ticnt_save; static int s3c_rtc_suspend(struct platform_device *pdev, pm_message_t state) diff --git a/trunk/drivers/s390/scsi/zfcp_aux.c b/trunk/drivers/s390/scsi/zfcp_aux.c index 00118499018b..fd5d0c1570df 100644 --- a/trunk/drivers/s390/scsi/zfcp_aux.c +++ b/trunk/drivers/s390/scsi/zfcp_aux.c @@ -562,6 +562,8 @@ zfcp_sg_list_alloc(struct zfcp_sg_list *sg_list, size_t size) sg_init_table(sg_list->sg, sg_list->count); for (i = 0, sg = sg_list->sg; i < sg_list->count; i++, sg++) { + sg->length = min(size, PAGE_SIZE); + sg->offset = 0; address = (void *) get_zeroed_page(GFP_KERNEL); if (address == NULL) { sg_list->count = i; @@ -569,7 +571,7 @@ zfcp_sg_list_alloc(struct zfcp_sg_list *sg_list, size_t size) retval = -ENOMEM; goto out; } - zfcp_address_to_sg(address, sg, min(size, PAGE_SIZE)); + zfcp_address_to_sg(address, sg); size -= sg->length; } @@ -1516,13 +1518,13 @@ zfcp_gid_pn_buffers_alloc(struct zfcp_gid_pn_data **gid_pn, mempool_t *pool) return -ENOMEM; memset(data, 0, sizeof(*data)); - sg_init_table(&data->req , 1); - sg_init_table(&data->resp , 1); data->ct.req = &data->req; data->ct.resp = &data->resp; data->ct.req_count = data->ct.resp_count = 1; - zfcp_address_to_sg(&data->ct_iu_req, &data->req, sizeof(struct ct_iu_gid_pn_req)); - zfcp_address_to_sg(&data->ct_iu_resp, &data->resp, sizeof(struct ct_iu_gid_pn_resp)); + zfcp_address_to_sg(&data->ct_iu_req, &data->req); + zfcp_address_to_sg(&data->ct_iu_resp, &data->resp); + data->req.length = sizeof(struct ct_iu_gid_pn_req); + data->resp.length = sizeof(struct ct_iu_gid_pn_resp); *gid_pn = data; return 0; diff --git a/trunk/drivers/s390/scsi/zfcp_def.h b/trunk/drivers/s390/scsi/zfcp_def.h index e268f79bdbd2..326e7ee232cb 100644 --- a/trunk/drivers/s390/scsi/zfcp_def.h +++ b/trunk/drivers/s390/scsi/zfcp_def.h @@ -70,12 +70,12 @@ zfcp_sg_to_address(struct scatterlist *list) * zfcp_address_to_sg - set up struct scatterlist from kernel address * @address: kernel address * @list: struct scatterlist - * @size: buffer size */ static inline void -zfcp_address_to_sg(void *address, struct scatterlist *list, unsigned int size) +zfcp_address_to_sg(void *address, struct scatterlist *list) { - sg_set_buf(list, address, size); + sg_set_page(list, virt_to_page(address)); + list->offset = ((unsigned long) address) & (PAGE_SIZE - 1); } #define REQUEST_LIST_SIZE 128 diff --git a/trunk/drivers/s390/scsi/zfcp_erp.c b/trunk/drivers/s390/scsi/zfcp_erp.c index 5552b755c08a..9438d0b28799 100644 --- a/trunk/drivers/s390/scsi/zfcp_erp.c +++ b/trunk/drivers/s390/scsi/zfcp_erp.c @@ -322,9 +322,9 @@ zfcp_erp_adisc(struct zfcp_port *port) if (address == NULL) goto nomem; - zfcp_address_to_sg(address, send_els->req, sizeof(struct zfcp_ls_adisc)); + zfcp_address_to_sg(address, send_els->req); address += PAGE_SIZE >> 1; - zfcp_address_to_sg(address, send_els->resp, sizeof(struct zfcp_ls_adisc_acc)); + zfcp_address_to_sg(address, send_els->resp); send_els->req_count = send_els->resp_count = 1; send_els->adapter = adapter; @@ -336,6 +336,9 @@ zfcp_erp_adisc(struct zfcp_port *port) adisc = zfcp_sg_to_address(send_els->req); send_els->ls_code = adisc->code = ZFCP_LS_ADISC; + send_els->req->length = sizeof(struct zfcp_ls_adisc); + send_els->resp->length = sizeof(struct zfcp_ls_adisc_acc); + /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports without FC-AL-2 capability, so we don't set it */ adisc->wwpn = fc_host_port_name(adapter->scsi_host); diff --git a/trunk/drivers/scsi/Kconfig b/trunk/drivers/scsi/Kconfig index 86cf10efb0c1..a5763c6e9362 100644 --- a/trunk/drivers/scsi/Kconfig +++ b/trunk/drivers/scsi/Kconfig @@ -172,12 +172,12 @@ config CHR_DEV_SCH don't need this for those tiny 6-slot cdrom changers. Media changers are listed as "Type: Medium Changer" in /proc/scsi/scsi. If you have such hardware and want to use it with linux, say Y - here. Check for details. + here. Check for details. If you want to compile this as a module ( = code which can be inserted in and removed from the running kernel whenever you want), say M here and read and - . The module will be called ch.o. + . The module will be called ch.o. If unsure, say N. diff --git a/trunk/drivers/scsi/Makefile b/trunk/drivers/scsi/Makefile index 2e6129f13d38..6141389dcdb2 100644 --- a/trunk/drivers/scsi/Makefile +++ b/trunk/drivers/scsi/Makefile @@ -115,6 +115,7 @@ obj-$(CONFIG_SCSI_QLOGICPTI) += qlogicpti.o obj-$(CONFIG_BLK_DEV_IDESCSI) += ide-scsi.o obj-$(CONFIG_SCSI_MESH) += mesh.o obj-$(CONFIG_SCSI_MAC53C94) += mac53c94.o +obj-$(CONFIG_SCSI_PLUTO) += pluto.o obj-$(CONFIG_SCSI_DECNCR) += NCR53C9x.o dec_esp.o obj-$(CONFIG_BLK_DEV_3W_XXXX_RAID) += 3w-xxxx.o obj-$(CONFIG_SCSI_3W_9XXX) += 3w-9xxx.o @@ -122,6 +123,7 @@ obj-$(CONFIG_SCSI_PPA) += ppa.o obj-$(CONFIG_SCSI_IMM) += imm.o obj-$(CONFIG_JAZZ_ESP) += esp_scsi.o jazz_esp.o obj-$(CONFIG_SUN3X_ESP) += NCR53C9x.o sun3x_esp.o +obj-$(CONFIG_SCSI_FCAL) += fcal.o obj-$(CONFIG_SCSI_LASI700) += 53c700.o lasi700.o obj-$(CONFIG_SCSI_SNI_53C710) += 53c700.o sni_53c710.o obj-$(CONFIG_SCSI_NSP32) += nsp32.o diff --git a/trunk/drivers/scsi/aacraid/commctrl.c b/trunk/drivers/scsi/aacraid/commctrl.c index 1e6d7a9c75bf..72b0393b4596 100644 --- a/trunk/drivers/scsi/aacraid/commctrl.c +++ b/trunk/drivers/scsi/aacraid/commctrl.c @@ -391,7 +391,7 @@ static int close_getadapter_fib(struct aac_dev * dev, void __user *arg) /* * Extract the fibctx from the input parameters */ - if (fibctx->unique == (u32)(uintptr_t)arg) /* We found a winner */ + if (fibctx->unique == (u32)(ptrdiff_t)arg) /* We found a winner */ break; entry = entry->next; fibctx = NULL; @@ -590,7 +590,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) } addr = (u64)upsg->sg[i].addr[0]; addr += ((u64)upsg->sg[i].addr[1]) << 32; - sg_user[i] = (void __user *)(uintptr_t)addr; + sg_user[i] = (void __user *)(ptrdiff_t)addr; sg_list[i] = p; // save so we can clean up later sg_indx = i; @@ -633,7 +633,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) rcode = -ENOMEM; goto cleanup; } - sg_user[i] = (void __user *)(uintptr_t)usg->sg[i].addr; + sg_user[i] = (void __user *)(ptrdiff_t)usg->sg[i].addr; sg_list[i] = p; // save so we can clean up later sg_indx = i; @@ -664,7 +664,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) if (actual_fibsize64 == fibsize) { struct user_sgmap64* usg = (struct user_sgmap64 *)upsg; for (i = 0; i < upsg->count; i++) { - uintptr_t addr; + u64 addr; void* p; /* Does this really need to be GFP_DMA? */ p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA); @@ -676,7 +676,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) } addr = (u64)usg->sg[i].addr[0]; addr += ((u64)usg->sg[i].addr[1]) << 32; - sg_user[i] = (void __user *)addr; + sg_user[i] = (void __user *)(ptrdiff_t)addr; sg_list[i] = p; // save so we can clean up later sg_indx = i; @@ -704,7 +704,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) rcode = -ENOMEM; goto cleanup; } - sg_user[i] = (void __user *)(uintptr_t)upsg->sg[i].addr; + sg_user[i] = (void __user *)(ptrdiff_t)upsg->sg[i].addr; sg_list[i] = p; // save so we can clean up later sg_indx = i; diff --git a/trunk/drivers/scsi/aacraid/comminit.c b/trunk/drivers/scsi/aacraid/comminit.c index 8736813a0296..3009ad8c4073 100644 --- a/trunk/drivers/scsi/aacraid/comminit.c +++ b/trunk/drivers/scsi/aacraid/comminit.c @@ -110,7 +110,7 @@ static int aac_alloc_comm(struct aac_dev *dev, void **commaddr, unsigned long co /* * Align the beginning of Headers to commalign */ - align = (commalign - ((uintptr_t)(base) & (commalign - 1))); + align = (commalign - ((ptrdiff_t)(base) & (commalign - 1))); base = base + align; phys = phys + align; /* diff --git a/trunk/drivers/scsi/aacraid/dpcsup.c b/trunk/drivers/scsi/aacraid/dpcsup.c index e6032ffc66a6..fcd25f7d0bc6 100644 --- a/trunk/drivers/scsi/aacraid/dpcsup.c +++ b/trunk/drivers/scsi/aacraid/dpcsup.c @@ -254,7 +254,7 @@ unsigned int aac_intr_normal(struct aac_dev * dev, u32 Index) kfree (fib); return 1; } - memcpy(hw_fib, (struct hw_fib *)(((uintptr_t)(dev->regs.sa)) + + memcpy(hw_fib, (struct hw_fib *)(((ptrdiff_t)(dev->regs.sa)) + (index & ~0x00000002L)), sizeof(struct hw_fib)); INIT_LIST_HEAD(&fib->fiblink); fib->type = FSAFS_NTC_FIB_CONTEXT; diff --git a/trunk/drivers/scsi/aic7xxx/aic7770.c b/trunk/drivers/scsi/aic7xxx/aic7770.c index 6d86a9be538f..c4d17231c828 100644 --- a/trunk/drivers/scsi/aic7xxx/aic7770.c +++ b/trunk/drivers/scsi/aic7xxx/aic7770.c @@ -60,6 +60,8 @@ #define ID_OLV_274xD 0x04907783 /* Olivetti OEM (Differential) */ static int aic7770_chip_init(struct ahc_softc *ahc); +static int aic7770_suspend(struct ahc_softc *ahc); +static int aic7770_resume(struct ahc_softc *ahc); static int aha2840_load_seeprom(struct ahc_softc *ahc); static ahc_device_setup_t ahc_aic7770_VL_setup; static ahc_device_setup_t ahc_aic7770_EISA_setup; @@ -153,6 +155,8 @@ aic7770_config(struct ahc_softc *ahc, struct aic7770_identity *entry, u_int io) return (error); ahc->bus_chip_init = aic7770_chip_init; + ahc->bus_suspend = aic7770_suspend; + ahc->bus_resume = aic7770_resume; error = ahc_reset(ahc, /*reinit*/FALSE); if (error != 0) @@ -268,6 +272,18 @@ aic7770_chip_init(struct ahc_softc *ahc) return (ahc_chip_init(ahc)); } +static int +aic7770_suspend(struct ahc_softc *ahc) +{ + return (ahc_suspend(ahc)); +} + +static int +aic7770_resume(struct ahc_softc *ahc) +{ + return (ahc_resume(ahc)); +} + /* * Read the 284x SEEPROM. */ diff --git a/trunk/drivers/scsi/aic7xxx/aic79xx.h b/trunk/drivers/scsi/aic7xxx/aic79xx.h index ce638aa6005a..27adbb294ac1 100644 --- a/trunk/drivers/scsi/aic7xxx/aic79xx.h +++ b/trunk/drivers/scsi/aic7xxx/aic79xx.h @@ -1003,15 +1003,8 @@ struct ahd_suspend_channel_state { uint8_t seqctl; }; -struct ahd_suspend_pci_state { - uint32_t devconfig; - uint8_t command; - uint8_t csize_lattime; -}; - struct ahd_suspend_state { struct ahd_suspend_channel_state channel[2]; - struct ahd_suspend_pci_state pci_state; uint8_t optionmode; uint8_t dscommand0; uint8_t dspcistatus; @@ -1340,8 +1333,6 @@ struct ahd_pci_identity *ahd_find_pci_device(ahd_dev_softc_t); int ahd_pci_config(struct ahd_softc *, struct ahd_pci_identity *); int ahd_pci_test_register_access(struct ahd_softc *); -void ahd_pci_suspend(struct ahd_softc *); -void ahd_pci_resume(struct ahd_softc *); /************************** SCB and SCB queue management **********************/ void ahd_qinfifo_requeue_tail(struct ahd_softc *ahd, @@ -1352,8 +1343,6 @@ struct ahd_softc *ahd_alloc(void *platform_arg, char *name); int ahd_softc_init(struct ahd_softc *); void ahd_controller_info(struct ahd_softc *ahd, char *buf); int ahd_init(struct ahd_softc *ahd); -int ahd_suspend(struct ahd_softc *ahd); -void ahd_resume(struct ahd_softc *ahd); int ahd_default_config(struct ahd_softc *ahd); int ahd_parse_vpddata(struct ahd_softc *ahd, struct vpd_config *vpd); diff --git a/trunk/drivers/scsi/aic7xxx/aic79xx_core.c b/trunk/drivers/scsi/aic7xxx/aic79xx_core.c index a7dd8cdda472..05f692bd0adc 100644 --- a/trunk/drivers/scsi/aic7xxx/aic79xx_core.c +++ b/trunk/drivers/scsi/aic7xxx/aic79xx_core.c @@ -7175,6 +7175,7 @@ ahd_pause_and_flushwork(struct ahd_softc *ahd) ahd->flags &= ~AHD_ALL_INTERRUPTS; } +#if 0 int ahd_suspend(struct ahd_softc *ahd) { @@ -7188,15 +7189,19 @@ ahd_suspend(struct ahd_softc *ahd) ahd_shutdown(ahd); return (0); } +#endif /* 0 */ -void +#if 0 +int ahd_resume(struct ahd_softc *ahd) { ahd_reset(ahd, /*reinit*/TRUE); ahd_intr_enable(ahd, TRUE); ahd_restart(ahd); + return (0); } +#endif /* 0 */ /************************** Busy Target Table *********************************/ /* diff --git a/trunk/drivers/scsi/aic7xxx/aic79xx_osm.c b/trunk/drivers/scsi/aic7xxx/aic79xx_osm.c index 2d020405480c..42c0f14a262c 100644 --- a/trunk/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/trunk/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -315,8 +315,8 @@ uint32_t aic79xx_slowcrc; */ static char *aic79xx = NULL; -MODULE_AUTHOR("Maintainer: Hannes Reinecke "); -MODULE_DESCRIPTION("Adaptec AIC790X U320 SCSI Host Bus Adapter driver"); +MODULE_AUTHOR("Maintainer: Justin T. Gibbs "); +MODULE_DESCRIPTION("Adaptec Aic790X U320 SCSI Host Bus Adapter driver"); MODULE_LICENSE("Dual BSD/GPL"); MODULE_VERSION(AIC79XX_DRIVER_VERSION); module_param(aic79xx, charp, 0444); diff --git a/trunk/drivers/scsi/aic7xxx/aic79xx_osm_pci.c b/trunk/drivers/scsi/aic7xxx/aic79xx_osm_pci.c index 66f0259edb69..c62ce41f2793 100644 --- a/trunk/drivers/scsi/aic7xxx/aic79xx_osm_pci.c +++ b/trunk/drivers/scsi/aic7xxx/aic79xx_osm_pci.c @@ -50,8 +50,6 @@ static int ahd_linux_pci_reserve_io_regions(struct ahd_softc *ahd, static int ahd_linux_pci_reserve_mem_region(struct ahd_softc *ahd, u_long *bus_addr, uint8_t __iomem **maddr); -static int ahd_linux_pci_dev_suspend(struct pci_dev *pdev, pm_message_t mesg); -static int ahd_linux_pci_dev_resume(struct pci_dev *pdev); static void ahd_linux_pci_dev_remove(struct pci_dev *pdev); /* Define the macro locally since it's different for different class of chips. @@ -88,58 +86,10 @@ MODULE_DEVICE_TABLE(pci, ahd_linux_pci_id_table); static struct pci_driver aic79xx_pci_driver = { .name = "aic79xx", .probe = ahd_linux_pci_dev_probe, -#ifdef CONFIG_PM - .suspend = ahd_linux_pci_dev_suspend, - .resume = ahd_linux_pci_dev_resume, -#endif .remove = ahd_linux_pci_dev_remove, .id_table = ahd_linux_pci_id_table }; -static int -ahd_linux_pci_dev_suspend(struct pci_dev *pdev, pm_message_t mesg) -{ - struct ahd_softc *ahd = pci_get_drvdata(pdev); - int rc; - - if ((rc = ahd_suspend(ahd))) - return rc; - - ahd_pci_suspend(ahd); - - pci_save_state(pdev); - pci_disable_device(pdev); - - if (mesg.event == PM_EVENT_SUSPEND) - pci_set_power_state(pdev, PCI_D3hot); - - return rc; -} - -static int -ahd_linux_pci_dev_resume(struct pci_dev *pdev) -{ - struct ahd_softc *ahd = pci_get_drvdata(pdev); - int rc; - - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - - if ((rc = pci_enable_device(pdev))) { - dev_printk(KERN_ERR, &pdev->dev, - "failed to enable device after resume (%d)\n", rc); - return rc; - } - - pci_set_master(pdev); - - ahd_pci_resume(ahd); - - ahd_resume(ahd); - - return rc; -} - static void ahd_linux_pci_dev_remove(struct pci_dev *pdev) { diff --git a/trunk/drivers/scsi/aic7xxx/aic79xx_pci.c b/trunk/drivers/scsi/aic7xxx/aic79xx_pci.c index 7a203a90601a..0bada0028aa0 100644 --- a/trunk/drivers/scsi/aic7xxx/aic79xx_pci.c +++ b/trunk/drivers/scsi/aic7xxx/aic79xx_pci.c @@ -389,33 +389,6 @@ ahd_pci_config(struct ahd_softc *ahd, struct ahd_pci_identity *entry) return error; } -void -ahd_pci_suspend(struct ahd_softc *ahd) -{ - /* - * Save chip register configuration data for chip resets - * that occur during runtime and resume events. - */ - ahd->suspend_state.pci_state.devconfig = - ahd_pci_read_config(ahd->dev_softc, DEVCONFIG, /*bytes*/4); - ahd->suspend_state.pci_state.command = - ahd_pci_read_config(ahd->dev_softc, PCIR_COMMAND, /*bytes*/1); - ahd->suspend_state.pci_state.csize_lattime = - ahd_pci_read_config(ahd->dev_softc, CSIZE_LATTIME, /*bytes*/1); - -} - -void -ahd_pci_resume(struct ahd_softc *ahd) -{ - ahd_pci_write_config(ahd->dev_softc, DEVCONFIG, - ahd->suspend_state.pci_state.devconfig, /*bytes*/4); - ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND, - ahd->suspend_state.pci_state.command, /*bytes*/1); - ahd_pci_write_config(ahd->dev_softc, CSIZE_LATTIME, - ahd->suspend_state.pci_state.csize_lattime, /*bytes*/1); -} - /* * Perform some simple tests that should catch situations where * our registers are invalidly mapped. diff --git a/trunk/drivers/scsi/aic7xxx/aic7xxx.h b/trunk/drivers/scsi/aic7xxx/aic7xxx.h index 3d4e42d90452..e1bd57b9f23d 100644 --- a/trunk/drivers/scsi/aic7xxx/aic7xxx.h +++ b/trunk/drivers/scsi/aic7xxx/aic7xxx.h @@ -961,6 +961,16 @@ struct ahc_softc { */ ahc_bus_chip_init_t bus_chip_init; + /* + * Bus specific suspend routine. + */ + ahc_bus_suspend_t bus_suspend; + + /* + * Bus specific resume routine. + */ + ahc_bus_resume_t bus_resume; + /* * Target mode related state kept on a per enabled lun basis. * Targets that are not enabled will have null entries. @@ -1143,7 +1153,6 @@ struct ahc_pci_identity *ahc_find_pci_device(ahc_dev_softc_t); int ahc_pci_config(struct ahc_softc *, struct ahc_pci_identity *); int ahc_pci_test_register_access(struct ahc_softc *); -void ahc_pci_resume(struct ahc_softc *ahc); /*************************** EISA/VL Front End ********************************/ struct aic7770_identity *aic7770_find_device(uint32_t); diff --git a/trunk/drivers/scsi/aic7xxx/aic7xxx_osm.c b/trunk/drivers/scsi/aic7xxx/aic7xxx_osm.c index 390b0fc991c5..7770befbf50c 100644 --- a/trunk/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/trunk/drivers/scsi/aic7xxx/aic7xxx_osm.c @@ -335,8 +335,8 @@ static uint32_t aic7xxx_periodic_otag; */ static char *aic7xxx = NULL; -MODULE_AUTHOR("Maintainer: Hannes Reinecke "); -MODULE_DESCRIPTION("Adaptec AIC77XX/78XX SCSI Host Bus Adapter driver"); +MODULE_AUTHOR("Maintainer: Justin T. Gibbs "); +MODULE_DESCRIPTION("Adaptec Aic77XX/78XX SCSI Host Bus Adapter driver"); MODULE_LICENSE("Dual BSD/GPL"); MODULE_VERSION(AIC7XXX_DRIVER_VERSION); module_param(aic7xxx, charp, 0444); diff --git a/trunk/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/trunk/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c index 4488946cff2e..ea5687df732d 100644 --- a/trunk/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c +++ b/trunk/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c @@ -49,8 +49,6 @@ static int ahc_linux_pci_reserve_io_region(struct ahc_softc *ahc, static int ahc_linux_pci_reserve_mem_region(struct ahc_softc *ahc, u_long *bus_addr, uint8_t __iomem **maddr); -static int ahc_linux_pci_dev_suspend(struct pci_dev *pdev, pm_message_t mesg); -static int ahc_linux_pci_dev_resume(struct pci_dev *pdev); static void ahc_linux_pci_dev_remove(struct pci_dev *pdev); /* Define the macro locally since it's different for different class of chips. @@ -135,54 +133,10 @@ MODULE_DEVICE_TABLE(pci, ahc_linux_pci_id_table); static struct pci_driver aic7xxx_pci_driver = { .name = "aic7xxx", .probe = ahc_linux_pci_dev_probe, -#ifdef CONFIG_PM - .suspend = ahc_linux_pci_dev_suspend, - .resume = ahc_linux_pci_dev_resume, -#endif .remove = ahc_linux_pci_dev_remove, .id_table = ahc_linux_pci_id_table }; -static int -ahc_linux_pci_dev_suspend(struct pci_dev *pdev, pm_message_t mesg) -{ - struct ahc_softc *ahc = pci_get_drvdata(pdev); - int rc; - - if ((rc = ahc_suspend(ahc))) - return rc; - - pci_save_state(pdev); - pci_disable_device(pdev); - - if (mesg.event == PM_EVENT_SUSPEND) - pci_set_power_state(pdev, PCI_D3hot); - - return rc; -} - -static int -ahc_linux_pci_dev_resume(struct pci_dev *pdev) -{ - struct ahc_softc *ahc = pci_get_drvdata(pdev); - int rc; - - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - - if ((rc = pci_enable_device(pdev))) { - dev_printk(KERN_ERR, &pdev->dev, - "failed to enable device after resume (%d)\n", rc); - return rc; - } - - pci_set_master(pdev); - - ahc_pci_resume(ahc); - - return (ahc_resume(ahc)); -} - static void ahc_linux_pci_dev_remove(struct pci_dev *pdev) { diff --git a/trunk/drivers/scsi/aic7xxx/aic7xxx_pci.c b/trunk/drivers/scsi/aic7xxx/aic7xxx_pci.c index ae35937b8055..09c8172c9e5e 100644 --- a/trunk/drivers/scsi/aic7xxx/aic7xxx_pci.c +++ b/trunk/drivers/scsi/aic7xxx/aic7xxx_pci.c @@ -633,6 +633,8 @@ static void write_brdctl(struct ahc_softc *ahc, uint8_t value); static uint8_t read_brdctl(struct ahc_softc *ahc); static void ahc_pci_intr(struct ahc_softc *ahc); static int ahc_pci_chip_init(struct ahc_softc *ahc); +static int ahc_pci_suspend(struct ahc_softc *ahc); +static int ahc_pci_resume(struct ahc_softc *ahc); static int ahc_9005_subdevinfo_valid(uint16_t device, uint16_t vendor, @@ -789,6 +791,8 @@ ahc_pci_config(struct ahc_softc *ahc, struct ahc_pci_identity *entry) ahc->bus_intr = ahc_pci_intr; ahc->bus_chip_init = ahc_pci_chip_init; + ahc->bus_suspend = ahc_pci_suspend; + ahc->bus_resume = ahc_pci_resume; /* Remeber how the card was setup in case there is no SEEPROM */ if ((ahc_inb(ahc, HCNTRL) & POWRDN) == 0) { @@ -2020,9 +2024,18 @@ ahc_pci_chip_init(struct ahc_softc *ahc) return (ahc_chip_init(ahc)); } -void +static int +ahc_pci_suspend(struct ahc_softc *ahc) +{ + return (ahc_suspend(ahc)); +} + +static int ahc_pci_resume(struct ahc_softc *ahc) { + + pci_set_power_state(ahc->dev_softc, AHC_POWER_STATE_D0); + /* * We assume that the OS has restored our register * mappings, etc. Just update the config space registers @@ -2050,6 +2063,7 @@ ahc_pci_resume(struct ahc_softc *ahc) &sxfrctl1); ahc_release_seeprom(&sd); } + return (ahc_resume(ahc)); } static int diff --git a/trunk/drivers/scsi/aic7xxx/aicasm/aicasm_macro_scan.l b/trunk/drivers/scsi/aic7xxx/aicasm/aicasm_macro_scan.l index c0457b8c3b77..f06e7035cb35 100644 --- a/trunk/drivers/scsi/aic7xxx/aicasm/aicasm_macro_scan.l +++ b/trunk/drivers/scsi/aic7xxx/aicasm/aicasm_macro_scan.l @@ -66,7 +66,6 @@ static char string_buf[MAX_STR_CONST]; static char *string_buf_ptr; static int parren_count; static char buf[255]; -int mmlineno; %} WORD [A-Za-z_][-A-Za-z_0-9]* @@ -77,7 +76,7 @@ MCARG [^(), \t]+ %% \n { - ++mmlineno; + ++yylineno; } \r ; {SPACE} ; diff --git a/trunk/drivers/scsi/aic7xxx_old.c b/trunk/drivers/scsi/aic7xxx_old.c index 8f8db5f0aef7..4025608d6964 100644 --- a/trunk/drivers/scsi/aic7xxx_old.c +++ b/trunk/drivers/scsi/aic7xxx_old.c @@ -8417,7 +8417,7 @@ aic7xxx_alloc(struct scsi_host_template *sht, struct aic7xxx_host *temp) p->host = host; p->scb_data = kzalloc(sizeof(scb_data_type), GFP_ATOMIC); - if (p->scb_data) + if (!p->scb_data) { scbq_init (&p->scb_data->free_scbs); } diff --git a/trunk/drivers/scsi/arcmsr/arcmsr.h b/trunk/drivers/scsi/arcmsr/arcmsr.h index a67e29f83ae5..ace7a15b413e 100644 --- a/trunk/drivers/scsi/arcmsr/arcmsr.h +++ b/trunk/drivers/scsi/arcmsr/arcmsr.h @@ -141,14 +141,14 @@ struct CMD_MESSAGE_FIELD #define IS_SG64_ADDR 0x01000000 /* bit24 */ struct SG32ENTRY { - __le32 length; - __le32 address; + uint32_t length; + uint32_t address; }; struct SG64ENTRY { - __le32 length; - __le32 address; - __le32 addresshigh; + uint32_t length; + uint32_t address; + uint32_t addresshigh; }; struct SGENTRY_UNION { @@ -339,15 +339,23 @@ struct MessageUnit_B uint32_t done_qbuffer[ARCMSR_MAX_HBB_POSTQUEUE]; uint32_t postq_index; uint32_t doneq_index; - uint32_t __iomem *drv2iop_doorbell_reg; - uint32_t __iomem *drv2iop_doorbell_mask_reg; - uint32_t __iomem *iop2drv_doorbell_reg; - uint32_t __iomem *iop2drv_doorbell_mask_reg; - uint32_t __iomem *msgcode_rwbuffer_reg; - uint32_t __iomem *ioctl_wbuffer_reg; - uint32_t __iomem *ioctl_rbuffer_reg; + uint32_t *drv2iop_doorbell_reg; + uint32_t *drv2iop_doorbell_mask_reg; + uint32_t *iop2drv_doorbell_reg; + uint32_t *iop2drv_doorbell_mask_reg; + uint32_t *msgcode_rwbuffer_reg; + uint32_t *ioctl_wbuffer_reg; + uint32_t *ioctl_rbuffer_reg; }; +struct MessageUnit +{ + union + { + struct MessageUnit_A pmu_A; + struct MessageUnit_B pmu_B; + } u; +}; /* ******************************************************************************* ** Adapter Control Block @@ -366,10 +374,7 @@ struct AdapterControlBlock /* Offset is used in making arc cdb physical to virtual calculations */ uint32_t outbound_int_enable; - union { - struct MessageUnit_A __iomem * pmuA; - struct MessageUnit_B * pmuB; - }; + struct MessageUnit * pmu; /* message unit ATU inbound base address0 */ uint32_t acb_flags; @@ -553,7 +558,7 @@ struct SENSE_DATA extern void arcmsr_post_ioctldata2iop(struct AdapterControlBlock *); extern void arcmsr_iop_message_read(struct AdapterControlBlock *); -extern struct QBUFFER __iomem *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *); +extern struct QBUFFER *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *); extern struct class_device_attribute *arcmsr_host_attrs[]; extern int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *); void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb); diff --git a/trunk/drivers/scsi/arcmsr/arcmsr_attr.c b/trunk/drivers/scsi/arcmsr/arcmsr_attr.c index 7d7b0a554276..d04d1aa28fa4 100644 --- a/trunk/drivers/scsi/arcmsr/arcmsr_attr.c +++ b/trunk/drivers/scsi/arcmsr/arcmsr_attr.c @@ -85,13 +85,13 @@ static ssize_t arcmsr_sysfs_iop_message_read(struct kobject *kobj, allxfer_len++; } if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) { - struct QBUFFER __iomem *prbuffer; - uint8_t __iomem *iop_data; + struct QBUFFER *prbuffer; + uint8_t *iop_data; int32_t iop_len; acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW; prbuffer = arcmsr_get_iop_rqbuffer(acb); - iop_data = prbuffer->data; + iop_data = (uint8_t *)prbuffer->data; iop_len = readl(&prbuffer->data_len); while (iop_len > 0) { acb->rqbuffer[acb->rqbuf_lastindex] = readb(iop_data); diff --git a/trunk/drivers/scsi/arcmsr/arcmsr_hba.c b/trunk/drivers/scsi/arcmsr/arcmsr_hba.c index d466a2dac1db..f7a252885a5c 100644 --- a/trunk/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/trunk/drivers/scsi/arcmsr/arcmsr_hba.c @@ -236,22 +236,18 @@ static int arcmsr_alloc_ccb_pool(struct AdapterControlBlock *acb) uint32_t intmask_org; int i, j; - acb->pmuA = ioremap(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0)); - if (!acb->pmuA) { + acb->pmu = ioremap(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0)); + if (!acb->pmu) { printk(KERN_NOTICE "arcmsr%d: memory mapping region fail \n", acb->host->host_no); - return -ENOMEM; } dma_coherent = dma_alloc_coherent(&pdev->dev, ARCMSR_MAX_FREECCB_NUM * sizeof (struct CommandControlBlock) + 0x20, &dma_coherent_handle, GFP_KERNEL); - - if (!dma_coherent) { - iounmap(acb->pmuA); + if (!dma_coherent) return -ENOMEM; - } acb->dma_coherent = dma_coherent; acb->dma_coherent_handle = dma_coherent_handle; @@ -291,7 +287,7 @@ static int arcmsr_alloc_ccb_pool(struct AdapterControlBlock *acb) struct pci_dev *pdev = acb->pdev; struct MessageUnit_B *reg; - void __iomem *mem_base0, *mem_base1; + void *mem_base0, *mem_base1; void *dma_coherent; dma_addr_t dma_coherent_handle, dma_addr; uint32_t intmask_org; @@ -332,28 +328,25 @@ static int arcmsr_alloc_ccb_pool(struct AdapterControlBlock *acb) reg = (struct MessageUnit_B *)(dma_coherent + ARCMSR_MAX_FREECCB_NUM * sizeof(struct CommandControlBlock)); - acb->pmuB = reg; + acb->pmu = (struct MessageUnit *)reg; mem_base0 = ioremap(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0)); - if (!mem_base0) - goto out; - mem_base1 = ioremap(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2)); - if (!mem_base1) { - iounmap(mem_base0); - goto out; - } - - reg->drv2iop_doorbell_reg = mem_base0 + ARCMSR_DRV2IOP_DOORBELL; - reg->drv2iop_doorbell_mask_reg = mem_base0 + - ARCMSR_DRV2IOP_DOORBELL_MASK; - reg->iop2drv_doorbell_reg = mem_base0 + ARCMSR_IOP2DRV_DOORBELL; - reg->iop2drv_doorbell_mask_reg = mem_base0 + - ARCMSR_IOP2DRV_DOORBELL_MASK; - reg->ioctl_wbuffer_reg = mem_base1 + ARCMSR_IOCTL_WBUFFER; - reg->ioctl_rbuffer_reg = mem_base1 + ARCMSR_IOCTL_RBUFFER; - reg->msgcode_rwbuffer_reg = mem_base1 + ARCMSR_MSGCODE_RWBUFFER; + reg->drv2iop_doorbell_reg = (uint32_t *)((char *)mem_base0 + + ARCMSR_DRV2IOP_DOORBELL); + reg->drv2iop_doorbell_mask_reg = (uint32_t *)((char *)mem_base0 + + ARCMSR_DRV2IOP_DOORBELL_MASK); + reg->iop2drv_doorbell_reg = (uint32_t *)((char *)mem_base0 + + ARCMSR_IOP2DRV_DOORBELL); + reg->iop2drv_doorbell_mask_reg = (uint32_t *)((char *)mem_base0 + + ARCMSR_IOP2DRV_DOORBELL_MASK); + reg->ioctl_wbuffer_reg = (uint32_t *)((char *)mem_base1 + + ARCMSR_IOCTL_WBUFFER); + reg->ioctl_rbuffer_reg = (uint32_t *)((char *)mem_base1 + + ARCMSR_IOCTL_RBUFFER); + reg->msgcode_rwbuffer_reg = (uint32_t *)((char *)mem_base1 + + ARCMSR_MSGCODE_RWBUFFER); acb->vir2phy_offset = (unsigned long)ccb_tmp -(unsigned long)dma_addr; for (i = 0; i < ARCMSR_MAX_TARGETID; i++) @@ -369,12 +362,6 @@ static int arcmsr_alloc_ccb_pool(struct AdapterControlBlock *acb) break; } return 0; - -out: - dma_free_coherent(&acb->pdev->dev, - ARCMSR_MAX_FREECCB_NUM * sizeof(struct CommandControlBlock) + 0x20, - acb->dma_coherent, acb->dma_coherent_handle); - return -ENOMEM; } static int arcmsr_probe(struct pci_dev *pdev, @@ -467,6 +454,7 @@ static int arcmsr_probe(struct pci_dev *pdev, free_irq(pdev->irq, acb); out_free_ccb_pool: arcmsr_free_ccb_pool(acb); + iounmap(acb->pmu); out_release_regions: pci_release_regions(pdev); out_host_put: @@ -479,7 +467,7 @@ static int arcmsr_probe(struct pci_dev *pdev, static uint8_t arcmsr_hba_wait_msgint_ready(struct AdapterControlBlock *acb) { - struct MessageUnit_A __iomem *reg = acb->pmuA; + struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; uint32_t Index; uint8_t Retries = 0x00; @@ -500,7 +488,7 @@ static uint8_t arcmsr_hba_wait_msgint_ready(struct AdapterControlBlock *acb) static uint8_t arcmsr_hbb_wait_msgint_ready(struct AdapterControlBlock *acb) { - struct MessageUnit_B *reg = acb->pmuB; + struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; uint32_t Index; uint8_t Retries = 0x00; @@ -521,7 +509,7 @@ static uint8_t arcmsr_hbb_wait_msgint_ready(struct AdapterControlBlock *acb) static void arcmsr_abort_hba_allcmd(struct AdapterControlBlock *acb) { - struct MessageUnit_A __iomem *reg = acb->pmuA; + struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; writel(ARCMSR_INBOUND_MESG0_ABORT_CMD, ®->inbound_msgaddr0); if (arcmsr_hba_wait_msgint_ready(acb)) @@ -532,7 +520,7 @@ static void arcmsr_abort_hba_allcmd(struct AdapterControlBlock *acb) static void arcmsr_abort_hbb_allcmd(struct AdapterControlBlock *acb) { - struct MessageUnit_B *reg = acb->pmuB; + struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; writel(ARCMSR_MESSAGE_ABORT_CMD, reg->drv2iop_doorbell_reg); if (arcmsr_hbb_wait_msgint_ready(acb)) @@ -578,7 +566,7 @@ static void arcmsr_ccb_complete(struct CommandControlBlock *ccb, int stand_flag) static void arcmsr_flush_hba_cache(struct AdapterControlBlock *acb) { - struct MessageUnit_A __iomem *reg = acb->pmuA; + struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; int retry_count = 30; writel(ARCMSR_INBOUND_MESG0_FLUSH_CACHE, ®->inbound_msgaddr0); @@ -595,7 +583,7 @@ static void arcmsr_flush_hba_cache(struct AdapterControlBlock *acb) static void arcmsr_flush_hbb_cache(struct AdapterControlBlock *acb) { - struct MessageUnit_B *reg = acb->pmuB; + struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; int retry_count = 30; writel(ARCMSR_MESSAGE_FLUSH_CACHE, reg->drv2iop_doorbell_reg); @@ -649,7 +637,7 @@ static u32 arcmsr_disable_outbound_ints(struct AdapterControlBlock *acb) switch (acb->adapter_type) { case ACB_ADAPTER_TYPE_A : { - struct MessageUnit_A __iomem *reg = acb->pmuA; + struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; orig_mask = readl(®->outbound_intmask)|\ ARCMSR_MU_OUTBOUND_MESSAGE0_INTMASKENABLE; writel(orig_mask|ARCMSR_MU_OUTBOUND_ALL_INTMASKENABLE, \ @@ -658,7 +646,7 @@ static u32 arcmsr_disable_outbound_ints(struct AdapterControlBlock *acb) break; case ACB_ADAPTER_TYPE_B : { - struct MessageUnit_B *reg = acb->pmuB; + struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; orig_mask = readl(reg->iop2drv_doorbell_mask_reg) & \ (~ARCMSR_IOP2DRV_MESSAGE_CMD_DONE); writel(0, reg->iop2drv_doorbell_mask_reg); @@ -760,13 +748,14 @@ static void arcmsr_done4abort_postqueue(struct AdapterControlBlock *acb) switch (acb->adapter_type) { case ACB_ADAPTER_TYPE_A: { - struct MessageUnit_A __iomem *reg = acb->pmuA; + struct MessageUnit_A __iomem *reg = \ + (struct MessageUnit_A *)acb->pmu; uint32_t outbound_intstatus; - outbound_intstatus = readl(®->outbound_intstatus) & + outbound_intstatus = readl(®->outbound_intstatus) & \ acb->outbound_int_enable; /*clear and abort all outbound posted Q*/ writel(outbound_intstatus, ®->outbound_intstatus);/*clear interrupt*/ - while (((flag_ccb = readl(®->outbound_queueport)) != 0xFFFFFFFF) + while (((flag_ccb = readl(®->outbound_queueport)) != 0xFFFFFFFF) \ && (i++ < ARCMSR_MAX_OUTSTANDING_CMD)) { arcmsr_drain_donequeue(acb, flag_ccb); } @@ -774,7 +763,7 @@ static void arcmsr_done4abort_postqueue(struct AdapterControlBlock *acb) break; case ACB_ADAPTER_TYPE_B: { - struct MessageUnit_B *reg = acb->pmuB; + struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; /*clear all outbound posted Q*/ for (i = 0; i < ARCMSR_MAX_HBB_POSTQUEUE; i++) { if ((flag_ccb = readl(®->done_qbuffer[i])) != 0) { @@ -827,6 +816,7 @@ static void arcmsr_remove(struct pci_dev *pdev) } free_irq(pdev->irq, acb); + iounmap(acb->pmu); arcmsr_free_ccb_pool(acb); pci_release_regions(pdev); @@ -869,7 +859,7 @@ static void arcmsr_enable_outbound_ints(struct AdapterControlBlock *acb, \ switch (acb->adapter_type) { case ACB_ADAPTER_TYPE_A : { - struct MessageUnit_A __iomem *reg = acb->pmuA; + struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; mask = intmask_org & ~(ARCMSR_MU_OUTBOUND_POSTQUEUE_INTMASKENABLE | ARCMSR_MU_OUTBOUND_DOORBELL_INTMASKENABLE); writel(mask, ®->outbound_intmask); @@ -878,7 +868,7 @@ static void arcmsr_enable_outbound_ints(struct AdapterControlBlock *acb, \ break; case ACB_ADAPTER_TYPE_B : { - struct MessageUnit_B *reg = acb->pmuB; + struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; mask = intmask_org | (ARCMSR_IOP2DRV_DATA_WRITE_OK | \ ARCMSR_IOP2DRV_DATA_READ_OK | ARCMSR_IOP2DRV_CDB_DONE); writel(mask, reg->iop2drv_doorbell_mask_reg); @@ -892,7 +882,7 @@ static void arcmsr_build_ccb(struct AdapterControlBlock *acb, { struct ARCMSR_CDB *arcmsr_cdb = (struct ARCMSR_CDB *)&ccb->arcmsr_cdb; int8_t *psge = (int8_t *)&arcmsr_cdb->u; - __le32 address_lo, address_hi; + uint32_t address_lo, address_hi; int arccdbsize = 0x30; int nseg; @@ -910,8 +900,7 @@ static void arcmsr_build_ccb(struct AdapterControlBlock *acb, BUG_ON(nseg < 0); if (nseg) { - __le32 length; - int i, cdb_sgcount = 0; + int length, i, cdb_sgcount = 0; struct scatterlist *sg; /* map stor port SG list to our iop SG List. */ @@ -932,7 +921,7 @@ static void arcmsr_build_ccb(struct AdapterControlBlock *acb, pdma_sg->addresshigh = address_hi; pdma_sg->address = address_lo; - pdma_sg->length = length|cpu_to_le32(IS_SG64_ADDR); + pdma_sg->length = length|IS_SG64_ADDR; psge += sizeof (struct SG64ENTRY); arccdbsize += sizeof (struct SG64ENTRY); } @@ -958,7 +947,7 @@ static void arcmsr_post_ccb(struct AdapterControlBlock *acb, struct CommandContr switch (acb->adapter_type) { case ACB_ADAPTER_TYPE_A: { - struct MessageUnit_A __iomem *reg = acb->pmuA; + struct MessageUnit_A *reg = (struct MessageUnit_A *)acb->pmu; if (arcmsr_cdb->Flags & ARCMSR_CDB_FLAG_SGL_BSIZE) writel(cdb_shifted_phyaddr | ARCMSR_CCBPOST_FLAG_SGL_BSIZE, @@ -970,7 +959,7 @@ static void arcmsr_post_ccb(struct AdapterControlBlock *acb, struct CommandContr break; case ACB_ADAPTER_TYPE_B: { - struct MessageUnit_B *reg = acb->pmuB; + struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; uint32_t ending_index, index = reg->postq_index; ending_index = ((index + 1) % ARCMSR_MAX_HBB_POSTQUEUE); @@ -993,7 +982,7 @@ static void arcmsr_post_ccb(struct AdapterControlBlock *acb, struct CommandContr static void arcmsr_stop_hba_bgrb(struct AdapterControlBlock *acb) { - struct MessageUnit_A __iomem *reg = acb->pmuA; + struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; acb->acb_flags &= ~ACB_F_MSG_START_BGRB; writel(ARCMSR_INBOUND_MESG0_STOP_BGRB, ®->inbound_msgaddr0); @@ -1006,7 +995,7 @@ static void arcmsr_stop_hba_bgrb(struct AdapterControlBlock *acb) static void arcmsr_stop_hbb_bgrb(struct AdapterControlBlock *acb) { - struct MessageUnit_B *reg = acb->pmuB; + struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; acb->acb_flags &= ~ACB_F_MSG_START_BGRB; writel(ARCMSR_MESSAGE_STOP_BGRB, reg->drv2iop_doorbell_reg); @@ -1034,17 +1023,6 @@ static void arcmsr_stop_adapter_bgrb(struct AdapterControlBlock *acb) static void arcmsr_free_ccb_pool(struct AdapterControlBlock *acb) { - switch (acb->adapter_type) { - case ACB_ADAPTER_TYPE_A: { - iounmap(acb->pmuA); - break; - } - case ACB_ADAPTER_TYPE_B: { - struct MessageUnit_B *reg = acb->pmuB; - iounmap(reg->drv2iop_doorbell_reg - ARCMSR_DRV2IOP_DOORBELL); - iounmap(reg->ioctl_wbuffer_reg - ARCMSR_IOCTL_WBUFFER); - } - } dma_free_coherent(&acb->pdev->dev, ARCMSR_MAX_FREECCB_NUM * sizeof (struct CommandControlBlock) + 0x20, acb->dma_coherent, @@ -1055,13 +1033,13 @@ void arcmsr_iop_message_read(struct AdapterControlBlock *acb) { switch (acb->adapter_type) { case ACB_ADAPTER_TYPE_A: { - struct MessageUnit_A __iomem *reg = acb->pmuA; + struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; writel(ARCMSR_INBOUND_DRIVER_DATA_READ_OK, ®->inbound_doorbell); } break; case ACB_ADAPTER_TYPE_B: { - struct MessageUnit_B *reg = acb->pmuB; + struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; writel(ARCMSR_DRV2IOP_DATA_READ_OK, reg->drv2iop_doorbell_reg); } break; @@ -1072,7 +1050,7 @@ static void arcmsr_iop_message_wrote(struct AdapterControlBlock *acb) { switch (acb->adapter_type) { case ACB_ADAPTER_TYPE_A: { - struct MessageUnit_A __iomem *reg = acb->pmuA; + struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; /* ** push inbound doorbell tell iop, driver data write ok ** and wait reply on next hwinterrupt for next Qbuffer post @@ -1082,7 +1060,7 @@ static void arcmsr_iop_message_wrote(struct AdapterControlBlock *acb) break; case ACB_ADAPTER_TYPE_B: { - struct MessageUnit_B *reg = acb->pmuB; + struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; /* ** push inbound doorbell tell iop, driver data write ok ** and wait reply on next hwinterrupt for next Qbuffer post @@ -1093,41 +1071,41 @@ static void arcmsr_iop_message_wrote(struct AdapterControlBlock *acb) } } -struct QBUFFER __iomem *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *acb) +struct QBUFFER *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *acb) { - struct QBUFFER __iomem *qbuffer = NULL; + static struct QBUFFER *qbuffer; switch (acb->adapter_type) { case ACB_ADAPTER_TYPE_A: { - struct MessageUnit_A __iomem *reg = acb->pmuA; - qbuffer = (struct QBUFFER __iomem *)®->message_rbuffer; + struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; + qbuffer = (struct QBUFFER __iomem *) ®->message_rbuffer; } break; case ACB_ADAPTER_TYPE_B: { - struct MessageUnit_B *reg = acb->pmuB; - qbuffer = (struct QBUFFER __iomem *)reg->ioctl_rbuffer_reg; + struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; + qbuffer = (struct QBUFFER __iomem *) reg->ioctl_rbuffer_reg; } break; } return qbuffer; } -static struct QBUFFER __iomem *arcmsr_get_iop_wqbuffer(struct AdapterControlBlock *acb) +static struct QBUFFER *arcmsr_get_iop_wqbuffer(struct AdapterControlBlock *acb) { - struct QBUFFER __iomem *pqbuffer = NULL; + static struct QBUFFER *pqbuffer; switch (acb->adapter_type) { case ACB_ADAPTER_TYPE_A: { - struct MessageUnit_A __iomem *reg = acb->pmuA; - pqbuffer = (struct QBUFFER __iomem *) ®->message_wbuffer; + struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; + pqbuffer = (struct QBUFFER *) ®->message_wbuffer; } break; case ACB_ADAPTER_TYPE_B: { - struct MessageUnit_B *reg = acb->pmuB; + struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; pqbuffer = (struct QBUFFER __iomem *)reg->ioctl_wbuffer_reg; } break; @@ -1137,15 +1115,15 @@ static struct QBUFFER __iomem *arcmsr_get_iop_wqbuffer(struct AdapterControlBloc static void arcmsr_iop2drv_data_wrote_handle(struct AdapterControlBlock *acb) { - struct QBUFFER __iomem *prbuffer; + struct QBUFFER *prbuffer; struct QBUFFER *pQbuffer; - uint8_t __iomem *iop_data; + uint8_t *iop_data; int32_t my_empty_len, iop_len, rqbuf_firstindex, rqbuf_lastindex; rqbuf_lastindex = acb->rqbuf_lastindex; rqbuf_firstindex = acb->rqbuf_firstindex; prbuffer = arcmsr_get_iop_rqbuffer(acb); - iop_data = (uint8_t __iomem *)prbuffer->data; + iop_data = (uint8_t *)prbuffer->data; iop_len = prbuffer->data_len; my_empty_len = (rqbuf_firstindex - rqbuf_lastindex -1)&(ARCMSR_MAX_QBUFFER -1); @@ -1173,8 +1151,8 @@ static void arcmsr_iop2drv_data_read_handle(struct AdapterControlBlock *acb) acb->acb_flags |= ACB_F_MESSAGE_WQBUFFER_READED; if (acb->wqbuf_firstindex != acb->wqbuf_lastindex) { uint8_t *pQbuffer; - struct QBUFFER __iomem *pwbuffer; - uint8_t __iomem *iop_data; + struct QBUFFER *pwbuffer; + uint8_t *iop_data; int32_t allxfer_len = 0; acb->acb_flags &= (~ACB_F_MESSAGE_WQBUFFER_READED); @@ -1203,7 +1181,7 @@ static void arcmsr_iop2drv_data_read_handle(struct AdapterControlBlock *acb) static void arcmsr_hba_doorbell_isr(struct AdapterControlBlock *acb) { uint32_t outbound_doorbell; - struct MessageUnit_A __iomem *reg = acb->pmuA; + struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; outbound_doorbell = readl(®->outbound_doorbell); writel(outbound_doorbell, ®->outbound_doorbell); @@ -1219,7 +1197,7 @@ static void arcmsr_hba_doorbell_isr(struct AdapterControlBlock *acb) static void arcmsr_hba_postqueue_isr(struct AdapterControlBlock *acb) { uint32_t flag_ccb; - struct MessageUnit_A __iomem *reg = acb->pmuA; + struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; while ((flag_ccb = readl(®->outbound_queueport)) != 0xFFFFFFFF) { arcmsr_drain_donequeue(acb, flag_ccb); @@ -1230,7 +1208,7 @@ static void arcmsr_hbb_postqueue_isr(struct AdapterControlBlock *acb) { uint32_t index; uint32_t flag_ccb; - struct MessageUnit_B *reg = acb->pmuB; + struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; index = reg->doneq_index; @@ -1246,7 +1224,7 @@ static void arcmsr_hbb_postqueue_isr(struct AdapterControlBlock *acb) static int arcmsr_handle_hba_isr(struct AdapterControlBlock *acb) { uint32_t outbound_intstatus; - struct MessageUnit_A __iomem *reg = acb->pmuA; + struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; outbound_intstatus = readl(®->outbound_intstatus) & \ acb->outbound_int_enable; @@ -1266,7 +1244,7 @@ static int arcmsr_handle_hba_isr(struct AdapterControlBlock *acb) static int arcmsr_handle_hbb_isr(struct AdapterControlBlock *acb) { uint32_t outbound_doorbell; - struct MessageUnit_B *reg = acb->pmuB; + struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; outbound_doorbell = readl(reg->iop2drv_doorbell_reg) & \ acb->outbound_int_enable; @@ -1327,8 +1305,8 @@ void arcmsr_post_ioctldata2iop(struct AdapterControlBlock *acb) { int32_t wqbuf_firstindex, wqbuf_lastindex; uint8_t *pQbuffer; - struct QBUFFER __iomem *pwbuffer; - uint8_t __iomem *iop_data; + struct QBUFFER *pwbuffer; + uint8_t *iop_data; int32_t allxfer_len = 0; pwbuffer = arcmsr_get_iop_wqbuffer(acb); @@ -1402,13 +1380,13 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, \ } if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) { - struct QBUFFER __iomem *prbuffer; - uint8_t __iomem *iop_data; + struct QBUFFER *prbuffer; + uint8_t *iop_data; int32_t iop_len; acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW; prbuffer = arcmsr_get_iop_rqbuffer(acb); - iop_data = prbuffer->data; + iop_data = (uint8_t *)prbuffer->data; iop_len = readl(&prbuffer->data_len); while (iop_len > 0) { acb->rqbuffer[acb->rqbuf_lastindex] = readb(iop_data); @@ -1691,11 +1669,11 @@ static int arcmsr_queue_command(struct scsi_cmnd *cmd, static void arcmsr_get_hba_config(struct AdapterControlBlock *acb) { - struct MessageUnit_A __iomem *reg = acb->pmuA; + struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; char *acb_firm_model = acb->firm_model; char *acb_firm_version = acb->firm_version; - char __iomem *iop_firm_model = (char __iomem *)(®->message_rwbuffer[15]); - char __iomem *iop_firm_version = (char __iomem *)(®->message_rwbuffer[17]); + char *iop_firm_model = (char *) (®->message_rwbuffer[15]); + char *iop_firm_version = (char *) (®->message_rwbuffer[17]); int count; writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, ®->inbound_msgaddr0); @@ -1732,13 +1710,13 @@ static void arcmsr_get_hba_config(struct AdapterControlBlock *acb) static void arcmsr_get_hbb_config(struct AdapterControlBlock *acb) { - struct MessageUnit_B *reg = acb->pmuB; - uint32_t __iomem *lrwbuffer = reg->msgcode_rwbuffer_reg; + struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; + uint32_t *lrwbuffer = reg->msgcode_rwbuffer_reg; char *acb_firm_model = acb->firm_model; char *acb_firm_version = acb->firm_version; - char __iomem *iop_firm_model = (char __iomem *)(&lrwbuffer[15]); + char *iop_firm_model = (char *) (&lrwbuffer[15]); /*firm_model,15,60-67*/ - char __iomem *iop_firm_version = (char __iomem *)(&lrwbuffer[17]); + char *iop_firm_version = (char *) (&lrwbuffer[17]); /*firm_version,17,68-83*/ int count; @@ -1799,7 +1777,7 @@ static void arcmsr_get_firmware_spec(struct AdapterControlBlock *acb) static void arcmsr_polling_hba_ccbdone(struct AdapterControlBlock *acb, struct CommandControlBlock *poll_ccb) { - struct MessageUnit_A __iomem *reg = acb->pmuA; + struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; struct CommandControlBlock *ccb; uint32_t flag_ccb, outbound_intstatus, poll_ccb_done = 0, poll_count = 0; @@ -1848,7 +1826,7 @@ static void arcmsr_polling_hba_ccbdone(struct AdapterControlBlock *acb, static void arcmsr_polling_hbb_ccbdone(struct AdapterControlBlock *acb, \ struct CommandControlBlock *poll_ccb) { - struct MessageUnit_B *reg = acb->pmuB; + struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; struct CommandControlBlock *ccb; uint32_t flag_ccb, poll_ccb_done = 0, poll_count = 0; int index; @@ -1940,7 +1918,8 @@ static int arcmsr_iop_confirm(struct AdapterControlBlock *acb) case ACB_ADAPTER_TYPE_A: { if (ccb_phyaddr_hi32 != 0) { - struct MessageUnit_A __iomem *reg = acb->pmuA; + struct MessageUnit_A __iomem *reg = \ + (struct MessageUnit_A *)acb->pmu; uint32_t intmask_org; intmask_org = arcmsr_disable_outbound_ints(acb); writel(ARCMSR_SIGNATURE_SET_CONFIG, \ @@ -1961,9 +1940,9 @@ static int arcmsr_iop_confirm(struct AdapterControlBlock *acb) case ACB_ADAPTER_TYPE_B: { unsigned long post_queue_phyaddr; - uint32_t __iomem *rwbuffer; + uint32_t *rwbuffer; - struct MessageUnit_B *reg = acb->pmuB; + struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; uint32_t intmask_org; intmask_org = arcmsr_disable_outbound_ints(acb); reg->postq_index = 0; @@ -2015,7 +1994,7 @@ static void arcmsr_wait_firmware_ready(struct AdapterControlBlock *acb) switch (acb->adapter_type) { case ACB_ADAPTER_TYPE_A: { - struct MessageUnit_A __iomem *reg = acb->pmuA; + struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; do { firmware_state = readl(®->outbound_msgaddr1); } while ((firmware_state & ARCMSR_OUTBOUND_MESG1_FIRMWARE_OK) == 0); @@ -2023,7 +2002,7 @@ static void arcmsr_wait_firmware_ready(struct AdapterControlBlock *acb) break; case ACB_ADAPTER_TYPE_B: { - struct MessageUnit_B *reg = acb->pmuB; + struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; do { firmware_state = readl(reg->iop2drv_doorbell_reg); } while ((firmware_state & ARCMSR_MESSAGE_FIRMWARE_OK) == 0); @@ -2034,7 +2013,7 @@ static void arcmsr_wait_firmware_ready(struct AdapterControlBlock *acb) static void arcmsr_start_hba_bgrb(struct AdapterControlBlock *acb) { - struct MessageUnit_A __iomem *reg = acb->pmuA; + struct MessageUnit_A __iomem *reg = (struct MessageUnit_A *)acb->pmu; acb->acb_flags |= ACB_F_MSG_START_BGRB; writel(ARCMSR_INBOUND_MESG0_START_BGRB, ®->inbound_msgaddr0); if (arcmsr_hba_wait_msgint_ready(acb)) { @@ -2045,7 +2024,7 @@ static void arcmsr_start_hba_bgrb(struct AdapterControlBlock *acb) static void arcmsr_start_hbb_bgrb(struct AdapterControlBlock *acb) { - struct MessageUnit_B *reg = acb->pmuB; + struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; acb->acb_flags |= ACB_F_MSG_START_BGRB; writel(ARCMSR_MESSAGE_START_BGRB, reg->drv2iop_doorbell_reg); if (arcmsr_hbb_wait_msgint_ready(acb)) { @@ -2070,7 +2049,7 @@ static void arcmsr_clear_doorbell_queue_buffer(struct AdapterControlBlock *acb) { switch (acb->adapter_type) { case ACB_ADAPTER_TYPE_A: { - struct MessageUnit_A __iomem *reg = acb->pmuA; + struct MessageUnit_A *reg = (struct MessageUnit_A *)acb->pmu; uint32_t outbound_doorbell; /* empty doorbell Qbuffer if door bell ringed */ outbound_doorbell = readl(®->outbound_doorbell); @@ -2081,7 +2060,7 @@ static void arcmsr_clear_doorbell_queue_buffer(struct AdapterControlBlock *acb) break; case ACB_ADAPTER_TYPE_B: { - struct MessageUnit_B *reg = acb->pmuB; + struct MessageUnit_B *reg = (struct MessageUnit_B *)acb->pmu; /*clear interrupt and message state*/ writel(ARCMSR_MESSAGE_INT_CLEAR_PATTERN, reg->iop2drv_doorbell_reg); writel(ARCMSR_DRV2IOP_DATA_READ_OK, reg->drv2iop_doorbell_reg); diff --git a/trunk/drivers/scsi/atari_NCR5380.c b/trunk/drivers/scsi/atari_NCR5380.c index a9680b5e8ac6..d1780980fb20 100644 --- a/trunk/drivers/scsi/atari_NCR5380.c +++ b/trunk/drivers/scsi/atari_NCR5380.c @@ -477,9 +477,10 @@ static void merge_contiguous_buffers(Scsi_Cmnd *cmd) for (endaddr = virt_to_phys(cmd->SCp.ptr + cmd->SCp.this_residual - 1) + 1; cmd->SCp.buffers_residual && - virt_to_phys(sg_virt(&cmd->SCp.buffer[1])) == endaddr;) { + virt_to_phys(page_address(cmd->SCp.buffer[1].page) + + cmd->SCp.buffer[1].offset) == endaddr;) { MER_PRINTK("VTOP(%p) == %08lx -> merging\n", - page_address(sg_page(&cmd->SCp.buffer[1])), endaddr); + page_address(cmd->SCp.buffer[1].page), endaddr); #if (NDEBUG & NDEBUG_MERGING) ++cnt; #endif diff --git a/trunk/drivers/scsi/fcal.c b/trunk/drivers/scsi/fcal.c new file mode 100644 index 000000000000..c4e16c0775de --- /dev/null +++ b/trunk/drivers/scsi/fcal.c @@ -0,0 +1,317 @@ +/* fcal.c: Fibre Channel Arbitrated Loop SCSI host adapter driver. + * + * Copyright (C) 1998,1999 Jakub Jelinek (jj@ultra.linux.cz) + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef CONFIG_KMOD +#include +#endif + +#include + +#include "scsi.h" +#include +#include "../fc4/fcp_impl.h" +#include "fcal.h" + +#include + +/* #define FCAL_DEBUG */ + +#define fcal_printk printk ("FCAL %s: ", fc->name); printk + +#ifdef FCAL_DEBUG +#define FCALD(x) fcal_printk x; +#define FCALND(x) printk ("FCAL: "); printk x; +#else +#define FCALD(x) +#define FCALND(x) +#endif + +static unsigned char alpa2target[] = { +0x7e, 0x7d, 0x7c, 0xff, 0x7b, 0xff, 0xff, 0xff, 0x7a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x79, +0x78, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x77, 0x76, 0xff, 0xff, 0x75, 0xff, 0x74, 0x73, 0x72, +0xff, 0xff, 0xff, 0x71, 0xff, 0x70, 0x6f, 0x6e, 0xff, 0x6d, 0x6c, 0x6b, 0x6a, 0x69, 0x68, 0xff, +0xff, 0x67, 0x66, 0x65, 0x64, 0x63, 0x62, 0xff, 0xff, 0x61, 0x60, 0xff, 0x5f, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0x5e, 0xff, 0x5d, 0x5c, 0x5b, 0xff, 0x5a, 0x59, 0x58, 0x57, 0x56, 0x55, 0xff, +0xff, 0x54, 0x53, 0x52, 0x51, 0x50, 0x4f, 0xff, 0xff, 0x4e, 0x4d, 0xff, 0x4c, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0x4b, 0xff, 0x4a, 0x49, 0x48, 0xff, 0x47, 0x46, 0x45, 0x44, 0x43, 0x42, 0xff, +0xff, 0x41, 0x40, 0x3f, 0x3e, 0x3d, 0x3c, 0xff, 0xff, 0x3b, 0x3a, 0xff, 0x39, 0xff, 0xff, 0xff, +0x38, 0x37, 0x36, 0xff, 0x35, 0xff, 0xff, 0xff, 0x34, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x33, +0x32, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x31, 0x30, 0xff, 0xff, 0x2f, 0xff, 0x2e, 0x2d, 0x2c, +0xff, 0xff, 0xff, 0x2b, 0xff, 0x2a, 0x29, 0x28, 0xff, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0xff, +0xff, 0x21, 0x20, 0x1f, 0x1e, 0x1d, 0x1c, 0xff, 0xff, 0x1b, 0x1a, 0xff, 0x19, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0x18, 0xff, 0x17, 0x16, 0x15, 0xff, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0f, 0xff, +0xff, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0xff, 0xff, 0x08, 0x07, 0xff, 0x06, 0xff, 0xff, 0xff, +0x05, 0x04, 0x03, 0xff, 0x02, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 +}; + +static unsigned char target2alpa[] = { +0xef, 0xe8, 0xe4, 0xe2, 0xe1, 0xe0, 0xdc, 0xda, 0xd9, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xce, +0xcd, 0xcc, 0xcb, 0xca, 0xc9, 0xc7, 0xc6, 0xc5, 0xc3, 0xbc, 0xba, 0xb9, 0xb6, 0xb5, 0xb4, 0xb3, +0xb2, 0xb1, 0xae, 0xad, 0xac, 0xab, 0xaa, 0xa9, 0xa7, 0xa6, 0xa5, 0xa3, 0x9f, 0x9e, 0x9d, 0x9b, +0x98, 0x97, 0x90, 0x8f, 0x88, 0x84, 0x82, 0x81, 0x80, 0x7c, 0x7a, 0x79, 0x76, 0x75, 0x74, 0x73, +0x72, 0x71, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x69, 0x67, 0x66, 0x65, 0x63, 0x5c, 0x5a, 0x59, 0x56, +0x55, 0x54, 0x53, 0x52, 0x51, 0x4e, 0x4d, 0x4c, 0x4b, 0x4a, 0x49, 0x47, 0x46, 0x45, 0x43, 0x3c, +0x3a, 0x39, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29, 0x27, 0x26, +0x25, 0x23, 0x1f, 0x1e, 0x1d, 0x1b, 0x18, 0x17, 0x10, 0x0f, 0x08, 0x04, 0x02, 0x01, 0x00 +}; + +static int fcal_encode_addr(Scsi_Cmnd *SCpnt, u16 *addr, fc_channel *fc, fcp_cmnd *fcmd); + +int fcal_slave_configure(struct scsi_device *device) +{ + int depth_to_use; + + if (device->tagged_supported) + depth_to_use = /* 254 */ 8; + else + depth_to_use = 2; + + scsi_adjust_queue_depth(device, + (device->tagged_supported ? + MSG_SIMPLE_TAG : 0), + depth_to_use); + + return 0; +} + +/* Detect all FC Arbitrated Loops attached to the machine. + fc4 module has done all the work for us... */ +int __init fcal_detect(struct scsi_host_template *tpnt) +{ + int nfcals = 0; + fc_channel *fc; + int fcalcount; + int i; + + tpnt->proc_name = "fcal"; + fcalcount = 0; + for_each_online_fc_channel(fc) + if (fc->posmap) + fcalcount++; + FCALND(("%d channels online\n", fcalcount)) + if (!fcalcount) { +#if defined(MODULE) && defined(CONFIG_FC4_SOCAL_MODULE) && defined(CONFIG_KMOD) + request_module("socal"); + + for_each_online_fc_channel(fc) + if (fc->posmap) + fcalcount++; + if (!fcalcount) +#endif + return 0; + } + for_each_online_fc_channel(fc) { + struct Scsi_Host *host; + long *ages; + struct fcal *fcal; + + if (!fc->posmap) continue; + + /* Strange, this is already registered to some other SCSI host, then it cannot be fcal */ + if (fc->scsi_name[0]) continue; + memcpy (fc->scsi_name, "FCAL", 4); + + fc->can_queue = FCAL_CAN_QUEUE; + fc->rsp_size = 64; + fc->encode_addr = fcal_encode_addr; + + ages = kmalloc (128 * sizeof(long), GFP_KERNEL); + if (!ages) continue; + + host = scsi_register (tpnt, sizeof (struct fcal)); + if (!host) + { + kfree(ages); + continue; + } + + if (!try_module_get(fc->module)) { + kfree(ages); + scsi_unregister(host); + continue; + } + + nfcals++; + + fcal = (struct fcal *)host->hostdata; + + fc->fcp_register(fc, TYPE_SCSI_FCP, 0); + + for (i = 0; i < fc->posmap->len; i++) { + int status, target, alpa; + + alpa = fc->posmap->list[i]; + FCALD(("Sending PLOGI to %02x\n", alpa)) + target = alpa2target[alpa]; + status = fc_do_plogi(fc, alpa, fcal->node_wwn + target, + fcal->nport_wwn + target); + FCALD(("PLOGI returned with status %d\n", status)) + if (status != FC_STATUS_OK) + continue; + FCALD(("Sending PRLI to %02x\n", alpa)) + status = fc_do_prli(fc, alpa); + FCALD(("PRLI returned with status %d\n", status)) + if (status == FC_STATUS_OK) + fcal->map[target] = 1; + } + + host->max_id = 127; + host->irq = fc->irq; +#ifdef __sparc_v9__ + host->unchecked_isa_dma = 1; +#endif + + fc->channels = 1; + fc->targets = 127; + fc->ages = ages; + memset (ages, 0, 128 * sizeof(long)); + + fcal->fc = fc; + + FCALD(("Found FCAL\n")) + } + if (nfcals) +#ifdef __sparc__ + printk ("FCAL: Total of %d Sun Enterprise Network Array (A5000 or EX500) channels found\n", nfcals); +#else + printk ("FCAL: Total of %d Fibre Channel Arbitrated Loops found\n", nfcals); +#endif + return nfcals; +} + +int fcal_release(struct Scsi_Host *host) +{ + struct fcal *fcal = (struct fcal *)host->hostdata; + fc_channel *fc = fcal->fc; + + module_put(fc->module); + + fc->fcp_register(fc, TYPE_SCSI_FCP, 1); + FCALND((" releasing fcal.\n")); + kfree (fc->ages); + FCALND(("released fcal!\n")); + return 0; +} + +#undef SPRINTF +#define SPRINTF(args...) { if (pos < (buffer + length)) pos += sprintf (pos, ## args); } + +int fcal_proc_info (struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int inout) +{ + struct fcal *fcal; + fc_channel *fc; + char *pos = buffer; + int i, j; + + if (inout) return length; + + fcal = (struct fcal *)host->hostdata; + fc = fcal->fc; + +#ifdef __sparc__ + SPRINTF ("Sun Enterprise Network Array (A5000 or E?500) on %s PROM node %x\n", fc->name, fc->dev->prom_node); +#else + SPRINTF ("Fibre Channel Arbitrated Loop on %s\n", fc->name); +#endif + SPRINTF ("Initiator AL-PA: %02x\n", fc->sid); + + SPRINTF ("\nAttached devices:\n"); + + for (i = 0; i < fc->posmap->len; i++) { + unsigned char alpa = fc->posmap->list[i]; + unsigned char target; + u32 *u1, *u2; + + target = alpa2target[alpa]; + u1 = (u32 *)&fcal->nport_wwn[target]; + u2 = (u32 *)&fcal->node_wwn[target]; + if (!u1[0] && !u1[1]) { + SPRINTF (" [AL-PA: %02x] Not responded to PLOGI\n", alpa); + } else if (!fcal->map[target]) { + SPRINTF (" [AL-PA: %02x, Port WWN: %08x%08x, Node WWN: %08x%08x] Not responded to PRLI\n", + alpa, u1[0], u1[1], u2[0], u2[1]); + } else { + struct scsi_device *scd; + shost_for_each_device(scd, host) + if (scd->id == target) { + SPRINTF (" [AL-PA: %02x, Id: %02d, Port WWN: %08x%08x, Node WWN: %08x%08x] ", + alpa, target, u1[0], u1[1], u2[0], u2[1]); + SPRINTF ("%s ", scsi_device_type(scd->type)); + + for (j = 0; (j < 8) && (scd->vendor[j] >= 0x20); j++) + SPRINTF ("%c", scd->vendor[j]); + SPRINTF (" "); + + for (j = 0; (j < 16) && (scd->model[j] >= 0x20); j++) + SPRINTF ("%c", scd->model[j]); + + SPRINTF ("\n"); + } + } + } + SPRINTF ("\n"); + + *start = buffer + offset; + + if ((pos - buffer) < offset) + return 0; + else if (pos - buffer - offset < length) + return pos - buffer - offset; + else + return length; +} + +/* + For FC-AL, we use a simple addressing: we have just one channel 0, + and all AL-PAs are mapped to targets 0..0x7e + */ +static int fcal_encode_addr(Scsi_Cmnd *SCpnt, u16 *addr, fc_channel *fc, fcp_cmnd *fcmd) +{ + struct fcal *f; + + /* We don't support LUNs yet - I'm not sure if LUN should be in SCSI fcp_cdb, or in second byte of addr[0] */ + if (SCpnt->cmnd[1] & 0xe0) return -EINVAL; + /* FC-PLDA tells us... */ + memset(addr, 0, 8); + f = (struct fcal *)SCpnt->device->host->hostdata; + if (!f->map[SCpnt->device->id]) + return -EINVAL; + /* Now, determine DID: It will be Native Identifier, so we zero upper + 2 bytes of the 3 byte DID, lowest byte will be AL-PA */ + fcmd->did = target2alpa[SCpnt->device->id]; + FCALD(("trying DID %06x\n", fcmd->did)) + return 0; +} + +static struct scsi_host_template driver_template = { + .name = "Fibre Channel Arbitrated Loop", + .detect = fcal_detect, + .release = fcal_release, + .proc_info = fcal_proc_info, + .queuecommand = fcp_scsi_queuecommand, + .slave_configure = fcal_slave_configure, + .can_queue = FCAL_CAN_QUEUE, + .this_id = -1, + .sg_tablesize = 1, + .cmd_per_lun = 1, + .use_clustering = ENABLE_CLUSTERING, + .eh_abort_handler = fcp_scsi_abort, + .eh_device_reset_handler = fcp_scsi_dev_reset, + .eh_host_reset_handler = fcp_scsi_host_reset, +}; +#include "scsi_module.c" + +MODULE_LICENSE("GPL"); + diff --git a/trunk/drivers/scsi/fcal.h b/trunk/drivers/scsi/fcal.h new file mode 100644 index 000000000000..7ff2c3494f9e --- /dev/null +++ b/trunk/drivers/scsi/fcal.h @@ -0,0 +1,27 @@ +/* fcal.h: Generic Fibre Channel Arbitrated Loop SCSI host adapter driver definitions. + * + * Copyright (C) 1998,1999 Jakub Jelinek (jj@ultra.linux.cz) + */ + +#ifndef _FCAL_H +#define _FCAL_H + +#include "../fc4/fcp_impl.h" + +struct fcal { + /* fc must be first */ + fc_channel *fc; + unsigned char map[128]; + fc_wwn nport_wwn[128]; + fc_wwn node_wwn[128]; +}; + +/* Arbitrary constant. Cannot be too large, as fc4 layer has limitations + for a particular channel */ +#define FCAL_CAN_QUEUE 512 + +int fcal_detect(struct scsi_host_template *); +int fcal_release(struct Scsi_Host *); +int fcal_slave_configure(struct scsi_device *); + +#endif /* !(_FCAL_H) */ diff --git a/trunk/drivers/scsi/gdth.c b/trunk/drivers/scsi/gdth.c index b253b8c718d3..5ab3ce762485 100644 --- a/trunk/drivers/scsi/gdth.c +++ b/trunk/drivers/scsi/gdth.c @@ -4734,7 +4734,7 @@ static struct scsi_host_template gdth_template = { }; #ifdef CONFIG_ISA -static int __init gdth_isa_probe_one(ulong32 isa_bios) +static int gdth_isa_probe_one(ulong32 isa_bios) { struct Scsi_Host *shp; gdth_ha_str *ha; @@ -4862,7 +4862,7 @@ static int __init gdth_isa_probe_one(ulong32 isa_bios) #endif /* CONFIG_ISA */ #ifdef CONFIG_EISA -static int __init gdth_eisa_probe_one(ushort eisa_slot) +static int gdth_eisa_probe_one(ushort eisa_slot) { struct Scsi_Host *shp; gdth_ha_str *ha; @@ -4991,7 +4991,7 @@ static int __init gdth_eisa_probe_one(ushort eisa_slot) #endif /* CONFIG_EISA */ #ifdef CONFIG_PCI -static int __init gdth_pci_probe_one(gdth_pci_str *pcistr, int ctr) +static int gdth_pci_probe_one(gdth_pci_str *pcistr, int ctr) { struct Scsi_Host *shp; gdth_ha_str *ha; diff --git a/trunk/drivers/scsi/hosts.c b/trunk/drivers/scsi/hosts.c index 24271a871b8c..112ab6abe62b 100644 --- a/trunk/drivers/scsi/hosts.c +++ b/trunk/drivers/scsi/hosts.c @@ -345,12 +345,6 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) shost->active_mode = sht->supported_mode; shost->use_sg_chaining = sht->use_sg_chaining; - if (sht->supported_mode == MODE_UNKNOWN) - /* means we didn't set it ... default to INITIATOR */ - shost->active_mode = MODE_INITIATOR; - else - shost->active_mode = sht->supported_mode; - if (sht->max_host_blocked) shost->max_host_blocked = sht->max_host_blocked; else diff --git a/trunk/drivers/scsi/hptiop.c b/trunk/drivers/scsi/hptiop.c index 0844331abb87..8515054cdf70 100644 --- a/trunk/drivers/scsi/hptiop.c +++ b/trunk/drivers/scsi/hptiop.c @@ -375,9 +375,8 @@ static void hptiop_host_request_callback(struct hptiop_hba *hba, u32 _tag) scp->result = SAM_STAT_CHECK_CONDITION; memset(&scp->sense_buffer, 0, sizeof(scp->sense_buffer)); - memcpy(&scp->sense_buffer, &req->sg_list, - min(sizeof(scp->sense_buffer), - le32_to_cpu(req->dataxfer_length))); + memcpy(&scp->sense_buffer, + &req->sg_list, le32_to_cpu(req->dataxfer_length)); break; default: diff --git a/trunk/drivers/scsi/initio.c b/trunk/drivers/scsi/initio.c index 4c4465d39a1d..22d40fd5845b 100644 --- a/trunk/drivers/scsi/initio.c +++ b/trunk/drivers/scsi/initio.c @@ -665,7 +665,7 @@ static void initio_init(struct initio_host * host, u8 *bios_addr) host->max_tags[i] = 0xFF; } /* for */ printk("i91u: PCI Base=0x%04X, IRQ=%d, BIOS=0x%04X0, SCSI ID=%d\n", - host->addr, host->pci_dev->irq, + host->addr, host->irq, host->bios_addr, host->scsi_id); /* Reset SCSI Bus */ if (host->config & HCC_SCSI_RESET) { @@ -2891,8 +2891,6 @@ static int initio_probe_one(struct pci_dev *pdev, goto out_release_region; } - host->pci_dev = pdev; - host->num_scbs = num_scb; host->scb = scb; host->next_pending = scb; @@ -2907,7 +2905,6 @@ static int initio_probe_one(struct pci_dev *pdev, host->scb_end = tmp; host->first_avail = scb; host->last_avail = prev; - spin_lock_init(&host->avail_lock); initio_init(host, phys_to_virt(bios_seg << 4)); @@ -2931,6 +2928,7 @@ static int initio_probe_one(struct pci_dev *pdev, } pci_set_drvdata(pdev, shost); + host->pci_dev = pdev; error = scsi_add_host(shost, &pdev->dev); if (error) diff --git a/trunk/drivers/scsi/ipr.c b/trunk/drivers/scsi/ipr.c index 0841df01bc19..439b97a6a269 100644 --- a/trunk/drivers/scsi/ipr.c +++ b/trunk/drivers/scsi/ipr.c @@ -2890,7 +2890,7 @@ static struct ipr_sglist *ipr_alloc_ucode_buffer(int buf_len) return NULL; } - sg_set_page(&scatterlist[i], page, 0, 0); + sg_set_page(&scatterlist[i], page); } return sglist; diff --git a/trunk/drivers/scsi/iscsi_tcp.c b/trunk/drivers/scsi/iscsi_tcp.c index 4bcf916c21a7..6ce4109efdf3 100644 --- a/trunk/drivers/scsi/iscsi_tcp.c +++ b/trunk/drivers/scsi/iscsi_tcp.c @@ -79,7 +79,9 @@ static inline void iscsi_buf_init_sg(struct iscsi_buf *ibuf, struct scatterlist *sg) { sg_init_table(&ibuf->sg, 1); - sg_set_page(&ibuf->sg, sg_page(sg), sg->length, sg->offset); + sg_set_page(&ibuf->sg, sg_page(sg)); + ibuf->sg.offset = sg->offset; + ibuf->sg.length = sg->length; /* * Fastpath: sg element fits into single page */ @@ -674,8 +676,9 @@ partial_sg_digest_update(struct hash_desc *desc, struct scatterlist *sg, { struct scatterlist temp; - sg_init_table(&temp, 1); - sg_set_page(&temp, sg_page(sg), length, offset); + memcpy(&temp, sg, sizeof(struct scatterlist)); + temp.offset = offset; + temp.length = length; crypto_hash_update(desc, &temp, length); } diff --git a/trunk/drivers/scsi/lpfc/lpfc_debugfs.c b/trunk/drivers/scsi/lpfc/lpfc_debugfs.c index d6a98bc970ff..149fdd25f8e8 100644 --- a/trunk/drivers/scsi/lpfc/lpfc_debugfs.c +++ b/trunk/drivers/scsi/lpfc/lpfc_debugfs.c @@ -901,7 +901,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport) } } - vport->disc_trc = kzalloc( + vport->disc_trc = kmzlloc( (sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_disc_trc), GFP_KERNEL); diff --git a/trunk/drivers/scsi/osst.c b/trunk/drivers/scsi/osst.c index 4652ad22516b..1c5c4b68f20f 100644 --- a/trunk/drivers/scsi/osst.c +++ b/trunk/drivers/scsi/osst.c @@ -5256,7 +5256,8 @@ static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma) STbuffer->sg[0].offset = 0; if (page != NULL) { - sg_set_page(&STbuffer->sg[0], page, b_size, 0); + sg_set_page(&STbuffer->sg[0], page); + STbuffer->sg[0].length = b_size; STbuffer->b_data = page_address(page); break; } @@ -5284,7 +5285,8 @@ static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma) normalize_buffer(STbuffer); return 0; } - sg_set_page(&STbuffer->sg[segs], page, (OS_FRAME_SIZE - got <= PAGE_SIZE / 2) ? (OS_FRAME_SIZE - got) : b_size, 0); + sg_set_page(&STbuffer->sg[segs], page); + STbuffer->sg[segs].length = (OS_FRAME_SIZE - got <= PAGE_SIZE / 2) ? (OS_FRAME_SIZE - got) : b_size; got += STbuffer->sg[segs].length; STbuffer->buffer_size = got; STbuffer->sg_segs = ++segs; diff --git a/trunk/drivers/scsi/pluto.c b/trunk/drivers/scsi/pluto.c new file mode 100644 index 000000000000..0363c1cd68c1 --- /dev/null +++ b/trunk/drivers/scsi/pluto.c @@ -0,0 +1,349 @@ +/* pluto.c: SparcSTORAGE Array SCSI host adapter driver. + * + * Copyright (C) 1997,1998,1999 Jakub Jelinek (jj@sunsite.mff.cuni.cz) + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef CONFIG_KMOD +#include +#endif + +#include + +#include "scsi.h" +#include +#include "../fc4/fcp_impl.h" +#include "pluto.h" + +#include + +#define RQ_SCSI_BUSY 0xffff +#define RQ_SCSI_DONE 0xfffe + +/* #define PLUTO_DEBUG */ + +#define pluto_printk printk ("PLUTO %s: ", fc->name); printk + +#ifdef PLUTO_DEBUG +#define PLD(x) pluto_printk x; +#define PLND(x) printk ("PLUTO: "); printk x; +#else +#define PLD(x) +#define PLND(x) +#endif + +static struct ctrl_inquiry { + struct Scsi_Host host; + struct pluto pluto; + Scsi_Cmnd cmd; + char inquiry[256]; + fc_channel *fc; +} *fcs __initdata; +static int fcscount __initdata = 0; +static atomic_t fcss __initdata = ATOMIC_INIT(0); +static DECLARE_COMPLETION(fc_detect_complete); + +static int pluto_encode_addr(Scsi_Cmnd *SCpnt, u16 *addr, fc_channel *fc, fcp_cmnd *fcmd); + +static void __init pluto_detect_done(Scsi_Cmnd *SCpnt) +{ + /* Do nothing */ +} + +static void __init pluto_detect_scsi_done(Scsi_Cmnd *SCpnt) +{ + PLND(("Detect done %08lx\n", (long)SCpnt)) + if (atomic_dec_and_test (&fcss)) + complete(&fc_detect_complete); +} + +int pluto_slave_configure(struct scsi_device *device) +{ + int depth_to_use; + + if (device->tagged_supported) + depth_to_use = /* 254 */ 8; + else + depth_to_use = 2; + + scsi_adjust_queue_depth(device, + (device->tagged_supported ? + MSG_SIMPLE_TAG : 0), + depth_to_use); + + return 0; +} + +/* Detect all SSAs attached to the machine. + To be fast, do it on all online FC channels at the same time. */ +int __init pluto_detect(struct scsi_host_template *tpnt) +{ + int i, retry, nplutos; + fc_channel *fc; + struct scsi_device dev; + + tpnt->proc_name = "pluto"; + fcscount = 0; + for_each_online_fc_channel(fc) { + if (!fc->posmap) + fcscount++; + } + PLND(("%d channels online\n", fcscount)) + if (!fcscount) { +#if defined(MODULE) && defined(CONFIG_FC4_SOC_MODULE) && defined(CONFIG_KMOD) + request_module("soc"); + + for_each_online_fc_channel(fc) { + if (!fc->posmap) + fcscount++; + } + if (!fcscount) +#endif + return 0; + } + fcs = kcalloc(fcscount, sizeof (struct ctrl_inquiry), GFP_DMA); + if (!fcs) { + printk ("PLUTO: Not enough memory to probe\n"); + return 0; + } + + memset (&dev, 0, sizeof(dev)); + atomic_set (&fcss, fcscount); + + i = 0; + for_each_online_fc_channel(fc) { + Scsi_Cmnd *SCpnt; + struct Scsi_Host *host; + struct pluto *pluto; + + if (i == fcscount) break; + if (fc->posmap) continue; + + PLD(("trying to find SSA\n")) + + /* If this is already registered to some other SCSI host, then it cannot be pluto */ + if (fc->scsi_name[0]) continue; + memcpy (fc->scsi_name, "SSA", 4); + + fcs[i].fc = fc; + + fc->can_queue = PLUTO_CAN_QUEUE; + fc->rsp_size = 64; + fc->encode_addr = pluto_encode_addr; + + fc->fcp_register(fc, TYPE_SCSI_FCP, 0); + + SCpnt = &(fcs[i].cmd); + host = &(fcs[i].host); + pluto = (struct pluto *)host->hostdata; + + pluto->fc = fc; + + SCpnt->cmnd[0] = INQUIRY; + SCpnt->cmnd[4] = 255; + + /* FC layer requires this, so that SCpnt->device->tagged_supported is initially 0 */ + SCpnt->device = &dev; + dev.host = host; + + SCpnt->cmd_len = COMMAND_SIZE(INQUIRY); + + SCpnt->request->cmd_flags &= ~REQ_STARTED; + + SCpnt->request_bufflen = 256; + SCpnt->request_buffer = fcs[i].inquiry; + PLD(("set up %d %08lx\n", i, (long)SCpnt)) + i++; + } + + for (retry = 0; retry < 5; retry++) { + for (i = 0; i < fcscount; i++) { + if (!fcs[i].fc) break; + if (!(fcs[i].cmd.request->cmd_flags & REQ_STARTED)) { + fcs[i].cmd.request->cmd_flags |= REQ_STARTED; + disable_irq(fcs[i].fc->irq); + PLND(("queuecommand %d %d\n", retry, i)) + fcp_scsi_queuecommand (&(fcs[i].cmd), + pluto_detect_scsi_done); + enable_irq(fcs[i].fc->irq); + } + } + + wait_for_completion_timeout(&fc_detect_complete, 10 * HZ); + PLND(("Woken up\n")) + if (!atomic_read(&fcss)) + break; /* All fc channels have answered us */ + } + + PLND(("Finished search\n")) + for (i = 0, nplutos = 0; i < fcscount; i++) { + Scsi_Cmnd *SCpnt; + + if (!(fc = fcs[i].fc)) break; + + SCpnt = &(fcs[i].cmd); + + /* Let FC mid-level free allocated resources */ + pluto_detect_scsi_done(SCpnt); + + if (!SCpnt->result) { + struct pluto_inquiry *inq; + struct pluto *pluto; + struct Scsi_Host *host; + + inq = (struct pluto_inquiry *)fcs[i].inquiry; + + if ((inq->dtype & 0x1f) == TYPE_PROCESSOR && + !strncmp (inq->vendor_id, "SUN", 3) && + !strncmp (inq->product_id, "SSA", 3)) { + char *p; + long *ages; + + ages = kcalloc((inq->channels + 1) * inq->targets, sizeof(long), GFP_KERNEL); + if (!ages) continue; + + host = scsi_register (tpnt, sizeof (struct pluto)); + if(!host) + { + kfree(ages); + continue; + } + + if (!try_module_get(fc->module)) { + kfree(ages); + scsi_unregister(host); + continue; + } + + nplutos++; + + pluto = (struct pluto *)host->hostdata; + + host->max_id = inq->targets; + host->max_channel = inq->channels; + host->irq = fc->irq; + + fc->channels = inq->channels + 1; + fc->targets = inq->targets; + fc->ages = ages; + + pluto->fc = fc; + memcpy (pluto->rev_str, inq->revision, 4); + pluto->rev_str[4] = 0; + p = strchr (pluto->rev_str, ' '); + if (p) *p = 0; + memcpy (pluto->fw_rev_str, inq->fw_revision, 4); + pluto->fw_rev_str[4] = 0; + p = strchr (pluto->fw_rev_str, ' '); + if (p) *p = 0; + memcpy (pluto->serial_str, inq->serial, 12); + pluto->serial_str[12] = 0; + p = strchr (pluto->serial_str, ' '); + if (p) *p = 0; + + PLD(("Found SSA rev %s fw rev %s serial %s %dx%d\n", pluto->rev_str, pluto->fw_rev_str, pluto->serial_str, host->max_channel, host->max_id)) + } else + fc->fcp_register(fc, TYPE_SCSI_FCP, 1); + } else + fc->fcp_register(fc, TYPE_SCSI_FCP, 1); + } + kfree(fcs); + if (nplutos) + printk ("PLUTO: Total of %d SparcSTORAGE Arrays found\n", nplutos); + return nplutos; +} + +int pluto_release(struct Scsi_Host *host) +{ + struct pluto *pluto = (struct pluto *)host->hostdata; + fc_channel *fc = pluto->fc; + + module_put(fc->module); + + fc->fcp_register(fc, TYPE_SCSI_FCP, 1); + PLND((" releasing pluto.\n")); + kfree (fc->ages); + PLND(("released pluto!\n")); + return 0; +} + +const char *pluto_info(struct Scsi_Host *host) +{ + static char buf[128], *p; + struct pluto *pluto = (struct pluto *) host->hostdata; + + sprintf(buf, "SUN SparcSTORAGE Array %s fw %s serial %s %dx%d on %s", + pluto->rev_str, pluto->fw_rev_str, pluto->serial_str, + host->max_channel, host->max_id, pluto->fc->name); +#ifdef __sparc__ + p = strchr(buf, 0); + sprintf(p, " PROM node %x", pluto->fc->dev->prom_node); +#endif + return buf; +} + +/* SSA uses this FC4S addressing: + switch (addr[0]) + { + case 0: CONTROLLER - All of addr[1]..addr[3] has to be 0 + case 1: SINGLE DISK - addr[1] channel, addr[2] id, addr[3] 0 + case 2: DISK GROUP - ??? + } + + So that SCSI mid-layer can access to these, we reserve + channel 0 id 0 lun 0 for CONTROLLER + and channels 1 .. max_channel are normal single disks. + */ +static int pluto_encode_addr(Scsi_Cmnd *SCpnt, u16 *addr, fc_channel *fc, fcp_cmnd *fcmd) +{ + PLND(("encode addr %d %d %d\n", SCpnt->device->channel, SCpnt->device->id, SCpnt->cmnd[1] & 0xe0)) + /* We don't support LUNs - neither does SSA :) */ + if (SCpnt->cmnd[1] & 0xe0) + return -EINVAL; + if (!SCpnt->device->channel) { + if (SCpnt->device->id) + return -EINVAL; + memset (addr, 0, 4 * sizeof(u16)); + } else { + addr[0] = 1; + addr[1] = SCpnt->device->channel - 1; + addr[2] = SCpnt->device->id; + addr[3] = 0; + } + /* We're Point-to-Point, so target it to the default DID */ + fcmd->did = fc->did; + PLND(("trying %04x%04x%04x%04x\n", addr[0], addr[1], addr[2], addr[3])) + return 0; +} + +static struct scsi_host_template driver_template = { + .name = "Sparc Storage Array 100/200", + .detect = pluto_detect, + .release = pluto_release, + .info = pluto_info, + .queuecommand = fcp_scsi_queuecommand, + .slave_configure = pluto_slave_configure, + .can_queue = PLUTO_CAN_QUEUE, + .this_id = -1, + .sg_tablesize = 1, + .cmd_per_lun = 1, + .use_clustering = ENABLE_CLUSTERING, + .eh_abort_handler = fcp_scsi_abort, + .eh_device_reset_handler = fcp_scsi_dev_reset, + .eh_host_reset_handler = fcp_scsi_host_reset, +}; + +#include "scsi_module.c" + +MODULE_LICENSE("GPL"); + diff --git a/trunk/drivers/scsi/pluto.h b/trunk/drivers/scsi/pluto.h new file mode 100644 index 000000000000..5da20616ac36 --- /dev/null +++ b/trunk/drivers/scsi/pluto.h @@ -0,0 +1,47 @@ +/* pluto.h: SparcSTORAGE Array SCSI host adapter driver definitions. + * + * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz) + */ + +#ifndef _PLUTO_H +#define _PLUTO_H + +#include "../fc4/fcp_impl.h" + +struct pluto { + /* This must be first */ + fc_channel *fc; + char rev_str[5]; + char fw_rev_str[5]; + char serial_str[13]; +}; + +struct pluto_inquiry { + u8 dtype; + u8 removable:1, qualifier:7; + u8 iso:2, ecma:3, ansi:3; + u8 aenc:1, trmiop:1, :2, rdf:4; + u8 len; + u8 xxx1; + u8 xxx2; + u8 reladdr:1, wbus32:1, wbus16:1, sync:1, linked:1, :1, cmdque:1, softreset:1; + u8 vendor_id[8]; + u8 product_id[16]; + u8 revision[4]; + u8 fw_revision[4]; + u8 serial[12]; + u8 xxx3[2]; + u8 channels; + u8 targets; +}; + +/* This is the max number of outstanding SCSI commands per pluto */ +#define PLUTO_CAN_QUEUE 254 + +int pluto_detect(struct scsi_host_template *); +int pluto_release(struct Scsi_Host *); +const char * pluto_info(struct Scsi_Host *); +int pluto_slave_configure(struct scsi_device *); + +#endif /* !(_PLUTO_H) */ + diff --git a/trunk/drivers/scsi/qla1280.c b/trunk/drivers/scsi/qla1280.c index 3aeb68bcb7ac..76089cf55f4e 100644 --- a/trunk/drivers/scsi/qla1280.c +++ b/trunk/drivers/scsi/qla1280.c @@ -4310,7 +4310,7 @@ qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) printk(KERN_WARNING "scsi(%li): Unable to set a " "suitable DMA mask - aborting\n", ha->host_no); error = -ENODEV; - goto error_put_host; + goto error_free_irq; } } else dprintk(2, "scsi(%li): 64 Bit PCI Addressing Enabled\n", @@ -4320,7 +4320,7 @@ qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) printk(KERN_WARNING "scsi(%li): Unable to set a " "suitable DMA mask - aborting\n", ha->host_no); error = -ENODEV; - goto error_put_host; + goto error_free_irq; } #endif diff --git a/trunk/drivers/scsi/qla1280.h b/trunk/drivers/scsi/qla1280.h index ff2c363ead26..59915fb70301 100644 --- a/trunk/drivers/scsi/qla1280.h +++ b/trunk/drivers/scsi/qla1280.h @@ -91,8 +91,8 @@ #define INVALID_HANDLE (MAX_OUTSTANDING_COMMANDS + 2) /* ISP request and response entry counts (37-65535) */ -#define REQUEST_ENTRY_CNT 255 /* Number of request entries. */ -#define RESPONSE_ENTRY_CNT 63 /* Number of response entries. */ +#define REQUEST_ENTRY_CNT 256 /* Number of request entries. */ +#define RESPONSE_ENTRY_CNT 16 /* Number of response entries. */ /* * SCSI Request Block structure (sp) that is placed diff --git a/trunk/drivers/scsi/qla2xxx/qla_attr.c b/trunk/drivers/scsi/qla2xxx/qla_attr.c index fb388b8c07cf..05fa7796a559 100644 --- a/trunk/drivers/scsi/qla2xxx/qla_attr.c +++ b/trunk/drivers/scsi/qla2xxx/qla_attr.c @@ -114,6 +114,7 @@ qla2x00_sysfs_write_nvram(struct kobject *kobj, { struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, struct device, kobj))); + unsigned long flags; uint16_t cnt; if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size) @@ -143,9 +144,11 @@ qla2x00_sysfs_write_nvram(struct kobject *kobj, } /* Write NVRAM. */ + spin_lock_irqsave(&ha->hardware_lock, flags); ha->isp_ops->write_nvram(ha, (uint8_t *)buf, ha->nvram_base, count); ha->isp_ops->read_nvram(ha, (uint8_t *)ha->nvram, ha->nvram_base, count); + spin_unlock_irqrestore(&ha->hardware_lock, flags); set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); @@ -394,13 +397,16 @@ qla2x00_sysfs_write_vpd(struct kobject *kobj, { struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, struct device, kobj))); + unsigned long flags; if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->vpd_size) return 0; /* Write NVRAM. */ + spin_lock_irqsave(&ha->hardware_lock, flags); ha->isp_ops->write_nvram(ha, (uint8_t *)buf, ha->vpd_base, count); ha->isp_ops->read_nvram(ha, (uint8_t *)ha->vpd, ha->vpd_base, count); + spin_unlock_irqrestore(&ha->hardware_lock, flags); return count; } @@ -538,9 +544,6 @@ qla2x00_serial_num_show(struct class_device *cdev, char *buf) scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev)); uint32_t sn; - if (IS_FWI2_CAPABLE(ha)) - return snprintf(buf, PAGE_SIZE, "\n"); - sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1; return snprintf(buf, PAGE_SIZE, "%c%05d\n", 'A' + sn / 100000, sn % 100000); diff --git a/trunk/drivers/scsi/qla2xxx/qla_def.h b/trunk/drivers/scsi/qla2xxx/qla_def.h index 04e8cbca4c0d..1900fbf6cd74 100644 --- a/trunk/drivers/scsi/qla2xxx/qla_def.h +++ b/trunk/drivers/scsi/qla2xxx/qla_def.h @@ -2271,7 +2271,6 @@ typedef struct scsi_qla_host { spinlock_t hardware_lock ____cacheline_aligned; - int bars; device_reg_t __iomem *iobase; /* Base I/O address */ unsigned long pio_address; unsigned long pio_length; diff --git a/trunk/drivers/scsi/qla2xxx/qla_devtbl.h b/trunk/drivers/scsi/qla2xxx/qla_devtbl.h index d78d35e681ab..dd435410dfa2 100644 --- a/trunk/drivers/scsi/qla2xxx/qla_devtbl.h +++ b/trunk/drivers/scsi/qla2xxx/qla_devtbl.h @@ -1,4 +1,4 @@ -#define QLA_MODEL_NAMES 0x5C +#define QLA_MODEL_NAMES 0x57 /* * Adapter model names and descriptions. @@ -91,9 +91,4 @@ static char *qla2x00_model_name[QLA_MODEL_NAMES*2] = { " ", " ", /* 0x154 */ "QLE220", "PCI-Express to 4Gb FC, Single Channel", /* 0x155 */ "QLE220", "PCI-Express to 4Gb FC, Single Channel", /* 0x156 */ - " ", " ", /* 0x157 */ - " ", " ", /* 0x158 */ - " ", " ", /* 0x159 */ - " ", " ", /* 0x15a */ - "QME2472", "Dell BS PCI-Express to 4Gb FC, Dual Channel", /* 0x15b */ }; diff --git a/trunk/drivers/scsi/qla2xxx/qla_iocb.c b/trunk/drivers/scsi/qla2xxx/qla_iocb.c index 024c662ec34d..7f6a89bd94f3 100644 --- a/trunk/drivers/scsi/qla2xxx/qla_iocb.c +++ b/trunk/drivers/scsi/qla2xxx/qla_iocb.c @@ -525,7 +525,7 @@ qla2x00_req_pkt(scsi_qla_host_t *ha) /* Check for pending interrupts. */ /* During init we issue marker directly */ - if (!ha->marker_needed && !ha->flags.init_done) + if (!ha->marker_needed) qla2x00_poll(ha); spin_lock_irq(&ha->hardware_lock); diff --git a/trunk/drivers/scsi/qla2xxx/qla_isr.c b/trunk/drivers/scsi/qla2xxx/qla_isr.c index 1104bd2eed40..c4768c4f3990 100644 --- a/trunk/drivers/scsi/qla2xxx/qla_isr.c +++ b/trunk/drivers/scsi/qla2xxx/qla_isr.c @@ -1012,14 +1012,8 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt) case CS_DATA_UNDERRUN: resid = resid_len; /* Use F/W calculated residual length. */ - if (IS_FWI2_CAPABLE(ha)) { - if (scsi_status & SS_RESIDUAL_UNDER && - resid != fw_resid_len) { - scsi_status &= ~SS_RESIDUAL_UNDER; - lscsi_status = 0; - } + if (IS_FWI2_CAPABLE(ha)) resid = fw_resid_len; - } if (scsi_status & SS_RESIDUAL_UNDER) { scsi_set_resid(cp, resid); diff --git a/trunk/drivers/scsi/qla2xxx/qla_mbx.c b/trunk/drivers/scsi/qla2xxx/qla_mbx.c index ccd662a6f5dc..c53ec67c47f4 100644 --- a/trunk/drivers/scsi/qla2xxx/qla_mbx.c +++ b/trunk/drivers/scsi/qla2xxx/qla_mbx.c @@ -252,7 +252,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp) /* Clean up */ ha->mcp = NULL; - if (abort_active || !io_lock_on) { + if (!abort_active) { DEBUG11(printk("%s(%ld): checking for additional resp " "interrupt.\n", __func__, ha->host_no)); diff --git a/trunk/drivers/scsi/qla2xxx/qla_os.c b/trunk/drivers/scsi/qla2xxx/qla_os.c index a5bcf1f390b3..0351d380c2d7 100644 --- a/trunk/drivers/scsi/qla2xxx/qla_os.c +++ b/trunk/drivers/scsi/qla2xxx/qla_os.c @@ -1482,17 +1482,6 @@ qla2x00_iospace_config(scsi_qla_host_t *ha) unsigned long pio, pio_len, pio_flags; unsigned long mmio, mmio_len, mmio_flags; - if (pci_request_selected_regions(ha->pdev, ha->bars, - QLA2XXX_DRIVER_NAME)) { - qla_printk(KERN_WARNING, ha, - "Failed to reserve PIO/MMIO regions (%s)\n", - pci_name(ha->pdev)); - - goto iospace_error_exit; - } - if (!(ha->bars & 1)) - goto skip_pio; - /* We only need PIO for Flash operations on ISP2312 v2 chips. */ pio = pci_resource_start(ha->pdev, 0); pio_len = pci_resource_len(ha->pdev, 0); @@ -1510,10 +1499,7 @@ qla2x00_iospace_config(scsi_qla_host_t *ha) pci_name(ha->pdev)); pio = 0; } - ha->pio_address = pio; - ha->pio_length = pio_len; -skip_pio: /* Use MMIO operations for all accesses. */ mmio = pci_resource_start(ha->pdev, 1); mmio_len = pci_resource_len(ha->pdev, 1); @@ -1532,6 +1518,16 @@ qla2x00_iospace_config(scsi_qla_host_t *ha) goto iospace_error_exit; } + if (pci_request_regions(ha->pdev, QLA2XXX_DRIVER_NAME)) { + qla_printk(KERN_WARNING, ha, + "Failed to reserve PIO/MMIO regions (%s)\n", + pci_name(ha->pdev)); + + goto iospace_error_exit; + } + + ha->pio_address = pio; + ha->pio_length = pio_len; ha->iobase = ioremap(mmio, MIN_IOBASE_LEN); if (!ha->iobase) { qla_printk(KERN_ERR, ha, @@ -1583,26 +1579,21 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) char pci_info[30]; char fw_str[30]; struct scsi_host_template *sht; - int bars; - - bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO); - sht = &qla2x00_driver_template; - if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || - pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 || - pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || - pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 || - pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532) { - bars = pci_select_bars(pdev, IORESOURCE_MEM); - sht = &qla24xx_driver_template; - } - if (pci_enable_device_bars(pdev, bars)) + if (pci_enable_device(pdev)) goto probe_out; if (pci_find_aer_capability(pdev)) if (pci_enable_pcie_error_reporting(pdev)) goto probe_out; + sht = &qla2x00_driver_template; + if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || + pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 || + pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || + pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 || + pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532) + sht = &qla24xx_driver_template; host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t)); if (host == NULL) { printk(KERN_WARNING @@ -1619,7 +1610,6 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) ha->host_no = host->host_no; sprintf(ha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, ha->host_no); ha->parent = NULL; - ha->bars = bars; /* Set ISP-type information. */ qla2x00_set_isp_flags(ha); @@ -1890,7 +1880,7 @@ qla2x00_free_device(scsi_qla_host_t *ha) /* release io space registers */ if (ha->iobase) iounmap(ha->iobase); - pci_release_selected_regions(ha->pdev, ha->bars); + pci_release_regions(ha->pdev); } static inline void @@ -2900,7 +2890,7 @@ qla2xxx_pci_slot_reset(struct pci_dev *pdev) pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT; scsi_qla_host_t *ha = pci_get_drvdata(pdev); - if (pci_enable_device_bars(pdev, ha->bars)) { + if (pci_enable_device(pdev)) { qla_printk(KERN_WARNING, ha, "Can't re-enable PCI device after reset.\n"); diff --git a/trunk/drivers/scsi/qla2xxx/qla_sup.c b/trunk/drivers/scsi/qla2xxx/qla_sup.c index ad2fa01bd233..40b059fc1981 100644 --- a/trunk/drivers/scsi/qla2xxx/qla_sup.c +++ b/trunk/drivers/scsi/qla2xxx/qla_sup.c @@ -7,7 +7,6 @@ #include "qla_def.h" #include -#include #include static uint16_t qla2x00_nvram_request(scsi_qla_host_t *, uint32_t); @@ -643,7 +642,7 @@ qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr, } /* Go with burst-write. */ - if (optrom && (liter + OPTROM_BURST_DWORDS) <= dwords) { + if (optrom && (liter + OPTROM_BURST_DWORDS) < dwords) { /* Copy data to DMA'ble buffer. */ for (miter = 0, s = optrom, d = dwptr; miter < OPTROM_BURST_DWORDS; miter++, s++, d++) @@ -657,7 +656,7 @@ qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr, "Unable to burst-write optrom segment " "(%x/%x/%llx).\n", ret, flash_data_to_access_addr(faddr), - (unsigned long long)optrom_dma); + optrom_dma); qla_printk(KERN_WARNING, ha, "Reverting to slow-write.\n"); @@ -746,11 +745,9 @@ qla2x00_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, int ret, stat; uint32_t i; uint16_t *wptr; - unsigned long flags; ret = QLA_SUCCESS; - spin_lock_irqsave(&ha->hardware_lock, flags); qla2x00_lock_nvram_access(ha); /* Disable NVRAM write-protection. */ @@ -767,7 +764,6 @@ qla2x00_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, qla2x00_set_nvram_protection(ha, stat); qla2x00_unlock_nvram_access(ha); - spin_unlock_irqrestore(&ha->hardware_lock, flags); return ret; } @@ -780,11 +776,9 @@ qla24xx_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, uint32_t i; uint32_t *dwptr; struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; - unsigned long flags; ret = QLA_SUCCESS; - spin_lock_irqsave(&ha->hardware_lock, flags); /* Enable flash write. */ WRT_REG_DWORD(®->ctrl_status, RD_REG_DWORD(®->ctrl_status) | CSRX_FLASH_ENABLE); @@ -818,7 +812,6 @@ qla24xx_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, WRT_REG_DWORD(®->ctrl_status, RD_REG_DWORD(®->ctrl_status) & ~CSRX_FLASH_ENABLE); RD_REG_DWORD(®->ctrl_status); /* PCI Posting. */ - spin_unlock_irqrestore(&ha->hardware_lock, flags); return ret; } @@ -843,20 +836,8 @@ int qla25xx_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, uint32_t bytes) { -#define RMW_BUFFER_SIZE (64 * 1024) - uint8_t *dbuf; - - dbuf = vmalloc(RMW_BUFFER_SIZE); - if (!dbuf) - return QLA_MEMORY_ALLOC_FAILED; - ha->isp_ops->read_optrom(ha, dbuf, FA_VPD_NVRAM_ADDR << 2, - RMW_BUFFER_SIZE); - memcpy(dbuf + (naddr << 2), buf, bytes); - ha->isp_ops->write_optrom(ha, dbuf, FA_VPD_NVRAM_ADDR << 2, - RMW_BUFFER_SIZE); - vfree(dbuf); - - return QLA_SUCCESS; + return qla24xx_write_flash_data(ha, (uint32_t *)buf, + FA_VPD_NVRAM_ADDR | naddr, bytes >> 2); } static inline void @@ -1872,8 +1853,7 @@ qla25xx_read_optrom_data(struct scsi_qla_host *ha, uint8_t *buf, qla_printk(KERN_WARNING, ha, "Unable to burst-read optrom segment " "(%x/%x/%llx).\n", rval, - flash_data_to_access_addr(faddr), - (unsigned long long)optrom_dma); + flash_data_to_access_addr(faddr), optrom_dma); qla_printk(KERN_WARNING, ha, "Reverting to slow-read.\n"); diff --git a/trunk/drivers/scsi/qla2xxx/qla_version.h b/trunk/drivers/scsi/qla2xxx/qla_version.h index ae6f7a2fb19f..2d551a3006f6 100644 --- a/trunk/drivers/scsi/qla2xxx/qla_version.h +++ b/trunk/drivers/scsi/qla2xxx/qla_version.h @@ -7,7 +7,7 @@ /* * Driver version */ -#define QLA2XXX_VERSION "8.02.00-k5" +#define QLA2XXX_VERSION "8.02.00-k4" #define QLA_DRIVER_MAJOR_VER 8 #define QLA_DRIVER_MINOR_VER 2 diff --git a/trunk/drivers/scsi/scsi_error.c b/trunk/drivers/scsi/scsi_error.c index ebaca4ca4a13..d29f8464b74f 100644 --- a/trunk/drivers/scsi/scsi_error.c +++ b/trunk/drivers/scsi/scsi_error.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include diff --git a/trunk/drivers/scsi/scsi_sysfs.c b/trunk/drivers/scsi/scsi_sysfs.c index d531ceeb0d8c..daed37df00b1 100644 --- a/trunk/drivers/scsi/scsi_sysfs.c +++ b/trunk/drivers/scsi/scsi_sysfs.c @@ -209,13 +209,11 @@ show_shost_mode(unsigned int mode, char *buf) static ssize_t show_shost_supported_mode(struct class_device *class_dev, char *buf) { struct Scsi_Host *shost = class_to_shost(class_dev); - unsigned int supported_mode = shost->hostt->supported_mode; - if (supported_mode == MODE_UNKNOWN) - /* by default this should be initiator */ - supported_mode = MODE_INITIATOR; - - return show_shost_mode(supported_mode, buf); + if (shost->hostt->supported_mode == MODE_UNKNOWN) + return snprintf(buf, 20, "unknown\n"); + else + return show_shost_mode(shost->hostt->supported_mode, buf); } static CLASS_DEVICE_ATTR(supported_mode, S_IRUGO | S_IWUSR, show_shost_supported_mode, NULL); diff --git a/trunk/drivers/scsi/sg.c b/trunk/drivers/scsi/sg.c index f1871ea04045..cc1971002846 100644 --- a/trunk/drivers/scsi/sg.c +++ b/trunk/drivers/scsi/sg.c @@ -1652,7 +1652,6 @@ sg_build_sgat(Sg_scatter_hold * schp, const Sg_fd * sfp, int tablesize) schp->buffer = kzalloc(sg_bufflen, gfp_flags); if (!schp->buffer) return -ENOMEM; - sg_init_table(schp->buffer, tablesize); schp->sglist_len = sg_bufflen; return tablesize; /* number of scat_gath elements allocated */ } @@ -1718,12 +1717,16 @@ st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages, goto out_unlock; */ } - sg_set_page(sgl, pages[0], 0, uaddr & ~PAGE_MASK); + sg_set_page(sgl, pages[0]); + sgl[0].offset = uaddr & ~PAGE_MASK; if (nr_pages > 1) { sgl[0].length = PAGE_SIZE - sgl[0].offset; count -= sgl[0].length; - for (i=1; i < nr_pages ; i++) - sg_set_page(&sgl[i], pages[i], count < PAGE_SIZE ? count : PAGE_SIZE, 0); + for (i=1; i < nr_pages ; i++) { + sg_set_page(&sgl[i], pages[i]); + sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE; + count -= PAGE_SIZE; + } } else { sgl[0].length = count; @@ -1851,7 +1854,8 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) scatter_elem_sz_prev = ret_sz; } } - sg_set_page(sg, p, (ret_sz > num) ? num : ret_sz, 0); + sg_set_page(sg, p); + sg->length = (ret_sz > num) ? num : ret_sz; SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, " "ret_sz=%d\n", k, num, ret_sz)); diff --git a/trunk/drivers/scsi/st.c b/trunk/drivers/scsi/st.c index 98dfd6ea209c..ce69b9efc102 100644 --- a/trunk/drivers/scsi/st.c +++ b/trunk/drivers/scsi/st.c @@ -3797,11 +3797,13 @@ static void buf_to_sg(struct st_buffer *STbp, unsigned int length) sg = &(STbp->sg[0]); frp = STbp->frp; for (i=count=0; count < length; i++) { + sg_set_page(&sg[i], frp[i].page); if (length - count > frp[i].length) - sg_set_page(&sg[i], frp[i].page, frp[i].length, 0); + sg[i].length = frp[i].length; else - sg_set_page(&sg[i], frp[i].page, length - count, 0); + sg[i].length = length - count; count += sg[i].length; + sg[i].offset = 0; } STbp->sg_segs = i; STbp->frp_sg_current = length; @@ -4444,13 +4446,15 @@ static int sgl_map_user_pages(struct scatterlist *sgl, const unsigned int max_pa } /* Populate the scatter/gather list */ - sg_set_page(&sgl[0], pages[0], 0, uaddr & ~PAGE_MASK); + sg_set_page(&sgl[0], pages[0]); + sgl[0].offset = uaddr & ~PAGE_MASK; if (nr_pages > 1) { sgl[0].length = PAGE_SIZE - sgl[0].offset; count -= sgl[0].length; for (i=1; i < nr_pages ; i++) { - sg_set_page(&sgl[i], pages[i], - count < PAGE_SIZE ? count : PAGE_SIZE, 0);; + sg_set_page(&sgl[i], pages[i]);; + sgl[i].offset = 0; + sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE; count -= PAGE_SIZE; } } diff --git a/trunk/drivers/scsi/sun3x_esp.c b/trunk/drivers/scsi/sun3x_esp.c index 1bc41907a038..80fb3f88af2e 100644 --- a/trunk/drivers/scsi/sun3x_esp.c +++ b/trunk/drivers/scsi/sun3x_esp.c @@ -332,8 +332,8 @@ static void dma_mmu_get_scsi_sgl (struct NCR_ESP *esp, Scsi_Cmnd *sp) struct scatterlist *sg = sp->SCp.buffer; while (sz >= 0) { - sg[sz].dma_address = dvma_map((unsigned long)sg_virt(&sg[sz]), - sg[sz].length); + sg[sz].dma_address = dvma_map((unsigned long)page_address(sg[sz].page) + + sg[sz].offset, sg[sz].length); sz--; } sp->SCp.ptr=(char *)((unsigned long)sp->SCp.buffer->dma_address); diff --git a/trunk/drivers/scsi/sym53c8xx_2/sym53c8xx.h b/trunk/drivers/scsi/sym53c8xx_2/sym53c8xx.h index 62d29cfac9e4..7519728dfc38 100644 --- a/trunk/drivers/scsi/sym53c8xx_2/sym53c8xx.h +++ b/trunk/drivers/scsi/sym53c8xx_2/sym53c8xx.h @@ -127,6 +127,7 @@ struct sym_driver_setup { u_char settle_delay; u_char use_nvram; u_long excludes[8]; + char tag_ctrl[100]; }; #define SYM_SETUP_MAX_TAG sym_driver_setup.max_tag diff --git a/trunk/drivers/scsi/sym53c8xx_2/sym_fw.c b/trunk/drivers/scsi/sym53c8xx_2/sym_fw.c index 190770bdc194..9916a2a22558 100644 --- a/trunk/drivers/scsi/sym53c8xx_2/sym_fw.c +++ b/trunk/drivers/scsi/sym53c8xx_2/sym_fw.c @@ -104,9 +104,8 @@ static struct sym_fwz_ofs sym_fw2z_ofs = { * Patch routine for firmware #1. */ static void -sym_fw1_patch(struct Scsi_Host *shost) +sym_fw1_patch(struct sym_hcb *np) { - struct sym_hcb *np = sym_get_hcb(shost); struct sym_fw1a_scr *scripta0; struct sym_fw1b_scr *scriptb0; @@ -146,11 +145,8 @@ sym_fw1_patch(struct Scsi_Host *shost) * Patch routine for firmware #2. */ static void -sym_fw2_patch(struct Scsi_Host *shost) +sym_fw2_patch(struct sym_hcb *np) { - struct sym_data *sym_data = shost_priv(shost); - struct pci_dev *pdev = sym_data->pdev; - struct sym_hcb *np = sym_data->ncb; struct sym_fw2a_scr *scripta0; struct sym_fw2b_scr *scriptb0; @@ -171,7 +167,7 @@ sym_fw2_patch(struct Scsi_Host *shost) * Remove useless 64 bit DMA specific SCRIPTS, * when this feature is not available. */ - if (!use_dac(np)) { + if (!np->use_dac) { scripta0->is_dmap_dirty[0] = cpu_to_scr(SCR_NO_OP); scripta0->is_dmap_dirty[1] = 0; scripta0->is_dmap_dirty[2] = cpu_to_scr(SCR_NO_OP); @@ -209,14 +205,14 @@ sym_fw2_patch(struct Scsi_Host *shost) * Remove a couple of work-arounds specific to C1010 if * they are not desirable. See `sym_fw2.h' for more details. */ - if (!(pdev->device == PCI_DEVICE_ID_LSI_53C1010_66 && - pdev->revision < 0x1 && + if (!(np->device_id == PCI_DEVICE_ID_LSI_53C1010_66 && + np->revision_id < 0x1 && np->pciclk_khz < 60000)) { scripta0->datao_phase[0] = cpu_to_scr(SCR_NO_OP); scripta0->datao_phase[1] = cpu_to_scr(0); } - if (!(pdev->device == PCI_DEVICE_ID_LSI_53C1010_33 /* && - pdev->revision < 0xff */)) { + if (!(np->device_id == PCI_DEVICE_ID_LSI_53C1010_33 && + /* np->revision_id < 0xff */ 1)) { scripta0->sel_done[0] = cpu_to_scr(SCR_NO_OP); scripta0->sel_done[1] = cpu_to_scr(0); } diff --git a/trunk/drivers/scsi/sym53c8xx_2/sym_fw.h b/trunk/drivers/scsi/sym53c8xx_2/sym_fw.h index ae7e0f9e93fc..66ec35beab5b 100644 --- a/trunk/drivers/scsi/sym53c8xx_2/sym_fw.h +++ b/trunk/drivers/scsi/sym53c8xx_2/sym_fw.h @@ -143,7 +143,7 @@ struct sym_fw { *z_ofs; /* Useful offsets in script Z */ /* Setup and patch methods for this firmware */ void (*setup)(struct sym_hcb *, struct sym_fw *); - void (*patch)(struct Scsi_Host *); + void (*patch)(struct sym_hcb *); }; /* diff --git a/trunk/drivers/scsi/sym53c8xx_2/sym_glue.c b/trunk/drivers/scsi/sym53c8xx_2/sym_glue.c index 0f74aba5b237..db03c4c8ec1e 100644 --- a/trunk/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/trunk/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -39,6 +39,7 @@ */ #include #include +#include #include #include #include @@ -53,12 +54,16 @@ #define NAME53C "sym53c" #define NAME53C8XX "sym53c8xx" +#define IRQ_FMT "%d" +#define IRQ_PRM(x) (x) + struct sym_driver_setup sym_driver_setup = SYM_LINUX_DRIVER_SETUP; unsigned int sym_debug_flags = 0; static char *excl_string; static char *safe_string; module_param_named(cmd_per_lun, sym_driver_setup.max_tag, ushort, 0); +module_param_string(tag_ctrl, sym_driver_setup.tag_ctrl, 100, 0); module_param_named(burst, sym_driver_setup.burst_order, byte, 0); module_param_named(led, sym_driver_setup.scsi_led, byte, 0); module_param_named(diff, sym_driver_setup.scsi_diff, byte, 0); @@ -73,6 +78,7 @@ module_param_named(excl, excl_string, charp, 0); module_param_named(safe, safe_string, charp, 0); MODULE_PARM_DESC(cmd_per_lun, "The maximum number of tags to use by default"); +MODULE_PARM_DESC(tag_ctrl, "More detailed control over tags per LUN"); MODULE_PARM_DESC(burst, "Maximum burst. 0 to disable, 255 to read from registers"); MODULE_PARM_DESC(led, "Set to 1 to enable LED support"); MODULE_PARM_DESC(diff, "0 for no differential mode, 1 for BIOS, 2 for always, 3 for not GPIO3"); @@ -128,27 +134,57 @@ static struct scsi_transport_template *sym2_transport_template = NULL; * Driver private area in the SCSI command structure. */ struct sym_ucmd { /* Override the SCSI pointer structure */ - struct completion *eh_done; /* SCSI error handling */ + dma_addr_t data_mapping; + unsigned char data_mapped; + unsigned char to_do; /* For error handling */ + void (*old_done)(struct scsi_cmnd *); /* For error handling */ + struct completion *eh_done; /* For error handling */ }; #define SYM_UCMD_PTR(cmd) ((struct sym_ucmd *)(&(cmd)->SCp)) #define SYM_SOFTC_PTR(cmd) sym_get_hcb(cmd->device->host) +static void __unmap_scsi_data(struct pci_dev *pdev, struct scsi_cmnd *cmd) +{ + if (SYM_UCMD_PTR(cmd)->data_mapped) + scsi_dma_unmap(cmd); + + SYM_UCMD_PTR(cmd)->data_mapped = 0; +} + +static int __map_scsi_sg_data(struct pci_dev *pdev, struct scsi_cmnd *cmd) +{ + int use_sg; + + use_sg = scsi_dma_map(cmd); + if (use_sg > 0) { + SYM_UCMD_PTR(cmd)->data_mapped = 2; + SYM_UCMD_PTR(cmd)->data_mapping = use_sg; + } + + return use_sg; +} + +#define unmap_scsi_data(np, cmd) \ + __unmap_scsi_data(np->s.device, cmd) +#define map_scsi_sg_data(np, cmd) \ + __map_scsi_sg_data(np->s.device, cmd) /* * Complete a pending CAM CCB. */ void sym_xpt_done(struct sym_hcb *np, struct scsi_cmnd *cmd) { - struct sym_ucmd *ucmd = SYM_UCMD_PTR(cmd); - BUILD_BUG_ON(sizeof(struct scsi_pointer) < sizeof(struct sym_ucmd)); - - if (ucmd->eh_done) - complete(ucmd->eh_done); - - scsi_dma_unmap(cmd); + unmap_scsi_data(np, cmd); cmd->scsi_done(cmd); } +static void sym_xpt_done2(struct sym_hcb *np, struct scsi_cmnd *cmd, int cam_status) +{ + sym_set_cam_status(cmd, cam_status); + sym_xpt_done(np, cmd); +} + + /* * Tell the SCSI layer about a BUS RESET. */ @@ -162,6 +198,14 @@ void sym_xpt_async_bus_reset(struct sym_hcb *np) sym_name(np), sym_driver_setup.settle_delay); } +/* + * Tell the SCSI layer about a BUS DEVICE RESET message sent. + */ +void sym_xpt_async_sent_bdr(struct sym_hcb *np, int target) +{ + printf_notice("%s: TARGET %d has been reset.\n", sym_name(np), target); +} + /* * Choose the more appropriate CAM status if * the IO encountered an extended error. @@ -263,14 +307,14 @@ static int sym_scatter(struct sym_hcb *np, struct sym_ccb *cp, struct scsi_cmnd cp->data_len = 0; - use_sg = scsi_dma_map(cmd); + use_sg = map_scsi_sg_data(np, cmd); if (use_sg > 0) { struct scatterlist *sg; struct sym_tcb *tp = &np->target[cp->target]; struct sym_tblmove *data; if (use_sg > SYM_CONF_MAX_SG) { - scsi_dma_unmap(cmd); + unmap_scsi_data(np, cmd); return -1; } @@ -306,6 +350,15 @@ static int sym_queue_command(struct sym_hcb *np, struct scsi_cmnd *cmd) struct sym_ccb *cp; int order; + /* + * Minimal checkings, so that we will not + * go outside our tables. + */ + if (sdev->id == np->myaddr) { + sym_xpt_done2(np, cmd, DID_NO_CONNECT); + return 0; + } + /* * Retrieve the target descriptor. */ @@ -380,7 +433,7 @@ int sym_setup_data_and_start(struct sym_hcb *np, struct scsi_cmnd *cmd, struct s */ switch (dir) { case DMA_BIDIRECTIONAL: - scmd_printk(KERN_INFO, cmd, "got DMA_BIDIRECTIONAL command"); + printk("%s: got DMA_BIDIRECTIONAL command", sym_name(np)); sym_set_cam_status(cmd, DID_ERROR); goto out_abort; case DMA_TO_DEVICE: @@ -489,16 +542,14 @@ static void sym_timer(struct sym_hcb *np) /* * PCI BUS error handler. */ -void sym_log_bus_error(struct Scsi_Host *shost) +void sym_log_bus_error(struct sym_hcb *np) { - struct sym_data *sym_data = shost_priv(shost); - struct pci_dev *pdev = sym_data->pdev; - unsigned short pci_sts; - pci_read_config_word(pdev, PCI_STATUS, &pci_sts); + u_short pci_sts; + pci_read_config_word(np->s.device, PCI_STATUS, &pci_sts); if (pci_sts & 0xf900) { - pci_write_config_word(pdev, PCI_STATUS, pci_sts); - shost_printk(KERN_WARNING, shost, - "PCI bus error: status = 0x%04x\n", pci_sts & 0xf900); + pci_write_config_word(np->s.device, PCI_STATUS, pci_sts); + printf("%s: PCI STATUS = 0x%04x\n", + sym_name(np), pci_sts & 0xf900); } } @@ -513,7 +564,7 @@ static int sym53c8xx_queue_command(struct scsi_cmnd *cmd, struct sym_ucmd *ucp = SYM_UCMD_PTR(cmd); int sts = 0; - cmd->scsi_done = done; + cmd->scsi_done = done; memset(ucp, 0, sizeof(*ucp)); /* @@ -542,23 +593,18 @@ static int sym53c8xx_queue_command(struct scsi_cmnd *cmd, */ static irqreturn_t sym53c8xx_intr(int irq, void *dev_id) { - struct Scsi_Host *shost = dev_id; - struct sym_data *sym_data = shost_priv(shost); - irqreturn_t result; - - /* Avoid spinloop trying to handle interrupts on frozen device */ - if (pci_channel_offline(sym_data->pdev)) - return IRQ_NONE; + unsigned long flags; + struct sym_hcb *np = (struct sym_hcb *)dev_id; if (DEBUG_FLAGS & DEBUG_TINY) printf_debug ("["); - spin_lock(shost->host_lock); - result = sym_interrupt(shost); - spin_unlock(shost->host_lock); + spin_lock_irqsave(np->s.host->host_lock, flags); + sym_interrupt(np); + spin_unlock_irqrestore(np->s.host->host_lock, flags); if (DEBUG_FLAGS & DEBUG_TINY) printf_debug ("]\n"); - return result; + return IRQ_HANDLED; } /* @@ -583,62 +629,60 @@ static void sym53c8xx_timer(unsigned long npref) #define SYM_EH_BUS_RESET 2 #define SYM_EH_HOST_RESET 3 +/* + * What we will do regarding the involved SCSI command. + */ +#define SYM_EH_DO_IGNORE 0 +#define SYM_EH_DO_WAIT 2 + +/* + * scsi_done() alias when error recovery is in progress. + */ +static void sym_eh_done(struct scsi_cmnd *cmd) +{ + struct sym_ucmd *ucmd = SYM_UCMD_PTR(cmd); + BUILD_BUG_ON(sizeof(struct scsi_pointer) < sizeof(struct sym_ucmd)); + + cmd->scsi_done = ucmd->old_done; + + if (ucmd->to_do == SYM_EH_DO_WAIT) + complete(ucmd->eh_done); +} + /* * Generic method for our eh processing. * The 'op' argument tells what we have to do. */ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) { + struct sym_hcb *np = SYM_SOFTC_PTR(cmd); struct sym_ucmd *ucmd = SYM_UCMD_PTR(cmd); - struct Scsi_Host *shost = cmd->device->host; - struct sym_data *sym_data = shost_priv(shost); - struct pci_dev *pdev = sym_data->pdev; - struct sym_hcb *np = sym_data->ncb; + struct Scsi_Host *host = cmd->device->host; SYM_QUEHEAD *qp; - int cmd_queued = 0; + int to_do = SYM_EH_DO_IGNORE; int sts = -1; struct completion eh_done; - scmd_printk(KERN_WARNING, cmd, "%s operation started\n", opname); - - /* We may be in an error condition because the PCI bus - * went down. In this case, we need to wait until the - * PCI bus is reset, the card is reset, and only then - * proceed with the scsi error recovery. There's no - * point in hurrying; take a leisurely wait. - */ -#define WAIT_FOR_PCI_RECOVERY 35 - if (pci_channel_offline(pdev)) { - struct completion *io_reset; - int finished_reset = 0; - init_completion(&eh_done); - spin_lock_irq(shost->host_lock); - /* Make sure we didn't race */ - if (pci_channel_offline(pdev)) { - if (!sym_data->io_reset) - sym_data->io_reset = &eh_done; - io_reset = sym_data->io_reset; - } else { - finished_reset = 1; - } - spin_unlock_irq(shost->host_lock); - if (!finished_reset) - finished_reset = wait_for_completion_timeout(io_reset, - WAIT_FOR_PCI_RECOVERY*HZ); - if (!finished_reset) - return SCSI_FAILED; - } + dev_warn(&cmd->device->sdev_gendev, "%s operation started.\n", opname); - spin_lock_irq(shost->host_lock); + spin_lock_irq(host->host_lock); /* This one is queued in some place -> to wait for completion */ FOR_EACH_QUEUED_ELEMENT(&np->busy_ccbq, qp) { struct sym_ccb *cp = sym_que_entry(qp, struct sym_ccb, link_ccbq); if (cp->cmd == cmd) { - cmd_queued = 1; + to_do = SYM_EH_DO_WAIT; break; } } + if (to_do == SYM_EH_DO_WAIT) { + init_completion(&eh_done); + ucmd->old_done = cmd->scsi_done; + ucmd->eh_done = &eh_done; + wmb(); + cmd->scsi_done = sym_eh_done; + } + /* Try to proceed the operation we have been asked for */ sts = -1; switch(op) { @@ -654,7 +698,7 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) break; case SYM_EH_HOST_RESET: sym_reset_scsi_bus(np, 0); - sym_start_up(shost, 1); + sym_start_up (np, 1); sts = 0; break; default: @@ -662,21 +706,21 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) } /* On error, restore everything and cross fingers :) */ - if (sts) - cmd_queued = 0; + if (sts) { + cmd->scsi_done = ucmd->old_done; + to_do = SYM_EH_DO_IGNORE; + } - if (cmd_queued) { - init_completion(&eh_done); - ucmd->eh_done = &eh_done; - spin_unlock_irq(shost->host_lock); + ucmd->to_do = to_do; + spin_unlock_irq(host->host_lock); + + if (to_do == SYM_EH_DO_WAIT) { if (!wait_for_completion_timeout(&eh_done, 5*HZ)) { - ucmd->eh_done = NULL; + ucmd->to_do = SYM_EH_DO_IGNORE; + wmb(); sts = -2; } - } else { - spin_unlock_irq(shost->host_lock); } - dev_warn(&cmd->device->sdev_gendev, "%s operation %s.\n", opname, sts==0 ? "complete" :sts==-2 ? "timed-out" : "failed"); return sts ? SCSI_FAILED : SCSI_SUCCESS; @@ -731,6 +775,59 @@ static void sym_tune_dev_queuing(struct sym_tcb *tp, int lun, u_short reqtags) } } +/* + * Linux select queue depths function + */ +#define DEF_DEPTH (sym_driver_setup.max_tag) +#define ALL_TARGETS -2 +#define NO_TARGET -1 +#define ALL_LUNS -2 +#define NO_LUN -1 + +static int device_queue_depth(struct sym_hcb *np, int target, int lun) +{ + int c, h, t, u, v; + char *p = sym_driver_setup.tag_ctrl; + char *ep; + + h = -1; + t = NO_TARGET; + u = NO_LUN; + while ((c = *p++) != 0) { + v = simple_strtoul(p, &ep, 0); + switch(c) { + case '/': + ++h; + t = ALL_TARGETS; + u = ALL_LUNS; + break; + case 't': + if (t != target) + t = (target == v) ? v : NO_TARGET; + u = ALL_LUNS; + break; + case 'u': + if (u != lun) + u = (lun == v) ? v : NO_LUN; + break; + case 'q': + if (h == np->s.unit && + (t == ALL_TARGETS || t == target) && + (u == ALL_LUNS || u == lun)) + return v; + break; + case '-': + t = ALL_TARGETS; + u = ALL_LUNS; + break; + default: + break; + } + p = ep; + } + return DEF_DEPTH; +} + static int sym53c8xx_slave_alloc(struct scsi_device *sdev) { struct sym_hcb *np = sym_get_hcb(sdev->host); @@ -795,16 +892,21 @@ static int sym53c8xx_slave_configure(struct scsi_device *sdev) * Use at least 2. * Donnot use more than our maximum. */ - reqtags = sym_driver_setup.max_tag; + reqtags = device_queue_depth(np, sdev->id, sdev->lun); if (reqtags > tp->usrtags) reqtags = tp->usrtags; if (!sdev->tagged_supported) reqtags = 0; +#if 1 /* Avoid to locally queue commands for no good reasons */ if (reqtags > SYM_CONF_MAX_TAG) reqtags = SYM_CONF_MAX_TAG; - depth_to_use = reqtags ? reqtags : 2; + depth_to_use = (reqtags ? reqtags : 2); +#else + depth_to_use = (reqtags ? SYM_CONF_MAX_TAG : 2); +#endif scsi_adjust_queue_depth(sdev, - sdev->tagged_supported ? MSG_SIMPLE_TAG : 0, + (sdev->tagged_supported ? + MSG_SIMPLE_TAG : 0), depth_to_use); lp->s.scdev_depth = depth_to_use; sym_tune_dev_queuing(tp, sdev->lun, reqtags); @@ -987,9 +1089,8 @@ static int is_keyword(char *ptr, int len, char *verb) * Parse a control command */ -static int sym_user_command(struct Scsi_Host *shost, char *buffer, int length) +static int sym_user_command(struct sym_hcb *np, char *buffer, int length) { - struct sym_hcb *np = sym_get_hcb(shost); char *ptr = buffer; int len = length; struct sym_usrcmd cmd, *uc = &cmd; @@ -1116,9 +1217,9 @@ printk("sym_user_command: data=%ld\n", uc->data); else { unsigned long flags; - spin_lock_irqsave(shost->host_lock, flags); - sym_exec_user_command(np, uc); - spin_unlock_irqrestore(shost->host_lock, flags); + spin_lock_irqsave(np->s.host->host_lock, flags); + sym_exec_user_command (np, uc); + spin_unlock_irqrestore(np->s.host->host_lock, flags); } return length; } @@ -1174,11 +1275,8 @@ static int copy_info(struct info_str *info, char *fmt, ...) /* * Copy formatted information into the input buffer. */ -static int sym_host_info(struct Scsi_Host *shost, char *ptr, off_t offset, int len) +static int sym_host_info(struct sym_hcb *np, char *ptr, off_t offset, int len) { - struct sym_data *sym_data = shost_priv(shost); - struct pci_dev *pdev = sym_data->pdev; - struct sym_hcb *np = sym_data->ncb; struct info_str info; info.buffer = ptr; @@ -1187,10 +1285,10 @@ static int sym_host_info(struct Scsi_Host *shost, char *ptr, off_t offset, int l info.pos = 0; copy_info(&info, "Chip " NAME53C "%s, device id 0x%x, " - "revision id 0x%x\n", np->s.chip_name, - pdev->device, pdev->revision); - copy_info(&info, "At PCI address %s, IRQ %u\n", - pci_name(pdev), pdev->irq); + "revision id 0x%x\n", + np->s.chip_name, np->device_id, np->revision_id); + copy_info(&info, "At PCI address %s, IRQ " IRQ_FMT "\n", + pci_name(np->s.device), IRQ_PRM(np->s.irq)); copy_info(&info, "Min. period factor %d, %s SCSI BUS%s\n", (int) (np->minsync_dt ? np->minsync_dt : np->minsync), np->maxwide ? "Wide" : "Narrow", @@ -1209,14 +1307,15 @@ static int sym_host_info(struct Scsi_Host *shost, char *ptr, off_t offset, int l * - func = 0 means read (returns adapter infos) * - func = 1 means write (not yet merget from sym53c8xx) */ -static int sym53c8xx_proc_info(struct Scsi_Host *shost, char *buffer, +static int sym53c8xx_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int func) { + struct sym_hcb *np = sym_get_hcb(host); int retv; if (func) { #ifdef SYM_LINUX_USER_COMMAND_SUPPORT - retv = sym_user_command(shost, buffer, length); + retv = sym_user_command(np, buffer, length); #else retv = -EINVAL; #endif @@ -1224,7 +1323,7 @@ static int sym53c8xx_proc_info(struct Scsi_Host *shost, char *buffer, if (start) *start = buffer; #ifdef SYM_LINUX_USER_INFO_SUPPORT - retv = sym_host_info(shost, buffer, offset, length); + retv = sym_host_info(np, buffer, offset, length); #else retv = -EINVAL; #endif @@ -1242,8 +1341,8 @@ static void sym_free_resources(struct sym_hcb *np, struct pci_dev *pdev) /* * Free O/S specific resources. */ - if (pdev->irq) - free_irq(pdev->irq, np); + if (np->s.irq) + free_irq(np->s.irq, np); if (np->s.ioaddr) pci_iounmap(pdev, np->s.ioaddr); if (np->s.ramaddr) @@ -1256,6 +1355,31 @@ static void sym_free_resources(struct sym_hcb *np, struct pci_dev *pdev) sym_mfree_dma(np, sizeof(*np), "HCB"); } +/* + * Ask/tell the system about DMA addressing. + */ +static int sym_setup_bus_dma_mask(struct sym_hcb *np) +{ +#if SYM_CONF_DMA_ADDRESSING_MODE > 0 +#if SYM_CONF_DMA_ADDRESSING_MODE == 1 +#define DMA_DAC_MASK DMA_40BIT_MASK +#elif SYM_CONF_DMA_ADDRESSING_MODE == 2 +#define DMA_DAC_MASK DMA_64BIT_MASK +#endif + if ((np->features & FE_DAC) && + !pci_set_dma_mask(np->s.device, DMA_DAC_MASK)) { + np->use_dac = 1; + return 0; + } +#endif + + if (!pci_set_dma_mask(np->s.device, DMA_32BIT_MASK)) + return 0; + + printf_warning("%s: No suitable DMA available\n", sym_name(np)); + return -1; +} + /* * Host attach and initialisations. * @@ -1268,28 +1392,32 @@ static void sym_free_resources(struct sym_hcb *np, struct pci_dev *pdev) static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, int unit, struct sym_device *dev) { - struct sym_data *sym_data; + struct host_data *host_data; struct sym_hcb *np = NULL; - struct Scsi_Host *shost; + struct Scsi_Host *instance = NULL; struct pci_dev *pdev = dev->pdev; unsigned long flags; struct sym_fw *fw; - printk(KERN_INFO "sym%d: <%s> rev 0x%x at pci %s irq %u\n", - unit, dev->chip.name, pdev->revision, pci_name(pdev), - pdev->irq); + printk(KERN_INFO + "sym%d: <%s> rev 0x%x at pci %s irq " IRQ_FMT "\n", + unit, dev->chip.name, dev->chip.revision_id, + pci_name(pdev), IRQ_PRM(pdev->irq)); /* * Get the firmware for this chip. */ fw = sym_find_firmware(&dev->chip); if (!fw) - return NULL; + goto attach_failed; - shost = scsi_host_alloc(tpnt, sizeof(*sym_data)); - if (!shost) - return NULL; - sym_data = shost_priv(shost); + /* + * Allocate host_data structure + */ + instance = scsi_host_alloc(tpnt, sizeof(*host_data)); + if (!instance) + goto attach_failed; + host_data = (struct host_data *) instance->hostdata; /* * Allocate immediately the host control block, @@ -1300,19 +1428,22 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, np = __sym_calloc_dma(&pdev->dev, sizeof(*np), "HCB"); if (!np) goto attach_failed; + np->s.device = pdev; np->bus_dmat = &pdev->dev; /* Result in 1 DMA pool per HBA */ - sym_data->ncb = np; - sym_data->pdev = pdev; - np->s.host = shost; + host_data->ncb = np; + np->s.host = instance; - pci_set_drvdata(pdev, shost); + pci_set_drvdata(pdev, np); /* * Copy some useful infos to the HCB. */ np->hcb_ba = vtobus(np); np->verbose = sym_driver_setup.verbose; + np->s.device = pdev; np->s.unit = unit; + np->device_id = dev->chip.device_id; + np->revision_id = dev->chip.revision_id; np->features = dev->chip.features; np->clock_divn = dev->chip.nr_divisor; np->maxoffs = dev->chip.offset_max; @@ -1325,13 +1456,8 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, strlcpy(np->s.chip_name, dev->chip.name, sizeof(np->s.chip_name)); sprintf(np->s.inst_name, "sym%d", np->s.unit); - if ((SYM_CONF_DMA_ADDRESSING_MODE > 0) && (np->features & FE_DAC) && - !pci_set_dma_mask(pdev, DMA_DAC_MASK)) { - set_dac(np); - } else if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { - printf_warning("%s: No suitable DMA available\n", sym_name(np)); + if (sym_setup_bus_dma_mask(np)) goto attach_failed; - } /* * Try to map the controller chip to @@ -1340,16 +1466,19 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, np->mmio_ba = (u32)dev->mmio_base; np->s.ioaddr = dev->s.ioaddr; np->s.ramaddr = dev->s.ramaddr; + np->s.io_ws = (np->features & FE_IO256) ? 256 : 128; /* * Map on-chip RAM if present and supported. */ if (!(np->features & FE_RAM)) dev->ram_base = 0; - if (dev->ram_base) + if (dev->ram_base) { np->ram_ba = (u32)dev->ram_base; + np->ram_ws = (np->features & FE_RAM8K) ? 8192 : 4096; + } - if (sym_hcb_attach(shost, fw, dev->nvram)) + if (sym_hcb_attach(instance, fw, dev->nvram)) goto attach_failed; /* @@ -1357,25 +1486,25 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, * If we synchonize the C code with SCRIPTS on interrupt, * we do not want to share the INTR line at all. */ - if (request_irq(pdev->irq, sym53c8xx_intr, IRQF_SHARED, NAME53C8XX, - shost)) { - printf_err("%s: request irq %u failure\n", + if (request_irq(pdev->irq, sym53c8xx_intr, IRQF_SHARED, NAME53C8XX, np)) { + printf_err("%s: request irq %d failure\n", sym_name(np), pdev->irq); goto attach_failed; } + np->s.irq = pdev->irq; /* * After SCSI devices have been opened, we cannot * reset the bus safely, so we do it here. */ - spin_lock_irqsave(shost->host_lock, flags); + spin_lock_irqsave(instance->host_lock, flags); if (sym_reset_scsi_bus(np, 0)) goto reset_failed; /* * Start the SCRIPTS. */ - sym_start_up(shost, 1); + sym_start_up (np, 1); /* * Start the timer daemon @@ -1390,37 +1519,33 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, * Fill Linux host instance structure * and return success. */ - shost->max_channel = 0; - shost->this_id = np->myaddr; - shost->max_id = np->maxwide ? 16 : 8; - shost->max_lun = SYM_CONF_MAX_LUN; - shost->unique_id = pci_resource_start(pdev, 0); - shost->cmd_per_lun = SYM_CONF_MAX_TAG; - shost->can_queue = (SYM_CONF_MAX_START-2); - shost->sg_tablesize = SYM_CONF_MAX_SG; - shost->max_cmd_len = 16; + instance->max_channel = 0; + instance->this_id = np->myaddr; + instance->max_id = np->maxwide ? 16 : 8; + instance->max_lun = SYM_CONF_MAX_LUN; + instance->unique_id = pci_resource_start(pdev, 0); + instance->cmd_per_lun = SYM_CONF_MAX_TAG; + instance->can_queue = (SYM_CONF_MAX_START-2); + instance->sg_tablesize = SYM_CONF_MAX_SG; + instance->max_cmd_len = 16; BUG_ON(sym2_transport_template == NULL); - shost->transportt = sym2_transport_template; - - /* 53c896 rev 1 errata: DMA may not cross 16MB boundary */ - if (pdev->device == PCI_DEVICE_ID_NCR_53C896 && pdev->revision < 2) - shost->dma_boundary = 0xFFFFFF; + instance->transportt = sym2_transport_template; - spin_unlock_irqrestore(shost->host_lock, flags); + spin_unlock_irqrestore(instance->host_lock, flags); - return shost; + return instance; reset_failed: printf_err("%s: FATAL ERROR: CHECK SCSI BUS - CABLES, " "TERMINATION, DEVICE POWER etc.!\n", sym_name(np)); - spin_unlock_irqrestore(shost->host_lock, flags); + spin_unlock_irqrestore(instance->host_lock, flags); attach_failed: - if (!shost) + if (!instance) return NULL; printf_info("%s: giving up ...\n", sym_name(np)); if (np) sym_free_resources(np, pdev); - scsi_host_put(shost); + scsi_host_put(instance); return NULL; } @@ -1433,6 +1558,7 @@ static struct Scsi_Host * __devinit sym_attach(struct scsi_host_template *tpnt, static void __devinit sym_get_nvram(struct sym_device *devp, struct sym_nvram *nvp) { devp->nvram = nvp; + devp->device_id = devp->chip.device_id; nvp->type = 0; sym_read_nvram(devp, nvp); @@ -1447,6 +1573,7 @@ static int __devinit sym_check_supported(struct sym_device *device) { struct sym_chip *chip; struct pci_dev *pdev = device->pdev; + u_char revision; unsigned long io_port = pci_resource_start(pdev, 0); int i; @@ -1466,12 +1593,14 @@ static int __devinit sym_check_supported(struct sym_device *device) * to our device structure so we can make it match the actual device * and options. */ - chip = sym_lookup_chip_table(pdev->device, pdev->revision); + pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision); + chip = sym_lookup_chip_table(pdev->device, revision); if (!chip) { dev_info(&pdev->dev, "device not supported\n"); return -ENODEV; } memcpy(&device->chip, chip, sizeof(device->chip)); + device->chip.revision_id = revision; return 0; } @@ -1512,7 +1641,7 @@ static int __devinit sym_set_workarounds(struct sym_device *device) * We must ensure the chip will use WRITE AND INVALIDATE. * The revision number limit is for now arbitrary. */ - if (pdev->device == PCI_DEVICE_ID_NCR_53C896 && pdev->revision < 0x4) { + if (pdev->device == PCI_DEVICE_ID_NCR_53C896 && chip->revision_id < 0x4) { chip->features |= (FE_WRIE | FE_CLSE); } @@ -1640,9 +1769,8 @@ static void sym_config_pqs(struct pci_dev *pdev, struct sym_device *sym_dev) * Detach the host. * We have to free resources and halt the NCR chip. */ -static int sym_detach(struct Scsi_Host *shost, struct pci_dev *pdev) +static int sym_detach(struct sym_hcb *np, struct pci_dev *pdev) { - struct sym_hcb *np = sym_get_hcb(shost); printk("%s: detaching ...\n", sym_name(np)); del_timer_sync(&np->s.timer); @@ -1695,7 +1823,7 @@ static int __devinit sym2_probe(struct pci_dev *pdev, { struct sym_device sym_dev; struct sym_nvram nvram; - struct Scsi_Host *shost; + struct Scsi_Host *instance; memset(&sym_dev, 0, sizeof(sym_dev)); memset(&nvram, 0, sizeof(nvram)); @@ -1722,13 +1850,13 @@ static int __devinit sym2_probe(struct pci_dev *pdev, sym_get_nvram(&sym_dev, &nvram); - shost = sym_attach(&sym2_template, attach_count, &sym_dev); - if (!shost) + instance = sym_attach(&sym2_template, attach_count, &sym_dev); + if (!instance) goto free; - if (scsi_add_host(shost, &pdev->dev)) + if (scsi_add_host(instance, &pdev->dev)) goto detach; - scsi_scan_host(shost); + scsi_scan_host(instance); attach_count++; @@ -1746,141 +1874,18 @@ static int __devinit sym2_probe(struct pci_dev *pdev, static void __devexit sym2_remove(struct pci_dev *pdev) { - struct Scsi_Host *shost = pci_get_drvdata(pdev); + struct sym_hcb *np = pci_get_drvdata(pdev); + struct Scsi_Host *host = np->s.host; - scsi_remove_host(shost); - scsi_host_put(shost); - sym_detach(shost, pdev); - pci_release_regions(pdev); - pci_disable_device(pdev); - - attach_count--; -} + scsi_remove_host(host); + scsi_host_put(host); -/** - * sym2_io_error_detected() - called when PCI error is detected - * @pdev: pointer to PCI device - * @state: current state of the PCI slot - */ -static pci_ers_result_t sym2_io_error_detected(struct pci_dev *pdev, - enum pci_channel_state state) -{ - /* If slot is permanently frozen, turn everything off */ - if (state == pci_channel_io_perm_failure) { - sym2_remove(pdev); - return PCI_ERS_RESULT_DISCONNECT; - } + sym_detach(np, pdev); - disable_irq(pdev->irq); + pci_release_regions(pdev); pci_disable_device(pdev); - /* Request that MMIO be enabled, so register dump can be taken. */ - return PCI_ERS_RESULT_CAN_RECOVER; -} - -/** - * sym2_io_slot_dump - Enable MMIO and dump debug registers - * @pdev: pointer to PCI device - */ -static pci_ers_result_t sym2_io_slot_dump(struct pci_dev *pdev) -{ - struct Scsi_Host *shost = pci_get_drvdata(pdev); - - sym_dump_registers(shost); - - /* Request a slot reset. */ - return PCI_ERS_RESULT_NEED_RESET; -} - -/** - * sym2_reset_workarounds - hardware-specific work-arounds - * - * This routine is similar to sym_set_workarounds(), except - * that, at this point, we already know that the device was - * succesfully intialized at least once before, and so most - * of the steps taken there are un-needed here. - */ -static void sym2_reset_workarounds(struct pci_dev *pdev) -{ - u_short status_reg; - struct sym_chip *chip; - - chip = sym_lookup_chip_table(pdev->device, pdev->revision); - - /* Work around for errant bit in 895A, in a fashion - * similar to what is done in sym_set_workarounds(). - */ - pci_read_config_word(pdev, PCI_STATUS, &status_reg); - if (!(chip->features & FE_66MHZ) && (status_reg & PCI_STATUS_66MHZ)) { - status_reg = PCI_STATUS_66MHZ; - pci_write_config_word(pdev, PCI_STATUS, status_reg); - pci_read_config_word(pdev, PCI_STATUS, &status_reg); - } -} - -/** - * sym2_io_slot_reset() - called when the pci bus has been reset. - * @pdev: pointer to PCI device - * - * Restart the card from scratch. - */ -static pci_ers_result_t sym2_io_slot_reset(struct pci_dev *pdev) -{ - struct Scsi_Host *shost = pci_get_drvdata(pdev); - struct sym_hcb *np = sym_get_hcb(shost); - - printk(KERN_INFO "%s: recovering from a PCI slot reset\n", - sym_name(np)); - - if (pci_enable_device(pdev)) { - printk(KERN_ERR "%s: Unable to enable after PCI reset\n", - sym_name(np)); - return PCI_ERS_RESULT_DISCONNECT; - } - - pci_set_master(pdev); - enable_irq(pdev->irq); - - /* If the chip can do Memory Write Invalidate, enable it */ - if (np->features & FE_WRIE) { - if (pci_set_mwi(pdev)) - return PCI_ERS_RESULT_DISCONNECT; - } - - /* Perform work-arounds, analogous to sym_set_workarounds() */ - sym2_reset_workarounds(pdev); - - /* Perform host reset only on one instance of the card */ - if (PCI_FUNC(pdev->devfn) == 0) { - if (sym_reset_scsi_bus(np, 0)) { - printk(KERN_ERR "%s: Unable to reset scsi host\n", - sym_name(np)); - return PCI_ERS_RESULT_DISCONNECT; - } - sym_start_up(shost, 1); - } - - return PCI_ERS_RESULT_RECOVERED; -} - -/** - * sym2_io_resume() - resume normal ops after PCI reset - * @pdev: pointer to PCI device - * - * Called when the error recovery driver tells us that its - * OK to resume normal operation. Use completion to allow - * halted scsi ops to resume. - */ -static void sym2_io_resume(struct pci_dev *pdev) -{ - struct Scsi_Host *shost = pci_get_drvdata(pdev); - struct sym_data *sym_data = shost_priv(shost); - - spin_lock_irq(shost->host_lock); - if (sym_data->io_reset) - complete_all(sym_data->io_reset); - sym_data->io_reset = NULL; - spin_unlock_irq(shost->host_lock); + attach_count--; } static void sym2_get_signalling(struct Scsi_Host *shost) @@ -2045,19 +2050,11 @@ static struct pci_device_id sym2_id_table[] __devinitdata = { MODULE_DEVICE_TABLE(pci, sym2_id_table); -static struct pci_error_handlers sym2_err_handler = { - .error_detected = sym2_io_error_detected, - .mmio_enabled = sym2_io_slot_dump, - .slot_reset = sym2_io_slot_reset, - .resume = sym2_io_resume, -}; - static struct pci_driver sym2_driver = { .name = NAME53C8XX, .id_table = sym2_id_table, .probe = sym2_probe, .remove = __devexit_p(sym2_remove), - .err_handler = &sym2_err_handler, }; static int __init sym2_init(void) diff --git a/trunk/drivers/scsi/sym53c8xx_2/sym_glue.h b/trunk/drivers/scsi/sym53c8xx_2/sym_glue.h index 567fbe0b4f09..0f097ba4f712 100644 --- a/trunk/drivers/scsi/sym53c8xx_2/sym_glue.h +++ b/trunk/drivers/scsi/sym53c8xx_2/sym_glue.h @@ -40,9 +40,7 @@ #ifndef SYM_GLUE_H #define SYM_GLUE_H -#include #include -#include #include #include #include @@ -179,11 +177,14 @@ struct sym_shcb { int unit; char inst_name[16]; char chip_name[8]; + struct pci_dev *device; struct Scsi_Host *host; void __iomem * ioaddr; /* MMIO kernel io address */ void __iomem * ramaddr; /* RAM kernel io address */ + u_short io_ws; /* IO window size */ + int irq; /* IRQ number */ struct timer_list timer; /* Timer handler link header */ u_long lasttime; @@ -211,21 +212,20 @@ struct sym_device { } s; struct sym_chip chip; struct sym_nvram *nvram; + u_short device_id; u_char host_id; }; /* * Driver host data structure. */ -struct sym_data { +struct host_data { struct sym_hcb *ncb; - struct completion *io_reset; /* PCI error handling */ - struct pci_dev *pdev; }; static inline struct sym_hcb * sym_get_hcb(struct Scsi_Host *host) { - return ((struct sym_data *)host->hostdata)->ncb; + return ((struct host_data *)host->hostdata)->ncb; } #include "sym_fw.h" @@ -263,8 +263,8 @@ void sym_set_cam_result_error(struct sym_hcb *np, struct sym_ccb *cp, int resid) void sym_xpt_done(struct sym_hcb *np, struct scsi_cmnd *ccb); #define sym_print_addr(cmd, arg...) dev_info(&cmd->device->sdev_gendev , ## arg) void sym_xpt_async_bus_reset(struct sym_hcb *np); +void sym_xpt_async_sent_bdr(struct sym_hcb *np, int target); int sym_setup_data_and_start (struct sym_hcb *np, struct scsi_cmnd *csio, struct sym_ccb *cp); -void sym_log_bus_error(struct Scsi_Host *); -void sym_dump_registers(struct Scsi_Host *); +void sym_log_bus_error(struct sym_hcb *np); #endif /* SYM_GLUE_H */ diff --git a/trunk/drivers/scsi/sym53c8xx_2/sym_hipd.c b/trunk/drivers/scsi/sym53c8xx_2/sym_hipd.c index 463f119f20e9..21cd4c7f5289 100644 --- a/trunk/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/trunk/drivers/scsi/sym53c8xx_2/sym_hipd.c @@ -52,7 +52,7 @@ * Needed function prototypes. */ static void sym_int_ma (struct sym_hcb *np); -static void sym_int_sir(struct sym_hcb *); +static void sym_int_sir (struct sym_hcb *np); static struct sym_ccb *sym_alloc_ccb(struct sym_hcb *np); static struct sym_ccb *sym_ccb_from_dsa(struct sym_hcb *np, u32 dsa); static void sym_alloc_lcb_tags (struct sym_hcb *np, u_char tn, u_char ln); @@ -684,8 +684,6 @@ static void sym_set_bus_mode(struct sym_hcb *np, struct sym_nvram *nvram) */ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, struct sym_nvram *nvram) { - struct sym_data *sym_data = shost_priv(shost); - struct pci_dev *pdev = sym_data->pdev; u_char burst_max; u32 period; int i; @@ -780,12 +778,19 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru * 64 bit addressing (895A/896/1010) ? */ if (np->features & FE_DAC) { - if (!use_dac(np)) - np->rv_ccntl1 |= (DDAC); - else if (SYM_CONF_DMA_ADDRESSING_MODE == 1) - np->rv_ccntl1 |= (XTIMOD | EXTIBMV); - else if (SYM_CONF_DMA_ADDRESSING_MODE == 2) - np->rv_ccntl1 |= (0 | EXTIBMV); +#if SYM_CONF_DMA_ADDRESSING_MODE == 0 + np->rv_ccntl1 |= (DDAC); +#elif SYM_CONF_DMA_ADDRESSING_MODE == 1 + if (!np->use_dac) + np->rv_ccntl1 |= (DDAC); + else + np->rv_ccntl1 |= (XTIMOD | EXTIBMV); +#elif SYM_CONF_DMA_ADDRESSING_MODE == 2 + if (!np->use_dac) + np->rv_ccntl1 |= (DDAC); + else + np->rv_ccntl1 |= (0 | EXTIBMV); +#endif } /* @@ -799,8 +804,8 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru * In dual channel mode, contention occurs if internal cycles * are used. Disable internal cycles. */ - if (pdev->device == PCI_DEVICE_ID_LSI_53C1010_33 && - pdev->revision < 0x1) + if (np->device_id == PCI_DEVICE_ID_LSI_53C1010_33 && + np->revision_id < 0x1) np->rv_ccntl0 |= DILS; /* @@ -823,10 +828,10 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru * this driver. The generic ncr driver that does not use * LOAD/STORE instructions does not need this work-around. */ - if ((pdev->device == PCI_DEVICE_ID_NCR_53C810 && - pdev->revision >= 0x10 && pdev->revision <= 0x11) || - (pdev->device == PCI_DEVICE_ID_NCR_53C860 && - pdev->revision <= 0x1)) + if ((np->device_id == PCI_DEVICE_ID_NCR_53C810 && + np->revision_id >= 0x10 && np->revision_id <= 0x11) || + (np->device_id == PCI_DEVICE_ID_NCR_53C860 && + np->revision_id <= 0x1)) np->features &= ~(FE_WRIE|FE_ERL|FE_ERMP); /* @@ -892,7 +897,7 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru if ((SYM_SETUP_SCSI_LED || (nvram->type == SYM_SYMBIOS_NVRAM || (nvram->type == SYM_TEKRAM_NVRAM && - pdev->device == PCI_DEVICE_ID_NCR_53C895))) && + np->device_id == PCI_DEVICE_ID_NCR_53C895))) && !(np->features & FE_LEDC) && !(np->sv_gpcntl & 0x01)) np->features |= FE_LED0; @@ -1130,9 +1135,8 @@ static int sym_snooptest(struct sym_hcb *np) * First 24 register of the chip: * r0..rf */ -static void sym_log_hard_error(struct Scsi_Host *shost, u_short sist, u_char dstat) +static void sym_log_hard_error(struct sym_hcb *np, u_short sist, u_char dstat) { - struct sym_hcb *np = sym_get_hcb(shost); u32 dsp; int script_ofs; int script_size; @@ -1176,27 +1180,16 @@ static void sym_log_hard_error(struct Scsi_Host *shost, u_short sist, u_char dst scr_to_cpu((int) *(u32 *)(script_base + script_ofs))); } - printf("%s: regdump:", sym_name(np)); - for (i = 0; i < 24; i++) - printf(" %02x", (unsigned)INB_OFF(np, i)); - printf(".\n"); + printf ("%s: regdump:", sym_name(np)); + for (i=0; i<24;i++) + printf (" %02x", (unsigned)INB_OFF(np, i)); + printf (".\n"); /* * PCI BUS error. */ if (dstat & (MDPE|BF)) - sym_log_bus_error(shost); -} - -void sym_dump_registers(struct Scsi_Host *shost) -{ - struct sym_hcb *np = sym_get_hcb(shost); - u_short sist; - u_char dstat; - - sist = INW(np, nc_sist); - dstat = INB(np, nc_dstat); - sym_log_hard_error(shost, sist, dstat); + sym_log_bus_error(np); } static struct sym_chip sym_dev_table[] = { @@ -1319,7 +1312,7 @@ int sym_lookup_dmap(struct sym_hcb *np, u32 h, int s) { int i; - if (!use_dac(np)) + if (!np->use_dac) goto weird; /* Look up existing mappings */ @@ -1526,8 +1519,7 @@ void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp) np->squeueput = qidx; if (DEBUG_FLAGS & DEBUG_QUEUE) - scmd_printk(KERN_DEBUG, cp->cmd, "queuepos=%d\n", - np->squeueput); + printf ("%s: queuepos=%d.\n", sym_name (np), np->squeueput); /* * Script processor may be waiting for reselect. @@ -1704,11 +1696,8 @@ static void sym_flush_busy_queue (struct sym_hcb *np, int cam_status) * 1: SCSI BUS RESET delivered or received. * 2: SCSI BUS MODE changed. */ -void sym_start_up(struct Scsi_Host *shost, int reason) +void sym_start_up (struct sym_hcb *np, int reason) { - struct sym_data *sym_data = shost_priv(shost); - struct pci_dev *pdev = sym_data->pdev; - struct sym_hcb *np = sym_data->ncb; int i; u32 phys; @@ -1757,7 +1746,7 @@ void sym_start_up(struct Scsi_Host *shost, int reason) * This also let point to first position the start * and done queue pointers used from SCRIPTS. */ - np->fw_patch(shost); + np->fw_patch(np); /* * Wakeup all pending jobs. @@ -1799,7 +1788,7 @@ void sym_start_up(struct Scsi_Host *shost, int reason) /* * For now, disable AIP generation on C1010-66. */ - if (pdev->device == PCI_DEVICE_ID_LSI_53C1010_66) + if (np->device_id == PCI_DEVICE_ID_LSI_53C1010_66) OUTB(np, nc_aipcntl1, DISAIP); /* @@ -1809,8 +1798,8 @@ void sym_start_up(struct Scsi_Host *shost, int reason) * that from SCRIPTS for each selection/reselection, but * I just don't want. :) */ - if (pdev->device == PCI_DEVICE_ID_LSI_53C1010_33 && - pdev->revision < 1) + if (np->device_id == PCI_DEVICE_ID_LSI_53C1010_33 && + np->revision_id < 1) OUTB(np, nc_stest1, INB(np, nc_stest1) | 0x30); /* @@ -1818,9 +1807,9 @@ void sym_start_up(struct Scsi_Host *shost, int reason) * Disable overlapped arbitration for some dual function devices, * regardless revision id (kind of post-chip-design feature. ;-)) */ - if (pdev->device == PCI_DEVICE_ID_NCR_53C875) + if (np->device_id == PCI_DEVICE_ID_NCR_53C875) OUTB(np, nc_ctest0, (1<<5)); - else if (pdev->device == PCI_DEVICE_ID_NCR_53C896) + else if (np->device_id == PCI_DEVICE_ID_NCR_53C896) np->rv_ccntl0 |= DPR; /* @@ -1838,7 +1827,7 @@ void sym_start_up(struct Scsi_Host *shost, int reason) * Set up scratch C and DRS IO registers to map the 32 bit * DMA address range our data structures are located in. */ - if (use_dac(np)) { + if (np->use_dac) { np->dmap_bah[0] = 0; /* ??? */ OUTL(np, nc_scrx[0], np->dmap_bah[0]); OUTL(np, nc_drs, np->dmap_bah[0]); @@ -1911,7 +1900,7 @@ void sym_start_up(struct Scsi_Host *shost, int reason) if (sym_verbose >= 2) printf("%s: Downloading SCSI SCRIPTS.\n", sym_name(np)); memcpy_toio(np->s.ramaddr, np->scripta0, np->scripta_sz); - if (np->features & FE_RAM8K) { + if (np->ram_ws == 8192) { memcpy_toio(np->s.ramaddr + 4096, np->scriptb0, np->scriptb_sz); phys = scr_to_cpu(np->scr_ram_seg); OUTL(np, nc_mmws, phys); @@ -2225,9 +2214,8 @@ static void sym_int_udc (struct sym_hcb *np) * mode to eight bit asynchronous, etc... * So, just reinitializing all except chip should be enough. */ -static void sym_int_sbmc(struct Scsi_Host *shost) +static void sym_int_sbmc (struct sym_hcb *np) { - struct sym_hcb *np = sym_get_hcb(shost); u_char scsi_mode = INB(np, nc_stest4) & SMODE; /* @@ -2240,7 +2228,7 @@ static void sym_int_sbmc(struct Scsi_Host *shost) * Should suspend command processing for a few seconds and * reinitialize all except the chip. */ - sym_start_up(shost, 2); + sym_start_up (np, 2); } /* @@ -2768,11 +2756,8 @@ static void sym_int_ma (struct sym_hcb *np) * Use at your own decision and risk. */ -irqreturn_t sym_interrupt(struct Scsi_Host *shost) +void sym_interrupt (struct sym_hcb *np) { - struct sym_data *sym_data = shost_priv(shost); - struct sym_hcb *np = sym_data->ncb; - struct pci_dev *pdev = sym_data->pdev; u_char istat, istatc; u_char dstat; u_short sist; @@ -2797,7 +2782,7 @@ irqreturn_t sym_interrupt(struct Scsi_Host *shost) } if (!(istat & (SIP|DIP))) - return (istat & INTF) ? IRQ_HANDLED : IRQ_NONE; + return; #if 0 /* We should never get this one */ if (istat & CABRT) @@ -2824,13 +2809,6 @@ irqreturn_t sym_interrupt(struct Scsi_Host *shost) dstat |= INB(np, nc_dstat); istatc = INB(np, nc_istat); istat |= istatc; - - /* Prevent deadlock waiting on a condition that may - * never clear. */ - if (unlikely(sist == 0xffff && dstat == 0xff)) { - if (pci_channel_offline(pdev)) - return IRQ_NONE; - } } while (istatc & (SIP|DIP)); if (DEBUG_FLAGS & DEBUG_TINY) @@ -2864,10 +2842,10 @@ irqreturn_t sym_interrupt(struct Scsi_Host *shost) !(dstat & (MDPE|BF|ABRT|IID))) { if (sist & PAR) sym_int_par (np, sist); else if (sist & MA) sym_int_ma (np); - else if (dstat & SIR) sym_int_sir(np); + else if (dstat & SIR) sym_int_sir (np); else if (dstat & SSI) OUTONB_STD(); else goto unknown_int; - return IRQ_HANDLED; + return; } /* @@ -2883,8 +2861,8 @@ irqreturn_t sym_interrupt(struct Scsi_Host *shost) */ if (sist & RST) { printf("%s: SCSI BUS reset detected.\n", sym_name(np)); - sym_start_up(shost, 1); - return IRQ_HANDLED; + sym_start_up (np, 1); + return; } OUTB(np, nc_ctest3, np->rv_ctest3 | CLF); /* clear dma fifo */ @@ -2892,11 +2870,11 @@ irqreturn_t sym_interrupt(struct Scsi_Host *shost) if (!(sist & (GEN|HTH|SGE)) && !(dstat & (MDPE|BF|ABRT|IID))) { - if (sist & SBMC) sym_int_sbmc(shost); + if (sist & SBMC) sym_int_sbmc (np); else if (sist & STO) sym_int_sto (np); else if (sist & UDC) sym_int_udc (np); else goto unknown_int; - return IRQ_HANDLED; + return; } /* @@ -2906,12 +2884,12 @@ irqreturn_t sym_interrupt(struct Scsi_Host *shost) * Reset everything. */ - sym_log_hard_error(shost, sist, dstat); + sym_log_hard_error(np, sist, dstat); if ((sist & (GEN|HTH|SGE)) || (dstat & (MDPE|BF|ABRT|IID))) { sym_start_reset(np); - return IRQ_HANDLED; + return; } unknown_int: @@ -2922,7 +2900,6 @@ irqreturn_t sym_interrupt(struct Scsi_Host *shost) printf( "%s: unknown interrupt(s) ignored, " "ISTAT=0x%x DSTAT=0x%x SIST=0x%x\n", sym_name(np), istat, dstat, sist); - return IRQ_NONE; } /* @@ -3543,8 +3520,7 @@ static void sym_sir_task_recovery(struct sym_hcb *np, int num) * If we sent a BDR, make upper layer aware of that. */ if (np->abrt_msg[0] == M_RESET) - starget_printk(KERN_NOTICE, starget, - "has been reset\n"); + sym_xpt_async_sent_bdr(np, target); break; } @@ -4328,7 +4304,7 @@ static void sym_nego_rejected(struct sym_hcb *np, struct sym_tcb *tp, struct sym /* * chip exception handler for programmed interrupts. */ -static void sym_int_sir(struct sym_hcb *np) +static void sym_int_sir (struct sym_hcb *np) { u_char num = INB(np, nc_dsps); u32 dsa = INL(np, nc_dsa); @@ -4367,30 +4343,31 @@ static void sym_int_sir(struct sym_hcb *np) return; /* * The device didn't go to MSG OUT phase after having - * been selected with ATN. We do not want to handle that. + * been selected with ATN. We donnot want to handle + * that. */ case SIR_SEL_ATN_NO_MSG_OUT: - scmd_printk(KERN_WARNING, cp->cmd, - "No MSG OUT phase after selection with ATN\n"); + printf ("%s:%d: No MSG OUT phase after selection with ATN.\n", + sym_name (np), target); goto out_stuck; /* * The device didn't switch to MSG IN phase after - * having reselected the initiator. + * having reseleted the initiator. */ case SIR_RESEL_NO_MSG_IN: - scmd_printk(KERN_WARNING, cp->cmd, - "No MSG IN phase after reselection\n"); + printf ("%s:%d: No MSG IN phase after reselection.\n", + sym_name (np), target); goto out_stuck; /* * After reselection, the device sent a message that wasn't * an IDENTIFY. */ case SIR_RESEL_NO_IDENTIFY: - scmd_printk(KERN_WARNING, cp->cmd, - "No IDENTIFY after reselection\n"); + printf ("%s:%d: No IDENTIFY after reselection.\n", + sym_name (np), target); goto out_stuck; /* - * The device reselected a LUN we do not know about. + * The device reselected a LUN we donnot know about. */ case SIR_RESEL_BAD_LUN: np->msgout[0] = M_RESET; @@ -4403,7 +4380,8 @@ static void sym_int_sir(struct sym_hcb *np) np->msgout[0] = M_ABORT; goto out; /* - * The device reselected for a tagged nexus that we do not have. + * The device reselected for a tagged nexus that we donnot + * have. */ case SIR_RESEL_BAD_I_T_L_Q: np->msgout[0] = M_ABORT_TAG; @@ -4415,8 +4393,8 @@ static void sym_int_sir(struct sym_hcb *np) case SIR_RESEL_ABORTED: np->lastmsg = np->msgout[0]; np->msgout[0] = M_NOOP; - scmd_printk(KERN_WARNING, cp->cmd, - "message %x sent on bad reselection\n", np->lastmsg); + printf ("%s:%d: message %x sent on bad reselection.\n", + sym_name (np), target, np->lastmsg); goto out; /* * The SCRIPTS let us know that a message has been @@ -5600,13 +5578,16 @@ int sym_hcb_attach(struct Scsi_Host *shost, struct sym_fw *fw, struct sym_nvram np->scriptz_ba = vtobus(np->scriptz0); if (np->ram_ba) { - np->scripta_ba = np->ram_ba; + np->scripta_ba = np->ram_ba; if (np->features & FE_RAM8K) { + np->ram_ws = 8192; np->scriptb_ba = np->scripta_ba + 4096; #if 0 /* May get useful for 64 BIT PCI addressing */ np->scr_ram_seg = cpu_to_scr(np->scripta_ba >> 32); #endif } + else + np->ram_ws = 4096; } /* diff --git a/trunk/drivers/scsi/sym53c8xx_2/sym_hipd.h b/trunk/drivers/scsi/sym53c8xx_2/sym_hipd.h index ad078805e62b..79ab6a177039 100644 --- a/trunk/drivers/scsi/sym53c8xx_2/sym_hipd.h +++ b/trunk/drivers/scsi/sym53c8xx_2/sym_hipd.h @@ -883,7 +883,10 @@ struct sym_hcb { * Physical bus addresses of the chip. */ u32 mmio_ba; /* MMIO 32 bit BUS address */ + int mmio_ws; /* MMIO Window size */ + u32 ram_ba; /* RAM 32 bit BUS address */ + int ram_ws; /* RAM window size */ /* * SCRIPTS virtual and physical bus addresses. @@ -909,12 +912,14 @@ struct sym_hcb { struct sym_fwb_ba fwb_bas; /* Useful SCRIPTB bus addresses */ struct sym_fwz_ba fwz_bas; /* Useful SCRIPTZ bus addresses */ void (*fw_setup)(struct sym_hcb *np, struct sym_fw *fw); - void (*fw_patch)(struct Scsi_Host *); + void (*fw_patch)(struct sym_hcb *np); char *fw_name; /* * General controller parameters and configuration. */ + u_short device_id; /* PCI device id */ + u_char revision_id; /* PCI device revision id */ u_int features; /* Chip features map */ u_char myaddr; /* SCSI id of the adapter */ u_char maxburst; /* log base 2 of dwords burst */ @@ -1026,14 +1031,6 @@ struct sym_hcb { #endif }; -#if SYM_CONF_DMA_ADDRESSING_MODE == 0 -#define use_dac(np) 0 -#define set_dac(np) do { } while (0) -#else -#define use_dac(np) (np)->use_dac -#define set_dac(np) (np)->use_dac = 1 -#endif - #define HCB_BA(np, lbl) (np->hcb_ba + offsetof(struct sym_hcb, lbl)) @@ -1055,8 +1052,8 @@ void sym_start_next_ccbs(struct sym_hcb *np, struct sym_lcb *lp, int maxn); #else void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp); #endif -void sym_start_up(struct Scsi_Host *, int reason); -irqreturn_t sym_interrupt(struct Scsi_Host *); +void sym_start_up(struct sym_hcb *np, int reason); +void sym_interrupt(struct sym_hcb *np); int sym_clear_tasks(struct sym_hcb *np, int cam_status, int target, int lun, int task); struct sym_ccb *sym_get_ccb(struct sym_hcb *np, struct scsi_cmnd *cmd, u_char tag_order); void sym_free_ccb(struct sym_hcb *np, struct sym_ccb *cp); @@ -1076,21 +1073,18 @@ int sym_hcb_attach(struct Scsi_Host *shost, struct sym_fw *fw, struct sym_nvram */ #if SYM_CONF_DMA_ADDRESSING_MODE == 0 -#define DMA_DAC_MASK DMA_32BIT_MASK #define sym_build_sge(np, data, badd, len) \ do { \ (data)->addr = cpu_to_scr(badd); \ (data)->size = cpu_to_scr(len); \ } while (0) #elif SYM_CONF_DMA_ADDRESSING_MODE == 1 -#define DMA_DAC_MASK DMA_40BIT_MASK #define sym_build_sge(np, data, badd, len) \ do { \ (data)->addr = cpu_to_scr(badd); \ (data)->size = cpu_to_scr((((badd) >> 8) & 0xff000000) + len); \ } while (0) #elif SYM_CONF_DMA_ADDRESSING_MODE == 2 -#define DMA_DAC_MASK DMA_64BIT_MASK int sym_lookup_dmap(struct sym_hcb *np, u32 h, int s); static __inline void sym_build_sge(struct sym_hcb *np, struct sym_tblmove *data, u64 badd, int len) diff --git a/trunk/drivers/scsi/sym53c8xx_2/sym_nvram.c b/trunk/drivers/scsi/sym53c8xx_2/sym_nvram.c index 5662fbb3ff60..15d69298ab6e 100644 --- a/trunk/drivers/scsi/sym53c8xx_2/sym_nvram.c +++ b/trunk/drivers/scsi/sym53c8xx_2/sym_nvram.c @@ -696,7 +696,7 @@ static int sym_read_Tekram_nvram (struct sym_device *np, Tekram_nvram *nvram) u_short csum; int x; - switch (np->pdev->device) { + switch (np->device_id) { case PCI_DEVICE_ID_NCR_53C885: case PCI_DEVICE_ID_NCR_53C895: case PCI_DEVICE_ID_NCR_53C896: diff --git a/trunk/drivers/serial/serial_core.c b/trunk/drivers/serial/serial_core.c index 3bb5d241dd40..103189095c80 100644 --- a/trunk/drivers/serial/serial_core.c +++ b/trunk/drivers/serial/serial_core.c @@ -1875,7 +1875,6 @@ uart_set_options(struct uart_port *port, struct console *co, int baud, int parity, int bits, int flow) { struct ktermios termios; - static struct ktermios dummy; int i; /* @@ -1921,7 +1920,7 @@ uart_set_options(struct uart_port *port, struct console *co, */ port->mctrl |= TIOCM_DTR; - port->ops->set_termios(port, &termios, &dummy); + port->ops->set_termios(port, &termios, NULL); co->cflag = termios.c_cflag; return 0; diff --git a/trunk/drivers/serial/serial_cs.c b/trunk/drivers/serial/serial_cs.c index d8b660061c13..5afcb2fa7cd3 100644 --- a/trunk/drivers/serial/serial_cs.c +++ b/trunk/drivers/serial/serial_cs.c @@ -345,7 +345,7 @@ static int serial_probe(struct pcmcia_device *link) link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; link->io.NumPorts1 = 8; - link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING; + link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; link->irq.IRQInfo1 = IRQ_LEVEL_ID; link->conf.Attributes = CONF_ENABLE_IRQ; if (do_sound) { diff --git a/trunk/drivers/serial/serial_txx9.c b/trunk/drivers/serial/serial_txx9.c index 7ad21925869a..6846a6c38b6d 100644 --- a/trunk/drivers/serial/serial_txx9.c +++ b/trunk/drivers/serial/serial_txx9.c @@ -657,15 +657,7 @@ static void serial_txx9_pm(struct uart_port *port, unsigned int state, unsigned int oldstate) { - /* - * If oldstate was -1 this is called from - * uart_configure_port(). In this case do not initialize the - * port now, because the port was already initialized (for - * non-console port) or should not be initialized here (for - * console port). If we initialized the port here we lose - * serial console settings. - */ - if (state == 0 && oldstate != -1) + if (state == 0) serial_txx9_initialize(port); } diff --git a/trunk/drivers/spi/spidev.c b/trunk/drivers/spi/spidev.c index b3518ca9f04e..c55459c592b8 100644 --- a/trunk/drivers/spi/spidev.c +++ b/trunk/drivers/spi/spidev.c @@ -184,14 +184,14 @@ static int spidev_message(struct spidev_data *spidev, if (u_tmp->rx_buf) { k_tmp->rx_buf = buf; if (!access_ok(VERIFY_WRITE, (u8 __user *) - (uintptr_t) u_tmp->rx_buf, + (ptrdiff_t) u_tmp->rx_buf, u_tmp->len)) goto done; } if (u_tmp->tx_buf) { k_tmp->tx_buf = buf; if (copy_from_user(buf, (const u8 __user *) - (uintptr_t) u_tmp->tx_buf, + (ptrdiff_t) u_tmp->tx_buf, u_tmp->len)) goto done; } @@ -224,7 +224,7 @@ static int spidev_message(struct spidev_data *spidev, for (n = n_xfers, u_tmp = u_xfers; n; n--, u_tmp++) { if (u_tmp->rx_buf) { if (__copy_to_user((u8 __user *) - (uintptr_t) u_tmp->rx_buf, buf, + (ptrdiff_t) u_tmp->rx_buf, buf, u_tmp->len)) { status = -EFAULT; goto done; diff --git a/trunk/drivers/usb/core/message.c b/trunk/drivers/usb/core/message.c index 316a746e0080..90d64a808464 100644 --- a/trunk/drivers/usb/core/message.c +++ b/trunk/drivers/usb/core/message.c @@ -11,9 +11,9 @@ #include #include #include -#include #include #include +#include #include "hcd.h" /* for usbcore internals */ #include "usb.h" @@ -434,7 +434,7 @@ int usb_sg_init ( if (dma) { io->urbs [i]->transfer_dma = sg_dma_address (sg + i); len = sg_dma_len (sg + i); -#if defined(CONFIG_HIGHMEM) || defined(CONFIG_GART_IOMMU) +#if defined(CONFIG_HIGHMEM) || defined(CONFIG_IOMMU) io->urbs[i]->transfer_buffer = NULL; #else io->urbs[i]->transfer_buffer = sg_virt(&sg[i]); @@ -1641,13 +1641,7 @@ int usb_set_configuration(struct usb_device *dev, int configuration) intf->dev.bus_id, ret); continue; } - - /* The driver's probe method can call usb_set_interface(), - * which would mean the interface's sysfs files are already - * created. Just in case, we'll remove them first. - */ - usb_remove_sysfs_intf_files(intf); - usb_create_sysfs_intf_files(intf); + usb_create_sysfs_intf_files (intf); } usb_autosuspend_device(dev); diff --git a/trunk/drivers/usb/core/urb.c b/trunk/drivers/usb/core/urb.c index d05ead20081c..c20c03aaf012 100644 --- a/trunk/drivers/usb/core/urb.c +++ b/trunk/drivers/usb/core/urb.c @@ -372,7 +372,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) /* enforce simple/standard policy */ allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP | - URB_NO_INTERRUPT | URB_DIR_MASK | URB_FREE_BUFFER); + URB_NO_INTERRUPT | URB_DIR_MASK); switch (xfertype) { case USB_ENDPOINT_XFER_BULK: if (is_out) diff --git a/trunk/drivers/usb/gadget/amd5536udc.c b/trunk/drivers/usb/gadget/amd5536udc.c index c72e9620bf8d..1c8040602525 100644 --- a/trunk/drivers/usb/gadget/amd5536udc.c +++ b/trunk/drivers/usb/gadget/amd5536udc.c @@ -3289,7 +3289,7 @@ static int udc_pci_probe( dev->chiprev = pdev->revision; pci_set_master(pdev); - pci_try_set_mwi(pdev); + pci_set_mwi(pdev); /* init dma pools */ if (use_dma) { diff --git a/trunk/drivers/usb/host/Kconfig b/trunk/drivers/usb/host/Kconfig index 177e78ed241b..c978d622fa8a 100644 --- a/trunk/drivers/usb/host/Kconfig +++ b/trunk/drivers/usb/host/Kconfig @@ -156,7 +156,7 @@ config USB_OHCI_HCD_PCI config USB_OHCI_HCD_SSB bool "OHCI support for Broadcom SSB OHCI core" - depends on USB_OHCI_HCD && (SSB = y || SSB = CONFIG_USB_OHCI_HCD) && EXPERIMENTAL + depends on USB_OHCI_HCD && SSB && EXPERIMENTAL default n ---help--- Support for the Sonics Silicon Backplane (SSB) attached diff --git a/trunk/drivers/usb/host/ohci-hcd.c b/trunk/drivers/usb/host/ohci-hcd.c index 704f33fdd2f1..240c7f507541 100644 --- a/trunk/drivers/usb/host/ohci-hcd.c +++ b/trunk/drivers/usb/host/ohci-hcd.c @@ -80,10 +80,7 @@ static const char hcd_name [] = "ohci_hcd"; static void ohci_dump (struct ohci_hcd *ohci, int verbose); static int ohci_init (struct ohci_hcd *ohci); static void ohci_stop (struct usb_hcd *hcd); - -#if defined(CONFIG_PM) || defined(CONFIG_PCI) static int ohci_restart (struct ohci_hcd *ohci); -#endif #include "ohci-hub.c" #include "ohci-dbg.c" @@ -399,7 +396,7 @@ static int check_ed(struct ohci_hcd *ohci, struct ed *ed) */ static void unlink_watchdog_func(unsigned long _ohci) { - unsigned long flags; + long flags; unsigned max; unsigned seen_count = 0; unsigned i; @@ -896,8 +893,6 @@ static void ohci_stop (struct usb_hcd *hcd) /*-------------------------------------------------------------------------*/ -#if defined(CONFIG_PM) || defined(CONFIG_PCI) - /* must not be called from interrupt context */ static int ohci_restart (struct ohci_hcd *ohci) { @@ -959,8 +954,6 @@ static int ohci_restart (struct ohci_hcd *ohci) return 0; } -#endif - /*-------------------------------------------------------------------------*/ #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC diff --git a/trunk/drivers/usb/host/uhci-q.c b/trunk/drivers/usb/host/uhci-q.c index 60379b17bbc1..e5d60d5b105a 100644 --- a/trunk/drivers/usb/host/uhci-q.c +++ b/trunk/drivers/usb/host/uhci-q.c @@ -1271,8 +1271,7 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb, } else if (qh->period != urb->interval) { return -EINVAL; /* Can't change the period */ - } else { - /* Find the next unused frame */ + } else { /* Pick up where the last URB leaves off */ if (list_empty(&qh->queue)) { frame = qh->iso_frame; } else { @@ -1284,18 +1283,10 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb, lurb->number_of_packets * lurb->interval; } - if (urb->transfer_flags & URB_ISO_ASAP) { - /* Skip some frames if necessary to insure - * the start frame is in the future. - */ - uhci_get_current_frame_number(uhci); - if (uhci_frame_before_eq(frame, uhci->frame_number)) { - frame = uhci->frame_number + 1; - frame += ((qh->phase - frame) & - (qh->period - 1)); - } - } /* Otherwise pick up where the last URB leaves off */ - urb->start_frame = frame; + if (urb->transfer_flags & URB_ISO_ASAP) + urb->start_frame = frame; + else if (urb->start_frame != frame) + return -EINVAL; } /* Make sure we won't have to go too far into the future */ diff --git a/trunk/drivers/usb/misc/cytherm.c b/trunk/drivers/usb/misc/cytherm.c index 1cd9e7eba93b..2677fea147d9 100644 --- a/trunk/drivers/usb/misc/cytherm.c +++ b/trunk/drivers/usb/misc/cytherm.c @@ -399,6 +399,7 @@ static void cytherm_disconnect(struct usb_interface *interface) struct usb_cytherm *dev; dev = usb_get_intfdata (interface); + usb_set_intfdata (interface, NULL); device_remove_file(&interface->dev, &dev_attr_brightness); device_remove_file(&interface->dev, &dev_attr_temp); @@ -406,9 +407,6 @@ static void cytherm_disconnect(struct usb_interface *interface) device_remove_file(&interface->dev, &dev_attr_port0); device_remove_file(&interface->dev, &dev_attr_port1); - /* first remove the files, then NULL the pointer */ - usb_set_intfdata (interface, NULL); - usb_put_dev(dev->udev); kfree(dev); diff --git a/trunk/drivers/usb/misc/emi26.c b/trunk/drivers/usb/misc/emi26.c index 4a09b87bdd28..cd137577bb2d 100644 --- a/trunk/drivers/usb/misc/emi26.c +++ b/trunk/drivers/usb/misc/emi26.c @@ -114,10 +114,6 @@ static int emi26_load_firmware (struct usb_device *dev) /* De-assert reset (let the CPU run) */ err = emi26_set_reset(dev,0); - if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); - goto wraperr; - } msleep(250); /* let device settle */ /* 2. We upload the FPGA firmware into the EMI diff --git a/trunk/drivers/usb/misc/emi62.c b/trunk/drivers/usb/misc/emi62.c index d1362415922c..4758cc5ccebc 100644 --- a/trunk/drivers/usb/misc/emi62.c +++ b/trunk/drivers/usb/misc/emi62.c @@ -123,10 +123,6 @@ static int emi62_load_firmware (struct usb_device *dev) /* De-assert reset (let the CPU run) */ err = emi62_set_reset(dev,0); - if (err < 0) { - err("%s - error loading firmware: error = %d", __FUNCTION__, err); - goto wraperr; - } msleep(250); /* let device settle */ /* 2. We upload the FPGA firmware into the EMI diff --git a/trunk/drivers/usb/misc/ftdi-elan.c b/trunk/drivers/usb/misc/ftdi-elan.c index 148b7fe639b2..d3d8cd6ff103 100644 --- a/trunk/drivers/usb/misc/ftdi-elan.c +++ b/trunk/drivers/usb/misc/ftdi-elan.c @@ -147,7 +147,7 @@ struct u132_target { /* Structure to hold all of our device specific stuff*/ struct usb_ftdi { struct list_head ftdi_list; - struct mutex u132_lock; + struct semaphore u132_lock; int command_next; int command_head; struct u132_command command[COMMAND_SIZE]; @@ -330,39 +330,39 @@ static int ftdi_elan_hcd_init(struct usb_ftdi *ftdi) static void ftdi_elan_abandon_completions(struct usb_ftdi *ftdi) { - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); while (ftdi->respond_next > ftdi->respond_head) { struct u132_respond *respond = &ftdi->respond[RESPOND_MASK & ftdi->respond_head++]; *respond->result = -ESHUTDOWN; *respond->value = 0; complete(&respond->wait_completion); - } mutex_unlock(&ftdi->u132_lock); + } up(&ftdi->u132_lock); } static void ftdi_elan_abandon_targets(struct usb_ftdi *ftdi) { int ed_number = 4; - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); while (ed_number-- > 0) { struct u132_target *target = &ftdi->target[ed_number]; if (target->active == 1) { target->condition_code = TD_DEVNOTRESP; - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); ftdi_elan_do_callback(ftdi, target, NULL, 0); - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); } } ftdi->recieved = 0; ftdi->expected = 4; ftdi->ed_found = 0; - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); } static void ftdi_elan_flush_targets(struct usb_ftdi *ftdi) { int ed_number = 4; - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); while (ed_number-- > 0) { struct u132_target *target = &ftdi->target[ed_number]; target->abandoning = 1; @@ -382,9 +382,9 @@ static void ftdi_elan_flush_targets(struct usb_ftdi *ftdi) ftdi->command_next += 1; ftdi_elan_kick_command_queue(ftdi); } else { - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); msleep(100); - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); goto wait_1; } } @@ -404,9 +404,9 @@ static void ftdi_elan_flush_targets(struct usb_ftdi *ftdi) ftdi->command_next += 1; ftdi_elan_kick_command_queue(ftdi); } else { - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); msleep(100); - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); goto wait_2; } } @@ -414,13 +414,13 @@ static void ftdi_elan_flush_targets(struct usb_ftdi *ftdi) ftdi->recieved = 0; ftdi->expected = 4; ftdi->ed_found = 0; - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); } static void ftdi_elan_cancel_targets(struct usb_ftdi *ftdi) { int ed_number = 4; - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); while (ed_number-- > 0) { struct u132_target *target = &ftdi->target[ed_number]; target->abandoning = 1; @@ -440,9 +440,9 @@ static void ftdi_elan_cancel_targets(struct usb_ftdi *ftdi) ftdi->command_next += 1; ftdi_elan_kick_command_queue(ftdi); } else { - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); msleep(100); - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); goto wait; } } @@ -450,7 +450,7 @@ static void ftdi_elan_cancel_targets(struct usb_ftdi *ftdi) ftdi->recieved = 0; ftdi->expected = 4; ftdi->ed_found = 0; - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); } static void ftdi_elan_kick_command_queue(struct usb_ftdi *ftdi) @@ -886,14 +886,14 @@ static char *have_ed_set_response(struct usb_ftdi *ftdi, char *b) { int payload = (ed_length >> 0) & 0x07FF; - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); target->actual = 0; target->non_null = (ed_length >> 15) & 0x0001; target->repeat_number = (ed_length >> 11) & 0x000F; if (ed_type == 0x02) { if (payload == 0 || target->abandoning > 0) { target->abandoning = 0; - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, payload); ftdi->recieved = 0; @@ -903,13 +903,13 @@ static char *have_ed_set_response(struct usb_ftdi *ftdi, } else { ftdi->expected = 4 + payload; ftdi->ed_found = 1; - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); return b; } } else if (ed_type == 0x03) { if (payload == 0 || target->abandoning > 0) { target->abandoning = 0; - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, payload); ftdi->recieved = 0; @@ -919,12 +919,12 @@ static char *have_ed_set_response(struct usb_ftdi *ftdi, } else { ftdi->expected = 4 + payload; ftdi->ed_found = 1; - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); return b; } } else if (ed_type == 0x01) { target->abandoning = 0; - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, payload); ftdi->recieved = 0; @@ -933,7 +933,7 @@ static char *have_ed_set_response(struct usb_ftdi *ftdi, return ftdi->response; } else { target->abandoning = 0; - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response, payload); ftdi->recieved = 0; @@ -947,12 +947,12 @@ static char *have_ed_get_response(struct usb_ftdi *ftdi, struct u132_target *target, u16 ed_length, int ed_number, int ed_type, char *b) { - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); target->condition_code = TD_DEVNOTRESP; target->actual = (ed_length >> 0) & 0x01FF; target->non_null = (ed_length >> 15) & 0x0001; target->repeat_number = (ed_length >> 11) & 0x000F; - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); if (target->active) ftdi_elan_do_callback(ftdi, target, NULL, 0); target->abandoning = 0; @@ -1278,7 +1278,7 @@ static int ftdi_elan_write_reg(struct usb_ftdi *ftdi, u32 data) return -ENODEV; } else { int command_size; - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); command_size = ftdi->command_next - ftdi->command_head; if (command_size < COMMAND_SIZE) { struct u132_command *command = &ftdi->command[ @@ -1292,10 +1292,10 @@ static int ftdi_elan_write_reg(struct usb_ftdi *ftdi, u32 data) command->buffer = &command->value; ftdi->command_next += 1; ftdi_elan_kick_command_queue(ftdi); - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); return 0; } else { - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); msleep(100); goto wait; } @@ -1310,7 +1310,7 @@ static int ftdi_elan_write_config(struct usb_ftdi *ftdi, int config_offset, return -ENODEV; } else { int command_size; - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); command_size = ftdi->command_next - ftdi->command_head; if (command_size < COMMAND_SIZE) { struct u132_command *command = &ftdi->command[ @@ -1324,10 +1324,10 @@ static int ftdi_elan_write_config(struct usb_ftdi *ftdi, int config_offset, command->buffer = &command->value; ftdi->command_next += 1; ftdi_elan_kick_command_queue(ftdi); - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); return 0; } else { - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); msleep(100); goto wait; } @@ -1342,7 +1342,7 @@ static int ftdi_elan_write_pcimem(struct usb_ftdi *ftdi, int mem_offset, return -ENODEV; } else { int command_size; - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); command_size = ftdi->command_next - ftdi->command_head; if (command_size < COMMAND_SIZE) { struct u132_command *command = &ftdi->command[ @@ -1356,10 +1356,10 @@ static int ftdi_elan_write_pcimem(struct usb_ftdi *ftdi, int mem_offset, command->buffer = &command->value; ftdi->command_next += 1; ftdi_elan_kick_command_queue(ftdi); - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); return 0; } else { - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); msleep(100); goto wait; } @@ -1382,7 +1382,7 @@ static int ftdi_elan_read_reg(struct usb_ftdi *ftdi, u32 *data) } else { int command_size; int respond_size; - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); command_size = ftdi->command_next - ftdi->command_head; respond_size = ftdi->respond_next - ftdi->respond_head; if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE) @@ -1405,11 +1405,11 @@ static int ftdi_elan_read_reg(struct usb_ftdi *ftdi, u32 *data) ftdi->command_next += 1; ftdi->respond_next += 1; ftdi_elan_kick_command_queue(ftdi); - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); wait_for_completion(&respond->wait_completion); return result; } else { - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); msleep(100); goto wait; } @@ -1425,7 +1425,7 @@ static int ftdi_elan_read_config(struct usb_ftdi *ftdi, int config_offset, } else { int command_size; int respond_size; - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); command_size = ftdi->command_next - ftdi->command_head; respond_size = ftdi->respond_next - ftdi->respond_head; if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE) @@ -1449,11 +1449,11 @@ static int ftdi_elan_read_config(struct usb_ftdi *ftdi, int config_offset, ftdi->command_next += 1; ftdi->respond_next += 1; ftdi_elan_kick_command_queue(ftdi); - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); wait_for_completion(&respond->wait_completion); return result; } else { - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); msleep(100); goto wait; } @@ -1469,7 +1469,7 @@ static int ftdi_elan_read_pcimem(struct usb_ftdi *ftdi, int mem_offset, } else { int command_size; int respond_size; - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); command_size = ftdi->command_next - ftdi->command_head; respond_size = ftdi->respond_next - ftdi->respond_head; if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE) @@ -1493,11 +1493,11 @@ static int ftdi_elan_read_pcimem(struct usb_ftdi *ftdi, int mem_offset, ftdi->command_next += 1; ftdi->respond_next += 1; ftdi_elan_kick_command_queue(ftdi); - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); wait_for_completion(&respond->wait_completion); return result; } else { - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); msleep(100); goto wait; } @@ -1529,7 +1529,7 @@ static int ftdi_elan_edset_setup(struct usb_ftdi *ftdi, u8 ed_number, return -ENODEV; } else { int command_size; - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); command_size = ftdi->command_next - ftdi->command_head; if (command_size < COMMAND_SIZE) { struct u132_target *target = &ftdi->target[ed]; @@ -1550,10 +1550,10 @@ static int ftdi_elan_edset_setup(struct usb_ftdi *ftdi, u8 ed_number, target->active = 1; ftdi->command_next += 1; ftdi_elan_kick_command_queue(ftdi); - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); return 0; } else { - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); msleep(100); goto wait; } @@ -1586,7 +1586,7 @@ static int ftdi_elan_edset_input(struct usb_ftdi *ftdi, u8 ed_number, return -ENODEV; } else { int command_size; - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); command_size = ftdi->command_next - ftdi->command_head; if (command_size < COMMAND_SIZE) { struct u132_target *target = &ftdi->target[ed]; @@ -1615,10 +1615,10 @@ static int ftdi_elan_edset_input(struct usb_ftdi *ftdi, u8 ed_number, target->active = 1; ftdi->command_next += 1; ftdi_elan_kick_command_queue(ftdi); - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); return 0; } else { - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); msleep(100); goto wait; } @@ -1651,7 +1651,7 @@ static int ftdi_elan_edset_empty(struct usb_ftdi *ftdi, u8 ed_number, return -ENODEV; } else { int command_size; - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); command_size = ftdi->command_next - ftdi->command_head; if (command_size < COMMAND_SIZE) { struct u132_target *target = &ftdi->target[ed]; @@ -1672,10 +1672,10 @@ static int ftdi_elan_edset_empty(struct usb_ftdi *ftdi, u8 ed_number, target->active = 1; ftdi->command_next += 1; ftdi_elan_kick_command_queue(ftdi); - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); return 0; } else { - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); msleep(100); goto wait; } @@ -1708,7 +1708,7 @@ static int ftdi_elan_edset_output(struct usb_ftdi *ftdi, u8 ed_number, return -ENODEV; } else { int command_size; - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); command_size = ftdi->command_next - ftdi->command_head; if (command_size < COMMAND_SIZE) { u8 *b; @@ -1751,10 +1751,10 @@ static int ftdi_elan_edset_output(struct usb_ftdi *ftdi, u8 ed_number, target->active = 1; ftdi->command_next += 1; ftdi_elan_kick_command_queue(ftdi); - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); return 0; } else { - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); msleep(100); goto wait; } @@ -1787,7 +1787,7 @@ static int ftdi_elan_edset_single(struct usb_ftdi *ftdi, u8 ed_number, return -ENODEV; } else { int command_size; - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); command_size = ftdi->command_next - ftdi->command_head; if (command_size < COMMAND_SIZE) { int remaining_length = urb->transfer_buffer_length - @@ -1816,10 +1816,10 @@ static int ftdi_elan_edset_single(struct usb_ftdi *ftdi, u8 ed_number, target->active = 1; ftdi->command_next += 1; ftdi_elan_kick_command_queue(ftdi); - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); return 0; } else { - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); msleep(100); goto wait; } @@ -1849,9 +1849,9 @@ static int ftdi_elan_edset_flush(struct usb_ftdi *ftdi, u8 ed_number, return -ENODEV; } else { struct u132_target *target = &ftdi->target[ed]; - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); if (target->abandoning > 0) { - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); return 0; } else { target->abandoning = 1; @@ -1873,13 +1873,13 @@ static int ftdi_elan_edset_flush(struct usb_ftdi *ftdi, u8 ed_number, ftdi->command_next += 1; ftdi_elan_kick_command_queue(ftdi); } else { - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); msleep(100); - mutex_lock(&ftdi->u132_lock); + down(&ftdi->u132_lock); goto wait_1; } } - mutex_unlock(&ftdi->u132_lock); + up(&ftdi->u132_lock); return 0; } } @@ -2793,7 +2793,7 @@ static int ftdi_elan_probe(struct usb_interface *interface, init_MUTEX(&ftdi->sw_lock); ftdi->udev = usb_get_dev(interface_to_usbdev(interface)); ftdi->interface = interface; - mutex_init(&ftdi->u132_lock); + init_MUTEX(&ftdi->u132_lock); ftdi->expected = 4; iface_desc = interface->cur_altsetting; for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { diff --git a/trunk/drivers/usb/misc/idmouse.c b/trunk/drivers/usb/misc/idmouse.c index 4bcf7fb4e5da..e6fd024024f5 100644 --- a/trunk/drivers/usb/misc/idmouse.c +++ b/trunk/drivers/usb/misc/idmouse.c @@ -66,7 +66,6 @@ static struct usb_device_id idmouse_table[] = { USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, value, index, NULL, 0, 1000) MODULE_DEVICE_TABLE(usb, idmouse_table); -static DEFINE_MUTEX(open_disc_mutex); /* structure to hold all of our device specific stuff */ struct usb_idmouse { @@ -81,7 +80,7 @@ struct usb_idmouse { int open; /* if the port is open or not */ int present; /* if the device is not disconnected */ - struct mutex lock; /* locks this structure */ + struct semaphore sem; /* locks this structure */ }; @@ -214,17 +213,13 @@ static int idmouse_open(struct inode *inode, struct file *file) if (!interface) return -ENODEV; - mutex_lock(&open_disc_mutex); /* get the device information block from the interface */ dev = usb_get_intfdata(interface); - if (!dev) { - mutex_unlock(&open_disc_mutex); + if (!dev) return -ENODEV; - } /* lock this device */ - mutex_lock(&dev->lock); - mutex_unlock(&open_disc_mutex); + down(&dev->sem); /* check if already open */ if (dev->open) { @@ -250,7 +245,7 @@ static int idmouse_open(struct inode *inode, struct file *file) error: /* unlock this device */ - mutex_unlock(&dev->lock); + up(&dev->sem); return result; } @@ -263,14 +258,12 @@ static int idmouse_release(struct inode *inode, struct file *file) if (dev == NULL) return -ENODEV; - mutex_lock(&open_disc_mutex); /* lock our device */ - mutex_lock(&dev->lock); + down(&dev->sem); /* are we really open? */ if (dev->open <= 0) { - mutex_unlock(&dev->lock); - mutex_unlock(&open_disc_mutex); + up(&dev->sem); return -ENODEV; } @@ -278,12 +271,10 @@ static int idmouse_release(struct inode *inode, struct file *file) if (!dev->present) { /* the device was unplugged before the file was released */ - mutex_unlock(&dev->lock); - mutex_unlock(&open_disc_mutex); + up(&dev->sem); idmouse_delete(dev); } else { - mutex_unlock(&dev->lock); - mutex_unlock(&open_disc_mutex); + up(&dev->sem); } return 0; } @@ -295,18 +286,18 @@ static ssize_t idmouse_read(struct file *file, char __user *buffer, size_t count int result; /* lock this object */ - mutex_lock(&dev->lock); + down(&dev->sem); /* verify that the device wasn't unplugged */ if (!dev->present) { - mutex_unlock(&dev->lock); + up(&dev->sem); return -ENODEV; } result = simple_read_from_buffer(buffer, count, ppos, dev->bulk_in_buffer, IMGSIZE); /* unlock the device */ - mutex_unlock(&dev->lock); + up(&dev->sem); return result; } @@ -329,7 +320,7 @@ static int idmouse_probe(struct usb_interface *interface, if (dev == NULL) return -ENOMEM; - mutex_init(&dev->lock); + init_MUTEX(&dev->sem); dev->udev = udev; dev->interface = interface; @@ -381,26 +372,24 @@ static void idmouse_disconnect(struct usb_interface *interface) /* get device structure */ dev = usb_get_intfdata(interface); + usb_set_intfdata(interface, NULL); /* give back our minor */ usb_deregister_dev(interface, &idmouse_class); - mutex_lock(&open_disc_mutex); - usb_set_intfdata(interface, NULL); - /* lock the device */ - mutex_lock(&dev->lock); - mutex_unlock(&open_disc_mutex); + /* lock it */ + down(&dev->sem); /* prevent device read, write and ioctl */ dev->present = 0; /* if the device is opened, idmouse_release will clean this up */ if (!dev->open) { - mutex_unlock(&dev->lock); + up(&dev->sem); idmouse_delete(dev); } else { /* unlock */ - mutex_unlock(&dev->lock); + up(&dev->sem); } info("%s disconnected", DRIVER_DESC); diff --git a/trunk/drivers/usb/misc/iowarrior.c b/trunk/drivers/usb/misc/iowarrior.c index 764696ff1e8e..d372fbc4effb 100644 --- a/trunk/drivers/usb/misc/iowarrior.c +++ b/trunk/drivers/usb/misc/iowarrior.c @@ -66,7 +66,6 @@ module_param(debug, bool, 0644); MODULE_PARM_DESC(debug, "debug=1 enables debugging messages"); static struct usb_driver iowarrior_driver; -static DEFINE_MUTEX(iowarrior_open_disc_lock); /*--------------*/ /* data */ @@ -352,7 +351,7 @@ static ssize_t iowarrior_write(struct file *file, mutex_lock(&dev->mutex); /* verify that the device wasn't unplugged */ - if (!dev->present) { + if (dev == NULL || !dev->present) { retval = -ENODEV; goto exit; } @@ -609,15 +608,11 @@ static int iowarrior_open(struct inode *inode, struct file *file) return -ENODEV; } - mutex_lock(&iowarrior_open_disc_lock); dev = usb_get_intfdata(interface); - if (!dev) { - mutex_unlock(&iowarrior_open_disc_lock); + if (!dev) return -ENODEV; - } mutex_lock(&dev->mutex); - mutex_unlock(&iowarrior_open_disc_lock); /* Only one process can open each device, no sharing. */ if (dev->opened) { @@ -871,7 +866,6 @@ static void iowarrior_disconnect(struct usb_interface *interface) int minor; dev = usb_get_intfdata(interface); - mutex_lock(&iowarrior_open_disc_lock); usb_set_intfdata(interface, NULL); minor = dev->minor; @@ -885,7 +879,6 @@ static void iowarrior_disconnect(struct usb_interface *interface) dev->present = 0; mutex_unlock(&dev->mutex); - mutex_unlock(&iowarrior_open_disc_lock); if (dev->opened) { /* There is a process that holds a filedescriptor to the device , diff --git a/trunk/drivers/usb/misc/legousbtower.c b/trunk/drivers/usb/misc/legousbtower.c index aab320085ebf..561970b889a5 100644 --- a/trunk/drivers/usb/misc/legousbtower.c +++ b/trunk/drivers/usb/misc/legousbtower.c @@ -198,7 +198,6 @@ static struct usb_device_id tower_table [] = { }; MODULE_DEVICE_TABLE (usb, tower_table); -static DEFINE_MUTEX(open_disc_mutex); #define LEGO_USB_TOWER_MINOR_BASE 160 @@ -351,31 +350,25 @@ static int tower_open (struct inode *inode, struct file *file) goto exit; } - mutex_lock(&open_disc_mutex); dev = usb_get_intfdata(interface); if (!dev) { - mutex_unlock(&open_disc_mutex); retval = -ENODEV; goto exit; } /* lock this device */ if (down_interruptible (&dev->sem)) { - mutex_unlock(&open_disc_mutex); retval = -ERESTARTSYS; goto exit; } - /* allow opening only once */ if (dev->open_count) { - mutex_unlock(&open_disc_mutex); retval = -EBUSY; goto unlock_exit; } dev->open_count = 1; - mutex_unlock(&open_disc_mutex); /* reset the tower */ result = usb_control_msg (dev->udev, @@ -444,10 +437,9 @@ static int tower_release (struct inode *inode, struct file *file) if (dev == NULL) { dbg(1, "%s: object is NULL", __FUNCTION__); retval = -ENODEV; - goto exit_nolock; + goto exit; } - mutex_lock(&open_disc_mutex); if (down_interruptible (&dev->sem)) { retval = -ERESTARTSYS; goto exit; @@ -476,8 +468,6 @@ static int tower_release (struct inode *inode, struct file *file) up (&dev->sem); exit: - mutex_unlock(&open_disc_mutex); -exit_nolock: dbg(2, "%s: leave, return value %d", __FUNCTION__, retval); return retval; } @@ -999,7 +989,6 @@ static void tower_disconnect (struct usb_interface *interface) dbg(2, "%s: enter", __FUNCTION__); dev = usb_get_intfdata (interface); - mutex_lock(&open_disc_mutex); usb_set_intfdata (interface, NULL); minor = dev->minor; @@ -1008,7 +997,6 @@ static void tower_disconnect (struct usb_interface *interface) usb_deregister_dev (interface, &tower_class); down (&dev->sem); - mutex_unlock(&open_disc_mutex); /* if the device is not opened, then we clean up right now */ if (!dev->open_count) { diff --git a/trunk/drivers/usb/misc/rio500.c b/trunk/drivers/usb/misc/rio500.c index 330c18e390b8..88f6abe73624 100644 --- a/trunk/drivers/usb/misc/rio500.c +++ b/trunk/drivers/usb/misc/rio500.c @@ -118,7 +118,10 @@ ioctl_rio(struct inode *inode, struct file *file, unsigned int cmd, mutex_lock(&(rio->lock)); /* Sanity check to make sure rio is connected, powered, etc */ - if (rio->present == 0 || rio->rio_dev == NULL) { + if ( rio == NULL || + rio->present == 0 || + rio->rio_dev == NULL ) + { retval = -ENODEV; goto err_out; } @@ -277,7 +280,10 @@ write_rio(struct file *file, const char __user *buffer, if (intr) return -EINTR; /* Sanity check to make sure rio is connected, powered, etc */ - if (rio->present == 0 || rio->rio_dev == NULL) { + if ( rio == NULL || + rio->present == 0 || + rio->rio_dev == NULL ) + { mutex_unlock(&(rio->lock)); return -ENODEV; } @@ -363,7 +369,10 @@ read_rio(struct file *file, char __user *buffer, size_t count, loff_t * ppos) if (intr) return -EINTR; /* Sanity check to make sure rio is connected, powered, etc */ - if (rio->present == 0 || rio->rio_dev == NULL) { + if ( rio == NULL || + rio->present == 0 || + rio->rio_dev == NULL ) + { mutex_unlock(&(rio->lock)); return -ENODEV; } diff --git a/trunk/drivers/usb/misc/usblcd.c b/trunk/drivers/usb/misc/usblcd.c index 20777d01db62..719842032712 100644 --- a/trunk/drivers/usb/misc/usblcd.c +++ b/trunk/drivers/usb/misc/usblcd.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include @@ -35,8 +34,6 @@ static struct usb_device_id id_table [] = { }; MODULE_DEVICE_TABLE (usb, id_table); -static DEFINE_MUTEX(open_disc_mutex); - struct usb_lcd { struct usb_device * udev; /* init: probe_lcd */ @@ -82,16 +79,12 @@ static int lcd_open(struct inode *inode, struct file *file) return -ENODEV; } - mutex_lock(&open_disc_mutex); dev = usb_get_intfdata(interface); - if (!dev) { - mutex_unlock(&open_disc_mutex); + if (!dev) return -ENODEV; - } /* increment our usage count for the device */ kref_get(&dev->kref); - mutex_unlock(&open_disc_mutex); /* grab a power reference */ r = usb_autopm_get_interface(interface); @@ -400,10 +393,8 @@ static void lcd_disconnect(struct usb_interface *interface) struct usb_lcd *dev; int minor = interface->minor; - mutex_lock(&open_disc_mutex); dev = usb_get_intfdata(interface); usb_set_intfdata(interface, NULL); - mutex_unlock(&open_disc_mutex); /* give back our minor */ usb_deregister_dev(interface, &lcd_class); diff --git a/trunk/drivers/usb/misc/uss720.c b/trunk/drivers/usb/misc/uss720.c index f1255b0a182d..2734fe2b9c43 100644 --- a/trunk/drivers/usb/misc/uss720.c +++ b/trunk/drivers/usb/misc/uss720.c @@ -128,7 +128,7 @@ static void async_complete(struct urb *urb) #endif /* if nAck interrupts are enabled and we have an interrupt, call the interrupt procedure */ if (rq->reg[2] & rq->reg[1] & 0x10 && pp) - parport_generic_irq(pp); + parport_generic_irq(0, pp); } complete(&rq->compl); kref_put(&rq->ref_count, destroy_async); @@ -337,7 +337,7 @@ static int uss720_irq(int usbstatus, void *buffer, int len, void *dev_id) memcpy(priv->reg, buffer, 4); /* if nAck interrupts are enabled and we have an interrupt, call the interrupt procedure */ if (priv->reg[2] & priv->reg[1] & 0x10) - parport_generic_irq(pp); + parport_generic_irq(0, pp); return 1; } #endif diff --git a/trunk/drivers/usb/serial/ark3116.c b/trunk/drivers/usb/serial/ark3116.c index ddfee918000d..2a8e537cb046 100644 --- a/trunk/drivers/usb/serial/ark3116.c +++ b/trunk/drivers/usb/serial/ark3116.c @@ -161,8 +161,7 @@ static void ark3116_set_termios(struct usb_serial_port *port, { struct usb_serial *serial = port->serial; struct ark3116_private *priv = usb_get_serial_port_data(port); - struct ktermios *termios = port->tty->termios; - unsigned int cflag = termios->c_cflag; + unsigned int cflag = port->tty->termios->c_cflag; unsigned long flags; int baud; int ark3116_baud; @@ -178,14 +177,11 @@ static void ark3116_set_termios(struct usb_serial_port *port, *(port->tty->termios) = tty_std_termios; port->tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; - termios->c_ispeed = 9600; - termios->c_ospeed = 9600; priv->termios_initialized = 1; } spin_unlock_irqrestore(&priv->lock, flags); - cflag = termios->c_cflag; - termios->c_cflag &= ~(CMSPAR|CRTSCTS); + cflag = port->tty->termios->c_cflag; buf = kmalloc(1, GFP_KERNEL); if (!buf) { @@ -258,13 +254,9 @@ static void ark3116_set_termios(struct usb_serial_port *port, case 115200: case 230400: case 460800: - /* Report the resulting rate back to the caller */ - tty_encode_baud_rate(port->tty, baud, baud); break; /* set 9600 as default (if given baudrate is invalid for example) */ default: - tty_encode_baud_rate(port->tty, 9600, 9600); - case 0: baud = 9600; } @@ -310,7 +302,6 @@ static void ark3116_set_termios(struct usb_serial_port *port, /* TEST ARK3116_SND(154, 0xFE, 0x40, 0xFFFF, 0x0006); */ kfree(buf); - return; } diff --git a/trunk/drivers/usb/serial/ch341.c b/trunk/drivers/usb/serial/ch341.c index 42582d49b69c..6b252ceb39a8 100644 --- a/trunk/drivers/usb/serial/ch341.c +++ b/trunk/drivers/usb/serial/ch341.c @@ -272,6 +272,9 @@ static void ch341_set_termios(struct usb_serial_port *port, dbg("ch341_set_termios()"); + if (!tty || !tty->termios) + return; + baud_rate = tty_get_baud_rate(tty); switch (baud_rate) { @@ -296,11 +299,6 @@ static void ch341_set_termios(struct usb_serial_port *port, * (cflag & PARENB) : parity {NONE, EVEN, ODD} * (cflag & CSTOPB) : stop bits [1, 2] */ - - /* Copy back the old hardware settings */ - tty_termios_copy_hw(tty->termios, old_termios); - /* And re-encode with the new baud */ - tty_encode_baud_rate(tty, baud_rate, baud_rate); } static struct usb_driver ch341_driver = { diff --git a/trunk/drivers/usb/serial/console.c b/trunk/drivers/usb/serial/console.c index 0362654d3b52..9386e216d681 100644 --- a/trunk/drivers/usb/serial/console.c +++ b/trunk/drivers/usb/serial/console.c @@ -164,7 +164,6 @@ static int usb_console_setup(struct console *co, char *options) } if (serial->type->set_termios) { - struct ktermios dummy; /* build up a fake tty structure so that the open call has something * to look at to get the cflag value */ tty = kzalloc(sizeof(*tty), GFP_KERNEL); @@ -178,13 +177,12 @@ static int usb_console_setup(struct console *co, char *options) kfree (tty); return -ENOMEM; } - memset(&dummy, 0, sizeof(struct ktermios)); termios->c_cflag = cflag; tty->termios = termios; port->tty = tty; /* set up the initial termios settings */ - serial->type->set_termios(port, &dummy); + serial->type->set_termios(port, NULL); port->tty = NULL; kfree (termios); kfree (tty); diff --git a/trunk/drivers/usb/serial/cp2101.c b/trunk/drivers/usb/serial/cp2101.c index 3a83cb4c4bc2..eb7df1835c11 100644 --- a/trunk/drivers/usb/serial/cp2101.c +++ b/trunk/drivers/usb/serial/cp2101.c @@ -361,6 +361,7 @@ static void cp2101_get_termios (struct usb_serial_port *port) dbg("%s - no tty structures", __FUNCTION__); return; } + cflag = port->tty->termios->c_cflag; cp2101_get_config(port, CP2101_BAUDRATE, &baud, 2); /* Convert to baudrate */ @@ -368,9 +369,40 @@ static void cp2101_get_termios (struct usb_serial_port *port) baud = BAUD_RATE_GEN_FREQ / baud; dbg("%s - baud rate = %d", __FUNCTION__, baud); - - tty_encode_baud_rate(port->tty, baud, baud); - cflag = port->tty->termios->c_cflag; + cflag &= ~CBAUD; + switch (baud) { + /* + * The baud rates which are commented out below + * appear to be supported by the device + * but are non-standard + */ + case 600: cflag |= B600; break; + case 1200: cflag |= B1200; break; + case 1800: cflag |= B1800; break; + case 2400: cflag |= B2400; break; + case 4800: cflag |= B4800; break; + /*case 7200: cflag |= B7200; break;*/ + case 9600: cflag |= B9600; break; + /*case 14400: cflag |= B14400; break;*/ + case 19200: cflag |= B19200; break; + /*case 28800: cflag |= B28800; break;*/ + case 38400: cflag |= B38400; break; + /*case 55854: cflag |= B55054; break;*/ + case 57600: cflag |= B57600; break; + case 115200: cflag |= B115200; break; + /*case 127117: cflag |= B127117; break;*/ + case 230400: cflag |= B230400; break; + case 460800: cflag |= B460800; break; + case 921600: cflag |= B921600; break; + /*case 3686400: cflag |= B3686400; break;*/ + default: + dbg("%s - Baud rate is not supported, " + "using 9600 baud", __FUNCTION__); + cflag |= B9600; + cp2101_set_config_single(port, CP2101_BAUDRATE, + (BAUD_RATE_GEN_FREQ/9600)); + break; + } cp2101_get_config(port, CP2101_BITS, &bits, 2); cflag &= ~CSIZE; @@ -484,7 +516,7 @@ static void cp2101_get_termios (struct usb_serial_port *port) static void cp2101_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) { - unsigned int cflag, old_cflag; + unsigned int cflag, old_cflag=0; int baud=0, bits; unsigned int modem_ctl[4]; @@ -494,8 +526,6 @@ static void cp2101_set_termios (struct usb_serial_port *port, dbg("%s - no tty structures", __FUNCTION__); return; } - port->tty->termios->c_cflag &= ~CMSPAR; - cflag = port->tty->termios->c_cflag; old_cflag = old_termios->c_cflag; baud = tty_get_baud_rate(port->tty); @@ -533,15 +563,11 @@ static void cp2101_set_termios (struct usb_serial_port *port, dbg("%s - Setting baud rate to %d baud", __FUNCTION__, baud); if (cp2101_set_config_single(port, CP2101_BAUDRATE, - (BAUD_RATE_GEN_FREQ / baud))) { + (BAUD_RATE_GEN_FREQ / baud))) dev_err(&port->dev, "Baud rate requested not " "supported by device\n"); - baud = tty_termios_baud_rate(old_termios); - } } } - /* Report back the resulting baud rate */ - tty_encode_baud_rate(port->tty, baud, baud); /* If the number of data bits is to be updated */ if ((cflag & CSIZE) != (old_cflag & CSIZE)) { diff --git a/trunk/drivers/usb/serial/digi_acceleport.c b/trunk/drivers/usb/serial/digi_acceleport.c index ae410c4678ea..dab2e66d111d 100644 --- a/trunk/drivers/usb/serial/digi_acceleport.c +++ b/trunk/drivers/usb/serial/digi_acceleport.c @@ -973,8 +973,6 @@ static void digi_set_termios(struct usb_serial_port *port, } } /* set parity */ - tty->termios->c_cflag &= ~CMSPAR; - if ((cflag&(PARENB|PARODD)) != (old_cflag&(PARENB|PARODD))) { if (cflag&PARENB) { if (cflag&PARODD) @@ -1056,15 +1054,15 @@ static void digi_set_termios(struct usb_serial_port *port, } /* set output flow control */ - if ((iflag & IXON) != (old_iflag & IXON) - || (cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { + if ((iflag&IXON) != (old_iflag&IXON) + || (cflag&CRTSCTS) != (old_cflag&CRTSCTS)) { arg = 0; - if (iflag & IXON) + if (iflag&IXON) arg |= DIGI_OUTPUT_FLOW_CONTROL_XON_XOFF; else arg &= ~DIGI_OUTPUT_FLOW_CONTROL_XON_XOFF; - if (cflag & CRTSCTS) { + if (cflag&CRTSCTS) { arg |= DIGI_OUTPUT_FLOW_CONTROL_CTS; } else { arg &= ~DIGI_OUTPUT_FLOW_CONTROL_CTS; @@ -1078,8 +1076,8 @@ static void digi_set_termios(struct usb_serial_port *port, } /* set receive enable/disable */ - if ((cflag & CREAD) != (old_cflag & CREAD)) { - if (cflag & CREAD) + if ((cflag&CREAD) != (old_cflag&CREAD)) { + if (cflag&CREAD) arg = DIGI_ENABLE; else arg = DIGI_DISABLE; @@ -1091,7 +1089,7 @@ static void digi_set_termios(struct usb_serial_port *port, } if ((ret = digi_write_oob_command(port, buf, i, 1)) != 0) dbg("digi_set_termios: write oob failed, ret=%d", ret); - tty_encode_baud_rate(tty, baud, baud); + } diff --git a/trunk/drivers/usb/serial/empeg.c b/trunk/drivers/usb/serial/empeg.c index a5c8e1e17ea5..050fcc996f56 100644 --- a/trunk/drivers/usb/serial/empeg.c +++ b/trunk/drivers/usb/serial/empeg.c @@ -449,9 +449,14 @@ static int empeg_ioctl (struct usb_serial_port *port, struct file * file, unsign static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) { - struct ktermios *termios = port->tty->termios; + dbg("%s - port %d", __FUNCTION__, port->number); + if ((!port->tty) || (!port->tty->termios)) { + dbg("%s - no tty structures", __FUNCTION__); + return; + } + /* * The empeg-car player wants these particular tty settings. * You could, for example, change the baud rate, however the @@ -461,7 +466,7 @@ static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *ol * * The default requirements for this device are: */ - termios->c_iflag + port->tty->termios->c_iflag &= ~(IGNBRK /* disable ignore break */ | BRKINT /* disable break causes interrupt */ | PARMRK /* disable mark parity errors */ @@ -471,23 +476,24 @@ static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *ol | ICRNL /* disable translate CR to NL */ | IXON); /* disable enable XON/XOFF flow control */ - termios->c_oflag + port->tty->termios->c_oflag &= ~OPOST; /* disable postprocess output characters */ - termios->c_lflag + port->tty->termios->c_lflag &= ~(ECHO /* disable echo input characters */ | ECHONL /* disable echo new line */ | ICANON /* disable erase, kill, werase, and rprnt special characters */ | ISIG /* disable interrupt, quit, and suspend special characters */ | IEXTEN); /* disable non-POSIX special characters */ - termios->c_cflag + port->tty->termios->c_cflag &= ~(CSIZE /* no size */ | PARENB /* disable parity bit */ | CBAUD); /* clear current baud rate */ - termios->c_cflag - |= CS8; /* character size 8 bits */ + port->tty->termios->c_cflag + |= (CS8 /* character size 8 bits */ + | B115200); /* baud rate 115200 */ /* * Force low_latency on; otherwise the pushes are scheduled; @@ -495,7 +501,8 @@ static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *ol * on the floor. We don't want to drop bytes on the floor. :) */ port->tty->low_latency = 1; - tty_encode_baud_rate(port->tty, 115200, 115200); + + return; } diff --git a/trunk/drivers/usb/serial/ftdi_sio.c b/trunk/drivers/usb/serial/ftdi_sio.c index c40e77dccf8e..8a8a6b9fb05b 100644 --- a/trunk/drivers/usb/serial/ftdi_sio.c +++ b/trunk/drivers/usb/serial/ftdi_sio.c @@ -294,7 +294,7 @@ struct ftdi_private { __u16 interface; /* FT2232C port interface (0 for FT232/245) */ - speed_t force_baud; /* if non-zero, force the baud rate to this value */ + int force_baud; /* if non-zero, force the baud rate to this value */ int force_rtscts; /* if non-zero, force RTS-CTS to always be enabled */ spinlock_t tx_lock; /* spinlock for transmit state */ @@ -878,7 +878,6 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) if (div_value == 0) { dbg("%s - Baudrate (%d) requested is not supported", __FUNCTION__, baud); div_value = ftdi_sio_b9600; - baud = 9600; div_okay = 0; } break; @@ -887,7 +886,6 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) div_value = ftdi_232am_baud_to_divisor(baud); } else { dbg("%s - Baud rate too high!", __FUNCTION__); - baud = 9600; div_value = ftdi_232am_baud_to_divisor(9600); div_okay = 0; } @@ -901,7 +899,6 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) dbg("%s - Baud rate too high!", __FUNCTION__); div_value = ftdi_232bm_baud_to_divisor(9600); div_okay = 0; - baud = 9600; } break; } /* priv->chip_type */ @@ -912,7 +909,6 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) ftdi_chip_name[priv->chip_type]); } - tty_encode_baud_rate(port->tty, baud, baud); return(div_value); } @@ -1267,7 +1263,7 @@ static void ftdi_USB_UIRT_setup (struct ftdi_private *priv) priv->flags |= ASYNC_SPD_CUST; priv->custom_divisor = 77; - priv->force_baud = 38400; + priv->force_baud = B38400; } /* ftdi_USB_UIRT_setup */ /* Setup for the HE-TIRA1 device, which requires hardwired @@ -1278,7 +1274,7 @@ static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv) priv->flags |= ASYNC_SPD_CUST; priv->custom_divisor = 240; - priv->force_baud = 38400; + priv->force_baud = B38400; priv->force_rtscts = 1; } /* ftdi_HE_TIRA1_setup */ @@ -1367,7 +1363,7 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp) /* ftdi_set_termios will send usb control messages */ if (port->tty) - ftdi_set_termios(port, port->tty->termios); + ftdi_set_termios(port, NULL); /* FIXME: Flow control might be enabled, so it should be checked - we have no control of defaults! */ @@ -1937,33 +1933,32 @@ static void ftdi_break_ctl( struct usb_serial_port *port, int break_state ) static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) { /* ftdi_termios */ struct usb_device *dev = port->serial->dev; + unsigned int cflag = port->tty->termios->c_cflag; struct ftdi_private *priv = usb_get_serial_port_data(port); - struct ktermios *termios = port->tty->termios; - unsigned int cflag = termios->c_cflag; __u16 urb_value; /* will hold the new flags */ char buf[1]; /* Perhaps I should dynamically alloc this? */ // Added for xon/xoff support - unsigned int iflag = termios->c_iflag; + unsigned int iflag = port->tty->termios->c_iflag; unsigned char vstop; unsigned char vstart; dbg("%s", __FUNCTION__); /* Force baud rate if this device requires it, unless it is set to B0. */ - if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) { + if (priv->force_baud && ((port->tty->termios->c_cflag & CBAUD) != B0)) { dbg("%s: forcing baud rate for this device", __FUNCTION__); - tty_encode_baud_rate(port->tty, priv->force_baud, - priv->force_baud); + port->tty->termios->c_cflag &= ~CBAUD; + port->tty->termios->c_cflag |= priv->force_baud; } /* Force RTS-CTS if this device requires it. */ if (priv->force_rtscts) { dbg("%s: forcing rtscts for this device", __FUNCTION__); - termios->c_cflag |= CRTSCTS; + port->tty->termios->c_cflag |= CRTSCTS; } - cflag = termios->c_cflag; + cflag = port->tty->termios->c_cflag; /* FIXME -For this cut I don't care if the line is really changing or not - so just do the change regardless - should be able to @@ -1974,8 +1969,6 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old /* Set number of data bits, parity, stop bits */ - termios->c_cflag &= ~CMSPAR; - urb_value = 0; urb_value |= (cflag & CSTOPB ? FTDI_SIO_SET_DATA_STOP_BITS_2 : FTDI_SIO_SET_DATA_STOP_BITS_1); @@ -2055,8 +2048,8 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old // Set the vstart and vstop -- could have been done up above where // a lot of other dereferencing is done but that would be very // inefficient as vstart and vstop are not always needed - vstart = termios->c_cc[VSTART]; - vstop = termios->c_cc[VSTOP]; + vstart=port->tty->termios->c_cc[VSTART]; + vstop=port->tty->termios->c_cc[VSTOP]; urb_value=(vstop << 8) | (vstart); if (usb_control_msg(dev, diff --git a/trunk/drivers/usb/serial/generic.c b/trunk/drivers/usb/serial/generic.c index 9eb4a65ee4d9..88a2c7dce335 100644 --- a/trunk/drivers/usb/serial/generic.c +++ b/trunk/drivers/usb/serial/generic.c @@ -208,15 +208,14 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char * /* only do something if we have a bulk out endpoint */ if (serial->num_bulk_out) { - unsigned long flags; - spin_lock_irqsave(&port->lock, flags); + spin_lock_bh(&port->lock); if (port->write_urb_busy) { - spin_unlock_irqrestore(&port->lock, flags); + spin_unlock_bh(&port->lock); dbg("%s - already writing", __FUNCTION__); return 0; } port->write_urb_busy = 1; - spin_unlock_irqrestore(&port->lock, flags); + spin_unlock_bh(&port->lock); count = (count > port->bulk_out_size) ? port->bulk_out_size : count; diff --git a/trunk/drivers/usb/serial/io_edgeport.c b/trunk/drivers/usb/serial/io_edgeport.c index a5d2e115e167..8dd3abc99d63 100644 --- a/trunk/drivers/usb/serial/io_edgeport.c +++ b/trunk/drivers/usb/serial/io_edgeport.c @@ -1503,16 +1503,22 @@ static void edge_unthrottle (struct usb_serial_port *port) *****************************************************************************/ static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) { - /* FIXME: This function appears unused ?? */ struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct tty_struct *tty = port->tty; unsigned int cflag; + if (!port->tty || !port->tty->termios) { + dbg ("%s - no tty or termios", __FUNCTION__); + return; + } + cflag = tty->termios->c_cflag; dbg("%s - clfag %08x iflag %08x", __FUNCTION__, tty->termios->c_cflag, tty->termios->c_iflag); - dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, - old_termios->c_cflag, old_termios->c_iflag); + if (old_termios) { + dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, + old_termios->c_cflag, old_termios->c_iflag); + } dbg("%s - port %d", __FUNCTION__, port->number); @@ -2647,11 +2653,7 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi dbg("%s - baud rate = %d", __FUNCTION__, baud); status = send_cmd_write_baud_rate (edge_port, baud); - if (status == -1) { - /* Speed change was not possible - put back the old speed */ - baud = tty_termios_baud_rate(old_termios); - tty_encode_baud_rate(tty, baud, baud); - } + return; } diff --git a/trunk/drivers/usb/serial/ir-usb.c b/trunk/drivers/usb/serial/ir-usb.c index 6b803ab98543..5ab6a0c5ac52 100644 --- a/trunk/drivers/usb/serial/ir-usb.c +++ b/trunk/drivers/usb/serial/ir-usb.c @@ -504,6 +504,11 @@ static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_t dbg("%s - port %d", __FUNCTION__, port->number); + if ((!port->tty) || (!port->tty->termios)) { + dbg("%s - no tty structures", __FUNCTION__); + return; + } + baud = tty_get_baud_rate(port->tty); /* @@ -526,6 +531,8 @@ static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_t default: ir_baud = SPEED_9600; baud = 9600; + /* And once the new tty stuff is all done we need to + call back to correct the baud bits */ } if (xbof == -1) @@ -555,10 +562,6 @@ static void ir_set_termios (struct usb_serial_port *port, struct ktermios *old_t result = usb_submit_urb (port->write_urb, GFP_KERNEL); if (result) dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result); - - /* Only speed changes are supported */ - tty_termios_copy_hw(port->tty->termios, old_termios); - tty_encode_baud_rate(port->tty, baud, baud); } diff --git a/trunk/drivers/usb/serial/keyspan.c b/trunk/drivers/usb/serial/keyspan.c index 6bfdba6a213f..f2a6fce5de1e 100644 --- a/trunk/drivers/usb/serial/keyspan.c +++ b/trunk/drivers/usb/serial/keyspan.c @@ -278,35 +278,29 @@ static void keyspan_set_termios (struct usb_serial_port *port, struct keyspan_port_private *p_priv; const struct keyspan_device_details *d_details; unsigned int cflag; - struct tty_struct *tty = port->tty; dbg("%s", __FUNCTION__); p_priv = usb_get_serial_port_data(port); d_details = p_priv->device_details; - cflag = tty->termios->c_cflag; + cflag = port->tty->termios->c_cflag; device_port = port->number - port->serial->minor; /* Baud rate calculation takes baud rate as an integer so other rates can be generated if desired. */ - baud_rate = tty_get_baud_rate(tty); + baud_rate = tty_get_baud_rate(port->tty); /* If no match or invalid, don't change */ - if (d_details->calculate_baud_rate(baud_rate, d_details->baudclk, + if (baud_rate >= 0 + && d_details->calculate_baud_rate(baud_rate, d_details->baudclk, NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) { /* FIXME - more to do here to ensure rate changes cleanly */ - /* FIXME - calcuate exact rate from divisor ? */ p_priv->baud = baud_rate; - } else - baud_rate = tty_termios_baud_rate(old_termios); + } - tty_encode_baud_rate(tty, baud_rate, baud_rate); /* set CTS/RTS handshake etc. */ p_priv->cflag = cflag; p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none; - /* Mark/Space not supported */ - tty->termios->c_cflag &= ~CMSPAR; - keyspan_send_setup(port, 0); } diff --git a/trunk/drivers/usb/serial/kobil_sct.c b/trunk/drivers/usb/serial/kobil_sct.c index aee450246bfd..6f224195bd25 100644 --- a/trunk/drivers/usb/serial/kobil_sct.c +++ b/trunk/drivers/usb/serial/kobil_sct.c @@ -616,9 +616,8 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old case 1200: urb_val = SUSBCR_SBR_1200; break; - default: - speed = 9600; case 9600: + default: urb_val = SUSBCR_SBR_9600; break; } @@ -642,8 +641,6 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old urb_val |= SUSBCR_SPASB_NoParity; strcat(settings, "No Parity"); } - port->tty->termios->c_cflag &= ~CMSPAR; - tty_encode_baud_rate(port->tty, speed, speed); result = usb_control_msg( port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0 ), diff --git a/trunk/drivers/usb/serial/mos7840.c b/trunk/drivers/usb/serial/mos7840.c index a5ced7e08cbf..f76480f1455d 100644 --- a/trunk/drivers/usb/serial/mos7840.c +++ b/trunk/drivers/usb/serial/mos7840.c @@ -1977,6 +1977,11 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port, tty = mos7840_port->port->tty; + if ((!tty) || (!tty->termios)) { + dbg("%s - no tty structures", __FUNCTION__); + return; + } + dbg("%s", "Entering .......... \n"); lData = LCR_BITS_8; @@ -2146,6 +2151,11 @@ static void mos7840_set_termios(struct usb_serial_port *port, tty = port->tty; + if (!port->tty || !port->tty->termios) { + dbg("%s - no tty or termios", __FUNCTION__); + return; + } + if (!mos7840_port->open) { dbg("%s - port not opened", __FUNCTION__); return; @@ -2155,10 +2165,19 @@ static void mos7840_set_termios(struct usb_serial_port *port, cflag = tty->termios->c_cflag; + if (!cflag) { + dbg("%s %s\n", __FUNCTION__, "cflag is NULL"); + return; + } + dbg("%s - clfag %08x iflag %08x", __FUNCTION__, tty->termios->c_cflag, RELEVANT_IFLAG(tty->termios->c_iflag)); - dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, - old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag)); + + if (old_termios) { + dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__, + old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag)); + } + dbg("%s - port %d", __FUNCTION__, port->number); /* change the port settings to the new ones specified */ diff --git a/trunk/drivers/usb/serial/option.c b/trunk/drivers/usb/serial/option.c index 4590124cf888..a18659e0700c 100644 --- a/trunk/drivers/usb/serial/option.c +++ b/trunk/drivers/usb/serial/option.c @@ -172,8 +172,6 @@ static struct usb_device_id option_ids[] = { { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2110) }, /* Novatel Merlin ES620 / Merlin ES720 / Ovation U720 */ { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2130) }, /* Novatel Merlin ES620 SM Bus */ { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2410) }, /* Novatel EU740 */ - { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x4100) }, /* Novatel U727 */ - { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x4400) }, /* Novatel MC950 */ { USB_DEVICE(DELL_VENDOR_ID, 0x8114) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite EV620 CDMA/EV-DO */ { USB_DEVICE(DELL_VENDOR_ID, 0x8115) }, /* Dell Wireless 5500 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ { USB_DEVICE(DELL_VENDOR_ID, 0x8116) }, /* Dell Wireless 5505 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ @@ -313,8 +311,7 @@ static void option_set_termios(struct usb_serial_port *port, struct ktermios *old_termios) { dbg("%s", __FUNCTION__); - /* Doesn't support option setting */ - tty_termios_copy_hw(port->tty->termios, old_termios); + option_send_setup(port); } diff --git a/trunk/drivers/usb/serial/pl2303.c b/trunk/drivers/usb/serial/pl2303.c index 2cd3f1d4b687..1da57fd9ea23 100644 --- a/trunk/drivers/usb/serial/pl2303.c +++ b/trunk/drivers/usb/serial/pl2303.c @@ -56,7 +56,6 @@ static struct usb_device_id id_table [] = { { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ3) }, { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) }, { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, - { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) }, { USB_DEVICE(ATEN_VENDOR_ID2, ATEN_PRODUCT_ID) }, { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID) }, @@ -471,13 +470,16 @@ static void pl2303_set_termios(struct usb_serial_port *port, dbg("%s - port %d", __FUNCTION__, port->number); + if ((!port->tty) || (!port->tty->termios)) { + dbg("%s - no tty structures", __FUNCTION__); + return; + } + spin_lock_irqsave(&priv->lock, flags); if (!priv->termios_initialized) { *(port->tty->termios) = tty_std_termios; port->tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; - port->tty->termios->c_ispeed = 9600; - port->tty->termios->c_ospeed = 9600; priv->termios_initialized = 1; } spin_unlock_irqrestore(&priv->lock, flags); @@ -594,10 +596,6 @@ static void pl2303_set_termios(struct usb_serial_port *port, dbg ("0x40:0x1:0x0:0x0 %d", i); } - /* FIXME: Need to read back resulting baud rate */ - if (baud) - tty_encode_baud_rate(port->tty, baud, baud); - kfree(buf); } diff --git a/trunk/drivers/usb/serial/pl2303.h b/trunk/drivers/usb/serial/pl2303.h index ed603e3decd6..c39bace5cbcc 100644 --- a/trunk/drivers/usb/serial/pl2303.h +++ b/trunk/drivers/usb/serial/pl2303.h @@ -20,7 +20,6 @@ #define IODATA_VENDOR_ID 0x04bb #define IODATA_PRODUCT_ID 0x0a03 -#define IODATA_PRODUCT_ID_RSAQ5 0x0a0e #define ELCOM_VENDOR_ID 0x056e #define ELCOM_PRODUCT_ID 0x5003 diff --git a/trunk/drivers/usb/serial/sierra.c b/trunk/drivers/usb/serial/sierra.c index 833f6e1e3721..959b3e4e9077 100644 --- a/trunk/drivers/usb/serial/sierra.c +++ b/trunk/drivers/usb/serial/sierra.c @@ -224,7 +224,7 @@ static void sierra_set_termios(struct usb_serial_port *port, struct ktermios *old_termios) { dbg("%s", __FUNCTION__); - tty_termios_copy_hw(port->tty->termios, old_termios); + sierra_send_setup(port); } diff --git a/trunk/drivers/usb/serial/usb-serial.c b/trunk/drivers/usb/serial/usb-serial.c index 497e29a700ca..4b1bd7def4a5 100644 --- a/trunk/drivers/usb/serial/usb-serial.c +++ b/trunk/drivers/usb/serial/usb-serial.c @@ -429,8 +429,6 @@ static void serial_set_termios (struct tty_struct *tty, struct ktermios * old) /* pass on to the driver specific version of this function if it is available */ if (port->serial->type->set_termios) port->serial->type->set_termios(port, old); - else - tty_termios_copy_hw(tty->termios, old); } static void serial_break (struct tty_struct *tty, int break_state) @@ -1123,9 +1121,7 @@ int usb_serial_resume(struct usb_interface *intf) { struct usb_serial *serial = usb_get_intfdata(intf); - if (serial->type->resume) - return serial->type->resume(serial); - return 0; + return serial->type->resume(serial); } EXPORT_SYMBOL(usb_serial_resume); diff --git a/trunk/drivers/usb/serial/whiteheat.c b/trunk/drivers/usb/serial/whiteheat.c index ee5dd8b5a713..cc8b44c08712 100644 --- a/trunk/drivers/usb/serial/whiteheat.c +++ b/trunk/drivers/usb/serial/whiteheat.c @@ -885,7 +885,16 @@ static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, un static void whiteheat_set_termios(struct usb_serial_port *port, struct ktermios *old_termios) { dbg("%s -port %d", __FUNCTION__, port->number); + + if ((!port->tty) || (!port->tty->termios)) { + dbg("%s - no tty structures", __FUNCTION__); + goto exit; + } + firm_setup_port(port); + +exit: + return; } @@ -1235,8 +1244,6 @@ static int firm_setup_port(struct usb_serial_port *port) { port_settings.baud = tty_get_baud_rate(port->tty); dbg("%s - baud rate = %d", __FUNCTION__, port_settings.baud); - /* fixme: should set validated settings */ - tty_encode_baud_rate(port->tty, port_settings.baud, port_settings.baud); /* handle any settings that aren't specified in the tty structure */ port_settings.lloop = 0; diff --git a/trunk/drivers/usb/storage/Kconfig b/trunk/drivers/usb/storage/Kconfig index 7e53333be013..fe2c4cd53f5a 100644 --- a/trunk/drivers/usb/storage/Kconfig +++ b/trunk/drivers/usb/storage/Kconfig @@ -48,6 +48,7 @@ config USB_STORAGE_FREECOM config USB_STORAGE_ISD200 bool "ISD-200 USB/ATA Bridge support" depends on USB_STORAGE + depends on BLK_DEV_IDE=y || BLK_DEV_IDE=USB_STORAGE ---help--- Say Y here if you want to use USB Mass Store devices based on the In-Systems Design ISD-200 USB/ATA bridge. diff --git a/trunk/drivers/usb/storage/isd200.c b/trunk/drivers/usb/storage/isd200.c index 49ba6c0ff1e8..93a7724e167a 100644 --- a/trunk/drivers/usb/storage/isd200.c +++ b/trunk/drivers/usb/storage/isd200.c @@ -977,109 +977,6 @@ static int isd200_manual_enum(struct us_data *us) return(retStatus); } -/* - * We are the last non IDE user of the legacy IDE ident structures - * and we thus want to keep a private copy of this function so the - * driver can be used without the obsolete drivers/ide layer - */ - -static void isd200_fix_driveid (struct hd_driveid *id) -{ -#ifndef __LITTLE_ENDIAN -# ifdef __BIG_ENDIAN - int i; - u16 *stringcast; - - id->config = __le16_to_cpu(id->config); - id->cyls = __le16_to_cpu(id->cyls); - id->reserved2 = __le16_to_cpu(id->reserved2); - id->heads = __le16_to_cpu(id->heads); - id->track_bytes = __le16_to_cpu(id->track_bytes); - id->sector_bytes = __le16_to_cpu(id->sector_bytes); - id->sectors = __le16_to_cpu(id->sectors); - id->vendor0 = __le16_to_cpu(id->vendor0); - id->vendor1 = __le16_to_cpu(id->vendor1); - id->vendor2 = __le16_to_cpu(id->vendor2); - stringcast = (u16 *)&id->serial_no[0]; - for (i = 0; i < (20/2); i++) - stringcast[i] = __le16_to_cpu(stringcast[i]); - id->buf_type = __le16_to_cpu(id->buf_type); - id->buf_size = __le16_to_cpu(id->buf_size); - id->ecc_bytes = __le16_to_cpu(id->ecc_bytes); - stringcast = (u16 *)&id->fw_rev[0]; - for (i = 0; i < (8/2); i++) - stringcast[i] = __le16_to_cpu(stringcast[i]); - stringcast = (u16 *)&id->model[0]; - for (i = 0; i < (40/2); i++) - stringcast[i] = __le16_to_cpu(stringcast[i]); - id->dword_io = __le16_to_cpu(id->dword_io); - id->reserved50 = __le16_to_cpu(id->reserved50); - id->field_valid = __le16_to_cpu(id->field_valid); - id->cur_cyls = __le16_to_cpu(id->cur_cyls); - id->cur_heads = __le16_to_cpu(id->cur_heads); - id->cur_sectors = __le16_to_cpu(id->cur_sectors); - id->cur_capacity0 = __le16_to_cpu(id->cur_capacity0); - id->cur_capacity1 = __le16_to_cpu(id->cur_capacity1); - id->lba_capacity = __le32_to_cpu(id->lba_capacity); - id->dma_1word = __le16_to_cpu(id->dma_1word); - id->dma_mword = __le16_to_cpu(id->dma_mword); - id->eide_pio_modes = __le16_to_cpu(id->eide_pio_modes); - id->eide_dma_min = __le16_to_cpu(id->eide_dma_min); - id->eide_dma_time = __le16_to_cpu(id->eide_dma_time); - id->eide_pio = __le16_to_cpu(id->eide_pio); - id->eide_pio_iordy = __le16_to_cpu(id->eide_pio_iordy); - for (i = 0; i < 2; ++i) - id->words69_70[i] = __le16_to_cpu(id->words69_70[i]); - for (i = 0; i < 4; ++i) - id->words71_74[i] = __le16_to_cpu(id->words71_74[i]); - id->queue_depth = __le16_to_cpu(id->queue_depth); - for (i = 0; i < 4; ++i) - id->words76_79[i] = __le16_to_cpu(id->words76_79[i]); - id->major_rev_num = __le16_to_cpu(id->major_rev_num); - id->minor_rev_num = __le16_to_cpu(id->minor_rev_num); - id->command_set_1 = __le16_to_cpu(id->command_set_1); - id->command_set_2 = __le16_to_cpu(id->command_set_2); - id->cfsse = __le16_to_cpu(id->cfsse); - id->cfs_enable_1 = __le16_to_cpu(id->cfs_enable_1); - id->cfs_enable_2 = __le16_to_cpu(id->cfs_enable_2); - id->csf_default = __le16_to_cpu(id->csf_default); - id->dma_ultra = __le16_to_cpu(id->dma_ultra); - id->trseuc = __le16_to_cpu(id->trseuc); - id->trsEuc = __le16_to_cpu(id->trsEuc); - id->CurAPMvalues = __le16_to_cpu(id->CurAPMvalues); - id->mprc = __le16_to_cpu(id->mprc); - id->hw_config = __le16_to_cpu(id->hw_config); - id->acoustic = __le16_to_cpu(id->acoustic); - id->msrqs = __le16_to_cpu(id->msrqs); - id->sxfert = __le16_to_cpu(id->sxfert); - id->sal = __le16_to_cpu(id->sal); - id->spg = __le32_to_cpu(id->spg); - id->lba_capacity_2 = __le64_to_cpu(id->lba_capacity_2); - for (i = 0; i < 22; i++) - id->words104_125[i] = __le16_to_cpu(id->words104_125[i]); - id->last_lun = __le16_to_cpu(id->last_lun); - id->word127 = __le16_to_cpu(id->word127); - id->dlf = __le16_to_cpu(id->dlf); - id->csfo = __le16_to_cpu(id->csfo); - for (i = 0; i < 26; i++) - id->words130_155[i] = __le16_to_cpu(id->words130_155[i]); - id->word156 = __le16_to_cpu(id->word156); - for (i = 0; i < 3; i++) - id->words157_159[i] = __le16_to_cpu(id->words157_159[i]); - id->cfa_power = __le16_to_cpu(id->cfa_power); - for (i = 0; i < 14; i++) - id->words161_175[i] = __le16_to_cpu(id->words161_175[i]); - for (i = 0; i < 31; i++) - id->words176_205[i] = __le16_to_cpu(id->words176_205[i]); - for (i = 0; i < 48; i++) - id->words206_254[i] = __le16_to_cpu(id->words206_254[i]); - id->integrity_word = __le16_to_cpu(id->integrity_word); -# else -# error "Please fix " -# endif -#endif -} - /************************************************************************** * isd200_get_inquiry_data @@ -1121,7 +1018,7 @@ static int isd200_get_inquiry_data( struct us_data *us ) int i; __be16 *src; __u16 *dest; - isd200_fix_driveid(id); + ide_fix_driveid(id); US_DEBUGP(" Identify Data Structure:\n"); US_DEBUGP(" config = 0x%x\n", id->config); diff --git a/trunk/drivers/video/Kconfig b/trunk/drivers/video/Kconfig index cc4b60f899ca..fb9d8d0b2c04 100644 --- a/trunk/drivers/video/Kconfig +++ b/trunk/drivers/video/Kconfig @@ -1509,7 +1509,7 @@ config FB_VOODOO1 WARNING: Do not use any application that uses the 3D engine (namely glide) while using this driver. - Please read the for supported + Please read the for supported options and other important info support. config FB_VT8623 @@ -1807,7 +1807,7 @@ config FB_SM501 This driver is also available as a module ( = code which can be inserted and removed from the running kernel whenever you want). The module will be called sm501fb. If you want to compile it as a module, - say M here and read . + say M here and read . If unsure, say N. @@ -1892,7 +1892,9 @@ config FB_VIRTUAL If unsure, say N. -source "drivers/video/omap/Kconfig" +if ARCH_OMAP + source "drivers/video/omap/Kconfig" +endif source "drivers/video/backlight/Kconfig" source "drivers/video/display/Kconfig" diff --git a/trunk/drivers/video/aty/radeon_pm.c b/trunk/drivers/video/aty/radeon_pm.c index 83ee3e75386c..be1d57bf9dc8 100644 --- a/trunk/drivers/video/aty/radeon_pm.c +++ b/trunk/drivers/video/aty/radeon_pm.c @@ -27,6 +27,8 @@ #include "ati_ids.h" +static void radeon_reinitialize_M10(struct radeonfb_info *rinfo); + /* * Workarounds for bugs in PC laptops: * - enable D2 sleep in some IBM Thinkpads @@ -37,8 +39,6 @@ */ #if defined(CONFIG_PM) && defined(CONFIG_X86) -static void radeon_reinitialize_M10(struct radeonfb_info *rinfo); - struct radeon_device_id { const char *ident; /* (arbitrary) Name */ const unsigned short subsystem_vendor; /* Subsystem Vendor ID */ diff --git a/trunk/drivers/video/cirrusfb.c b/trunk/drivers/video/cirrusfb.c index f7e2d5add831..f99cb77e7b42 100644 --- a/trunk/drivers/video/cirrusfb.c +++ b/trunk/drivers/video/cirrusfb.c @@ -2509,7 +2509,8 @@ static int cirrusfb_zorro_register(struct zorro_dev *z, cinfo = info->par; cinfo->btype = btype; - assert(z); + assert(z > 0); + assert(z2 >= 0); assert(btype != BT_NONE); cinfo->zdev = z; diff --git a/trunk/drivers/video/omap/Kconfig b/trunk/drivers/video/omap/Kconfig index 44408850e2eb..f4fcf11b290d 100644 --- a/trunk/drivers/video/omap/Kconfig +++ b/trunk/drivers/video/omap/Kconfig @@ -1,6 +1,6 @@ config FB_OMAP tristate "OMAP frame buffer support (EXPERIMENTAL)" - depends on FB && ARCH_OMAP + depends on FB select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT diff --git a/trunk/drivers/w1/Kconfig b/trunk/drivers/w1/Kconfig index 9adbb4f90479..6854fd6b9714 100644 --- a/trunk/drivers/w1/Kconfig +++ b/trunk/drivers/w1/Kconfig @@ -17,8 +17,7 @@ config W1_CON bool "Userspace communication over connector" default y --- help --- - This allows to communicate with userspace using connector. For more - information see . + This allows to communicate with userspace using connector [Documentation/connector]. There are three types of messages between w1 core and userspace: 1. Events. They are generated each time new master or slave device found either due to automatic or requested search. diff --git a/trunk/drivers/watchdog/Kconfig b/trunk/drivers/watchdog/Kconfig index 2792bc1a7269..37bddc1802de 100644 --- a/trunk/drivers/watchdog/Kconfig +++ b/trunk/drivers/watchdog/Kconfig @@ -15,8 +15,8 @@ menuconfig WATCHDOG implementation entirely in software (which can sometimes fail to reboot the machine) and a driver for hardware watchdog boards, which are more robust and can also keep track of the temperature inside - your computer. For details, read - in the kernel source. + your computer. For details, read + in the kernel source. The watchdog is usually used together with the watchdog daemon which is available from @@ -343,12 +343,11 @@ config IBMASR module will be called ibmasr. config WAFER_WDT - tristate "ICP Single Board Computer Watchdog Timer" + tristate "ICP Wafer 5823 Single Board Computer Watchdog" depends on X86 help - This is a driver for the hardware watchdog on the ICP Single - Board Computer. This driver is working on (at least) the following - IPC SBC's: Wafer 5823, Rocky 4783, Rocky 3703 and Rocky 3782. + This is a driver for the hardware watchdog on the ICP Wafer 5823 + Single Board Computer (and probably other similar models). To compile this driver as a module, choose M here: the module will be called wafer5823wdt. @@ -610,12 +609,6 @@ config WDT_RM9K_GPI To compile this driver as a module, choose M here: the module will be called rm9k_wdt. -config AR7_WDT - tristate "TI AR7 Watchdog Timer" - depends on AR7 - help - Hardware driver for the TI AR7 Watchdog Timer. - # PARISC Architecture # POWERPC Architecture diff --git a/trunk/drivers/watchdog/Makefile b/trunk/drivers/watchdog/Makefile index 7d9e5734f8bb..389f8b14ccc4 100644 --- a/trunk/drivers/watchdog/Makefile +++ b/trunk/drivers/watchdog/Makefile @@ -90,7 +90,6 @@ obj-$(CONFIG_SBC_EPX_C3_WATCHDOG) += sbc_epx_c3.o obj-$(CONFIG_INDYDOG) += indydog.o obj-$(CONFIG_WDT_MTX1) += mtx-1_wdt.o obj-$(CONFIG_WDT_RM9K_GPI) += rm9k_wdt.o -obj-$(CONFIG_AR7_WDT) += ar7_wdt.o # PARISC Architecture diff --git a/trunk/drivers/watchdog/ar7_wdt.c b/trunk/drivers/watchdog/ar7_wdt.c deleted file mode 100644 index cdaab8c3d3d0..000000000000 --- a/trunk/drivers/watchdog/ar7_wdt.c +++ /dev/null @@ -1,349 +0,0 @@ -/* - * drivers/watchdog/ar7_wdt.c - * - * Copyright (C) 2007 Nicolas Thill - * Copyright (c) 2005 Enrik Berkhan - * - * Some code taken from: - * National Semiconductor SCx200 Watchdog support - * Copyright (c) 2001,2002 Christer Weinigel - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#define DRVNAME "ar7_wdt" -#define LONGNAME "TI AR7 Watchdog Timer" - -MODULE_AUTHOR("Nicolas Thill "); -MODULE_DESCRIPTION(LONGNAME); -MODULE_LICENSE("GPL"); -MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); - -static int margin = 60; -module_param(margin, int, 0); -MODULE_PARM_DESC(margin, "Watchdog margin in seconds"); - -static int nowayout = WATCHDOG_NOWAYOUT; -module_param(nowayout, int, 0); -MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close"); - -#define READ_REG(x) readl((void __iomem *)&(x)) -#define WRITE_REG(x, v) writel((v), (void __iomem *)&(x)) - -struct ar7_wdt { - u32 kick_lock; - u32 kick; - u32 change_lock; - u32 change; - u32 disable_lock; - u32 disable; - u32 prescale_lock; - u32 prescale; -}; - -static struct semaphore open_semaphore; -static unsigned expect_close; - -/* XXX currently fixed, allows max margin ~68.72 secs */ -#define prescale_value 0xffff - -/* Offset of the WDT registers */ -static unsigned long ar7_regs_wdt; -/* Pointer to the remapped WDT IO space */ -static struct ar7_wdt *ar7_wdt; -static void ar7_wdt_get_regs(void) -{ - u16 chip_id = ar7_chip_id(); - switch (chip_id) { - case AR7_CHIP_7100: - case AR7_CHIP_7200: - ar7_regs_wdt = AR7_REGS_WDT; - break; - default: - ar7_regs_wdt = UR8_REGS_WDT; - break; - } -} - - -static void ar7_wdt_kick(u32 value) -{ - WRITE_REG(ar7_wdt->kick_lock, 0x5555); - if ((READ_REG(ar7_wdt->kick_lock) & 3) == 1) { - WRITE_REG(ar7_wdt->kick_lock, 0xaaaa); - if ((READ_REG(ar7_wdt->kick_lock) & 3) == 3) { - WRITE_REG(ar7_wdt->kick, value); - return; - } - } - printk(KERN_ERR DRVNAME ": failed to unlock WDT kick reg\n"); -} - -static void ar7_wdt_prescale(u32 value) -{ - WRITE_REG(ar7_wdt->prescale_lock, 0x5a5a); - if ((READ_REG(ar7_wdt->prescale_lock) & 3) == 1) { - WRITE_REG(ar7_wdt->prescale_lock, 0xa5a5); - if ((READ_REG(ar7_wdt->prescale_lock) & 3) == 3) { - WRITE_REG(ar7_wdt->prescale, value); - return; - } - } - printk(KERN_ERR DRVNAME ": failed to unlock WDT prescale reg\n"); -} - -static void ar7_wdt_change(u32 value) -{ - WRITE_REG(ar7_wdt->change_lock, 0x6666); - if ((READ_REG(ar7_wdt->change_lock) & 3) == 1) { - WRITE_REG(ar7_wdt->change_lock, 0xbbbb); - if ((READ_REG(ar7_wdt->change_lock) & 3) == 3) { - WRITE_REG(ar7_wdt->change, value); - return; - } - } - printk(KERN_ERR DRVNAME ": failed to unlock WDT change reg\n"); -} - -static void ar7_wdt_disable(u32 value) -{ - WRITE_REG(ar7_wdt->disable_lock, 0x7777); - if ((READ_REG(ar7_wdt->disable_lock) & 3) == 1) { - WRITE_REG(ar7_wdt->disable_lock, 0xcccc); - if ((READ_REG(ar7_wdt->disable_lock) & 3) == 2) { - WRITE_REG(ar7_wdt->disable_lock, 0xdddd); - if ((READ_REG(ar7_wdt->disable_lock) & 3) == 3) { - WRITE_REG(ar7_wdt->disable, value); - return; - } - } - } - printk(KERN_ERR DRVNAME ": failed to unlock WDT disable reg\n"); -} - -static void ar7_wdt_update_margin(int new_margin) -{ - u32 change; - - change = new_margin * (ar7_vbus_freq() / prescale_value); - if (change < 1) change = 1; - if (change > 0xffff) change = 0xffff; - ar7_wdt_change(change); - margin = change * prescale_value / ar7_vbus_freq(); - printk(KERN_INFO DRVNAME - ": timer margin %d seconds (prescale %d, change %d, freq %d)\n", - margin, prescale_value, change, ar7_vbus_freq()); -} - -static void ar7_wdt_enable_wdt(void) -{ - printk(KERN_DEBUG DRVNAME ": enabling watchdog timer\n"); - ar7_wdt_disable(1); - ar7_wdt_kick(1); -} - -static void ar7_wdt_disable_wdt(void) -{ - printk(KERN_DEBUG DRVNAME ": disabling watchdog timer\n"); - ar7_wdt_disable(0); -} - -static int ar7_wdt_open(struct inode *inode, struct file *file) -{ - /* only allow one at a time */ - if (down_trylock(&open_semaphore)) - return -EBUSY; - ar7_wdt_enable_wdt(); - expect_close = 0; - - return nonseekable_open(inode, file); -} - -static int ar7_wdt_release(struct inode *inode, struct file *file) -{ - if (!expect_close) - printk(KERN_WARNING DRVNAME - ": watchdog device closed unexpectedly," - "will not disable the watchdog timer\n"); - else if (!nowayout) - ar7_wdt_disable_wdt(); - - up(&open_semaphore); - - return 0; -} - -static int ar7_wdt_notify_sys(struct notifier_block *this, - unsigned long code, void *unused) -{ - if (code == SYS_HALT || code == SYS_POWER_OFF) - if (!nowayout) - ar7_wdt_disable_wdt(); - - return NOTIFY_DONE; -} - -static struct notifier_block ar7_wdt_notifier = { - .notifier_call = ar7_wdt_notify_sys -}; - -static ssize_t ar7_wdt_write(struct file *file, const char *data, - size_t len, loff_t *ppos) -{ - /* check for a magic close character */ - if (len) { - size_t i; - - ar7_wdt_kick(1); - - expect_close = 0; - for (i = 0; i < len; ++i) { - char c; - if (get_user(c, data+i)) - return -EFAULT; - if (c == 'V') - expect_close = 1; - } - - } - return len; -} - -static int ar7_wdt_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) -{ - static struct watchdog_info ident = { - .identity = LONGNAME, - .firmware_version = 1, - .options = (WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING), - }; - int new_margin; - - switch (cmd) { - default: - return -ENOTTY; - case WDIOC_GETSUPPORT: - if (copy_to_user((struct watchdog_info *)arg, &ident, - sizeof(ident))) - return -EFAULT; - return 0; - case WDIOC_GETSTATUS: - case WDIOC_GETBOOTSTATUS: - if (put_user(0, (int *)arg)) - return -EFAULT; - return 0; - case WDIOC_KEEPALIVE: - ar7_wdt_kick(1); - return 0; - case WDIOC_SETTIMEOUT: - if (get_user(new_margin, (int *)arg)) - return -EFAULT; - if (new_margin < 1) - return -EINVAL; - - ar7_wdt_update_margin(new_margin); - ar7_wdt_kick(1); - - case WDIOC_GETTIMEOUT: - if (put_user(margin, (int *)arg)) - return -EFAULT; - return 0; - } -} - -static struct file_operations ar7_wdt_fops = { - .owner = THIS_MODULE, - .write = ar7_wdt_write, - .ioctl = ar7_wdt_ioctl, - .open = ar7_wdt_open, - .release = ar7_wdt_release, -}; - -static struct miscdevice ar7_wdt_miscdev = { - .minor = WATCHDOG_MINOR, - .name = "watchdog", - .fops = &ar7_wdt_fops, -}; - -static int __init ar7_wdt_init(void) -{ - int rc; - - ar7_wdt_get_regs(); - - if (!request_mem_region(ar7_regs_wdt, sizeof(struct ar7_wdt), - LONGNAME)) { - printk(KERN_WARNING DRVNAME ": watchdog I/O region busy\n"); - return -EBUSY; - } - - ar7_wdt = (struct ar7_wdt *) - ioremap(ar7_regs_wdt, sizeof(struct ar7_wdt)); - - ar7_wdt_disable_wdt(); - ar7_wdt_prescale(prescale_value); - ar7_wdt_update_margin(margin); - - sema_init(&open_semaphore, 1); - - rc = register_reboot_notifier(&ar7_wdt_notifier); - if (rc) { - printk(KERN_ERR DRVNAME - ": unable to register reboot notifier\n"); - goto out_alloc; - } - - rc = misc_register(&ar7_wdt_miscdev); - if (rc) { - printk(KERN_ERR DRVNAME ": unable to register misc device\n"); - goto out_register; - } - goto out; - -out_register: - unregister_reboot_notifier(&ar7_wdt_notifier); -out_alloc: - iounmap(ar7_wdt); - release_mem_region(ar7_regs_wdt, sizeof(struct ar7_wdt)); -out: - return rc; -} - -static void __exit ar7_wdt_cleanup(void) -{ - misc_deregister(&ar7_wdt_miscdev); - unregister_reboot_notifier(&ar7_wdt_notifier); - iounmap(ar7_wdt); - release_mem_region(ar7_regs_wdt, sizeof(struct ar7_wdt)); -} - -module_init(ar7_wdt_init); -module_exit(ar7_wdt_cleanup); diff --git a/trunk/fs/9p/v9fs.c b/trunk/fs/9p/v9fs.c index 756f7e9beb2e..873802de21cd 100644 --- a/trunk/fs/9p/v9fs.c +++ b/trunk/fs/9p/v9fs.c @@ -162,7 +162,6 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses) if (*e != '\0') v9ses->uid = ~0; } - kfree(s); break; default: diff --git a/trunk/fs/9p/vfs_inode.c b/trunk/fs/9p/vfs_inode.c index 23581bcb599b..175b4d9bf3f8 100644 --- a/trunk/fs/9p/vfs_inode.c +++ b/trunk/fs/9p/vfs_inode.c @@ -687,10 +687,10 @@ v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry, retval = p9_client_wstat(oldfid, &wstat); clunk_newdir: - p9_client_clunk(newdirfid); + p9_client_clunk(olddirfid); clunk_olddir: - p9_client_clunk(olddirfid); + p9_client_clunk(newdirfid); done: return retval; diff --git a/trunk/fs/Kconfig b/trunk/fs/Kconfig index c75c95406497..cc28a69246a7 100644 --- a/trunk/fs/Kconfig +++ b/trunk/fs/Kconfig @@ -504,7 +504,7 @@ config INOTIFY including multiple file events, one-shot support, and unmount notification. - For more information, see + For more information, see Documentation/filesystems/inotify.txt If unsure, say Y. @@ -518,7 +518,7 @@ config INOTIFY_USER directories via a single open fd. Events are read from the file descriptor, which is also select()- and poll()-able. - For more information, see + For more information, see Documentation/filesystems/inotify.txt If unsure, say Y. @@ -1089,7 +1089,7 @@ config ECRYPT_FS depends on EXPERIMENTAL && KEYS && CRYPTO && NET help Encrypted filesystem that operates on the VFS layer. See - to learn more about + to learn more about eCryptfs. Userspace components are required and can be obtained from . diff --git a/trunk/fs/ecryptfs/crypto.c b/trunk/fs/ecryptfs/crypto.c index 9d70289f7df3..0a9882edf562 100644 --- a/trunk/fs/ecryptfs/crypto.c +++ b/trunk/fs/ecryptfs/crypto.c @@ -279,13 +279,13 @@ int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg, int offset; int remainder_of_page; - sg_init_table(sg, sg_size); - while (size > 0 && i < sg_size) { pg = virt_to_page(addr); offset = offset_in_page(addr); - if (sg) - sg_set_page(&sg[i], pg, 0, offset); + if (sg) { + sg_set_page(&sg[i], pg); + sg[i].offset = offset; + } remainder_of_page = PAGE_CACHE_SIZE - offset; if (size >= remainder_of_page) { if (sg) @@ -716,8 +716,12 @@ ecryptfs_encrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, sg_init_table(&src_sg, 1); sg_init_table(&dst_sg, 1); - sg_set_page(&src_sg, src_page, size, src_offset); - sg_set_page(&dst_sg, dst_page, size, dst_offset); + sg_set_page(&src_sg, src_page); + src_sg.offset = src_offset; + src_sg.length = size; + sg_set_page(&dst_sg, dst_page); + dst_sg.offset = dst_offset; + dst_sg.length = size; return encrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv); } @@ -742,11 +746,14 @@ ecryptfs_decrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, struct scatterlist src_sg, dst_sg; sg_init_table(&src_sg, 1); - sg_set_page(&src_sg, src_page, size, src_offset); - sg_init_table(&dst_sg, 1); - sg_set_page(&dst_sg, dst_page, size, dst_offset); + sg_set_page(&src_sg, src_page); + src_sg.offset = src_offset; + src_sg.length = size; + sg_set_page(&dst_sg, dst_page); + dst_sg.offset = dst_offset; + dst_sg.length = size; return decrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv); } diff --git a/trunk/fs/jffs2/acl.c b/trunk/fs/jffs2/acl.c index 77fc5838609c..9728614b8958 100644 --- a/trunk/fs/jffs2/acl.c +++ b/trunk/fs/jffs2/acl.c @@ -372,7 +372,7 @@ int jffs2_init_acl_post(struct inode *inode) return rc; } - return 0; + return rc; } void jffs2_clear_acl(struct jffs2_inode_info *f) diff --git a/trunk/fs/locks.c b/trunk/fs/locks.c index 8b8388eca05e..0127a2846819 100644 --- a/trunk/fs/locks.c +++ b/trunk/fs/locks.c @@ -696,28 +696,17 @@ EXPORT_SYMBOL(posix_test_lock); * Note: the above assumption may not be true when handling lock requests * from a broken NFS client. But broken NFS clients have a lot more to * worry about than proper deadlock detection anyway... --okir - * - * However, the failure of this assumption (also possible in the case of - * multiple tasks sharing the same open file table) also means there's no - * guarantee that the loop below will terminate. As a hack, we give up - * after a few iterations. */ - -#define MAX_DEADLK_ITERATIONS 10 - static int posix_locks_deadlock(struct file_lock *caller_fl, struct file_lock *block_fl) { struct file_lock *fl; - int i = 0; next_task: if (posix_same_owner(caller_fl, block_fl)) return 1; list_for_each_entry(fl, &blocked_list, fl_link) { if (posix_same_owner(fl, block_fl)) { - if (i++ > MAX_DEADLK_ITERATIONS) - return 0; fl = fl->fl_next; block_fl = fl; goto next_task; diff --git a/trunk/fs/mbcache.c b/trunk/fs/mbcache.c index eb31b73e7d69..1046cbefbfbf 100644 --- a/trunk/fs/mbcache.c +++ b/trunk/fs/mbcache.c @@ -403,9 +403,9 @@ mb_cache_entry_alloc(struct mb_cache *cache) { struct mb_cache_entry *ce; + atomic_inc(&cache->c_entry_count); ce = kmem_cache_alloc(cache->c_entry_cache, GFP_KERNEL); if (ce) { - atomic_inc(&cache->c_entry_count); INIT_LIST_HEAD(&ce->e_lru_list); INIT_LIST_HEAD(&ce->e_block_list); ce->e_cache = cache; diff --git a/trunk/fs/nfs/direct.c b/trunk/fs/nfs/direct.c index afcab007a22b..32fe97211eea 100644 --- a/trunk/fs/nfs/direct.c +++ b/trunk/fs/nfs/direct.c @@ -549,13 +549,13 @@ static void nfs_direct_write_result(struct rpc_task *task, void *calldata) spin_lock(&dreq->lock); + if (unlikely(dreq->error != 0)) + goto out_unlock; if (unlikely(status < 0)) { - /* An error has occurred, so we should not commit */ + /* An error has occured, so we should not commit */ dreq->flags = 0; dreq->error = status; } - if (unlikely(dreq->error != 0)) - goto out_unlock; dreq->count += data->res.count; diff --git a/trunk/fs/proc/array.c b/trunk/fs/proc/array.c index eba339ecba27..63c95afb561f 100644 --- a/trunk/fs/proc/array.c +++ b/trunk/fs/proc/array.c @@ -358,8 +358,7 @@ static cputime_t task_utime(struct task_struct *p) } utime = (clock_t)temp; - p->prev_utime = max(p->prev_utime, clock_t_to_cputime(utime)); - return p->prev_utime; + return clock_t_to_cputime(utime); } static cputime_t task_stime(struct task_struct *p) @@ -374,8 +373,7 @@ static cputime_t task_stime(struct task_struct *p) stime = nsec_to_clock_t(p->se.sum_exec_runtime) - cputime_to_clock_t(task_utime(p)); - p->prev_stime = max(p->prev_stime, clock_t_to_cputime(stime)); - return p->prev_stime; + return clock_t_to_cputime(stime); } #endif diff --git a/trunk/fs/proc/proc_net.c b/trunk/fs/proc/proc_net.c index 749def054a34..2e91fb756e9a 100644 --- a/trunk/fs/proc/proc_net.c +++ b/trunk/fs/proc/proc_net.c @@ -185,7 +185,7 @@ static __net_exit void proc_net_ns_exit(struct net *net) kfree(net->proc_net_root); } -static struct pernet_operations proc_net_ns_ops = { +struct pernet_operations __net_initdata proc_net_ns_ops = { .init = proc_net_ns_init, .exit = proc_net_ns_exit, }; diff --git a/trunk/fs/proc/proc_sysctl.c b/trunk/fs/proc/proc_sysctl.c index 4e57fcf85982..680c429bfa22 100644 --- a/trunk/fs/proc/proc_sysctl.c +++ b/trunk/fs/proc/proc_sysctl.c @@ -171,8 +171,7 @@ static ssize_t proc_sys_read(struct file *filp, char __user *buf, struct dentry *dentry = filp->f_dentry; struct ctl_table_header *head; struct ctl_table *table; - ssize_t error; - size_t res; + ssize_t error, res; table = do_proc_sys_lookup(dentry->d_parent, &dentry->d_name, &head); /* Has the sysctl entry disappeared on us? */ @@ -210,8 +209,7 @@ static ssize_t proc_sys_write(struct file *filp, const char __user *buf, struct dentry *dentry = filp->f_dentry; struct ctl_table_header *head; struct ctl_table *table; - ssize_t error; - size_t res; + ssize_t error, res; table = do_proc_sys_lookup(dentry->d_parent, &dentry->d_name, &head); /* Has the sysctl entry disappeared on us? */ diff --git a/trunk/fs/ufs/super.c b/trunk/fs/ufs/super.c index c78c04fd993f..584cf12cc40f 100644 --- a/trunk/fs/ufs/super.c +++ b/trunk/fs/ufs/super.c @@ -933,19 +933,20 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) goto again; } - sbi->s_flags = flags;/*after that line some functions use s_flags*/ + /* Set sbi->s_flags here, used by ufs_get_fs_state() below */ + sbi->s_flags = flags; ufs_print_super_stuff(sb, usb1, usb2, usb3); /* * Check, if file system was correctly unmounted. * If not, make it read only. */ - if (((flags & UFS_ST_MASK) == UFS_ST_44BSD) || - ((flags & UFS_ST_MASK) == UFS_ST_OLD) || - (((flags & UFS_ST_MASK) == UFS_ST_SUN || - (flags & UFS_ST_MASK) == UFS_ST_SUNOS || - (flags & UFS_ST_MASK) == UFS_ST_SUNx86) && - (ufs_get_fs_state(sb, usb1, usb3) == (UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time))))) { + if ((((flags & UFS_ST_MASK) == UFS_ST_44BSD) || + ((flags & UFS_ST_MASK) == UFS_ST_OLD) || + ((flags & UFS_ST_MASK) == UFS_ST_SUN) || + ((flags & UFS_ST_MASK) == UFS_ST_SUNOS) || + ((flags & UFS_ST_MASK) == UFS_ST_SUNx86)) && + (ufs_get_fs_state(sb, usb1, usb3) == (UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time)))) { switch(usb1->fs_clean) { case UFS_FSCLEAN: UFSD("fs is clean\n"); diff --git a/trunk/include/acpi/acpi_bus.h b/trunk/include/acpi/acpi_bus.h index 19c3ead2a90b..7b74b60a68a4 100644 --- a/trunk/include/acpi/acpi_bus.h +++ b/trunk/include/acpi/acpi_bus.h @@ -168,7 +168,8 @@ struct acpi_device_flags { u32 power_manageable:1; u32 performance_manageable:1; u32 wake_capable:1; /* Wakeup(_PRW) supported? */ - u32 reserved:20; + u32 force_power_state:1; + u32 reserved:19; }; /* File System */ diff --git a/trunk/include/asm-avr32/dma-mapping.h b/trunk/include/asm-avr32/dma-mapping.h index 57dc672bab8e..a7131630c057 100644 --- a/trunk/include/asm-avr32/dma-mapping.h +++ b/trunk/include/asm-avr32/dma-mapping.h @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include #include diff --git a/trunk/include/asm-blackfin/bfin-global.h b/trunk/include/asm-blackfin/bfin-global.h index 0212e180b90e..14cb8d35924e 100644 --- a/trunk/include/asm-blackfin/bfin-global.h +++ b/trunk/include/asm-blackfin/bfin-global.h @@ -80,7 +80,6 @@ extern int atomic_sub32(void); extern int atomic_ior32(void); extern int atomic_and32(void); extern int atomic_xor32(void); -extern void safe_user_instruction(void); extern void sigreturn_stub(void); extern void *l1_data_A_sram_alloc(size_t); diff --git a/trunk/include/asm-blackfin/fixed_code.h b/trunk/include/asm-blackfin/fixed_code.h index 37db66c7030d..e6df84ee1557 100644 --- a/trunk/include/asm-blackfin/fixed_code.h +++ b/trunk/include/asm-blackfin/fixed_code.h @@ -17,6 +17,4 @@ #define ATOMIC_SEQS_END 0x480 -#define SAFE_USER_INSTRUCTION 0x480 - -#define FIXED_CODE_END 0x490 +#define FIXED_CODE_END 0x480 diff --git a/trunk/include/asm-blackfin/gptimers.h b/trunk/include/asm-blackfin/gptimers.h index 8265ea473d5b..c97ab03e43a6 100644 --- a/trunk/include/asm-blackfin/gptimers.h +++ b/trunk/include/asm-blackfin/gptimers.h @@ -197,8 +197,6 @@ uint32_t get_gptimer_period (int timer_id); uint32_t get_gptimer_count (int timer_id); uint16_t get_gptimer_intr (int timer_id); void clear_gptimer_intr (int timer_id); -uint16_t get_gptimer_over (int timer_id); -void clear_gptimer_over (int timer_id); void set_gptimer_config (int timer_id, uint16_t config); uint16_t get_gptimer_config (int timer_id); void set_gptimer_pulse_hi (int timer_id); diff --git a/trunk/include/asm-blackfin/mach-bf527/defBF52x_base.h b/trunk/include/asm-blackfin/mach-bf527/defBF52x_base.h index fc69cf93f149..d6c24c54699d 100644 --- a/trunk/include/asm-blackfin/mach-bf527/defBF52x_base.h +++ b/trunk/include/asm-blackfin/mach-bf527/defBF52x_base.h @@ -1718,55 +1718,55 @@ /* Bit masks for HOST_CONTROL */ -#define HOST_CNTR_HOST_EN 0x1 /* Host Enable */ -#define HOST_CNTR_nHOST_EN 0x0 -#define HOST_CNTR_HOST_END 0x2 /* Host Endianess */ -#define HOST_CNTR_nHOST_END 0x0 -#define HOST_CNTR_DATA_SIZE 0x4 /* Data Size */ -#define HOST_CNTR_nDATA_SIZE 0x0 -#define HOST_CNTR_HOST_RST 0x8 /* Host Reset */ -#define HOST_CNTR_nHOST_RST 0x0 -#define HOST_CNTR_HRDY_OVR 0x20 /* Host Ready Override */ -#define HOST_CNTR_nHRDY_OVR 0x0 -#define HOST_CNTR_INT_MODE 0x40 /* Interrupt Mode */ -#define HOST_CNTR_nINT_MODE 0x0 -#define HOST_CNTR_BT_EN 0x80 /* Bus Timeout Enable */ -#define HOST_CNTR_ nBT_EN 0x0 -#define HOST_CNTR_EHW 0x100 /* Enable Host Write */ -#define HOST_CNTR_nEHW 0x0 -#define HOST_CNTR_EHR 0x200 /* Enable Host Read */ -#define HOST_CNTR_nEHR 0x0 -#define HOST_CNTR_BDR 0x400 /* Burst DMA Requests */ -#define HOST_CNTR_nBDR 0x0 +#define HOST_EN 0x1 /* Host Enable */ +#define nHOST_EN 0x0 +#define HOST_END 0x2 /* Host Endianess */ +#define nHOST_END 0x0 +#define DATA_SIZE 0x4 /* Data Size */ +#define nDATA_SIZE 0x0 +#define HOST_RST 0x8 /* Host Reset */ +#define nHOST_RST 0x0 +#define HRDY_OVR 0x20 /* Host Ready Override */ +#define nHRDY_OVR 0x0 +#define INT_MODE 0x40 /* Interrupt Mode */ +#define nINT_MODE 0x0 +#define BT_EN 0x80 /* Bus Timeout Enable */ +#define nBT_EN 0x0 +#define EHW 0x100 /* Enable Host Write */ +#define nEHW 0x0 +#define EHR 0x200 /* Enable Host Read */ +#define nEHR 0x0 +#define BDR 0x400 /* Burst DMA Requests */ +#define nBDR 0x0 /* Bit masks for HOST_STATUS */ -#define HOST_STAT_READY 0x1 /* DMA Ready */ -#define HOST_STAT_nREADY 0x0 -#define HOST_STAT_FIFOFULL 0x2 /* FIFO Full */ -#define HOST_STAT_nFIFOFULL 0x0 -#define HOST_STAT_FIFOEMPTY 0x4 /* FIFO Empty */ -#define HOST_STAT_nFIFOEMPTY 0x0 -#define HOST_STAT_COMPLETE 0x8 /* DMA Complete */ -#define HOST_STAT_nCOMPLETE 0x0 -#define HOST_STAT_HSHK 0x10 /* Host Handshake */ -#define HOST_STAT_nHSHK 0x0 -#define HOST_STAT_TIMEOUT 0x20 /* Host Timeout */ -#define HOST_STAT_nTIMEOUT 0x0 -#define HOST_STAT_HIRQ 0x40 /* Host Interrupt Request */ -#define HOST_STAT_nHIRQ 0x0 -#define HOST_STAT_ALLOW_CNFG 0x80 /* Allow New Configuration */ -#define HOST_STAT_nALLOW_CNFG 0x0 -#define HOST_STAT_DMA_DIR 0x100 /* DMA Direction */ -#define HOST_STAT_nDMA_DIR 0x0 -#define HOST_STAT_BTE 0x200 /* Bus Timeout Enabled */ -#define HOST_STAT_nBTE 0x0 -#define HOST_STAT_HOSTRD_DONE 0x8000 /* Host Read Completion Interrupt */ -#define HOST_STAT_nHOSTRD_DONE 0x0 +#define READY 0x1 /* DMA Ready */ +#define nREADY 0x0 +#define FIFOFULL 0x2 /* FIFO Full */ +#define nFIFOFULL 0x0 +#define FIFOEMPTY 0x4 /* FIFO Empty */ +#define nFIFOEMPTY 0x0 +#define COMPLETE 0x8 /* DMA Complete */ +#define nCOMPLETE 0x0 +#define HSHK 0x10 /* Host Handshake */ +#define nHSHK 0x0 +#define TIMEOUT 0x20 /* Host Timeout */ +#define nTIMEOUT 0x0 +#define HIRQ 0x40 /* Host Interrupt Request */ +#define nHIRQ 0x0 +#define ALLOW_CNFG 0x80 /* Allow New Configuration */ +#define nALLOW_CNFG 0x0 +#define DMA_DIR 0x100 /* DMA Direction */ +#define nDMA_DIR 0x0 +#define BTE 0x200 /* Bus Timeout Enabled */ +#define nBTE 0x0 +#define HOSTRD_DONE 0x8000 /* Host Read Completion Interrupt */ +#define nHOSTRD_DONE 0x0 /* Bit masks for HOST_TIMEOUT */ -#define HOST_COUNT_TIMEOUT 0x7ff /* Host Timeout count */ +#define COUNT_TIMEOUT 0x7ff /* Host Timeout count */ /* Bit masks for CNT_CONFIG */ diff --git a/trunk/include/asm-blackfin/mach-bf527/dma.h b/trunk/include/asm-blackfin/mach-bf527/dma.h index 2dfee12864f6..a41627ae9134 100644 --- a/trunk/include/asm-blackfin/mach-bf527/dma.h +++ b/trunk/include/asm-blackfin/mach-bf527/dma.h @@ -35,6 +35,7 @@ #define MAX_BLACKFIN_DMA_CHANNEL 16 #define CH_PPI 0 /* PPI receive/transmit or NFC */ +#define CH_NFC 0 /* PPI receive/transmit or NFC */ #define CH_EMAC_RX 1 /* Ethernet MAC receive or HOSTDP */ #define CH_EMAC_HOSTDP 1 /* Ethernet MAC receive or HOSTDP */ #define CH_EMAC_TX 2 /* Ethernet MAC transmit or NFC */ @@ -53,12 +54,6 @@ #define CH_MEM_STREAM1_DEST 14 /* TX */ #define CH_MEM_STREAM1_SRC 15 /* RX */ -#if defined(CONFIG_BF527_NAND_D_PORTF) -#define CH_NFC CH_PPI /* PPI receive/transmit or NFC */ -#elif defined(CONFIG_BF527_NAND_D_PORTH) -#define CH_NFC CH_EMAC_TX /* PPI receive/transmit or NFC */ -#endif - extern int channel2irq(unsigned int channel); extern struct dma_register *base_addr[]; diff --git a/trunk/include/asm-blackfin/mach-bf548/defBF549.h b/trunk/include/asm-blackfin/mach-bf548/defBF549.h index fcb72b41e007..4e46d657e50e 100644 --- a/trunk/include/asm-blackfin/mach-bf548/defBF549.h +++ b/trunk/include/asm-blackfin/mach-bf548/defBF549.h @@ -1671,7 +1671,7 @@ /* Bit masks for MXVR_DMAx_CONFIG */ #define MDMAEN 0x1 /* DMA Channel Enable */ -#define DMADD 0x2 /* DMA Channel Direction */ +#define DD 0x2 /* DMA Channel Direction */ #define BY4SWAPEN 0x20 /* DMA Channel Four Byte Swap Enable */ #define LCHAN 0x3c0 /* DMA Channel Logical Channel */ #define BITSWAPEN 0x400 /* DMA Channel Bit Swap Enable */ diff --git a/trunk/include/asm-blackfin/mach-bf548/defBF54x_base.h b/trunk/include/asm-blackfin/mach-bf548/defBF54x_base.h index da979cb62f7d..1d365c844ffe 100644 --- a/trunk/include/asm-blackfin/mach-bf548/defBF54x_base.h +++ b/trunk/include/asm-blackfin/mach-bf548/defBF54x_base.h @@ -2252,13 +2252,6 @@ #define PLL_OFF 0x2 /* Disable PLL */ #define DF 0x1 /* Divide Frequency */ -/* SWRST Masks */ -#define SYSTEM_RESET 0x0007 /* Initiates A System Software Reset */ -#define DOUBLE_FAULT 0x0008 /* Core Double Fault Causes Reset */ -#define RESET_DOUBLE 0x2000 /* SW Reset Generated By Core Double-Fault */ -#define RESET_WDOG 0x4000 /* SW Reset Generated By Watchdog Timer */ -#define RESET_SOFTWARE 0x8000 /* SW Reset Occurred Since Last Read Of SWRST */ - /* Bit masks for PLL_STAT */ #define PLL_LOCKED 0x20 /* PLL Locked Status */ diff --git a/trunk/include/asm-blackfin/mach-bf548/portmux.h b/trunk/include/asm-blackfin/mach-bf548/portmux.h index 6b485120015f..b382deb501a7 100644 --- a/trunk/include/asm-blackfin/mach-bf548/portmux.h +++ b/trunk/include/asm-blackfin/mach-bf548/portmux.h @@ -267,18 +267,4 @@ #define P_AMC_BG (P_DEFINED | P_IDENT(GPIO_PJ12) | P_FUNCT(0)) #define P_AMC_BGH (P_DEFINED | P_IDENT(GPIO_PJ13) | P_FUNCT(0)) - -#define P_NAND_D0 (P_DONTCARE) -#define P_NAND_D1 (P_DONTCARE) -#define P_NAND_D2 (P_DONTCARE) -#define P_NAND_D3 (P_DONTCARE) -#define P_NAND_D4 (P_DONTCARE) -#define P_NAND_D5 (P_DONTCARE) -#define P_NAND_D6 (P_DONTCARE) -#define P_NAND_D7 (P_DONTCARE) -#define P_NAND_WE (P_DONTCARE) -#define P_NAND_RE (P_DONTCARE) -#define P_NAND_CLE (P_DONTCARE) -#define P_NAND_ALE (P_DONTCARE) - #endif /* _MACH_PORTMUX_H_ */ diff --git a/trunk/include/asm-blackfin/mach-bf561/defBF561.h b/trunk/include/asm-blackfin/mach-bf561/defBF561.h index 7945e8a3a841..bf7dc4e00065 100644 --- a/trunk/include/asm-blackfin/mach-bf561/defBF561.h +++ b/trunk/include/asm-blackfin/mach-bf561/defBF561.h @@ -55,9 +55,6 @@ /* For MMR's that are reserved on Core B, set up defines to better integrate with other ports */ #define SWRST SICA_SWRST #define SYSCR SICA_SYSCR -#define RESET_DOUBLE (SWRST_DBL_FAULT_B|SWRST_DBL_FAULT_A) -#define RESET_WDOG (SWRST_WDT_B|SWRST_WDT_A) -#define RESET_SOFTWARE (SWRST_OCCURRED) /* System Reset and Interrupt Controller registers for core A (0xFFC0 0100-0xFFC0 01FF) */ #define SICA_SWRST 0xFFC00100 /* Software Reset register */ diff --git a/trunk/include/asm-frv/scatterlist.h b/trunk/include/asm-frv/scatterlist.h index 2e7143b5a7ad..99ba76edc42a 100644 --- a/trunk/include/asm-frv/scatterlist.h +++ b/trunk/include/asm-frv/scatterlist.h @@ -16,7 +16,8 @@ * * can be rewritten as * - * sg_set_buf(sg, some_ptr, length); + * sg_set_page(virt_to_page(some_ptr)); + * sg->offset = (unsigned long) some_ptr & ~PAGE_MASK; * * and that's it. There's no excuse for not highmem enabling YOUR driver. /jens */ diff --git a/trunk/include/asm-ia64/percpu.h b/trunk/include/asm-ia64/percpu.h index c4f1e328a5ba..43a7aac414e0 100644 --- a/trunk/include/asm-ia64/percpu.h +++ b/trunk/include/asm-ia64/percpu.h @@ -46,7 +46,7 @@ #ifdef CONFIG_SMP extern unsigned long __per_cpu_offset[NR_CPUS]; -#define per_cpu_offset(x) (__per_cpu_offset[x]) +#define per_cpu_offset(x) (__per_cpu_offset(x)) /* Equal to __per_cpu_offset[smp_processor_id()], but faster to access: */ DECLARE_PER_CPU(unsigned long, local_per_cpu_offset); diff --git a/trunk/include/asm-ia64/smp.h b/trunk/include/asm-ia64/smp.h index 4fa733dd417a..471cc2ee9ac4 100644 --- a/trunk/include/asm-ia64/smp.h +++ b/trunk/include/asm-ia64/smp.h @@ -60,6 +60,7 @@ extern cpumask_t cpu_online_map; extern cpumask_t cpu_core_map[NR_CPUS]; DECLARE_PER_CPU(cpumask_t, cpu_sibling_map); extern int smp_num_siblings; +extern int smp_num_cpucores; extern void __iomem *ipi_base_addr; extern unsigned char smp_int_redirect; diff --git a/trunk/include/asm-m68knommu/dma.h b/trunk/include/asm-m68knommu/dma.h index 3f20419c633a..3338001abb40 100644 --- a/trunk/include/asm-m68knommu/dma.h +++ b/trunk/include/asm-m68knommu/dma.h @@ -39,8 +39,6 @@ #define MAX_M68K_DMA_CHANNELS 4 #elif defined(CONFIG_M5272) #define MAX_M68K_DMA_CHANNELS 1 -#elif defined(CONFIG_M532x) -#define MAX_M68K_DMA_CHANNELS 0 #else #define MAX_M68K_DMA_CHANNELS 2 #endif diff --git a/trunk/include/asm-m68knommu/machdep.h b/trunk/include/asm-m68knommu/machdep.h index 1cf26d240d83..708d7863ba68 100644 --- a/trunk/include/asm-m68knommu/machdep.h +++ b/trunk/include/asm-m68knommu/machdep.h @@ -3,13 +3,9 @@ #include -/* Hardware clock functions */ -extern void hw_timer_init(void); -extern unsigned long hw_timer_offset(void); - -extern irqreturn_t arch_timer_interrupt(int irq, void *dummy); - -/* Machine dependent time handling */ +extern void (*mach_sched_init) (irq_handler_t handler); +/* machine dependent timer functions */ +extern unsigned long (*mach_gettimeoffset)(void); extern void (*mach_gettod)(int *year, int *mon, int *day, int *hour, int *min, int *sec); extern int (*mach_set_clock_mmss)(unsigned long); @@ -20,5 +16,6 @@ extern void (*mach_halt)( void ); extern void (*mach_power_off)( void ); extern void config_BSP(char *command, int len); +extern void (*mach_tick)(void); #endif /* _M68KNOMMU_MACHDEP_H */ diff --git a/trunk/include/asm-m68knommu/mcfuart.h b/trunk/include/asm-m68knommu/mcfuart.h index 873d0805219c..dc0146c5258b 100644 --- a/trunk/include/asm-m68knommu/mcfuart.h +++ b/trunk/include/asm-m68knommu/mcfuart.h @@ -51,16 +51,6 @@ #endif -#include -#include - -struct mcf_platform_uart { - unsigned long mapbase; /* Physical address base */ - void __iomem *membase; /* Virtual address if mapped */ - unsigned int irq; /* Interrupt vector */ - unsigned int uartclk; /* UART clock rate */ -}; - /* * Define the ColdFire UART register set addresses. */ diff --git a/trunk/include/asm-mips/ip32/ip32_ints.h b/trunk/include/asm-mips/ip32/ip32_ints.h index ab5612f90f6f..042f821899a8 100644 --- a/trunk/include/asm-mips/ip32/ip32_ints.h +++ b/trunk/include/asm-mips/ip32/ip32_ints.h @@ -22,12 +22,10 @@ enum ip32_irq_no { * CPU interrupts are 0 ... 7 */ - CRIME_IRQ_BASE = MIPS_CPU_IRQ_BASE, - /* * MACE */ - MACE_VID_IN1_IRQ = CRIME_IRQ_BASE, + MACE_VID_IN1_IRQ = MIPS_CPU_IRQ_BASE + 8, MACE_VID_IN2_IRQ, MACE_VID_OUT_IRQ, MACE_ETHERNET_IRQ, diff --git a/trunk/include/asm-mips/jmr3927/jmr3927.h b/trunk/include/asm-mips/jmr3927/jmr3927.h index 81602c8047eb..b2dc35f56181 100644 --- a/trunk/include/asm-mips/jmr3927/jmr3927.h +++ b/trunk/include/asm-mips/jmr3927/jmr3927.h @@ -132,7 +132,9 @@ #define JMR3927_IRQ_IRC_DMA (JMR3927_IRQ_IRC + TX3927_IR_DMA) #define JMR3927_IRQ_IRC_PIO (JMR3927_IRQ_IRC + TX3927_IR_PIO) #define JMR3927_IRQ_IRC_PCI (JMR3927_IRQ_IRC + TX3927_IR_PCI) -#define JMR3927_IRQ_IRC_TMR(ch) (JMR3927_IRQ_IRC + TX3927_IR_TMR(ch)) +#define JMR3927_IRQ_IRC_TMR0 (JMR3927_IRQ_IRC + TX3927_IR_TMR0) +#define JMR3927_IRQ_IRC_TMR1 (JMR3927_IRQ_IRC + TX3927_IR_TMR1) +#define JMR3927_IRQ_IRC_TMR2 (JMR3927_IRQ_IRC + TX3927_IR_TMR2) #define JMR3927_IRQ_IOC_PCIA (JMR3927_IRQ_IOC + JMR3927_IOC_INTB_PCIA) #define JMR3927_IRQ_IOC_PCIB (JMR3927_IRQ_IOC + JMR3927_IOC_INTB_PCIB) #define JMR3927_IRQ_IOC_PCIC (JMR3927_IRQ_IOC + JMR3927_IOC_INTB_PCIC) @@ -146,12 +148,17 @@ #define JMR3927_IRQ_IOCINT JMR3927_IRQ_IRC_INT1 /* TC35815 100M Ether (JMR-TX3912:JPW4:2-3 Short) */ #define JMR3927_IRQ_ETHER0 JMR3927_IRQ_IRC_INT3 +/* Clock Tick (10ms) */ +#define JMR3927_IRQ_TICK JMR3927_IRQ_IRC_TMR0 /* Clocks */ #define JMR3927_CORECLK 132710400 /* 132.7MHz */ #define JMR3927_GBUSCLK (JMR3927_CORECLK / 2) /* 66.35MHz */ #define JMR3927_IMCLK (JMR3927_CORECLK / 4) /* 33.17MHz */ +#define jmr3927_tmrptr tx3927_tmrptr(0) /* TMR0 */ + + /* * TX3927 Pin Configuration: * diff --git a/trunk/include/asm-mips/jmr3927/tx3927.h b/trunk/include/asm-mips/jmr3927/tx3927.h index 338f99882a39..211bcf47fffb 100644 --- a/trunk/include/asm-mips/jmr3927/tx3927.h +++ b/trunk/include/asm-mips/jmr3927/tx3927.h @@ -222,7 +222,9 @@ struct tx3927_ccfg_reg { #define TX3927_IR_DMA 8 #define TX3927_IR_PIO 9 #define TX3927_IR_PCI 10 -#define TX3927_IR_TMR(ch) (13 + (ch)) +#define TX3927_IR_TMR0 13 +#define TX3927_IR_TMR1 14 +#define TX3927_IR_TMR2 15 #define TX3927_NUM_IR 16 /* diff --git a/trunk/include/asm-mips/jmr3927/txx927.h b/trunk/include/asm-mips/jmr3927/txx927.h index 0474fe8dac3f..58a8ff6be815 100644 --- a/trunk/include/asm-mips/jmr3927/txx927.h +++ b/trunk/include/asm-mips/jmr3927/txx927.h @@ -10,6 +10,22 @@ #ifndef __ASM_TXX927_H #define __ASM_TXX927_H +struct txx927_tmr_reg { + volatile unsigned long tcr; + volatile unsigned long tisr; + volatile unsigned long cpra; + volatile unsigned long cprb; + volatile unsigned long itmr; + volatile unsigned long unused0[3]; + volatile unsigned long ccdr; + volatile unsigned long unused1[3]; + volatile unsigned long pgmr; + volatile unsigned long unused2[3]; + volatile unsigned long wtmr; + volatile unsigned long unused3[43]; + volatile unsigned long trr; +}; + struct txx927_sio_reg { volatile unsigned long lcr; volatile unsigned long dicr; @@ -34,6 +50,27 @@ struct txx927_pio_reg { volatile unsigned long maskext; }; +/* + * TMR + */ +/* TMTCR : Timer Control */ +#define TXx927_TMTCR_TCE 0x00000080 +#define TXx927_TMTCR_CCDE 0x00000040 +#define TXx927_TMTCR_CRE 0x00000020 +#define TXx927_TMTCR_ECES 0x00000008 +#define TXx927_TMTCR_CCS 0x00000004 +#define TXx927_TMTCR_TMODE_MASK 0x00000003 +#define TXx927_TMTCR_TMODE_ITVL 0x00000000 + +/* TMTISR : Timer Int. Status */ +#define TXx927_TMTISR_TPIBS 0x00000004 +#define TXx927_TMTISR_TPIAS 0x00000002 +#define TXx927_TMTISR_TIIS 0x00000001 + +/* TMTITMR : Interval Timer Mode */ +#define TXx927_TMTITMR_TIIE 0x00008000 +#define TXx927_TMTITMR_TZCE 0x00000001 + /* * SIO */ diff --git a/trunk/include/asm-mips/time.h b/trunk/include/asm-mips/time.h index 0a6bc7dc158e..bc47af313bcd 100644 --- a/trunk/include/asm-mips/time.h +++ b/trunk/include/asm-mips/time.h @@ -58,6 +58,7 @@ extern void local_timer_interrupt(int irq, void *dev_id); */ struct irqaction; extern void plat_time_init(void); +extern void plat_timer_setup(struct irqaction *irq); /* * mips_hpt_frequency - must be set if you intend to use an R4k-compatible @@ -77,7 +78,6 @@ extern int (*perf_irq)(void); */ #ifdef CONFIG_CEVT_R4K extern void mips_clockevent_init(void); -extern unsigned int __weak get_c0_compare_int(void); #else static inline void mips_clockevent_init(void) { diff --git a/trunk/include/asm-mips/tx4927/tx4927_pci.h b/trunk/include/asm-mips/tx4927/tx4927_pci.h index 3f1e470192e3..f98b2bb719d5 100644 --- a/trunk/include/asm-mips/tx4927/tx4927_pci.h +++ b/trunk/include/asm-mips/tx4927/tx4927_pci.h @@ -9,7 +9,6 @@ #define __ASM_TX4927_TX4927_PCI_H #define TX4927_CCFG_TOE 0x00004000 -#define TX4927_CCFG_TINTDIS 0x01000000 #define TX4927_PCIMEM 0x08000000 #define TX4927_PCIMEM_SIZE 0x08000000 @@ -21,8 +20,6 @@ #define TX4927_PCIC_REG 0xff1fd000 #define TX4927_CCFG_REG 0xff1fe000 #define TX4927_IRC_REG 0xff1ff600 -#define TX4927_NR_TMR 3 -#define TX4927_TMR_REG(ch) (0xff1ff000 + (ch) * 0x100) #define TX4927_CE3 0x17f00000 /* 1M */ #define TX4927_PCIRESET_ADDR 0xbc00f006 #define TX4927_PCI_CLK_ADDR (KSEG1 + TX4927_CE3 + 0x00040020) diff --git a/trunk/include/asm-mips/tx4938/tx4938.h b/trunk/include/asm-mips/tx4938/tx4938.h index f7c448b90578..650b010761f9 100644 --- a/trunk/include/asm-mips/tx4938/tx4938.h +++ b/trunk/include/asm-mips/tx4938/tx4938.h @@ -641,6 +641,7 @@ struct tx4938_ccfg_reg { #define tx4938_pcicptr ((struct tx4938_pcic_reg *)TX4938_PCIC_REG) #define tx4938_pcic1ptr ((struct tx4938_pcic_reg *)TX4938_PCIC1_REG) #define tx4938_ccfgptr ((struct tx4938_ccfg_reg *)TX4938_CCFG_REG) +#define tx4938_tmrptr(ch) ((struct tx4938_tmr_reg *)TX4938_TMR_REG(ch)) #define tx4938_sioptr(ch) ((struct tx4938_sio_reg *)TX4938_SIO_REG(ch)) #define tx4938_pioptr ((struct tx4938_pio_reg *)TX4938_PIO_REG) #define tx4938_aclcptr ((struct tx4938_aclc_reg *)TX4938_ACLC_REG) diff --git a/trunk/include/asm-mips/txx9tmr.h b/trunk/include/asm-mips/txx9tmr.h deleted file mode 100644 index 67f70a8f09bd..000000000000 --- a/trunk/include/asm-mips/txx9tmr.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * include/asm-mips/txx9tmr.h - * TX39/TX49 timer controller definitions. - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file "COPYING" in the main directory of this archive - * for more details. - */ -#ifndef __ASM_TXX9TMR_H -#define __ASM_TXX9TMR_H - -#include - -struct txx9_tmr_reg { - u32 tcr; - u32 tisr; - u32 cpra; - u32 cprb; - u32 itmr; - u32 unused0[3]; - u32 ccdr; - u32 unused1[3]; - u32 pgmr; - u32 unused2[3]; - u32 wtmr; - u32 unused3[43]; - u32 trr; -}; - -/* TMTCR : Timer Control */ -#define TXx9_TMTCR_TCE 0x00000080 -#define TXx9_TMTCR_CCDE 0x00000040 -#define TXx9_TMTCR_CRE 0x00000020 -#define TXx9_TMTCR_ECES 0x00000008 -#define TXx9_TMTCR_CCS 0x00000004 -#define TXx9_TMTCR_TMODE_MASK 0x00000003 -#define TXx9_TMTCR_TMODE_ITVL 0x00000000 -#define TXx9_TMTCR_TMODE_PGEN 0x00000001 -#define TXx9_TMTCR_TMODE_WDOG 0x00000002 - -/* TMTISR : Timer Int. Status */ -#define TXx9_TMTISR_TPIBS 0x00000004 -#define TXx9_TMTISR_TPIAS 0x00000002 -#define TXx9_TMTISR_TIIS 0x00000001 - -/* TMITMR : Interval Timer Mode */ -#define TXx9_TMITMR_TIIE 0x00008000 -#define TXx9_TMITMR_TZCE 0x00000001 - -/* TMWTMR : Watchdog Timer Mode */ -#define TXx9_TMWTMR_TWIE 0x00008000 -#define TXx9_TMWTMR_WDIS 0x00000080 -#define TXx9_TMWTMR_TWC 0x00000001 - -void txx9_clocksource_init(unsigned long baseaddr, - unsigned int imbusclk); -void txx9_clockevent_init(unsigned long baseaddr, int irq, - unsigned int imbusclk); -void txx9_tmr_init(unsigned long baseaddr); - -#ifdef CONFIG_CPU_TX39XX -#define TXX9_TIMER_BITS 24 -#else -#define TXX9_TIMER_BITS 32 -#endif - -#endif /* __ASM_TXX9TMR_H */ diff --git a/trunk/include/asm-sparc/atomic.h b/trunk/include/asm-sparc/atomic.h index 3328950dbfe6..bdca5416d8b0 100644 --- a/trunk/include/asm-sparc/atomic.h +++ b/trunk/include/asm-sparc/atomic.h @@ -1,6 +1,6 @@ /* atomic.h: These still suck, but the I-cache hit rate is higher. * - * Copyright (C) 1996 David S. Miller (davem@davemloft.net) + * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) * Copyright (C) 2000 Anton Blanchard (anton@linuxcare.com.au) * Copyright (C) 2007 Kyle McMartin (kyle@parisc-linux.org) * @@ -33,7 +33,7 @@ extern void __cmpxchg_called_with_bad_pointer(void); extern unsigned long __cmpxchg_u32(volatile u32 *m, u32 old, u32 new_); /* don't worry...optimizer will get rid of most of this */ -static inline unsigned long +static __inline__ unsigned long __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size) { switch(size) { diff --git a/trunk/include/asm-sparc/dma.h b/trunk/include/asm-sparc/dma.h index 959d6c8a71ae..407b3614468a 100644 --- a/trunk/include/asm-sparc/dma.h +++ b/trunk/include/asm-sparc/dma.h @@ -1,6 +1,7 @@ -/* include/asm-sparc/dma.h +/* $Id: dma.h,v 1.35 1999/12/27 06:37:09 anton Exp $ + * include/asm-sparc/dma.h * - * Copyright 1995 (C) David S. Miller (davem@davemloft.net) + * Copyright 1995 (C) David S. Miller (davem@caip.rutgers.edu) */ #ifndef _ASM_SPARC_DMA_H @@ -20,14 +21,14 @@ struct page; extern spinlock_t dma_spin_lock; -static inline unsigned long claim_dma_lock(void) +static __inline__ unsigned long claim_dma_lock(void) { unsigned long flags; spin_lock_irqsave(&dma_spin_lock, flags); return flags; } -static inline void release_dma_lock(unsigned long flags) +static __inline__ void release_dma_lock(unsigned long flags) { spin_unlock_irqrestore(&dma_spin_lock, flags); } diff --git a/trunk/include/asm-sparc/floppy.h b/trunk/include/asm-sparc/floppy.h index dbe7a586be5b..5da1eef0f706 100644 --- a/trunk/include/asm-sparc/floppy.h +++ b/trunk/include/asm-sparc/floppy.h @@ -1,6 +1,6 @@ /* asm-sparc/floppy.h: Sparc specific parts of the Floppy driver. * - * Copyright (C) 1995 David S. Miller (davem@davemloft.net) + * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) */ #ifndef __ASM_SPARC_FLOPPY_H @@ -232,12 +232,12 @@ extern char *pdma_base; extern unsigned long pdma_areasize; /* Common routines to all controller types on the Sparc. */ -static inline void virtual_dma_init(void) +static __inline__ void virtual_dma_init(void) { /* nothing... */ } -static inline void sun_fd_disable_dma(void) +static __inline__ void sun_fd_disable_dma(void) { doing_pdma = 0; if (pdma_base) { @@ -246,7 +246,7 @@ static inline void sun_fd_disable_dma(void) } } -static inline void sun_fd_set_dma_mode(int mode) +static __inline__ void sun_fd_set_dma_mode(int mode) { switch(mode) { case DMA_MODE_READ: @@ -261,17 +261,17 @@ static inline void sun_fd_set_dma_mode(int mode) } } -static inline void sun_fd_set_dma_addr(char *buffer) +static __inline__ void sun_fd_set_dma_addr(char *buffer) { pdma_vaddr = buffer; } -static inline void sun_fd_set_dma_count(int length) +static __inline__ void sun_fd_set_dma_count(int length) { pdma_size = length; } -static inline void sun_fd_enable_dma(void) +static __inline__ void sun_fd_enable_dma(void) { pdma_vaddr = mmu_lockarea(pdma_vaddr, pdma_size); pdma_base = pdma_vaddr; diff --git a/trunk/include/asm-sparc/ide.h b/trunk/include/asm-sparc/ide.h index 4076cb5d1581..404022765fc7 100644 --- a/trunk/include/asm-sparc/ide.h +++ b/trunk/include/asm-sparc/ide.h @@ -1,6 +1,7 @@ -/* ide.h: SPARC PCI specific IDE glue. +/* $Id: ide.h,v 1.7 2002/01/16 20:58:40 davem Exp $ + * ide.h: SPARC PCI specific IDE glue. * - * Copyright (C) 1997 David S. Miller (davem@davemloft.net) + * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu) * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be) * Adaptation from sparc64 version to sparc by Pete Zaitcev. */ @@ -30,7 +31,7 @@ #define __ide_mm_outsw __ide_outsw #define __ide_mm_outsl __ide_outsl -static inline void __ide_insw(unsigned long port, +static __inline__ void __ide_insw(unsigned long port, void *dst, unsigned long count) { @@ -61,7 +62,7 @@ static inline void __ide_insw(unsigned long port, /* __flush_dcache_range((unsigned long)dst, end); */ /* P3 see hme */ } -static inline void __ide_outsw(unsigned long port, +static __inline__ void __ide_outsw(unsigned long port, const void *src, unsigned long count) { diff --git a/trunk/include/asm-sparc/posix_types.h b/trunk/include/asm-sparc/posix_types.h index 62c8fa7b36d4..9ef1b3db4cbf 100644 --- a/trunk/include/asm-sparc/posix_types.h +++ b/trunk/include/asm-sparc/posix_types.h @@ -49,7 +49,7 @@ typedef struct { #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) #undef __FD_SET -static inline void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp) +static __inline__ void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp) { unsigned long _tmp = fd / __NFDBITS; unsigned long _rem = fd % __NFDBITS; @@ -57,7 +57,7 @@ static inline void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp) } #undef __FD_CLR -static inline void __FD_CLR(unsigned long fd, __kernel_fd_set *fdsetp) +static __inline__ void __FD_CLR(unsigned long fd, __kernel_fd_set *fdsetp) { unsigned long _tmp = fd / __NFDBITS; unsigned long _rem = fd % __NFDBITS; @@ -65,7 +65,7 @@ static inline void __FD_CLR(unsigned long fd, __kernel_fd_set *fdsetp) } #undef __FD_ISSET -static inline int __FD_ISSET(unsigned long fd, __const__ __kernel_fd_set *p) +static __inline__ int __FD_ISSET(unsigned long fd, __const__ __kernel_fd_set *p) { unsigned long _tmp = fd / __NFDBITS; unsigned long _rem = fd % __NFDBITS; @@ -77,7 +77,7 @@ static inline int __FD_ISSET(unsigned long fd, __const__ __kernel_fd_set *p) * for 256 and 1024-bit fd_sets respectively) */ #undef __FD_ZERO -static inline void __FD_ZERO(__kernel_fd_set *p) +static __inline__ void __FD_ZERO(__kernel_fd_set *p) { unsigned long *tmp = p->fds_bits; int i; diff --git a/trunk/include/asm-sparc/system.h b/trunk/include/asm-sparc/system.h index 2655d142b22d..8c259de02614 100644 --- a/trunk/include/asm-sparc/system.h +++ b/trunk/include/asm-sparc/system.h @@ -1,3 +1,5 @@ +/* $Id: system.h,v 1.86 2001/10/30 04:57:10 davem Exp $ */ + #ifndef __SPARC_SYSTEM_H #define __SPARC_SYSTEM_H @@ -54,7 +56,7 @@ extern void sun_do_break(void); extern int serial_console; extern int stop_a_enabled; -static inline int con_is_present(void) +static __inline__ int con_is_present(void) { return serial_console ? 0 : 1; } @@ -215,7 +217,7 @@ static inline unsigned long xchg_u32(__volatile__ unsigned long *m, unsigned lon extern void __xchg_called_with_bad_pointer(void); -static inline unsigned long __xchg(unsigned long x, __volatile__ void * ptr, int size) +static __inline__ unsigned long __xchg(unsigned long x, __volatile__ void * ptr, int size) { switch (size) { case 4: diff --git a/trunk/include/asm-sparc64/atomic.h b/trunk/include/asm-sparc64/atomic.h index 2c71ec4a3b18..3fb4e1f7f186 100644 --- a/trunk/include/asm-sparc64/atomic.h +++ b/trunk/include/asm-sparc64/atomic.h @@ -1,4 +1,5 @@ -/* atomic.h: Thankfully the V9 is at least reasonable for this +/* $Id: atomic.h,v 1.22 2001/07/11 23:56:07 davem Exp $ + * atomic.h: Thankfully the V9 is at least reasonable for this * stuff. * * Copyright (C) 1996, 1997, 2000 David S. Miller (davem@redhat.com) @@ -73,7 +74,7 @@ extern int atomic64_sub_ret(int, atomic64_t *); #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n))) #define atomic_xchg(v, new) (xchg(&((v)->counter), new)) -static inline int atomic_add_unless(atomic_t *v, int a, int u) +static __inline__ int atomic_add_unless(atomic_t *v, int a, int u) { int c, old; c = atomic_read(v); @@ -94,7 +95,7 @@ static inline int atomic_add_unless(atomic_t *v, int a, int u) ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n))) #define atomic64_xchg(v, new) (xchg(&((v)->counter), new)) -static inline int atomic64_add_unless(atomic64_t *v, long a, long u) +static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u) { long c, old; c = atomic64_read(v); diff --git a/trunk/include/asm-sparc64/backoff.h b/trunk/include/asm-sparc64/backoff.h index dadd6c385c6c..0e32f8b62fd2 100644 --- a/trunk/include/asm-sparc64/backoff.h +++ b/trunk/include/asm-sparc64/backoff.h @@ -21,9 +21,7 @@ #else #define BACKOFF_SETUP(reg) -#define BACKOFF_SPIN(reg, tmp, label) \ - ba,pt %xcc, label; \ - nop; +#define BACKOFF_SPIN(reg, tmp, label) #endif diff --git a/trunk/include/asm-sparc64/byteorder.h b/trunk/include/asm-sparc64/byteorder.h index 3943022906fd..c69b08af5fe0 100644 --- a/trunk/include/asm-sparc64/byteorder.h +++ b/trunk/include/asm-sparc64/byteorder.h @@ -1,3 +1,4 @@ +/* $Id: byteorder.h,v 1.8 1997/12/18 02:44:14 ecd Exp $ */ #ifndef _SPARC64_BYTEORDER_H #define _SPARC64_BYTEORDER_H @@ -6,7 +7,7 @@ #ifdef __GNUC__ -static inline __u16 ___arch__swab16p(const __u16 *addr) +static __inline__ __u16 ___arch__swab16p(const __u16 *addr) { __u16 ret; @@ -16,7 +17,7 @@ static inline __u16 ___arch__swab16p(const __u16 *addr) return ret; } -static inline __u32 ___arch__swab32p(const __u32 *addr) +static __inline__ __u32 ___arch__swab32p(const __u32 *addr) { __u32 ret; @@ -26,7 +27,7 @@ static inline __u32 ___arch__swab32p(const __u32 *addr) return ret; } -static inline __u64 ___arch__swab64p(const __u64 *addr) +static __inline__ __u64 ___arch__swab64p(const __u64 *addr) { __u64 ret; diff --git a/trunk/include/asm-sparc64/fpumacro.h b/trunk/include/asm-sparc64/fpumacro.h index cc463fec806f..d583e5efd75d 100644 --- a/trunk/include/asm-sparc64/fpumacro.h +++ b/trunk/include/asm-sparc64/fpumacro.h @@ -16,7 +16,7 @@ struct fpustate { #define FPUSTATE (struct fpustate *)(current_thread_info()->fpregs) -static inline unsigned long fprs_read(void) +static __inline__ unsigned long fprs_read(void) { unsigned long retval; @@ -25,7 +25,7 @@ static inline unsigned long fprs_read(void) return retval; } -static inline void fprs_write(unsigned long val) +static __inline__ void fprs_write(unsigned long val) { __asm__ __volatile__("wr %0, 0x0, %%fprs" : : "r" (val)); } diff --git a/trunk/include/asm-sparc64/io.h b/trunk/include/asm-sparc64/io.h index c299b853b5ba..cd7ef3097ac2 100644 --- a/trunk/include/asm-sparc64/io.h +++ b/trunk/include/asm-sparc64/io.h @@ -1,3 +1,4 @@ +/* $Id: io.h,v 1.47 2001/12/13 10:36:02 davem Exp $ */ #ifndef __SPARC64_IO_H #define __SPARC64_IO_H @@ -18,7 +19,7 @@ extern unsigned long kern_base, kern_size; #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) #define BIO_VMERGE_BOUNDARY 8192 -static inline u8 _inb(unsigned long addr) +static __inline__ u8 _inb(unsigned long addr) { u8 ret; @@ -29,7 +30,7 @@ static inline u8 _inb(unsigned long addr) return ret; } -static inline u16 _inw(unsigned long addr) +static __inline__ u16 _inw(unsigned long addr) { u16 ret; @@ -40,7 +41,7 @@ static inline u16 _inw(unsigned long addr) return ret; } -static inline u32 _inl(unsigned long addr) +static __inline__ u32 _inl(unsigned long addr) { u32 ret; @@ -51,21 +52,21 @@ static inline u32 _inl(unsigned long addr) return ret; } -static inline void _outb(u8 b, unsigned long addr) +static __inline__ void _outb(u8 b, unsigned long addr) { __asm__ __volatile__("stba\t%r0, [%1] %2\t/* pci_outb */" : /* no outputs */ : "Jr" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)); } -static inline void _outw(u16 w, unsigned long addr) +static __inline__ void _outw(u16 w, unsigned long addr) { __asm__ __volatile__("stha\t%r0, [%1] %2\t/* pci_outw */" : /* no outputs */ : "Jr" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)); } -static inline void _outl(u32 l, unsigned long addr) +static __inline__ void _outl(u32 l, unsigned long addr) { __asm__ __volatile__("stwa\t%r0, [%1] %2\t/* pci_outl */" : /* no outputs */ @@ -204,7 +205,7 @@ static inline void _writeq(u64 q, volatile void __iomem *addr) #define writeq(__q, __addr) _writeq(__q, __addr) /* Now versions without byte-swapping. */ -static inline u8 _raw_readb(unsigned long addr) +static __inline__ u8 _raw_readb(unsigned long addr) { u8 ret; @@ -215,7 +216,7 @@ static inline u8 _raw_readb(unsigned long addr) return ret; } -static inline u16 _raw_readw(unsigned long addr) +static __inline__ u16 _raw_readw(unsigned long addr) { u16 ret; @@ -226,7 +227,7 @@ static inline u16 _raw_readw(unsigned long addr) return ret; } -static inline u32 _raw_readl(unsigned long addr) +static __inline__ u32 _raw_readl(unsigned long addr) { u32 ret; @@ -237,7 +238,7 @@ static inline u32 _raw_readl(unsigned long addr) return ret; } -static inline u64 _raw_readq(unsigned long addr) +static __inline__ u64 _raw_readq(unsigned long addr) { u64 ret; @@ -248,28 +249,28 @@ static inline u64 _raw_readq(unsigned long addr) return ret; } -static inline void _raw_writeb(u8 b, unsigned long addr) +static __inline__ void _raw_writeb(u8 b, unsigned long addr) { __asm__ __volatile__("stba\t%r0, [%1] %2\t/* pci_raw_writeb */" : /* no outputs */ : "Jr" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); } -static inline void _raw_writew(u16 w, unsigned long addr) +static __inline__ void _raw_writew(u16 w, unsigned long addr) { __asm__ __volatile__("stha\t%r0, [%1] %2\t/* pci_raw_writew */" : /* no outputs */ : "Jr" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); } -static inline void _raw_writel(u32 l, unsigned long addr) +static __inline__ void _raw_writel(u32 l, unsigned long addr) { __asm__ __volatile__("stwa\t%r0, [%1] %2\t/* pci_raw_writel */" : /* no outputs */ : "Jr" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); } -static inline void _raw_writeq(u64 q, unsigned long addr) +static __inline__ void _raw_writeq(u64 q, unsigned long addr) { __asm__ __volatile__("stxa\t%r0, [%1] %2\t/* pci_raw_writeq */" : /* no outputs */ diff --git a/trunk/include/asm-sparc64/irq.h b/trunk/include/asm-sparc64/irq.h index 30cb76b47be1..182dba05c702 100644 --- a/trunk/include/asm-sparc64/irq.h +++ b/trunk/include/asm-sparc64/irq.h @@ -1,6 +1,7 @@ -/* irq.h: IRQ registers on the 64-bit Sparc. +/* $Id: irq.h,v 1.21 2002/01/23 11:27:36 davem Exp $ + * irq.h: IRQ registers on the 64-bit Sparc. * - * Copyright (C) 1996 David S. Miller (davem@davemloft.net) + * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) * Copyright (C) 1998 Jakub Jelinek (jj@ultra.linux.cz) */ @@ -66,21 +67,21 @@ extern void virt_irq_free(unsigned int virt_irq); extern void fixup_irqs(void); -static inline void set_softint(unsigned long bits) +static __inline__ void set_softint(unsigned long bits) { __asm__ __volatile__("wr %0, 0x0, %%set_softint" : /* No outputs */ : "r" (bits)); } -static inline void clear_softint(unsigned long bits) +static __inline__ void clear_softint(unsigned long bits) { __asm__ __volatile__("wr %0, 0x0, %%clear_softint" : /* No outputs */ : "r" (bits)); } -static inline unsigned long get_softint(void) +static __inline__ unsigned long get_softint(void) { unsigned long retval; diff --git a/trunk/include/asm-sparc64/mostek.h b/trunk/include/asm-sparc64/mostek.h index c5652de2ace2..d14dd8988161 100644 --- a/trunk/include/asm-sparc64/mostek.h +++ b/trunk/include/asm-sparc64/mostek.h @@ -1,6 +1,7 @@ -/* mostek.h: Describes the various Mostek time of day clock registers. +/* $Id: mostek.h,v 1.4 2001/01/11 15:07:09 davem Exp $ + * mostek.h: Describes the various Mostek time of day clock registers. * - * Copyright (C) 1995 David S. Miller (davem@davemloft.net) + * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) * Copyright (C) 1996 Thomas K. Dyas (tdyas@eden.rutgers.edu) */ @@ -37,7 +38,7 @@ * * We now deal with physical addresses for I/O to the chip. -DaveM */ -static inline u8 mostek_read(void __iomem *addr) +static __inline__ u8 mostek_read(void __iomem *addr) { u8 ret; @@ -47,7 +48,7 @@ static inline u8 mostek_read(void __iomem *addr) return ret; } -static inline void mostek_write(void __iomem *addr, u8 val) +static __inline__ void mostek_write(void __iomem *addr, u8 val) { __asm__ __volatile__("stba %0, [%1] %2" : /* no outputs */ diff --git a/trunk/include/asm-sparc64/ns87303.h b/trunk/include/asm-sparc64/ns87303.h index 686defe6aaa0..6d58fdf349b5 100644 --- a/trunk/include/asm-sparc64/ns87303.h +++ b/trunk/include/asm-sparc64/ns87303.h @@ -1,4 +1,5 @@ -/* ns87303.h: Configuration Register Description for the +/* $Id: ns87303.h,v 1.3 2000/01/09 15:16:34 ecd Exp $ + * ns87303.h: Configuration Register Description for the * National Semiconductor PC87303 (SuperIO). * * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be) @@ -84,7 +85,7 @@ extern spinlock_t ns87303_lock; -static inline int ns87303_modify(unsigned long port, unsigned int index, +static __inline__ int ns87303_modify(unsigned long port, unsigned int index, unsigned char clr, unsigned char set) { static unsigned char reserved[] = { diff --git a/trunk/include/asm-sparc64/parport.h b/trunk/include/asm-sparc64/parport.h index e9555b246c8d..8116e8f6062c 100644 --- a/trunk/include/asm-sparc64/parport.h +++ b/trunk/include/asm-sparc64/parport.h @@ -1,4 +1,5 @@ -/* parport.h: sparc64 specific parport initialization and dma. +/* $Id: parport.h,v 1.11 2001/05/11 07:54:24 davem Exp $ + * parport.h: sparc64 specific parport initialization and dma. * * Copyright (C) 1999 Eddie C. Dost (ecd@skynet.be) */ @@ -41,7 +42,7 @@ static struct sparc_ebus_info { static DECLARE_BITMAP(dma_slot_map, PARPORT_PC_MAX_PORTS); -static inline int request_dma(unsigned int dmanr, const char *device_id) +static __inline__ int request_dma(unsigned int dmanr, const char *device_id) { if (dmanr >= PARPORT_PC_MAX_PORTS) return -EINVAL; @@ -50,7 +51,7 @@ static inline int request_dma(unsigned int dmanr, const char *device_id) return 0; } -static inline void free_dma(unsigned int dmanr) +static __inline__ void free_dma(unsigned int dmanr) { if (dmanr >= PARPORT_PC_MAX_PORTS) { printk(KERN_WARNING "Trying to free DMA%d\n", dmanr); @@ -62,7 +63,7 @@ static inline void free_dma(unsigned int dmanr) } } -static inline void enable_dma(unsigned int dmanr) +static __inline__ void enable_dma(unsigned int dmanr) { ebus_dma_enable(&sparc_ebus_dmas[dmanr].info, 1); @@ -72,32 +73,32 @@ static inline void enable_dma(unsigned int dmanr) BUG(); } -static inline void disable_dma(unsigned int dmanr) +static __inline__ void disable_dma(unsigned int dmanr) { ebus_dma_enable(&sparc_ebus_dmas[dmanr].info, 0); } -static inline void clear_dma_ff(unsigned int dmanr) +static __inline__ void clear_dma_ff(unsigned int dmanr) { /* nothing */ } -static inline void set_dma_mode(unsigned int dmanr, char mode) +static __inline__ void set_dma_mode(unsigned int dmanr, char mode) { ebus_dma_prepare(&sparc_ebus_dmas[dmanr].info, (mode != DMA_MODE_WRITE)); } -static inline void set_dma_addr(unsigned int dmanr, unsigned int addr) +static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int addr) { sparc_ebus_dmas[dmanr].addr = addr; } -static inline void set_dma_count(unsigned int dmanr, unsigned int count) +static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count) { sparc_ebus_dmas[dmanr].count = count; } -static inline unsigned int get_dma_residue(unsigned int dmanr) +static __inline__ unsigned int get_dma_residue(unsigned int dmanr) { return ebus_dma_residue(&sparc_ebus_dmas[dmanr].info); } diff --git a/trunk/include/asm-sparc64/posix_types.h b/trunk/include/asm-sparc64/posix_types.h index 3426a65ecd35..c86b9452c683 100644 --- a/trunk/include/asm-sparc64/posix_types.h +++ b/trunk/include/asm-sparc64/posix_types.h @@ -53,7 +53,7 @@ typedef struct { #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) #undef __FD_SET -static inline void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp) +static __inline__ void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp) { unsigned long _tmp = fd / __NFDBITS; unsigned long _rem = fd % __NFDBITS; @@ -61,7 +61,7 @@ static inline void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp) } #undef __FD_CLR -static inline void __FD_CLR(unsigned long fd, __kernel_fd_set *fdsetp) +static __inline__ void __FD_CLR(unsigned long fd, __kernel_fd_set *fdsetp) { unsigned long _tmp = fd / __NFDBITS; unsigned long _rem = fd % __NFDBITS; @@ -69,7 +69,7 @@ static inline void __FD_CLR(unsigned long fd, __kernel_fd_set *fdsetp) } #undef __FD_ISSET -static inline int __FD_ISSET(unsigned long fd, __const__ __kernel_fd_set *p) +static __inline__ int __FD_ISSET(unsigned long fd, __const__ __kernel_fd_set *p) { unsigned long _tmp = fd / __NFDBITS; unsigned long _rem = fd % __NFDBITS; @@ -81,7 +81,7 @@ static inline int __FD_ISSET(unsigned long fd, __const__ __kernel_fd_set *p) * for 256 and 1024-bit fd_sets respectively) */ #undef __FD_ZERO -static inline void __FD_ZERO(__kernel_fd_set *p) +static __inline__ void __FD_ZERO(__kernel_fd_set *p) { unsigned long *tmp = p->fds_bits; int i; diff --git a/trunk/include/asm-sparc64/sbus.h b/trunk/include/asm-sparc64/sbus.h index 24a04a55cf85..0151cad486f3 100644 --- a/trunk/include/asm-sparc64/sbus.h +++ b/trunk/include/asm-sparc64/sbus.h @@ -29,12 +29,12 @@ * numbers + offsets, and vice versa. */ -static inline unsigned long sbus_devaddr(int slotnum, unsigned long offset) +static __inline__ unsigned long sbus_devaddr(int slotnum, unsigned long offset) { return (unsigned long) (SUN_SBUS_BVADDR+((slotnum)<<28)+(offset)); } -static inline int sbus_dev_slot(unsigned long dev_addr) +static __inline__ int sbus_dev_slot(unsigned long dev_addr) { return (int) (((dev_addr)-SUN_SBUS_BVADDR)>>28); } diff --git a/trunk/include/asm-sparc64/spitfire.h b/trunk/include/asm-sparc64/spitfire.h index 63b7040e8134..cf7807813e85 100644 --- a/trunk/include/asm-sparc64/spitfire.h +++ b/trunk/include/asm-sparc64/spitfire.h @@ -1,6 +1,7 @@ -/* spitfire.h: SpitFire/BlackBird/Cheetah inline MMU operations. +/* $Id: spitfire.h,v 1.18 2001/11/29 16:42:10 kanoj Exp $ + * spitfire.h: SpitFire/BlackBird/Cheetah inline MMU operations. * - * Copyright (C) 1996 David S. Miller (davem@davemloft.net) + * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) */ #ifndef _SPARC64_SPITFIRE_H @@ -66,7 +67,7 @@ extern void cheetah_enable_pcache(void); /* The data cache is write through, so this just invalidates the * specified line. */ -static inline void spitfire_put_dcache_tag(unsigned long addr, unsigned long tag) +static __inline__ void spitfire_put_dcache_tag(unsigned long addr, unsigned long tag) { __asm__ __volatile__("stxa %0, [%1] %2\n\t" "membar #Sync" @@ -80,7 +81,7 @@ static inline void spitfire_put_dcache_tag(unsigned long addr, unsigned long tag * a flush instruction (to any address) is sufficient to handle * this issue after the line is invalidated. */ -static inline void spitfire_put_icache_tag(unsigned long addr, unsigned long tag) +static __inline__ void spitfire_put_icache_tag(unsigned long addr, unsigned long tag) { __asm__ __volatile__("stxa %0, [%1] %2\n\t" "membar #Sync" @@ -88,7 +89,7 @@ static inline void spitfire_put_icache_tag(unsigned long addr, unsigned long tag : "r" (tag), "r" (addr), "i" (ASI_IC_TAG)); } -static inline unsigned long spitfire_get_dtlb_data(int entry) +static __inline__ unsigned long spitfire_get_dtlb_data(int entry) { unsigned long data; @@ -102,7 +103,7 @@ static inline unsigned long spitfire_get_dtlb_data(int entry) return data; } -static inline unsigned long spitfire_get_dtlb_tag(int entry) +static __inline__ unsigned long spitfire_get_dtlb_tag(int entry) { unsigned long tag; @@ -112,7 +113,7 @@ static inline unsigned long spitfire_get_dtlb_tag(int entry) return tag; } -static inline void spitfire_put_dtlb_data(int entry, unsigned long data) +static __inline__ void spitfire_put_dtlb_data(int entry, unsigned long data) { __asm__ __volatile__("stxa %0, [%1] %2\n\t" "membar #Sync" @@ -121,7 +122,7 @@ static inline void spitfire_put_dtlb_data(int entry, unsigned long data) "i" (ASI_DTLB_DATA_ACCESS)); } -static inline unsigned long spitfire_get_itlb_data(int entry) +static __inline__ unsigned long spitfire_get_itlb_data(int entry) { unsigned long data; @@ -135,7 +136,7 @@ static inline unsigned long spitfire_get_itlb_data(int entry) return data; } -static inline unsigned long spitfire_get_itlb_tag(int entry) +static __inline__ unsigned long spitfire_get_itlb_tag(int entry) { unsigned long tag; @@ -145,7 +146,7 @@ static inline unsigned long spitfire_get_itlb_tag(int entry) return tag; } -static inline void spitfire_put_itlb_data(int entry, unsigned long data) +static __inline__ void spitfire_put_itlb_data(int entry, unsigned long data) { __asm__ __volatile__("stxa %0, [%1] %2\n\t" "membar #Sync" @@ -154,7 +155,7 @@ static inline void spitfire_put_itlb_data(int entry, unsigned long data) "i" (ASI_ITLB_DATA_ACCESS)); } -static inline void spitfire_flush_dtlb_nucleus_page(unsigned long page) +static __inline__ void spitfire_flush_dtlb_nucleus_page(unsigned long page) { __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" "membar #Sync" @@ -162,7 +163,7 @@ static inline void spitfire_flush_dtlb_nucleus_page(unsigned long page) : "r" (page | 0x20), "i" (ASI_DMMU_DEMAP)); } -static inline void spitfire_flush_itlb_nucleus_page(unsigned long page) +static __inline__ void spitfire_flush_itlb_nucleus_page(unsigned long page) { __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" "membar #Sync" @@ -171,7 +172,7 @@ static inline void spitfire_flush_itlb_nucleus_page(unsigned long page) } /* Cheetah has "all non-locked" tlb flushes. */ -static inline void cheetah_flush_dtlb_all(void) +static __inline__ void cheetah_flush_dtlb_all(void) { __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" "membar #Sync" @@ -179,7 +180,7 @@ static inline void cheetah_flush_dtlb_all(void) : "r" (0x80), "i" (ASI_DMMU_DEMAP)); } -static inline void cheetah_flush_itlb_all(void) +static __inline__ void cheetah_flush_itlb_all(void) { __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" "membar #Sync" @@ -201,7 +202,7 @@ static inline void cheetah_flush_itlb_all(void) * ASI_{D,I}TLB_DATA_ACCESS loads, doing the load twice fixes * the problem for me. -DaveM */ -static inline unsigned long cheetah_get_ldtlb_data(int entry) +static __inline__ unsigned long cheetah_get_ldtlb_data(int entry) { unsigned long data; @@ -214,7 +215,7 @@ static inline unsigned long cheetah_get_ldtlb_data(int entry) return data; } -static inline unsigned long cheetah_get_litlb_data(int entry) +static __inline__ unsigned long cheetah_get_litlb_data(int entry) { unsigned long data; @@ -227,7 +228,7 @@ static inline unsigned long cheetah_get_litlb_data(int entry) return data; } -static inline unsigned long cheetah_get_ldtlb_tag(int entry) +static __inline__ unsigned long cheetah_get_ldtlb_tag(int entry) { unsigned long tag; @@ -239,7 +240,7 @@ static inline unsigned long cheetah_get_ldtlb_tag(int entry) return tag; } -static inline unsigned long cheetah_get_litlb_tag(int entry) +static __inline__ unsigned long cheetah_get_litlb_tag(int entry) { unsigned long tag; @@ -251,7 +252,7 @@ static inline unsigned long cheetah_get_litlb_tag(int entry) return tag; } -static inline void cheetah_put_ldtlb_data(int entry, unsigned long data) +static __inline__ void cheetah_put_ldtlb_data(int entry, unsigned long data) { __asm__ __volatile__("stxa %0, [%1] %2\n\t" "membar #Sync" @@ -261,7 +262,7 @@ static inline void cheetah_put_ldtlb_data(int entry, unsigned long data) "i" (ASI_DTLB_DATA_ACCESS)); } -static inline void cheetah_put_litlb_data(int entry, unsigned long data) +static __inline__ void cheetah_put_litlb_data(int entry, unsigned long data) { __asm__ __volatile__("stxa %0, [%1] %2\n\t" "membar #Sync" @@ -271,7 +272,7 @@ static inline void cheetah_put_litlb_data(int entry, unsigned long data) "i" (ASI_ITLB_DATA_ACCESS)); } -static inline unsigned long cheetah_get_dtlb_data(int entry, int tlb) +static __inline__ unsigned long cheetah_get_dtlb_data(int entry, int tlb) { unsigned long data; @@ -283,7 +284,7 @@ static inline unsigned long cheetah_get_dtlb_data(int entry, int tlb) return data; } -static inline unsigned long cheetah_get_dtlb_tag(int entry, int tlb) +static __inline__ unsigned long cheetah_get_dtlb_tag(int entry, int tlb) { unsigned long tag; @@ -293,7 +294,7 @@ static inline unsigned long cheetah_get_dtlb_tag(int entry, int tlb) return tag; } -static inline void cheetah_put_dtlb_data(int entry, unsigned long data, int tlb) +static __inline__ void cheetah_put_dtlb_data(int entry, unsigned long data, int tlb) { __asm__ __volatile__("stxa %0, [%1] %2\n\t" "membar #Sync" @@ -303,7 +304,7 @@ static inline void cheetah_put_dtlb_data(int entry, unsigned long data, int tlb) "i" (ASI_DTLB_DATA_ACCESS)); } -static inline unsigned long cheetah_get_itlb_data(int entry) +static __inline__ unsigned long cheetah_get_itlb_data(int entry) { unsigned long data; @@ -316,7 +317,7 @@ static inline unsigned long cheetah_get_itlb_data(int entry) return data; } -static inline unsigned long cheetah_get_itlb_tag(int entry) +static __inline__ unsigned long cheetah_get_itlb_tag(int entry) { unsigned long tag; @@ -326,7 +327,7 @@ static inline unsigned long cheetah_get_itlb_tag(int entry) return tag; } -static inline void cheetah_put_itlb_data(int entry, unsigned long data) +static __inline__ void cheetah_put_itlb_data(int entry, unsigned long data) { __asm__ __volatile__("stxa %0, [%1] %2\n\t" "membar #Sync" diff --git a/trunk/include/asm-sparc64/system.h b/trunk/include/asm-sparc64/system.h index 159e62b51d70..3f175fa7e6d2 100644 --- a/trunk/include/asm-sparc64/system.h +++ b/trunk/include/asm-sparc64/system.h @@ -1,3 +1,4 @@ +/* $Id: system.h,v 1.69 2002/02/09 19:49:31 davem Exp $ */ #ifndef __SPARC64_SYSTEM_H #define __SPARC64_SYSTEM_H @@ -239,7 +240,7 @@ static inline unsigned long xchg64(__volatile__ unsigned long *m, unsigned long extern void __xchg_called_with_bad_pointer(void); -static inline unsigned long __xchg(unsigned long x, __volatile__ void * ptr, +static __inline__ unsigned long __xchg(unsigned long x, __volatile__ void * ptr, int size) { switch (size) { @@ -262,7 +263,7 @@ extern void die_if_kernel(char *str, struct pt_regs *regs) __attribute__ ((noret #define __HAVE_ARCH_CMPXCHG 1 -static inline unsigned long +static __inline__ unsigned long __cmpxchg_u32(volatile int *m, int old, int new) { __asm__ __volatile__("membar #StoreLoad | #LoadLoad\n" @@ -275,7 +276,7 @@ __cmpxchg_u32(volatile int *m, int old, int new) return new; } -static inline unsigned long +static __inline__ unsigned long __cmpxchg_u64(volatile long *m, unsigned long old, unsigned long new) { __asm__ __volatile__("membar #StoreLoad | #LoadLoad\n" @@ -292,7 +293,7 @@ __cmpxchg_u64(volatile long *m, unsigned long old, unsigned long new) if something tries to do an invalid cmpxchg(). */ extern void __cmpxchg_called_with_bad_pointer(void); -static inline unsigned long +static __inline__ unsigned long __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) { switch (size) { diff --git a/trunk/include/asm-sparc64/upa.h b/trunk/include/asm-sparc64/upa.h index 5b1633223f92..7ae09a22e408 100644 --- a/trunk/include/asm-sparc64/upa.h +++ b/trunk/include/asm-sparc64/upa.h @@ -1,3 +1,4 @@ +/* $Id: upa.h,v 1.3 1999/09/21 14:39:47 davem Exp $ */ #ifndef _SPARC64_UPA_H #define _SPARC64_UPA_H @@ -24,7 +25,7 @@ /* UPA I/O space accessors */ #if defined(__KERNEL__) && !defined(__ASSEMBLY__) -static inline unsigned char _upa_readb(unsigned long addr) +static __inline__ unsigned char _upa_readb(unsigned long addr) { unsigned char ret; @@ -35,7 +36,7 @@ static inline unsigned char _upa_readb(unsigned long addr) return ret; } -static inline unsigned short _upa_readw(unsigned long addr) +static __inline__ unsigned short _upa_readw(unsigned long addr) { unsigned short ret; @@ -46,7 +47,7 @@ static inline unsigned short _upa_readw(unsigned long addr) return ret; } -static inline unsigned int _upa_readl(unsigned long addr) +static __inline__ unsigned int _upa_readl(unsigned long addr) { unsigned int ret; @@ -57,7 +58,7 @@ static inline unsigned int _upa_readl(unsigned long addr) return ret; } -static inline unsigned long _upa_readq(unsigned long addr) +static __inline__ unsigned long _upa_readq(unsigned long addr) { unsigned long ret; @@ -68,28 +69,28 @@ static inline unsigned long _upa_readq(unsigned long addr) return ret; } -static inline void _upa_writeb(unsigned char b, unsigned long addr) +static __inline__ void _upa_writeb(unsigned char b, unsigned long addr) { __asm__ __volatile__("stba\t%0, [%1] %2\t/* upa_writeb */" : /* no outputs */ : "r" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); } -static inline void _upa_writew(unsigned short w, unsigned long addr) +static __inline__ void _upa_writew(unsigned short w, unsigned long addr) { __asm__ __volatile__("stha\t%0, [%1] %2\t/* upa_writew */" : /* no outputs */ : "r" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); } -static inline void _upa_writel(unsigned int l, unsigned long addr) +static __inline__ void _upa_writel(unsigned int l, unsigned long addr) { __asm__ __volatile__("stwa\t%0, [%1] %2\t/* upa_writel */" : /* no outputs */ : "r" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); } -static inline void _upa_writeq(unsigned long q, unsigned long addr) +static __inline__ void _upa_writeq(unsigned long q, unsigned long addr) { __asm__ __volatile__("stxa\t%0, [%1] %2\t/* upa_writeq */" : /* no outputs */ diff --git a/trunk/include/asm-sparc64/visasm.h b/trunk/include/asm-sparc64/visasm.h index 34f2ec64933b..a74078551e0f 100644 --- a/trunk/include/asm-sparc64/visasm.h +++ b/trunk/include/asm-sparc64/visasm.h @@ -1,3 +1,4 @@ +/* $Id: visasm.h,v 1.5 2001/04/24 01:09:12 davem Exp $ */ #ifndef _SPARC64_VISASM_H #define _SPARC64_VISASM_H @@ -43,7 +44,7 @@ wr %o5, 0, %fprs; #ifndef __ASSEMBLY__ -static inline void save_and_clear_fpu(void) { +static __inline__ void save_and_clear_fpu(void) { __asm__ __volatile__ ( " rd %%fprs, %%o5\n" " andcc %%o5, %0, %%g0\n" diff --git a/trunk/include/asm-um/unistd.h b/trunk/include/asm-um/unistd.h index 38bd9d94ee46..732c83f04c3d 100644 --- a/trunk/include/asm-um/unistd.h +++ b/trunk/include/asm-um/unistd.h @@ -14,6 +14,7 @@ extern int um_execve(const char *file, char *const argv[], char *const env[]); #ifdef __KERNEL__ /* We get __ARCH_WANT_OLD_STAT and __ARCH_WANT_STAT64 from the base arch */ +#define __ARCH_WANT_IPC_PARSE_VERSION #define __ARCH_WANT_OLD_READDIR #define __ARCH_WANT_SYS_ALARM #define __ARCH_WANT_SYS_GETHOSTNAME diff --git a/trunk/include/asm-x86/Kbuild b/trunk/include/asm-x86/Kbuild index 12db5a1cdd74..5e3539c129b9 100644 --- a/trunk/include/asm-x86/Kbuild +++ b/trunk/include/asm-x86/Kbuild @@ -11,16 +11,41 @@ header-y += sigcontext32.h header-y += ucontext.h header-y += vsyscall32.h +unifdef-y += a.out_32.h +unifdef-y += a.out_64.h +unifdef-y += byteorder_32.h +unifdef-y += byteorder_64.h unifdef-y += e820.h +unifdef-y += elf_32.h +unifdef-y += elf_64.h unifdef-y += ist.h unifdef-y += mce.h +unifdef-y += msgbuf_32.h +unifdef-y += msgbuf_64.h +unifdef-y += msr_32.h +unifdef-y += msr_64.h unifdef-y += msr.h +unifdef-y += mtrr_32.h +unifdef-y += mtrr_64.h unifdef-y += mtrr.h unifdef-y += page_32.h unifdef-y += page_64.h unifdef-y += posix_types_32.h unifdef-y += posix_types_64.h -unifdef-y += ptrace.h +unifdef-y += ptrace_32.h +unifdef-y += ptrace_64.h +unifdef-y += setup_32.h +unifdef-y += setup_64.h +unifdef-y += shmbuf_32.h +unifdef-y += shmbuf_64.h +unifdef-y += sigcontext_32.h +unifdef-y += sigcontext_64.h +unifdef-y += signal_32.h +unifdef-y += signal_64.h +unifdef-y += stat_32.h +unifdef-y += stat_64.h +unifdef-y += statfs_32.h +unifdef-y += statfs_64.h unifdef-y += unistd_32.h unifdef-y += unistd_64.h unifdef-y += user_32.h diff --git a/trunk/include/asm-x86/a.out.h b/trunk/include/asm-x86/a.out.h index a62443e38eb8..5bc9b1d3b227 100644 --- a/trunk/include/asm-x86/a.out.h +++ b/trunk/include/asm-x86/a.out.h @@ -1,30 +1,13 @@ -#ifndef _ASM_X86_A_OUT_H -#define _ASM_X86_A_OUT_H - -struct exec -{ - unsigned int a_info; /* Use macros N_MAGIC, etc for access */ - unsigned a_text; /* length of text, in bytes */ - unsigned a_data; /* length of data, in bytes */ - unsigned a_bss; /* length of uninitialized data area for file, in bytes */ - unsigned a_syms; /* length of symbol table data in file, in bytes */ - unsigned a_entry; /* start address */ - unsigned a_trsize; /* length of relocation info for text, in bytes */ - unsigned a_drsize; /* length of relocation info for data, in bytes */ -}; - -#define N_TRSIZE(a) ((a).a_trsize) -#define N_DRSIZE(a) ((a).a_drsize) -#define N_SYMSIZE(a) ((a).a_syms) - #ifdef __KERNEL__ -# include -# define STACK_TOP TASK_SIZE # ifdef CONFIG_X86_32 -# define STACK_TOP_MAX STACK_TOP +# include "a.out_32.h" # else -# define STACK_TOP_MAX TASK_SIZE64 +# include "a.out_64.h" +# endif +#else +# ifdef __i386__ +# include "a.out_32.h" +# else +# include "a.out_64.h" # endif #endif - -#endif /* _ASM_X86_A_OUT_H */ diff --git a/trunk/include/asm-x86/a.out_32.h b/trunk/include/asm-x86/a.out_32.h new file mode 100644 index 000000000000..851a60f8258c --- /dev/null +++ b/trunk/include/asm-x86/a.out_32.h @@ -0,0 +1,27 @@ +#ifndef __I386_A_OUT_H__ +#define __I386_A_OUT_H__ + +struct exec +{ + unsigned long a_info; /* Use macros N_MAGIC, etc for access */ + unsigned a_text; /* length of text, in bytes */ + unsigned a_data; /* length of data, in bytes */ + unsigned a_bss; /* length of uninitialized data area for file, in bytes */ + unsigned a_syms; /* length of symbol table data in file, in bytes */ + unsigned a_entry; /* start address */ + unsigned a_trsize; /* length of relocation info for text, in bytes */ + unsigned a_drsize; /* length of relocation info for data, in bytes */ +}; + +#define N_TRSIZE(a) ((a).a_trsize) +#define N_DRSIZE(a) ((a).a_drsize) +#define N_SYMSIZE(a) ((a).a_syms) + +#ifdef __KERNEL__ + +#define STACK_TOP TASK_SIZE +#define STACK_TOP_MAX STACK_TOP + +#endif + +#endif /* __A_OUT_GNU_H__ */ diff --git a/trunk/include/asm-x86/a.out_64.h b/trunk/include/asm-x86/a.out_64.h new file mode 100644 index 000000000000..e789300e41a5 --- /dev/null +++ b/trunk/include/asm-x86/a.out_64.h @@ -0,0 +1,28 @@ +#ifndef __X8664_A_OUT_H__ +#define __X8664_A_OUT_H__ + +/* 32bit a.out */ + +struct exec +{ + unsigned int a_info; /* Use macros N_MAGIC, etc for access */ + unsigned a_text; /* length of text, in bytes */ + unsigned a_data; /* length of data, in bytes */ + unsigned a_bss; /* length of uninitialized data area for file, in bytes */ + unsigned a_syms; /* length of symbol table data in file, in bytes */ + unsigned a_entry; /* start address */ + unsigned a_trsize; /* length of relocation info for text, in bytes */ + unsigned a_drsize; /* length of relocation info for data, in bytes */ +}; + +#define N_TRSIZE(a) ((a).a_trsize) +#define N_DRSIZE(a) ((a).a_drsize) +#define N_SYMSIZE(a) ((a).a_syms) + +#ifdef __KERNEL__ +#include +#define STACK_TOP TASK_SIZE +#define STACK_TOP_MAX TASK_SIZE64 +#endif + +#endif /* __A_OUT_GNU_H__ */ diff --git a/trunk/include/asm-x86/apic_64.h b/trunk/include/asm-x86/apic_64.h index 2747a11a2b19..3c8f21eef0be 100644 --- a/trunk/include/asm-x86/apic_64.h +++ b/trunk/include/asm-x86/apic_64.h @@ -69,7 +69,6 @@ extern void clear_local_APIC (void); extern void connect_bsp_APIC (void); extern void disconnect_bsp_APIC (int virt_wire_setup); extern void disable_local_APIC (void); -extern void lapic_shutdown (void); extern int verify_local_APIC (void); extern void cache_APIC_registers (void); extern void sync_Arb_IDs (void); diff --git a/trunk/include/asm-x86/bitops_32.h b/trunk/include/asm-x86/bitops_32.h index 0b40f6d20bea..3268a341cf49 100644 --- a/trunk/include/asm-x86/bitops_32.h +++ b/trunk/include/asm-x86/bitops_32.h @@ -80,20 +80,6 @@ static inline void clear_bit(int nr, volatile unsigned long * addr) :"Ir" (nr)); } -/* - * clear_bit_unlock - Clears a bit in memory - * @nr: Bit to clear - * @addr: Address to start counting from - * - * clear_bit() is atomic and implies release semantics before the memory - * operation. It can be used for an unlock. - */ -static inline void clear_bit_unlock(unsigned long nr, volatile unsigned long *addr) -{ - barrier(); - clear_bit(nr, addr); -} - static inline void __clear_bit(int nr, volatile unsigned long * addr) { __asm__ __volatile__( @@ -101,25 +87,6 @@ static inline void __clear_bit(int nr, volatile unsigned long * addr) :"+m" (ADDR) :"Ir" (nr)); } - -/* - * __clear_bit_unlock - Clears a bit in memory - * @nr: Bit to clear - * @addr: Address to start counting from - * - * __clear_bit() is non-atomic and implies release semantics before the memory - * operation. It can be used for an unlock if no other CPUs can concurrently - * modify other bits in the word. - * - * No memory barrier is required here, because x86 cannot reorder stores past - * older loads. Same principle as spin_unlock. - */ -static inline void __clear_bit_unlock(unsigned long nr, volatile unsigned long *addr) -{ - barrier(); - __clear_bit(nr, addr); -} - #define smp_mb__before_clear_bit() barrier() #define smp_mb__after_clear_bit() barrier() @@ -178,18 +145,6 @@ static inline int test_and_set_bit(int nr, volatile unsigned long * addr) return oldbit; } -/** - * test_and_set_bit_lock - Set a bit and return its old value for lock - * @nr: Bit to set - * @addr: Address to count from - * - * This is the same as test_and_set_bit on x86. - */ -static inline int test_and_set_bit_lock(int nr, volatile unsigned long *addr) -{ - return test_and_set_bit(nr, addr); -} - /** * __test_and_set_bit - Set a bit and return its old value * @nr: Bit to set @@ -451,6 +406,7 @@ static inline int fls(int x) } #include +#include #endif /* __KERNEL__ */ diff --git a/trunk/include/asm-x86/bitops_64.h b/trunk/include/asm-x86/bitops_64.h index 766bcc0470a6..dacaa5f1febc 100644 --- a/trunk/include/asm-x86/bitops_64.h +++ b/trunk/include/asm-x86/bitops_64.h @@ -29,7 +29,7 @@ * Note that @nr may be almost arbitrarily large; this function is not * restricted to acting on a single-word quantity. */ -static inline void set_bit(int nr, volatile void *addr) +static __inline__ void set_bit(int nr, volatile void * addr) { __asm__ __volatile__( LOCK_PREFIX "btsl %1,%0" @@ -46,7 +46,7 @@ static inline void set_bit(int nr, volatile void *addr) * If it's called on the same region of memory simultaneously, the effect * may be that only one operation succeeds. */ -static inline void __set_bit(int nr, volatile void *addr) +static __inline__ void __set_bit(int nr, volatile void * addr) { __asm__ volatile( "btsl %1,%0" @@ -64,7 +64,7 @@ static inline void __set_bit(int nr, volatile void *addr) * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit() * in order to ensure changes are visible on other processors. */ -static inline void clear_bit(int nr, volatile void *addr) +static __inline__ void clear_bit(int nr, volatile void * addr) { __asm__ __volatile__( LOCK_PREFIX "btrl %1,%0" @@ -72,21 +72,7 @@ static inline void clear_bit(int nr, volatile void *addr) :"dIr" (nr)); } -/* - * clear_bit_unlock - Clears a bit in memory - * @nr: Bit to clear - * @addr: Address to start counting from - * - * clear_bit() is atomic and implies release semantics before the memory - * operation. It can be used for an unlock. - */ -static inline void clear_bit_unlock(unsigned long nr, volatile unsigned long *addr) -{ - barrier(); - clear_bit(nr, addr); -} - -static inline void __clear_bit(int nr, volatile void *addr) +static __inline__ void __clear_bit(int nr, volatile void * addr) { __asm__ __volatile__( "btrl %1,%0" @@ -94,24 +80,6 @@ static inline void __clear_bit(int nr, volatile void *addr) :"dIr" (nr)); } -/* - * __clear_bit_unlock - Clears a bit in memory - * @nr: Bit to clear - * @addr: Address to start counting from - * - * __clear_bit() is non-atomic and implies release semantics before the memory - * operation. It can be used for an unlock if no other CPUs can concurrently - * modify other bits in the word. - * - * No memory barrier is required here, because x86 cannot reorder stores past - * older loads. Same principle as spin_unlock. - */ -static inline void __clear_bit_unlock(unsigned long nr, volatile unsigned long *addr) -{ - barrier(); - __clear_bit(nr, addr); -} - #define smp_mb__before_clear_bit() barrier() #define smp_mb__after_clear_bit() barrier() @@ -124,7 +92,7 @@ static inline void __clear_bit_unlock(unsigned long nr, volatile unsigned long * * If it's called on the same region of memory simultaneously, the effect * may be that only one operation succeeds. */ -static inline void __change_bit(int nr, volatile void *addr) +static __inline__ void __change_bit(int nr, volatile void * addr) { __asm__ __volatile__( "btcl %1,%0" @@ -141,7 +109,7 @@ static inline void __change_bit(int nr, volatile void *addr) * Note that @nr may be almost arbitrarily large; this function is not * restricted to acting on a single-word quantity. */ -static inline void change_bit(int nr, volatile void *addr) +static __inline__ void change_bit(int nr, volatile void * addr) { __asm__ __volatile__( LOCK_PREFIX "btcl %1,%0" @@ -157,7 +125,7 @@ static inline void change_bit(int nr, volatile void *addr) * This operation is atomic and cannot be reordered. * It also implies a memory barrier. */ -static inline int test_and_set_bit(int nr, volatile void *addr) +static __inline__ int test_and_set_bit(int nr, volatile void * addr) { int oldbit; @@ -168,18 +136,6 @@ static inline int test_and_set_bit(int nr, volatile void *addr) return oldbit; } -/** - * test_and_set_bit_lock - Set a bit and return its old value for lock - * @nr: Bit to set - * @addr: Address to count from - * - * This is the same as test_and_set_bit on x86. - */ -static inline int test_and_set_bit_lock(int nr, volatile void *addr) -{ - return test_and_set_bit(nr, addr); -} - /** * __test_and_set_bit - Set a bit and return its old value * @nr: Bit to set @@ -189,7 +145,7 @@ static inline int test_and_set_bit_lock(int nr, volatile void *addr) * If two examples of this operation race, one can appear to succeed * but actually fail. You must protect multiple accesses with a lock. */ -static inline int __test_and_set_bit(int nr, volatile void *addr) +static __inline__ int __test_and_set_bit(int nr, volatile void * addr) { int oldbit; @@ -208,7 +164,7 @@ static inline int __test_and_set_bit(int nr, volatile void *addr) * This operation is atomic and cannot be reordered. * It also implies a memory barrier. */ -static inline int test_and_clear_bit(int nr, volatile void *addr) +static __inline__ int test_and_clear_bit(int nr, volatile void * addr) { int oldbit; @@ -228,7 +184,7 @@ static inline int test_and_clear_bit(int nr, volatile void *addr) * If two examples of this operation race, one can appear to succeed * but actually fail. You must protect multiple accesses with a lock. */ -static inline int __test_and_clear_bit(int nr, volatile void *addr) +static __inline__ int __test_and_clear_bit(int nr, volatile void * addr) { int oldbit; @@ -240,7 +196,7 @@ static inline int __test_and_clear_bit(int nr, volatile void *addr) } /* WARNING: non atomic and it can be reordered! */ -static inline int __test_and_change_bit(int nr, volatile void *addr) +static __inline__ int __test_and_change_bit(int nr, volatile void * addr) { int oldbit; @@ -259,7 +215,7 @@ static inline int __test_and_change_bit(int nr, volatile void *addr) * This operation is atomic and cannot be reordered. * It also implies a memory barrier. */ -static inline int test_and_change_bit(int nr, volatile void *addr) +static __inline__ int test_and_change_bit(int nr, volatile void * addr) { int oldbit; @@ -276,15 +232,15 @@ static inline int test_and_change_bit(int nr, volatile void *addr) * @nr: bit number to test * @addr: Address to start counting from */ -static int test_bit(int nr, const volatile void *addr); +static int test_bit(int nr, const volatile void * addr); #endif -static inline int constant_test_bit(int nr, const volatile void *addr) +static __inline__ int constant_test_bit(int nr, const volatile void * addr) { return ((1UL << (nr & 31)) & (((const volatile unsigned int *) addr)[nr >> 5])) != 0; } -static inline int variable_test_bit(int nr, volatile const void *addr) +static __inline__ int variable_test_bit(int nr, volatile const void * addr) { int oldbit; @@ -302,10 +258,10 @@ static inline int variable_test_bit(int nr, volatile const void *addr) #undef ADDR -extern long find_first_zero_bit(const unsigned long *addr, unsigned long size); -extern long find_next_zero_bit(const unsigned long *addr, long size, long offset); -extern long find_first_bit(const unsigned long *addr, unsigned long size); -extern long find_next_bit(const unsigned long *addr, long size, long offset); +extern long find_first_zero_bit(const unsigned long * addr, unsigned long size); +extern long find_next_zero_bit (const unsigned long * addr, long size, long offset); +extern long find_first_bit(const unsigned long * addr, unsigned long size); +extern long find_next_bit(const unsigned long * addr, long size, long offset); /* return index of first bet set in val or max when no bit is set */ static inline long __scanbit(unsigned long val, unsigned long max) @@ -366,7 +322,7 @@ static inline void __clear_bit_string(unsigned long *bitmap, unsigned long i, * * Undefined if no zero exists, so code should check against ~0UL first. */ -static inline unsigned long ffz(unsigned long word) +static __inline__ unsigned long ffz(unsigned long word) { __asm__("bsfq %1,%0" :"=r" (word) @@ -380,7 +336,7 @@ static inline unsigned long ffz(unsigned long word) * * Undefined if no bit exists, so code should check against 0 first. */ -static inline unsigned long __ffs(unsigned long word) +static __inline__ unsigned long __ffs(unsigned long word) { __asm__("bsfq %1,%0" :"=r" (word) @@ -394,7 +350,7 @@ static inline unsigned long __ffs(unsigned long word) * * Undefined if no zero exists, so code should check against ~0UL first. */ -static inline unsigned long __fls(unsigned long word) +static __inline__ unsigned long __fls(unsigned long word) { __asm__("bsrq %1,%0" :"=r" (word) @@ -414,7 +370,7 @@ static inline unsigned long __fls(unsigned long word) * the libc and compiler builtin ffs routines, therefore * differs in spirit from the above ffz (man ffs). */ -static inline int ffs(int x) +static __inline__ int ffs(int x) { int r; @@ -430,7 +386,7 @@ static inline int ffs(int x) * * This is defined the same way as fls. */ -static inline int fls64(__u64 x) +static __inline__ int fls64(__u64 x) { if (x == 0) return 0; @@ -443,7 +399,7 @@ static inline int fls64(__u64 x) * * This is defined the same way as ffs. */ -static inline int fls(int x) +static __inline__ int fls(int x) { int r; @@ -456,6 +412,7 @@ static inline int fls(int x) #define ARCH_HAS_FAST_MULTIPLIER 1 #include +#include #endif /* __KERNEL__ */ diff --git a/trunk/include/asm-x86/byteorder.h b/trunk/include/asm-x86/byteorder.h index 1f2d6d5bf20d..eb14b1870ed7 100644 --- a/trunk/include/asm-x86/byteorder.h +++ b/trunk/include/asm-x86/byteorder.h @@ -1,72 +1,13 @@ -#ifndef _ASM_X86_BYTEORDER_H -#define _ASM_X86_BYTEORDER_H - -#include -#include - -#ifdef __GNUC__ - -#ifdef __i386__ - -static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x) -{ -#ifdef CONFIG_X86_BSWAP - __asm__("bswap %0" : "=r" (x) : "0" (x)); +#ifdef __KERNEL__ +# ifdef CONFIG_X86_32 +# include "byteorder_32.h" +# else +# include "byteorder_64.h" +# endif #else - __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */ - "rorl $16,%0\n\t" /* swap words */ - "xchgb %b0,%h0" /* swap higher bytes */ - :"=q" (x) - : "0" (x)); +# ifdef __i386__ +# include "byteorder_32.h" +# else +# include "byteorder_64.h" +# endif #endif - return x; -} - -static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 val) -{ - union { - struct { __u32 a,b; } s; - __u64 u; - } v; - v.u = val; -#ifdef CONFIG_X86_BSWAP - asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1" - : "=r" (v.s.a), "=r" (v.s.b) - : "0" (v.s.a), "1" (v.s.b)); -#else - v.s.a = ___arch__swab32(v.s.a); - v.s.b = ___arch__swab32(v.s.b); - asm("xchgl %0,%1" : "=r" (v.s.a), "=r" (v.s.b) : "0" (v.s.a), "1" (v.s.b)); -#endif - return v.u; -} - -#else /* __i386__ */ - -static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x) -{ - __asm__("bswapq %0" : "=r" (x) : "0" (x)); - return x; -} - -static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x) -{ - __asm__("bswapl %0" : "=r" (x) : "0" (x)); - return x; -} - -#endif - -/* Do not define swab16. Gcc is smart enough to recognize "C" version and - convert it into rotation or exhange. */ - -#define __arch__swab64(x) ___arch__swab64(x) -#define __arch__swab32(x) ___arch__swab32(x) - -#define __BYTEORDER_HAS_U64__ - -#endif /* __GNUC__ */ - -#include - -#endif /* _ASM_X86_BYTEORDER_H */ diff --git a/trunk/include/asm-x86/byteorder_32.h b/trunk/include/asm-x86/byteorder_32.h new file mode 100644 index 000000000000..a45470a8b74a --- /dev/null +++ b/trunk/include/asm-x86/byteorder_32.h @@ -0,0 +1,58 @@ +#ifndef _I386_BYTEORDER_H +#define _I386_BYTEORDER_H + +#include +#include + +#ifdef __GNUC__ + +/* For avoiding bswap on i386 */ +#ifdef __KERNEL__ +#endif + +static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x) +{ +#ifdef CONFIG_X86_BSWAP + __asm__("bswap %0" : "=r" (x) : "0" (x)); +#else + __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */ + "rorl $16,%0\n\t" /* swap words */ + "xchgb %b0,%h0" /* swap higher bytes */ + :"=q" (x) + : "0" (x)); +#endif + return x; +} + +static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 val) +{ + union { + struct { __u32 a,b; } s; + __u64 u; + } v; + v.u = val; +#ifdef CONFIG_X86_BSWAP + asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1" + : "=r" (v.s.a), "=r" (v.s.b) + : "0" (v.s.a), "1" (v.s.b)); +#else + v.s.a = ___arch__swab32(v.s.a); + v.s.b = ___arch__swab32(v.s.b); + asm("xchgl %0,%1" : "=r" (v.s.a), "=r" (v.s.b) : "0" (v.s.a), "1" (v.s.b)); +#endif + return v.u; +} + +/* Do not define swab16. Gcc is smart enough to recognize "C" version and + convert it into rotation or exhange. */ + +#define __arch__swab64(x) ___arch__swab64(x) +#define __arch__swab32(x) ___arch__swab32(x) + +#define __BYTEORDER_HAS_U64__ + +#endif /* __GNUC__ */ + +#include + +#endif /* _I386_BYTEORDER_H */ diff --git a/trunk/include/asm-x86/byteorder_64.h b/trunk/include/asm-x86/byteorder_64.h new file mode 100644 index 000000000000..5e86c868c75e --- /dev/null +++ b/trunk/include/asm-x86/byteorder_64.h @@ -0,0 +1,33 @@ +#ifndef _X86_64_BYTEORDER_H +#define _X86_64_BYTEORDER_H + +#include +#include + +#ifdef __GNUC__ + +static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x) +{ + __asm__("bswapq %0" : "=r" (x) : "0" (x)); + return x; +} + +static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x) +{ + __asm__("bswapl %0" : "=r" (x) : "0" (x)); + return x; +} + +/* Do not define swab16. Gcc is smart enough to recognize "C" version and + convert it into rotation or exhange. */ + +#define __arch__swab32(x) ___arch__swab32(x) +#define __arch__swab64(x) ___arch__swab64(x) + +#endif /* __GNUC__ */ + +#define __BYTEORDER_HAS_U64__ + +#include + +#endif /* _X86_64_BYTEORDER_H */ diff --git a/trunk/include/asm-x86/div64.h b/trunk/include/asm-x86/div64.h index e98d16e7a37a..8ac7da6ca284 100644 --- a/trunk/include/asm-x86/div64.h +++ b/trunk/include/asm-x86/div64.h @@ -1,59 +1,5 @@ -#ifndef _ASM_X86_DIV64_H -#define _ASM_X86_DIV64_H - #ifdef CONFIG_X86_32 - -#include - -/* - * do_div() is NOT a C function. It wants to return - * two values (the quotient and the remainder), but - * since that doesn't work very well in C, what it - * does is: - * - * - modifies the 64-bit dividend _in_place_ - * - returns the 32-bit remainder - * - * This ends up being the most efficient "calling - * convention" on x86. - */ -#define do_div(n,base) ({ \ - unsigned long __upper, __low, __high, __mod, __base; \ - __base = (base); \ - asm("":"=a" (__low), "=d" (__high):"A" (n)); \ - __upper = __high; \ - if (__high) { \ - __upper = __high % (__base); \ - __high = __high / (__base); \ - } \ - asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (__base), "0" (__low), "1" (__upper)); \ - asm("":"=A" (n):"a" (__low),"d" (__high)); \ - __mod; \ -}) - -/* - * (long)X = ((long long)divs) / (long)div - * (long)rem = ((long long)divs) % (long)div - * - * Warning, this will do an exception if X overflows. - */ -#define div_long_long_rem(a,b,c) div_ll_X_l_rem(a,b,c) - -static inline long -div_ll_X_l_rem(long long divs, long div, long *rem) -{ - long dum2; - __asm__("divl %2":"=a"(dum2), "=d"(*rem) - : "rm"(div), "A"(divs)); - - return dum2; - -} - -extern uint64_t div64_64(uint64_t dividend, uint64_t divisor); - +# include "div64_32.h" #else -# include -#endif /* CONFIG_X86_32 */ - -#endif /* _ASM_X86_DIV64_H */ +# include "div64_64.h" +#endif diff --git a/trunk/include/asm-x86/div64_32.h b/trunk/include/asm-x86/div64_32.h new file mode 100644 index 000000000000..438e980068bd --- /dev/null +++ b/trunk/include/asm-x86/div64_32.h @@ -0,0 +1,52 @@ +#ifndef __I386_DIV64 +#define __I386_DIV64 + +#include + +/* + * do_div() is NOT a C function. It wants to return + * two values (the quotient and the remainder), but + * since that doesn't work very well in C, what it + * does is: + * + * - modifies the 64-bit dividend _in_place_ + * - returns the 32-bit remainder + * + * This ends up being the most efficient "calling + * convention" on x86. + */ +#define do_div(n,base) ({ \ + unsigned long __upper, __low, __high, __mod, __base; \ + __base = (base); \ + asm("":"=a" (__low), "=d" (__high):"A" (n)); \ + __upper = __high; \ + if (__high) { \ + __upper = __high % (__base); \ + __high = __high / (__base); \ + } \ + asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (__base), "0" (__low), "1" (__upper)); \ + asm("":"=A" (n):"a" (__low),"d" (__high)); \ + __mod; \ +}) + +/* + * (long)X = ((long long)divs) / (long)div + * (long)rem = ((long long)divs) % (long)div + * + * Warning, this will do an exception if X overflows. + */ +#define div_long_long_rem(a,b,c) div_ll_X_l_rem(a,b,c) + +static inline long +div_ll_X_l_rem(long long divs, long div, long *rem) +{ + long dum2; + __asm__("divl %2":"=a"(dum2), "=d"(*rem) + : "rm"(div), "A"(divs)); + + return dum2; + +} + +extern uint64_t div64_64(uint64_t dividend, uint64_t divisor); +#endif diff --git a/trunk/include/asm-x86/div64_64.h b/trunk/include/asm-x86/div64_64.h new file mode 100644 index 000000000000..6cd978cefb28 --- /dev/null +++ b/trunk/include/asm-x86/div64_64.h @@ -0,0 +1 @@ +#include diff --git a/trunk/include/asm-x86/elf.h b/trunk/include/asm-x86/elf.h index ec42a4d2e83b..ed6bb6e546b9 100644 --- a/trunk/include/asm-x86/elf.h +++ b/trunk/include/asm-x86/elf.h @@ -1,290 +1,13 @@ -#ifndef _ASM_X86_ELF_H -#define _ASM_X86_ELF_H - -/* - * ELF register definitions.. - */ - -#include -#include -#include - -typedef unsigned long elf_greg_t; - -#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t)) -typedef elf_greg_t elf_gregset_t[ELF_NGREG]; - -typedef struct user_i387_struct elf_fpregset_t; - -#ifdef __i386__ - -typedef struct user_fxsr_struct elf_fpxregset_t; - -#define R_386_NONE 0 -#define R_386_32 1 -#define R_386_PC32 2 -#define R_386_GOT32 3 -#define R_386_PLT32 4 -#define R_386_COPY 5 -#define R_386_GLOB_DAT 6 -#define R_386_JMP_SLOT 7 -#define R_386_RELATIVE 8 -#define R_386_GOTOFF 9 -#define R_386_GOTPC 10 -#define R_386_NUM 11 - -/* - * These are used to set parameters in the core dumps. - */ -#define ELF_CLASS ELFCLASS32 -#define ELF_DATA ELFDATA2LSB -#define ELF_ARCH EM_386 - -#else - -/* x86-64 relocation types */ -#define R_X86_64_NONE 0 /* No reloc */ -#define R_X86_64_64 1 /* Direct 64 bit */ -#define R_X86_64_PC32 2 /* PC relative 32 bit signed */ -#define R_X86_64_GOT32 3 /* 32 bit GOT entry */ -#define R_X86_64_PLT32 4 /* 32 bit PLT address */ -#define R_X86_64_COPY 5 /* Copy symbol at runtime */ -#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ -#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ -#define R_X86_64_RELATIVE 8 /* Adjust by program base */ -#define R_X86_64_GOTPCREL 9 /* 32 bit signed pc relative - offset to GOT */ -#define R_X86_64_32 10 /* Direct 32 bit zero extended */ -#define R_X86_64_32S 11 /* Direct 32 bit sign extended */ -#define R_X86_64_16 12 /* Direct 16 bit zero extended */ -#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */ -#define R_X86_64_8 14 /* Direct 8 bit sign extended */ -#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */ - -#define R_X86_64_NUM 16 - -/* - * These are used to set parameters in the core dumps. - */ -#define ELF_CLASS ELFCLASS64 -#define ELF_DATA ELFDATA2LSB -#define ELF_ARCH EM_X86_64 - -#endif - #ifdef __KERNEL__ - -#ifdef CONFIG_X86_32 -#include -#include /* for savesegment */ -#include - -/* - * This is used to ensure we don't load something for the wrong architecture. - */ -#define elf_check_arch(x) \ - (((x)->e_machine == EM_386) || ((x)->e_machine == EM_486)) - -/* SVR4/i386 ABI (pages 3-31, 3-32) says that when the program starts %edx - contains a pointer to a function which might be registered using `atexit'. - This provides a mean for the dynamic linker to call DT_FINI functions for - shared libraries that have been loaded before the code runs. - - A value of 0 tells we have no such handler. - - We might as well make sure everything else is cleared too (except for %esp), - just to make things more deterministic. - */ -#define ELF_PLAT_INIT(_r, load_addr) do { \ - _r->ebx = 0; _r->ecx = 0; _r->edx = 0; \ - _r->esi = 0; _r->edi = 0; _r->ebp = 0; \ - _r->eax = 0; \ -} while (0) - -/* regs is struct pt_regs, pr_reg is elf_gregset_t (which is - now struct_user_regs, they are different) */ - -#define ELF_CORE_COPY_REGS(pr_reg, regs) \ - pr_reg[0] = regs->ebx; \ - pr_reg[1] = regs->ecx; \ - pr_reg[2] = regs->edx; \ - pr_reg[3] = regs->esi; \ - pr_reg[4] = regs->edi; \ - pr_reg[5] = regs->ebp; \ - pr_reg[6] = regs->eax; \ - pr_reg[7] = regs->xds & 0xffff; \ - pr_reg[8] = regs->xes & 0xffff; \ - pr_reg[9] = regs->xfs & 0xffff; \ - savesegment(gs,pr_reg[10]); \ - pr_reg[11] = regs->orig_eax; \ - pr_reg[12] = regs->eip; \ - pr_reg[13] = regs->xcs & 0xffff; \ - pr_reg[14] = regs->eflags; \ - pr_reg[15] = regs->esp; \ - pr_reg[16] = regs->xss & 0xffff; - -#define ELF_PLATFORM (utsname()->machine) -#define set_personality_64bit() do { } while (0) -extern unsigned int vdso_enabled; - -#else /* CONFIG_X86_32 */ - -#include - -/* - * This is used to ensure we don't load something for the wrong architecture. - */ -#define elf_check_arch(x) \ - ((x)->e_machine == EM_X86_64) - -#define ELF_PLAT_INIT(_r, load_addr) do { \ - struct task_struct *cur = current; \ - (_r)->rbx = 0; (_r)->rcx = 0; (_r)->rdx = 0; \ - (_r)->rsi = 0; (_r)->rdi = 0; (_r)->rbp = 0; \ - (_r)->rax = 0; \ - (_r)->r8 = 0; \ - (_r)->r9 = 0; \ - (_r)->r10 = 0; \ - (_r)->r11 = 0; \ - (_r)->r12 = 0; \ - (_r)->r13 = 0; \ - (_r)->r14 = 0; \ - (_r)->r15 = 0; \ - cur->thread.fs = 0; cur->thread.gs = 0; \ - cur->thread.fsindex = 0; cur->thread.gsindex = 0; \ - cur->thread.ds = 0; cur->thread.es = 0; \ - clear_thread_flag(TIF_IA32); \ -} while (0) - -/* regs is struct pt_regs, pr_reg is elf_gregset_t (which is - now struct_user_regs, they are different). Assumes current is the process - getting dumped. */ - -#define ELF_CORE_COPY_REGS(pr_reg, regs) do { \ - unsigned v; \ - (pr_reg)[0] = (regs)->r15; \ - (pr_reg)[1] = (regs)->r14; \ - (pr_reg)[2] = (regs)->r13; \ - (pr_reg)[3] = (regs)->r12; \ - (pr_reg)[4] = (regs)->rbp; \ - (pr_reg)[5] = (regs)->rbx; \ - (pr_reg)[6] = (regs)->r11; \ - (pr_reg)[7] = (regs)->r10; \ - (pr_reg)[8] = (regs)->r9; \ - (pr_reg)[9] = (regs)->r8; \ - (pr_reg)[10] = (regs)->rax; \ - (pr_reg)[11] = (regs)->rcx; \ - (pr_reg)[12] = (regs)->rdx; \ - (pr_reg)[13] = (regs)->rsi; \ - (pr_reg)[14] = (regs)->rdi; \ - (pr_reg)[15] = (regs)->orig_rax; \ - (pr_reg)[16] = (regs)->rip; \ - (pr_reg)[17] = (regs)->cs; \ - (pr_reg)[18] = (regs)->eflags; \ - (pr_reg)[19] = (regs)->rsp; \ - (pr_reg)[20] = (regs)->ss; \ - (pr_reg)[21] = current->thread.fs; \ - (pr_reg)[22] = current->thread.gs; \ - asm("movl %%ds,%0" : "=r" (v)); (pr_reg)[23] = v; \ - asm("movl %%es,%0" : "=r" (v)); (pr_reg)[24] = v; \ - asm("movl %%fs,%0" : "=r" (v)); (pr_reg)[25] = v; \ - asm("movl %%gs,%0" : "=r" (v)); (pr_reg)[26] = v; \ -} while(0); - -/* I'm not sure if we can use '-' here */ -#define ELF_PLATFORM ("x86_64") -extern void set_personality_64bit(void); -extern int vdso_enabled; - -#endif /* !CONFIG_X86_32 */ - -#define USE_ELF_CORE_DUMP -#define ELF_EXEC_PAGESIZE 4096 - -/* This is the location that an ET_DYN program is loaded if exec'ed. Typical - use of this is to invoke "./ld.so someprog" to test out a new version of - the loader. We need to make sure that it is out of the way of the program - that it will "exec", and that there is sufficient room for the brk. */ - -#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2) - -/* This yields a mask that user programs can use to figure out what - instruction set this CPU supports. This could be done in user space, - but it's not easy, and we've already done it here. */ - -#define ELF_HWCAP (boot_cpu_data.x86_capability[0]) - -/* This yields a string that ld.so will use to load implementation - specific libraries for optimization. This is more specific in - intent than poking at uname or /proc/cpuinfo. - - For the moment, we have only optimizations for the Intel generations, - but that could change... */ - -#define SET_PERSONALITY(ex, ibcs2) set_personality_64bit() - -/* - * An executable for which elf_read_implies_exec() returns TRUE will - * have the READ_IMPLIES_EXEC personality flag set automatically. - */ -#define elf_read_implies_exec(ex, executable_stack) \ - (executable_stack != EXSTACK_DISABLE_X) - -struct task_struct; - -extern int dump_task_regs (struct task_struct *, elf_gregset_t *); -extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *); - -#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs) -#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs) - -#ifdef CONFIG_X86_32 -extern int dump_task_extended_fpu (struct task_struct *, - struct user_fxsr_struct *); -#define ELF_CORE_COPY_XFPREGS(tsk, elf_xfpregs) \ - dump_task_extended_fpu(tsk, elf_xfpregs) -#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG - -#define VDSO_HIGH_BASE (__fix_to_virt(FIX_VDSO)) -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso) -#define VDSO_PRELINK 0 - -#define VDSO_SYM(x) \ - (VDSO_CURRENT_BASE + (unsigned long)(x) - VDSO_PRELINK) - -#define VDSO_HIGH_EHDR ((const struct elfhdr *) VDSO_HIGH_BASE) -#define VDSO_EHDR ((const struct elfhdr *) VDSO_CURRENT_BASE) - -extern void __kernel_vsyscall; - -#define VDSO_ENTRY VDSO_SYM(&__kernel_vsyscall) - -/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */ - -#define ARCH_DLINFO \ -do if (vdso_enabled) { \ - NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY); \ - NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_CURRENT_BASE); \ -} while (0) - -#else /* CONFIG_X86_32 */ - -/* 1GB for 64bit, 8MB for 32bit */ -#define STACK_RND_MASK (test_thread_flag(TIF_IA32) ? 0x7ff : 0x3fffff) - -#define ARCH_DLINFO \ -do if (vdso_enabled) { \ - NEW_AUX_ENT(AT_SYSINFO_EHDR,(unsigned long)current->mm->context.vdso);\ -} while (0) - -#endif /* !CONFIG_X86_32 */ - -struct linux_binprm; - -#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 -extern int arch_setup_additional_pages(struct linux_binprm *bprm, - int executable_stack); - -#endif /* __KERNEL__ */ - +# ifdef CONFIG_X86_32 +# include "elf_32.h" +# else +# include "elf_64.h" +# endif +#else +# ifdef __i386__ +# include "elf_32.h" +# else +# include "elf_64.h" +# endif #endif diff --git a/trunk/include/asm-x86/elf_32.h b/trunk/include/asm-x86/elf_32.h new file mode 100644 index 000000000000..b3f694eaaf37 --- /dev/null +++ b/trunk/include/asm-x86/elf_32.h @@ -0,0 +1,165 @@ +#ifndef __ASMi386_ELF_H +#define __ASMi386_ELF_H + +/* + * ELF register definitions.. + */ + +#include +#include +#include + +#define R_386_NONE 0 +#define R_386_32 1 +#define R_386_PC32 2 +#define R_386_GOT32 3 +#define R_386_PLT32 4 +#define R_386_COPY 5 +#define R_386_GLOB_DAT 6 +#define R_386_JMP_SLOT 7 +#define R_386_RELATIVE 8 +#define R_386_GOTOFF 9 +#define R_386_GOTPC 10 +#define R_386_NUM 11 + +typedef unsigned long elf_greg_t; + +#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t)) +typedef elf_greg_t elf_gregset_t[ELF_NGREG]; + +typedef struct user_i387_struct elf_fpregset_t; +typedef struct user_fxsr_struct elf_fpxregset_t; + +/* + * This is used to ensure we don't load something for the wrong architecture. + */ +#define elf_check_arch(x) \ + (((x)->e_machine == EM_386) || ((x)->e_machine == EM_486)) + +/* + * These are used to set parameters in the core dumps. + */ +#define ELF_CLASS ELFCLASS32 +#define ELF_DATA ELFDATA2LSB +#define ELF_ARCH EM_386 + +#ifdef __KERNEL__ + +#include +#include /* for savesegment */ +#include + +/* SVR4/i386 ABI (pages 3-31, 3-32) says that when the program starts %edx + contains a pointer to a function which might be registered using `atexit'. + This provides a mean for the dynamic linker to call DT_FINI functions for + shared libraries that have been loaded before the code runs. + + A value of 0 tells we have no such handler. + + We might as well make sure everything else is cleared too (except for %esp), + just to make things more deterministic. + */ +#define ELF_PLAT_INIT(_r, load_addr) do { \ + _r->ebx = 0; _r->ecx = 0; _r->edx = 0; \ + _r->esi = 0; _r->edi = 0; _r->ebp = 0; \ + _r->eax = 0; \ +} while (0) + +#define USE_ELF_CORE_DUMP +#define ELF_EXEC_PAGESIZE 4096 + +/* This is the location that an ET_DYN program is loaded if exec'ed. Typical + use of this is to invoke "./ld.so someprog" to test out a new version of + the loader. We need to make sure that it is out of the way of the program + that it will "exec", and that there is sufficient room for the brk. */ + +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2) + +/* regs is struct pt_regs, pr_reg is elf_gregset_t (which is + now struct_user_regs, they are different) */ + +#define ELF_CORE_COPY_REGS(pr_reg, regs) \ + pr_reg[0] = regs->ebx; \ + pr_reg[1] = regs->ecx; \ + pr_reg[2] = regs->edx; \ + pr_reg[3] = regs->esi; \ + pr_reg[4] = regs->edi; \ + pr_reg[5] = regs->ebp; \ + pr_reg[6] = regs->eax; \ + pr_reg[7] = regs->xds & 0xffff; \ + pr_reg[8] = regs->xes & 0xffff; \ + pr_reg[9] = regs->xfs & 0xffff; \ + savesegment(gs,pr_reg[10]); \ + pr_reg[11] = regs->orig_eax; \ + pr_reg[12] = regs->eip; \ + pr_reg[13] = regs->xcs & 0xffff; \ + pr_reg[14] = regs->eflags; \ + pr_reg[15] = regs->esp; \ + pr_reg[16] = regs->xss & 0xffff; + +/* This yields a mask that user programs can use to figure out what + instruction set this CPU supports. This could be done in user space, + but it's not easy, and we've already done it here. */ + +#define ELF_HWCAP (boot_cpu_data.x86_capability[0]) + +/* This yields a string that ld.so will use to load implementation + specific libraries for optimization. This is more specific in + intent than poking at uname or /proc/cpuinfo. + + For the moment, we have only optimizations for the Intel generations, + but that could change... */ + +#define ELF_PLATFORM (utsname()->machine) + +#define SET_PERSONALITY(ex, ibcs2) do { } while (0) + +/* + * An executable for which elf_read_implies_exec() returns TRUE will + * have the READ_IMPLIES_EXEC personality flag set automatically. + */ +#define elf_read_implies_exec(ex, executable_stack) (executable_stack != EXSTACK_DISABLE_X) + +struct task_struct; + +extern int dump_task_regs (struct task_struct *, elf_gregset_t *); +extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *); +extern int dump_task_extended_fpu (struct task_struct *, struct user_fxsr_struct *); + +#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs) +#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs) +#define ELF_CORE_COPY_XFPREGS(tsk, elf_xfpregs) dump_task_extended_fpu(tsk, elf_xfpregs) +#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG + +#define VDSO_HIGH_BASE (__fix_to_virt(FIX_VDSO)) +#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso) +#define VDSO_PRELINK 0 + +#define VDSO_SYM(x) \ + (VDSO_CURRENT_BASE + (unsigned long)(x) - VDSO_PRELINK) + +#define VDSO_HIGH_EHDR ((const struct elfhdr *) VDSO_HIGH_BASE) +#define VDSO_EHDR ((const struct elfhdr *) VDSO_CURRENT_BASE) + +extern void __kernel_vsyscall; + +#define VDSO_ENTRY VDSO_SYM(&__kernel_vsyscall) + +struct linux_binprm; + +#define ARCH_HAS_SETUP_ADDITIONAL_PAGES +extern int arch_setup_additional_pages(struct linux_binprm *bprm, + int executable_stack); + +extern unsigned int vdso_enabled; + +/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */ +#define ARCH_DLINFO \ +do if (vdso_enabled) { \ + NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY); \ + NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_CURRENT_BASE); \ +} while (0) + +#endif + +#endif diff --git a/trunk/include/asm-x86/elf_64.h b/trunk/include/asm-x86/elf_64.h new file mode 100644 index 000000000000..b4fbe47f6ccd --- /dev/null +++ b/trunk/include/asm-x86/elf_64.h @@ -0,0 +1,180 @@ +#ifndef __ASM_X86_64_ELF_H +#define __ASM_X86_64_ELF_H + +/* + * ELF register definitions.. + */ + +#include +#include + +/* x86-64 relocation types */ +#define R_X86_64_NONE 0 /* No reloc */ +#define R_X86_64_64 1 /* Direct 64 bit */ +#define R_X86_64_PC32 2 /* PC relative 32 bit signed */ +#define R_X86_64_GOT32 3 /* 32 bit GOT entry */ +#define R_X86_64_PLT32 4 /* 32 bit PLT address */ +#define R_X86_64_COPY 5 /* Copy symbol at runtime */ +#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ +#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ +#define R_X86_64_RELATIVE 8 /* Adjust by program base */ +#define R_X86_64_GOTPCREL 9 /* 32 bit signed pc relative + offset to GOT */ +#define R_X86_64_32 10 /* Direct 32 bit zero extended */ +#define R_X86_64_32S 11 /* Direct 32 bit sign extended */ +#define R_X86_64_16 12 /* Direct 16 bit zero extended */ +#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */ +#define R_X86_64_8 14 /* Direct 8 bit sign extended */ +#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */ + +#define R_X86_64_NUM 16 + +typedef unsigned long elf_greg_t; + +#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t)) +typedef elf_greg_t elf_gregset_t[ELF_NGREG]; + +typedef struct user_i387_struct elf_fpregset_t; + +/* + * These are used to set parameters in the core dumps. + */ +#define ELF_CLASS ELFCLASS64 +#define ELF_DATA ELFDATA2LSB +#define ELF_ARCH EM_X86_64 + +#ifdef __KERNEL__ +#include + +/* + * This is used to ensure we don't load something for the wrong architecture. + */ +#define elf_check_arch(x) \ + ((x)->e_machine == EM_X86_64) + + +/* SVR4/i386 ABI (pages 3-31, 3-32) says that when the program starts %edx + contains a pointer to a function which might be registered using `atexit'. + This provides a mean for the dynamic linker to call DT_FINI functions for + shared libraries that have been loaded before the code runs. + + A value of 0 tells we have no such handler. + + We might as well make sure everything else is cleared too (except for %esp), + just to make things more deterministic. + */ +#define ELF_PLAT_INIT(_r, load_addr) do { \ + struct task_struct *cur = current; \ + (_r)->rbx = 0; (_r)->rcx = 0; (_r)->rdx = 0; \ + (_r)->rsi = 0; (_r)->rdi = 0; (_r)->rbp = 0; \ + (_r)->rax = 0; \ + (_r)->r8 = 0; \ + (_r)->r9 = 0; \ + (_r)->r10 = 0; \ + (_r)->r11 = 0; \ + (_r)->r12 = 0; \ + (_r)->r13 = 0; \ + (_r)->r14 = 0; \ + (_r)->r15 = 0; \ + cur->thread.fs = 0; cur->thread.gs = 0; \ + cur->thread.fsindex = 0; cur->thread.gsindex = 0; \ + cur->thread.ds = 0; cur->thread.es = 0; \ + clear_thread_flag(TIF_IA32); \ +} while (0) + +#define USE_ELF_CORE_DUMP +#define ELF_EXEC_PAGESIZE 4096 + +/* This is the location that an ET_DYN program is loaded if exec'ed. Typical + use of this is to invoke "./ld.so someprog" to test out a new version of + the loader. We need to make sure that it is out of the way of the program + that it will "exec", and that there is sufficient room for the brk. */ + +#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3) + +/* regs is struct pt_regs, pr_reg is elf_gregset_t (which is + now struct_user_regs, they are different). Assumes current is the process + getting dumped. */ + +#define ELF_CORE_COPY_REGS(pr_reg, regs) do { \ + unsigned v; \ + (pr_reg)[0] = (regs)->r15; \ + (pr_reg)[1] = (regs)->r14; \ + (pr_reg)[2] = (regs)->r13; \ + (pr_reg)[3] = (regs)->r12; \ + (pr_reg)[4] = (regs)->rbp; \ + (pr_reg)[5] = (regs)->rbx; \ + (pr_reg)[6] = (regs)->r11; \ + (pr_reg)[7] = (regs)->r10; \ + (pr_reg)[8] = (regs)->r9; \ + (pr_reg)[9] = (regs)->r8; \ + (pr_reg)[10] = (regs)->rax; \ + (pr_reg)[11] = (regs)->rcx; \ + (pr_reg)[12] = (regs)->rdx; \ + (pr_reg)[13] = (regs)->rsi; \ + (pr_reg)[14] = (regs)->rdi; \ + (pr_reg)[15] = (regs)->orig_rax; \ + (pr_reg)[16] = (regs)->rip; \ + (pr_reg)[17] = (regs)->cs; \ + (pr_reg)[18] = (regs)->eflags; \ + (pr_reg)[19] = (regs)->rsp; \ + (pr_reg)[20] = (regs)->ss; \ + (pr_reg)[21] = current->thread.fs; \ + (pr_reg)[22] = current->thread.gs; \ + asm("movl %%ds,%0" : "=r" (v)); (pr_reg)[23] = v; \ + asm("movl %%es,%0" : "=r" (v)); (pr_reg)[24] = v; \ + asm("movl %%fs,%0" : "=r" (v)); (pr_reg)[25] = v; \ + asm("movl %%gs,%0" : "=r" (v)); (pr_reg)[26] = v; \ +} while(0); + +/* This yields a mask that user programs can use to figure out what + instruction set this CPU supports. This could be done in user space, + but it's not easy, and we've already done it here. */ + +#define ELF_HWCAP (boot_cpu_data.x86_capability[0]) + +/* This yields a string that ld.so will use to load implementation + specific libraries for optimization. This is more specific in + intent than poking at uname or /proc/cpuinfo. + + For the moment, we have only optimizations for the Intel generations, + but that could change... */ + +/* I'm not sure if we can use '-' here */ +#define ELF_PLATFORM ("x86_64") + +extern void set_personality_64bit(void); +#define SET_PERSONALITY(ex, ibcs2) set_personality_64bit() +/* + * An executable for which elf_read_implies_exec() returns TRUE will + * have the READ_IMPLIES_EXEC personality flag set automatically. + */ +#define elf_read_implies_exec(ex, executable_stack) (executable_stack != EXSTACK_DISABLE_X) + +struct task_struct; + +extern int dump_task_regs (struct task_struct *, elf_gregset_t *); +extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *); + +#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs) +#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs) + +/* 1GB for 64bit, 8MB for 32bit */ +#define STACK_RND_MASK (test_thread_flag(TIF_IA32) ? 0x7ff : 0x3fffff) + + +#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 +struct linux_binprm; +extern int arch_setup_additional_pages(struct linux_binprm *bprm, + int executable_stack); + +extern int vdso_enabled; + +#define ARCH_DLINFO \ +do if (vdso_enabled) { \ + NEW_AUX_ENT(AT_SYSINFO_EHDR,(unsigned long)current->mm->context.vdso);\ +} while (0) + +#endif + +#endif diff --git a/trunk/include/asm-x86/gart.h b/trunk/include/asm-x86/gart.h deleted file mode 100644 index f704c50519b8..000000000000 --- a/trunk/include/asm-x86/gart.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _ASM_X8664_IOMMU_H -#define _ASM_X8664_IOMMU_H 1 - -extern void pci_iommu_shutdown(void); -extern void no_iommu_init(void); -extern int force_iommu, no_iommu; -extern int iommu_detected; -#ifdef CONFIG_GART_IOMMU -extern void gart_iommu_init(void); -extern void gart_iommu_shutdown(void); -extern void __init gart_parse_options(char *); -extern void gart_iommu_hole_init(void); -extern int fallback_aper_order; -extern int fallback_aper_force; -extern int gart_iommu_aperture; -extern int gart_iommu_aperture_allowed; -extern int gart_iommu_aperture_disabled; -extern int fix_aperture; -#else -#define gart_iommu_aperture 0 -#define gart_iommu_aperture_allowed 0 - -static inline void gart_iommu_shutdown(void) -{ -} - -#endif - -#endif diff --git a/trunk/include/asm-x86/iommu.h b/trunk/include/asm-x86/iommu.h index 07862fdd23c0..5af471f228ee 100644 --- a/trunk/include/asm-x86/iommu.h +++ b/trunk/include/asm-x86/iommu.h @@ -1,5 +1,5 @@ -#ifndef _ASM_X8664_GART_H -#define _ASM_X8664_GART_H 1 +#ifndef _ASM_X8664_IOMMU_H +#define _ASM_X8664_IOMMU_H 1 extern void pci_iommu_shutdown(void); extern void no_iommu_init(void); diff --git a/trunk/include/asm-x86/lguest_hcall.h b/trunk/include/asm-x86/lguest_hcall.h index 9c5092b6aa9f..f948491eb56a 100644 --- a/trunk/include/asm-x86/lguest_hcall.h +++ b/trunk/include/asm-x86/lguest_hcall.h @@ -18,17 +18,12 @@ #define LHCALL_LOAD_TLS 16 #define LHCALL_NOTIFY 17 -#define LGUEST_TRAP_ENTRY 0x1F - -#ifndef __ASSEMBLY__ -#include - /*G:031 First, how does our Guest contact the Host to ask for privileged * operations? There are two ways: the direct way is to make a "hypercall", * to make requests of the Host Itself. * * Our hypercall mechanism uses the highest unused trap code (traps 32 and - * above are used by real hardware interrupts). Fifteen hypercalls are + * above are used by real hardware interrupts). Seventeen hypercalls are * available: the hypercall number is put in the %eax register, and the * arguments (when required) are placed in %edx, %ebx and %ecx. If a return * value makes sense, it's returned in %eax. @@ -36,15 +31,20 @@ * Grossly invalid calls result in Sudden Death at the hands of the vengeful * Host, rather than returning failure. This reflects Winston Churchill's * definition of a gentleman: "someone who is only rude intentionally". */ +#define LGUEST_TRAP_ENTRY 0x1F + +#ifndef __ASSEMBLY__ +#include + static inline unsigned long hcall(unsigned long call, unsigned long arg1, unsigned long arg2, unsigned long arg3) { /* "int" is the Intel instruction to trigger a trap. */ asm volatile("int $" __stringify(LGUEST_TRAP_ENTRY) - /* The call in %eax (aka "a") might be overwritten */ + /* The call is in %eax (aka "a"), and can be replaced */ : "=a"(call) - /* The arguments are in %eax, %edx, %ebx & %ecx */ + /* The other arguments are in %eax, %edx, %ebx & %ecx */ : "a"(call), "d"(arg1), "b"(arg2), "c"(arg3) /* "memory" means this might write somewhere in memory. * This isn't true for all calls, but it's safe to tell diff --git a/trunk/include/asm-x86/mmu.h b/trunk/include/asm-x86/mmu.h index 3f922c8e1c88..9c628cd70e23 100644 --- a/trunk/include/asm-x86/mmu.h +++ b/trunk/include/asm-x86/mmu.h @@ -1,23 +1,5 @@ -#ifndef _ASM_X86_MMU_H -#define _ASM_X86_MMU_H - -#include -#include - -/* - * The x86 doesn't have a mmu context, but - * we put the segment information here. - * - * cpu_vm_mask is used to optimize ldt flushing. - */ -typedef struct { - void *ldt; -#ifdef CONFIG_X86_64 - rwlock_t ldtlock; +#ifdef CONFIG_X86_32 +# include "mmu_32.h" +#else +# include "mmu_64.h" #endif - int size; - struct mutex lock; - void *vdso; -} mm_context_t; - -#endif /* _ASM_X86_MMU_H */ diff --git a/trunk/include/asm-x86/mmu_32.h b/trunk/include/asm-x86/mmu_32.h new file mode 100644 index 000000000000..5e249c51ef56 --- /dev/null +++ b/trunk/include/asm-x86/mmu_32.h @@ -0,0 +1,18 @@ +#ifndef __i386_MMU_H +#define __i386_MMU_H + +#include +/* + * The i386 doesn't have a mmu context, but + * we put the segment information here. + * + * cpu_vm_mask is used to optimize ldt flushing. + */ +typedef struct { + int size; + struct mutex lock; + void *ldt; + void *vdso; +} mm_context_t; + +#endif diff --git a/trunk/include/asm-x86/mmu_64.h b/trunk/include/asm-x86/mmu_64.h new file mode 100644 index 000000000000..024357c27222 --- /dev/null +++ b/trunk/include/asm-x86/mmu_64.h @@ -0,0 +1,21 @@ +#ifndef __x86_64_MMU_H +#define __x86_64_MMU_H + +#include +#include + +/* + * The x86_64 doesn't have a mmu context, but + * we put the segment information here. + * + * cpu_vm_mask is used to optimize ldt flushing. + */ +typedef struct { + void *ldt; + rwlock_t ldtlock; + int size; + struct mutex lock; + void *vdso; +} mm_context_t; + +#endif diff --git a/trunk/include/asm-x86/msgbuf.h b/trunk/include/asm-x86/msgbuf.h index 7e4e9481f51c..154f7d64e862 100644 --- a/trunk/include/asm-x86/msgbuf.h +++ b/trunk/include/asm-x86/msgbuf.h @@ -1,39 +1,13 @@ -#ifndef _ASM_X86_MSGBUF_H -#define _ASM_X86_MSGBUF_H - -/* - * The msqid64_ds structure for i386 architecture. - * Note extra padding because this structure is passed back and forth - * between kernel and user space. - * - * Pad space on i386 is left for: - * - 64-bit time_t to solve y2038 problem - * - 2 miscellaneous 32-bit values - * - * Pad space on x8664 is left for: - * - 2 miscellaneous 64-bit values - */ -struct msqid64_ds { - struct ipc64_perm msg_perm; - __kernel_time_t msg_stime; /* last msgsnd time */ -#ifdef __i386__ - unsigned long __unused1; +#ifdef __KERNEL__ +# ifdef CONFIG_X86_32 +# include "msgbuf_32.h" +# else +# include "msgbuf_64.h" +# endif +#else +# ifdef __i386__ +# include "msgbuf_32.h" +# else +# include "msgbuf_64.h" +# endif #endif - __kernel_time_t msg_rtime; /* last msgrcv time */ -#ifdef __i386__ - unsigned long __unused2; -#endif - __kernel_time_t msg_ctime; /* last change time */ -#ifdef __i386__ - unsigned long __unused3; -#endif - unsigned long msg_cbytes; /* current number of bytes on queue */ - unsigned long msg_qnum; /* number of messages in queue */ - unsigned long msg_qbytes; /* max number of bytes on queue */ - __kernel_pid_t msg_lspid; /* pid of last msgsnd */ - __kernel_pid_t msg_lrpid; /* last receive pid */ - unsigned long __unused4; - unsigned long __unused5; -}; - -#endif /* _ASM_X86_MSGBUF_H */ diff --git a/trunk/include/asm-x86/msgbuf_32.h b/trunk/include/asm-x86/msgbuf_32.h new file mode 100644 index 000000000000..b8d659c157ae --- /dev/null +++ b/trunk/include/asm-x86/msgbuf_32.h @@ -0,0 +1,31 @@ +#ifndef _I386_MSGBUF_H +#define _I386_MSGBUF_H + +/* + * The msqid64_ds structure for i386 architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * Pad space is left for: + * - 64-bit time_t to solve y2038 problem + * - 2 miscellaneous 32-bit values + */ + +struct msqid64_ds { + struct ipc64_perm msg_perm; + __kernel_time_t msg_stime; /* last msgsnd time */ + unsigned long __unused1; + __kernel_time_t msg_rtime; /* last msgrcv time */ + unsigned long __unused2; + __kernel_time_t msg_ctime; /* last change time */ + unsigned long __unused3; + unsigned long msg_cbytes; /* current number of bytes on queue */ + unsigned long msg_qnum; /* number of messages in queue */ + unsigned long msg_qbytes; /* max number of bytes on queue */ + __kernel_pid_t msg_lspid; /* pid of last msgsnd */ + __kernel_pid_t msg_lrpid; /* last receive pid */ + unsigned long __unused4; + unsigned long __unused5; +}; + +#endif /* _I386_MSGBUF_H */ diff --git a/trunk/include/asm-x86/msgbuf_64.h b/trunk/include/asm-x86/msgbuf_64.h new file mode 100644 index 000000000000..cd6f95dd54da --- /dev/null +++ b/trunk/include/asm-x86/msgbuf_64.h @@ -0,0 +1,27 @@ +#ifndef _X8664_MSGBUF_H +#define _X8664_MSGBUF_H + +/* + * The msqid64_ds structure for x86-64 architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * Pad space is left for: + * - 2 miscellaneous 64-bit values + */ + +struct msqid64_ds { + struct ipc64_perm msg_perm; + __kernel_time_t msg_stime; /* last msgsnd time */ + __kernel_time_t msg_rtime; /* last msgrcv time */ + __kernel_time_t msg_ctime; /* last change time */ + unsigned long msg_cbytes; /* current number of bytes on queue */ + unsigned long msg_qnum; /* number of messages in queue */ + unsigned long msg_qbytes; /* max number of bytes on queue */ + __kernel_pid_t msg_lspid; /* pid of last msgsnd */ + __kernel_pid_t msg_lrpid; /* last receive pid */ + unsigned long __unused4; + unsigned long __unused5; +}; + +#endif diff --git a/trunk/include/asm-x86/msr.h b/trunk/include/asm-x86/msr.h index ba4b31432120..2f87ce007002 100644 --- a/trunk/include/asm-x86/msr.h +++ b/trunk/include/asm-x86/msr.h @@ -1,350 +1,13 @@ -#ifndef __ASM_X86_MSR_H_ -#define __ASM_X86_MSR_H_ - -#include - -#ifdef __i386__ - #ifdef __KERNEL__ -#ifndef __ASSEMBLY__ - -#include - -static inline unsigned long long native_read_msr(unsigned int msr) -{ - unsigned long long val; - - asm volatile("rdmsr" : "=A" (val) : "c" (msr)); - return val; -} - -static inline unsigned long long native_read_msr_safe(unsigned int msr, - int *err) -{ - unsigned long long val; - - asm volatile("2: rdmsr ; xorl %0,%0\n" - "1:\n\t" - ".section .fixup,\"ax\"\n\t" - "3: movl %3,%0 ; jmp 1b\n\t" - ".previous\n\t" - ".section __ex_table,\"a\"\n" - " .align 4\n\t" - " .long 2b,3b\n\t" - ".previous" - : "=r" (*err), "=A" (val) - : "c" (msr), "i" (-EFAULT)); - - return val; -} - -static inline void native_write_msr(unsigned int msr, unsigned long long val) -{ - asm volatile("wrmsr" : : "c" (msr), "A"(val)); -} - -static inline int native_write_msr_safe(unsigned int msr, - unsigned long long val) -{ - int err; - asm volatile("2: wrmsr ; xorl %0,%0\n" - "1:\n\t" - ".section .fixup,\"ax\"\n\t" - "3: movl %4,%0 ; jmp 1b\n\t" - ".previous\n\t" - ".section __ex_table,\"a\"\n" - " .align 4\n\t" - " .long 2b,3b\n\t" - ".previous" - : "=a" (err) - : "c" (msr), "0" ((u32)val), "d" ((u32)(val>>32)), - "i" (-EFAULT)); - return err; -} - -static inline unsigned long long native_read_tsc(void) -{ - unsigned long long val; - asm volatile("rdtsc" : "=A" (val)); - return val; -} - -static inline unsigned long long native_read_pmc(void) -{ - unsigned long long val; - asm volatile("rdpmc" : "=A" (val)); - return val; -} - -#ifdef CONFIG_PARAVIRT -#include +# ifdef CONFIG_X86_32 +# include "msr_32.h" +# else +# include "msr_64.h" +# endif #else -#include -/* - * Access to machine-specific registers (available on 586 and better only) - * Note: the rd* operations modify the parameters directly (without using - * pointer indirection), this allows gcc to optimize better - */ - -#define rdmsr(msr,val1,val2) \ - do { \ - u64 __val = native_read_msr(msr); \ - (val1) = (u32)__val; \ - (val2) = (u32)(__val >> 32); \ - } while(0) - -static inline void wrmsr(u32 __msr, u32 __low, u32 __high) -{ - native_write_msr(__msr, ((u64)__high << 32) | __low); -} - -#define rdmsrl(msr,val) \ - ((val) = native_read_msr(msr)) - -#define wrmsrl(msr,val) native_write_msr(msr, val) - -/* wrmsr with exception handling */ -static inline int wrmsr_safe(u32 __msr, u32 __low, u32 __high) -{ - return native_write_msr_safe(__msr, ((u64)__high << 32) | __low); -} - -/* rdmsr with exception handling */ -#define rdmsr_safe(msr,p1,p2) \ - ({ \ - int __err; \ - u64 __val = native_read_msr_safe(msr, &__err); \ - (*p1) = (u32)__val; \ - (*p2) = (u32)(__val >> 32); \ - __err; \ - }) - -#define rdtscl(low) \ - ((low) = (u32)native_read_tsc()) - -#define rdtscll(val) \ - ((val) = native_read_tsc()) - -#define write_tsc(val1,val2) wrmsr(0x10, val1, val2) - -#define rdpmc(counter,low,high) \ - do { \ - u64 _l = native_read_pmc(); \ - (low) = (u32)_l; \ - (high) = (u32)(_l >> 32); \ - } while(0) -#endif /* !CONFIG_PARAVIRT */ - -#ifdef CONFIG_SMP -void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); -void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); -int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); -int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); -#else /* CONFIG_SMP */ -static inline void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) -{ - rdmsr(msr_no, *l, *h); -} -static inline void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) -{ - wrmsr(msr_no, l, h); -} -static inline int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) -{ - return rdmsr_safe(msr_no, l, h); -} -static inline int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) -{ - return wrmsr_safe(msr_no, l, h); -} -#endif /* CONFIG_SMP */ -#endif /* ! __ASSEMBLY__ */ -#endif /* __KERNEL__ */ - -#else /* __i386__ */ - -#ifndef __ASSEMBLY__ -#include -/* - * Access to machine-specific registers (available on 586 and better only) - * Note: the rd* operations modify the parameters directly (without using - * pointer indirection), this allows gcc to optimize better - */ - -#define rdmsr(msr,val1,val2) \ - __asm__ __volatile__("rdmsr" \ - : "=a" (val1), "=d" (val2) \ - : "c" (msr)) - - -#define rdmsrl(msr,val) do { unsigned long a__,b__; \ - __asm__ __volatile__("rdmsr" \ - : "=a" (a__), "=d" (b__) \ - : "c" (msr)); \ - val = a__ | (b__<<32); \ -} while(0) - -#define wrmsr(msr,val1,val2) \ - __asm__ __volatile__("wrmsr" \ - : /* no outputs */ \ - : "c" (msr), "a" (val1), "d" (val2)) - -#define wrmsrl(msr,val) wrmsr(msr,(__u32)((__u64)(val)),((__u64)(val))>>32) - -/* wrmsr with exception handling */ -#define wrmsr_safe(msr,a,b) ({ int ret__; \ - asm volatile("2: wrmsr ; xorl %0,%0\n" \ - "1:\n\t" \ - ".section .fixup,\"ax\"\n\t" \ - "3: movl %4,%0 ; jmp 1b\n\t" \ - ".previous\n\t" \ - ".section __ex_table,\"a\"\n" \ - " .align 8\n\t" \ - " .quad 2b,3b\n\t" \ - ".previous" \ - : "=a" (ret__) \ - : "c" (msr), "0" (a), "d" (b), "i" (-EFAULT)); \ - ret__; }) - -#define checking_wrmsrl(msr,val) wrmsr_safe(msr,(u32)(val),(u32)((val)>>32)) - -#define rdmsr_safe(msr,a,b) \ - ({ int ret__; \ - asm volatile ("1: rdmsr\n" \ - "2:\n" \ - ".section .fixup,\"ax\"\n" \ - "3: movl %4,%0\n" \ - " jmp 2b\n" \ - ".previous\n" \ - ".section __ex_table,\"a\"\n" \ - " .align 8\n" \ - " .quad 1b,3b\n" \ - ".previous":"=&bDS" (ret__), "=a"(*(a)), "=d"(*(b)) \ - :"c"(msr), "i"(-EIO), "0"(0)); \ - ret__; }) - -#define rdtsc(low,high) \ - __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high)) - -#define rdtscl(low) \ - __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx") - -#define rdtscp(low,high,aux) \ - asm volatile (".byte 0x0f,0x01,0xf9" : "=a" (low), "=d" (high), "=c" (aux)) - -#define rdtscll(val) do { \ - unsigned int __a,__d; \ - asm volatile("rdtsc" : "=a" (__a), "=d" (__d)); \ - (val) = ((unsigned long)__a) | (((unsigned long)__d)<<32); \ -} while(0) - -#define rdtscpll(val, aux) do { \ - unsigned long __a, __d; \ - asm volatile (".byte 0x0f,0x01,0xf9" : "=a" (__a), "=d" (__d), "=c" (aux)); \ - (val) = (__d << 32) | __a; \ -} while (0) - -#define write_tsc(val1,val2) wrmsr(0x10, val1, val2) - -#define write_rdtscp_aux(val) wrmsr(0xc0000103, val, 0) - -#define rdpmc(counter,low,high) \ - __asm__ __volatile__("rdpmc" \ - : "=a" (low), "=d" (high) \ - : "c" (counter)) - -static inline void cpuid(int op, unsigned int *eax, unsigned int *ebx, - unsigned int *ecx, unsigned int *edx) -{ - __asm__("cpuid" - : "=a" (*eax), - "=b" (*ebx), - "=c" (*ecx), - "=d" (*edx) - : "0" (op)); -} - -/* Some CPUID calls want 'count' to be placed in ecx */ -static inline void cpuid_count(int op, int count, int *eax, int *ebx, int *ecx, - int *edx) -{ - __asm__("cpuid" - : "=a" (*eax), - "=b" (*ebx), - "=c" (*ecx), - "=d" (*edx) - : "0" (op), "c" (count)); -} - -/* - * CPUID functions returning a single datum - */ -static inline unsigned int cpuid_eax(unsigned int op) -{ - unsigned int eax; - - __asm__("cpuid" - : "=a" (eax) - : "0" (op) - : "bx", "cx", "dx"); - return eax; -} -static inline unsigned int cpuid_ebx(unsigned int op) -{ - unsigned int eax, ebx; - - __asm__("cpuid" - : "=a" (eax), "=b" (ebx) - : "0" (op) - : "cx", "dx" ); - return ebx; -} -static inline unsigned int cpuid_ecx(unsigned int op) -{ - unsigned int eax, ecx; - - __asm__("cpuid" - : "=a" (eax), "=c" (ecx) - : "0" (op) - : "bx", "dx" ); - return ecx; -} -static inline unsigned int cpuid_edx(unsigned int op) -{ - unsigned int eax, edx; - - __asm__("cpuid" - : "=a" (eax), "=d" (edx) - : "0" (op) - : "bx", "cx"); - return edx; -} - -#ifdef CONFIG_SMP -void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); -void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); -int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); -int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); -#else /* CONFIG_SMP */ -static inline void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) -{ - rdmsr(msr_no, *l, *h); -} -static inline void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) -{ - wrmsr(msr_no, l, h); -} -static inline int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) -{ - return rdmsr_safe(msr_no, l, h); -} -static inline int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) -{ - return wrmsr_safe(msr_no, l, h); -} -#endif /* CONFIG_SMP */ -#endif /* __ASSEMBLY__ */ - -#endif /* !__i386__ */ - +# ifdef __i386__ +# include "msr_32.h" +# else +# include "msr_64.h" +# endif #endif diff --git a/trunk/include/asm-x86/msr_32.h b/trunk/include/asm-x86/msr_32.h new file mode 100644 index 000000000000..df21ea049369 --- /dev/null +++ b/trunk/include/asm-x86/msr_32.h @@ -0,0 +1,161 @@ +#ifndef __ASM_MSR_H +#define __ASM_MSR_H + +#include + +#ifdef __KERNEL__ +#ifndef __ASSEMBLY__ + +#include + +static inline unsigned long long native_read_msr(unsigned int msr) +{ + unsigned long long val; + + asm volatile("rdmsr" : "=A" (val) : "c" (msr)); + return val; +} + +static inline unsigned long long native_read_msr_safe(unsigned int msr, + int *err) +{ + unsigned long long val; + + asm volatile("2: rdmsr ; xorl %0,%0\n" + "1:\n\t" + ".section .fixup,\"ax\"\n\t" + "3: movl %3,%0 ; jmp 1b\n\t" + ".previous\n\t" + ".section __ex_table,\"a\"\n" + " .align 4\n\t" + " .long 2b,3b\n\t" + ".previous" + : "=r" (*err), "=A" (val) + : "c" (msr), "i" (-EFAULT)); + + return val; +} + +static inline void native_write_msr(unsigned int msr, unsigned long long val) +{ + asm volatile("wrmsr" : : "c" (msr), "A"(val)); +} + +static inline int native_write_msr_safe(unsigned int msr, + unsigned long long val) +{ + int err; + asm volatile("2: wrmsr ; xorl %0,%0\n" + "1:\n\t" + ".section .fixup,\"ax\"\n\t" + "3: movl %4,%0 ; jmp 1b\n\t" + ".previous\n\t" + ".section __ex_table,\"a\"\n" + " .align 4\n\t" + " .long 2b,3b\n\t" + ".previous" + : "=a" (err) + : "c" (msr), "0" ((u32)val), "d" ((u32)(val>>32)), + "i" (-EFAULT)); + return err; +} + +static inline unsigned long long native_read_tsc(void) +{ + unsigned long long val; + asm volatile("rdtsc" : "=A" (val)); + return val; +} + +static inline unsigned long long native_read_pmc(void) +{ + unsigned long long val; + asm volatile("rdpmc" : "=A" (val)); + return val; +} + +#ifdef CONFIG_PARAVIRT +#include +#else +#include +/* + * Access to machine-specific registers (available on 586 and better only) + * Note: the rd* operations modify the parameters directly (without using + * pointer indirection), this allows gcc to optimize better + */ + +#define rdmsr(msr,val1,val2) \ + do { \ + u64 __val = native_read_msr(msr); \ + (val1) = (u32)__val; \ + (val2) = (u32)(__val >> 32); \ + } while(0) + +static inline void wrmsr(u32 __msr, u32 __low, u32 __high) +{ + native_write_msr(__msr, ((u64)__high << 32) | __low); +} + +#define rdmsrl(msr,val) \ + ((val) = native_read_msr(msr)) + +#define wrmsrl(msr,val) native_write_msr(msr, val) + +/* wrmsr with exception handling */ +static inline int wrmsr_safe(u32 __msr, u32 __low, u32 __high) +{ + return native_write_msr_safe(__msr, ((u64)__high << 32) | __low); +} + +/* rdmsr with exception handling */ +#define rdmsr_safe(msr,p1,p2) \ + ({ \ + int __err; \ + u64 __val = native_read_msr_safe(msr, &__err); \ + (*p1) = (u32)__val; \ + (*p2) = (u32)(__val >> 32); \ + __err; \ + }) + +#define rdtscl(low) \ + ((low) = (u32)native_read_tsc()) + +#define rdtscll(val) \ + ((val) = native_read_tsc()) + +#define write_tsc(val1,val2) wrmsr(0x10, val1, val2) + +#define rdpmc(counter,low,high) \ + do { \ + u64 _l = native_read_pmc(); \ + (low) = (u32)_l; \ + (high) = (u32)(_l >> 32); \ + } while(0) +#endif /* !CONFIG_PARAVIRT */ + +#ifdef CONFIG_SMP +void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); +void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); +int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); +int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); +#else /* CONFIG_SMP */ +static inline void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) +{ + rdmsr(msr_no, *l, *h); +} +static inline void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) +{ + wrmsr(msr_no, l, h); +} +static inline int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) +{ + return rdmsr_safe(msr_no, l, h); +} +static inline int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) +{ + return wrmsr_safe(msr_no, l, h); +} +#endif /* CONFIG_SMP */ +#endif +#endif +#endif /* __ASM_MSR_H */ diff --git a/trunk/include/asm-x86/msr_64.h b/trunk/include/asm-x86/msr_64.h new file mode 100644 index 000000000000..d5c55b80da54 --- /dev/null +++ b/trunk/include/asm-x86/msr_64.h @@ -0,0 +1,187 @@ +#ifndef X86_64_MSR_H +#define X86_64_MSR_H 1 + +#include + +#ifndef __ASSEMBLY__ +#include +/* + * Access to machine-specific registers (available on 586 and better only) + * Note: the rd* operations modify the parameters directly (without using + * pointer indirection), this allows gcc to optimize better + */ + +#define rdmsr(msr,val1,val2) \ + __asm__ __volatile__("rdmsr" \ + : "=a" (val1), "=d" (val2) \ + : "c" (msr)) + + +#define rdmsrl(msr,val) do { unsigned long a__,b__; \ + __asm__ __volatile__("rdmsr" \ + : "=a" (a__), "=d" (b__) \ + : "c" (msr)); \ + val = a__ | (b__<<32); \ +} while(0) + +#define wrmsr(msr,val1,val2) \ + __asm__ __volatile__("wrmsr" \ + : /* no outputs */ \ + : "c" (msr), "a" (val1), "d" (val2)) + +#define wrmsrl(msr,val) wrmsr(msr,(__u32)((__u64)(val)),((__u64)(val))>>32) + +/* wrmsr with exception handling */ +#define wrmsr_safe(msr,a,b) ({ int ret__; \ + asm volatile("2: wrmsr ; xorl %0,%0\n" \ + "1:\n\t" \ + ".section .fixup,\"ax\"\n\t" \ + "3: movl %4,%0 ; jmp 1b\n\t" \ + ".previous\n\t" \ + ".section __ex_table,\"a\"\n" \ + " .align 8\n\t" \ + " .quad 2b,3b\n\t" \ + ".previous" \ + : "=a" (ret__) \ + : "c" (msr), "0" (a), "d" (b), "i" (-EFAULT)); \ + ret__; }) + +#define checking_wrmsrl(msr,val) wrmsr_safe(msr,(u32)(val),(u32)((val)>>32)) + +#define rdmsr_safe(msr,a,b) \ + ({ int ret__; \ + asm volatile ("1: rdmsr\n" \ + "2:\n" \ + ".section .fixup,\"ax\"\n" \ + "3: movl %4,%0\n" \ + " jmp 2b\n" \ + ".previous\n" \ + ".section __ex_table,\"a\"\n" \ + " .align 8\n" \ + " .quad 1b,3b\n" \ + ".previous":"=&bDS" (ret__), "=a"(*(a)), "=d"(*(b))\ + :"c"(msr), "i"(-EIO), "0"(0)); \ + ret__; }) + +#define rdtsc(low,high) \ + __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high)) + +#define rdtscl(low) \ + __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx") + +#define rdtscp(low,high,aux) \ + asm volatile (".byte 0x0f,0x01,0xf9" : "=a" (low), "=d" (high), "=c" (aux)) + +#define rdtscll(val) do { \ + unsigned int __a,__d; \ + asm volatile("rdtsc" : "=a" (__a), "=d" (__d)); \ + (val) = ((unsigned long)__a) | (((unsigned long)__d)<<32); \ +} while(0) + +#define rdtscpll(val, aux) do { \ + unsigned long __a, __d; \ + asm volatile (".byte 0x0f,0x01,0xf9" : "=a" (__a), "=d" (__d), "=c" (aux)); \ + (val) = (__d << 32) | __a; \ +} while (0) + +#define write_tsc(val1,val2) wrmsr(0x10, val1, val2) + +#define write_rdtscp_aux(val) wrmsr(0xc0000103, val, 0) + +#define rdpmc(counter,low,high) \ + __asm__ __volatile__("rdpmc" \ + : "=a" (low), "=d" (high) \ + : "c" (counter)) + +static inline void cpuid(int op, unsigned int *eax, unsigned int *ebx, + unsigned int *ecx, unsigned int *edx) +{ + __asm__("cpuid" + : "=a" (*eax), + "=b" (*ebx), + "=c" (*ecx), + "=d" (*edx) + : "0" (op)); +} + +/* Some CPUID calls want 'count' to be placed in ecx */ +static inline void cpuid_count(int op, int count, int *eax, int *ebx, int *ecx, + int *edx) +{ + __asm__("cpuid" + : "=a" (*eax), + "=b" (*ebx), + "=c" (*ecx), + "=d" (*edx) + : "0" (op), "c" (count)); +} + +/* + * CPUID functions returning a single datum + */ +static inline unsigned int cpuid_eax(unsigned int op) +{ + unsigned int eax; + + __asm__("cpuid" + : "=a" (eax) + : "0" (op) + : "bx", "cx", "dx"); + return eax; +} +static inline unsigned int cpuid_ebx(unsigned int op) +{ + unsigned int eax, ebx; + + __asm__("cpuid" + : "=a" (eax), "=b" (ebx) + : "0" (op) + : "cx", "dx" ); + return ebx; +} +static inline unsigned int cpuid_ecx(unsigned int op) +{ + unsigned int eax, ecx; + + __asm__("cpuid" + : "=a" (eax), "=c" (ecx) + : "0" (op) + : "bx", "dx" ); + return ecx; +} +static inline unsigned int cpuid_edx(unsigned int op) +{ + unsigned int eax, edx; + + __asm__("cpuid" + : "=a" (eax), "=d" (edx) + : "0" (op) + : "bx", "cx"); + return edx; +} + +#ifdef CONFIG_SMP +void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); +void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); +int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); +int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); +#else /* CONFIG_SMP */ +static inline void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) +{ + rdmsr(msr_no, *l, *h); +} +static inline void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) +{ + wrmsr(msr_no, l, h); +} +static inline int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) +{ + return rdmsr_safe(msr_no, l, h); +} +static inline int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h) +{ + return wrmsr_safe(msr_no, l, h); +} +#endif /* CONFIG_SMP */ +#endif /* __ASSEMBLY__ */ +#endif /* X86_64_MSR_H */ diff --git a/trunk/include/asm-x86/mtrr.h b/trunk/include/asm-x86/mtrr.h index e8320e4e6ca2..34f633b3e00c 100644 --- a/trunk/include/asm-x86/mtrr.h +++ b/trunk/include/asm-x86/mtrr.h @@ -1,164 +1,13 @@ -/* Generic MTRR (Memory Type Range Register) ioctls. - - Copyright (C) 1997-1999 Richard Gooch - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - Richard Gooch may be reached by email at rgooch@atnf.csiro.au - The postal address is: - Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia. -*/ -#ifndef _ASM_X86_MTRR_H -#define _ASM_X86_MTRR_H - -#include -#include - -#define MTRR_IOCTL_BASE 'M' - -struct mtrr_sentry -{ - unsigned long base; /* Base address */ - unsigned int size; /* Size of region */ - unsigned int type; /* Type of region */ -}; - -/* Warning: this structure has a different order from i386 - on x86-64. The 32bit emulation code takes care of that. - But you need to use this for 64bit, otherwise your X server - will break. */ - -#ifdef __i386__ -struct mtrr_gentry -{ - unsigned int regnum; /* Register number */ - unsigned long base; /* Base address */ - unsigned int size; /* Size of region */ - unsigned int type; /* Type of region */ -}; - -#else /* __i386__ */ - -struct mtrr_gentry -{ - unsigned long base; /* Base address */ - unsigned int size; /* Size of region */ - unsigned int regnum; /* Register number */ - unsigned int type; /* Type of region */ -}; -#endif /* !__i386__ */ - -/* These are the various ioctls */ -#define MTRRIOC_ADD_ENTRY _IOW(MTRR_IOCTL_BASE, 0, struct mtrr_sentry) -#define MTRRIOC_SET_ENTRY _IOW(MTRR_IOCTL_BASE, 1, struct mtrr_sentry) -#define MTRRIOC_DEL_ENTRY _IOW(MTRR_IOCTL_BASE, 2, struct mtrr_sentry) -#define MTRRIOC_GET_ENTRY _IOWR(MTRR_IOCTL_BASE, 3, struct mtrr_gentry) -#define MTRRIOC_KILL_ENTRY _IOW(MTRR_IOCTL_BASE, 4, struct mtrr_sentry) -#define MTRRIOC_ADD_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 5, struct mtrr_sentry) -#define MTRRIOC_SET_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 6, struct mtrr_sentry) -#define MTRRIOC_DEL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 7, struct mtrr_sentry) -#define MTRRIOC_GET_PAGE_ENTRY _IOWR(MTRR_IOCTL_BASE, 8, struct mtrr_gentry) -#define MTRRIOC_KILL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 9, struct mtrr_sentry) - -/* These are the region types */ -#define MTRR_TYPE_UNCACHABLE 0 -#define MTRR_TYPE_WRCOMB 1 -/*#define MTRR_TYPE_ 2*/ -/*#define MTRR_TYPE_ 3*/ -#define MTRR_TYPE_WRTHROUGH 4 -#define MTRR_TYPE_WRPROT 5 -#define MTRR_TYPE_WRBACK 6 -#define MTRR_NUM_TYPES 7 - #ifdef __KERNEL__ - -/* The following functions are for use by other drivers */ -# ifdef CONFIG_MTRR -extern void mtrr_save_fixed_ranges(void *); -extern void mtrr_save_state(void); -extern int mtrr_add (unsigned long base, unsigned long size, - unsigned int type, char increment); -extern int mtrr_add_page (unsigned long base, unsigned long size, - unsigned int type, char increment); -extern int mtrr_del (int reg, unsigned long base, unsigned long size); -extern int mtrr_del_page (int reg, unsigned long base, unsigned long size); -extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi); -extern void mtrr_ap_init(void); -extern void mtrr_bp_init(void); -# else -#define mtrr_save_fixed_ranges(arg) do {} while (0) -#define mtrr_save_state() do {} while (0) -static __inline__ int mtrr_add (unsigned long base, unsigned long size, - unsigned int type, char increment) -{ - return -ENODEV; -} -static __inline__ int mtrr_add_page (unsigned long base, unsigned long size, - unsigned int type, char increment) -{ - return -ENODEV; -} -static __inline__ int mtrr_del (int reg, unsigned long base, - unsigned long size) -{ - return -ENODEV; -} -static __inline__ int mtrr_del_page (int reg, unsigned long base, - unsigned long size) -{ - return -ENODEV; -} - -static __inline__ void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi) {;} - -#define mtrr_ap_init() do {} while (0) -#define mtrr_bp_init() do {} while (0) -# endif - -#ifdef CONFIG_COMPAT -#include - -struct mtrr_sentry32 -{ - compat_ulong_t base; /* Base address */ - compat_uint_t size; /* Size of region */ - compat_uint_t type; /* Type of region */ -}; - -struct mtrr_gentry32 -{ - compat_ulong_t regnum; /* Register number */ - compat_uint_t base; /* Base address */ - compat_uint_t size; /* Size of region */ - compat_uint_t type; /* Type of region */ -}; - -#define MTRR_IOCTL_BASE 'M' - -#define MTRRIOC32_ADD_ENTRY _IOW(MTRR_IOCTL_BASE, 0, struct mtrr_sentry32) -#define MTRRIOC32_SET_ENTRY _IOW(MTRR_IOCTL_BASE, 1, struct mtrr_sentry32) -#define MTRRIOC32_DEL_ENTRY _IOW(MTRR_IOCTL_BASE, 2, struct mtrr_sentry32) -#define MTRRIOC32_GET_ENTRY _IOWR(MTRR_IOCTL_BASE, 3, struct mtrr_gentry32) -#define MTRRIOC32_KILL_ENTRY _IOW(MTRR_IOCTL_BASE, 4, struct mtrr_sentry32) -#define MTRRIOC32_ADD_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 5, struct mtrr_sentry32) -#define MTRRIOC32_SET_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 6, struct mtrr_sentry32) -#define MTRRIOC32_DEL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 7, struct mtrr_sentry32) -#define MTRRIOC32_GET_PAGE_ENTRY _IOWR(MTRR_IOCTL_BASE, 8, struct mtrr_gentry32) -#define MTRRIOC32_KILL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 9, struct mtrr_sentry32) -#endif /* CONFIG_COMPAT */ - -#endif /* __KERNEL__ */ - -#endif /* _ASM_X86_MTRR_H */ +# ifdef CONFIG_X86_32 +# include "mtrr_32.h" +# else +# include "mtrr_64.h" +# endif +#else +# ifdef __i386__ +# include "mtrr_32.h" +# else +# include "mtrr_64.h" +# endif +#endif diff --git a/trunk/include/asm-x86/mtrr_32.h b/trunk/include/asm-x86/mtrr_32.h new file mode 100644 index 000000000000..7e9c7ccbdcfe --- /dev/null +++ b/trunk/include/asm-x86/mtrr_32.h @@ -0,0 +1,115 @@ +/* Generic MTRR (Memory Type Range Register) ioctls. + + Copyright (C) 1997-1999 Richard Gooch + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + Richard Gooch may be reached by email at rgooch@atnf.csiro.au + The postal address is: + Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia. +*/ +#ifndef _LINUX_MTRR_H +#define _LINUX_MTRR_H + +#include +#include + +#define MTRR_IOCTL_BASE 'M' + +struct mtrr_sentry +{ + unsigned long base; /* Base address */ + unsigned int size; /* Size of region */ + unsigned int type; /* Type of region */ +}; + +struct mtrr_gentry +{ + unsigned int regnum; /* Register number */ + unsigned long base; /* Base address */ + unsigned int size; /* Size of region */ + unsigned int type; /* Type of region */ +}; + +/* These are the various ioctls */ +#define MTRRIOC_ADD_ENTRY _IOW(MTRR_IOCTL_BASE, 0, struct mtrr_sentry) +#define MTRRIOC_SET_ENTRY _IOW(MTRR_IOCTL_BASE, 1, struct mtrr_sentry) +#define MTRRIOC_DEL_ENTRY _IOW(MTRR_IOCTL_BASE, 2, struct mtrr_sentry) +#define MTRRIOC_GET_ENTRY _IOWR(MTRR_IOCTL_BASE, 3, struct mtrr_gentry) +#define MTRRIOC_KILL_ENTRY _IOW(MTRR_IOCTL_BASE, 4, struct mtrr_sentry) +#define MTRRIOC_ADD_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 5, struct mtrr_sentry) +#define MTRRIOC_SET_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 6, struct mtrr_sentry) +#define MTRRIOC_DEL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 7, struct mtrr_sentry) +#define MTRRIOC_GET_PAGE_ENTRY _IOWR(MTRR_IOCTL_BASE, 8, struct mtrr_gentry) +#define MTRRIOC_KILL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 9, struct mtrr_sentry) + +/* These are the region types */ +#define MTRR_TYPE_UNCACHABLE 0 +#define MTRR_TYPE_WRCOMB 1 +/*#define MTRR_TYPE_ 2*/ +/*#define MTRR_TYPE_ 3*/ +#define MTRR_TYPE_WRTHROUGH 4 +#define MTRR_TYPE_WRPROT 5 +#define MTRR_TYPE_WRBACK 6 +#define MTRR_NUM_TYPES 7 + +#ifdef __KERNEL__ + +/* The following functions are for use by other drivers */ +# ifdef CONFIG_MTRR +extern void mtrr_save_fixed_ranges(void *); +extern void mtrr_save_state(void); +extern int mtrr_add (unsigned long base, unsigned long size, + unsigned int type, char increment); +extern int mtrr_add_page (unsigned long base, unsigned long size, + unsigned int type, char increment); +extern int mtrr_del (int reg, unsigned long base, unsigned long size); +extern int mtrr_del_page (int reg, unsigned long base, unsigned long size); +extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi); +extern void mtrr_ap_init(void); +extern void mtrr_bp_init(void); +# else +#define mtrr_save_fixed_ranges(arg) do {} while (0) +#define mtrr_save_state() do {} while (0) +static __inline__ int mtrr_add (unsigned long base, unsigned long size, + unsigned int type, char increment) +{ + return -ENODEV; +} +static __inline__ int mtrr_add_page (unsigned long base, unsigned long size, + unsigned int type, char increment) +{ + return -ENODEV; +} +static __inline__ int mtrr_del (int reg, unsigned long base, + unsigned long size) +{ + return -ENODEV; +} +static __inline__ int mtrr_del_page (int reg, unsigned long base, + unsigned long size) +{ + return -ENODEV; +} + +static __inline__ void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi) {;} + +#define mtrr_ap_init() do {} while (0) +#define mtrr_bp_init() do {} while (0) +# endif + +#endif + +#endif /* _LINUX_MTRR_H */ diff --git a/trunk/include/asm-x86/mtrr_64.h b/trunk/include/asm-x86/mtrr_64.h new file mode 100644 index 000000000000..b557c486bef8 --- /dev/null +++ b/trunk/include/asm-x86/mtrr_64.h @@ -0,0 +1,152 @@ +/* Generic MTRR (Memory Type Range Register) ioctls. + + Copyright (C) 1997-1999 Richard Gooch + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + Richard Gooch may be reached by email at rgooch@atnf.csiro.au + The postal address is: + Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia. +*/ +#ifndef _LINUX_MTRR_H +#define _LINUX_MTRR_H + +#include + +#define MTRR_IOCTL_BASE 'M' + +struct mtrr_sentry +{ + unsigned long base; /* Base address */ + unsigned int size; /* Size of region */ + unsigned int type; /* Type of region */ +}; + +/* Warning: this structure has a different order from i386 + on x86-64. The 32bit emulation code takes care of that. + But you need to use this for 64bit, otherwise your X server + will break. */ +struct mtrr_gentry +{ + unsigned long base; /* Base address */ + unsigned int size; /* Size of region */ + unsigned int regnum; /* Register number */ + unsigned int type; /* Type of region */ +}; + +/* These are the various ioctls */ +#define MTRRIOC_ADD_ENTRY _IOW(MTRR_IOCTL_BASE, 0, struct mtrr_sentry) +#define MTRRIOC_SET_ENTRY _IOW(MTRR_IOCTL_BASE, 1, struct mtrr_sentry) +#define MTRRIOC_DEL_ENTRY _IOW(MTRR_IOCTL_BASE, 2, struct mtrr_sentry) +#define MTRRIOC_GET_ENTRY _IOWR(MTRR_IOCTL_BASE, 3, struct mtrr_gentry) +#define MTRRIOC_KILL_ENTRY _IOW(MTRR_IOCTL_BASE, 4, struct mtrr_sentry) +#define MTRRIOC_ADD_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 5, struct mtrr_sentry) +#define MTRRIOC_SET_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 6, struct mtrr_sentry) +#define MTRRIOC_DEL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 7, struct mtrr_sentry) +#define MTRRIOC_GET_PAGE_ENTRY _IOWR(MTRR_IOCTL_BASE, 8, struct mtrr_gentry) +#define MTRRIOC_KILL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 9, struct mtrr_sentry) + +/* These are the region types */ +#define MTRR_TYPE_UNCACHABLE 0 +#define MTRR_TYPE_WRCOMB 1 +/*#define MTRR_TYPE_ 2*/ +/*#define MTRR_TYPE_ 3*/ +#define MTRR_TYPE_WRTHROUGH 4 +#define MTRR_TYPE_WRPROT 5 +#define MTRR_TYPE_WRBACK 6 +#define MTRR_NUM_TYPES 7 + +#ifdef __KERNEL__ + +/* The following functions are for use by other drivers */ +# ifdef CONFIG_MTRR +extern int mtrr_add (unsigned long base, unsigned long size, + unsigned int type, char increment); +extern int mtrr_add_page (unsigned long base, unsigned long size, + unsigned int type, char increment); +extern int mtrr_del (int reg, unsigned long base, unsigned long size); +extern int mtrr_del_page (int reg, unsigned long base, unsigned long size); +# else +static __inline__ int mtrr_add (unsigned long base, unsigned long size, + unsigned int type, char increment) +{ + return -ENODEV; +} +static __inline__ int mtrr_add_page (unsigned long base, unsigned long size, + unsigned int type, char increment) +{ + return -ENODEV; +} +static __inline__ int mtrr_del (int reg, unsigned long base, + unsigned long size) +{ + return -ENODEV; +} +static __inline__ int mtrr_del_page (int reg, unsigned long base, + unsigned long size) +{ + return -ENODEV; +} + +#endif /* CONFIG_MTRR */ + +#ifdef CONFIG_COMPAT +#include + +struct mtrr_sentry32 +{ + compat_ulong_t base; /* Base address */ + compat_uint_t size; /* Size of region */ + compat_uint_t type; /* Type of region */ +}; + +struct mtrr_gentry32 +{ + compat_ulong_t regnum; /* Register number */ + compat_uint_t base; /* Base address */ + compat_uint_t size; /* Size of region */ + compat_uint_t type; /* Type of region */ +}; + +#define MTRR_IOCTL_BASE 'M' + +#define MTRRIOC32_ADD_ENTRY _IOW(MTRR_IOCTL_BASE, 0, struct mtrr_sentry32) +#define MTRRIOC32_SET_ENTRY _IOW(MTRR_IOCTL_BASE, 1, struct mtrr_sentry32) +#define MTRRIOC32_DEL_ENTRY _IOW(MTRR_IOCTL_BASE, 2, struct mtrr_sentry32) +#define MTRRIOC32_GET_ENTRY _IOWR(MTRR_IOCTL_BASE, 3, struct mtrr_gentry32) +#define MTRRIOC32_KILL_ENTRY _IOW(MTRR_IOCTL_BASE, 4, struct mtrr_sentry32) +#define MTRRIOC32_ADD_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 5, struct mtrr_sentry32) +#define MTRRIOC32_SET_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 6, struct mtrr_sentry32) +#define MTRRIOC32_DEL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 7, struct mtrr_sentry32) +#define MTRRIOC32_GET_PAGE_ENTRY _IOWR(MTRR_IOCTL_BASE, 8, struct mtrr_gentry32) +#define MTRRIOC32_KILL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 9, struct mtrr_sentry32) + +#endif /* CONFIG_COMPAT */ + +#ifdef CONFIG_MTRR +extern void mtrr_ap_init(void); +extern void mtrr_bp_init(void); +extern void mtrr_save_fixed_ranges(void *); +extern void mtrr_save_state(void); +#else +#define mtrr_ap_init() do {} while (0) +#define mtrr_bp_init() do {} while (0) +#define mtrr_save_fixed_ranges(arg) do {} while (0) +#define mtrr_save_state() do {} while (0) +#endif + +#endif /* __KERNEL__ */ + +#endif /* _LINUX_MTRR_H */ diff --git a/trunk/include/asm-x86/pci_64.h b/trunk/include/asm-x86/pci_64.h index ef54226a9325..9baa46d9f594 100644 --- a/trunk/include/asm-x86/pci_64.h +++ b/trunk/include/asm-x86/pci_64.h @@ -37,7 +37,7 @@ extern int iommu_setup(char *opt); */ #define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys) -#if defined(CONFIG_GART_IOMMU) || defined(CONFIG_CALGARY_IOMMU) +#if defined(CONFIG_IOMMU) || defined(CONFIG_CALGARY_IOMMU) #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \ dma_addr_t ADDR_NAME; diff --git a/trunk/include/asm-x86/ptrace.h b/trunk/include/asm-x86/ptrace.h index 213c97300cb3..bc4d64a87689 100644 --- a/trunk/include/asm-x86/ptrace.h +++ b/trunk/include/asm-x86/ptrace.h @@ -1,142 +1,13 @@ -#ifndef _ASM_X86_PTRACE_H -#define _ASM_X86_PTRACE_H - -#include /* For __user */ -#include - -#ifndef __ASSEMBLY__ - -#ifdef __i386__ -/* this struct defines the way the registers are stored on the - stack during a system call. */ - -struct pt_regs { - long ebx; - long ecx; - long edx; - long esi; - long edi; - long ebp; - long eax; - int xds; - int xes; - int xfs; - /* int xgs; */ - long orig_eax; - long eip; - int xcs; - long eflags; - long esp; - int xss; -}; - #ifdef __KERNEL__ - -#include -#include - -struct task_struct; -extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code); - -/* - * user_mode_vm(regs) determines whether a register set came from user mode. - * This is true if V8086 mode was enabled OR if the register set was from - * protected mode with RPL-3 CS value. This tricky test checks that with - * one comparison. Many places in the kernel can bypass this full check - * if they have already ruled out V8086 mode, so user_mode(regs) can be used. - */ -static inline int user_mode(struct pt_regs *regs) -{ - return (regs->xcs & SEGMENT_RPL_MASK) == USER_RPL; -} -static inline int user_mode_vm(struct pt_regs *regs) -{ - return ((regs->xcs & SEGMENT_RPL_MASK) | (regs->eflags & VM_MASK)) >= USER_RPL; -} -static inline int v8086_mode(struct pt_regs *regs) -{ - return (regs->eflags & VM_MASK); -} - -#define instruction_pointer(regs) ((regs)->eip) -#define frame_pointer(regs) ((regs)->ebp) -#define stack_pointer(regs) ((regs)->esp) -#define regs_return_value(regs) ((regs)->eax) - -extern unsigned long profile_pc(struct pt_regs *regs); -#endif /* __KERNEL__ */ - -#else /* __i386__ */ - -struct pt_regs { - unsigned long r15; - unsigned long r14; - unsigned long r13; - unsigned long r12; - unsigned long rbp; - unsigned long rbx; -/* arguments: non interrupts/non tracing syscalls only save upto here*/ - unsigned long r11; - unsigned long r10; - unsigned long r9; - unsigned long r8; - unsigned long rax; - unsigned long rcx; - unsigned long rdx; - unsigned long rsi; - unsigned long rdi; - unsigned long orig_rax; -/* end of arguments */ -/* cpu exception frame or undefined */ - unsigned long rip; - unsigned long cs; - unsigned long eflags; - unsigned long rsp; - unsigned long ss; -/* top of stack page */ -}; - -#ifdef __KERNEL__ - -#define user_mode(regs) (!!((regs)->cs & 3)) -#define user_mode_vm(regs) user_mode(regs) -#define instruction_pointer(regs) ((regs)->rip) -#define frame_pointer(regs) ((regs)->rbp) -#define stack_pointer(regs) ((regs)->rsp) -#define regs_return_value(regs) ((regs)->rax) - -extern unsigned long profile_pc(struct pt_regs *regs); -void signal_fault(struct pt_regs *regs, void __user *frame, char *where); - -struct task_struct; - -extern unsigned long -convert_rip_to_linear(struct task_struct *child, struct pt_regs *regs); - -enum { - EF_CF = 0x00000001, - EF_PF = 0x00000004, - EF_AF = 0x00000010, - EF_ZF = 0x00000040, - EF_SF = 0x00000080, - EF_TF = 0x00000100, - EF_IE = 0x00000200, - EF_DF = 0x00000400, - EF_OF = 0x00000800, - EF_IOPL = 0x00003000, - EF_IOPL_RING0 = 0x00000000, - EF_IOPL_RING1 = 0x00001000, - EF_IOPL_RING2 = 0x00002000, - EF_NT = 0x00004000, /* nested task */ - EF_RF = 0x00010000, /* resume */ - EF_VM = 0x00020000, /* virtual mode */ - EF_AC = 0x00040000, /* alignment */ - EF_VIF = 0x00080000, /* virtual interrupt */ - EF_VIP = 0x00100000, /* virtual interrupt pending */ - EF_ID = 0x00200000, /* id */ -}; -#endif /* __KERNEL__ */ -#endif /* !__i386__ */ -#endif /* !__ASSEMBLY__ */ - +# ifdef CONFIG_X86_32 +# include "ptrace_32.h" +# else +# include "ptrace_64.h" +# endif +#else +# ifdef __i386__ +# include "ptrace_32.h" +# else +# include "ptrace_64.h" +# endif #endif diff --git a/trunk/include/asm-x86/ptrace_32.h b/trunk/include/asm-x86/ptrace_32.h new file mode 100644 index 000000000000..78d063dabe0a --- /dev/null +++ b/trunk/include/asm-x86/ptrace_32.h @@ -0,0 +1,65 @@ +#ifndef _I386_PTRACE_H +#define _I386_PTRACE_H + +#include + +/* this struct defines the way the registers are stored on the + stack during a system call. */ + +struct pt_regs { + long ebx; + long ecx; + long edx; + long esi; + long edi; + long ebp; + long eax; + int xds; + int xes; + int xfs; + /* int xgs; */ + long orig_eax; + long eip; + int xcs; + long eflags; + long esp; + int xss; +}; + +#ifdef __KERNEL__ + +#include +#include + +struct task_struct; +extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code); + +/* + * user_mode_vm(regs) determines whether a register set came from user mode. + * This is true if V8086 mode was enabled OR if the register set was from + * protected mode with RPL-3 CS value. This tricky test checks that with + * one comparison. Many places in the kernel can bypass this full check + * if they have already ruled out V8086 mode, so user_mode(regs) can be used. + */ +static inline int user_mode(struct pt_regs *regs) +{ + return (regs->xcs & SEGMENT_RPL_MASK) == USER_RPL; +} +static inline int user_mode_vm(struct pt_regs *regs) +{ + return ((regs->xcs & SEGMENT_RPL_MASK) | (regs->eflags & VM_MASK)) >= USER_RPL; +} +static inline int v8086_mode(struct pt_regs *regs) +{ + return (regs->eflags & VM_MASK); +} + +#define instruction_pointer(regs) ((regs)->eip) +#define frame_pointer(regs) ((regs)->ebp) +#define stack_pointer(regs) ((regs)->esp) +#define regs_return_value(regs) ((regs)->eax) + +extern unsigned long profile_pc(struct pt_regs *regs); +#endif /* __KERNEL__ */ + +#endif diff --git a/trunk/include/asm-x86/ptrace_64.h b/trunk/include/asm-x86/ptrace_64.h new file mode 100644 index 000000000000..7bfe61e1b705 --- /dev/null +++ b/trunk/include/asm-x86/ptrace_64.h @@ -0,0 +1,80 @@ +#ifndef _X86_64_PTRACE_H +#define _X86_64_PTRACE_H + +#include /* For __user */ +#include + +#ifndef __ASSEMBLY__ + +struct pt_regs { + unsigned long r15; + unsigned long r14; + unsigned long r13; + unsigned long r12; + unsigned long rbp; + unsigned long rbx; +/* arguments: non interrupts/non tracing syscalls only save upto here*/ + unsigned long r11; + unsigned long r10; + unsigned long r9; + unsigned long r8; + unsigned long rax; + unsigned long rcx; + unsigned long rdx; + unsigned long rsi; + unsigned long rdi; + unsigned long orig_rax; +/* end of arguments */ +/* cpu exception frame or undefined */ + unsigned long rip; + unsigned long cs; + unsigned long eflags; + unsigned long rsp; + unsigned long ss; +/* top of stack page */ +}; + +#endif + +#if defined(__KERNEL__) && !defined(__ASSEMBLY__) +#define user_mode(regs) (!!((regs)->cs & 3)) +#define user_mode_vm(regs) user_mode(regs) +#define instruction_pointer(regs) ((regs)->rip) +#define frame_pointer(regs) ((regs)->rbp) +#define stack_pointer(regs) ((regs)->rsp) +#define regs_return_value(regs) ((regs)->rax) + +extern unsigned long profile_pc(struct pt_regs *regs); +void signal_fault(struct pt_regs *regs, void __user *frame, char *where); + +struct task_struct; + +extern unsigned long +convert_rip_to_linear(struct task_struct *child, struct pt_regs *regs); + +enum { + EF_CF = 0x00000001, + EF_PF = 0x00000004, + EF_AF = 0x00000010, + EF_ZF = 0x00000040, + EF_SF = 0x00000080, + EF_TF = 0x00000100, + EF_IE = 0x00000200, + EF_DF = 0x00000400, + EF_OF = 0x00000800, + EF_IOPL = 0x00003000, + EF_IOPL_RING0 = 0x00000000, + EF_IOPL_RING1 = 0x00001000, + EF_IOPL_RING2 = 0x00002000, + EF_NT = 0x00004000, /* nested task */ + EF_RF = 0x00010000, /* resume */ + EF_VM = 0x00020000, /* virtual mode */ + EF_AC = 0x00040000, /* alignment */ + EF_VIF = 0x00080000, /* virtual interrupt */ + EF_VIP = 0x00100000, /* virtual interrupt pending */ + EF_ID = 0x00200000, /* id */ +}; + +#endif + +#endif diff --git a/trunk/include/asm-x86/required-features.h b/trunk/include/asm-x86/required-features.h index 7400d3ad75c6..8b64f3ea2b78 100644 --- a/trunk/include/asm-x86/required-features.h +++ b/trunk/include/asm-x86/required-features.h @@ -1,72 +1,5 @@ -#ifndef _ASM_REQUIRED_FEATURES_H -#define _ASM_REQUIRED_FEATURES_H 1 - -/* Define minimum CPUID feature set for kernel These bits are checked - really early to actually display a visible error message before the - kernel dies. Make sure to assign features to the proper mask! - - Some requirements that are not in CPUID yet are also in the - CONFIG_X86_MINIMUM_CPU_FAMILY which is checked too. - - The real information is in arch/x86/Kconfig.cpu, this just converts - the CONFIGs into a bitmask */ - -#ifndef CONFIG_MATH_EMULATION -# define NEED_FPU (1<<(X86_FEATURE_FPU & 31)) +#ifdef CONFIG_X86_32 +# include "required-features_32.h" #else -# define NEED_FPU 0 -#endif - -#if defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64) -# define NEED_PAE (1<<(X86_FEATURE_PAE & 31)) -# define NEED_CX8 (1<<(X86_FEATURE_CX8 & 31)) -#else -# define NEED_PAE 0 -# define NEED_CX8 0 -#endif - -#if defined(CONFIG_X86_CMOV) || defined(CONFIG_X86_64) -# define NEED_CMOV (1<<(X86_FEATURE_CMOV & 31)) -#else -# define NEED_CMOV 0 -#endif - -#ifdef CONFIG_X86_USE_3DNOW -# define NEED_3DNOW (1<<(X86_FEATURE_3DNOW & 31)) -#else -# define NEED_3DNOW 0 -#endif - -#ifdef CONFIG_X86_64 -#define NEED_PSE (1<<(X86_FEATURE_PSE & 31)) -#define NEED_MSR (1<<(X86_FEATURE_MSR & 31)) -#define NEED_PGE (1<<(X86_FEATURE_PGE & 31)) -#define NEED_FXSR (1<<(X86_FEATURE_FXSR & 31)) -#define NEED_XMM (1<<(X86_FEATURE_XMM & 31)) -#define NEED_XMM2 (1<<(X86_FEATURE_XMM2 & 31)) -#define NEED_LM (1<<(X86_FEATURE_LM & 31)) -#else -#define NEED_PSE 0 -#define NEED_MSR 0 -#define NEED_PGE 0 -#define NEED_FXSR 0 -#define NEED_XMM 0 -#define NEED_XMM2 0 -#define NEED_LM 0 -#endif - -#define REQUIRED_MASK0 (NEED_FPU|NEED_PSE|NEED_MSR|NEED_PAE|\ - NEED_CX8|NEED_PGE|NEED_FXSR|NEED_CMOV|\ - NEED_XMM|NEED_XMM2) -#define SSE_MASK (NEED_XMM|NEED_XMM2) - -#define REQUIRED_MASK1 (NEED_LM|NEED_3DNOW) - -#define REQUIRED_MASK2 0 -#define REQUIRED_MASK3 0 -#define REQUIRED_MASK4 0 -#define REQUIRED_MASK5 0 -#define REQUIRED_MASK6 0 -#define REQUIRED_MASK7 0 - +# include "required-features_64.h" #endif diff --git a/trunk/include/asm-x86/required-features_32.h b/trunk/include/asm-x86/required-features_32.h new file mode 100644 index 000000000000..618feb98f9f5 --- /dev/null +++ b/trunk/include/asm-x86/required-features_32.h @@ -0,0 +1,55 @@ +#ifndef _ASM_REQUIRED_FEATURES_H +#define _ASM_REQUIRED_FEATURES_H 1 + +/* Define minimum CPUID feature set for kernel These bits are checked + really early to actually display a visible error message before the + kernel dies. Make sure to assign features to the proper mask! + + Some requirements that are not in CPUID yet are also in the + CONFIG_X86_MINIMUM_CPU_FAMILY which is checked too. + + The real information is in arch/i386/Kconfig.cpu, this just converts + the CONFIGs into a bitmask */ + +#ifndef CONFIG_MATH_EMULATION +# define NEED_FPU (1<<(X86_FEATURE_FPU & 31)) +#else +# define NEED_FPU 0 +#endif + +#ifdef CONFIG_X86_PAE +# define NEED_PAE (1<<(X86_FEATURE_PAE & 31)) +#else +# define NEED_PAE 0 +#endif + +#ifdef CONFIG_X86_CMOV +# define NEED_CMOV (1<<(X86_FEATURE_CMOV & 31)) +#else +# define NEED_CMOV 0 +#endif + +#ifdef CONFIG_X86_PAE +# define NEED_CX8 (1<<(X86_FEATURE_CX8 & 31)) +#else +# define NEED_CX8 0 +#endif + +#define REQUIRED_MASK0 (NEED_FPU|NEED_PAE|NEED_CMOV|NEED_CX8) + +#ifdef CONFIG_X86_USE_3DNOW +# define NEED_3DNOW (1<<(X86_FEATURE_3DNOW & 31)) +#else +# define NEED_3DNOW 0 +#endif + +#define REQUIRED_MASK1 (NEED_3DNOW) + +#define REQUIRED_MASK2 0 +#define REQUIRED_MASK3 0 +#define REQUIRED_MASK4 0 +#define REQUIRED_MASK5 0 +#define REQUIRED_MASK6 0 +#define REQUIRED_MASK7 0 + +#endif diff --git a/trunk/include/asm-x86/required-features_64.h b/trunk/include/asm-x86/required-features_64.h new file mode 100644 index 000000000000..e80d5761b00a --- /dev/null +++ b/trunk/include/asm-x86/required-features_64.h @@ -0,0 +1,46 @@ +#ifndef _ASM_REQUIRED_FEATURES_H +#define _ASM_REQUIRED_FEATURES_H 1 + +/* Define minimum CPUID feature set for kernel These bits are checked + really early to actually display a visible error message before the + kernel dies. Make sure to assign features to the proper mask! + + The real information is in arch/x86_64/Kconfig.cpu, this just converts + the CONFIGs into a bitmask */ + +/* x86-64 baseline features */ +#define NEED_FPU (1<<(X86_FEATURE_FPU & 31)) +#define NEED_PSE (1<<(X86_FEATURE_PSE & 31)) +#define NEED_MSR (1<<(X86_FEATURE_MSR & 31)) +#define NEED_PAE (1<<(X86_FEATURE_PAE & 31)) +#define NEED_CX8 (1<<(X86_FEATURE_CX8 & 31)) +#define NEED_PGE (1<<(X86_FEATURE_PGE & 31)) +#define NEED_FXSR (1<<(X86_FEATURE_FXSR & 31)) +#define NEED_CMOV (1<<(X86_FEATURE_CMOV & 31)) +#define NEED_XMM (1<<(X86_FEATURE_XMM & 31)) +#define NEED_XMM2 (1<<(X86_FEATURE_XMM2 & 31)) + +#define REQUIRED_MASK0 (NEED_FPU|NEED_PSE|NEED_MSR|NEED_PAE|\ + NEED_CX8|NEED_PGE|NEED_FXSR|NEED_CMOV|\ + NEED_XMM|NEED_XMM2) +#define SSE_MASK (NEED_XMM|NEED_XMM2) + +/* x86-64 baseline features */ +#define NEED_LM (1<<(X86_FEATURE_LM & 31)) + +#ifdef CONFIG_X86_USE_3DNOW +# define NEED_3DNOW (1<<(X86_FEATURE_3DNOW & 31)) +#else +# define NEED_3DNOW 0 +#endif + +#define REQUIRED_MASK1 (NEED_LM|NEED_3DNOW) + +#define REQUIRED_MASK2 0 +#define REQUIRED_MASK3 0 +#define REQUIRED_MASK4 0 +#define REQUIRED_MASK5 0 +#define REQUIRED_MASK6 0 +#define REQUIRED_MASK7 0 + +#endif diff --git a/trunk/include/asm-x86/setup.h b/trunk/include/asm-x86/setup.h index 24d786e07b49..81c0d98bb1c8 100644 --- a/trunk/include/asm-x86/setup.h +++ b/trunk/include/asm-x86/setup.h @@ -1,63 +1,13 @@ -#ifndef _ASM_X86_SETUP_H -#define _ASM_X86_SETUP_H - -#define COMMAND_LINE_SIZE 2048 - #ifdef __KERNEL__ - -#ifdef __i386__ - -#include -/* - * Reserved space for vmalloc and iomap - defined in asm/page.h - */ -#define MAXMEM_PFN PFN_DOWN(MAXMEM) -#define MAX_NONPAE_PFN (1 << 20) - -#endif /* __i386__ */ - -#define PARAM_SIZE 4096 /* sizeof(struct boot_params) */ - -#define OLD_CL_MAGIC 0xA33F -#define OLD_CL_ADDRESS 0x020 /* Relative to real mode data */ -#define NEW_CL_POINTER 0x228 /* Relative to real mode data */ - -#ifndef __ASSEMBLY__ -#include - -#ifndef _SETUP - -/* - * This is set up by the setup-routine at boot-time - */ -extern struct boot_params boot_params; - -#ifdef __i386__ -/* - * Do NOT EVER look at the BIOS memory size location. - * It does not work on many machines. - */ -#define LOWMEMSIZE() (0x9f000) - -struct e820entry; - -char * __init machine_specific_memory_setup(void); -char *memory_setup(void); - -int __init copy_e820_map(struct e820entry * biosmap, int nr_map); -int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map); -void __init add_memory_region(unsigned long long start, - unsigned long long size, int type); - -extern unsigned long init_pg_tables_end; - -#ifndef CONFIG_PARAVIRT -#define paravirt_post_allocator_init() do {} while (0) +# ifdef CONFIG_X86_32 +# include "setup_32.h" +# else +# include "setup_64.h" +# endif +#else +# ifdef __i386__ +# include "setup_32.h" +# else +# include "setup_64.h" +# endif #endif - -#endif /* __i386__ */ -#endif /* _SETUP */ -#endif /* __ASSEMBLY__ */ -#endif /* __KERNEL__ */ - -#endif /* _ASM_X86_SETUP_H */ diff --git a/trunk/include/asm-x86/setup_32.h b/trunk/include/asm-x86/setup_32.h new file mode 100644 index 000000000000..7a57ca8a1793 --- /dev/null +++ b/trunk/include/asm-x86/setup_32.h @@ -0,0 +1,63 @@ +/* + * Just a place holder. We don't want to have to test x86 before + * we include stuff + */ + +#ifndef _i386_SETUP_H +#define _i386_SETUP_H + +#define COMMAND_LINE_SIZE 2048 + +#ifdef __KERNEL__ +#include + +/* + * Reserved space for vmalloc and iomap - defined in asm/page.h + */ +#define MAXMEM_PFN PFN_DOWN(MAXMEM) +#define MAX_NONPAE_PFN (1 << 20) + +#define PARAM_SIZE 4096 + +#define OLD_CL_MAGIC_ADDR 0x90020 +#define OLD_CL_MAGIC 0xA33F +#define OLD_CL_BASE_ADDR 0x90000 +#define OLD_CL_OFFSET 0x90022 +#define NEW_CL_POINTER 0x228 /* Relative to real mode data */ + +#ifndef __ASSEMBLY__ + +#include + +/* + * This is set up by the setup-routine at boot-time + */ +extern struct boot_params boot_params; + +/* + * Do NOT EVER look at the BIOS memory size location. + * It does not work on many machines. + */ +#define LOWMEMSIZE() (0x9f000) + +struct e820entry; + +char * __init machine_specific_memory_setup(void); +char *memory_setup(void); + +int __init copy_e820_map(struct e820entry * biosmap, int nr_map); +int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map); +void __init add_memory_region(unsigned long long start, + unsigned long long size, int type); + +extern unsigned long init_pg_tables_end; + +#ifndef CONFIG_PARAVIRT +#define paravirt_post_allocator_init() do {} while (0) +#endif + +#endif /* __ASSEMBLY__ */ + +#endif /* __KERNEL__ */ + +#endif /* _i386_SETUP_H */ diff --git a/trunk/include/asm-x86/setup_64.h b/trunk/include/asm-x86/setup_64.h new file mode 100644 index 000000000000..a04aadcccf67 --- /dev/null +++ b/trunk/include/asm-x86/setup_64.h @@ -0,0 +1,19 @@ +#ifndef _x8664_SETUP_H +#define _x8664_SETUP_H + +#define COMMAND_LINE_SIZE 2048 + +#ifdef __KERNEL__ + +#ifndef __ASSEMBLY__ +#include + +/* + * This is set up by the setup-routine at boot-time + */ +extern struct boot_params boot_params; + +#endif /* not __ASSEMBLY__ */ +#endif /* __KERNEL__ */ + +#endif diff --git a/trunk/include/asm-x86/shmbuf.h b/trunk/include/asm-x86/shmbuf.h index b51413b74971..e85f1cb11217 100644 --- a/trunk/include/asm-x86/shmbuf.h +++ b/trunk/include/asm-x86/shmbuf.h @@ -1,51 +1,13 @@ -#ifndef _ASM_X86_SHMBUF_H -#define _ASM_X86_SHMBUF_H - -/* - * The shmid64_ds structure for x86 architecture. - * Note extra padding because this structure is passed back and forth - * between kernel and user space. - * - * Pad space on 32 bit is left for: - * - 64-bit time_t to solve y2038 problem - * - 2 miscellaneous 32-bit values - * - * Pad space on 64 bit is left for: - * - 2 miscellaneous 64-bit values - */ - -struct shmid64_ds { - struct ipc64_perm shm_perm; /* operation perms */ - size_t shm_segsz; /* size of segment (bytes) */ - __kernel_time_t shm_atime; /* last attach time */ -#ifdef __i386__ - unsigned long __unused1; +#ifdef __KERNEL__ +# ifdef CONFIG_X86_32 +# include "shmbuf_32.h" +# else +# include "shmbuf_64.h" +# endif +#else +# ifdef __i386__ +# include "shmbuf_32.h" +# else +# include "shmbuf_64.h" +# endif #endif - __kernel_time_t shm_dtime; /* last detach time */ -#ifdef __i386__ - unsigned long __unused2; -#endif - __kernel_time_t shm_ctime; /* last change time */ -#ifdef __i386__ - unsigned long __unused3; -#endif - __kernel_pid_t shm_cpid; /* pid of creator */ - __kernel_pid_t shm_lpid; /* pid of last operator */ - unsigned long shm_nattch; /* no. of current attaches */ - unsigned long __unused4; - unsigned long __unused5; -}; - -struct shminfo64 { - unsigned long shmmax; - unsigned long shmmin; - unsigned long shmmni; - unsigned long shmseg; - unsigned long shmall; - unsigned long __unused1; - unsigned long __unused2; - unsigned long __unused3; - unsigned long __unused4; -}; - -#endif /* _ASM_X86_SHMBUF_H */ diff --git a/trunk/include/asm-x86/shmbuf_32.h b/trunk/include/asm-x86/shmbuf_32.h new file mode 100644 index 000000000000..d1cdc3cb079b --- /dev/null +++ b/trunk/include/asm-x86/shmbuf_32.h @@ -0,0 +1,42 @@ +#ifndef _I386_SHMBUF_H +#define _I386_SHMBUF_H + +/* + * The shmid64_ds structure for i386 architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * Pad space is left for: + * - 64-bit time_t to solve y2038 problem + * - 2 miscellaneous 32-bit values + */ + +struct shmid64_ds { + struct ipc64_perm shm_perm; /* operation perms */ + size_t shm_segsz; /* size of segment (bytes) */ + __kernel_time_t shm_atime; /* last attach time */ + unsigned long __unused1; + __kernel_time_t shm_dtime; /* last detach time */ + unsigned long __unused2; + __kernel_time_t shm_ctime; /* last change time */ + unsigned long __unused3; + __kernel_pid_t shm_cpid; /* pid of creator */ + __kernel_pid_t shm_lpid; /* pid of last operator */ + unsigned long shm_nattch; /* no. of current attaches */ + unsigned long __unused4; + unsigned long __unused5; +}; + +struct shminfo64 { + unsigned long shmmax; + unsigned long shmmin; + unsigned long shmmni; + unsigned long shmseg; + unsigned long shmall; + unsigned long __unused1; + unsigned long __unused2; + unsigned long __unused3; + unsigned long __unused4; +}; + +#endif /* _I386_SHMBUF_H */ diff --git a/trunk/include/asm-x86/shmbuf_64.h b/trunk/include/asm-x86/shmbuf_64.h new file mode 100644 index 000000000000..5a6d6dda7c48 --- /dev/null +++ b/trunk/include/asm-x86/shmbuf_64.h @@ -0,0 +1,38 @@ +#ifndef _X8664_SHMBUF_H +#define _X8664_SHMBUF_H + +/* + * The shmid64_ds structure for x8664 architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * Pad space is left for: + * - 2 miscellaneous 64-bit values + */ + +struct shmid64_ds { + struct ipc64_perm shm_perm; /* operation perms */ + size_t shm_segsz; /* size of segment (bytes) */ + __kernel_time_t shm_atime; /* last attach time */ + __kernel_time_t shm_dtime; /* last detach time */ + __kernel_time_t shm_ctime; /* last change time */ + __kernel_pid_t shm_cpid; /* pid of creator */ + __kernel_pid_t shm_lpid; /* pid of last operator */ + unsigned long shm_nattch; /* no. of current attaches */ + unsigned long __unused4; + unsigned long __unused5; +}; + +struct shminfo64 { + unsigned long shmmax; + unsigned long shmmin; + unsigned long shmmni; + unsigned long shmseg; + unsigned long shmall; + unsigned long __unused1; + unsigned long __unused2; + unsigned long __unused3; + unsigned long __unused4; +}; + +#endif diff --git a/trunk/include/asm-x86/sigcontext.h b/trunk/include/asm-x86/sigcontext.h index c047f9dc3423..0d16ceff1599 100644 --- a/trunk/include/asm-x86/sigcontext.h +++ b/trunk/include/asm-x86/sigcontext.h @@ -1,138 +1,13 @@ -#ifndef _ASM_X86_SIGCONTEXT_H -#define _ASM_X86_SIGCONTEXT_H - -#include -#include - -#ifdef __i386__ -/* - * As documented in the iBCS2 standard.. - * - * The first part of "struct _fpstate" is just the normal i387 - * hardware setup, the extra "status" word is used to save the - * coprocessor status word before entering the handler. - * - * Pentium III FXSR, SSE support - * Gareth Hughes , May 2000 - * - * The FPU state data structure has had to grow to accommodate the - * extended FPU state required by the Streaming SIMD Extensions. - * There is no documented standard to accomplish this at the moment. - */ -struct _fpreg { - unsigned short significand[4]; - unsigned short exponent; -}; - -struct _fpxreg { - unsigned short significand[4]; - unsigned short exponent; - unsigned short padding[3]; -}; - -struct _xmmreg { - unsigned long element[4]; -}; - -struct _fpstate { - /* Regular FPU environment */ - unsigned long cw; - unsigned long sw; - unsigned long tag; - unsigned long ipoff; - unsigned long cssel; - unsigned long dataoff; - unsigned long datasel; - struct _fpreg _st[8]; - unsigned short status; - unsigned short magic; /* 0xffff = regular FPU data only */ - - /* FXSR FPU environment */ - unsigned long _fxsr_env[6]; /* FXSR FPU env is ignored */ - unsigned long mxcsr; - unsigned long reserved; - struct _fpxreg _fxsr_st[8]; /* FXSR FPU reg data is ignored */ - struct _xmmreg _xmm[8]; - unsigned long padding[56]; -}; - -#define X86_FXSR_MAGIC 0x0000 - -struct sigcontext { - unsigned short gs, __gsh; - unsigned short fs, __fsh; - unsigned short es, __esh; - unsigned short ds, __dsh; - unsigned long edi; - unsigned long esi; - unsigned long ebp; - unsigned long esp; - unsigned long ebx; - unsigned long edx; - unsigned long ecx; - unsigned long eax; - unsigned long trapno; - unsigned long err; - unsigned long eip; - unsigned short cs, __csh; - unsigned long eflags; - unsigned long esp_at_signal; - unsigned short ss, __ssh; - struct _fpstate __user * fpstate; - unsigned long oldmask; - unsigned long cr2; -}; - -#else /* __i386__ */ - -/* FXSAVE frame */ -/* Note: reserved1/2 may someday contain valuable data. Always save/restore - them when you change signal frames. */ -struct _fpstate { - __u16 cwd; - __u16 swd; - __u16 twd; /* Note this is not the same as the 32bit/x87/FSAVE twd */ - __u16 fop; - __u64 rip; - __u64 rdp; - __u32 mxcsr; - __u32 mxcsr_mask; - __u32 st_space[32]; /* 8*16 bytes for each FP-reg */ - __u32 xmm_space[64]; /* 16*16 bytes for each XMM-reg */ - __u32 reserved2[24]; -}; - -struct sigcontext { - unsigned long r8; - unsigned long r9; - unsigned long r10; - unsigned long r11; - unsigned long r12; - unsigned long r13; - unsigned long r14; - unsigned long r15; - unsigned long rdi; - unsigned long rsi; - unsigned long rbp; - unsigned long rbx; - unsigned long rdx; - unsigned long rax; - unsigned long rcx; - unsigned long rsp; - unsigned long rip; - unsigned long eflags; /* RFLAGS */ - unsigned short cs; - unsigned short gs; - unsigned short fs; - unsigned short __pad0; - unsigned long err; - unsigned long trapno; - unsigned long oldmask; - unsigned long cr2; - struct _fpstate __user *fpstate; /* zero when no FPU context */ - unsigned long reserved1[8]; -}; - -#endif /* !__i386__ */ - +#ifdef __KERNEL__ +# ifdef CONFIG_X86_32 +# include "sigcontext_32.h" +# else +# include "sigcontext_64.h" +# endif +#else +# ifdef __i386__ +# include "sigcontext_32.h" +# else +# include "sigcontext_64.h" +# endif #endif diff --git a/trunk/include/asm-x86/sigcontext_32.h b/trunk/include/asm-x86/sigcontext_32.h new file mode 100644 index 000000000000..aaef089a7787 --- /dev/null +++ b/trunk/include/asm-x86/sigcontext_32.h @@ -0,0 +1,85 @@ +#ifndef _ASMi386_SIGCONTEXT_H +#define _ASMi386_SIGCONTEXT_H + +#include + +/* + * As documented in the iBCS2 standard.. + * + * The first part of "struct _fpstate" is just the normal i387 + * hardware setup, the extra "status" word is used to save the + * coprocessor status word before entering the handler. + * + * Pentium III FXSR, SSE support + * Gareth Hughes , May 2000 + * + * The FPU state data structure has had to grow to accommodate the + * extended FPU state required by the Streaming SIMD Extensions. + * There is no documented standard to accomplish this at the moment. + */ +struct _fpreg { + unsigned short significand[4]; + unsigned short exponent; +}; + +struct _fpxreg { + unsigned short significand[4]; + unsigned short exponent; + unsigned short padding[3]; +}; + +struct _xmmreg { + unsigned long element[4]; +}; + +struct _fpstate { + /* Regular FPU environment */ + unsigned long cw; + unsigned long sw; + unsigned long tag; + unsigned long ipoff; + unsigned long cssel; + unsigned long dataoff; + unsigned long datasel; + struct _fpreg _st[8]; + unsigned short status; + unsigned short magic; /* 0xffff = regular FPU data only */ + + /* FXSR FPU environment */ + unsigned long _fxsr_env[6]; /* FXSR FPU env is ignored */ + unsigned long mxcsr; + unsigned long reserved; + struct _fpxreg _fxsr_st[8]; /* FXSR FPU reg data is ignored */ + struct _xmmreg _xmm[8]; + unsigned long padding[56]; +}; + +#define X86_FXSR_MAGIC 0x0000 + +struct sigcontext { + unsigned short gs, __gsh; + unsigned short fs, __fsh; + unsigned short es, __esh; + unsigned short ds, __dsh; + unsigned long edi; + unsigned long esi; + unsigned long ebp; + unsigned long esp; + unsigned long ebx; + unsigned long edx; + unsigned long ecx; + unsigned long eax; + unsigned long trapno; + unsigned long err; + unsigned long eip; + unsigned short cs, __csh; + unsigned long eflags; + unsigned long esp_at_signal; + unsigned short ss, __ssh; + struct _fpstate __user * fpstate; + unsigned long oldmask; + unsigned long cr2; +}; + + +#endif diff --git a/trunk/include/asm-x86/sigcontext_64.h b/trunk/include/asm-x86/sigcontext_64.h new file mode 100644 index 000000000000..b4e40236666c --- /dev/null +++ b/trunk/include/asm-x86/sigcontext_64.h @@ -0,0 +1,55 @@ +#ifndef _ASM_X86_64_SIGCONTEXT_H +#define _ASM_X86_64_SIGCONTEXT_H + +#include +#include + +/* FXSAVE frame */ +/* Note: reserved1/2 may someday contain valuable data. Always save/restore + them when you change signal frames. */ +struct _fpstate { + __u16 cwd; + __u16 swd; + __u16 twd; /* Note this is not the same as the 32bit/x87/FSAVE twd */ + __u16 fop; + __u64 rip; + __u64 rdp; + __u32 mxcsr; + __u32 mxcsr_mask; + __u32 st_space[32]; /* 8*16 bytes for each FP-reg */ + __u32 xmm_space[64]; /* 16*16 bytes for each XMM-reg */ + __u32 reserved2[24]; +}; + +struct sigcontext { + unsigned long r8; + unsigned long r9; + unsigned long r10; + unsigned long r11; + unsigned long r12; + unsigned long r13; + unsigned long r14; + unsigned long r15; + unsigned long rdi; + unsigned long rsi; + unsigned long rbp; + unsigned long rbx; + unsigned long rdx; + unsigned long rax; + unsigned long rcx; + unsigned long rsp; + unsigned long rip; + unsigned long eflags; /* RFLAGS */ + unsigned short cs; + unsigned short gs; + unsigned short fs; + unsigned short __pad0; + unsigned long err; + unsigned long trapno; + unsigned long oldmask; + unsigned long cr2; + struct _fpstate __user *fpstate; /* zero when no FPU context */ + unsigned long reserved1[8]; +}; + +#endif diff --git a/trunk/include/asm-x86/signal.h b/trunk/include/asm-x86/signal.h index 987a422a2c78..bf5a63f457da 100644 --- a/trunk/include/asm-x86/signal.h +++ b/trunk/include/asm-x86/signal.h @@ -1,266 +1,13 @@ -#ifndef _ASM_X86_SIGNAL_H -#define _ASM_X86_SIGNAL_H - -#ifndef __ASSEMBLY__ -#include -#include -#include - -/* Avoid too many header ordering problems. */ -struct siginfo; - #ifdef __KERNEL__ -#include - -/* Most things should be clean enough to redefine this at will, if care - is taken to make libc match. */ - -#define _NSIG 64 - -#ifdef __i386__ -# define _NSIG_BPW 32 +# ifdef CONFIG_X86_32 +# include "signal_32.h" +# else +# include "signal_64.h" +# endif #else -# define _NSIG_BPW 64 -#endif - -#define _NSIG_WORDS (_NSIG / _NSIG_BPW) - -typedef unsigned long old_sigset_t; /* at least 32 bits */ - -typedef struct { - unsigned long sig[_NSIG_WORDS]; -} sigset_t; - -#else -/* Here we must cater to libcs that poke about in kernel headers. */ - -#define NSIG 32 -typedef unsigned long sigset_t; - -#endif /* __KERNEL__ */ -#endif /* __ASSEMBLY__ */ - -#define SIGHUP 1 -#define SIGINT 2 -#define SIGQUIT 3 -#define SIGILL 4 -#define SIGTRAP 5 -#define SIGABRT 6 -#define SIGIOT 6 -#define SIGBUS 7 -#define SIGFPE 8 -#define SIGKILL 9 -#define SIGUSR1 10 -#define SIGSEGV 11 -#define SIGUSR2 12 -#define SIGPIPE 13 -#define SIGALRM 14 -#define SIGTERM 15 -#define SIGSTKFLT 16 -#define SIGCHLD 17 -#define SIGCONT 18 -#define SIGSTOP 19 -#define SIGTSTP 20 -#define SIGTTIN 21 -#define SIGTTOU 22 -#define SIGURG 23 -#define SIGXCPU 24 -#define SIGXFSZ 25 -#define SIGVTALRM 26 -#define SIGPROF 27 -#define SIGWINCH 28 -#define SIGIO 29 -#define SIGPOLL SIGIO -/* -#define SIGLOST 29 -*/ -#define SIGPWR 30 -#define SIGSYS 31 -#define SIGUNUSED 31 - -/* These should not be considered constants from userland. */ -#define SIGRTMIN 32 -#define SIGRTMAX _NSIG - -/* - * SA_FLAGS values: - * - * SA_ONSTACK indicates that a registered stack_t will be used. - * SA_RESTART flag to get restarting signals (which were the default long ago) - * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop. - * SA_RESETHAND clears the handler when the signal is delivered. - * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies. - * SA_NODEFER prevents the current signal from being masked in the handler. - * - * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single - * Unix names RESETHAND and NODEFER respectively. - */ -#define SA_NOCLDSTOP 0x00000001u -#define SA_NOCLDWAIT 0x00000002u -#define SA_SIGINFO 0x00000004u -#define SA_ONSTACK 0x08000000u -#define SA_RESTART 0x10000000u -#define SA_NODEFER 0x40000000u -#define SA_RESETHAND 0x80000000u - -#define SA_NOMASK SA_NODEFER -#define SA_ONESHOT SA_RESETHAND - -#define SA_RESTORER 0x04000000 - -/* - * sigaltstack controls - */ -#define SS_ONSTACK 1 -#define SS_DISABLE 2 - -#define MINSIGSTKSZ 2048 -#define SIGSTKSZ 8192 - -#include - -#ifndef __ASSEMBLY__ - -#ifdef __i386__ -# ifdef __KERNEL__ -struct old_sigaction { - __sighandler_t sa_handler; - old_sigset_t sa_mask; - unsigned long sa_flags; - __sigrestore_t sa_restorer; -}; - -struct sigaction { - __sighandler_t sa_handler; - unsigned long sa_flags; - __sigrestore_t sa_restorer; - sigset_t sa_mask; /* mask last for extensibility */ -}; - -struct k_sigaction { - struct sigaction sa; -}; -# else /* __KERNEL__ */ -/* Here we must cater to libcs that poke about in kernel headers. */ - -struct sigaction { - union { - __sighandler_t _sa_handler; - void (*_sa_sigaction)(int, struct siginfo *, void *); - } _u; - sigset_t sa_mask; - unsigned long sa_flags; - void (*sa_restorer)(void); -}; - -#define sa_handler _u._sa_handler -#define sa_sigaction _u._sa_sigaction - -# endif /* ! __KERNEL__ */ -#else /* __i386__ */ - -struct sigaction { - __sighandler_t sa_handler; - unsigned long sa_flags; - __sigrestore_t sa_restorer; - sigset_t sa_mask; /* mask last for extensibility */ -}; - -struct k_sigaction { - struct sigaction sa; -}; - -#endif /* !__i386__ */ - -typedef struct sigaltstack { - void __user *ss_sp; - int ss_flags; - size_t ss_size; -} stack_t; - -#ifdef __KERNEL__ -#include - -#ifdef __386__ - -#define __HAVE_ARCH_SIG_BITOPS - -#define sigaddset(set,sig) \ - (__builtin_constantp(sig) ? \ - __const_sigaddset((set),(sig)) : \ - __gen_sigaddset((set),(sig))) - -static __inline__ void __gen_sigaddset(sigset_t *set, int _sig) -{ - __asm__("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc"); -} - -static __inline__ void __const_sigaddset(sigset_t *set, int _sig) -{ - unsigned long sig = _sig - 1; - set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW); -} - -#define sigdelset(set,sig) \ - (__builtin_constant_p(sig) ? \ - __const_sigdelset((set),(sig)) : \ - __gen_sigdelset((set),(sig))) - - -static __inline__ void __gen_sigdelset(sigset_t *set, int _sig) -{ - __asm__("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc"); -} - -static __inline__ void __const_sigdelset(sigset_t *set, int _sig) -{ - unsigned long sig = _sig - 1; - set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW)); -} - -static __inline__ int __const_sigismember(sigset_t *set, int _sig) -{ - unsigned long sig = _sig - 1; - return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW)); -} - -static __inline__ int __gen_sigismember(sigset_t *set, int _sig) -{ - int ret; - __asm__("btl %2,%1\n\tsbbl %0,%0" - : "=r"(ret) : "m"(*set), "Ir"(_sig-1) : "cc"); - return ret; -} - -#define sigismember(set,sig) \ - (__builtin_constant_p(sig) ? \ - __const_sigismember((set),(sig)) : \ - __gen_sigismember((set),(sig))) - -static __inline__ int sigfindinword(unsigned long word) -{ - __asm__("bsfl %1,%0" : "=r"(word) : "rm"(word) : "cc"); - return word; -} - -struct pt_regs; - -#define ptrace_signal_deliver(regs, cookie) \ - do { \ - if (current->ptrace & PT_DTRACE) { \ - current->ptrace &= ~PT_DTRACE; \ - (regs)->eflags &= ~TF_MASK; \ - } \ - } while (0) - -#else /* __i386__ */ - -#undef __HAVE_ARCH_SIG_BITOPS - -#define ptrace_signal_deliver(regs, cookie) do { } while (0) - -#endif /* !__i386__ */ -#endif /* __KERNEL__ */ -#endif /* __ASSEMBLY__ */ - +# ifdef __i386__ +# include "signal_32.h" +# else +# include "signal_64.h" +# endif #endif diff --git a/trunk/include/asm-x86/signal_32.h b/trunk/include/asm-x86/signal_32.h new file mode 100644 index 000000000000..c3e8adec5918 --- /dev/null +++ b/trunk/include/asm-x86/signal_32.h @@ -0,0 +1,232 @@ +#ifndef _ASMi386_SIGNAL_H +#define _ASMi386_SIGNAL_H + +#include +#include +#include + +/* Avoid too many header ordering problems. */ +struct siginfo; + +#ifdef __KERNEL__ + +#include + +/* Most things should be clean enough to redefine this at will, if care + is taken to make libc match. */ + +#define _NSIG 64 +#define _NSIG_BPW 32 +#define _NSIG_WORDS (_NSIG / _NSIG_BPW) + +typedef unsigned long old_sigset_t; /* at least 32 bits */ + +typedef struct { + unsigned long sig[_NSIG_WORDS]; +} sigset_t; + +#else +/* Here we must cater to libcs that poke about in kernel headers. */ + +#define NSIG 32 +typedef unsigned long sigset_t; + +#endif /* __KERNEL__ */ + +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGABRT 6 +#define SIGIOT 6 +#define SIGBUS 7 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGUSR1 10 +#define SIGSEGV 11 +#define SIGUSR2 12 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGSTKFLT 16 +#define SIGCHLD 17 +#define SIGCONT 18 +#define SIGSTOP 19 +#define SIGTSTP 20 +#define SIGTTIN 21 +#define SIGTTOU 22 +#define SIGURG 23 +#define SIGXCPU 24 +#define SIGXFSZ 25 +#define SIGVTALRM 26 +#define SIGPROF 27 +#define SIGWINCH 28 +#define SIGIO 29 +#define SIGPOLL SIGIO +/* +#define SIGLOST 29 +*/ +#define SIGPWR 30 +#define SIGSYS 31 +#define SIGUNUSED 31 + +/* These should not be considered constants from userland. */ +#define SIGRTMIN 32 +#define SIGRTMAX _NSIG + +/* + * SA_FLAGS values: + * + * SA_ONSTACK indicates that a registered stack_t will be used. + * SA_RESTART flag to get restarting signals (which were the default long ago) + * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop. + * SA_RESETHAND clears the handler when the signal is delivered. + * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies. + * SA_NODEFER prevents the current signal from being masked in the handler. + * + * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single + * Unix names RESETHAND and NODEFER respectively. + */ +#define SA_NOCLDSTOP 0x00000001u +#define SA_NOCLDWAIT 0x00000002u +#define SA_SIGINFO 0x00000004u +#define SA_ONSTACK 0x08000000u +#define SA_RESTART 0x10000000u +#define SA_NODEFER 0x40000000u +#define SA_RESETHAND 0x80000000u + +#define SA_NOMASK SA_NODEFER +#define SA_ONESHOT SA_RESETHAND + +#define SA_RESTORER 0x04000000 + +/* + * sigaltstack controls + */ +#define SS_ONSTACK 1 +#define SS_DISABLE 2 + +#define MINSIGSTKSZ 2048 +#define SIGSTKSZ 8192 + +#include + +#ifdef __KERNEL__ +struct old_sigaction { + __sighandler_t sa_handler; + old_sigset_t sa_mask; + unsigned long sa_flags; + __sigrestore_t sa_restorer; +}; + +struct sigaction { + __sighandler_t sa_handler; + unsigned long sa_flags; + __sigrestore_t sa_restorer; + sigset_t sa_mask; /* mask last for extensibility */ +}; + +struct k_sigaction { + struct sigaction sa; +}; +#else +/* Here we must cater to libcs that poke about in kernel headers. */ + +struct sigaction { + union { + __sighandler_t _sa_handler; + void (*_sa_sigaction)(int, struct siginfo *, void *); + } _u; + sigset_t sa_mask; + unsigned long sa_flags; + void (*sa_restorer)(void); +}; + +#define sa_handler _u._sa_handler +#define sa_sigaction _u._sa_sigaction + +#endif /* __KERNEL__ */ + +typedef struct sigaltstack { + void __user *ss_sp; + int ss_flags; + size_t ss_size; +} stack_t; + +#ifdef __KERNEL__ +#include + +#define __HAVE_ARCH_SIG_BITOPS + +#define sigaddset(set,sig) \ + (__builtin_constant_p(sig) ? \ + __const_sigaddset((set),(sig)) : \ + __gen_sigaddset((set),(sig))) + +static __inline__ void __gen_sigaddset(sigset_t *set, int _sig) +{ + __asm__("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc"); +} + +static __inline__ void __const_sigaddset(sigset_t *set, int _sig) +{ + unsigned long sig = _sig - 1; + set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW); +} + +#define sigdelset(set,sig) \ + (__builtin_constant_p(sig) ? \ + __const_sigdelset((set),(sig)) : \ + __gen_sigdelset((set),(sig))) + + +static __inline__ void __gen_sigdelset(sigset_t *set, int _sig) +{ + __asm__("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc"); +} + +static __inline__ void __const_sigdelset(sigset_t *set, int _sig) +{ + unsigned long sig = _sig - 1; + set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW)); +} + +static __inline__ int __const_sigismember(sigset_t *set, int _sig) +{ + unsigned long sig = _sig - 1; + return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW)); +} + +static __inline__ int __gen_sigismember(sigset_t *set, int _sig) +{ + int ret; + __asm__("btl %2,%1\n\tsbbl %0,%0" + : "=r"(ret) : "m"(*set), "Ir"(_sig-1) : "cc"); + return ret; +} + +#define sigismember(set,sig) \ + (__builtin_constant_p(sig) ? \ + __const_sigismember((set),(sig)) : \ + __gen_sigismember((set),(sig))) + +static __inline__ int sigfindinword(unsigned long word) +{ + __asm__("bsfl %1,%0" : "=r"(word) : "rm"(word) : "cc"); + return word; +} + +struct pt_regs; + +#define ptrace_signal_deliver(regs, cookie) \ + do { \ + if (current->ptrace & PT_DTRACE) { \ + current->ptrace &= ~PT_DTRACE; \ + (regs)->eflags &= ~TF_MASK; \ + } \ + } while (0) + +#endif /* __KERNEL__ */ + +#endif diff --git a/trunk/include/asm-x86/signal_64.h b/trunk/include/asm-x86/signal_64.h new file mode 100644 index 000000000000..4581f978b299 --- /dev/null +++ b/trunk/include/asm-x86/signal_64.h @@ -0,0 +1,181 @@ +#ifndef _ASMx8664_SIGNAL_H +#define _ASMx8664_SIGNAL_H + +#ifndef __ASSEMBLY__ +#include +#include + +/* Avoid too many header ordering problems. */ +struct siginfo; + +#ifdef __KERNEL__ +#include +/* Most things should be clean enough to redefine this at will, if care + is taken to make libc match. */ + +#define _NSIG 64 +#define _NSIG_BPW 64 +#define _NSIG_WORDS (_NSIG / _NSIG_BPW) + +typedef unsigned long old_sigset_t; /* at least 32 bits */ + +typedef struct { + unsigned long sig[_NSIG_WORDS]; +} sigset_t; + + +#else +/* Here we must cater to libcs that poke about in kernel headers. */ + +#define NSIG 32 +typedef unsigned long sigset_t; + +#endif /* __KERNEL__ */ +#endif + +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGABRT 6 +#define SIGIOT 6 +#define SIGBUS 7 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGUSR1 10 +#define SIGSEGV 11 +#define SIGUSR2 12 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGSTKFLT 16 +#define SIGCHLD 17 +#define SIGCONT 18 +#define SIGSTOP 19 +#define SIGTSTP 20 +#define SIGTTIN 21 +#define SIGTTOU 22 +#define SIGURG 23 +#define SIGXCPU 24 +#define SIGXFSZ 25 +#define SIGVTALRM 26 +#define SIGPROF 27 +#define SIGWINCH 28 +#define SIGIO 29 +#define SIGPOLL SIGIO +/* +#define SIGLOST 29 +*/ +#define SIGPWR 30 +#define SIGSYS 31 +#define SIGUNUSED 31 + +/* These should not be considered constants from userland. */ +#define SIGRTMIN 32 +#define SIGRTMAX _NSIG + +/* + * SA_FLAGS values: + * + * SA_ONSTACK indicates that a registered stack_t will be used. + * SA_RESTART flag to get restarting signals (which were the default long ago) + * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop. + * SA_RESETHAND clears the handler when the signal is delivered. + * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies. + * SA_NODEFER prevents the current signal from being masked in the handler. + * + * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single + * Unix names RESETHAND and NODEFER respectively. + */ +#define SA_NOCLDSTOP 0x00000001 +#define SA_NOCLDWAIT 0x00000002 +#define SA_SIGINFO 0x00000004 +#define SA_ONSTACK 0x08000000 +#define SA_RESTART 0x10000000 +#define SA_NODEFER 0x40000000 +#define SA_RESETHAND 0x80000000 + +#define SA_NOMASK SA_NODEFER +#define SA_ONESHOT SA_RESETHAND + +#define SA_RESTORER 0x04000000 + +/* + * sigaltstack controls + */ +#define SS_ONSTACK 1 +#define SS_DISABLE 2 + +#define MINSIGSTKSZ 2048 +#define SIGSTKSZ 8192 + +#include + +#ifndef __ASSEMBLY__ + +struct sigaction { + __sighandler_t sa_handler; + unsigned long sa_flags; + __sigrestore_t sa_restorer; + sigset_t sa_mask; /* mask last for extensibility */ +}; + +struct k_sigaction { + struct sigaction sa; +}; + +typedef struct sigaltstack { + void __user *ss_sp; + int ss_flags; + size_t ss_size; +} stack_t; + +#ifdef __KERNEL__ +#include + +#undef __HAVE_ARCH_SIG_BITOPS +#if 0 + +static inline void sigaddset(sigset_t *set, int _sig) +{ + __asm__("btsq %1,%0" : "=m"(*set) : "Ir"(_sig - 1) : "cc"); +} + +static inline void sigdelset(sigset_t *set, int _sig) +{ + __asm__("btrq %1,%0" : "=m"(*set) : "Ir"(_sig - 1) : "cc"); +} + +static inline int __const_sigismember(sigset_t *set, int _sig) +{ + unsigned long sig = _sig - 1; + return 1 & (set->sig[sig / _NSIG_BPW] >> (sig & ~(_NSIG_BPW-1))); +} + +static inline int __gen_sigismember(sigset_t *set, int _sig) +{ + int ret; + __asm__("btq %2,%1\n\tsbbq %0,%0" + : "=r"(ret) : "m"(*set), "Ir"(_sig-1) : "cc"); + return ret; +} + +#define sigismember(set,sig) \ + (__builtin_constant_p(sig) ? \ + __const_sigismember((set),(sig)) : \ + __gen_sigismember((set),(sig))) + +static inline int sigfindinword(unsigned long word) +{ + __asm__("bsfq %1,%0" : "=r"(word) : "rm"(word) : "cc"); + return word; +} +#endif +#endif + +#define ptrace_signal_deliver(regs, cookie) do { } while (0) + +#endif /* __KERNEL__ */ + +#endif diff --git a/trunk/include/asm-x86/smp_32.h b/trunk/include/asm-x86/smp_32.h index e10b7affdfe5..7056d8684522 100644 --- a/trunk/include/asm-x86/smp_32.h +++ b/trunk/include/asm-x86/smp_32.h @@ -94,12 +94,9 @@ static inline void smp_send_reschedule(int cpu) { smp_ops.smp_send_reschedule(cpu); } -static inline int smp_call_function_mask(cpumask_t mask, - void (*func) (void *info), void *info, - int wait) -{ - return smp_ops.smp_call_function_mask(mask, func, info, wait); -} +extern int smp_call_function_mask(cpumask_t mask, + void (*func) (void *info), void *info, + int wait); void native_smp_prepare_boot_cpu(void); void native_smp_prepare_cpus(unsigned int max_cpus); diff --git a/trunk/include/asm-x86/smp_64.h b/trunk/include/asm-x86/smp_64.h index ab612b0ff270..6f0e0273b646 100644 --- a/trunk/include/asm-x86/smp_64.h +++ b/trunk/include/asm-x86/smp_64.h @@ -76,8 +76,6 @@ extern unsigned __cpuinitdata disabled_cpus; #endif /* CONFIG_SMP */ -#define safe_smp_processor_id() smp_processor_id() - static inline int hard_smp_processor_id(void) { /* we don't want to mark this access volatile - bad code generation */ diff --git a/trunk/include/asm-x86/stat.h b/trunk/include/asm-x86/stat.h index 5c22dcb5d17e..3ff6b50ef833 100644 --- a/trunk/include/asm-x86/stat.h +++ b/trunk/include/asm-x86/stat.h @@ -1,114 +1,13 @@ -#ifndef _ASM_X86_STAT_H -#define _ASM_X86_STAT_H - -#define STAT_HAVE_NSEC 1 - -#ifdef __i386__ -struct stat { - unsigned long st_dev; - unsigned long st_ino; - unsigned short st_mode; - unsigned short st_nlink; - unsigned short st_uid; - unsigned short st_gid; - unsigned long st_rdev; - unsigned long st_size; - unsigned long st_blksize; - unsigned long st_blocks; - unsigned long st_atime; - unsigned long st_atime_nsec; - unsigned long st_mtime; - unsigned long st_mtime_nsec; - unsigned long st_ctime; - unsigned long st_ctime_nsec; - unsigned long __unused4; - unsigned long __unused5; -}; - -#define STAT64_HAS_BROKEN_ST_INO 1 - -/* This matches struct stat64 in glibc2.1, hence the absolutely - * insane amounts of padding around dev_t's. - */ -struct stat64 { - unsigned long long st_dev; - unsigned char __pad0[4]; - - unsigned long __st_ino; - - unsigned int st_mode; - unsigned int st_nlink; - - unsigned long st_uid; - unsigned long st_gid; - - unsigned long long st_rdev; - unsigned char __pad3[4]; - - long long st_size; - unsigned long st_blksize; - - /* Number 512-byte blocks allocated. */ - unsigned long long st_blocks; - - unsigned long st_atime; - unsigned long st_atime_nsec; - - unsigned long st_mtime; - unsigned int st_mtime_nsec; - - unsigned long st_ctime; - unsigned long st_ctime_nsec; - - unsigned long long st_ino; -}; - -#else /* __i386__ */ - -struct stat { - unsigned long st_dev; - unsigned long st_ino; - unsigned long st_nlink; - - unsigned int st_mode; - unsigned int st_uid; - unsigned int st_gid; - unsigned int __pad0; - unsigned long st_rdev; - long st_size; - long st_blksize; - long st_blocks; /* Number 512-byte blocks allocated. */ - - unsigned long st_atime; - unsigned long st_atime_nsec; - unsigned long st_mtime; - unsigned long st_mtime_nsec; - unsigned long st_ctime; - unsigned long st_ctime_nsec; - long __unused[3]; -}; -#endif - -/* for 32bit emulation and 32 bit kernels */ -struct __old_kernel_stat { - unsigned short st_dev; - unsigned short st_ino; - unsigned short st_mode; - unsigned short st_nlink; - unsigned short st_uid; - unsigned short st_gid; - unsigned short st_rdev; -#ifdef __i386__ - unsigned long st_size; - unsigned long st_atime; - unsigned long st_mtime; - unsigned long st_ctime; +#ifdef __KERNEL__ +# ifdef CONFIG_X86_32 +# include "stat_32.h" +# else +# include "stat_64.h" +# endif #else - unsigned int st_size; - unsigned int st_atime; - unsigned int st_mtime; - unsigned int st_ctime; -#endif -}; - +# ifdef __i386__ +# include "stat_32.h" +# else +# include "stat_64.h" +# endif #endif diff --git a/trunk/include/asm-x86/stat_32.h b/trunk/include/asm-x86/stat_32.h new file mode 100644 index 000000000000..67eae78323ba --- /dev/null +++ b/trunk/include/asm-x86/stat_32.h @@ -0,0 +1,77 @@ +#ifndef _I386_STAT_H +#define _I386_STAT_H + +struct __old_kernel_stat { + unsigned short st_dev; + unsigned short st_ino; + unsigned short st_mode; + unsigned short st_nlink; + unsigned short st_uid; + unsigned short st_gid; + unsigned short st_rdev; + unsigned long st_size; + unsigned long st_atime; + unsigned long st_mtime; + unsigned long st_ctime; +}; + +struct stat { + unsigned long st_dev; + unsigned long st_ino; + unsigned short st_mode; + unsigned short st_nlink; + unsigned short st_uid; + unsigned short st_gid; + unsigned long st_rdev; + unsigned long st_size; + unsigned long st_blksize; + unsigned long st_blocks; + unsigned long st_atime; + unsigned long st_atime_nsec; + unsigned long st_mtime; + unsigned long st_mtime_nsec; + unsigned long st_ctime; + unsigned long st_ctime_nsec; + unsigned long __unused4; + unsigned long __unused5; +}; + +/* This matches struct stat64 in glibc2.1, hence the absolutely + * insane amounts of padding around dev_t's. + */ +struct stat64 { + unsigned long long st_dev; + unsigned char __pad0[4]; + +#define STAT64_HAS_BROKEN_ST_INO 1 + unsigned long __st_ino; + + unsigned int st_mode; + unsigned int st_nlink; + + unsigned long st_uid; + unsigned long st_gid; + + unsigned long long st_rdev; + unsigned char __pad3[4]; + + long long st_size; + unsigned long st_blksize; + + unsigned long long st_blocks; /* Number 512-byte blocks allocated. */ + + unsigned long st_atime; + unsigned long st_atime_nsec; + + unsigned long st_mtime; + unsigned int st_mtime_nsec; + + unsigned long st_ctime; + unsigned long st_ctime_nsec; + + unsigned long long st_ino; +}; + +#define STAT_HAVE_NSEC 1 + +#endif diff --git a/trunk/include/asm-x86/stat_64.h b/trunk/include/asm-x86/stat_64.h new file mode 100644 index 000000000000..fd9f00d560f8 --- /dev/null +++ b/trunk/include/asm-x86/stat_64.h @@ -0,0 +1,44 @@ +#ifndef _ASM_X86_64_STAT_H +#define _ASM_X86_64_STAT_H + +#define STAT_HAVE_NSEC 1 + +struct stat { + unsigned long st_dev; + unsigned long st_ino; + unsigned long st_nlink; + + unsigned int st_mode; + unsigned int st_uid; + unsigned int st_gid; + unsigned int __pad0; + unsigned long st_rdev; + long st_size; + long st_blksize; + long st_blocks; /* Number 512-byte blocks allocated. */ + + unsigned long st_atime; + unsigned long st_atime_nsec; + unsigned long st_mtime; + unsigned long st_mtime_nsec; + unsigned long st_ctime; + unsigned long st_ctime_nsec; + long __unused[3]; +}; + +/* For 32bit emulation */ +struct __old_kernel_stat { + unsigned short st_dev; + unsigned short st_ino; + unsigned short st_mode; + unsigned short st_nlink; + unsigned short st_uid; + unsigned short st_gid; + unsigned short st_rdev; + unsigned int st_size; + unsigned int st_atime; + unsigned int st_mtime; + unsigned int st_ctime; +}; + +#endif diff --git a/trunk/include/asm-x86/statfs.h b/trunk/include/asm-x86/statfs.h index 7c651aa97252..327fb5d7a148 100644 --- a/trunk/include/asm-x86/statfs.h +++ b/trunk/include/asm-x86/statfs.h @@ -1,63 +1,13 @@ -#ifndef _ASM_X86_STATFS_H -#define _ASM_X86_STATFS_H - -#ifdef __i386__ -#include +#ifdef __KERNEL__ +# ifdef CONFIG_X86_32 +# include "statfs_32.h" +# else +# include "statfs_64.h" +# endif #else - -#ifndef __KERNEL_STRICT_NAMES - -#include - -typedef __kernel_fsid_t fsid_t; - -#endif - -/* - * This is ugly -- we're already 64-bit clean, so just duplicate the - * definitions. - */ -struct statfs { - long f_type; - long f_bsize; - long f_blocks; - long f_bfree; - long f_bavail; - long f_files; - long f_ffree; - __kernel_fsid_t f_fsid; - long f_namelen; - long f_frsize; - long f_spare[5]; -}; - -struct statfs64 { - long f_type; - long f_bsize; - long f_blocks; - long f_bfree; - long f_bavail; - long f_files; - long f_ffree; - __kernel_fsid_t f_fsid; - long f_namelen; - long f_frsize; - long f_spare[5]; -}; - -struct compat_statfs64 { - __u32 f_type; - __u32 f_bsize; - __u64 f_blocks; - __u64 f_bfree; - __u64 f_bavail; - __u64 f_files; - __u64 f_ffree; - __kernel_fsid_t f_fsid; - __u32 f_namelen; - __u32 f_frsize; - __u32 f_spare[5]; -} __attribute__((packed)); - -#endif /* !__i386__ */ +# ifdef __i386__ +# include "statfs_32.h" +# else +# include "statfs_64.h" +# endif #endif diff --git a/trunk/include/asm-x86/statfs_32.h b/trunk/include/asm-x86/statfs_32.h new file mode 100644 index 000000000000..24972c175132 --- /dev/null +++ b/trunk/include/asm-x86/statfs_32.h @@ -0,0 +1,6 @@ +#ifndef _I386_STATFS_H +#define _I386_STATFS_H + +#include + +#endif diff --git a/trunk/include/asm-x86/statfs_64.h b/trunk/include/asm-x86/statfs_64.h new file mode 100644 index 000000000000..b3f4718af30b --- /dev/null +++ b/trunk/include/asm-x86/statfs_64.h @@ -0,0 +1,58 @@ +#ifndef _X86_64_STATFS_H +#define _X86_64_STATFS_H + +#ifndef __KERNEL_STRICT_NAMES + +#include + +typedef __kernel_fsid_t fsid_t; + +#endif + +/* + * This is ugly -- we're already 64-bit clean, so just duplicate the + * definitions. + */ +struct statfs { + long f_type; + long f_bsize; + long f_blocks; + long f_bfree; + long f_bavail; + long f_files; + long f_ffree; + __kernel_fsid_t f_fsid; + long f_namelen; + long f_frsize; + long f_spare[5]; +}; + +struct statfs64 { + long f_type; + long f_bsize; + long f_blocks; + long f_bfree; + long f_bavail; + long f_files; + long f_ffree; + __kernel_fsid_t f_fsid; + long f_namelen; + long f_frsize; + long f_spare[5]; +}; + +struct compat_statfs64 { + __u32 f_type; + __u32 f_bsize; + __u64 f_blocks; + __u64 f_bfree; + __u64 f_bavail; + __u64 f_files; + __u64 f_ffree; + __kernel_fsid_t f_fsid; + __u32 f_namelen; + __u32 f_frsize; + __u32 f_spare[5]; +} __attribute__((packed)); + +#endif diff --git a/trunk/include/asm-x86/suspend_64.h b/trunk/include/asm-x86/suspend_64.h index c505a76bcf6e..9440a7a1b99a 100644 --- a/trunk/include/asm-x86/suspend_64.h +++ b/trunk/include/asm-x86/suspend_64.h @@ -3,9 +3,6 @@ * Based on code * Copyright 2001 Patrick Mochel */ -#ifndef __ASM_X86_64_SUSPEND_H -#define __ASM_X86_64_SUSPEND_H - #include #include @@ -15,9 +12,8 @@ arch_prepare_suspend(void) return 0; } -/* Image of the saved processor state. If you touch this, fix acpi/wakeup.S. */ +/* Image of the saved processor state. If you touch this, fix acpi_wakeup.S. */ struct saved_context { - struct pt_regs regs; u16 ds, es, fs, gs, ss; unsigned long gs_base, gs_kernel_base, fs_base; unsigned long cr0, cr2, cr3, cr4, cr8; @@ -33,16 +29,29 @@ struct saved_context { unsigned long tr; unsigned long safety; unsigned long return_address; + unsigned long eflags; } __attribute__((packed)); +/* We'll access these from assembly, so we'd better have them outside struct */ +extern unsigned long saved_context_eax, saved_context_ebx, saved_context_ecx, saved_context_edx; +extern unsigned long saved_context_esp, saved_context_ebp, saved_context_esi, saved_context_edi; +extern unsigned long saved_context_r08, saved_context_r09, saved_context_r10, saved_context_r11; +extern unsigned long saved_context_r12, saved_context_r13, saved_context_r14, saved_context_r15; +extern unsigned long saved_context_eflags; + #define loaddebug(thread,register) \ set_debugreg((thread)->debugreg##register, register) extern void fix_processor_context(void); +extern unsigned long saved_rip; +extern unsigned long saved_rsp; +extern unsigned long saved_rbp; +extern unsigned long saved_rbx; +extern unsigned long saved_rsi; +extern unsigned long saved_rdi; + /* routines for saving/restoring kernel state */ extern int acpi_save_state_mem(void); extern char core_restore_code; extern char restore_registers; - -#endif /* __ASM_X86_64_SUSPEND_H */ diff --git a/trunk/include/asm-xtensa/dma-mapping.h b/trunk/include/asm-xtensa/dma-mapping.h index 3c7d537dd15d..82b03b3a2ee6 100644 --- a/trunk/include/asm-xtensa/dma-mapping.h +++ b/trunk/include/asm-xtensa/dma-mapping.h @@ -11,10 +11,10 @@ #ifndef _XTENSA_DMA_MAPPING_H #define _XTENSA_DMA_MAPPING_H +#include #include #include #include -#include /* * DMA-consistent mapping functions. @@ -58,10 +58,11 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, BUG_ON(direction == DMA_NONE); for (i = 0; i < nents; i++, sg++ ) { - BUG_ON(!sg_page(sg)); + BUG_ON(!sg->page); - sg->dma_address = sg_phys(sg); - consistent_sync(sg_virt(sg), sg->length, direction); + sg->dma_address = page_to_phys(sg->page) + sg->offset; + consistent_sync(page_address(sg->page) + sg->offset, + sg->length, direction); } return nents; @@ -127,7 +128,8 @@ dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems, { int i; for (i = 0; i < nelems; i++, sg++) - consistent_sync(sg_virt(sg), sg->length, dir); + consistent_sync(page_address(sg->page) + sg->offset, + sg->length, dir); } static inline void @@ -136,7 +138,8 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems, { int i; for (i = 0; i < nelems; i++, sg++) - consistent_sync(sg_virt(sg), sg->length, dir); + consistent_sync(page_address(sg->page) + sg->offset, + sg->length, dir); } static inline int dma_mapping_error(dma_addr_t dma_addr) diff --git a/trunk/include/linux/Kbuild b/trunk/include/linux/Kbuild index bd33c22315c1..6a65231bc785 100644 --- a/trunk/include/linux/Kbuild +++ b/trunk/include/linux/Kbuild @@ -149,7 +149,6 @@ header-y += ticable.h header-y += times.h header-y += tiocl.h header-y += tipc.h -header-y += tipc_config.h header-y += toshiba.h header-y += ultrasound.h header-y += un.h diff --git a/trunk/include/linux/ata.h b/trunk/include/linux/ata.h index 128dc7ad4901..a4f373f8b798 100644 --- a/trunk/include/linux/ata.h +++ b/trunk/include/linux/ata.h @@ -178,9 +178,8 @@ enum { ATA_CMD_PACKET = 0xA0, ATA_CMD_VERIFY = 0x40, ATA_CMD_VERIFY_EXT = 0x42, - ATA_CMD_STANDBYNOW1 = 0xE0, - ATA_CMD_IDLEIMMEDIATE = 0xE1, - ATA_CMD_SLEEP = 0xE6, + ATA_CMD_STANDBYNOW1 = 0xE0, + ATA_CMD_IDLEIMMEDIATE = 0xE1, ATA_CMD_INIT_DEV_PARAMS = 0x91, ATA_CMD_READ_NATIVE_MAX = 0xF8, ATA_CMD_READ_NATIVE_MAX_EXT = 0x27, @@ -236,7 +235,6 @@ enum { /* SETFEATURE Sector counts for SATA features */ SATA_AN = 0x05, /* Asynchronous Notification */ - SATA_DIPM = 0x03, /* Device Initiated Power Management */ /* ATAPI stuff */ ATAPI_PKT_DMA = (1 << 0), @@ -379,26 +377,6 @@ struct ata_taskfile { #define ata_id_cdb_intr(id) (((id)[0] & 0x60) == 0x20) -static inline bool ata_id_has_hipm(const u16 *id) -{ - u16 val = id[76]; - - if (val == 0 || val == 0xffff) - return false; - - return val & (1 << 9); -} - -static inline bool ata_id_has_dipm(const u16 *id) -{ - u16 val = id[78]; - - if (val == 0 || val == 0xffff) - return false; - - return val & (1 << 3); -} - static inline int ata_id_has_fua(const u16 *id) { if ((id[84] & 0xC000) != 0x4000) @@ -480,7 +458,7 @@ static inline int ata_id_wcache_enabled(const u16 *id) * ATA-3 introduces word 80 and accurate reporting * * The practical impact of this is that ata_id_major_version cannot - * reliably report on drives below ATA3. + * reliably report on drives below ATA3. */ static inline unsigned int ata_id_major_version(const u16 *id) diff --git a/trunk/include/linux/blkdev.h b/trunk/include/linux/blkdev.h index 8396db24d019..bbf906a0b419 100644 --- a/trunk/include/linux/blkdev.h +++ b/trunk/include/linux/blkdev.h @@ -341,6 +341,7 @@ enum blk_queue_state { struct blk_queue_tag { struct request **tag_index; /* map of busy tags */ unsigned long *tag_map; /* bit map of free/busy tags */ + struct list_head busy_list; /* fifo list of busy tags */ int busy; /* current depth */ int max_depth; /* what we will send to device */ int real_max_depth; /* what the array can hold */ @@ -434,7 +435,6 @@ struct request_queue unsigned int dma_alignment; struct blk_queue_tag *queue_tags; - struct list_head tag_busy_list; unsigned int nr_sorted; unsigned int in_flight; diff --git a/trunk/include/linux/bootmem.h b/trunk/include/linux/bootmem.h index 0365ec9fc0c9..c83534ee1e79 100644 --- a/trunk/include/linux/bootmem.h +++ b/trunk/include/linux/bootmem.h @@ -59,6 +59,7 @@ extern void *__alloc_bootmem_core(struct bootmem_data *bdata, unsigned long align, unsigned long goal, unsigned long limit); +extern void *alloc_bootmem_high_node(pg_data_t *pgdat, unsigned long size); #ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE extern void reserve_bootmem(unsigned long addr, unsigned long size); diff --git a/trunk/include/linux/compiler.h b/trunk/include/linux/compiler.h index c68b67b86ef1..c811c8b979ac 100644 --- a/trunk/include/linux/compiler.h +++ b/trunk/include/linux/compiler.h @@ -101,12 +101,6 @@ extern void __chk_io_ptr(const volatile void __iomem *); #undef __must_check #define __must_check #endif -#ifndef CONFIG_ENABLE_WARN_DEPRECATED -#undef __deprecated -#undef __deprecated_for_modules -#define __deprecated -#define __deprecated_for_modules -#endif /* * Allow us to avoid 'defined but not used' warnings on functions and data, diff --git a/trunk/include/linux/completion.h b/trunk/include/linux/completion.h index 33d6aaf94447..268c5a4a2bd4 100644 --- a/trunk/include/linux/completion.h +++ b/trunk/include/linux/completion.h @@ -42,15 +42,15 @@ static inline void init_completion(struct completion *x) init_waitqueue_head(&x->wait); } -extern void wait_for_completion(struct completion *); -extern int wait_for_completion_interruptible(struct completion *x); -extern unsigned long wait_for_completion_timeout(struct completion *x, - unsigned long timeout); -extern unsigned long wait_for_completion_interruptible_timeout( - struct completion *x, unsigned long timeout); - -extern void complete(struct completion *); -extern void complete_all(struct completion *); +extern void FASTCALL(wait_for_completion(struct completion *)); +extern int FASTCALL(wait_for_completion_interruptible(struct completion *x)); +extern unsigned long FASTCALL(wait_for_completion_timeout(struct completion *x, + unsigned long timeout)); +extern unsigned long FASTCALL(wait_for_completion_interruptible_timeout( + struct completion *x, unsigned long timeout)); + +extern void FASTCALL(complete(struct completion *)); +extern void FASTCALL(complete_all(struct completion *)); #define INIT_COMPLETION(x) ((x).done = 0) diff --git a/trunk/include/linux/dccp.h b/trunk/include/linux/dccp.h index 333c3ea82a5d..f3fc4392e93d 100644 --- a/trunk/include/linux/dccp.h +++ b/trunk/include/linux/dccp.h @@ -144,8 +144,6 @@ enum dccp_reset_codes { DCCP_RESET_CODE_TOO_BUSY, DCCP_RESET_CODE_BAD_INIT_COOKIE, DCCP_RESET_CODE_AGGRESSION_PENALTY, - - DCCP_MAX_RESET_CODES /* Leave at the end! */ }; /* DCCP options */ @@ -272,9 +270,10 @@ static inline struct dccp_hdr *dccp_zeroed_hdr(struct sk_buff *skb, int headlen) return memset(skb_transport_header(skb), 0, headlen); } -static inline struct dccp_hdr_ext *dccp_hdrx(const struct dccp_hdr *dh) +static inline struct dccp_hdr_ext *dccp_hdrx(const struct sk_buff *skb) { - return (struct dccp_hdr_ext *)((unsigned char *)dh + sizeof(*dh)); + return (struct dccp_hdr_ext *)(skb_transport_header(skb) + + sizeof(struct dccp_hdr)); } static inline unsigned int __dccp_basic_hdr_len(const struct dccp_hdr *dh) @@ -288,12 +287,13 @@ static inline unsigned int dccp_basic_hdr_len(const struct sk_buff *skb) return __dccp_basic_hdr_len(dh); } -static inline __u64 dccp_hdr_seq(const struct dccp_hdr *dh) +static inline __u64 dccp_hdr_seq(const struct sk_buff *skb) { + const struct dccp_hdr *dh = dccp_hdr(skb); __u64 seq_nr = ntohs(dh->dccph_seq); if (dh->dccph_x != 0) - seq_nr = (seq_nr << 32) + ntohl(dccp_hdrx(dh)->dccph_seq_low); + seq_nr = (seq_nr << 32) + ntohl(dccp_hdrx(skb)->dccph_seq_low); else seq_nr += (u32)dh->dccph_seq2 << 16; diff --git a/trunk/include/linux/eventpoll.h b/trunk/include/linux/eventpoll.h index cf79853967ff..d2a96cbf4f0e 100644 --- a/trunk/include/linux/eventpoll.h +++ b/trunk/include/linux/eventpoll.h @@ -32,13 +32,18 @@ * On x86-64 make the 64bit structure have the same alignment as the * 32bit structure. This makes 32bit emulation easier. * - * UML/x86_64 needs the same packing as x86_64 + * UML/x86_64 needs the same packing as x86_64 - UML + UML_X86 + + * 64_BIT adds up to UML/x86_64. */ #ifdef __x86_64__ #define EPOLL_PACKED __attribute__((packed)) #else +#if defined(CONFIG_UML) && defined(CONFIG_UML_X86) && defined(CONFIG_64BIT) +#define EPOLL_PACKED __attribute__((packed)) +#else #define EPOLL_PACKED #endif +#endif struct epoll_event { __u32 events; diff --git a/trunk/include/linux/ipmi_smi.h b/trunk/include/linux/ipmi_smi.h index 6e8cec503380..56ae438ae510 100644 --- a/trunk/include/linux/ipmi_smi.h +++ b/trunk/include/linux/ipmi_smi.h @@ -173,7 +173,7 @@ static inline int ipmi_demangle_device_id(const unsigned char *data, id->firmware_revision_2 = data[3]; id->ipmi_version = data[4]; id->additional_device_support = data[5]; - if (data_len >= 11) { + if (data_len >= 6) { id->manufacturer_id = (data[6] | (data[7] << 8) | (data[8] << 16)); id->product_id = data[9] | (data[10] << 8); diff --git a/trunk/include/linux/lguest.h b/trunk/include/linux/lguest.h index 175e63f4a8c0..8beb29134626 100644 --- a/trunk/include/linux/lguest.h +++ b/trunk/include/linux/lguest.h @@ -12,8 +12,8 @@ #define LG_CLOCK_MAX_DELTA ULONG_MAX /*G:032 The second method of communicating with the Host is to via "struct - * lguest_data". Once the Guest's initialization hypercall tells the Host where - * this is, the Guest and Host both publish information in it. :*/ + * lguest_data". The Guest's very first hypercall is to tell the Host where + * this is, and then the Guest and Host both publish information in it. :*/ struct lguest_data { /* 512 == enabled (same as eflags in normal hardware). The Guest diff --git a/trunk/include/linux/lguest_launcher.h b/trunk/include/linux/lguest_launcher.h index 697104da91f1..61e1e3e6b1cc 100644 --- a/trunk/include/linux/lguest_launcher.h +++ b/trunk/include/linux/lguest_launcher.h @@ -1,7 +1,17 @@ -#ifndef _LINUX_LGUEST_LAUNCHER -#define _LINUX_LGUEST_LAUNCHER +#ifndef _ASM_LGUEST_USER +#define _ASM_LGUEST_USER /* Everything the "lguest" userspace program needs to know. */ #include +/* They can register up to 32 arrays of lguest_dma. */ +#define LGUEST_MAX_DMA 32 +/* At most we can dma 16 lguest_dma in one op. */ +#define LGUEST_MAX_DMA_SECTIONS 16 + +/* How many devices? Assume each one wants up to two dma arrays per device. */ +#define LGUEST_MAX_DEVICES (LGUEST_MAX_DMA/2) + +/* Where the Host expects the Guest to SEND_DMA console output to. */ +#define LGUEST_CONSOLE_DMA_KEY 0 /*D:010 * Drivers @@ -10,11 +20,7 @@ * real devices (think of the damage it could do!) we provide virtual devices. * We could emulate a PCI bus with various devices on it, but that is a fairly * complex burden for the Host and suboptimal for the Guest, so we have our own - * simple lguest bus and we use "virtio" drivers. These drivers need a set of - * routines from us which will actually do the virtual I/O, but they handle all - * the net/block/console stuff themselves. This means that if we want to add - * a new device, we simply need to write a new virtio driver and create support - * for it in the Launcher: this code won't need to change. + * "lguest" bus and simple drivers. * * Devices are described by a simplified ID, a status byte, and some "config" * bytes which describe this device's configuration. This is placed by the @@ -45,9 +51,9 @@ struct lguest_vqconfig { /* Write command first word is a request. */ enum lguest_req { - LHREQ_INITIALIZE, /* + base, pfnlimit, pgdir, start */ + LHREQ_INITIALIZE, /* + pfnlimit, pgdir, start, pageoffset */ LHREQ_GETDMA, /* No longer used */ LHREQ_IRQ, /* + irq */ LHREQ_BREAK, /* + on/off flag (on blocks until someone does off) */ }; -#endif /* _LINUX_LGUEST_LAUNCHER */ +#endif /* _ASM_LGUEST_USER */ diff --git a/trunk/include/linux/libata.h b/trunk/include/linux/libata.h index 1e277852ba42..bc3b6fc7b98d 100644 --- a/trunk/include/linux/libata.h +++ b/trunk/include/linux/libata.h @@ -133,14 +133,11 @@ enum { ATA_DFLAG_ACPI_PENDING = (1 << 5), /* ACPI resume action pending */ ATA_DFLAG_ACPI_FAILED = (1 << 6), /* ACPI on devcfg has failed */ ATA_DFLAG_AN = (1 << 7), /* AN configured */ - ATA_DFLAG_HIPM = (1 << 8), /* device supports HIPM */ - ATA_DFLAG_DIPM = (1 << 9), /* device supports DIPM */ ATA_DFLAG_CFG_MASK = (1 << 12) - 1, ATA_DFLAG_PIO = (1 << 12), /* device limited to PIO mode */ ATA_DFLAG_NCQ_OFF = (1 << 13), /* device limited to non-NCQ mode */ ATA_DFLAG_SPUNDOWN = (1 << 14), /* XXX: for spindown_compat */ - ATA_DFLAG_SLEEPING = (1 << 15), /* device is sleeping */ ATA_DFLAG_INIT_MASK = (1 << 16) - 1, ATA_DFLAG_DETACH = (1 << 16), @@ -188,7 +185,6 @@ enum { ATA_FLAG_ACPI_SATA = (1 << 17), /* need native SATA ACPI layout */ ATA_FLAG_AN = (1 << 18), /* controller supports AN */ ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */ - ATA_FLAG_IPM = (1 << 20), /* driver can handle IPM */ /* The following flag belongs to ap->pflags but is kept in * ap->flags because it's referenced in many LLDs and will be @@ -221,7 +217,6 @@ enum { ATA_QCFLAG_IO = (1 << 3), /* standard IO command */ ATA_QCFLAG_RESULT_TF = (1 << 4), /* result TF requested */ ATA_QCFLAG_CLEAR_EXCL = (1 << 5), /* clear excl_link on completion */ - ATA_QCFLAG_QUIET = (1 << 6), /* don't report device error */ ATA_QCFLAG_FAILED = (1 << 16), /* cmd failed and is owned by EH */ ATA_QCFLAG_SENSE_VALID = (1 << 17), /* sense data valid */ @@ -239,13 +234,6 @@ enum { ATA_TMOUT_INTERNAL = 30 * HZ, ATA_TMOUT_INTERNAL_QUICK = 5 * HZ, - /* FIXME: GoVault needs 2s but we can't afford that without - * parallel probing. 800ms is enough for iVDR disk - * HHD424020F7SV00. Increase to 2secs when parallel probing - * is in place. - */ - ATA_TMOUT_FF_WAIT = 4 * HZ / 5, - /* ATA bus states */ BUS_UNKNOWN = 0, BUS_DMA = 1, @@ -306,7 +294,6 @@ enum { ATA_EHI_RESUME_LINK = (1 << 1), /* resume link (reset modifier) */ ATA_EHI_NO_AUTOPSY = (1 << 2), /* no autopsy */ ATA_EHI_QUIET = (1 << 3), /* be quiet */ - ATA_EHI_LPM = (1 << 4), /* link power management action */ ATA_EHI_DID_SOFTRESET = (1 << 16), /* already soft-reset this port */ ATA_EHI_DID_HARDRESET = (1 << 17), /* already soft-reset this port */ @@ -338,9 +325,8 @@ enum { ATA_HORKAGE_BROKEN_HPA = (1 << 4), /* Broken HPA */ ATA_HORKAGE_SKIP_PM = (1 << 5), /* Skip PM operations */ ATA_HORKAGE_HPA_SIZE = (1 << 6), /* native size off by one */ - ATA_HORKAGE_IPM = (1 << 7), /* Link PM problems */ - /* DMA mask for user DMA control: User visible values; DO NOT + /* DMA mask for user DMA control: User visible values; DO NOT renumber */ ATA_DMA_MASK_ATA = (1 << 0), /* DMA on ATA Disk */ ATA_DMA_MASK_ATAPI = (1 << 1), /* DMA on ATAPI */ @@ -384,18 +370,6 @@ typedef int (*ata_reset_fn_t)(struct ata_link *link, unsigned int *classes, unsigned long deadline); typedef void (*ata_postreset_fn_t)(struct ata_link *link, unsigned int *classes); -/* - * host pm policy: If you alter this, you also need to alter libata-scsi.c - * (for the ascii descriptions) - */ -enum link_pm { - NOT_AVAILABLE, - MIN_POWER, - MAX_PERFORMANCE, - MEDIUM_POWER, -}; -extern struct class_device_attribute class_device_attr_link_power_management_policy; - struct ata_ioports { void __iomem *cmd_addr; void __iomem *data_addr; @@ -642,7 +616,6 @@ struct ata_port { pm_message_t pm_mesg; int *pm_result; - enum link_pm pm_policy; struct timer_list fastdrain_timer; unsigned long fastdrain_cnt; @@ -710,8 +683,7 @@ struct ata_port_operations { int (*port_suspend) (struct ata_port *ap, pm_message_t mesg); int (*port_resume) (struct ata_port *ap); - int (*enable_pm) (struct ata_port *ap, enum link_pm policy); - void (*disable_pm) (struct ata_port *ap); + int (*port_start) (struct ata_port *ap); void (*port_stop) (struct ata_port *ap); @@ -745,7 +717,7 @@ struct ata_timing { unsigned short udma; /* t2CYCTYP/2 */ }; -#define FIT(v, vmin, vmax) max_t(short, min_t(short, v, vmax), vmin) +#define FIT(v,vmin,vmax) max_t(short,min_t(short,v,vmax),vmin) extern const unsigned long sata_deb_timing_normal[]; extern const unsigned long sata_deb_timing_hotplug[]; @@ -827,7 +799,6 @@ extern void ata_host_resume(struct ata_host *host); extern int ata_ratelimit(void); extern int ata_busy_sleep(struct ata_port *ap, unsigned long timeout_pat, unsigned long timeout); -extern void ata_wait_after_reset(struct ata_port *ap, unsigned long deadline); extern int ata_wait_ready(struct ata_port *ap, unsigned long deadline); extern void ata_port_queue_task(struct ata_port *ap, work_func_t fn, void *data, unsigned long delay); @@ -845,14 +816,14 @@ extern void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf); extern void ata_tf_to_fis(const struct ata_taskfile *tf, u8 pmp, int is_cmd, u8 *fis); extern void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf); -extern void ata_noop_dev_select(struct ata_port *ap, unsigned int device); -extern void ata_std_dev_select(struct ata_port *ap, unsigned int device); +extern void ata_noop_dev_select (struct ata_port *ap, unsigned int device); +extern void ata_std_dev_select (struct ata_port *ap, unsigned int device); extern u8 ata_check_status(struct ata_port *ap); extern u8 ata_altstatus(struct ata_port *ap); extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); -extern int ata_port_start(struct ata_port *ap); -extern int ata_sff_port_start(struct ata_port *ap); -extern irqreturn_t ata_interrupt(int irq, void *dev_instance); +extern int ata_port_start (struct ata_port *ap); +extern int ata_sff_port_start (struct ata_port *ap); +extern irqreturn_t ata_interrupt (int irq, void *dev_instance); extern void ata_data_xfer(struct ata_device *adev, unsigned char *buf, unsigned int buflen, int write_data); extern void ata_data_xfer_noirq(struct ata_device *adev, unsigned char *buf, @@ -873,8 +844,8 @@ extern void ata_id_string(const u16 *id, unsigned char *s, extern void ata_id_c_string(const u16 *id, unsigned char *s, unsigned int ofs, unsigned int len); extern void ata_id_to_dma_mode(struct ata_device *dev, u8 unknown); -extern void ata_bmdma_setup(struct ata_queued_cmd *qc); -extern void ata_bmdma_start(struct ata_queued_cmd *qc); +extern void ata_bmdma_setup (struct ata_queued_cmd *qc); +extern void ata_bmdma_start (struct ata_queued_cmd *qc); extern void ata_bmdma_stop(struct ata_queued_cmd *qc); extern u8 ata_bmdma_status(struct ata_port *ap); extern void ata_bmdma_irq_clear(struct ata_port *ap); @@ -949,9 +920,9 @@ static inline int ata_acpi_cbl_80wire(struct ata_port *ap) { return 0; } #ifdef CONFIG_PCI struct pci_dev; -extern int ata_pci_init_one(struct pci_dev *pdev, +extern int ata_pci_init_one (struct pci_dev *pdev, const struct ata_port_info * const * ppi); -extern void ata_pci_remove_one(struct pci_dev *pdev); +extern void ata_pci_remove_one (struct pci_dev *pdev); #ifdef CONFIG_PM extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg); extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev); diff --git a/trunk/include/linux/mv643xx.h b/trunk/include/linux/mv643xx.h index d2ae6185f03b..9c8049005052 100644 --- a/trunk/include/linux/mv643xx.h +++ b/trunk/include/linux/mv643xx.h @@ -14,7 +14,6 @@ #define __ASM_MV643XX_H #include -#include /****************************************/ /* Processor Address Space */ @@ -659,6 +658,120 @@ /* Ethernet Unit Registers */ /****************************************/ +#define MV643XX_ETH_SHARED_REGS 0x2000 +#define MV643XX_ETH_SHARED_REGS_SIZE 0x2000 + +#define MV643XX_ETH_PHY_ADDR_REG 0x2000 +#define MV643XX_ETH_SMI_REG 0x2004 +#define MV643XX_ETH_UNIT_DEFAULT_ADDR_REG 0x2008 +#define MV643XX_ETH_UNIT_DEFAULTID_REG 0x200c +#define MV643XX_ETH_UNIT_INTERRUPT_CAUSE_REG 0x2080 +#define MV643XX_ETH_UNIT_INTERRUPT_MASK_REG 0x2084 +#define MV643XX_ETH_UNIT_INTERNAL_USE_REG 0x24fc +#define MV643XX_ETH_UNIT_ERROR_ADDR_REG 0x2094 +#define MV643XX_ETH_BAR_0 0x2200 +#define MV643XX_ETH_BAR_1 0x2208 +#define MV643XX_ETH_BAR_2 0x2210 +#define MV643XX_ETH_BAR_3 0x2218 +#define MV643XX_ETH_BAR_4 0x2220 +#define MV643XX_ETH_BAR_5 0x2228 +#define MV643XX_ETH_SIZE_REG_0 0x2204 +#define MV643XX_ETH_SIZE_REG_1 0x220c +#define MV643XX_ETH_SIZE_REG_2 0x2214 +#define MV643XX_ETH_SIZE_REG_3 0x221c +#define MV643XX_ETH_SIZE_REG_4 0x2224 +#define MV643XX_ETH_SIZE_REG_5 0x222c +#define MV643XX_ETH_HEADERS_RETARGET_BASE_REG 0x2230 +#define MV643XX_ETH_HEADERS_RETARGET_CONTROL_REG 0x2234 +#define MV643XX_ETH_HIGH_ADDR_REMAP_REG_0 0x2280 +#define MV643XX_ETH_HIGH_ADDR_REMAP_REG_1 0x2284 +#define MV643XX_ETH_HIGH_ADDR_REMAP_REG_2 0x2288 +#define MV643XX_ETH_HIGH_ADDR_REMAP_REG_3 0x228c +#define MV643XX_ETH_BASE_ADDR_ENABLE_REG 0x2290 +#define MV643XX_ETH_ACCESS_PROTECTION_REG(port) (0x2294 + (port<<2)) +#define MV643XX_ETH_MIB_COUNTERS_BASE(port) (0x3000 + (port<<7)) +#define MV643XX_ETH_PORT_CONFIG_REG(port) (0x2400 + (port<<10)) +#define MV643XX_ETH_PORT_CONFIG_EXTEND_REG(port) (0x2404 + (port<<10)) +#define MV643XX_ETH_MII_SERIAL_PARAMETRS_REG(port) (0x2408 + (port<<10)) +#define MV643XX_ETH_GMII_SERIAL_PARAMETRS_REG(port) (0x240c + (port<<10)) +#define MV643XX_ETH_VLAN_ETHERTYPE_REG(port) (0x2410 + (port<<10)) +#define MV643XX_ETH_MAC_ADDR_LOW(port) (0x2414 + (port<<10)) +#define MV643XX_ETH_MAC_ADDR_HIGH(port) (0x2418 + (port<<10)) +#define MV643XX_ETH_SDMA_CONFIG_REG(port) (0x241c + (port<<10)) +#define MV643XX_ETH_DSCP_0(port) (0x2420 + (port<<10)) +#define MV643XX_ETH_DSCP_1(port) (0x2424 + (port<<10)) +#define MV643XX_ETH_DSCP_2(port) (0x2428 + (port<<10)) +#define MV643XX_ETH_DSCP_3(port) (0x242c + (port<<10)) +#define MV643XX_ETH_DSCP_4(port) (0x2430 + (port<<10)) +#define MV643XX_ETH_DSCP_5(port) (0x2434 + (port<<10)) +#define MV643XX_ETH_DSCP_6(port) (0x2438 + (port<<10)) +#define MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port) (0x243c + (port<<10)) +#define MV643XX_ETH_VLAN_PRIORITY_TAG_TO_PRIORITY(port) (0x2440 + (port<<10)) +#define MV643XX_ETH_PORT_STATUS_REG(port) (0x2444 + (port<<10)) +#define MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port) (0x2448 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_FIXED_PRIORITY(port) (0x244c + (port<<10)) +#define MV643XX_ETH_PORT_TX_TOKEN_BUCKET_RATE_CONFIG(port) (0x2450 + (port<<10)) +#define MV643XX_ETH_MAXIMUM_TRANSMIT_UNIT(port) (0x2458 + (port<<10)) +#define MV643XX_ETH_PORT_MAXIMUM_TOKEN_BUCKET_SIZE(port) (0x245c + (port<<10)) +#define MV643XX_ETH_INTERRUPT_CAUSE_REG(port) (0x2460 + (port<<10)) +#define MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port) (0x2464 + (port<<10)) +#define MV643XX_ETH_INTERRUPT_MASK_REG(port) (0x2468 + (port<<10)) +#define MV643XX_ETH_INTERRUPT_EXTEND_MASK_REG(port) (0x246c + (port<<10)) +#define MV643XX_ETH_RX_FIFO_URGENT_THRESHOLD_REG(port) (0x2470 + (port<<10)) +#define MV643XX_ETH_TX_FIFO_URGENT_THRESHOLD_REG(port) (0x2474 + (port<<10)) +#define MV643XX_ETH_RX_MINIMAL_FRAME_SIZE_REG(port) (0x247c + (port<<10)) +#define MV643XX_ETH_RX_DISCARDED_FRAMES_COUNTER(port) (0x2484 + (port<<10)) +#define MV643XX_ETH_PORT_DEBUG_0_REG(port) (0x248c + (port<<10)) +#define MV643XX_ETH_PORT_DEBUG_1_REG(port) (0x2490 + (port<<10)) +#define MV643XX_ETH_PORT_INTERNAL_ADDR_ERROR_REG(port) (0x2494 + (port<<10)) +#define MV643XX_ETH_INTERNAL_USE_REG(port) (0x24fc + (port<<10)) +#define MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port) (0x2680 + (port<<10)) +#define MV643XX_ETH_CURRENT_SERVED_TX_DESC_PTR(port) (0x2684 + (port<<10)) +#define MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_0(port) (0x260c + (port<<10)) +#define MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_1(port) (0x261c + (port<<10)) +#define MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_2(port) (0x262c + (port<<10)) +#define MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_3(port) (0x263c + (port<<10)) +#define MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_4(port) (0x264c + (port<<10)) +#define MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_5(port) (0x265c + (port<<10)) +#define MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_6(port) (0x266c + (port<<10)) +#define MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_7(port) (0x267c + (port<<10)) +#define MV643XX_ETH_TX_CURRENT_QUEUE_DESC_PTR_0(port) (0x26c0 + (port<<10)) +#define MV643XX_ETH_TX_CURRENT_QUEUE_DESC_PTR_1(port) (0x26c4 + (port<<10)) +#define MV643XX_ETH_TX_CURRENT_QUEUE_DESC_PTR_2(port) (0x26c8 + (port<<10)) +#define MV643XX_ETH_TX_CURRENT_QUEUE_DESC_PTR_3(port) (0x26cc + (port<<10)) +#define MV643XX_ETH_TX_CURRENT_QUEUE_DESC_PTR_4(port) (0x26d0 + (port<<10)) +#define MV643XX_ETH_TX_CURRENT_QUEUE_DESC_PTR_5(port) (0x26d4 + (port<<10)) +#define MV643XX_ETH_TX_CURRENT_QUEUE_DESC_PTR_6(port) (0x26d8 + (port<<10)) +#define MV643XX_ETH_TX_CURRENT_QUEUE_DESC_PTR_7(port) (0x26dc + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_0_TOKEN_BUCKET_COUNT(port) (0x2700 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_1_TOKEN_BUCKET_COUNT(port) (0x2710 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_2_TOKEN_BUCKET_COUNT(port) (0x2720 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_3_TOKEN_BUCKET_COUNT(port) (0x2730 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_4_TOKEN_BUCKET_COUNT(port) (0x2740 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_5_TOKEN_BUCKET_COUNT(port) (0x2750 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_6_TOKEN_BUCKET_COUNT(port) (0x2760 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_7_TOKEN_BUCKET_COUNT(port) (0x2770 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_0_TOKEN_BUCKET_CONFIG(port) (0x2704 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_1_TOKEN_BUCKET_CONFIG(port) (0x2714 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_2_TOKEN_BUCKET_CONFIG(port) (0x2724 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_3_TOKEN_BUCKET_CONFIG(port) (0x2734 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_4_TOKEN_BUCKET_CONFIG(port) (0x2744 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_5_TOKEN_BUCKET_CONFIG(port) (0x2754 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_6_TOKEN_BUCKET_CONFIG(port) (0x2764 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_7_TOKEN_BUCKET_CONFIG(port) (0x2774 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_0_ARBITER_CONFIG(port) (0x2708 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_1_ARBITER_CONFIG(port) (0x2718 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_2_ARBITER_CONFIG(port) (0x2728 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_3_ARBITER_CONFIG(port) (0x2738 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_4_ARBITER_CONFIG(port) (0x2748 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_5_ARBITER_CONFIG(port) (0x2758 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_6_ARBITER_CONFIG(port) (0x2768 + (port<<10)) +#define MV643XX_ETH_TX_QUEUE_7_ARBITER_CONFIG(port) (0x2778 + (port<<10)) +#define MV643XX_ETH_PORT_TX_TOKEN_BUCKET_COUNT(port) (0x2780 + (port<<10)) +#define MV643XX_ETH_DA_FILTER_SPECIAL_MULTICAST_TABLE_BASE(port) (0x3400 + (port<<10)) +#define MV643XX_ETH_DA_FILTER_OTHER_MULTICAST_TABLE_BASE(port) (0x3500 + (port<<10)) +#define MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE(port) (0x3600 + (port<<10)) + /*******************************************/ /* CUNIT Registers */ /*******************************************/ @@ -976,6 +1089,219 @@ struct mv64xxx_i2c_pdata { u32 retries; }; +/* These macros describe Ethernet Port configuration reg (Px_cR) bits */ +#define MV643XX_ETH_UNICAST_NORMAL_MODE 0 +#define MV643XX_ETH_UNICAST_PROMISCUOUS_MODE (1<<0) +#define MV643XX_ETH_DEFAULT_RX_QUEUE_0 0 +#define MV643XX_ETH_DEFAULT_RX_QUEUE_1 (1<<1) +#define MV643XX_ETH_DEFAULT_RX_QUEUE_2 (1<<2) +#define MV643XX_ETH_DEFAULT_RX_QUEUE_3 ((1<<2) | (1<<1)) +#define MV643XX_ETH_DEFAULT_RX_QUEUE_4 (1<<3) +#define MV643XX_ETH_DEFAULT_RX_QUEUE_5 ((1<<3) | (1<<1)) +#define MV643XX_ETH_DEFAULT_RX_QUEUE_6 ((1<<3) | (1<<2)) +#define MV643XX_ETH_DEFAULT_RX_QUEUE_7 ((1<<3) | (1<<2) | (1<<1)) +#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_0 0 +#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_1 (1<<4) +#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_2 (1<<5) +#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_3 ((1<<5) | (1<<4)) +#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_4 (1<<6) +#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_5 ((1<<6) | (1<<4)) +#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_6 ((1<<6) | (1<<5)) +#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_7 ((1<<6) | (1<<5) | (1<<4)) +#define MV643XX_ETH_RECEIVE_BC_IF_NOT_IP_OR_ARP 0 +#define MV643XX_ETH_REJECT_BC_IF_NOT_IP_OR_ARP (1<<7) +#define MV643XX_ETH_RECEIVE_BC_IF_IP 0 +#define MV643XX_ETH_REJECT_BC_IF_IP (1<<8) +#define MV643XX_ETH_RECEIVE_BC_IF_ARP 0 +#define MV643XX_ETH_REJECT_BC_IF_ARP (1<<9) +#define MV643XX_ETH_TX_AM_NO_UPDATE_ERROR_SUMMARY (1<<12) +#define MV643XX_ETH_CAPTURE_TCP_FRAMES_DIS 0 +#define MV643XX_ETH_CAPTURE_TCP_FRAMES_EN (1<<14) +#define MV643XX_ETH_CAPTURE_UDP_FRAMES_DIS 0 +#define MV643XX_ETH_CAPTURE_UDP_FRAMES_EN (1<<15) +#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_0 0 +#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_1 (1<<16) +#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_2 (1<<17) +#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_3 ((1<<17) | (1<<16)) +#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_4 (1<<18) +#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_5 ((1<<18) | (1<<16)) +#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_6 ((1<<18) | (1<<17)) +#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_7 ((1<<18) | (1<<17) | (1<<16)) +#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_0 0 +#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_1 (1<<19) +#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_2 (1<<20) +#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_3 ((1<<20) | (1<<19)) +#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_4 (1<<21) +#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_5 ((1<<21) | (1<<19)) +#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_6 ((1<<21) | (1<<20)) +#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_7 ((1<<21) | (1<<20) | (1<<19)) +#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_0 0 +#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_1 (1<<22) +#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_2 (1<<23) +#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_3 ((1<<23) | (1<<22)) +#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_4 (1<<24) +#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_5 ((1<<24) | (1<<22)) +#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_6 ((1<<24) | (1<<23)) +#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_7 ((1<<24) | (1<<23) | (1<<22)) + +#define MV643XX_ETH_PORT_CONFIG_DEFAULT_VALUE \ + MV643XX_ETH_UNICAST_NORMAL_MODE | \ + MV643XX_ETH_DEFAULT_RX_QUEUE_0 | \ + MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_0 | \ + MV643XX_ETH_RECEIVE_BC_IF_NOT_IP_OR_ARP | \ + MV643XX_ETH_RECEIVE_BC_IF_IP | \ + MV643XX_ETH_RECEIVE_BC_IF_ARP | \ + MV643XX_ETH_CAPTURE_TCP_FRAMES_DIS | \ + MV643XX_ETH_CAPTURE_UDP_FRAMES_DIS | \ + MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_0 | \ + MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_0 | \ + MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_0 + +/* These macros describe Ethernet Port configuration extend reg (Px_cXR) bits*/ +#define MV643XX_ETH_CLASSIFY_EN (1<<0) +#define MV643XX_ETH_SPAN_BPDU_PACKETS_AS_NORMAL 0 +#define MV643XX_ETH_SPAN_BPDU_PACKETS_TO_RX_QUEUE_7 (1<<1) +#define MV643XX_ETH_PARTITION_DISABLE 0 +#define MV643XX_ETH_PARTITION_ENABLE (1<<2) + +#define MV643XX_ETH_PORT_CONFIG_EXTEND_DEFAULT_VALUE \ + MV643XX_ETH_SPAN_BPDU_PACKETS_AS_NORMAL | \ + MV643XX_ETH_PARTITION_DISABLE + +/* These macros describe Ethernet Port Sdma configuration reg (SDCR) bits */ +#define MV643XX_ETH_RIFB (1<<0) +#define MV643XX_ETH_RX_BURST_SIZE_1_64BIT 0 +#define MV643XX_ETH_RX_BURST_SIZE_2_64BIT (1<<1) +#define MV643XX_ETH_RX_BURST_SIZE_4_64BIT (1<<2) +#define MV643XX_ETH_RX_BURST_SIZE_8_64BIT ((1<<2) | (1<<1)) +#define MV643XX_ETH_RX_BURST_SIZE_16_64BIT (1<<3) +#define MV643XX_ETH_BLM_RX_NO_SWAP (1<<4) +#define MV643XX_ETH_BLM_RX_BYTE_SWAP 0 +#define MV643XX_ETH_BLM_TX_NO_SWAP (1<<5) +#define MV643XX_ETH_BLM_TX_BYTE_SWAP 0 +#define MV643XX_ETH_DESCRIPTORS_BYTE_SWAP (1<<6) +#define MV643XX_ETH_DESCRIPTORS_NO_SWAP 0 +#define MV643XX_ETH_TX_BURST_SIZE_1_64BIT 0 +#define MV643XX_ETH_TX_BURST_SIZE_2_64BIT (1<<22) +#define MV643XX_ETH_TX_BURST_SIZE_4_64BIT (1<<23) +#define MV643XX_ETH_TX_BURST_SIZE_8_64BIT ((1<<23) | (1<<22)) +#define MV643XX_ETH_TX_BURST_SIZE_16_64BIT (1<<24) + +#define MV643XX_ETH_IPG_INT_RX(value) ((value & 0x3fff) << 8) + +#define MV643XX_ETH_PORT_SDMA_CONFIG_DEFAULT_VALUE \ + MV643XX_ETH_RX_BURST_SIZE_4_64BIT | \ + MV643XX_ETH_IPG_INT_RX(0) | \ + MV643XX_ETH_TX_BURST_SIZE_4_64BIT + +/* These macros describe Ethernet Port serial control reg (PSCR) bits */ +#define MV643XX_ETH_SERIAL_PORT_DISABLE 0 +#define MV643XX_ETH_SERIAL_PORT_ENABLE (1<<0) +#define MV643XX_ETH_FORCE_LINK_PASS (1<<1) +#define MV643XX_ETH_DO_NOT_FORCE_LINK_PASS 0 +#define MV643XX_ETH_ENABLE_AUTO_NEG_FOR_DUPLX 0 +#define MV643XX_ETH_DISABLE_AUTO_NEG_FOR_DUPLX (1<<2) +#define MV643XX_ETH_ENABLE_AUTO_NEG_FOR_FLOW_CTRL 0 +#define MV643XX_ETH_DISABLE_AUTO_NEG_FOR_FLOW_CTRL (1<<3) +#define MV643XX_ETH_ADV_NO_FLOW_CTRL 0 +#define MV643XX_ETH_ADV_SYMMETRIC_FLOW_CTRL (1<<4) +#define MV643XX_ETH_FORCE_FC_MODE_NO_PAUSE_DIS_TX 0 +#define MV643XX_ETH_FORCE_FC_MODE_TX_PAUSE_DIS (1<<5) +#define MV643XX_ETH_FORCE_BP_MODE_NO_JAM 0 +#define MV643XX_ETH_FORCE_BP_MODE_JAM_TX (1<<7) +#define MV643XX_ETH_FORCE_BP_MODE_JAM_TX_ON_RX_ERR (1<<8) +#define MV643XX_ETH_SERIAL_PORT_CONTROL_RESERVED (1<<9) +#define MV643XX_ETH_FORCE_LINK_FAIL 0 +#define MV643XX_ETH_DO_NOT_FORCE_LINK_FAIL (1<<10) +#define MV643XX_ETH_RETRANSMIT_16_ATTEMPTS 0 +#define MV643XX_ETH_RETRANSMIT_FOREVER (1<<11) +#define MV643XX_ETH_DISABLE_AUTO_NEG_SPEED_GMII (1<<13) +#define MV643XX_ETH_ENABLE_AUTO_NEG_SPEED_GMII 0 +#define MV643XX_ETH_DTE_ADV_0 0 +#define MV643XX_ETH_DTE_ADV_1 (1<<14) +#define MV643XX_ETH_DISABLE_AUTO_NEG_BYPASS 0 +#define MV643XX_ETH_ENABLE_AUTO_NEG_BYPASS (1<<15) +#define MV643XX_ETH_AUTO_NEG_NO_CHANGE 0 +#define MV643XX_ETH_RESTART_AUTO_NEG (1<<16) +#define MV643XX_ETH_MAX_RX_PACKET_1518BYTE 0 +#define MV643XX_ETH_MAX_RX_PACKET_1522BYTE (1<<17) +#define MV643XX_ETH_MAX_RX_PACKET_1552BYTE (1<<18) +#define MV643XX_ETH_MAX_RX_PACKET_9022BYTE ((1<<18) | (1<<17)) +#define MV643XX_ETH_MAX_RX_PACKET_9192BYTE (1<<19) +#define MV643XX_ETH_MAX_RX_PACKET_9700BYTE ((1<<19) | (1<<17)) +#define MV643XX_ETH_SET_EXT_LOOPBACK (1<<20) +#define MV643XX_ETH_CLR_EXT_LOOPBACK 0 +#define MV643XX_ETH_SET_FULL_DUPLEX_MODE (1<<21) +#define MV643XX_ETH_SET_HALF_DUPLEX_MODE 0 +#define MV643XX_ETH_ENABLE_FLOW_CTRL_TX_RX_IN_FULL_DUPLEX (1<<22) +#define MV643XX_ETH_DISABLE_FLOW_CTRL_TX_RX_IN_FULL_DUPLEX 0 +#define MV643XX_ETH_SET_GMII_SPEED_TO_10_100 0 +#define MV643XX_ETH_SET_GMII_SPEED_TO_1000 (1<<23) +#define MV643XX_ETH_SET_MII_SPEED_TO_10 0 +#define MV643XX_ETH_SET_MII_SPEED_TO_100 (1<<24) + +#define MV643XX_ETH_MAX_RX_PACKET_MASK (0x7<<17) + +#define MV643XX_ETH_PORT_SERIAL_CONTROL_DEFAULT_VALUE \ + MV643XX_ETH_DO_NOT_FORCE_LINK_PASS | \ + MV643XX_ETH_ENABLE_AUTO_NEG_FOR_DUPLX | \ + MV643XX_ETH_DISABLE_AUTO_NEG_FOR_FLOW_CTRL | \ + MV643XX_ETH_ADV_SYMMETRIC_FLOW_CTRL | \ + MV643XX_ETH_FORCE_FC_MODE_NO_PAUSE_DIS_TX | \ + MV643XX_ETH_FORCE_BP_MODE_NO_JAM | \ + (1<<9) /* reserved */ | \ + MV643XX_ETH_DO_NOT_FORCE_LINK_FAIL | \ + MV643XX_ETH_RETRANSMIT_16_ATTEMPTS | \ + MV643XX_ETH_ENABLE_AUTO_NEG_SPEED_GMII | \ + MV643XX_ETH_DTE_ADV_0 | \ + MV643XX_ETH_DISABLE_AUTO_NEG_BYPASS | \ + MV643XX_ETH_AUTO_NEG_NO_CHANGE | \ + MV643XX_ETH_MAX_RX_PACKET_9700BYTE | \ + MV643XX_ETH_CLR_EXT_LOOPBACK | \ + MV643XX_ETH_SET_FULL_DUPLEX_MODE | \ + MV643XX_ETH_ENABLE_FLOW_CTRL_TX_RX_IN_FULL_DUPLEX + +/* These macros describe Ethernet Serial Status reg (PSR) bits */ +#define MV643XX_ETH_PORT_STATUS_MODE_10_BIT (1<<0) +#define MV643XX_ETH_PORT_STATUS_LINK_UP (1<<1) +#define MV643XX_ETH_PORT_STATUS_FULL_DUPLEX (1<<2) +#define MV643XX_ETH_PORT_STATUS_FLOW_CONTROL (1<<3) +#define MV643XX_ETH_PORT_STATUS_GMII_1000 (1<<4) +#define MV643XX_ETH_PORT_STATUS_MII_100 (1<<5) +/* PSR bit 6 is undocumented */ +#define MV643XX_ETH_PORT_STATUS_TX_IN_PROGRESS (1<<7) +#define MV643XX_ETH_PORT_STATUS_AUTONEG_BYPASSED (1<<8) +#define MV643XX_ETH_PORT_STATUS_PARTITION (1<<9) +#define MV643XX_ETH_PORT_STATUS_TX_FIFO_EMPTY (1<<10) +/* PSR bits 11-31 are reserved */ + +#define MV643XX_ETH_PORT_DEFAULT_TRANSMIT_QUEUE_SIZE 800 +#define MV643XX_ETH_PORT_DEFAULT_RECEIVE_QUEUE_SIZE 400 + +#define MV643XX_ETH_DESC_SIZE 64 + +#define MV643XX_ETH_SHARED_NAME "mv643xx_eth_shared" +#define MV643XX_ETH_NAME "mv643xx_eth" + +struct mv643xx_eth_platform_data { + int port_number; + u16 force_phy_addr; /* force override if phy_addr == 0 */ + u16 phy_addr; + + /* If speed is 0, then speed and duplex are autonegotiated. */ + int speed; /* 0, SPEED_10, SPEED_100, SPEED_1000 */ + int duplex; /* DUPLEX_HALF or DUPLEX_FULL */ + + /* non-zero values of the following fields override defaults */ + u32 tx_queue_size; + u32 rx_queue_size; + u32 tx_sram_addr; + u32 tx_sram_size; + u32 rx_sram_addr; + u32 rx_sram_size; + u8 mac_addr[6]; /* mac address if non-zero*/ +}; + /* Watchdog Platform Device, Driver Data */ #define MV64x60_WDT_NAME "mv64x60_wdt" diff --git a/trunk/include/linux/mv643xx_eth.h b/trunk/include/linux/mv643xx_eth.h deleted file mode 100644 index 30e11aa3c1c9..000000000000 --- a/trunk/include/linux/mv643xx_eth.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * MV-643XX ethernet platform device data definition file. - */ -#ifndef __LINUX_MV643XX_ETH_H -#define __LINUX_MV643XX_ETH_H - -#define MV643XX_ETH_SHARED_NAME "mv643xx_eth_shared" -#define MV643XX_ETH_NAME "mv643xx_eth" -#define MV643XX_ETH_SHARED_REGS 0x2000 -#define MV643XX_ETH_SHARED_REGS_SIZE 0x2000 -#define MV643XX_ETH_BAR_4 0x2220 -#define MV643XX_ETH_SIZE_REG_4 0x2224 -#define MV643XX_ETH_BASE_ADDR_ENABLE_REG 0x2290 - -struct mv643xx_eth_platform_data { - int port_number; - u16 force_phy_addr; /* force override if phy_addr == 0 */ - u16 phy_addr; - - /* If speed is 0, then speed and duplex are autonegotiated. */ - int speed; /* 0, SPEED_10, SPEED_100, SPEED_1000 */ - int duplex; /* DUPLEX_HALF or DUPLEX_FULL */ - - /* non-zero values of the following fields override defaults */ - u32 tx_queue_size; - u32 rx_queue_size; - u32 tx_sram_addr; - u32 tx_sram_size; - u32 rx_sram_addr; - u32 rx_sram_size; - u8 mac_addr[6]; /* mac address if non-zero*/ -}; - -#endif /* __LINUX_MV643XX_ETH_H */ diff --git a/trunk/include/linux/netdevice.h b/trunk/include/linux/netdevice.h index 9b0c8f12373e..4a3f54e358e5 100644 --- a/trunk/include/linux/netdevice.h +++ b/trunk/include/linux/netdevice.h @@ -390,7 +390,7 @@ static inline void napi_complete(struct napi_struct *n) static inline void napi_disable(struct napi_struct *n) { while (test_and_set_bit(NAPI_STATE_SCHED, &n->state)) - msleep(1); + msleep_interruptible(1); } /** @@ -669,8 +669,6 @@ struct net_device #define HAVE_SET_MAC_ADDR int (*set_mac_address)(struct net_device *dev, void *addr); -#define HAVE_VALIDATE_ADDR - int (*validate_addr)(struct net_device *dev); #define HAVE_PRIVATE_IOCTL int (*do_ioctl)(struct net_device *dev, struct ifreq *ifr, int cmd); @@ -836,7 +834,7 @@ static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev, const void *daddr, const void *saddr, unsigned len) { - if (!dev->header_ops || !dev->header_ops->create) + if (!dev->header_ops) return 0; return dev->header_ops->create(skb, dev, type, daddr, saddr, len); diff --git a/trunk/include/linux/parport.h b/trunk/include/linux/parport.h index d1ad546c8c9e..ec3f76598327 100644 --- a/trunk/include/linux/parport.h +++ b/trunk/include/linux/parport.h @@ -100,7 +100,6 @@ typedef enum { #include #include #include -#include #include #include #include @@ -230,7 +229,7 @@ struct pardevice { int (*preempt)(void *); void (*wakeup)(void *); void *private; - void (*irq_func)(void *); + void (*irq_func)(int, void *); unsigned int flags; struct pardevice *next; struct pardevice *prev; @@ -367,9 +366,6 @@ extern void parport_unregister_driver (struct parport_driver *); extern struct parport *parport_find_number (int); extern struct parport *parport_find_base (unsigned long); -/* generic irq handler, if it suits your needs */ -extern irqreturn_t parport_irq_handler(int irq, void *dev_id); - /* Reference counting for ports. */ extern struct parport *parport_get_port (struct parport *); extern void parport_put_port (struct parport *); @@ -383,7 +379,7 @@ extern void parport_put_port (struct parport *); struct pardevice *parport_register_device(struct parport *port, const char *name, int (*pf)(void *), void (*kf)(void *), - void (*irq_func)(void *), + void (*irq_func)(int, void *), int flags, void *handle); /* parport_unregister unlinks a device from the chain. */ @@ -465,7 +461,7 @@ static __inline__ int parport_yield_blocking(struct pardevice *dev) #define PARPORT_FLAG_EXCL (1<<1) /* EXCL driver registered. */ /* IEEE1284 functions */ -extern void parport_ieee1284_interrupt (void *); +extern void parport_ieee1284_interrupt (int, void *); extern int parport_negotiate (struct parport *, int mode); extern ssize_t parport_write (struct parport *, const void *buf, size_t len); extern ssize_t parport_read (struct parport *, void *buf, size_t len); @@ -507,19 +503,23 @@ extern size_t parport_ieee1284_epp_read_addr (struct parport *, /* IEEE1284.3 functions */ extern int parport_daisy_init (struct parport *port); extern void parport_daisy_fini (struct parport *port); -extern struct pardevice *parport_open (int devnum, const char *name); +extern struct pardevice *parport_open (int devnum, const char *name, + int (*pf) (void *), + void (*kf) (void *), + void (*irqf) (int, void *), + int flags, void *handle); extern void parport_close (struct pardevice *dev); extern ssize_t parport_device_id (int devnum, char *buffer, size_t len); extern void parport_daisy_deselect_all (struct parport *port); extern int parport_daisy_select (struct parport *port, int daisy, int mode); /* Lowlevel drivers _can_ call this support function to handle irqs. */ -static inline void parport_generic_irq(struct parport *port) +static __inline__ void parport_generic_irq(int irq, struct parport *port) { - parport_ieee1284_interrupt (port); + parport_ieee1284_interrupt (irq, port); read_lock(&port->cad_lock); if (port->cad && port->cad->irq_func) - port->cad->irq_func(port->cad->private); + port->cad->irq_func(irq, port->cad->private); read_unlock(&port->cad_lock); } diff --git a/trunk/include/linux/pci_ids.h b/trunk/include/linux/pci_ids.h index e44aac8cf5ff..4e10a074ca56 100644 --- a/trunk/include/linux/pci_ids.h +++ b/trunk/include/linux/pci_ids.h @@ -1236,10 +1236,6 @@ #define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE 0x0560 #define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE 0x056C #define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE 0x0759 -#define PCI_DEVICE_ID_NVIDIA_NVENET_32 0x0760 -#define PCI_DEVICE_ID_NVIDIA_NVENET_33 0x0761 -#define PCI_DEVICE_ID_NVIDIA_NVENET_34 0x0762 -#define PCI_DEVICE_ID_NVIDIA_NVENET_35 0x0763 #define PCI_VENDOR_ID_IMS 0x10e0 #define PCI_DEVICE_ID_IMS_TT128 0x9128 diff --git a/trunk/include/linux/scatterlist.h b/trunk/include/linux/scatterlist.h index 32326c293d7b..42daf5e15265 100644 --- a/trunk/include/linux/scatterlist.h +++ b/trunk/include/linux/scatterlist.h @@ -1,7 +1,6 @@ #ifndef _LINUX_SCATTERLIST_H #define _LINUX_SCATTERLIST_H -#include #include #include #include @@ -26,37 +25,10 @@ #define SG_MAGIC 0x87654321 -/** - * sg_assign_page - Assign a given page to an SG entry - * @sg: SG entry - * @page: The page - * - * Description: - * Assign page to sg entry. Also see sg_set_page(), the most commonly used - * variant. - * - **/ -static inline void sg_assign_page(struct scatterlist *sg, struct page *page) -{ - unsigned long page_link = sg->page_link & 0x3; - - /* - * In order for the low bit stealing approach to work, pages - * must be aligned at a 32-bit boundary as a minimum. - */ - BUG_ON((unsigned long) page & 0x03); -#ifdef CONFIG_DEBUG_SG - BUG_ON(sg->sg_magic != SG_MAGIC); -#endif - sg->page_link = page_link | (unsigned long) page; -} - /** * sg_set_page - Set sg entry to point at given page * @sg: SG entry * @page: The page - * @len: Length of data - * @offset: Offset into page * * Description: * Use this function to set an sg entry pointing at a page, never assign @@ -65,12 +37,14 @@ static inline void sg_assign_page(struct scatterlist *sg, struct page *page) * to an sg entry. * **/ -static inline void sg_set_page(struct scatterlist *sg, struct page *page, - unsigned int len, unsigned int offset) +static inline void sg_set_page(struct scatterlist *sg, struct page *page) { - sg_assign_page(sg, page); - sg->offset = offset; - sg->length = len; + unsigned long page_link = sg->page_link & 0x3; + +#ifdef CONFIG_DEBUG_SG + BUG_ON(sg->sg_magic != SG_MAGIC); +#endif + sg->page_link = page_link | (unsigned long) page; } #define sg_page(sg) ((struct page *) ((sg)->page_link & ~0x3)) @@ -85,7 +59,9 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page, static inline void sg_set_buf(struct scatterlist *sg, const void *buf, unsigned int buflen) { - sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf)); + sg_set_page(sg, virt_to_page(buf)); + sg->offset = offset_in_page(buf); + sg->length = buflen; } /* @@ -150,7 +126,7 @@ static inline struct scatterlist *sg_last(struct scatterlist *sgl, struct scatterlist *ret = &sgl[nents - 1]; #else struct scatterlist *sg, *ret = NULL; - unsigned int i; + int i; for_each_sg(sgl, sg, nents, i) ret = sg; @@ -179,11 +155,7 @@ static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents, #ifndef ARCH_HAS_SG_CHAIN BUG(); #endif - /* - * Set lowest bit to indicate a link pointer, and make sure to clear - * the termination bit if it happens to be set. - */ - prv[prv_nents - 1].page_link = ((unsigned long) sgl | 0x01) & ~0x02; + prv[prv_nents - 1].page_link = (unsigned long) sgl | 0x01; } /** @@ -243,7 +215,7 @@ static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents) sg_mark_end(sgl, nents); #ifdef CONFIG_DEBUG_SG { - unsigned int i; + int i; for (i = 0; i < nents; i++) sgl[i].sg_magic = SG_MAGIC; } @@ -260,7 +232,7 @@ static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents) * on the sg page. * **/ -static inline dma_addr_t sg_phys(struct scatterlist *sg) +static inline unsigned long sg_phys(struct scatterlist *sg) { return page_to_phys(sg_page(sg)) + sg->offset; } diff --git a/trunk/include/linux/sched.h b/trunk/include/linux/sched.h index 155d7438f7ad..13df99fb2769 100644 --- a/trunk/include/linux/sched.h +++ b/trunk/include/linux/sched.h @@ -828,17 +828,12 @@ struct sched_class { struct task_struct * (*pick_next_task) (struct rq *rq); void (*put_prev_task) (struct rq *rq, struct task_struct *p); -#ifdef CONFIG_SMP unsigned long (*load_balance) (struct rq *this_rq, int this_cpu, - struct rq *busiest, unsigned long max_load_move, + struct rq *busiest, + unsigned long max_nr_move, unsigned long max_load_move, struct sched_domain *sd, enum cpu_idle_type idle, int *all_pinned, int *this_best_prio); - int (*move_one_task) (struct rq *this_rq, int this_cpu, - struct rq *busiest, struct sched_domain *sd, - enum cpu_idle_type idle); -#endif - void (*set_curr_task) (struct rq *rq); void (*task_tick) (struct rq *rq, struct task_struct *p); void (*task_new) (struct rq *rq, struct task_struct *p); @@ -1009,7 +1004,6 @@ struct task_struct { unsigned int rt_priority; cputime_t utime, stime, utimescaled, stimescaled; cputime_t gtime; - cputime_t prev_utime, prev_stime; unsigned long nvcsw, nivcsw; /* context switch counts */ struct timespec start_time; /* monotonic time */ struct timespec real_start_time; /* boot based time */ diff --git a/trunk/include/linux/serial_core.h b/trunk/include/linux/serial_core.h index 6a5203fb9cf1..4db77249281c 100644 --- a/trunk/include/linux/serial_core.h +++ b/trunk/include/linux/serial_core.h @@ -146,9 +146,6 @@ /* Broadcom SB1250, etc. SOC */ #define PORT_SB1250_DUART 77 -/* Freescale ColdFire */ -#define PORT_MCF 78 - #ifdef __KERNEL__ diff --git a/trunk/include/linux/skbuff.h b/trunk/include/linux/skbuff.h index 94e49915a8c0..fd4e12f24270 100644 --- a/trunk/include/linux/skbuff.h +++ b/trunk/include/linux/skbuff.h @@ -994,7 +994,7 @@ static inline int pskb_may_pull(struct sk_buff *skb, unsigned int len) * * Return the number of bytes of free space at the head of an &sk_buff. */ -static inline unsigned int skb_headroom(const struct sk_buff *skb) +static inline int skb_headroom(const struct sk_buff *skb) { return skb->data - skb->head; } @@ -1347,7 +1347,7 @@ static inline struct sk_buff *netdev_alloc_skb(struct net_device *dev, * Returns true if modifying the header part of the cloned buffer * does not requires the data to be copied. */ -static inline int skb_clone_writable(struct sk_buff *skb, unsigned int len) +static inline int skb_clone_writable(struct sk_buff *skb, int len) { return !skb_header_cloned(skb) && skb_headroom(skb) + len <= skb->hdr_len; diff --git a/trunk/include/linux/sunrpc/rpc_rdma.h b/trunk/include/linux/sunrpc/rpc_rdma.h index 87b895d5c786..0013a0d8dc6b 100644 --- a/trunk/include/linux/sunrpc/rpc_rdma.h +++ b/trunk/include/linux/sunrpc/rpc_rdma.h @@ -41,17 +41,17 @@ #define _LINUX_SUNRPC_RPC_RDMA_H struct rpcrdma_segment { - __be32 rs_handle; /* Registered memory handle */ - __be32 rs_length; /* Length of the chunk in bytes */ - __be64 rs_offset; /* Chunk virtual address or offset */ + uint32_t rs_handle; /* Registered memory handle */ + uint32_t rs_length; /* Length of the chunk in bytes */ + uint64_t rs_offset; /* Chunk virtual address or offset */ }; /* * read chunk(s), encoded as a linked list. */ struct rpcrdma_read_chunk { - __be32 rc_discrim; /* 1 indicates presence */ - __be32 rc_position; /* Position in XDR stream */ + uint32_t rc_discrim; /* 1 indicates presence */ + uint32_t rc_position; /* Position in XDR stream */ struct rpcrdma_segment rc_target; }; @@ -66,29 +66,29 @@ struct rpcrdma_write_chunk { * write chunk(s), encoded as a counted array. */ struct rpcrdma_write_array { - __be32 wc_discrim; /* 1 indicates presence */ - __be32 wc_nchunks; /* Array count */ + uint32_t wc_discrim; /* 1 indicates presence */ + uint32_t wc_nchunks; /* Array count */ struct rpcrdma_write_chunk wc_array[0]; }; struct rpcrdma_msg { - __be32 rm_xid; /* Mirrors the RPC header xid */ - __be32 rm_vers; /* Version of this protocol */ - __be32 rm_credit; /* Buffers requested/granted */ - __be32 rm_type; /* Type of message (enum rpcrdma_proc) */ + uint32_t rm_xid; /* Mirrors the RPC header xid */ + uint32_t rm_vers; /* Version of this protocol */ + uint32_t rm_credit; /* Buffers requested/granted */ + uint32_t rm_type; /* Type of message (enum rpcrdma_proc) */ union { struct { /* no chunks */ - __be32 rm_empty[3]; /* 3 empty chunk lists */ + uint32_t rm_empty[3]; /* 3 empty chunk lists */ } rm_nochunks; struct { /* no chunks and padded */ - __be32 rm_align; /* Padding alignment */ - __be32 rm_thresh; /* Padding threshold */ - __be32 rm_pempty[3]; /* 3 empty chunk lists */ + uint32_t rm_align; /* Padding alignment */ + uint32_t rm_thresh; /* Padding threshold */ + uint32_t rm_pempty[3]; /* 3 empty chunk lists */ } rm_padded; - __be32 rm_chunks[0]; /* read, write and reply chunks */ + uint32_t rm_chunks[0]; /* read, write and reply chunks */ } rm_body; }; diff --git a/trunk/include/linux/types.h b/trunk/include/linux/types.h index f4f8d19158e4..4f0dad21c917 100644 --- a/trunk/include/linux/types.h +++ b/trunk/include/linux/types.h @@ -37,8 +37,6 @@ typedef __kernel_gid32_t gid_t; typedef __kernel_uid16_t uid16_t; typedef __kernel_gid16_t gid16_t; -typedef unsigned long uintptr_t; - #ifdef CONFIG_UID16 /* This is defined by include/asm-{arch}/posix_types.h */ typedef __kernel_old_uid_t old_uid_t; diff --git a/trunk/include/linux/virtio_9p.h b/trunk/include/linux/virtio_9p.h deleted file mode 100644 index 8eff0b53910b..000000000000 --- a/trunk/include/linux/virtio_9p.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _LINUX_VIRTIO_9P_H -#define _LINUX_VIRTIO_9P_H -#include - -/* The ID for virtio console */ -#define VIRTIO_ID_9P 9 -/* Maximum number of virtio channels per partition (1 for now) */ -#define MAX_9P_CHAN 1 - -#endif /* _LINUX_VIRTIO_9P_H */ diff --git a/trunk/include/media/saa7146.h b/trunk/include/media/saa7146.h index 88b2b5a619aa..cd3ff2c29d5e 100644 --- a/trunk/include/media/saa7146.h +++ b/trunk/include/media/saa7146.h @@ -12,7 +12,6 @@ #include /* for accessing devices */ #include #include -#include #include /* for vmalloc() */ #include /* for vmalloc_to_page() */ diff --git a/trunk/include/net/inet_hashtables.h b/trunk/include/net/inet_hashtables.h index 4427dcd1e53a..8228b57eb18f 100644 --- a/trunk/include/net/inet_hashtables.h +++ b/trunk/include/net/inet_hashtables.h @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -265,6 +266,11 @@ static inline void inet_unhash(struct inet_hashinfo *hashinfo, struct sock *sk) wake_up(&hashinfo->lhash_wait); } +static inline int inet_iif(const struct sk_buff *skb) +{ + return ((struct rtable *)skb->dst)->rt_iif; +} + extern struct sock *__inet_lookup_listener(struct inet_hashinfo *hashinfo, const __be32 daddr, const unsigned short hnum, diff --git a/trunk/include/net/inet_sock.h b/trunk/include/net/inet_sock.h index 70013c5f4e59..62daf214931f 100644 --- a/trunk/include/net/inet_sock.h +++ b/trunk/include/net/inet_sock.h @@ -24,7 +24,6 @@ #include #include #include -#include /** struct ip_options - IP Options * @@ -191,10 +190,4 @@ static inline int inet_sk_ehashfn(const struct sock *sk) return inet_ehashfn(laddr, lport, faddr, fport); } - -static inline int inet_iif(const struct sk_buff *skb) -{ - return ((struct rtable *)skb->dst)->rt_iif; -} - #endif /* _INET_SOCK_H */ diff --git a/trunk/include/net/irda/ircomm_tty.h b/trunk/include/net/irda/ircomm_tty.h index eea2e6152389..8dabdd603fe1 100644 --- a/trunk/include/net/irda/ircomm_tty.h +++ b/trunk/include/net/irda/ircomm_tty.h @@ -127,6 +127,7 @@ extern int ircomm_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); extern void ircomm_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios); +extern hashbin_t *ircomm_tty; #endif diff --git a/trunk/include/net/net_namespace.h b/trunk/include/net/net_namespace.h index 5279466606d2..93aa87d32804 100644 --- a/trunk/include/net/net_namespace.h +++ b/trunk/include/net/net_namespace.h @@ -102,9 +102,11 @@ static inline void release_net(struct net *net) #ifdef CONFIG_NET_NS #define __net_init #define __net_exit +#define __net_initdata #else #define __net_init __init #define __net_exit __exit_refok +#define __net_initdata __initdata #endif struct pernet_operations { diff --git a/trunk/include/net/sch_generic.h b/trunk/include/net/sch_generic.h index c9265518a378..a02ec9e5fea5 100644 --- a/trunk/include/net/sch_generic.h +++ b/trunk/include/net/sch_generic.h @@ -316,19 +316,4 @@ static inline u32 qdisc_l2t(struct qdisc_rate_table* rtab, unsigned int pktlen) return rtab->data[slot]; } -#ifdef CONFIG_NET_CLS_ACT -static inline struct sk_buff *skb_act_clone(struct sk_buff *skb, gfp_t gfp_mask) -{ - struct sk_buff *n = skb_clone(skb, gfp_mask); - - if (n) { - n->tc_verd = SET_TC_VERD(n->tc_verd, 0); - n->tc_verd = CLR_TC_OK2MUNGE(n->tc_verd); - n->tc_verd = CLR_TC_MUNGED(n->tc_verd); - n->iif = skb->iif; - } - return n; -} -#endif - #endif diff --git a/trunk/include/net/sctp/auth.h b/trunk/include/net/sctp/auth.h index 5db261a1e85e..4945954a16af 100644 --- a/trunk/include/net/sctp/auth.h +++ b/trunk/include/net/sctp/auth.h @@ -88,6 +88,7 @@ static inline void sctp_auth_key_hold(struct sctp_auth_bytes *key) void sctp_auth_key_put(struct sctp_auth_bytes *key); struct sctp_shared_key *sctp_auth_shkey_create(__u16 key_id, gfp_t gfp); +void sctp_auth_shkey_free(struct sctp_shared_key *sh_key); void sctp_auth_destroy_keys(struct list_head *keys); int sctp_auth_asoc_init_active_key(struct sctp_association *asoc, gfp_t gfp); struct sctp_shared_key *sctp_auth_get_shkey( @@ -103,7 +104,7 @@ struct sctp_hmac *sctp_auth_asoc_get_hmac(const struct sctp_association *asoc); void sctp_auth_asoc_set_default_hmac(struct sctp_association *asoc, struct sctp_hmac_algo_param *hmacs); int sctp_auth_asoc_verify_hmac_id(const struct sctp_association *asoc, - __be16 hmac_id); + __u16 hmac_id); int sctp_auth_send_cid(sctp_cid_t chunk, const struct sctp_association *asoc); int sctp_auth_recv_cid(sctp_cid_t chunk, const struct sctp_association *asoc); void sctp_auth_calculate_hmac(const struct sctp_association *asoc, diff --git a/trunk/include/net/sctp/sctp.h b/trunk/include/net/sctp/sctp.h index 93eb708609e7..119f5a1ed499 100644 --- a/trunk/include/net/sctp/sctp.h +++ b/trunk/include/net/sctp/sctp.h @@ -156,6 +156,7 @@ int sctp_primitive_ASCONF(struct sctp_association *, void *arg); __u32 sctp_start_cksum(__u8 *ptr, __u16 count); __u32 sctp_update_cksum(__u8 *ptr, __u16 count, __u32 cksum); __u32 sctp_end_cksum(__u32 cksum); +__u32 sctp_update_copy_cksum(__u8 *, __u8 *, __u16 count, __u32 cksum); /* * sctp/input.c diff --git a/trunk/include/net/tcp.h b/trunk/include/net/tcp.h index d695cea7730d..92049e681258 100644 --- a/trunk/include/net/tcp.h +++ b/trunk/include/net/tcp.h @@ -803,7 +803,7 @@ static inline int tcp_is_cwnd_limited(const struct sock *sk, u32 in_flight) return left <= tcp_max_burst(tp); } -static inline void tcp_minshall_update(struct tcp_sock *tp, unsigned int mss, +static inline void tcp_minshall_update(struct tcp_sock *tp, int mss, const struct sk_buff *skb) { if (skb->len < mss) diff --git a/trunk/include/net/xfrm.h b/trunk/include/net/xfrm.h index 58dfa82889aa..688f6f5d3285 100644 --- a/trunk/include/net/xfrm.h +++ b/trunk/include/net/xfrm.h @@ -37,8 +37,6 @@ extern struct sock *xfrm_nl; extern u32 sysctl_xfrm_aevent_etime; extern u32 sysctl_xfrm_aevent_rseqth; -extern int sysctl_xfrm_larval_drop; -extern u32 sysctl_xfrm_acq_expires; extern struct mutex xfrm_cfg_mutex; diff --git a/trunk/include/scsi/scsi_eh.h b/trunk/include/scsi/scsi_eh.h index d21b8913ceb3..44224ba4dd90 100644 --- a/trunk/include/scsi/scsi_eh.h +++ b/trunk/include/scsi/scsi_eh.h @@ -1,8 +1,6 @@ #ifndef _SCSI_SCSI_EH_H #define _SCSI_SCSI_EH_H -#include - #include struct scsi_device; struct Scsi_Host; diff --git a/trunk/init/Kconfig b/trunk/init/Kconfig index 8b88d0bedcbd..b7dffa837926 100644 --- a/trunk/init/Kconfig +++ b/trunk/init/Kconfig @@ -322,6 +322,7 @@ config CPUSETS config FAIR_GROUP_SCHED bool "Fair group CPU scheduler" default y + depends on EXPERIMENTAL help This feature lets CPU scheduler recognize task groups and control CPU bandwidth allocation to such task groups. diff --git a/trunk/kernel/cgroup.c b/trunk/kernel/cgroup.c index 3fe21e19c96e..5987dccdb2a0 100644 --- a/trunk/kernel/cgroup.c +++ b/trunk/kernel/cgroup.c @@ -2402,6 +2402,7 @@ struct file_operations proc_cgroup_operations = { static int proc_cgroupstats_show(struct seq_file *m, void *v) { int i; + struct cgroupfs_root *root; seq_puts(m, "#subsys_name\thierarchy\tnum_cgroups\n"); mutex_lock(&cgroup_mutex); diff --git a/trunk/kernel/fork.c b/trunk/kernel/fork.c index 28a740151988..ddafdfac9456 100644 --- a/trunk/kernel/fork.c +++ b/trunk/kernel/fork.c @@ -1056,8 +1056,6 @@ static struct task_struct *copy_process(unsigned long clone_flags, p->gtime = cputime_zero; p->utimescaled = cputime_zero; p->stimescaled = cputime_zero; - p->prev_utime = cputime_zero; - p->prev_stime = cputime_zero; #ifdef CONFIG_TASK_XACCT p->rchar = 0; /* I/O counter: bytes read */ diff --git a/trunk/kernel/hrtimer.c b/trunk/kernel/hrtimer.c index 22a25142e4cf..b6d2ff7e37ee 100644 --- a/trunk/kernel/hrtimer.c +++ b/trunk/kernel/hrtimer.c @@ -602,7 +602,7 @@ static int hrtimer_switch_to_hres(void) /* "Retrigger" the interrupt to get things going */ retrigger_next_event(NULL); local_irq_restore(flags); - printk(KERN_DEBUG "Switched to high resolution mode on CPU %d\n", + printk(KERN_INFO "Switched to high resolution mode on CPU %d\n", smp_processor_id()); return 1; } diff --git a/trunk/kernel/profile.c b/trunk/kernel/profile.c index 5e95330e5120..631b75c25d7e 100644 --- a/trunk/kernel/profile.c +++ b/trunk/kernel/profile.c @@ -60,7 +60,6 @@ static int __init profile_setup(char * str) int par; if (!strncmp(str, sleepstr, strlen(sleepstr))) { -#ifdef CONFIG_SCHEDSTATS prof_on = SLEEP_PROFILING; if (str[strlen(sleepstr)] == ',') str += strlen(sleepstr) + 1; @@ -69,10 +68,6 @@ static int __init profile_setup(char * str) printk(KERN_INFO "kernel sleep profiling enabled (shift: %ld)\n", prof_shift); -#else - printk(KERN_WARNING - "kernel sleep profiling requires CONFIG_SCHEDSTATS\n"); -#endif /* CONFIG_SCHEDSTATS */ } else if (!strncmp(str, schedstr, strlen(schedstr))) { prof_on = SCHED_PROFILING; if (str[strlen(schedstr)] == ',') diff --git a/trunk/kernel/sched.c b/trunk/kernel/sched.c index 3f6bd1112900..2810e562a991 100644 --- a/trunk/kernel/sched.c +++ b/trunk/kernel/sched.c @@ -66,7 +66,6 @@ #include #include -#include /* * Scheduler clock - returns current time in nanosec units. @@ -172,7 +171,6 @@ struct task_group { unsigned long shares; /* spinlock to serialize modification to shares */ spinlock_t lock; - struct rcu_head rcu; }; /* Default task group's sched entity on each cpu */ @@ -259,6 +257,7 @@ struct cfs_rq { */ struct list_head leaf_cfs_rq_list; /* Better name : task_cfs_rq_list? */ struct task_group *tg; /* group that "owns" this runqueue */ + struct rcu_head rcu; #endif }; @@ -838,18 +837,11 @@ struct rq_iterator { struct task_struct *(*next)(void *); }; -#ifdef CONFIG_SMP -static unsigned long -balance_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest, - unsigned long max_load_move, struct sched_domain *sd, - enum cpu_idle_type idle, int *all_pinned, - int *this_best_prio, struct rq_iterator *iterator); - -static int -iter_move_one_task(struct rq *this_rq, int this_cpu, struct rq *busiest, - struct sched_domain *sd, enum cpu_idle_type idle, - struct rq_iterator *iterator); -#endif +static int balance_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest, + unsigned long max_nr_move, unsigned long max_load_move, + struct sched_domain *sd, enum cpu_idle_type idle, + int *all_pinned, unsigned long *load_moved, + int *this_best_prio, struct rq_iterator *iterator); #include "sched_stats.h" #include "sched_idletask.c" @@ -2231,17 +2223,17 @@ int can_migrate_task(struct task_struct *p, struct rq *rq, int this_cpu, return 1; } -static unsigned long -balance_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest, - unsigned long max_load_move, struct sched_domain *sd, - enum cpu_idle_type idle, int *all_pinned, - int *this_best_prio, struct rq_iterator *iterator) +static int balance_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest, + unsigned long max_nr_move, unsigned long max_load_move, + struct sched_domain *sd, enum cpu_idle_type idle, + int *all_pinned, unsigned long *load_moved, + int *this_best_prio, struct rq_iterator *iterator) { int pulled = 0, pinned = 0, skip_for_load; struct task_struct *p; long rem_load_move = max_load_move; - if (max_load_move == 0) + if (max_nr_move == 0 || max_load_move == 0) goto out; pinned = 1; @@ -2274,7 +2266,7 @@ balance_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest, * We only want to steal up to the prescribed number of tasks * and the prescribed amount of weighted load. */ - if (rem_load_move > 0) { + if (pulled < max_nr_move && rem_load_move > 0) { if (p->prio < *this_best_prio) *this_best_prio = p->prio; p = iterator->next(iterator->arg); @@ -2282,7 +2274,7 @@ balance_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest, } out: /* - * Right now, this is one of only two places pull_task() is called, + * Right now, this is the only place pull_task() is called, * so we can safely collect pull_task() stats here rather than * inside pull_task(). */ @@ -2290,8 +2282,8 @@ balance_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest, if (all_pinned) *all_pinned = pinned; - - return max_load_move - rem_load_move; + *load_moved = max_load_move - rem_load_move; + return pulled; } /* @@ -2313,7 +2305,7 @@ static int move_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest, do { total_load_moved += class->load_balance(this_rq, this_cpu, busiest, - max_load_move - total_load_moved, + ULONG_MAX, max_load_move - total_load_moved, sd, idle, all_pinned, &this_best_prio); class = class->next; } while (class && max_load_move > total_load_moved); @@ -2321,32 +2313,6 @@ static int move_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest, return total_load_moved > 0; } -static int -iter_move_one_task(struct rq *this_rq, int this_cpu, struct rq *busiest, - struct sched_domain *sd, enum cpu_idle_type idle, - struct rq_iterator *iterator) -{ - struct task_struct *p = iterator->start(iterator->arg); - int pinned = 0; - - while (p) { - if (can_migrate_task(p, busiest, this_cpu, sd, idle, &pinned)) { - pull_task(busiest, p, this_rq, this_cpu); - /* - * Right now, this is only the second place pull_task() - * is called, so we can safely collect pull_task() - * stats here rather than inside pull_task(). - */ - schedstat_inc(sd, lb_gained[idle]); - - return 1; - } - p = iterator->next(iterator->arg); - } - - return 0; -} - /* * move_one_task tries to move exactly one task from busiest to this_rq, as * part of active balancing operations within "domain". @@ -2358,9 +2324,12 @@ static int move_one_task(struct rq *this_rq, int this_cpu, struct rq *busiest, struct sched_domain *sd, enum cpu_idle_type idle) { const struct sched_class *class; + int this_best_prio = MAX_PRIO; for (class = sched_class_highest; class; class = class->next) - if (class->move_one_task(this_rq, this_cpu, busiest, sd, idle)) + if (class->load_balance(this_rq, this_cpu, busiest, + 1, ULONG_MAX, sd, idle, NULL, + &this_best_prio)) return 1; return 0; @@ -3297,6 +3266,18 @@ static inline void idle_balance(int cpu, struct rq *rq) { } +/* Avoid "used but not defined" warning on UP */ +static int balance_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest, + unsigned long max_nr_move, unsigned long max_load_move, + struct sched_domain *sd, enum cpu_idle_type idle, + int *all_pinned, unsigned long *load_moved, + int *this_best_prio, struct rq_iterator *iterator) +{ + *load_moved = 0; + + return 0; +} + #endif DEFINE_PER_CPU(struct kernel_stat, kstat); @@ -3355,7 +3336,7 @@ void account_user_time(struct task_struct *p, cputime_t cputime) * @p: the process that the cpu time gets accounted to * @cputime: the cpu time spent in virtual machine since the last update */ -static void account_guest_time(struct task_struct *p, cputime_t cputime) +void account_guest_time(struct task_struct *p, cputime_t cputime) { cputime64_t tmp; struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; @@ -3526,19 +3507,12 @@ EXPORT_SYMBOL(sub_preempt_count); */ static noinline void __schedule_bug(struct task_struct *prev) { - struct pt_regs *regs = get_irq_regs(); - - printk(KERN_ERR "BUG: scheduling while atomic: %s/%d/0x%08x\n", - prev->comm, prev->pid, preempt_count()); - + printk(KERN_ERR "BUG: scheduling while atomic: %s/0x%08x/%d\n", + prev->comm, preempt_count(), task_pid_nr(prev)); debug_show_held_locks(prev); if (irqs_disabled()) print_irqtrace_events(prev); - - if (regs) - show_regs(regs); - else - dump_stack(); + dump_stack(); } /* @@ -3846,7 +3820,7 @@ __wake_up_sync(wait_queue_head_t *q, unsigned int mode, int nr_exclusive) } EXPORT_SYMBOL_GPL(__wake_up_sync); /* For internal use only */ -void complete(struct completion *x) +void fastcall complete(struct completion *x) { unsigned long flags; @@ -3858,7 +3832,7 @@ void complete(struct completion *x) } EXPORT_SYMBOL(complete); -void complete_all(struct completion *x) +void fastcall complete_all(struct completion *x) { unsigned long flags; @@ -3910,13 +3884,13 @@ wait_for_common(struct completion *x, long timeout, int state) return timeout; } -void __sched wait_for_completion(struct completion *x) +void fastcall __sched wait_for_completion(struct completion *x) { wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_UNINTERRUPTIBLE); } EXPORT_SYMBOL(wait_for_completion); -unsigned long __sched +unsigned long fastcall __sched wait_for_completion_timeout(struct completion *x, unsigned long timeout) { return wait_for_common(x, timeout, TASK_UNINTERRUPTIBLE); @@ -3932,7 +3906,7 @@ int __sched wait_for_completion_interruptible(struct completion *x) } EXPORT_SYMBOL(wait_for_completion_interruptible); -unsigned long __sched +unsigned long fastcall __sched wait_for_completion_interruptible_timeout(struct completion *x, unsigned long timeout) { @@ -5365,7 +5339,7 @@ static struct ctl_table sd_ctl_dir[] = { .procname = "sched_domain", .mode = 0555, }, - {0, }, + {0,}, }; static struct ctl_table sd_ctl_root[] = { @@ -5375,7 +5349,7 @@ static struct ctl_table sd_ctl_root[] = { .mode = 0555, .child = sd_ctl_dir, }, - {0, }, + {0,}, }; static struct ctl_table *sd_alloc_ctl_entry(int n) @@ -5487,12 +5461,11 @@ static void register_sched_domain_sysctl(void) struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1); char buf[32]; - WARN_ON(sd_ctl_dir[0].child); - sd_ctl_dir[0].child = entry; - if (entry == NULL) return; + sd_ctl_dir[0].child = entry; + for_each_online_cpu(i) { snprintf(buf, 32, "cpu%d", i); entry->procname = kstrdup(buf, GFP_KERNEL); @@ -5500,19 +5473,14 @@ static void register_sched_domain_sysctl(void) entry->child = sd_alloc_ctl_cpu_table(i); entry++; } - - WARN_ON(sd_sysctl_header); sd_sysctl_header = register_sysctl_table(sd_ctl_root); } -/* may be called multiple times per register */ static void unregister_sched_domain_sysctl(void) { - if (sd_sysctl_header) - unregister_sysctl_table(sd_sysctl_header); + unregister_sysctl_table(sd_sysctl_header); sd_sysctl_header = NULL; - if (sd_ctl_dir[0].child) - sd_free_ctl_entry(&sd_ctl_dir[0].child); + sd_free_ctl_entry(&sd_ctl_dir[0].child); } #else static void register_sched_domain_sysctl(void) @@ -5643,101 +5611,101 @@ int nr_cpu_ids __read_mostly = NR_CPUS; EXPORT_SYMBOL(nr_cpu_ids); #ifdef CONFIG_SCHED_DEBUG - -static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level) +static void sched_domain_debug(struct sched_domain *sd, int cpu) { - struct sched_group *group = sd->groups; - cpumask_t groupmask; - char str[NR_CPUS]; - - cpumask_scnprintf(str, NR_CPUS, sd->span); - cpus_clear(groupmask); - - printk(KERN_DEBUG "%*s domain %d: ", level, "", level); + int level = 0; - if (!(sd->flags & SD_LOAD_BALANCE)) { - printk("does not load-balance\n"); - if (sd->parent) - printk(KERN_ERR "ERROR: !SD_LOAD_BALANCE domain" - " has parent"); - return -1; + if (!sd) { + printk(KERN_DEBUG "CPU%d attaching NULL sched-domain.\n", cpu); + return; } - printk(KERN_CONT "span %s\n", str); - - if (!cpu_isset(cpu, sd->span)) { - printk(KERN_ERR "ERROR: domain->span does not contain " - "CPU%d\n", cpu); - } - if (!cpu_isset(cpu, group->cpumask)) { - printk(KERN_ERR "ERROR: domain->groups does not contain" - " CPU%d\n", cpu); - } + printk(KERN_DEBUG "CPU%d attaching sched-domain:\n", cpu); - printk(KERN_DEBUG "%*s groups:", level + 1, ""); do { - if (!group) { - printk("\n"); - printk(KERN_ERR "ERROR: group is NULL\n"); - break; - } - - if (!group->__cpu_power) { - printk(KERN_CONT "\n"); - printk(KERN_ERR "ERROR: domain->cpu_power not " - "set\n"); + int i; + char str[NR_CPUS]; + struct sched_group *group = sd->groups; + cpumask_t groupmask; + + cpumask_scnprintf(str, NR_CPUS, sd->span); + cpus_clear(groupmask); + + printk(KERN_DEBUG); + for (i = 0; i < level + 1; i++) + printk(" "); + printk("domain %d: ", level); + + if (!(sd->flags & SD_LOAD_BALANCE)) { + printk("does not load-balance\n"); + if (sd->parent) + printk(KERN_ERR "ERROR: !SD_LOAD_BALANCE domain" + " has parent"); break; } - if (!cpus_weight(group->cpumask)) { - printk(KERN_CONT "\n"); - printk(KERN_ERR "ERROR: empty group\n"); - break; - } + printk("span %s\n", str); - if (cpus_intersects(groupmask, group->cpumask)) { - printk(KERN_CONT "\n"); - printk(KERN_ERR "ERROR: repeated CPUs\n"); - break; - } + if (!cpu_isset(cpu, sd->span)) + printk(KERN_ERR "ERROR: domain->span does not contain " + "CPU%d\n", cpu); + if (!cpu_isset(cpu, group->cpumask)) + printk(KERN_ERR "ERROR: domain->groups does not contain" + " CPU%d\n", cpu); - cpus_or(groupmask, groupmask, group->cpumask); + printk(KERN_DEBUG); + for (i = 0; i < level + 2; i++) + printk(" "); + printk("groups:"); + do { + if (!group) { + printk("\n"); + printk(KERN_ERR "ERROR: group is NULL\n"); + break; + } - cpumask_scnprintf(str, NR_CPUS, group->cpumask); - printk(KERN_CONT " %s", str); + if (!group->__cpu_power) { + printk(KERN_CONT "\n"); + printk(KERN_ERR "ERROR: domain->cpu_power not " + "set\n"); + break; + } - group = group->next; - } while (group != sd->groups); - printk(KERN_CONT "\n"); + if (!cpus_weight(group->cpumask)) { + printk(KERN_CONT "\n"); + printk(KERN_ERR "ERROR: empty group\n"); + break; + } - if (!cpus_equal(sd->span, groupmask)) - printk(KERN_ERR "ERROR: groups don't span domain->span\n"); + if (cpus_intersects(groupmask, group->cpumask)) { + printk(KERN_CONT "\n"); + printk(KERN_ERR "ERROR: repeated CPUs\n"); + break; + } - if (sd->parent && !cpus_subset(groupmask, sd->parent->span)) - printk(KERN_ERR "ERROR: parent span is not a superset " - "of domain->span\n"); - return 0; -} + cpus_or(groupmask, groupmask, group->cpumask); -static void sched_domain_debug(struct sched_domain *sd, int cpu) -{ - int level = 0; + cpumask_scnprintf(str, NR_CPUS, group->cpumask); + printk(KERN_CONT " %s", str); - if (!sd) { - printk(KERN_DEBUG "CPU%d attaching NULL sched-domain.\n", cpu); - return; - } + group = group->next; + } while (group != sd->groups); + printk(KERN_CONT "\n"); - printk(KERN_DEBUG "CPU%d attaching sched-domain:\n", cpu); + if (!cpus_equal(sd->span, groupmask)) + printk(KERN_ERR "ERROR: groups don't span " + "domain->span\n"); - for (;;) { - if (sched_domain_debug_one(sd, cpu, level)) - break; level++; sd = sd->parent; if (!sd) - break; - } + continue; + + if (!cpus_subset(groupmask, sd->span)) + printk(KERN_ERR "ERROR: parent span is not a superset " + "of domain->span\n"); + + } while (sd); } #else # define sched_domain_debug(sd, cpu) do { } while (0) @@ -6456,17 +6424,13 @@ static cpumask_t fallback_doms; */ static int arch_init_sched_domains(const cpumask_t *cpu_map) { - int err; - ndoms_cur = 1; doms_cur = kmalloc(sizeof(cpumask_t), GFP_KERNEL); if (!doms_cur) doms_cur = &fallback_doms; cpus_andnot(*doms_cur, *cpu_map, cpu_isolated_map); - err = build_sched_domains(doms_cur); register_sched_domain_sysctl(); - - return err; + return build_sched_domains(doms_cur); } static void arch_destroy_sched_domains(const cpumask_t *cpu_map) @@ -6515,9 +6479,6 @@ void partition_sched_domains(int ndoms_new, cpumask_t *doms_new) { int i, j; - /* always unregister in case we don't destroy any domains */ - unregister_sched_domain_sysctl(); - if (doms_new == NULL) { ndoms_new = 1; doms_new = &fallback_doms; @@ -6553,8 +6514,6 @@ void partition_sched_domains(int ndoms_new, cpumask_t *doms_new) kfree(doms_cur); doms_cur = doms_new; ndoms_cur = ndoms_new; - - register_sched_domain_sysctl(); } #if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) @@ -7019,8 +6978,8 @@ struct task_group *sched_create_group(void) /* rcu callback to free various structures associated with a task group */ static void free_sched_group(struct rcu_head *rhp) { - struct task_group *tg = container_of(rhp, struct task_group, rcu); - struct cfs_rq *cfs_rq; + struct cfs_rq *cfs_rq = container_of(rhp, struct cfs_rq, rcu); + struct task_group *tg = cfs_rq->tg; struct sched_entity *se; int i; @@ -7041,7 +7000,7 @@ static void free_sched_group(struct rcu_head *rhp) /* Destroy runqueue etc associated with a task group */ void sched_destroy_group(struct task_group *tg) { - struct cfs_rq *cfs_rq = NULL; + struct cfs_rq *cfs_rq; int i; for_each_possible_cpu(i) { @@ -7049,10 +7008,10 @@ void sched_destroy_group(struct task_group *tg) list_del_rcu(&cfs_rq->leaf_cfs_rq_list); } - BUG_ON(!cfs_rq); + cfs_rq = tg->cfs_rq[0]; /* wait for possible concurrent references to cfs_rqs complete */ - call_rcu(&tg->rcu, free_sched_group); + call_rcu(&cfs_rq->rcu, free_sched_group); } /* change task's runqueue when it moves between groups. @@ -7142,25 +7101,25 @@ unsigned long sched_group_shares(struct task_group *tg) #ifdef CONFIG_FAIR_CGROUP_SCHED /* return corresponding task_group object of a cgroup */ -static inline struct task_group *cgroup_tg(struct cgroup *cgrp) +static inline struct task_group *cgroup_tg(struct cgroup *cont) { - return container_of(cgroup_subsys_state(cgrp, cpu_cgroup_subsys_id), - struct task_group, css); + return container_of(cgroup_subsys_state(cont, cpu_cgroup_subsys_id), + struct task_group, css); } static struct cgroup_subsys_state * -cpu_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cgrp) +cpu_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont) { struct task_group *tg; - if (!cgrp->parent) { + if (!cont->parent) { /* This is early initialization for the top cgroup */ - init_task_group.css.cgroup = cgrp; + init_task_group.css.cgroup = cont; return &init_task_group.css; } /* we support only 1-level deep hierarchical scheduler atm */ - if (cgrp->parent->parent) + if (cont->parent->parent) return ERR_PTR(-EINVAL); tg = sched_create_group(); @@ -7168,21 +7127,21 @@ cpu_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cgrp) return ERR_PTR(-ENOMEM); /* Bind the cgroup to task_group object we just created */ - tg->css.cgroup = cgrp; + tg->css.cgroup = cont; return &tg->css; } static void cpu_cgroup_destroy(struct cgroup_subsys *ss, - struct cgroup *cgrp) + struct cgroup *cont) { - struct task_group *tg = cgroup_tg(cgrp); + struct task_group *tg = cgroup_tg(cont); sched_destroy_group(tg); } static int cpu_cgroup_can_attach(struct cgroup_subsys *ss, - struct cgroup *cgrp, struct task_struct *tsk) + struct cgroup *cont, struct task_struct *tsk) { /* We don't support RT-tasks being in separate groups */ if (tsk->sched_class != &fair_sched_class) @@ -7192,72 +7151,61 @@ static int cpu_cgroup_can_attach(struct cgroup_subsys *ss, } static void -cpu_cgroup_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, +cpu_cgroup_attach(struct cgroup_subsys *ss, struct cgroup *cont, struct cgroup *old_cont, struct task_struct *tsk) { sched_move_task(tsk); } -static int cpu_shares_write_uint(struct cgroup *cgrp, struct cftype *cftype, - u64 shareval) +static ssize_t cpu_shares_write(struct cgroup *cont, struct cftype *cftype, + struct file *file, const char __user *userbuf, + size_t nbytes, loff_t *ppos) { - return sched_group_set_shares(cgroup_tg(cgrp), shareval); -} + unsigned long shareval; + struct task_group *tg = cgroup_tg(cont); + char buffer[2*sizeof(unsigned long) + 1]; + int rc; -static u64 cpu_shares_read_uint(struct cgroup *cgrp, struct cftype *cft) -{ - struct task_group *tg = cgroup_tg(cgrp); + if (nbytes > 2*sizeof(unsigned long)) /* safety check */ + return -E2BIG; - return (u64) tg->shares; + if (copy_from_user(buffer, userbuf, nbytes)) + return -EFAULT; + + buffer[nbytes] = 0; /* nul-terminate */ + shareval = simple_strtoul(buffer, NULL, 10); + + rc = sched_group_set_shares(tg, shareval); + + return (rc < 0 ? rc : nbytes); } -static u64 cpu_usage_read(struct cgroup *cgrp, struct cftype *cft) +static u64 cpu_shares_read_uint(struct cgroup *cont, struct cftype *cft) { - struct task_group *tg = cgroup_tg(cgrp); - unsigned long flags; - u64 res = 0; - int i; + struct task_group *tg = cgroup_tg(cont); - for_each_possible_cpu(i) { - /* - * Lock to prevent races with updating 64-bit counters - * on 32-bit arches. - */ - spin_lock_irqsave(&cpu_rq(i)->lock, flags); - res += tg->se[i]->sum_exec_runtime; - spin_unlock_irqrestore(&cpu_rq(i)->lock, flags); - } - /* Convert from ns to ms */ - do_div(res, 1000000); - - return res; + return (u64) tg->shares; } -static struct cftype cpu_files[] = { - { - .name = "shares", - .read_uint = cpu_shares_read_uint, - .write_uint = cpu_shares_write_uint, - }, - { - .name = "usage", - .read_uint = cpu_usage_read, - }, +static struct cftype cpu_shares = { + .name = "shares", + .read_uint = cpu_shares_read_uint, + .write = cpu_shares_write, }; static int cpu_cgroup_populate(struct cgroup_subsys *ss, struct cgroup *cont) { - return cgroup_add_files(cont, ss, cpu_files, ARRAY_SIZE(cpu_files)); + return cgroup_add_file(cont, ss, &cpu_shares); } struct cgroup_subsys cpu_cgroup_subsys = { - .name = "cpu", - .create = cpu_cgroup_create, - .destroy = cpu_cgroup_destroy, - .can_attach = cpu_cgroup_can_attach, - .attach = cpu_cgroup_attach, - .populate = cpu_cgroup_populate, - .subsys_id = cpu_cgroup_subsys_id, + .name = "cpu", + .create = cpu_cgroup_create, + .destroy = cpu_cgroup_destroy, + .can_attach = cpu_cgroup_can_attach, + .attach = cpu_cgroup_attach, + .populate = cpu_cgroup_populate, + .subsys_id = cpu_cgroup_subsys_id, .early_init = 1, }; diff --git a/trunk/kernel/sched_fair.c b/trunk/kernel/sched_fair.c index 01859f662ab7..166ed6db600b 100644 --- a/trunk/kernel/sched_fair.c +++ b/trunk/kernel/sched_fair.c @@ -876,7 +876,6 @@ static void put_prev_task_fair(struct rq *rq, struct task_struct *prev) } } -#ifdef CONFIG_SMP /************************************************** * Fair scheduling class load-balancing methods: */ @@ -937,11 +936,12 @@ static int cfs_rq_best_prio(struct cfs_rq *cfs_rq) static unsigned long load_balance_fair(struct rq *this_rq, int this_cpu, struct rq *busiest, - unsigned long max_load_move, + unsigned long max_nr_move, unsigned long max_load_move, struct sched_domain *sd, enum cpu_idle_type idle, int *all_pinned, int *this_best_prio) { struct cfs_rq *busy_cfs_rq; + unsigned long load_moved, total_nr_moved = 0, nr_moved; long rem_load_move = max_load_move; struct rq_iterator cfs_rq_iterator; @@ -969,48 +969,25 @@ load_balance_fair(struct rq *this_rq, int this_cpu, struct rq *busiest, #else # define maxload rem_load_move #endif - /* - * pass busy_cfs_rq argument into + /* pass busy_cfs_rq argument into * load_balance_[start|next]_fair iterators */ cfs_rq_iterator.arg = busy_cfs_rq; - rem_load_move -= balance_tasks(this_rq, this_cpu, busiest, - maxload, sd, idle, all_pinned, - this_best_prio, - &cfs_rq_iterator); + nr_moved = balance_tasks(this_rq, this_cpu, busiest, + max_nr_move, maxload, sd, idle, all_pinned, + &load_moved, this_best_prio, &cfs_rq_iterator); + + total_nr_moved += nr_moved; + max_nr_move -= nr_moved; + rem_load_move -= load_moved; - if (rem_load_move <= 0) + if (max_nr_move <= 0 || rem_load_move <= 0) break; } return max_load_move - rem_load_move; } -static int -move_one_task_fair(struct rq *this_rq, int this_cpu, struct rq *busiest, - struct sched_domain *sd, enum cpu_idle_type idle) -{ - struct cfs_rq *busy_cfs_rq; - struct rq_iterator cfs_rq_iterator; - - cfs_rq_iterator.start = load_balance_start_fair; - cfs_rq_iterator.next = load_balance_next_fair; - - for_each_leaf_cfs_rq(busiest, busy_cfs_rq) { - /* - * pass busy_cfs_rq argument into - * load_balance_[start|next]_fair iterators - */ - cfs_rq_iterator.arg = busy_cfs_rq; - if (iter_move_one_task(this_rq, this_cpu, busiest, sd, idle, - &cfs_rq_iterator)) - return 1; - } - - return 0; -} -#endif - /* * scheduler tick hitting a task of our scheduling class: */ @@ -1025,7 +1002,7 @@ static void task_tick_fair(struct rq *rq, struct task_struct *curr) } } -#define swap(a, b) do { typeof(a) tmp = (a); (a) = (b); (b) = tmp; } while (0) +#define swap(a,b) do { typeof(a) tmp = (a); (a) = (b); (b) = tmp; } while (0) /* * Share the fairness runtime between parent and child, thus the @@ -1086,10 +1063,7 @@ static const struct sched_class fair_sched_class = { .pick_next_task = pick_next_task_fair, .put_prev_task = put_prev_task_fair, -#ifdef CONFIG_SMP .load_balance = load_balance_fair, - .move_one_task = move_one_task_fair, -#endif .set_curr_task = set_curr_task_fair, .task_tick = task_tick_fair, diff --git a/trunk/kernel/sched_idletask.c b/trunk/kernel/sched_idletask.c index bf9c25c15b8b..6e2ead41516e 100644 --- a/trunk/kernel/sched_idletask.c +++ b/trunk/kernel/sched_idletask.c @@ -37,24 +37,15 @@ static void put_prev_task_idle(struct rq *rq, struct task_struct *prev) { } -#ifdef CONFIG_SMP static unsigned long load_balance_idle(struct rq *this_rq, int this_cpu, struct rq *busiest, - unsigned long max_load_move, - struct sched_domain *sd, enum cpu_idle_type idle, - int *all_pinned, int *this_best_prio) + unsigned long max_nr_move, unsigned long max_load_move, + struct sched_domain *sd, enum cpu_idle_type idle, + int *all_pinned, int *this_best_prio) { return 0; } -static int -move_one_task_idle(struct rq *this_rq, int this_cpu, struct rq *busiest, - struct sched_domain *sd, enum cpu_idle_type idle) -{ - return 0; -} -#endif - static void task_tick_idle(struct rq *rq, struct task_struct *curr) { } @@ -78,10 +69,7 @@ const struct sched_class idle_sched_class = { .pick_next_task = pick_next_task_idle, .put_prev_task = put_prev_task_idle, -#ifdef CONFIG_SMP .load_balance = load_balance_idle, - .move_one_task = move_one_task_idle, -#endif .set_curr_task = set_curr_task_idle, .task_tick = task_tick_idle, diff --git a/trunk/kernel/sched_rt.c b/trunk/kernel/sched_rt.c index 8abd752a0ebd..d0097a0634e5 100644 --- a/trunk/kernel/sched_rt.c +++ b/trunk/kernel/sched_rt.c @@ -98,7 +98,6 @@ static void put_prev_task_rt(struct rq *rq, struct task_struct *p) p->se.exec_start = 0; } -#ifdef CONFIG_SMP /* * Load-balancing iterator. Note: while the runqueue stays locked * during the whole iteration, the current task might be @@ -173,11 +172,13 @@ static struct task_struct *load_balance_next_rt(void *arg) static unsigned long load_balance_rt(struct rq *this_rq, int this_cpu, struct rq *busiest, - unsigned long max_load_move, - struct sched_domain *sd, enum cpu_idle_type idle, - int *all_pinned, int *this_best_prio) + unsigned long max_nr_move, unsigned long max_load_move, + struct sched_domain *sd, enum cpu_idle_type idle, + int *all_pinned, int *this_best_prio) { + int nr_moved; struct rq_iterator rt_rq_iterator; + unsigned long load_moved; rt_rq_iterator.start = load_balance_start_rt; rt_rq_iterator.next = load_balance_next_rt; @@ -186,24 +187,12 @@ load_balance_rt(struct rq *this_rq, int this_cpu, struct rq *busiest, */ rt_rq_iterator.arg = busiest; - return balance_tasks(this_rq, this_cpu, busiest, max_load_move, sd, - idle, all_pinned, this_best_prio, &rt_rq_iterator); -} - -static int -move_one_task_rt(struct rq *this_rq, int this_cpu, struct rq *busiest, - struct sched_domain *sd, enum cpu_idle_type idle) -{ - struct rq_iterator rt_rq_iterator; - - rt_rq_iterator.start = load_balance_start_rt; - rt_rq_iterator.next = load_balance_next_rt; - rt_rq_iterator.arg = busiest; + nr_moved = balance_tasks(this_rq, this_cpu, busiest, max_nr_move, + max_load_move, sd, idle, all_pinned, &load_moved, + this_best_prio, &rt_rq_iterator); - return iter_move_one_task(this_rq, this_cpu, busiest, sd, idle, - &rt_rq_iterator); + return load_moved; } -#endif static void task_tick_rt(struct rq *rq, struct task_struct *p) { @@ -247,10 +236,7 @@ const struct sched_class rt_sched_class = { .pick_next_task = pick_next_task_rt, .put_prev_task = put_prev_task_rt, -#ifdef CONFIG_SMP .load_balance = load_balance_rt, - .move_one_task = move_one_task_rt, -#endif .set_curr_task = set_curr_task_rt, .task_tick = task_tick_rt, diff --git a/trunk/kernel/signal.c b/trunk/kernel/signal.c index 909a0cc6bc70..12006308c7eb 100644 --- a/trunk/kernel/signal.c +++ b/trunk/kernel/signal.c @@ -124,7 +124,7 @@ void recalc_sigpending_and_wake(struct task_struct *t) void recalc_sigpending(void) { - if (!recalc_sigpending_tsk(current) && !freezing(current)) + if (!recalc_sigpending_tsk(current)) clear_thread_flag(TIF_SIGPENDING); } @@ -732,7 +732,7 @@ static void print_fatal_signal(struct pt_regs *regs, int signr) printk("%s/%d: potentially unexpected fatal signal %d.\n", current->comm, task_pid_nr(current), signr); -#if defined(__i386__) && !defined(__arch_um__) +#ifdef __i386__ printk("code at %08lx: ", regs->eip); { int i; diff --git a/trunk/kernel/time/tick-sched.c b/trunk/kernel/time/tick-sched.c index 5997456ebbc9..10a1347597fd 100644 --- a/trunk/kernel/time/tick-sched.c +++ b/trunk/kernel/time/tick-sched.c @@ -320,6 +320,8 @@ ktime_t tick_nohz_get_sleep_length(void) return ts->sleep_length; } +EXPORT_SYMBOL_GPL(tick_nohz_get_sleep_length); + /** * nohz_restart_sched_tick - restart the idle tick from the idle task * diff --git a/trunk/kernel/time/timer_list.c b/trunk/kernel/time/timer_list.c index 12c5f4cb6b8c..fdb2e03d4fe0 100644 --- a/trunk/kernel/time/timer_list.c +++ b/trunk/kernel/time/timer_list.c @@ -129,8 +129,7 @@ static void print_cpu(struct seq_file *m, int cpu, u64 now) struct hrtimer_cpu_base *cpu_base = &per_cpu(hrtimer_bases, cpu); int i; - SEQ_printf(m, "\n"); - SEQ_printf(m, "cpu: %d\n", cpu); + SEQ_printf(m, "\ncpu: %d\n", cpu); for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) { SEQ_printf(m, " clock %d:\n", i); print_base(m, cpu_base->clock_base + i, now); @@ -185,8 +184,7 @@ print_tickdevice(struct seq_file *m, struct tick_device *td) { struct clock_event_device *dev = td->evtdev; - SEQ_printf(m, "\n"); - SEQ_printf(m, "Tick Device: mode: %d\n", td->mode); + SEQ_printf(m, "\nTick Device: mode: %d\n", td->mode); SEQ_printf(m, "Clock Event Device: "); if (!dev) { diff --git a/trunk/kernel/user.c b/trunk/kernel/user.c index 0f3aa0234107..e91331c457e2 100644 --- a/trunk/kernel/user.c +++ b/trunk/kernel/user.c @@ -129,7 +129,7 @@ static inline void uids_mutex_unlock(void) } /* return cpu shares held by the user */ -static ssize_t cpu_shares_show(struct kset *kset, char *buffer) +ssize_t cpu_shares_show(struct kset *kset, char *buffer) { struct user_struct *up = container_of(kset, struct user_struct, kset); @@ -137,8 +137,7 @@ static ssize_t cpu_shares_show(struct kset *kset, char *buffer) } /* modify cpu shares held by the user */ -static ssize_t cpu_shares_store(struct kset *kset, const char *buffer, - size_t size) +ssize_t cpu_shares_store(struct kset *kset, const char *buffer, size_t size) { struct user_struct *up = container_of(kset, struct user_struct, kset); unsigned long shares; diff --git a/trunk/lib/Kconfig.debug b/trunk/lib/Kconfig.debug index 1e5f207b9074..1faa5087dc86 100644 --- a/trunk/lib/Kconfig.debug +++ b/trunk/lib/Kconfig.debug @@ -9,14 +9,6 @@ config PRINTK_TIME operations. This is useful for identifying long delays in kernel startup. -config ENABLE_WARN_DEPRECATED - bool "Enable __deprecated logic" - default y - help - Enable the __deprecated logic in the kernel build. - Disable this to suppress the "warning: 'foo' is deprecated - (declared at kernel/power/somefile.c:1234)" messages. - config ENABLE_MUST_CHECK bool "Enable __must_check logic" default y diff --git a/trunk/mm/filemap.c b/trunk/mm/filemap.c index 9940895f734c..5209e47b7fe3 100644 --- a/trunk/mm/filemap.c +++ b/trunk/mm/filemap.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -2511,17 +2510,21 @@ generic_file_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, } retval = mapping->a_ops->direct_IO(rw, iocb, iov, offset, nr_segs); + if (retval) + goto out; /* * Finally, try again to invalidate clean pages which might have been - * cached by non-direct readahead, or faulted in by get_user_pages() - * if the source of the write was an mmap'ed region of the file - * we're writing. Either one is a pretty crazy thing to do, - * so we don't support it 100%. If this invalidation - * fails, tough, the write still worked... + * faulted in by get_user_pages() if the source of the write was an + * mmap()ed region of the file we're writing. That's a pretty crazy + * thing to do, so we don't support it 100%. If this invalidation + * fails and we have -EIOCBQUEUED we ignore the failure. */ if (rw == WRITE && mapping->nrpages) { - invalidate_inode_pages2_range(mapping, offset >> PAGE_CACHE_SHIFT, end); + int err = invalidate_inode_pages2_range(mapping, + offset >> PAGE_CACHE_SHIFT, end); + if (err && retval >= 0) + retval = err; } out: return retval; diff --git a/trunk/mm/nommu.c b/trunk/mm/nommu.c index 35622c590925..8f09333f78e1 100644 --- a/trunk/mm/nommu.c +++ b/trunk/mm/nommu.c @@ -12,7 +12,6 @@ * Copyright (c) 2002 Greg Ungerer */ -#include #include #include #include diff --git a/trunk/mm/shmem.c b/trunk/mm/shmem.c index 253d205914ba..404e53bb2127 100644 --- a/trunk/mm/shmem.c +++ b/trunk/mm/shmem.c @@ -915,21 +915,6 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc) struct inode *inode; BUG_ON(!PageLocked(page)); - /* - * shmem_backing_dev_info's capabilities prevent regular writeback or - * sync from ever calling shmem_writepage; but a stacking filesystem - * may use the ->writepage of its underlying filesystem, in which case - * we want to do nothing when that underlying filesystem is tmpfs - * (writing out to swap is useful as a response to memory pressure, but - * of no use to stabilize the data) - just redirty the page, unlock it - * and claim success in this case. AOP_WRITEPAGE_ACTIVATE, and the - * page_mapped check below, must be avoided unless we're in reclaim. - */ - if (!wbc->for_reclaim) { - set_page_dirty(page); - unlock_page(page); - return 0; - } BUG_ON(page_mapped(page)); mapping = page->mapping; diff --git a/trunk/mm/slub.c b/trunk/mm/slub.c index bcdb2c8941a5..aac1dd3c657d 100644 --- a/trunk/mm/slub.c +++ b/trunk/mm/slub.c @@ -2734,7 +2734,7 @@ static void slab_mem_offline_callback(void *arg) * and offline_pages() function shoudn't call this * callback. So, we must fail. */ - BUG_ON(atomic_long_read(&n->nr_slabs)); + BUG_ON(atomic_read(&n->nr_slabs)); s->node[offline_node] = NULL; kmem_cache_free(kmalloc_caches, n); diff --git a/trunk/mm/sparse-vmemmap.c b/trunk/mm/sparse-vmemmap.c index 22620f6a976b..d3b718b0c20a 100644 --- a/trunk/mm/sparse-vmemmap.c +++ b/trunk/mm/sparse-vmemmap.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include diff --git a/trunk/mm/sparse.c b/trunk/mm/sparse.c index e06f514fe04f..08fb14f5eea3 100644 --- a/trunk/mm/sparse.c +++ b/trunk/mm/sparse.c @@ -220,6 +220,12 @@ static int __meminit sparse_init_one_section(struct mem_section *ms, return 1; } +__attribute__((weak)) __init +void *alloc_bootmem_high_node(pg_data_t *pgdat, unsigned long size) +{ + return NULL; +} + static unsigned long usemap_size(void) { unsigned long size_bytes; @@ -261,6 +267,11 @@ struct page __init *sparse_mem_map_populate(unsigned long pnum, int nid) if (map) return map; + map = alloc_bootmem_high_node(NODE_DATA(nid), + sizeof(struct page) * PAGES_PER_SECTION); + if (map) + return map; + map = alloc_bootmem_node(NODE_DATA(nid), sizeof(struct page) * PAGES_PER_SECTION); return map; diff --git a/trunk/net/9p/Kconfig b/trunk/net/9p/Kconfig index bafc50c9e6ff..71bc110aebf8 100644 --- a/trunk/net/9p/Kconfig +++ b/trunk/net/9p/Kconfig @@ -23,13 +23,6 @@ config NET_9P_FD file descriptors. TCP/IP is the default transport for 9p, so if you are going to use 9p, you'll likely want this. -config NET_9P_VIRTIO - depends on NET_9P && EXPERIMENTAL && VIRTIO - tristate "9P Virtio Transport (Experimental)" - help - This builds support for a transports between - guest partitions and a host partition. - config NET_9P_DEBUG bool "Debug information" depends on NET_9P diff --git a/trunk/net/9p/Makefile b/trunk/net/9p/Makefile index d3abb246ccab..5059bc06f8f3 100644 --- a/trunk/net/9p/Makefile +++ b/trunk/net/9p/Makefile @@ -1,6 +1,5 @@ obj-$(CONFIG_NET_9P) := 9pnet.o obj-$(CONFIG_NET_9P_FD) += 9pnet_fd.o -obj-$(CONFIG_NET_9P_VIRTIO) += 9pnet_virtio.o 9pnet-objs := \ mod.o \ @@ -13,6 +12,3 @@ obj-$(CONFIG_NET_9P_VIRTIO) += 9pnet_virtio.o 9pnet_fd-objs := \ trans_fd.o \ - -9pnet_virtio-objs := \ - trans_virtio.o \ diff --git a/trunk/net/9p/mux.c b/trunk/net/9p/mux.c index c9f0805048e4..f14014793bed 100644 --- a/trunk/net/9p/mux.c +++ b/trunk/net/9p/mux.c @@ -222,10 +222,8 @@ static int p9_mux_poll_start(struct p9_conn *m) } if (i >= ARRAY_SIZE(p9_mux_poll_tasks)) { - if (vptlast == NULL) { - mutex_unlock(&p9_mux_task_lock); + if (vptlast == NULL) return -ENOMEM; - } P9_DPRINTK(P9_DEBUG_MUX, "put in proc %d\n", i); list_add(&m->mux_list, &vptlast->mux_list); diff --git a/trunk/net/9p/trans_virtio.c b/trunk/net/9p/trans_virtio.c deleted file mode 100644 index 40b71a29fc3f..000000000000 --- a/trunk/net/9p/trans_virtio.c +++ /dev/null @@ -1,353 +0,0 @@ -/* - * The Guest 9p transport driver - * - * This is a trivial pipe-based transport driver based on the lguest console - * code: we use lguest's DMA mechanism to send bytes out, and register a - * DMA buffer to receive bytes in. It is assumed to be present and available - * from the very beginning of boot. - * - * This may be have been done by just instaniating another HVC console, - * but HVC's blocksize of 16 bytes is annoying and painful to performance. - * - * A more efficient transport could be built based on the virtio block driver - * but it requires some changes in the 9p transport model (which are in - * progress) - * - */ -/* - * Copyright (C) 2007 Eric Van Hensbergen, IBM Corporation - * - * Based on virtio console driver - * Copyright (C) 2006, 2007 Rusty Russell, IBM Corporation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to: - * Free Software Foundation - * 51 Franklin Street, Fifth Floor - * Boston, MA 02111-1301 USA - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* a single mutex to manage channel initialization and attachment */ -static DECLARE_MUTEX(virtio_9p_lock); -/* global which tracks highest initialized channel */ -static int chan_index; - -/* We keep all per-channel information in a structure. - * This structure is allocated within the devices dev->mem space. - * A pointer to the structure will get put in the transport private. - */ -static struct virtio_chan { - bool initialized; /* channel is initialized */ - bool inuse; /* channel is in use */ - - struct virtqueue *in_vq, *out_vq; - struct virtio_device *vdev; - - /* This is our input buffer, and how much data is left in it. */ - unsigned int in_len; - char *in, *inbuf; - - wait_queue_head_t wq; /* waitq for buffer */ -} channels[MAX_9P_CHAN]; - -/* How many bytes left in this page. */ -static unsigned int rest_of_page(void *data) -{ - return PAGE_SIZE - ((unsigned long)data % PAGE_SIZE); -} - -static int p9_virtio_write(struct p9_trans *trans, void *buf, int count) -{ - struct virtio_chan *chan = (struct virtio_chan *) trans->priv; - struct virtqueue *out_vq = chan->out_vq; - struct scatterlist sg[1]; - unsigned int len; - - P9_DPRINTK(P9_DEBUG_TRANS, "9p debug: virtio write (%d)\n", count); - - /* keep it simple - make sure we don't overflow a page */ - if (rest_of_page(buf) < count) - count = rest_of_page(buf); - - sg_init_one(sg, buf, count); - - /* add_buf wants a token to identify this buffer: we hand it any - * non-NULL pointer, since there's only ever one buffer. */ - if (out_vq->vq_ops->add_buf(out_vq, sg, 1, 0, (void *)1) == 0) { - /* Tell Host to go! */ - out_vq->vq_ops->kick(out_vq); - /* Chill out until it's done with the buffer. */ - while (!out_vq->vq_ops->get_buf(out_vq, &len)) - cpu_relax(); - } - - P9_DPRINTK(P9_DEBUG_TRANS, "9p debug: virtio wrote (%d)\n", count); - - /* We're expected to return the amount of data we wrote: all of it. */ - return count; -} - -/* Create a scatter-gather list representing our input buffer and put it in the - * queue. */ -static void add_inbuf(struct virtio_chan *chan) -{ - struct scatterlist sg[1]; - - sg_init_one(sg, chan->inbuf, PAGE_SIZE); - - /* We should always be able to add one buffer to an empty queue. */ - if (chan->in_vq->vq_ops->add_buf(chan->in_vq, sg, 0, 1, chan->inbuf)) - BUG(); - chan->in_vq->vq_ops->kick(chan->in_vq); -} - -static int p9_virtio_read(struct p9_trans *trans, void *buf, int count) -{ - struct virtio_chan *chan = (struct virtio_chan *) trans->priv; - struct virtqueue *in_vq = chan->in_vq; - - P9_DPRINTK(P9_DEBUG_TRANS, "9p debug: virtio read (%d)\n", count); - - /* If we don't have an input queue yet, we can't get input. */ - BUG_ON(!in_vq); - - /* No buffer? Try to get one. */ - if (!chan->in_len) { - chan->in = in_vq->vq_ops->get_buf(in_vq, &chan->in_len); - if (!chan->in) - return 0; - } - - /* You want more than we have to give? Well, try wanting less! */ - if (chan->in_len < count) - count = chan->in_len; - - /* Copy across to their buffer and increment offset. */ - memcpy(buf, chan->in, count); - chan->in += count; - chan->in_len -= count; - - /* Finished? Re-register buffer so Host will use it again. */ - if (chan->in_len == 0) - add_inbuf(chan); - - P9_DPRINTK(P9_DEBUG_TRANS, "9p debug: virtio finished read (%d)\n", - count); - - return count; -} - -/* The poll function is used by 9p transports to determine if there - * is there is activity available on a particular channel. In our case - * we use it to wait for a callback from the input routines. - */ -static unsigned int -p9_virtio_poll(struct p9_trans *trans, struct poll_table_struct *pt) -{ - struct virtio_chan *chan = (struct virtio_chan *)trans->priv; - struct virtqueue *in_vq = chan->in_vq; - int ret = POLLOUT; /* we can always handle more output */ - - poll_wait(NULL, &chan->wq, pt); - - /* No buffer? Try to get one. */ - if (!chan->in_len) - chan->in = in_vq->vq_ops->get_buf(in_vq, &chan->in_len); - - if (chan->in_len) - ret |= POLLIN; - - return ret; -} - -static void p9_virtio_close(struct p9_trans *trans) -{ - struct virtio_chan *chan = trans->priv; - - down(&virtio_9p_lock); - chan->inuse = false; - up(&virtio_9p_lock); - - kfree(trans); -} - -static bool p9_virtio_intr(struct virtqueue *q) -{ - struct virtio_chan *chan = q->vdev->priv; - - P9_DPRINTK(P9_DEBUG_TRANS, "9p poll_wakeup: %p\n", &chan->wq); - wake_up_interruptible(&chan->wq); - - return true; -} - -static int p9_virtio_probe(struct virtio_device *dev) -{ - int err; - struct virtio_chan *chan; - int index; - - down(&virtio_9p_lock); - index = chan_index++; - chan = &channels[index]; - up(&virtio_9p_lock); - - if (chan_index > MAX_9P_CHAN) { - printk(KERN_ERR "9p: virtio: Maximum channels exceeded\n"); - BUG(); - } - - chan->vdev = dev; - - /* This is the scratch page we use to receive console input */ - chan->inbuf = kmalloc(PAGE_SIZE, GFP_KERNEL); - if (!chan->inbuf) { - err = -ENOMEM; - goto fail; - } - - /* Find the input queue. */ - dev->priv = chan; - chan->in_vq = dev->config->find_vq(dev, p9_virtio_intr); - if (IS_ERR(chan->in_vq)) { - err = PTR_ERR(chan->in_vq); - goto free; - } - - chan->out_vq = dev->config->find_vq(dev, NULL); - if (IS_ERR(chan->out_vq)) { - err = PTR_ERR(chan->out_vq); - goto free_in_vq; - } - - init_waitqueue_head(&chan->wq); - - /* Register the input buffer the first time. */ - add_inbuf(chan); - chan->inuse = false; - chan->initialized = true; - - return 0; - -free_in_vq: - dev->config->del_vq(chan->in_vq); -free: - kfree(chan->inbuf); -fail: - down(&virtio_9p_lock); - chan_index--; - up(&virtio_9p_lock); - return err; -} - -/* This sets up a transport channel for 9p communication. Right now - * we only match the first available channel, but eventually we couldlook up - * alternate channels by matching devname versus a virtio_config entry. - * We use a simple reference count mechanism to ensure that only a single - * mount has a channel open at a time. */ -static struct p9_trans *p9_virtio_create(const char *devname, char *args) -{ - struct p9_trans *trans; - int index = 0; - struct virtio_chan *chan = channels; - - down(&virtio_9p_lock); - while (index < MAX_9P_CHAN) { - if (chan->initialized && !chan->inuse) { - chan->inuse = true; - break; - } else { - index++; - chan = &channels[index]; - } - } - up(&virtio_9p_lock); - - if (index >= MAX_9P_CHAN) { - printk(KERN_ERR "9p: virtio: couldn't find a free channel\n"); - return NULL; - } - - trans = kmalloc(sizeof(struct p9_trans), GFP_KERNEL); - if (!trans) { - printk(KERN_ERR "9p: couldn't allocate transport\n"); - return ERR_PTR(-ENOMEM); - } - - trans->write = p9_virtio_write; - trans->read = p9_virtio_read; - trans->close = p9_virtio_close; - trans->poll = p9_virtio_poll; - trans->priv = chan; - - return trans; -} - -#define VIRTIO_ID_9P 9 - -static struct virtio_device_id id_table[] = { - { VIRTIO_ID_9P, VIRTIO_DEV_ANY_ID }, - { 0 }, -}; - -/* The standard "struct lguest_driver": */ -static struct virtio_driver p9_virtio_drv = { - .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, - .id_table = id_table, - .probe = p9_virtio_probe, -}; - -static struct p9_trans_module p9_virtio_trans = { - .name = "virtio", - .create = p9_virtio_create, - .maxsize = PAGE_SIZE, - .def = 0, -}; - -/* The standard init function */ -static int __init p9_virtio_init(void) -{ - int count; - - for (count = 0; count < MAX_9P_CHAN; count++) - channels[count].initialized = false; - - v9fs_register_trans(&p9_virtio_trans); - return register_virtio_driver(&p9_virtio_drv); -} - -module_init(p9_virtio_init); - -MODULE_DEVICE_TABLE(virtio, id_table); -MODULE_AUTHOR("Eric Van Hensbergen "); -MODULE_DESCRIPTION("Virtio 9p Transport"); -MODULE_LICENSE("GPL"); diff --git a/trunk/net/core/dev.c b/trunk/net/core/dev.c index 02e7d8377c4a..872658927e47 100644 --- a/trunk/net/core/dev.c +++ b/trunk/net/core/dev.c @@ -120,8 +120,6 @@ #include #include -#include "net-sysfs.h" - /* * The list of packet types we will receive (as opposed to discard) * and the routines to invoke. @@ -251,6 +249,10 @@ static RAW_NOTIFIER_HEAD(netdev_chain); DEFINE_PER_CPU(struct softnet_data, softnet_data); +extern int netdev_kobject_init(void); +extern int netdev_register_kobject(struct net_device *); +extern void netdev_unregister_kobject(struct net_device *); + #ifdef CONFIG_DEBUG_LOCK_ALLOC /* * register_netdevice() inits dev->_xmit_lock and sets lockdep class @@ -883,9 +885,6 @@ int dev_change_name(struct net_device *dev, char *newname) if (!dev_valid_name(newname)) return -EINVAL; - if (strncmp(newname, dev->name, IFNAMSIZ) == 0) - return 0; - memcpy(oldname, dev->name, IFNAMSIZ); if (strchr(newname, '%')) { @@ -1008,20 +1007,17 @@ int dev_open(struct net_device *dev) * Call device private open method */ set_bit(__LINK_STATE_START, &dev->state); - - if (dev->validate_addr) - ret = dev->validate_addr(dev); - - if (!ret && dev->open) + if (dev->open) { ret = dev->open(dev); + if (ret) + clear_bit(__LINK_STATE_START, &dev->state); + } /* * If it went open OK then: */ - if (ret) - clear_bit(__LINK_STATE_START, &dev->state); - else { + if (!ret) { /* * Set the flags. */ @@ -1042,7 +1038,6 @@ int dev_open(struct net_device *dev) */ call_netdevice_notifiers(NETDEV_UP, dev); } - return ret; } @@ -2172,15 +2167,7 @@ static void net_rx_action(struct softirq_action *h) weight = n->weight; - /* This NAPI_STATE_SCHED test is for avoiding a race - * with netpoll's poll_napi(). Only the entity which - * obtains the lock and sees NAPI_STATE_SCHED set will - * actually make the ->poll() call. Therefore we avoid - * accidently calling ->poll() when NAPI is not scheduled. - */ - work = 0; - if (test_bit(NAPI_STATE_SCHED, &n->state)) - work = n->poll(n, weight); + work = n->poll(n, weight); WARN_ON_ONCE(work > weight); @@ -2676,7 +2663,7 @@ static void __net_exit dev_proc_net_exit(struct net *net) proc_net_remove(net, "dev"); } -static struct pernet_operations dev_proc_ops = { +static struct pernet_operations __net_initdata dev_proc_ops = { .init = dev_proc_net_init, .exit = dev_proc_net_exit, }; @@ -4336,7 +4323,7 @@ static void __net_exit netdev_exit(struct net *net) kfree(net->dev_index_head); } -static struct pernet_operations netdev_net_ops = { +static struct pernet_operations __net_initdata netdev_net_ops = { .init = netdev_init, .exit = netdev_exit, }; @@ -4367,7 +4354,7 @@ static void __net_exit default_device_exit(struct net *net) rtnl_unlock(); } -static struct pernet_operations default_device_ops = { +static struct pernet_operations __net_initdata default_device_ops = { .exit = default_device_exit, }; diff --git a/trunk/net/core/dev_mcast.c b/trunk/net/core/dev_mcast.c index ae354057d84c..15241cf48af8 100644 --- a/trunk/net/core/dev_mcast.c +++ b/trunk/net/core/dev_mcast.c @@ -285,7 +285,7 @@ static void __net_exit dev_mc_net_exit(struct net *net) proc_net_remove(net, "dev_mcast"); } -static struct pernet_operations dev_mc_net_ops = { +static struct pernet_operations __net_initdata dev_mc_net_ops = { .init = dev_mc_net_init, .exit = dev_mc_net_exit, }; diff --git a/trunk/net/core/flow.c b/trunk/net/core/flow.c index 3ed2b4b1d6d4..0ab5234b17d8 100644 --- a/trunk/net/core/flow.c +++ b/trunk/net/core/flow.c @@ -142,6 +142,8 @@ typedef u64 flow_compare_t; typedef u32 flow_compare_t; #endif +extern void flowi_is_missized(void); + /* I hear what you're saying, use memcmp. But memcmp cannot make * important assumptions that we can here, such as alignment and * constant size. @@ -151,7 +153,8 @@ static int flow_key_compare(struct flowi *key1, struct flowi *key2) flow_compare_t *k1, *k1_lim, *k2; const int n_elem = sizeof(struct flowi) / sizeof(flow_compare_t); - BUILD_BUG_ON(sizeof(struct flowi) % sizeof(flow_compare_t)); + if (sizeof(struct flowi) % sizeof(flow_compare_t)) + flowi_is_missized(); k1 = (flow_compare_t *) key1; k1_lim = k1 + n_elem; diff --git a/trunk/net/core/net-sysfs.c b/trunk/net/core/net-sysfs.c index 61ead1d11132..6628e457ddc0 100644 --- a/trunk/net/core/net-sysfs.c +++ b/trunk/net/core/net-sysfs.c @@ -18,8 +18,6 @@ #include #include -#include "net-sysfs.h" - #ifdef CONFIG_SYSFS static const char fmt_hex[] = "%#x\n"; static const char fmt_long_hex[] = "%#lx\n"; diff --git a/trunk/net/core/net-sysfs.h b/trunk/net/core/net-sysfs.h deleted file mode 100644 index f5f108db3924..000000000000 --- a/trunk/net/core/net-sysfs.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __NET_SYSFS_H__ -#define __NET_SYSFS_H__ - -int netdev_kobject_init(void); -int netdev_register_kobject(struct net_device *); -void netdev_unregister_kobject(struct net_device *); - -#endif diff --git a/trunk/net/core/netpoll.c b/trunk/net/core/netpoll.c index c499b5c69bed..bf8d18f1b013 100644 --- a/trunk/net/core/netpoll.c +++ b/trunk/net/core/netpoll.c @@ -116,29 +116,6 @@ static __sum16 checksum_udp(struct sk_buff *skb, struct udphdr *uh, * network adapter, forcing superfluous retries and possibly timeouts. * Thus, we set our budget to greater than 1. */ -static int poll_one_napi(struct netpoll_info *npinfo, - struct napi_struct *napi, int budget) -{ - int work; - - /* net_rx_action's ->poll() invocations and our's are - * synchronized by this test which is only made while - * holding the napi->poll_lock. - */ - if (!test_bit(NAPI_STATE_SCHED, &napi->state)) - return budget; - - npinfo->rx_flags |= NETPOLL_RX_DROP; - atomic_inc(&trapped); - - work = napi->poll(napi, budget); - - atomic_dec(&trapped); - npinfo->rx_flags &= ~NETPOLL_RX_DROP; - - return budget - work; -} - static void poll_napi(struct netpoll *np) { struct netpoll_info *npinfo = np->dev->npinfo; @@ -146,13 +123,17 @@ static void poll_napi(struct netpoll *np) int budget = 16; list_for_each_entry(napi, &np->dev->napi_list, dev_list) { - if (napi->poll_owner != smp_processor_id() && + if (test_bit(NAPI_STATE_SCHED, &napi->state) && + napi->poll_owner != smp_processor_id() && spin_trylock(&napi->poll_lock)) { - budget = poll_one_napi(npinfo, napi, budget); - spin_unlock(&napi->poll_lock); + npinfo->rx_flags |= NETPOLL_RX_DROP; + atomic_inc(&trapped); - if (!budget) - break; + napi->poll(napi, budget); + + atomic_dec(&trapped); + npinfo->rx_flags &= ~NETPOLL_RX_DROP; + spin_unlock(&napi->poll_lock); } } } diff --git a/trunk/net/core/rtnetlink.c b/trunk/net/core/rtnetlink.c index e1ba26fb4bf2..4a2640d38261 100644 --- a/trunk/net/core/rtnetlink.c +++ b/trunk/net/core/rtnetlink.c @@ -742,7 +742,7 @@ static struct net *get_net_ns_by_pid(pid_t pid) /* Lookup the network namespace */ net = ERR_PTR(-ESRCH); rcu_read_lock(); - tsk = find_task_by_vpid(pid); + tsk = find_task_by_pid(pid); if (tsk) { struct nsproxy *nsproxy; nsproxy = task_nsproxy(tsk); diff --git a/trunk/net/core/skbuff.c b/trunk/net/core/skbuff.c index 573e17240197..4e2c84fcf276 100644 --- a/trunk/net/core/skbuff.c +++ b/trunk/net/core/skbuff.c @@ -415,6 +415,13 @@ static struct sk_buff *__skb_clone(struct sk_buff *n, struct sk_buff *skb) n->hdr_len = skb->nohdr ? skb_headroom(skb) : skb->hdr_len; n->nohdr = 0; n->destructor = NULL; +#ifdef CONFIG_NET_CLS_ACT + /* FIXME What is this and why don't we do it in copy_skb_header? */ + n->tc_verd = SET_TC_VERD(n->tc_verd,0); + n->tc_verd = CLR_TC_OK2MUNGE(n->tc_verd); + n->tc_verd = CLR_TC_MUNGED(n->tc_verd); + C(iif); +#endif C(truesize); atomic_set(&n->users, 1); C(head); @@ -2038,7 +2045,9 @@ skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len) if (copy > 0) { if (copy > len) copy = len; - sg_set_buf(sg, skb->data + offset, copy); + sg_set_page(&sg[elt], virt_to_page(skb->data + offset)); + sg[elt].offset = (unsigned long)(skb->data + offset) % PAGE_SIZE; + sg[elt].length = copy; elt++; if ((len -= copy) == 0) return elt; @@ -2056,8 +2065,9 @@ skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len) if (copy > len) copy = len; - sg_set_page(&sg[elt], frag->page, copy, - frag->page_offset+offset-start); + sg_set_page(&sg[elt], frag->page); + sg[elt].offset = frag->page_offset+offset-start; + sg[elt].length = copy; elt++; if (!(len -= copy)) return elt; diff --git a/trunk/net/core/sock.c b/trunk/net/core/sock.c index bba9949681ff..febbcbcf8022 100644 --- a/trunk/net/core/sock.c +++ b/trunk/net/core/sock.c @@ -1649,6 +1649,7 @@ void sock_enable_timestamp(struct sock *sk) net_enable_timestamp(); } } +EXPORT_SYMBOL(sock_enable_timestamp); /* * Get a socket option on an socket. diff --git a/trunk/net/core/sysctl_net_core.c b/trunk/net/core/sysctl_net_core.c index 113cc728dc31..6d5ea9762040 100644 --- a/trunk/net/core/sysctl_net_core.c +++ b/trunk/net/core/sysctl_net_core.c @@ -9,12 +9,25 @@ #include #include #include -#include #include -#include #ifdef CONFIG_SYSCTL +extern int netdev_max_backlog; +extern int weight_p; + +extern __u32 sysctl_wmem_max; +extern __u32 sysctl_rmem_max; + +extern int sysctl_core_destroy_delay; + +#ifdef CONFIG_XFRM +extern u32 sysctl_xfrm_aevent_etime; +extern u32 sysctl_xfrm_aevent_rseqth; +extern int sysctl_xfrm_larval_drop; +extern u32 sysctl_xfrm_acq_expires; +#endif + ctl_table core_table[] = { #ifdef CONFIG_NET { diff --git a/trunk/net/dccp/ccids/ccid2.c b/trunk/net/dccp/ccids/ccid2.c index d694656b8800..426008e3b7e3 100644 --- a/trunk/net/dccp/ccids/ccid2.c +++ b/trunk/net/dccp/ccids/ccid2.c @@ -750,16 +750,20 @@ static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk) */ hctx->ccid2hctx_ssthresh = ~0; hctx->ccid2hctx_numdupack = 3; + hctx->ccid2hctx_seqbufc = 0; /* XXX init ~ to window size... */ if (ccid2_hc_tx_alloc_seq(hctx)) return -ENOMEM; + hctx->ccid2hctx_sent = 0; hctx->ccid2hctx_rto = 3 * HZ; ccid2_change_srtt(hctx, -1); hctx->ccid2hctx_rttvar = -1; + hctx->ccid2hctx_lastrtt = 0; hctx->ccid2hctx_rpdupack = -1; hctx->ccid2hctx_last_cong = jiffies; + hctx->ccid2hctx_high_ack = 0; hctx->ccid2hctx_rtotimer.function = &ccid2_hc_tx_rto_expire; hctx->ccid2hctx_rtotimer.data = (unsigned long)sk; diff --git a/trunk/net/dccp/ccids/ccid3.c b/trunk/net/dccp/ccids/ccid3.c index 19b33586333d..25772c326172 100644 --- a/trunk/net/dccp/ccids/ccid3.c +++ b/trunk/net/dccp/ccids/ccid3.c @@ -40,8 +40,6 @@ #include "lib/tfrc.h" #include "ccid3.h" -#include - #ifdef CONFIG_IP_DCCP_CCID3_DEBUG static int ccid3_debug; #define ccid3_pr_debug(format, a...) DCCP_PR_DEBUG(ccid3_debug, format, ##a) @@ -546,7 +544,6 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option, const struct dccp_sock *dp = dccp_sk(sk); struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); struct ccid3_options_received *opt_recv; - __be32 opt_val; opt_recv = &hctx->ccid3hctx_options_received; @@ -566,8 +563,8 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option, dccp_role(sk), sk, len); rc = -EINVAL; } else { - opt_val = get_unaligned((__be32 *)value); - opt_recv->ccid3or_loss_event_rate = ntohl(opt_val); + opt_recv->ccid3or_loss_event_rate = + ntohl(*(__be32 *)value); ccid3_pr_debug("%s(%p), LOSS_EVENT_RATE=%u\n", dccp_role(sk), sk, opt_recv->ccid3or_loss_event_rate); @@ -588,8 +585,8 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option, dccp_role(sk), sk, len); rc = -EINVAL; } else { - opt_val = get_unaligned((__be32 *)value); - opt_recv->ccid3or_receive_rate = ntohl(opt_val); + opt_recv->ccid3or_receive_rate = + ntohl(*(__be32 *)value); ccid3_pr_debug("%s(%p), RECEIVE_RATE=%u\n", dccp_role(sk), sk, opt_recv->ccid3or_receive_rate); @@ -604,6 +601,8 @@ static int ccid3_hc_tx_init(struct ccid *ccid, struct sock *sk) { struct ccid3_hc_tx_sock *hctx = ccid_priv(ccid); + hctx->ccid3hctx_s = 0; + hctx->ccid3hctx_rtt = 0; hctx->ccid3hctx_state = TFRC_SSTATE_NO_SENT; INIT_LIST_HEAD(&hctx->ccid3hctx_hist); @@ -964,6 +963,8 @@ static int ccid3_hc_rx_init(struct ccid *ccid, struct sock *sk) INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist); hcrx->ccid3hcrx_tstamp_last_feedback = hcrx->ccid3hcrx_tstamp_last_ack = ktime_get_real(); + hcrx->ccid3hcrx_s = 0; + hcrx->ccid3hcrx_rtt = 0; return 0; } diff --git a/trunk/net/dccp/input.c b/trunk/net/dccp/input.c index 1ce101062824..3560a2a875a0 100644 --- a/trunk/net/dccp/input.c +++ b/trunk/net/dccp/input.c @@ -58,42 +58,6 @@ static void dccp_rcv_closereq(struct sock *sk, struct sk_buff *skb) dccp_send_close(sk, 0); } -static u8 dccp_reset_code_convert(const u8 code) -{ - const u8 error_code[] = { - [DCCP_RESET_CODE_CLOSED] = 0, /* normal termination */ - [DCCP_RESET_CODE_UNSPECIFIED] = 0, /* nothing known */ - [DCCP_RESET_CODE_ABORTED] = ECONNRESET, - - [DCCP_RESET_CODE_NO_CONNECTION] = ECONNREFUSED, - [DCCP_RESET_CODE_CONNECTION_REFUSED] = ECONNREFUSED, - [DCCP_RESET_CODE_TOO_BUSY] = EUSERS, - [DCCP_RESET_CODE_AGGRESSION_PENALTY] = EDQUOT, - - [DCCP_RESET_CODE_PACKET_ERROR] = ENOMSG, - [DCCP_RESET_CODE_BAD_INIT_COOKIE] = EBADR, - [DCCP_RESET_CODE_BAD_SERVICE_CODE] = EBADRQC, - [DCCP_RESET_CODE_OPTION_ERROR] = EILSEQ, - [DCCP_RESET_CODE_MANDATORY_ERROR] = EOPNOTSUPP, - }; - - return code >= DCCP_MAX_RESET_CODES ? 0 : error_code[code]; -} - -static void dccp_rcv_reset(struct sock *sk, struct sk_buff *skb) -{ - u8 err = dccp_reset_code_convert(dccp_hdr_reset(skb)->dccph_reset_code); - - sk->sk_err = err; - - /* Queue the equivalent of TCP fin so that dccp_recvmsg exits the loop */ - dccp_fin(sk, skb); - - if (err && !sock_flag(sk, SOCK_DEAD)) - sk_wake_async(sk, 0, POLL_ERR); - dccp_time_wait(sk, DCCP_TIME_WAIT, 0); -} - static void dccp_event_ack_recv(struct sock *sk, struct sk_buff *skb) { struct dccp_sock *dp = dccp_sk(sk); @@ -227,8 +191,9 @@ static int __dccp_rcv_established(struct sock *sk, struct sk_buff *skb, * S.state := TIMEWAIT * Set TIMEWAIT timer * Drop packet and return - */ - dccp_rcv_reset(sk, skb); + */ + dccp_fin(sk, skb); + dccp_time_wait(sk, DCCP_TIME_WAIT, 0); return 0; case DCCP_PKT_CLOSEREQ: dccp_rcv_closereq(sk, skb); @@ -556,7 +521,12 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, * Drop packet and return */ if (dh->dccph_type == DCCP_PKT_RESET) { - dccp_rcv_reset(sk, skb); + /* + * Queue the equivalent of TCP fin so that dccp_recvmsg + * exits the loop + */ + dccp_fin(sk, skb); + dccp_time_wait(sk, DCCP_TIME_WAIT, 0); return 0; /* * Step 7: Check for unexpected packet types diff --git a/trunk/net/dccp/ipv4.c b/trunk/net/dccp/ipv4.c index 01a6a808bdb7..222549ab274a 100644 --- a/trunk/net/dccp/ipv4.c +++ b/trunk/net/dccp/ipv4.c @@ -241,8 +241,8 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info) goto out; dp = dccp_sk(sk); - seq = dccp_hdr_seq(dh); - if ((1 << sk->sk_state) & ~(DCCPF_REQUESTING | DCCPF_LISTEN) && + seq = dccp_hdr_seq(skb); + if (sk->sk_state != DCCP_LISTEN && !between48(seq, dp->dccps_swl, dp->dccps_swh)) { NET_INC_STATS_BH(LINUX_MIB_OUTOFWINDOWICMPS); goto out; @@ -795,7 +795,7 @@ static int dccp_v4_rcv(struct sk_buff *skb) dh = dccp_hdr(skb); - DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(dh); + DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(skb); DCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type; dccp_pr_debug("%8.8s " diff --git a/trunk/net/dccp/ipv6.c b/trunk/net/dccp/ipv6.c index 62428ff137dd..bbadd6681b83 100644 --- a/trunk/net/dccp/ipv6.c +++ b/trunk/net/dccp/ipv6.c @@ -173,7 +173,7 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, icmpv6_err_convert(type, code, &err); - seq = dccp_hdr_seq(dh); + seq = DCCP_SKB_CB(skb)->dccpd_seq; /* Might be for an request_sock */ switch (sk->sk_state) { struct request_sock *req, **prev; @@ -787,7 +787,7 @@ static int dccp_v6_rcv(struct sk_buff *skb) dh = dccp_hdr(skb); - DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(dh); + DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(skb); DCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type; if (dccp_packet_without_ack(skb)) diff --git a/trunk/net/dccp/options.c b/trunk/net/dccp/options.c index d286cffe2c49..d361b5533309 100644 --- a/trunk/net/dccp/options.c +++ b/trunk/net/dccp/options.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include @@ -60,7 +59,6 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) unsigned char opt, len; unsigned char *value; u32 elapsed_time; - __be32 opt_val; int rc; int mandatory = 0; @@ -147,8 +145,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) if (len != 4) goto out_invalid_option; - opt_val = get_unaligned((__be32 *)value); - opt_recv->dccpor_timestamp = ntohl(opt_val); + opt_recv->dccpor_timestamp = ntohl(*(__be32 *)value); dp->dccps_timestamp_echo = opt_recv->dccpor_timestamp; dp->dccps_timestamp_time = ktime_get_real(); @@ -162,8 +159,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) if (len != 4 && len != 6 && len != 8) goto out_invalid_option; - opt_val = get_unaligned((__be32 *)value); - opt_recv->dccpor_timestamp_echo = ntohl(opt_val); + opt_recv->dccpor_timestamp_echo = ntohl(*(__be32 *)value); dccp_pr_debug("%s rx opt: TIMESTAMP_ECHO=%u, len=%d, " "ackno=%llu", dccp_role(sk), @@ -172,20 +168,16 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) (unsigned long long) DCCP_SKB_CB(skb)->dccpd_ack_seq); - value += 4; - if (len == 4) { /* no elapsed time included */ + if (len == 4) { dccp_pr_debug_cat("\n"); break; } - if (len == 6) { /* 2-byte elapsed time */ - __be16 opt_val2 = get_unaligned((__be16 *)value); - elapsed_time = ntohs(opt_val2); - } else { /* 4-byte elapsed time */ - opt_val = get_unaligned((__be32 *)value); - elapsed_time = ntohl(opt_val); - } + if (len == 6) + elapsed_time = ntohs(*(__be16 *)(value + 4)); + else + elapsed_time = ntohl(*(__be32 *)(value + 4)); dccp_pr_debug_cat(", ELAPSED_TIME=%u\n", elapsed_time); @@ -200,13 +192,10 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) if (pkt_type == DCCP_PKT_DATA) continue; - if (len == 2) { - __be16 opt_val2 = get_unaligned((__be16 *)value); - elapsed_time = ntohs(opt_val2); - } else { - opt_val = get_unaligned((__be32 *)value); - elapsed_time = ntohl(opt_val); - } + if (len == 2) + elapsed_time = ntohs(*(__be16 *)value); + else + elapsed_time = ntohl(*(__be32 *)value); if (elapsed_time > opt_recv->dccpor_elapsed_time) opt_recv->dccpor_elapsed_time = elapsed_time; diff --git a/trunk/net/dccp/proto.c b/trunk/net/dccp/proto.c index d84973928033..cc9bf1cb2646 100644 --- a/trunk/net/dccp/proto.c +++ b/trunk/net/dccp/proto.c @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -379,36 +378,8 @@ EXPORT_SYMBOL_GPL(dccp_poll); int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg) { - int rc = -ENOTCONN; - - lock_sock(sk); - - if (sk->sk_state == DCCP_LISTEN) - goto out; - - switch (cmd) { - case SIOCINQ: { - struct sk_buff *skb; - unsigned long amount = 0; - - skb = skb_peek(&sk->sk_receive_queue); - if (skb != NULL) { - /* - * We will only return the amount of this packet since - * that is all that will be read. - */ - amount = skb->len; - } - rc = put_user(amount, (int __user *)arg); - } - break; - default: - rc = -ENOIOCTLCMD; - break; - } -out: - release_sock(sk); - return rc; + dccp_pr_debug("entry\n"); + return -ENOIOCTLCMD; } EXPORT_SYMBOL_GPL(dccp_ioctl); diff --git a/trunk/net/ethernet/eth.c b/trunk/net/ethernet/eth.c index 6b2e454ae313..ed8a3d49487d 100644 --- a/trunk/net/ethernet/eth.c +++ b/trunk/net/ethernet/eth.c @@ -298,14 +298,6 @@ static int eth_change_mtu(struct net_device *dev, int new_mtu) return 0; } -static int eth_validate_addr(struct net_device *dev) -{ - if (!is_valid_ether_addr(dev->dev_addr)) - return -EINVAL; - - return 0; -} - const struct header_ops eth_header_ops ____cacheline_aligned = { .create = eth_header, .parse = eth_header_parse, @@ -325,7 +317,6 @@ void ether_setup(struct net_device *dev) dev->change_mtu = eth_change_mtu; dev->set_mac_address = eth_mac_addr; - dev->validate_addr = eth_validate_addr; dev->type = ARPHRD_ETHER; dev->hard_header_len = ETH_HLEN; diff --git a/trunk/net/ieee80211/ieee80211_crypt_tkip.c b/trunk/net/ieee80211/ieee80211_crypt_tkip.c index 4cce3534e408..c796661a021b 100644 --- a/trunk/net/ieee80211/ieee80211_crypt_tkip.c +++ b/trunk/net/ieee80211/ieee80211_crypt_tkip.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -25,7 +24,7 @@ #include #include -#include +#include #include MODULE_AUTHOR("Jouni Malinen"); @@ -537,8 +536,13 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr, return -1; } sg_init_table(sg, 2); - sg_set_buf(&sg[0], hdr, 16); - sg_set_buf(&sg[1], data, data_len); + sg_set_page(&sg[0], virt_to_page(hdr)); + sg[0].offset = offset_in_page(hdr); + sg[0].length = 16; + + sg_set_page(&sg[1], virt_to_page(data)); + sg[1].offset = offset_in_page(data); + sg[1].length = data_len; if (crypto_hash_setkey(tfm_michael, key, 8)) return -1; diff --git a/trunk/net/ieee80211/ieee80211_crypt_wep.c b/trunk/net/ieee80211/ieee80211_crypt_wep.c index 866fc04c44f9..0af6103d715c 100644 --- a/trunk/net/ieee80211/ieee80211_crypt_wep.c +++ b/trunk/net/ieee80211/ieee80211_crypt_wep.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -22,7 +21,7 @@ #include #include -#include +#include #include MODULE_AUTHOR("Jouni Malinen"); diff --git a/trunk/net/ipv4/cipso_ipv4.c b/trunk/net/ipv4/cipso_ipv4.c index f18e88bc86ec..805a78e6ed55 100644 --- a/trunk/net/ipv4/cipso_ipv4.c +++ b/trunk/net/ipv4/cipso_ipv4.c @@ -504,16 +504,22 @@ int cipso_v4_doi_add(struct cipso_v4_doi *doi_def) INIT_RCU_HEAD(&doi_def->rcu); INIT_LIST_HEAD(&doi_def->dom_list); + rcu_read_lock(); + if (cipso_v4_doi_search(doi_def->doi) != NULL) + goto doi_add_failure_rlock; spin_lock(&cipso_v4_doi_list_lock); if (cipso_v4_doi_search(doi_def->doi) != NULL) - goto doi_add_failure; + goto doi_add_failure_slock; list_add_tail_rcu(&doi_def->list, &cipso_v4_doi_list); spin_unlock(&cipso_v4_doi_list_lock); + rcu_read_unlock(); return 0; -doi_add_failure: +doi_add_failure_slock: spin_unlock(&cipso_v4_doi_list_lock); +doi_add_failure_rlock: + rcu_read_unlock(); return -EEXIST; } @@ -537,23 +543,29 @@ int cipso_v4_doi_remove(u32 doi, struct cipso_v4_doi *doi_def; struct cipso_v4_domhsh_entry *dom_iter; - spin_lock(&cipso_v4_doi_list_lock); - doi_def = cipso_v4_doi_search(doi); - if (doi_def != NULL) { + rcu_read_lock(); + if (cipso_v4_doi_search(doi) != NULL) { + spin_lock(&cipso_v4_doi_list_lock); + doi_def = cipso_v4_doi_search(doi); + if (doi_def == NULL) { + spin_unlock(&cipso_v4_doi_list_lock); + rcu_read_unlock(); + return -ENOENT; + } doi_def->valid = 0; list_del_rcu(&doi_def->list); spin_unlock(&cipso_v4_doi_list_lock); - rcu_read_lock(); list_for_each_entry_rcu(dom_iter, &doi_def->dom_list, list) if (dom_iter->valid) netlbl_domhsh_remove(dom_iter->domain, audit_info); - rcu_read_unlock(); cipso_v4_cache_invalidate(); + rcu_read_unlock(); + call_rcu(&doi_def->rcu, callback); return 0; } - spin_unlock(&cipso_v4_doi_list_lock); + rcu_read_unlock(); return -ENOENT; } @@ -641,19 +653,22 @@ int cipso_v4_doi_domhsh_add(struct cipso_v4_doi *doi_def, const char *domain) new_dom->valid = 1; INIT_RCU_HEAD(&new_dom->rcu); + rcu_read_lock(); spin_lock(&cipso_v4_doi_list_lock); - list_for_each_entry(iter, &doi_def->dom_list, list) + list_for_each_entry_rcu(iter, &doi_def->dom_list, list) if (iter->valid && ((domain != NULL && iter->domain != NULL && strcmp(iter->domain, domain) == 0) || (domain == NULL && iter->domain == NULL))) { spin_unlock(&cipso_v4_doi_list_lock); + rcu_read_unlock(); kfree(new_dom->domain); kfree(new_dom); return -EEXIST; } list_add_tail_rcu(&new_dom->list, &doi_def->dom_list); spin_unlock(&cipso_v4_doi_list_lock); + rcu_read_unlock(); return 0; } @@ -674,8 +689,9 @@ int cipso_v4_doi_domhsh_remove(struct cipso_v4_doi *doi_def, { struct cipso_v4_domhsh_entry *iter; + rcu_read_lock(); spin_lock(&cipso_v4_doi_list_lock); - list_for_each_entry(iter, &doi_def->dom_list, list) + list_for_each_entry_rcu(iter, &doi_def->dom_list, list) if (iter->valid && ((domain != NULL && iter->domain != NULL && strcmp(iter->domain, domain) == 0) || @@ -683,10 +699,13 @@ int cipso_v4_doi_domhsh_remove(struct cipso_v4_doi *doi_def, iter->valid = 0; list_del_rcu(&iter->list); spin_unlock(&cipso_v4_doi_list_lock); + rcu_read_unlock(); call_rcu(&iter->rcu, cipso_v4_doi_domhsh_free); + return 0; } spin_unlock(&cipso_v4_doi_list_lock); + rcu_read_unlock(); return -ENOENT; } diff --git a/trunk/net/ipv4/esp4.c b/trunk/net/ipv4/esp4.c index cad4278025ad..6b1a31a74cf2 100644 --- a/trunk/net/ipv4/esp4.c +++ b/trunk/net/ipv4/esp4.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include #include @@ -110,10 +110,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb) if (!sg) goto unlock; } - sg_init_table(sg, nfrags); - sg_mark_end(sg, skb_to_sgvec(skb, sg, esph->enc_data + - esp->conf.ivlen - - skb->data, clen)); + skb_to_sgvec(skb, sg, esph->enc_data+esp->conf.ivlen-skb->data, clen); err = crypto_blkcipher_encrypt(&desc, sg, sg, clen); if (unlikely(sg != &esp->sgbuf[0])) kfree(sg); @@ -204,9 +201,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb) if (!sg) goto out; } - sg_init_table(sg, nfrags); - sg_mark_end(sg, skb_to_sgvec(skb, sg, sizeof(*esph) + esp->conf.ivlen, - elen)); + skb_to_sgvec(skb, sg, sizeof(*esph) + esp->conf.ivlen, elen); err = crypto_blkcipher_decrypt(&desc, sg, sg, elen); if (unlikely(sg != &esp->sgbuf[0])) kfree(sg); diff --git a/trunk/net/ipv4/fib_frontend.c b/trunk/net/ipv4/fib_frontend.c index 60123905dbbf..78b514ba1414 100644 --- a/trunk/net/ipv4/fib_frontend.c +++ b/trunk/net/ipv4/fib_frontend.c @@ -128,14 +128,13 @@ struct net_device * ip_dev_find(__be32 addr) struct flowi fl = { .nl_u = { .ip4_u = { .daddr = addr } } }; struct fib_result res; struct net_device *dev = NULL; - struct fib_table *local_table; #ifdef CONFIG_IP_MULTIPLE_TABLES res.r = NULL; #endif - local_table = fib_get_table(RT_TABLE_LOCAL); - if (!local_table || local_table->tb_lookup(local_table, &fl, &res)) + if (!ip_fib_local_table || + ip_fib_local_table->tb_lookup(ip_fib_local_table, &fl, &res)) return NULL; if (res.type != RTN_LOCAL) goto out; @@ -153,7 +152,6 @@ unsigned inet_addr_type(__be32 addr) struct flowi fl = { .nl_u = { .ip4_u = { .daddr = addr } } }; struct fib_result res; unsigned ret = RTN_BROADCAST; - struct fib_table *local_table; if (ZERONET(addr) || BADCLASS(addr)) return RTN_BROADCAST; @@ -164,10 +162,10 @@ unsigned inet_addr_type(__be32 addr) res.r = NULL; #endif - local_table = fib_get_table(RT_TABLE_LOCAL); - if (local_table) { + if (ip_fib_local_table) { ret = RTN_UNICAST; - if (!local_table->tb_lookup(local_table, &fl, &res)) { + if (!ip_fib_local_table->tb_lookup(ip_fib_local_table, + &fl, &res)) { ret = res.type; fib_res_put(&res); } diff --git a/trunk/net/ipv4/icmp.c b/trunk/net/ipv4/icmp.c index 233de0634298..272c69e106e9 100644 --- a/trunk/net/ipv4/icmp.c +++ b/trunk/net/ipv4/icmp.c @@ -1104,4 +1104,5 @@ void __init icmp_init(struct net_proto_family *ops) EXPORT_SYMBOL(icmp_err_convert); EXPORT_SYMBOL(icmp_send); EXPORT_SYMBOL(icmp_statistics); +EXPORT_SYMBOL(icmpmsg_statistics); EXPORT_SYMBOL(xrlim_allow); diff --git a/trunk/net/ipv4/ip_gre.c b/trunk/net/ipv4/ip_gre.c index 02b02a8d681c..f151900efaf9 100644 --- a/trunk/net/ipv4/ip_gre.c +++ b/trunk/net/ipv4/ip_gre.c @@ -674,7 +674,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) struct rtable *rt; /* Route to the other host */ struct net_device *tdev; /* Device to other host */ struct iphdr *iph; /* Our new IP header */ - unsigned int max_headroom; /* The extra header space needed */ + int max_headroom; /* The extra header space needed */ int gre_hlen; __be32 dst; int mtu; @@ -1033,6 +1033,7 @@ static int ipgre_tunnel_change_mtu(struct net_device *dev, int new_mtu) return 0; } +#ifdef CONFIG_NET_IPGRE_BROADCAST /* Nice toy. Unfortunately, useless in real life :-) It allows to construct virtual multiprotocol broadcast "LAN" over the Internet, provided multicast routing is tuned. @@ -1091,19 +1092,10 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev, return -t->hlen; } -static int ipgre_header_parse(const struct sk_buff *skb, unsigned char *haddr) -{ - struct iphdr *iph = (struct iphdr*) skb_mac_header(skb); - memcpy(haddr, &iph->saddr, 4); - return 4; -} - static const struct header_ops ipgre_header_ops = { .create = ipgre_header, - .parse = ipgre_header_parse, }; -#ifdef CONFIG_NET_IPGRE_BROADCAST static int ipgre_open(struct net_device *dev) { struct ip_tunnel *t = netdev_priv(dev); @@ -1205,8 +1197,6 @@ static int ipgre_tunnel_init(struct net_device *dev) dev->stop = ipgre_close; } #endif - } else { - dev->header_ops = &ipgre_header_ops; } if (!tdev && tunnel->parms.link) diff --git a/trunk/net/ipv4/ip_output.c b/trunk/net/ipv4/ip_output.c index e5f7dc2de303..f508835ba713 100644 --- a/trunk/net/ipv4/ip_output.c +++ b/trunk/net/ipv4/ip_output.c @@ -161,7 +161,7 @@ static inline int ip_finish_output2(struct sk_buff *skb) struct dst_entry *dst = skb->dst; struct rtable *rt = (struct rtable *)dst; struct net_device *dev = dst->dev; - unsigned int hh_len = LL_RESERVED_SPACE(dev); + int hh_len = LL_RESERVED_SPACE(dev); if (rt->rt_type == RTN_MULTICAST) IP_INC_STATS(IPSTATS_MIB_OUTMCASTPKTS); diff --git a/trunk/net/ipv4/ipip.c b/trunk/net/ipv4/ipip.c index 8c2b2b0741da..5cd5bbe1379a 100644 --- a/trunk/net/ipv4/ipip.c +++ b/trunk/net/ipv4/ipip.c @@ -515,7 +515,7 @@ static int ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) struct net_device *tdev; /* Device to other host */ struct iphdr *old_iph = ip_hdr(skb); struct iphdr *iph; /* Our new IP header */ - unsigned int max_headroom; /* The extra header space needed */ + int max_headroom; /* The extra header space needed */ __be32 dst = tiph->daddr; int mtu; diff --git a/trunk/net/ipv4/ipvs/ip_vs_sync.c b/trunk/net/ipv4/ipvs/ip_vs_sync.c index 0d4d9721cbd4..c99f2a33fb9e 100644 --- a/trunk/net/ipv4/ipvs/ip_vs_sync.c +++ b/trunk/net/ipv4/ipvs/ip_vs_sync.c @@ -72,6 +72,7 @@ struct ip_vs_sync_thread_data { int state; }; +#define IP_VS_SYNC_CONN_TIMEOUT (3*60*HZ) #define SIMPLE_CONN_SIZE (sizeof(struct ip_vs_sync_conn)) #define FULL_CONN_SIZE \ (sizeof(struct ip_vs_sync_conn) + sizeof(struct ip_vs_sync_conn_options)) @@ -283,7 +284,6 @@ static void ip_vs_process_message(const char *buffer, const size_t buflen) struct ip_vs_sync_conn *s; struct ip_vs_sync_conn_options *opt; struct ip_vs_conn *cp; - struct ip_vs_protocol *pp; char *p; int i; @@ -342,8 +342,7 @@ static void ip_vs_process_message(const char *buffer, const size_t buflen) p += SIMPLE_CONN_SIZE; atomic_set(&cp->in_pkts, sysctl_ip_vs_sync_threshold[0]); - pp = ip_vs_proto_get(s->protocol); - cp->timeout = pp->timeout_table[cp->state]; + cp->timeout = IP_VS_SYNC_CONN_TIMEOUT; ip_vs_conn_put(cp); if (p > buffer+buflen) { diff --git a/trunk/net/ipv4/ipvs/ip_vs_xmit.c b/trunk/net/ipv4/ipvs/ip_vs_xmit.c index 7c074e386c17..d0a92dec1050 100644 --- a/trunk/net/ipv4/ipvs/ip_vs_xmit.c +++ b/trunk/net/ipv4/ipvs/ip_vs_xmit.c @@ -325,7 +325,7 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp, __be16 df = old_iph->frag_off; sk_buff_data_t old_transport_header = skb->transport_header; struct iphdr *iph; /* Our new IP header */ - unsigned int max_headroom; /* The extra header space needed */ + int max_headroom; /* The extra header space needed */ int mtu; EnterFunction(10); diff --git a/trunk/net/ipv4/netfilter/Kconfig b/trunk/net/ipv4/netfilter/Kconfig index 9aca9c55687c..fa97947c6ae1 100644 --- a/trunk/net/ipv4/netfilter/Kconfig +++ b/trunk/net/ipv4/netfilter/Kconfig @@ -128,7 +128,7 @@ config IP_NF_MATCH_ADDRTYPE eg. UNICAST, LOCAL, BROADCAST, ... If you want to compile it as a module, say M here and read - . If unsure, say `N'. + . If unsure, say `N'. # `filter', generic and specific targets config IP_NF_FILTER @@ -371,7 +371,7 @@ config IP_NF_RAW and OUTPUT chains. If you want to compile it as a module, say M here and read - . If unsure, say `N'. + . If unsure, say `N'. # ARP tables config IP_NF_ARPTABLES diff --git a/trunk/net/ipv4/proc.c b/trunk/net/ipv4/proc.c index ffdccc0972e0..fd16cb8f8abe 100644 --- a/trunk/net/ipv4/proc.c +++ b/trunk/net/ipv4/proc.c @@ -121,6 +121,14 @@ static const struct snmp_mib snmp4_ipextstats_list[] = { SNMP_MIB_SENTINEL }; +static const struct snmp_mib snmp4_icmp_list[] = { + SNMP_MIB_ITEM("InMsgs", ICMP_MIB_INMSGS), + SNMP_MIB_ITEM("InErrors", ICMP_MIB_INERRORS), + SNMP_MIB_ITEM("OutMsgs", ICMP_MIB_OUTMSGS), + SNMP_MIB_ITEM("OutErrors", ICMP_MIB_OUTERRORS), + SNMP_MIB_SENTINEL +}; + static struct { char *name; int index; @@ -304,7 +312,7 @@ static void icmp_put(struct seq_file *seq) for (i=0; icmpmibmap[i].name != NULL; i++) seq_printf(seq, " %lu", snmp_fold_field((void **) icmpmsg_statistics, - icmpmibmap[i].index | 0x100)); + icmpmibmap[i].index)); } /* diff --git a/trunk/net/ipv4/tcp.c b/trunk/net/ipv4/tcp.c index c64072bb504b..2e6ad6dbba6c 100644 --- a/trunk/net/ipv4/tcp.c +++ b/trunk/net/ipv4/tcp.c @@ -2453,7 +2453,7 @@ void __init tcp_init(void) 0, &tcp_hashinfo.ehash_size, NULL, - thash_entries ? 0 : 512 * 1024); + 0); tcp_hashinfo.ehash_size = 1 << tcp_hashinfo.ehash_size; for (i = 0; i < tcp_hashinfo.ehash_size; i++) { rwlock_init(&tcp_hashinfo.ehash[i].lock); diff --git a/trunk/net/ipv4/tcp_input.c b/trunk/net/ipv4/tcp_input.c index 69d8c38ccd39..9288220b73a8 100644 --- a/trunk/net/ipv4/tcp_input.c +++ b/trunk/net/ipv4/tcp_input.c @@ -103,7 +103,7 @@ int sysctl_tcp_abc __read_mostly; #define FLAG_SLOWPATH 0x100 /* Do not skip RFC checks for window update.*/ #define FLAG_ONLY_ORIG_SACKED 0x200 /* SACKs only non-rexmit sent before RTO */ #define FLAG_SND_UNA_ADVANCED 0x400 /* Snd_una was changed (!= FLAG_DATA_ACKED) */ -#define FLAG_DSACKING_ACK 0x800 /* SACK blocks contained D-SACK info */ +#define FLAG_DSACKING_ACK 0x800 /* SACK blocks contained DSACK info */ #define FLAG_NONHEAD_RETRANS_ACKED 0x1000 /* Non-head rexmitted data was ACKed */ #define FLAG_ACKED (FLAG_DATA_ACKED|FLAG_SYN_ACKED) @@ -866,7 +866,7 @@ static void tcp_disable_fack(struct tcp_sock *tp) tp->rx_opt.sack_ok &= ~2; } -/* Take a notice that peer is sending D-SACKs */ +/* Take a notice that peer is sending DSACKs */ static void tcp_dsack_seen(struct tcp_sock *tp) { tp->rx_opt.sack_ok |= 4; @@ -1058,7 +1058,7 @@ static void tcp_update_reordering(struct sock *sk, const int metric, * * With D-SACK the lower bound is extended to cover sequence space below * SND.UNA down to undo_marker, which is the last point of interest. Yet - * again, D-SACK block must not to go across snd_una (for the same reason as + * again, DSACK block must not to go across snd_una (for the same reason as * for the normal SACK blocks, explained above). But there all simplicity * ends, TCP might receive valid D-SACKs below that. As long as they reside * fully below undo_marker they do not affect behavior in anyway and can @@ -1080,7 +1080,7 @@ static int tcp_is_sackblock_valid(struct tcp_sock *tp, int is_dsack, if (!before(start_seq, tp->snd_nxt)) return 0; - /* In outstanding window? ...This is valid exit for D-SACKs too. + /* In outstanding window? ...This is valid exit for DSACKs too. * start_seq == snd_una is non-sensical (see comments above) */ if (after(start_seq, tp->snd_una)) @@ -1204,8 +1204,8 @@ static int tcp_check_dsack(struct tcp_sock *tp, struct sk_buff *ack_skb, * which may fail and creates some hassle (caller must handle error case * returns). */ -static int tcp_match_skb_to_sack(struct sock *sk, struct sk_buff *skb, - u32 start_seq, u32 end_seq) +int tcp_match_skb_to_sack(struct sock *sk, struct sk_buff *skb, + u32 start_seq, u32 end_seq) { int in_sack, err; unsigned int pkt_len; @@ -1248,7 +1248,6 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ int cached_fack_count; int i; int first_sack_index; - int force_one_sack; if (!tp->sacked_out) { if (WARN_ON(tp->fackets_out)) @@ -1273,18 +1272,18 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ * if the only SACK change is the increase of the end_seq of * the first block then only apply that SACK block * and use retrans queue hinting otherwise slowpath */ - force_one_sack = 1; + flag = 1; for (i = 0; i < num_sacks; i++) { __be32 start_seq = sp[i].start_seq; __be32 end_seq = sp[i].end_seq; if (i == 0) { if (tp->recv_sack_cache[i].start_seq != start_seq) - force_one_sack = 0; + flag = 0; } else { if ((tp->recv_sack_cache[i].start_seq != start_seq) || (tp->recv_sack_cache[i].end_seq != end_seq)) - force_one_sack = 0; + flag = 0; } tp->recv_sack_cache[i].start_seq = start_seq; tp->recv_sack_cache[i].end_seq = end_seq; @@ -1296,7 +1295,7 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ } first_sack_index = 0; - if (force_one_sack) + if (flag) num_sacks = 1; else { int j; @@ -1322,6 +1321,9 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ } } + /* clear flag as used for different purpose in following code */ + flag = 0; + /* Use SACK fastpath hint if valid */ cached_skb = tp->fastpath_skb_hint; cached_fack_count = tp->fastpath_cnt_hint; @@ -1613,7 +1615,7 @@ void tcp_enter_frto(struct sock *sk) !icsk->icsk_retransmits)) { tp->prior_ssthresh = tcp_current_ssthresh(sk); /* Our state is too optimistic in ssthresh() call because cwnd - * is not reduced until tcp_enter_frto_loss() when previous F-RTO + * is not reduced until tcp_enter_frto_loss() when previous FRTO * recovery has not yet completed. Pattern would be this: RTO, * Cumulative ACK, RTO (2xRTO for the same segment does not end * up here twice). @@ -1799,7 +1801,7 @@ void tcp_enter_loss(struct sock *sk, int how) tcp_set_ca_state(sk, TCP_CA_Loss); tp->high_seq = tp->snd_nxt; TCP_ECN_queue_cwr(tp); - /* Abort F-RTO algorithm if one is in progress */ + /* Abort FRTO algorithm if one is in progress */ tp->frto_counter = 0; } @@ -1944,7 +1946,7 @@ static int tcp_time_to_recover(struct sock *sk) struct tcp_sock *tp = tcp_sk(sk); __u32 packets_out; - /* Do not perform any recovery during F-RTO algorithm */ + /* Do not perform any recovery during FRTO algorithm */ if (tp->frto_counter) return 0; @@ -2960,7 +2962,7 @@ static int tcp_process_frto(struct sock *sk, int flag) } if (tp->frto_counter == 1) { - /* Sending of the next skb must be allowed or no F-RTO */ + /* Sending of the next skb must be allowed or no FRTO */ if (!tcp_send_head(sk) || after(TCP_SKB_CB(tcp_send_head(sk))->end_seq, tp->snd_una + tp->snd_wnd)) { @@ -3907,7 +3909,7 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list, while (before(start, end)) { struct sk_buff *nskb; - unsigned int header = skb_headroom(skb); + int header = skb_headroom(skb); int copy = SKB_MAX_ORDER(header, 0); /* Too big header? This can happen with IPv6. */ diff --git a/trunk/net/ipv4/tcp_ipv4.c b/trunk/net/ipv4/tcp_ipv4.c index d3d8d5dfcee3..38cf73a56731 100644 --- a/trunk/net/ipv4/tcp_ipv4.c +++ b/trunk/net/ipv4/tcp_ipv4.c @@ -858,16 +858,16 @@ int tcp_v4_md5_do_add(struct sock *sk, __be32 addr, u8 *newkey, u8 newkeylen) { /* Add Key to the list */ - struct tcp_md5sig_key *key; + struct tcp4_md5sig_key *key; struct tcp_sock *tp = tcp_sk(sk); struct tcp4_md5sig_key *keys; - key = tcp_v4_md5_do_lookup(sk, addr); + key = (struct tcp4_md5sig_key *)tcp_v4_md5_do_lookup(sk, addr); if (key) { /* Pre-existing entry - just update that one. */ - kfree(key->key); - key->key = newkey; - key->keylen = newkeylen; + kfree(key->base.key); + key->base.key = newkey; + key->base.keylen = newkeylen; } else { struct tcp_md5sig_info *md5sig; @@ -1055,9 +1055,6 @@ static int tcp_v4_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key, bp->pad = 0; bp->protocol = protocol; bp->len = htons(tcplen); - - sg_init_table(sg, 4); - sg_set_buf(&sg[block++], bp, sizeof(*bp)); nbytes += sizeof(*bp); @@ -1083,8 +1080,6 @@ static int tcp_v4_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key, sg_set_buf(&sg[block++], key->key, key->keylen); nbytes += key->keylen; - sg_mark_end(sg, block); - /* Now store the Hash into the packet */ err = crypto_hash_init(desc); if (err) diff --git a/trunk/net/ipv4/tcp_vegas.c b/trunk/net/ipv4/tcp_vegas.c index 007304e99842..b49dedcda52d 100644 --- a/trunk/net/ipv4/tcp_vegas.c +++ b/trunk/net/ipv4/tcp_vegas.c @@ -266,25 +266,26 @@ static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack, */ diff = (old_wnd << V_PARAM_SHIFT) - target_cwnd; - if (diff > gamma && tp->snd_ssthresh > 2 ) { - /* Going too fast. Time to slow down - * and switch to congestion avoidance. - */ - tp->snd_ssthresh = 2; - - /* Set cwnd to match the actual rate - * exactly: - * cwnd = (actual rate) * baseRTT - * Then we add 1 because the integer - * truncation robs us of full link - * utilization. - */ - tp->snd_cwnd = min(tp->snd_cwnd, - (target_cwnd >> - V_PARAM_SHIFT)+1); - - } else if (tp->snd_cwnd <= tp->snd_ssthresh) { + if (tp->snd_cwnd <= tp->snd_ssthresh) { /* Slow start. */ + if (diff > gamma) { + /* Going too fast. Time to slow down + * and switch to congestion avoidance. + */ + tp->snd_ssthresh = 2; + + /* Set cwnd to match the actual rate + * exactly: + * cwnd = (actual rate) * baseRTT + * Then we add 1 because the integer + * truncation robs us of full link + * utilization. + */ + tp->snd_cwnd = min(tp->snd_cwnd, + (target_cwnd >> + V_PARAM_SHIFT)+1); + + } tcp_slow_start(tp); } else { /* Congestion avoidance. */ diff --git a/trunk/net/ipv4/udp.c b/trunk/net/ipv4/udp.c index 4bc25b46f33f..35d2b0e9e10b 100644 --- a/trunk/net/ipv4/udp.c +++ b/trunk/net/ipv4/udp.c @@ -1152,7 +1152,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], return __udp4_lib_mcast_deliver(skb, uh, saddr, daddr, udptable); sk = __udp4_lib_lookup(saddr, uh->source, daddr, uh->dest, - inet_iif(skb), udptable); + skb->dev->ifindex, udptable ); if (sk != NULL) { int ret = udp_queue_rcv_skb(sk, skb); diff --git a/trunk/net/ipv6/esp6.c b/trunk/net/ipv6/esp6.c index ab17b5e62355..72a659806cad 100644 --- a/trunk/net/ipv6/esp6.c +++ b/trunk/net/ipv6/esp6.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -109,10 +109,7 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb) if (!sg) goto unlock; } - sg_init_table(sg, nfrags); - sg_mark_end(sg, skb_to_sgvec(skb, sg, esph->enc_data + - esp->conf.ivlen - - skb->data, clen)); + skb_to_sgvec(skb, sg, esph->enc_data+esp->conf.ivlen-skb->data, clen); err = crypto_blkcipher_encrypt(&desc, sg, sg, clen); if (unlikely(sg != &esp->sgbuf[0])) kfree(sg); @@ -208,10 +205,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb) goto out; } } - sg_init_table(sg, nfrags); - sg_mark_end(sg, skb_to_sgvec(skb, sg, - sizeof(*esph) + esp->conf.ivlen, - elen)); + skb_to_sgvec(skb, sg, sizeof(*esph) + esp->conf.ivlen, elen); ret = crypto_blkcipher_decrypt(&desc, sg, sg, elen); if (unlikely(sg != &esp->sgbuf[0])) kfree(sg); diff --git a/trunk/net/ipv6/ip6_output.c b/trunk/net/ipv6/ip6_output.c index 653fc0a8235b..13565dfb1b45 100644 --- a/trunk/net/ipv6/ip6_output.c +++ b/trunk/net/ipv6/ip6_output.c @@ -171,7 +171,7 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl, u32 mtu; if (opt) { - unsigned int head_room; + int head_room; /* First: exthdrs may take lots of space (~8K for now) MAX_HEADER is not enough. diff --git a/trunk/net/ipv6/ip6_tunnel.c b/trunk/net/ipv6/ip6_tunnel.c index 5383b33db8ca..2320cc27ff9e 100644 --- a/trunk/net/ipv6/ip6_tunnel.c +++ b/trunk/net/ipv6/ip6_tunnel.c @@ -838,7 +838,7 @@ static int ip6_tnl_xmit2(struct sk_buff *skb, struct dst_entry *dst; struct net_device *tdev; int mtu; - unsigned int max_headroom = sizeof(struct ipv6hdr); + int max_headroom = sizeof(struct ipv6hdr); u8 proto; int err = -1; int pkt_len; diff --git a/trunk/net/ipv6/ndisc.c b/trunk/net/ipv6/ndisc.c index 36f7dbfb6dbb..20cfc90d5597 100644 --- a/trunk/net/ipv6/ndisc.c +++ b/trunk/net/ipv6/ndisc.c @@ -1670,7 +1670,7 @@ int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, struct file * f filp, buffer, lenp, ppos); else if ((strcmp(ctl->procname, "retrans_time_ms") == 0) || - (strcmp(ctl->procname, "base_reachable_time_ms") == 0)) + (strcmp(ctl->procname, "base_reacable_time_ms") == 0)) ret = proc_dointvec_ms_jiffies(ctl, write, filp, buffer, lenp, ppos); else diff --git a/trunk/net/ipv6/sit.c b/trunk/net/ipv6/sit.c index 71433d29d884..466657a9a8bd 100644 --- a/trunk/net/ipv6/sit.c +++ b/trunk/net/ipv6/sit.c @@ -430,7 +430,7 @@ static int ipip6_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) struct rtable *rt; /* Route to the other host */ struct net_device *tdev; /* Device to other host */ struct iphdr *iph; /* Our new IP header */ - unsigned int max_headroom; /* The extra header space needed */ + int max_headroom; /* The extra header space needed */ __be32 dst = tiph->daddr; int mtu; struct in6_addr *addr6; diff --git a/trunk/net/ipv6/tcp_ipv6.c b/trunk/net/ipv6/tcp_ipv6.c index f1523b82cac1..737b755342bd 100644 --- a/trunk/net/ipv6/tcp_ipv6.c +++ b/trunk/net/ipv6/tcp_ipv6.c @@ -59,7 +59,6 @@ #include #include #include -#include #include @@ -561,16 +560,16 @@ static int tcp_v6_md5_do_add(struct sock *sk, struct in6_addr *peer, char *newkey, u8 newkeylen) { /* Add key to the list */ - struct tcp_md5sig_key *key; + struct tcp6_md5sig_key *key; struct tcp_sock *tp = tcp_sk(sk); struct tcp6_md5sig_key *keys; - key = tcp_v6_md5_do_lookup(sk, peer); + key = (struct tcp6_md5sig_key*) tcp_v6_md5_do_lookup(sk, peer); if (key) { /* modify existing entry - just update that one */ - kfree(key->key); - key->key = newkey; - key->keylen = newkeylen; + kfree(key->base.key); + key->base.key = newkey; + key->base.keylen = newkeylen; } else { /* reallocate new list if current one is full. */ if (!tp->md5sig_info) { @@ -758,8 +757,6 @@ static int tcp_v6_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key, bp->len = htonl(tcplen); bp->protocol = htonl(protocol); - sg_init_table(sg, 4); - sg_set_buf(&sg[block++], bp, sizeof(*bp)); nbytes += sizeof(*bp); @@ -781,8 +778,6 @@ static int tcp_v6_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key, sg_set_buf(&sg[block++], key->key, key->keylen); nbytes += key->keylen; - sg_mark_end(sg, block); - /* Now store the hash into the packet */ err = crypto_hash_init(desc); if (err) { @@ -1733,8 +1728,6 @@ static int tcp_v6_rcv(struct sk_buff *skb) if (!sock_owned_by_user(sk)) { #ifdef CONFIG_NET_DMA struct tcp_sock *tp = tcp_sk(sk); - if (!tp->ucopy.dma_chan && tp->ucopy.pinned_list) - tp->ucopy.dma_chan = get_softnet_dma(); if (tp->ucopy.dma_chan) ret = tcp_v6_do_rcv(sk, skb); else diff --git a/trunk/net/irda/ircomm/ircomm_tty.c b/trunk/net/irda/ircomm/ircomm_tty.c index 1120b150e211..3d241e415a2a 100644 --- a/trunk/net/irda/ircomm/ircomm_tty.c +++ b/trunk/net/irda/ircomm/ircomm_tty.c @@ -77,7 +77,7 @@ static int ircomm_tty_read_proc(char *buf, char **start, off_t offset, int len, #endif /* CONFIG_PROC_FS */ static struct tty_driver *driver; -static hashbin_t *ircomm_tty = NULL; +hashbin_t *ircomm_tty = NULL; static const struct tty_operations ops = { .open = ircomm_tty_open, diff --git a/trunk/net/mac80211/ieee80211_sta.c b/trunk/net/mac80211/ieee80211_sta.c index fda0e06453e8..f7ffeec3913f 100644 --- a/trunk/net/mac80211/ieee80211_sta.c +++ b/trunk/net/mac80211/ieee80211_sta.c @@ -1184,7 +1184,7 @@ static void ieee80211_rx_mgmt_assoc_resp(struct net_device *dev, printk(KERN_DEBUG "%s: RX %sssocResp from %s (capab=0x%x " "status=%d aid=%d)\n", dev->name, reassoc ? "Rea" : "A", print_mac(mac, mgmt->sa), - capab_info, status_code, (u16)(aid & ~(BIT(15) | BIT(14)))); + capab_info, status_code, aid & ~(BIT(15) | BIT(14))); if (status_code != WLAN_STATUS_SUCCESS) { printk(KERN_DEBUG "%s: AP denied association (code=%d)\n", @@ -2096,8 +2096,7 @@ static int ieee80211_sta_match_ssid(struct ieee80211_if_sta *ifsta, { int tmp, hidden_ssid; - if (ssid_len == ifsta->ssid_len && - !memcmp(ifsta->ssid, ssid, ssid_len)) + if (!memcmp(ifsta->ssid, ssid, ssid_len)) return 1; if (ifsta->flags & IEEE80211_STA_AUTO_BSSID_SEL) diff --git a/trunk/net/mac80211/wep.c b/trunk/net/mac80211/wep.c index a84a23310ff4..cc806d640f7a 100644 --- a/trunk/net/mac80211/wep.c +++ b/trunk/net/mac80211/wep.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include "ieee80211_i.h" diff --git a/trunk/net/netfilter/Kconfig b/trunk/net/netfilter/Kconfig index 21a9fcc03796..d7a600a5720a 100644 --- a/trunk/net/netfilter/Kconfig +++ b/trunk/net/netfilter/Kconfig @@ -363,7 +363,7 @@ config NETFILTER_XT_TARGET_TRACE the tables, chains, rules. If you want to compile it as a module, say M here and read - . If unsure, say `N'. + . If unsure, say `N'. config NETFILTER_XT_TARGET_SECMARK tristate '"SECMARK" target support' diff --git a/trunk/net/netfilter/nf_conntrack_core.c b/trunk/net/netfilter/nf_conntrack_core.c index 000c2fb462d0..4d6171bc0829 100644 --- a/trunk/net/netfilter/nf_conntrack_core.c +++ b/trunk/net/netfilter/nf_conntrack_core.c @@ -999,7 +999,7 @@ struct hlist_head *nf_ct_alloc_hashtable(int *sizep, int *vmalloced) *vmalloced = 0; size = *sizep = roundup(*sizep, PAGE_SIZE / sizeof(struct hlist_head)); - hash = (void*)__get_free_pages(GFP_KERNEL|__GFP_NOWARN, + hash = (void*)__get_free_pages(GFP_KERNEL, get_order(sizeof(struct hlist_head) * size)); if (!hash) { diff --git a/trunk/net/netlabel/netlabel_domainhash.c b/trunk/net/netlabel/netlabel_domainhash.c index b3675bd7db33..b6c844b7e1c1 100644 --- a/trunk/net/netlabel/netlabel_domainhash.c +++ b/trunk/net/netlabel/netlabel_domainhash.c @@ -178,9 +178,11 @@ int netlbl_domhsh_init(u32 size) for (iter = 0; iter < hsh_tbl->size; iter++) INIT_LIST_HEAD(&hsh_tbl->tbl[iter]); + rcu_read_lock(); spin_lock(&netlbl_domhsh_lock); rcu_assign_pointer(netlbl_domhsh, hsh_tbl); spin_unlock(&netlbl_domhsh_lock); + rcu_read_unlock(); return 0; } @@ -220,6 +222,7 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry, entry->valid = 1; INIT_RCU_HEAD(&entry->rcu); + ret_val = 0; rcu_read_lock(); if (entry->domain != NULL) { bkt = netlbl_domhsh_hash(entry->domain); @@ -230,7 +233,7 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry, else ret_val = -EEXIST; spin_unlock(&netlbl_domhsh_lock); - } else { + } else if (entry->domain == NULL) { INIT_LIST_HEAD(&entry->list); spin_lock(&netlbl_domhsh_def_lock); if (rcu_dereference(netlbl_domhsh_def) == NULL) @@ -238,7 +241,9 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry, else ret_val = -EEXIST; spin_unlock(&netlbl_domhsh_def_lock); - } + } else + ret_val = -EINVAL; + audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_ADD, audit_info); if (audit_buf != NULL) { audit_log_format(audit_buf, @@ -257,6 +262,7 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry, audit_log_format(audit_buf, " res=%u", ret_val == 0 ? 1 : 0); audit_log_end(audit_buf); } + rcu_read_unlock(); if (ret_val != 0) { @@ -307,30 +313,38 @@ int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info) struct audit_buffer *audit_buf; rcu_read_lock(); - entry = netlbl_domhsh_search(domain, (domain != NULL ? 0 : 1)); + if (domain != NULL) + entry = netlbl_domhsh_search(domain, 0); + else + entry = netlbl_domhsh_search(domain, 1); if (entry == NULL) goto remove_return; switch (entry->type) { + case NETLBL_NLTYPE_UNLABELED: + break; case NETLBL_NLTYPE_CIPSOV4: - cipso_v4_doi_domhsh_remove(entry->type_def.cipsov4, - entry->domain); + ret_val = cipso_v4_doi_domhsh_remove(entry->type_def.cipsov4, + entry->domain); + if (ret_val != 0) + goto remove_return; break; } + ret_val = 0; if (entry != rcu_dereference(netlbl_domhsh_def)) { spin_lock(&netlbl_domhsh_lock); if (entry->valid) { entry->valid = 0; list_del_rcu(&entry->list); - ret_val = 0; - } + } else + ret_val = -ENOENT; spin_unlock(&netlbl_domhsh_lock); } else { spin_lock(&netlbl_domhsh_def_lock); if (entry->valid) { entry->valid = 0; rcu_assign_pointer(netlbl_domhsh_def, NULL); - ret_val = 0; - } + } else + ret_val = -ENOENT; spin_unlock(&netlbl_domhsh_def_lock); } @@ -343,10 +357,11 @@ int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info) audit_log_end(audit_buf); } -remove_return: - rcu_read_unlock(); if (ret_val == 0) call_rcu(&entry->rcu, netlbl_domhsh_free_entry); + +remove_return: + rcu_read_unlock(); return ret_val; } diff --git a/trunk/net/netlabel/netlabel_mgmt.c b/trunk/net/netlabel/netlabel_mgmt.c index 56483377997a..5315dacc5222 100644 --- a/trunk/net/netlabel/netlabel_mgmt.c +++ b/trunk/net/netlabel/netlabel_mgmt.c @@ -85,9 +85,11 @@ static const struct nla_policy netlbl_mgmt_genl_policy[NLBL_MGMT_A_MAX + 1] = { */ void netlbl_mgmt_protocount_inc(void) { + rcu_read_lock(); spin_lock(&netlabel_mgmt_protocount_lock); netlabel_mgmt_protocount++; spin_unlock(&netlabel_mgmt_protocount_lock); + rcu_read_unlock(); } /** @@ -101,10 +103,12 @@ void netlbl_mgmt_protocount_inc(void) */ void netlbl_mgmt_protocount_dec(void) { + rcu_read_lock(); spin_lock(&netlabel_mgmt_protocount_lock); if (netlabel_mgmt_protocount > 0) netlabel_mgmt_protocount--; spin_unlock(&netlabel_mgmt_protocount_lock); + rcu_read_unlock(); } /** diff --git a/trunk/net/netlabel/netlabel_unlabeled.c b/trunk/net/netlabel/netlabel_unlabeled.c index 348292450deb..5c303c68af1d 100644 --- a/trunk/net/netlabel/netlabel_unlabeled.c +++ b/trunk/net/netlabel/netlabel_unlabeled.c @@ -84,10 +84,12 @@ static void netlbl_unlabel_acceptflg_set(u8 value, struct audit_buffer *audit_buf; u8 old_val; - spin_lock(&netlabel_unlabel_acceptflg_lock); + rcu_read_lock(); old_val = netlabel_unlabel_acceptflg; + spin_lock(&netlabel_unlabel_acceptflg_lock); netlabel_unlabel_acceptflg = value; spin_unlock(&netlabel_unlabel_acceptflg_lock); + rcu_read_unlock(); audit_buf = netlbl_audit_start_common(AUDIT_MAC_UNLBL_ALLOW, audit_info); diff --git a/trunk/net/netlink/af_netlink.c b/trunk/net/netlink/af_netlink.c index 4f994c0fb3f8..98e313e5e594 100644 --- a/trunk/net/netlink/af_netlink.c +++ b/trunk/net/netlink/af_netlink.c @@ -1565,11 +1565,7 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb, netlink_dump(sk); sock_put(sk); - - /* We successfully started a dump, by returning -EINTR we - * signal not to send ACK even if it was requested. - */ - return -EINTR; + return 0; } void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err) @@ -1623,21 +1619,17 @@ int netlink_rcv_skb(struct sk_buff *skb, int (*cb)(struct sk_buff *, /* Only requests are handled by the kernel */ if (!(nlh->nlmsg_flags & NLM_F_REQUEST)) - goto ack; + goto skip; /* Skip control messages */ if (nlh->nlmsg_type < NLMSG_MIN_TYPE) - goto ack; - - err = cb(skb, nlh); - if (err == -EINTR) goto skip; -ack: + err = cb(skb, nlh); +skip: if (nlh->nlmsg_flags & NLM_F_ACK || err) netlink_ack(skb, nlh, err); -skip: msglen = NLMSG_ALIGN(nlh->nlmsg_len); if (msglen > skb->len) msglen = skb->len; @@ -1888,7 +1880,7 @@ static void __net_exit netlink_net_exit(struct net *net) #endif } -static struct pernet_operations netlink_net_ops = { +static struct pernet_operations __net_initdata netlink_net_ops = { .init = netlink_net_init, .exit = netlink_net_exit, }; diff --git a/trunk/net/rxrpc/rxkad.c b/trunk/net/rxrpc/rxkad.c index eebefb6ef139..ac3cabdca78c 100644 --- a/trunk/net/rxrpc/rxkad.c +++ b/trunk/net/rxrpc/rxkad.c @@ -135,8 +135,9 @@ static void rxkad_prime_packet_security(struct rxrpc_connection *conn) tmpbuf.x[2] = 0; tmpbuf.x[3] = htonl(conn->security_ix); - sg_init_one(&sg[0], &tmpbuf, sizeof(tmpbuf)); - sg_init_one(&sg[1], &tmpbuf, sizeof(tmpbuf)); + memset(sg, 0, sizeof(sg)); + sg_set_buf(&sg[0], &tmpbuf, sizeof(tmpbuf)); + sg_set_buf(&sg[1], &tmpbuf, sizeof(tmpbuf)); crypto_blkcipher_encrypt_iv(&desc, &sg[0], &sg[1], sizeof(tmpbuf)); memcpy(&conn->csum_iv, &tmpbuf.x[2], sizeof(conn->csum_iv)); @@ -179,8 +180,9 @@ static int rxkad_secure_packet_auth(const struct rxrpc_call *call, desc.info = iv.x; desc.flags = 0; - sg_init_one(&sg[0], &tmpbuf, sizeof(tmpbuf)); - sg_init_one(&sg[1], &tmpbuf, sizeof(tmpbuf)); + memset(sg, 0, sizeof(sg)); + sg_set_buf(&sg[0], &tmpbuf, sizeof(tmpbuf)); + sg_set_buf(&sg[1], &tmpbuf, sizeof(tmpbuf)); crypto_blkcipher_encrypt_iv(&desc, &sg[0], &sg[1], sizeof(tmpbuf)); memcpy(sechdr, &tmpbuf, sizeof(tmpbuf)); @@ -225,8 +227,9 @@ static int rxkad_secure_packet_encrypt(const struct rxrpc_call *call, desc.info = iv.x; desc.flags = 0; - sg_init_one(&sg[0], sechdr, sizeof(rxkhdr)); - sg_init_one(&sg[1], &rxkhdr, sizeof(rxkhdr)); + memset(sg, 0, sizeof(sg[0]) * 2); + sg_set_buf(&sg[0], sechdr, sizeof(rxkhdr)); + sg_set_buf(&sg[1], &rxkhdr, sizeof(rxkhdr)); crypto_blkcipher_encrypt_iv(&desc, &sg[0], &sg[1], sizeof(rxkhdr)); /* we want to encrypt the skbuff in-place */ @@ -237,7 +240,7 @@ static int rxkad_secure_packet_encrypt(const struct rxrpc_call *call, len = data_size + call->conn->size_align - 1; len &= ~(call->conn->size_align - 1); - sg_init_table(sg, skb_to_sgvec(skb, sg, 0, len)); + skb_to_sgvec(skb, sg, 0, len); crypto_blkcipher_encrypt_iv(&desc, sg, sg, len); _leave(" = 0"); @@ -287,8 +290,9 @@ static int rxkad_secure_packet(const struct rxrpc_call *call, tmpbuf.x[0] = sp->hdr.callNumber; tmpbuf.x[1] = x; - sg_init_one(&sg[0], &tmpbuf, sizeof(tmpbuf)); - sg_init_one(&sg[1], &tmpbuf, sizeof(tmpbuf)); + memset(&sg, 0, sizeof(sg)); + sg_set_buf(&sg[0], &tmpbuf, sizeof(tmpbuf)); + sg_set_buf(&sg[1], &tmpbuf, sizeof(tmpbuf)); crypto_blkcipher_encrypt_iv(&desc, &sg[0], &sg[1], sizeof(tmpbuf)); x = ntohl(tmpbuf.x[1]); @@ -328,23 +332,20 @@ static int rxkad_verify_packet_auth(const struct rxrpc_call *call, struct rxrpc_skb_priv *sp; struct blkcipher_desc desc; struct rxrpc_crypt iv; - struct scatterlist sg[16]; + struct scatterlist sg[2]; struct sk_buff *trailer; u32 data_size, buf; u16 check; - int nsg; _enter(""); sp = rxrpc_skb(skb); /* we want to decrypt the skbuff in-place */ - nsg = skb_cow_data(skb, 0, &trailer); - if (nsg < 0 || nsg > 16) + if (skb_cow_data(skb, 0, &trailer) < 0) goto nomem; - sg_init_table(sg, nsg); - sg_mark_end(sg, skb_to_sgvec(skb, sg, 0, 8)); + skb_to_sgvec(skb, sg, 0, 8); /* start the decryption afresh */ memset(&iv, 0, sizeof(iv)); @@ -425,8 +426,7 @@ static int rxkad_verify_packet_encrypt(const struct rxrpc_call *call, goto nomem; } - sg_init_table(sg, nsg); - sg_mark_end(sg, skb_to_sgvec(skb, sg, 0, skb->len)); + skb_to_sgvec(skb, sg, 0, skb->len); /* decrypt from the session key */ payload = call->conn->key->payload.data; @@ -521,8 +521,9 @@ static int rxkad_verify_packet(const struct rxrpc_call *call, tmpbuf.x[0] = call->call_id; tmpbuf.x[1] = x; - sg_init_one(&sg[0], &tmpbuf, sizeof(tmpbuf)); - sg_init_one(&sg[1], &tmpbuf, sizeof(tmpbuf)); + memset(&sg, 0, sizeof(sg)); + sg_set_buf(&sg[0], &tmpbuf, sizeof(tmpbuf)); + sg_set_buf(&sg[1], &tmpbuf, sizeof(tmpbuf)); crypto_blkcipher_encrypt_iv(&desc, &sg[0], &sg[1], sizeof(tmpbuf)); x = ntohl(tmpbuf.x[1]); @@ -689,20 +690,16 @@ static void rxkad_calc_response_checksum(struct rxkad_response *response) static void rxkad_sg_set_buf2(struct scatterlist sg[2], void *buf, size_t buflen) { - int nsg = 1; - sg_init_table(sg, 2); + memset(sg, 0, sizeof(sg)); sg_set_buf(&sg[0], buf, buflen); if (sg[0].offset + buflen > PAGE_SIZE) { /* the buffer was split over two pages */ sg[0].length = PAGE_SIZE - sg[0].offset; sg_set_buf(&sg[1], buf + sg[0].length, buflen - sg[0].length); - nsg++; } - sg_mark_end(sg, nsg); - ASSERTCMP(sg[0].length + sg[1].length, ==, buflen); } @@ -715,7 +712,7 @@ static void rxkad_encrypt_response(struct rxrpc_connection *conn, { struct blkcipher_desc desc; struct rxrpc_crypt iv; - struct scatterlist sg[2]; + struct scatterlist ssg[2], dsg[2]; /* continue encrypting from where we left off */ memcpy(&iv, s2->session_key, sizeof(iv)); @@ -723,8 +720,9 @@ static void rxkad_encrypt_response(struct rxrpc_connection *conn, desc.info = iv.x; desc.flags = 0; - rxkad_sg_set_buf2(sg, &resp->encrypted, sizeof(resp->encrypted)); - crypto_blkcipher_encrypt_iv(&desc, sg, sg, sizeof(resp->encrypted)); + rxkad_sg_set_buf2(ssg, &resp->encrypted, sizeof(resp->encrypted)); + memcpy(dsg, ssg, sizeof(dsg)); + crypto_blkcipher_encrypt_iv(&desc, dsg, ssg, sizeof(resp->encrypted)); } /* @@ -819,7 +817,7 @@ static int rxkad_decrypt_ticket(struct rxrpc_connection *conn, { struct blkcipher_desc desc; struct rxrpc_crypt iv, key; - struct scatterlist sg[1]; + struct scatterlist ssg[1], dsg[1]; struct in_addr addr; unsigned life; time_t issue, now; @@ -852,8 +850,9 @@ static int rxkad_decrypt_ticket(struct rxrpc_connection *conn, desc.info = iv.x; desc.flags = 0; - sg_init_one(&sg[0], ticket, ticket_len); - crypto_blkcipher_decrypt_iv(&desc, sg, sg, ticket_len); + sg_init_one(&ssg[0], ticket, ticket_len); + memcpy(dsg, ssg, sizeof(dsg)); + crypto_blkcipher_decrypt_iv(&desc, dsg, ssg, ticket_len); p = ticket; end = p + ticket_len; @@ -962,7 +961,7 @@ static void rxkad_decrypt_response(struct rxrpc_connection *conn, const struct rxrpc_crypt *session_key) { struct blkcipher_desc desc; - struct scatterlist sg[2]; + struct scatterlist ssg[2], dsg[2]; struct rxrpc_crypt iv; _enter(",,%08x%08x", @@ -980,8 +979,9 @@ static void rxkad_decrypt_response(struct rxrpc_connection *conn, desc.info = iv.x; desc.flags = 0; - rxkad_sg_set_buf2(sg, &resp->encrypted, sizeof(resp->encrypted)); - crypto_blkcipher_decrypt_iv(&desc, sg, sg, sizeof(resp->encrypted)); + rxkad_sg_set_buf2(ssg, &resp->encrypted, sizeof(resp->encrypted)); + memcpy(dsg, ssg, sizeof(dsg)); + crypto_blkcipher_decrypt_iv(&desc, dsg, ssg, sizeof(resp->encrypted)); mutex_unlock(&rxkad_ci_mutex); _leave(""); diff --git a/trunk/net/sched/act_mirred.c b/trunk/net/sched/act_mirred.c index c3fde9180f9d..fd7bca4d5c20 100644 --- a/trunk/net/sched/act_mirred.c +++ b/trunk/net/sched/act_mirred.c @@ -166,7 +166,7 @@ static int tcf_mirred(struct sk_buff *skb, struct tc_action *a, return TC_ACT_SHOT; } - skb2 = skb_act_clone(skb, GFP_ATOMIC); + skb2 = skb_clone(skb, GFP_ATOMIC); if (skb2 == NULL) goto bad_mirred; if (m->tcfm_eaction != TCA_EGRESS_MIRROR && diff --git a/trunk/net/sched/sch_prio.c b/trunk/net/sched/sch_prio.c index de894096e442..abd82fc3ec60 100644 --- a/trunk/net/sched/sch_prio.c +++ b/trunk/net/sched/sch_prio.c @@ -136,7 +136,7 @@ prio_dequeue(struct Qdisc* sch) * pulling an skb. This way we avoid excessive requeues * for slower queues. */ - if (!__netif_subqueue_stopped(sch->dev, (q->mq ? prio : 0))) { + if (!netif_subqueue_stopped(sch->dev, (q->mq ? prio : 0))) { qdisc = q->queues[prio]; skb = qdisc->dequeue(qdisc); if (skb) { @@ -165,7 +165,7 @@ static struct sk_buff *rr_dequeue(struct Qdisc* sch) * for slower queues. If the queue is stopped, try the * next queue. */ - if (!__netif_subqueue_stopped(sch->dev, + if (!netif_subqueue_stopped(sch->dev, (q->mq ? q->curband : 0))) { qdisc = q->queues[q->curband]; skb = qdisc->dequeue(qdisc); diff --git a/trunk/net/sctp/auth.c b/trunk/net/sctp/auth.c index 6d5fa6bb371b..cbd64b216cce 100644 --- a/trunk/net/sctp/auth.c +++ b/trunk/net/sctp/auth.c @@ -107,7 +107,7 @@ struct sctp_shared_key *sctp_auth_shkey_create(__u16 key_id, gfp_t gfp) } /* Free the shared key stucture */ -static void sctp_auth_shkey_free(struct sctp_shared_key *sh_key) +void sctp_auth_shkey_free(struct sctp_shared_key *sh_key) { BUG_ON(!list_empty(&sh_key->key_list)); sctp_auth_key_put(sh_key->key); @@ -220,7 +220,7 @@ static struct sctp_auth_bytes *sctp_auth_make_key_vector( /* Make a key vector based on our local parameters */ -static struct sctp_auth_bytes *sctp_auth_make_local_vector( +struct sctp_auth_bytes *sctp_auth_make_local_vector( const struct sctp_association *asoc, gfp_t gfp) { @@ -232,7 +232,7 @@ static struct sctp_auth_bytes *sctp_auth_make_local_vector( } /* Make a key vector based on peer's parameters */ -static struct sctp_auth_bytes *sctp_auth_make_peer_vector( +struct sctp_auth_bytes *sctp_auth_make_peer_vector( const struct sctp_association *asoc, gfp_t gfp) { @@ -556,7 +556,7 @@ struct sctp_hmac *sctp_auth_asoc_get_hmac(const struct sctp_association *asoc) return &sctp_hmac_list[id]; } -static int __sctp_auth_find_hmacid(__be16 *hmacs, int n_elts, __be16 hmac_id) +static int __sctp_auth_find_hmacid(__u16 *hmacs, int n_elts, __u16 hmac_id) { int found = 0; int i; @@ -573,7 +573,7 @@ static int __sctp_auth_find_hmacid(__be16 *hmacs, int n_elts, __be16 hmac_id) /* See if the HMAC_ID is one that we claim as supported */ int sctp_auth_asoc_verify_hmac_id(const struct sctp_association *asoc, - __be16 hmac_id) + __u16 hmac_id) { struct sctp_hmac_algo_param *hmacs; __u16 n_elt; @@ -726,7 +726,10 @@ void sctp_auth_calculate_hmac(const struct sctp_association *asoc, /* set up scatter list */ end = skb_tail_pointer(skb); - sg_init_one(&sg, auth, end - (unsigned char *)auth); + sg_init_table(&sg, 1); + sg_set_page(&sg, virt_to_page(auth)); + sg.offset = (unsigned long)(auth) % PAGE_SIZE; + sg.length = end - (unsigned char *)auth; desc.tfm = asoc->ep->auth_hmacs[hmac_id]; desc.flags = 0; diff --git a/trunk/net/sctp/crc32c.c b/trunk/net/sctp/crc32c.c index 181edabdb8ca..59cf7b06d216 100644 --- a/trunk/net/sctp/crc32c.c +++ b/trunk/net/sctp/crc32c.c @@ -170,7 +170,6 @@ __u32 sctp_update_cksum(__u8 *buffer, __u16 length, __u32 crc32) return crc32; } -#if 0 __u32 sctp_update_copy_cksum(__u8 *to, __u8 *from, __u16 length, __u32 crc32) { __u32 i; @@ -187,7 +186,6 @@ __u32 sctp_update_copy_cksum(__u8 *to, __u8 *from, __u16 length, __u32 crc32) return crc32; } -#endif /* 0 */ __u32 sctp_end_cksum(__u32 crc32) { diff --git a/trunk/net/sctp/sm_make_chunk.c b/trunk/net/sctp/sm_make_chunk.c index c377e4e8f653..658476c4d587 100644 --- a/trunk/net/sctp/sm_make_chunk.c +++ b/trunk/net/sctp/sm_make_chunk.c @@ -1513,7 +1513,10 @@ static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep, struct hash_desc desc; /* Sign the message. */ - sg_init_one(&sg, &cookie->c, bodysize); + sg_init_table(&sg, 1); + sg_set_page(&sg, virt_to_page(&cookie->c)); + sg.offset = (unsigned long)(&cookie->c) % PAGE_SIZE; + sg.length = bodysize; keylen = SCTP_SECRET_SIZE; key = (char *)ep->secret_key[ep->current_key]; desc.tfm = sctp_sk(ep->base.sk)->hmac; @@ -1583,7 +1586,10 @@ struct sctp_association *sctp_unpack_cookie( /* Check the signature. */ keylen = SCTP_SECRET_SIZE; - sg_init_one(&sg, bear_cookie, bodysize); + sg_init_table(&sg, 1); + sg_set_page(&sg, virt_to_page(bear_cookie)); + sg.offset = (unsigned long)(bear_cookie) % PAGE_SIZE; + sg.length = bodysize; key = (char *)ep->secret_key[ep->current_key]; desc.tfm = sctp_sk(ep->base.sk)->hmac; desc.flags = 0; diff --git a/trunk/net/sctp/ulpqueue.c b/trunk/net/sctp/ulpqueue.c index 4be92d0a2cab..b9370956b187 100644 --- a/trunk/net/sctp/ulpqueue.c +++ b/trunk/net/sctp/ulpqueue.c @@ -908,8 +908,8 @@ void sctp_ulpq_skip(struct sctp_ulpq *ulpq, __u16 sid, __u16 ssn) return; } -static __u16 sctp_ulpq_renege_list(struct sctp_ulpq *ulpq, - struct sk_buff_head *list, __u16 needed) +/* Renege 'needed' bytes from the ordering queue. */ +static __u16 sctp_ulpq_renege_order(struct sctp_ulpq *ulpq, __u16 needed) { __u16 freed = 0; __u32 tsn; @@ -919,7 +919,7 @@ static __u16 sctp_ulpq_renege_list(struct sctp_ulpq *ulpq, tsnmap = &ulpq->asoc->peer.tsn_map; - while ((skb = __skb_dequeue_tail(list)) != NULL) { + while ((skb = __skb_dequeue_tail(&ulpq->lobby)) != NULL) { freed += skb_headlen(skb); event = sctp_skb2event(skb); tsn = event->tsn; @@ -933,16 +933,30 @@ static __u16 sctp_ulpq_renege_list(struct sctp_ulpq *ulpq, return freed; } -/* Renege 'needed' bytes from the ordering queue. */ -static __u16 sctp_ulpq_renege_order(struct sctp_ulpq *ulpq, __u16 needed) -{ - return sctp_ulpq_renege_list(ulpq, &ulpq->lobby, needed); -} - /* Renege 'needed' bytes from the reassembly queue. */ static __u16 sctp_ulpq_renege_frags(struct sctp_ulpq *ulpq, __u16 needed) { - return sctp_ulpq_renege_list(ulpq, &ulpq->reasm, needed); + __u16 freed = 0; + __u32 tsn; + struct sk_buff *skb; + struct sctp_ulpevent *event; + struct sctp_tsnmap *tsnmap; + + tsnmap = &ulpq->asoc->peer.tsn_map; + + /* Walk backwards through the list, reneges the newest tsns. */ + while ((skb = __skb_dequeue_tail(&ulpq->reasm)) != NULL) { + freed += skb_headlen(skb); + event = sctp_skb2event(skb); + tsn = event->tsn; + + sctp_ulpevent_free(event); + sctp_tsnmap_renege(tsnmap, tsn); + if (freed >= needed) + return freed; + } + + return freed; } /* Partial deliver the first message as there is pressure on rwnd. */ diff --git a/trunk/net/socket.c b/trunk/net/socket.c index 5d879fd3d01d..540013ea8620 100644 --- a/trunk/net/socket.c +++ b/trunk/net/socket.c @@ -1250,14 +1250,11 @@ asmlinkage long sys_socketpair(int family, int type, int protocol, goto out_release_both; fd1 = sock_alloc_fd(&newfile1); - if (unlikely(fd1 < 0)) { - err = fd1; + if (unlikely(fd1 < 0)) goto out_release_both; - } fd2 = sock_alloc_fd(&newfile2); if (unlikely(fd2 < 0)) { - err = fd2; put_filp(newfile1); put_unused_fd(fd1); goto out_release_both; diff --git a/trunk/net/sunrpc/auth_gss/gss_krb5_crypto.c b/trunk/net/sunrpc/auth_gss/gss_krb5_crypto.c index 91cd8f0d1e10..32be431affcf 100644 --- a/trunk/net/sunrpc/auth_gss/gss_krb5_crypto.c +++ b/trunk/net/sunrpc/auth_gss/gss_krb5_crypto.c @@ -75,7 +75,7 @@ krb5_encrypt( memcpy(local_iv, iv, crypto_blkcipher_ivsize(tfm)); memcpy(out, in, length); - sg_init_one(sg, out, length); + sg_set_buf(sg, out, length); ret = crypto_blkcipher_encrypt_iv(&desc, sg, sg, length); out: @@ -110,7 +110,7 @@ krb5_decrypt( memcpy(local_iv,iv, crypto_blkcipher_ivsize(tfm)); memcpy(out, in, length); - sg_init_one(sg, out, length); + sg_set_buf(sg, out, length); ret = crypto_blkcipher_decrypt_iv(&desc, sg, sg, length); out: @@ -146,7 +146,7 @@ make_checksum(char *cksumname, char *header, int hdrlen, struct xdr_buf *body, err = crypto_hash_init(&desc); if (err) goto out; - sg_init_one(sg, header, hdrlen); + sg_set_buf(sg, header, hdrlen); err = crypto_hash_update(&desc, sg, hdrlen); if (err) goto out; @@ -188,6 +188,8 @@ encryptor(struct scatterlist *sg, void *data) /* Worst case is 4 fragments: head, end of page 1, start * of page 2, tail. Anything more is a bug. */ BUG_ON(desc->fragno > 3); + desc->infrags[desc->fragno] = *sg; + desc->outfrags[desc->fragno] = *sg; page_pos = desc->pos - outbuf->head[0].iov_len; if (page_pos >= 0 && page_pos < outbuf->page_len) { @@ -197,10 +199,7 @@ encryptor(struct scatterlist *sg, void *data) } else { in_page = sg_page(sg); } - sg_set_page(&desc->infrags[desc->fragno], in_page, sg->length, - sg->offset); - sg_set_page(&desc->outfrags[desc->fragno], sg_page(sg), sg->length, - sg->offset); + sg_set_page(&desc->infrags[desc->fragno], in_page); desc->fragno++; desc->fraglen += sg->length; desc->pos += sg->length; @@ -211,22 +210,16 @@ encryptor(struct scatterlist *sg, void *data) if (thislen == 0) return 0; - sg_mark_end(desc->infrags, desc->fragno); - sg_mark_end(desc->outfrags, desc->fragno); - ret = crypto_blkcipher_encrypt_iv(&desc->desc, desc->outfrags, desc->infrags, thislen); if (ret) return ret; - - sg_init_table(desc->infrags, 4); - sg_init_table(desc->outfrags, 4); - if (fraglen) { - sg_set_page(&desc->outfrags[0], sg_page(sg), fraglen, - sg->offset + sg->length - fraglen); + sg_set_page(&desc->outfrags[0], sg_page(sg)); + desc->outfrags[0].offset = sg->offset + sg->length - fraglen; + desc->outfrags[0].length = fraglen; desc->infrags[0] = desc->outfrags[0]; - sg_assign_page(&desc->infrags[0], in_page); + sg_set_page(&desc->infrags[0], in_page); desc->fragno = 1; desc->fraglen = fraglen; } else { @@ -255,9 +248,6 @@ gss_encrypt_xdr_buf(struct crypto_blkcipher *tfm, struct xdr_buf *buf, desc.fragno = 0; desc.fraglen = 0; - sg_init_table(desc.infrags, 4); - sg_init_table(desc.outfrags, 4); - ret = xdr_process_buf(buf, offset, buf->len - offset, encryptor, &desc); return ret; } @@ -282,8 +272,7 @@ decryptor(struct scatterlist *sg, void *data) /* Worst case is 4 fragments: head, end of page 1, start * of page 2, tail. Anything more is a bug. */ BUG_ON(desc->fragno > 3); - sg_set_page(&desc->frags[desc->fragno], sg_page(sg), sg->length, - sg->offset); + desc->frags[desc->fragno] = *sg; desc->fragno++; desc->fraglen += sg->length; @@ -293,18 +282,14 @@ decryptor(struct scatterlist *sg, void *data) if (thislen == 0) return 0; - sg_mark_end(desc->frags, desc->fragno); - ret = crypto_blkcipher_decrypt_iv(&desc->desc, desc->frags, desc->frags, thislen); if (ret) return ret; - - sg_init_table(desc->frags, 4); - if (fraglen) { - sg_set_page(&desc->frags[0], sg_page(sg), fraglen, - sg->offset + sg->length - fraglen); + sg_set_page(&desc->frags[0], sg_page(sg)); + desc->frags[0].offset = sg->offset + sg->length - fraglen; + desc->frags[0].length = fraglen; desc->fragno = 1; desc->fraglen = fraglen; } else { @@ -329,9 +314,6 @@ gss_decrypt_xdr_buf(struct crypto_blkcipher *tfm, struct xdr_buf *buf, desc.desc.flags = 0; desc.fragno = 0; desc.fraglen = 0; - - sg_init_table(desc.frags, 4); - return xdr_process_buf(buf, offset, buf->len - offset, decryptor, &desc); } diff --git a/trunk/net/sunrpc/auth_gss/gss_spkm3_seal.c b/trunk/net/sunrpc/auth_gss/gss_spkm3_seal.c index abf17ce2e3b1..d158635de6c0 100644 --- a/trunk/net/sunrpc/auth_gss/gss_spkm3_seal.c +++ b/trunk/net/sunrpc/auth_gss/gss_spkm3_seal.c @@ -173,7 +173,7 @@ make_spkm3_checksum(s32 cksumtype, struct xdr_netobj *key, char *header, if (err) goto out; - sg_init_one(sg, header, hdrlen); + sg_set_buf(sg, header, hdrlen); crypto_hash_update(&desc, sg, sg->length); xdr_process_buf(body, body_offset, body->len - body_offset, diff --git a/trunk/net/sunrpc/sysctl.c b/trunk/net/sunrpc/sysctl.c index 2be714e9b382..864b541bbf51 100644 --- a/trunk/net/sunrpc/sysctl.c +++ b/trunk/net/sunrpc/sysctl.c @@ -87,8 +87,9 @@ proc_dodebug(ctl_table *table, int write, struct file *file, left--, s++; *(unsigned int *) table->data = value; /* Display the RPC tasks on writing to rpc_debug */ - if (strcmp(table->procname, "rpc_debug") == 0) + if (table->ctl_name == CTL_RPCDEBUG) { rpc_show_tasks(); + } } else { if (!access_ok(VERIFY_WRITE, buffer, left)) return -EFAULT; diff --git a/trunk/net/sunrpc/xdr.c b/trunk/net/sunrpc/xdr.c index fdc5e6d7562b..3d1f7cdf9dd0 100644 --- a/trunk/net/sunrpc/xdr.c +++ b/trunk/net/sunrpc/xdr.c @@ -1030,8 +1030,6 @@ xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len, unsigned page_len, thislen, page_offset; struct scatterlist sg[1]; - sg_init_table(sg, 1); - if (offset >= buf->head[0].iov_len) { offset -= buf->head[0].iov_len; } else { @@ -1061,7 +1059,9 @@ xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len, do { if (thislen > page_len) thislen = page_len; - sg_set_page(sg, buf->pages[i], thislen, page_offset); + sg_set_page(sg, buf->pages[i]); + sg->offset = page_offset; + sg->length = thislen; ret = actor(sg, data); if (ret) goto out; diff --git a/trunk/net/sunrpc/xprtrdma/rpc_rdma.c b/trunk/net/sunrpc/xprtrdma/rpc_rdma.c index 9e11ce715958..12db63580427 100644 --- a/trunk/net/sunrpc/xprtrdma/rpc_rdma.c +++ b/trunk/net/sunrpc/xprtrdma/rpc_rdma.c @@ -181,7 +181,7 @@ rpcrdma_create_chunks(struct rpc_rqst *rqst, struct xdr_buf *target, struct rpcrdma_read_chunk *cur_rchunk = NULL; struct rpcrdma_write_array *warray = NULL; struct rpcrdma_write_chunk *cur_wchunk = NULL; - __be32 *iptr = headerp->rm_body.rm_chunks; + u32 *iptr = headerp->rm_body.rm_chunks; if (type == rpcrdma_readch || type == rpcrdma_areadch) { /* a read chunk - server will RDMA Read our memory */ @@ -217,25 +217,25 @@ rpcrdma_create_chunks(struct rpc_rqst *rqst, struct xdr_buf *target, cur_rchunk->rc_target.rs_handle = htonl(seg->mr_rkey); cur_rchunk->rc_target.rs_length = htonl(seg->mr_len); xdr_encode_hyper( - (__be32 *)&cur_rchunk->rc_target.rs_offset, + (u32 *)&cur_rchunk->rc_target.rs_offset, seg->mr_base); dprintk("RPC: %s: read chunk " "elem %d@0x%llx:0x%x pos %d (%s)\n", __func__, - seg->mr_len, (unsigned long long)seg->mr_base, - seg->mr_rkey, pos, n < nsegs ? "more" : "last"); + seg->mr_len, seg->mr_base, seg->mr_rkey, pos, + n < nsegs ? "more" : "last"); cur_rchunk++; r_xprt->rx_stats.read_chunk_count++; } else { /* write/reply */ cur_wchunk->wc_target.rs_handle = htonl(seg->mr_rkey); cur_wchunk->wc_target.rs_length = htonl(seg->mr_len); xdr_encode_hyper( - (__be32 *)&cur_wchunk->wc_target.rs_offset, + (u32 *)&cur_wchunk->wc_target.rs_offset, seg->mr_base); dprintk("RPC: %s: %s chunk " "elem %d@0x%llx:0x%x (%s)\n", __func__, (type == rpcrdma_replych) ? "reply" : "write", - seg->mr_len, (unsigned long long)seg->mr_base, - seg->mr_rkey, n < nsegs ? "more" : "last"); + seg->mr_len, seg->mr_base, seg->mr_rkey, + n < nsegs ? "more" : "last"); cur_wchunk++; if (type == rpcrdma_replych) r_xprt->rx_stats.reply_chunk_count++; @@ -257,14 +257,14 @@ rpcrdma_create_chunks(struct rpc_rqst *rqst, struct xdr_buf *target, * finish off header. If write, marshal discrim and nchunks. */ if (cur_rchunk) { - iptr = (__be32 *) cur_rchunk; + iptr = (u32 *) cur_rchunk; *iptr++ = xdr_zero; /* finish the read chunk list */ *iptr++ = xdr_zero; /* encode a NULL write chunk list */ *iptr++ = xdr_zero; /* encode a NULL reply chunk */ } else { warray->wc_discrim = xdr_one; warray->wc_nchunks = htonl(nchunks); - iptr = (__be32 *) cur_wchunk; + iptr = (u32 *) cur_wchunk; if (type == rpcrdma_writech) { *iptr++ = xdr_zero; /* finish the write chunk list */ *iptr++ = xdr_zero; /* encode a NULL reply chunk */ @@ -559,7 +559,7 @@ rpcrdma_marshal_req(struct rpc_rqst *rqst) * RDMA'd by server. See map at rpcrdma_create_chunks()! :-) */ static int -rpcrdma_count_chunks(struct rpcrdma_rep *rep, int max, int wrchunk, __be32 **iptrp) +rpcrdma_count_chunks(struct rpcrdma_rep *rep, int max, int wrchunk, u32 **iptrp) { unsigned int i, total_len; struct rpcrdma_write_chunk *cur_wchunk; @@ -573,11 +573,11 @@ rpcrdma_count_chunks(struct rpcrdma_rep *rep, int max, int wrchunk, __be32 **ipt struct rpcrdma_segment *seg = &cur_wchunk->wc_target; ifdebug(FACILITY) { u64 off; - xdr_decode_hyper((__be32 *)&seg->rs_offset, &off); + xdr_decode_hyper((u32 *)&seg->rs_offset, &off); dprintk("RPC: %s: chunk %d@0x%llx:0x%x\n", __func__, ntohl(seg->rs_length), - (unsigned long long)off, + off, ntohl(seg->rs_handle)); } total_len += ntohl(seg->rs_length); @@ -585,7 +585,7 @@ rpcrdma_count_chunks(struct rpcrdma_rep *rep, int max, int wrchunk, __be32 **ipt } /* check and adjust for properly terminated write chunk */ if (wrchunk) { - __be32 *w = (__be32 *) cur_wchunk; + u32 *w = (u32 *) cur_wchunk; if (*w++ != xdr_zero) return -1; cur_wchunk = (struct rpcrdma_write_chunk *) w; @@ -593,7 +593,7 @@ rpcrdma_count_chunks(struct rpcrdma_rep *rep, int max, int wrchunk, __be32 **ipt if ((char *) cur_wchunk > rep->rr_base + rep->rr_len) return -1; - *iptrp = (__be32 *) cur_wchunk; + *iptrp = (u32 *) cur_wchunk; return total_len; } @@ -721,7 +721,7 @@ rpcrdma_reply_handler(struct rpcrdma_rep *rep) struct rpc_rqst *rqst; struct rpc_xprt *xprt = rep->rr_xprt; struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt); - __be32 *iptr; + u32 *iptr; int i, rdmalen, status; /* Check status. If bad, signal disconnect and return rep to pool */ @@ -801,7 +801,7 @@ rpcrdma_reply_handler(struct rpcrdma_rep *rep) r_xprt->rx_stats.total_rdma_reply += rdmalen; } else { /* else ordinary inline */ - iptr = (__be32 *)((unsigned char *)headerp + 28); + iptr = (u32 *)((unsigned char *)headerp + 28); rep->rr_len -= 28; /*sizeof *headerp;*/ status = rep->rr_len; } @@ -816,7 +816,7 @@ rpcrdma_reply_handler(struct rpcrdma_rep *rep) headerp->rm_body.rm_chunks[2] != xdr_one || req->rl_nchunks == 0) goto badheader; - iptr = (__be32 *)((unsigned char *)headerp + 28); + iptr = (u32 *)((unsigned char *)headerp + 28); rdmalen = rpcrdma_count_chunks(rep, req->rl_nchunks, 0, &iptr); if (rdmalen < 0) goto badheader; diff --git a/trunk/net/xfrm/xfrm_algo.c b/trunk/net/xfrm/xfrm_algo.c index 0426388d351d..313d4bed3aa9 100644 --- a/trunk/net/xfrm/xfrm_algo.c +++ b/trunk/net/xfrm/xfrm_algo.c @@ -553,7 +553,9 @@ int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc, if (copy > len) copy = len; - sg_init_one(&sg, skb->data + offset, copy); + sg_set_page(&sg, virt_to_page(skb->data + offset)); + sg.offset = (unsigned long)(skb->data + offset) % PAGE_SIZE; + sg.length = copy; err = icv_update(desc, &sg, copy); if (unlikely(err)) @@ -576,9 +578,9 @@ int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc, if (copy > len) copy = len; - sg_init_table(&sg, 1); - sg_set_page(&sg, frag->page, copy, - frag->page_offset + offset-start); + sg_set_page(&sg, frag->page); + sg.offset = frag->page_offset + offset-start; + sg.length = copy; err = icv_update(desc, &sg, copy); if (unlikely(err)) diff --git a/trunk/scripts/kconfig/Makefile b/trunk/scripts/kconfig/Makefile index 59594126e8b6..83c5e76414ce 100644 --- a/trunk/scripts/kconfig/Makefile +++ b/trunk/scripts/kconfig/Makefile @@ -4,30 +4,23 @@ PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config -# If a arch/$(SRCARCH)/Kconfig.$(ARCH) file exist use it -ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/Kconfig.$(ARCH)),) - Kconfig := arch/$(SRCARCH)/Kconfig.$(ARCH) -else - Kconfig := arch/$(SRCARCH)/Kconfig -endif - xconfig: $(obj)/qconf - $< $(Kconfig) + $< arch/$(ARCH)/Kconfig gconfig: $(obj)/gconf - $< $(Kconfig) + $< arch/$(ARCH)/Kconfig menuconfig: $(obj)/mconf - $< $(Kconfig) + $< arch/$(ARCH)/Kconfig config: $(obj)/conf - $< $(Kconfig) + $< arch/$(ARCH)/Kconfig oldconfig: $(obj)/conf - $< -o $(Kconfig) + $< -o arch/$(ARCH)/Kconfig silentoldconfig: $(obj)/conf - $< -s $(Kconfig) + $< -s arch/$(ARCH)/Kconfig # Create new linux.po file # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files @@ -52,27 +45,27 @@ update-po-config: $(obj)/kxgettext PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig randconfig: $(obj)/conf - $< -r $(Kconfig) + $< -r arch/$(ARCH)/Kconfig allyesconfig: $(obj)/conf - $< -y $(Kconfig) + $< -y arch/$(ARCH)/Kconfig allnoconfig: $(obj)/conf - $< -n $(Kconfig) + $< -n arch/$(ARCH)/Kconfig allmodconfig: $(obj)/conf - $< -m $(Kconfig) + $< -m arch/$(ARCH)/Kconfig defconfig: $(obj)/conf ifeq ($(KBUILD_DEFCONFIG),) - $< -d $(Kconfig) + $< -d arch/$(ARCH)/Kconfig else - @echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" - $(Q)$< -D arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) + @echo *** Default configuration is based on '$(KBUILD_DEFCONFIG)' + $(Q)$< -D arch/$(ARCH)/configs/$(KBUILD_DEFCONFIG) arch/$(ARCH)/Kconfig endif %_defconfig: $(obj)/conf - $(Q)$< -D arch/$(SRCARCH)/configs/$@ $(Kconfig) + $(Q)$< -D arch/$(ARCH)/configs/$@ arch/$(ARCH)/Kconfig # Help text used by make help help: diff --git a/trunk/sound/drivers/mts64.c b/trunk/sound/drivers/mts64.c index dcc90f995294..911c159bb3d3 100644 --- a/trunk/sound/drivers/mts64.c +++ b/trunk/sound/drivers/mts64.c @@ -830,7 +830,7 @@ static int __devinit snd_mts64_rawmidi_create(struct snd_card *card) /********************************************************************* * parport stuff *********************************************************************/ -static void snd_mts64_interrupt(void *private) +static void snd_mts64_interrupt(int irq, void *private) { struct mts64 *mts = ((struct snd_card*)private)->private_data; u16 ret; diff --git a/trunk/sound/drivers/portman2x4.c b/trunk/sound/drivers/portman2x4.c index e065b2a6444a..0eb9b5cebfcd 100644 --- a/trunk/sound/drivers/portman2x4.c +++ b/trunk/sound/drivers/portman2x4.c @@ -611,7 +611,7 @@ static int __devinit snd_portman_rawmidi_create(struct snd_card *card) /********************************************************************* * parport stuff *********************************************************************/ -static void snd_portman_interrupt(void *userdata) +static void snd_portman_interrupt(int irq, void *userdata) { unsigned char midivalue = 0; struct portman *pm = ((struct snd_card*)userdata)->private_data; diff --git a/trunk/sound/pci/hda/patch_realtek.c b/trunk/sound/pci/hda/patch_realtek.c index 1c502789cc1e..d9f78c809ee9 100644 --- a/trunk/sound/pci/hda/patch_realtek.c +++ b/trunk/sound/pci/hda/patch_realtek.c @@ -9299,6 +9299,7 @@ static struct alc_config_preset alc268_presets[] = { .num_channel_mode = ARRAY_SIZE(alc268_modes), .channel_mode = alc268_modes, .input_mux = &alc268_capture_source, + .input_mux = &alc268_capture_source, .unsol_event = alc268_toshiba_unsol_event, .init_hook = alc268_toshiba_automute, },