Merge git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc

* git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc: (67 commits)
  [PATCH] powerpc: Remove oprofile spinlock backtrace code
  [PATCH] powerpc: Add oprofile calltrace support to all powerpc cpus
  [PATCH] powerpc: Add oprofile calltrace support
  [PATCH] for_each_possible_cpu: ppc
  [PATCH] for_each_possible_cpu: powerpc
  [PATCH] lock PTE before updating it in 440/BookE page fault handler
  [PATCH] powerpc: Kill _machine and hard-coded platform numbers
  ppc: Fix compile error in arch/ppc/lib/strcase.c
  [PATCH] git-powerpc: WARN was a dumb idea
  [PATCH] powerpc: a couple of trivial compile warning fixes
  powerpc: remove OCP references
  powerpc: Make uImage default build output for MPC8540 ADS
  powerpc: move math-emu over to arch/powerpc
  powerpc: use memparse() for mem= command line parsing
  ppc: fix strncasecmp prototype
  [PATCH] powerpc: make ISA floppies work again
  [PATCH] powerpc: Fix some initcall return values
  [PATCH] powerpc: Workaround for pSeries RTAS bug
  [PATCH] spufs: fix __init/__exit annotations
  [PATCH] powerpc: add hvc backend for rtas
  ...
This commit is contained in:
Linus Torvalds 2006-03-29 11:28:30 -08:00
commit 76babde121
265 changed files with 3372 additions and 11751 deletions

View file

@ -561,14 +561,31 @@ config TIPAR
If unsure, say N.
config HVC_DRIVER
bool
help
Users of pSeries machines that want to utilize the hvc console front-end
module for their backend console driver should select this option.
It will automatically be selected if one of the back-end console drivers
is selected.
config HVC_CONSOLE
bool "pSeries Hypervisor Virtual Console support"
depends on PPC_PSERIES
select HVC_DRIVER
help
pSeries machines when partitioned support a hypervisor virtual
console. This driver allows each pSeries partition to have a console
which is accessed via the HMC.
config HVC_RTAS
bool "IBM RTAS Console support"
depends on PPC_RTAS
select HVC_DRIVER
help
IBM Console device driver which makes use of RTAS
config HVCS
tristate "IBM Hypervisor Virtual Console Server support"
depends on PPC_PSERIES

View file

@ -41,7 +41,9 @@ obj-$(CONFIG_N_HDLC) += n_hdlc.o
obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o
obj-$(CONFIG_SX) += sx.o generic_serial.o
obj-$(CONFIG_RIO) += rio/ generic_serial.o
obj-$(CONFIG_HVC_CONSOLE) += hvc_console.o hvc_vio.o hvsi.o
obj-$(CONFIG_HVC_DRIVER) += hvc_console.o
obj-$(CONFIG_HVC_CONSOLE) += hvc_vio.o hvsi.o
obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o
obj-$(CONFIG_RAW_DRIVER) += raw.o
obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o
obj-$(CONFIG_MMTIMER) += mmtimer.o

View file

@ -22,6 +22,9 @@
#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <asm/nvram.h>
#ifdef CONFIG_PPC_PMAC
#include <asm/machdep.h>
#endif
#define NVRAM_SIZE 8192
@ -92,7 +95,7 @@ static int nvram_ioctl(struct inode *inode, struct file *file,
case IOC_NVRAM_GET_OFFSET: {
int part, offset;
if (_machine != _MACH_Pmac)
if (!machine_is(powermac))
return -EINVAL;
if (copy_from_user(&part, (void __user*)arg, sizeof(part)) != 0)
return -EFAULT;

View file

@ -39,8 +39,10 @@
#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/delay.h>
#include <asm/uaccess.h>
#include <asm/hvconsole.h>
#include "hvc_console.h"
#define HVC_MAJOR 229
#define HVC_MINOR 0
@ -54,17 +56,14 @@
#define HVC_CLOSE_WAIT (HZ/100) /* 1/10 of a second */
/*
* The Linux TTY code does not support dynamic addition of tty derived devices
* so we need to know how many tty devices we might need when space is allocated
* for the tty device. Since this driver supports hotplug of vty adapters we
* need to make sure we have enough allocated.
* These sizes are most efficient for vio, because they are the
* native transfer size. We could make them selectable in the
* future to better deal with backends that want other buffer sizes.
*/
#define HVC_ALLOC_TTY_ADAPTERS 8
#define N_OUTBUF 16
#define N_INBUF 16
#define __ALIGNED__ __attribute__((__aligned__(8)))
#define __ALIGNED__ __attribute__((__aligned__(sizeof(long))))
static struct tty_driver *hvc_driver;
static struct task_struct *hvc_task;
@ -154,7 +153,7 @@ static uint32_t vtermnos[MAX_NR_HVC_CONSOLES] =
void hvc_console_print(struct console *co, const char *b, unsigned count)
{
char c[16] __ALIGNED__;
char c[N_OUTBUF] __ALIGNED__;
unsigned i = 0, n = 0;
int r, donecr = 0, index = co->index;
@ -473,8 +472,10 @@ static void hvc_push(struct hvc_struct *hp)
n = hp->ops->put_chars(hp->vtermno, hp->outbuf, hp->n_outbuf);
if (n <= 0) {
if (n == 0)
if (n == 0) {
hp->do_wakeup = 1;
return;
}
/* throw away output on error; this happens when
there is no session connected to the vterm. */
hp->n_outbuf = 0;
@ -486,12 +487,19 @@ static void hvc_push(struct hvc_struct *hp)
hp->do_wakeup = 1;
}
static inline int __hvc_write_kernel(struct hvc_struct *hp,
const unsigned char *buf, int count)
static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count)
{
struct hvc_struct *hp = tty->driver_data;
unsigned long flags;
int rsize, written = 0;
/* This write was probably executed during a tty close. */
if (!hp)
return -EPIPE;
if (hp->count <= 0)
return -EIO;
spin_lock_irqsave(&hp->lock, flags);
/* Push pending writes */
@ -510,26 +518,8 @@ static inline int __hvc_write_kernel(struct hvc_struct *hp,
}
spin_unlock_irqrestore(&hp->lock, flags);
return written;
}
static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count)
{
struct hvc_struct *hp = tty->driver_data;
int written;
/* This write was probably executed during a tty close. */
if (!hp)
return -EPIPE;
if (hp->count <= 0)
return -EIO;
written = __hvc_write_kernel(hp, buf, count);
/*
* Racy, but harmless, kick thread if there is still pending data.
* There really is nothing wrong with kicking the thread, even if there
* is no buffered data.
*/
if (hp->n_outbuf)
hvc_kick();
@ -614,6 +604,13 @@ static int hvc_poll(struct hvc_struct *hp)
spin_unlock_irqrestore(&hp->lock, flags);
tty_hangup(tty);
spin_lock_irqsave(&hp->lock, flags);
} else if ( n == -EAGAIN ) {
/*
* Some back-ends can only ensure a certain min
* num of bytes read, which may be > 'count'.
* Let the tty clear the flip buff to make room.
*/
poll_mask |= HVC_POLL_READ;
}
break;
}
@ -635,16 +632,7 @@ static int hvc_poll(struct hvc_struct *hp)
tty_insert_flip_char(tty, buf[i], 0);
}
/*
* Account for the total amount read in one loop, and if above
* 64 bytes, we do a quick schedule loop to let the tty grok
* the data and eventually throttle us.
*/
read_total += n;
if (read_total >= 64) {
poll_mask |= HVC_POLL_QUICK;
break;
}
}
throttled:
/* Wakeup write queue if necessary */
@ -767,7 +755,8 @@ struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int irq,
* see if this vterm id matches one registered for console.
*/
for (i=0; i < MAX_NR_HVC_CONSOLES; i++)
if (vtermnos[i] == hp->vtermno)
if (vtermnos[i] == hp->vtermno &&
cons_ops[i] == hp->ops)
break;
/* no matching slot, just use a counter */
@ -823,34 +812,38 @@ EXPORT_SYMBOL(hvc_remove);
* interfaces start to become available. */
int __init hvc_init(void)
{
struct tty_driver *drv;
/* We need more than hvc_count adapters due to hotplug additions. */
hvc_driver = alloc_tty_driver(HVC_ALLOC_TTY_ADAPTERS);
if (!hvc_driver)
drv = alloc_tty_driver(HVC_ALLOC_TTY_ADAPTERS);
if (!drv)
return -ENOMEM;
hvc_driver->owner = THIS_MODULE;
hvc_driver->devfs_name = "hvc/";
hvc_driver->driver_name = "hvc";
hvc_driver->name = "hvc";
hvc_driver->major = HVC_MAJOR;
hvc_driver->minor_start = HVC_MINOR;
hvc_driver->type = TTY_DRIVER_TYPE_SYSTEM;
hvc_driver->init_termios = tty_std_termios;
hvc_driver->flags = TTY_DRIVER_REAL_RAW;
tty_set_operations(hvc_driver, &hvc_ops);
drv->owner = THIS_MODULE;
drv->devfs_name = "hvc/";
drv->driver_name = "hvc";
drv->name = "hvc";
drv->major = HVC_MAJOR;
drv->minor_start = HVC_MINOR;
drv->type = TTY_DRIVER_TYPE_SYSTEM;
drv->init_termios = tty_std_termios;
drv->flags = TTY_DRIVER_REAL_RAW;
tty_set_operations(drv, &hvc_ops);
/* Always start the kthread because there can be hotplug vty adapters
* added later. */
hvc_task = kthread_run(khvcd, NULL, "khvcd");
if (IS_ERR(hvc_task)) {
panic("Couldn't create kthread for console.\n");
put_tty_driver(hvc_driver);
put_tty_driver(drv);
return -EIO;
}
if (tty_register_driver(hvc_driver))
if (tty_register_driver(drv))
panic("Couldn't register hvc console driver\n");
mb();
hvc_driver = drv;
return 0;
}
module_init(hvc_init);

View file

@ -0,0 +1,63 @@
/*
* hvc_console.h
* Copyright (C) 2005 IBM Corporation
*
* Author(s):
* Ryan S. Arnold <rsa@us.ibm.com>
*
* hvc_console header information:
* moved here from include/asm-powerpc/hvconsole.h
* and drivers/char/hvc_console.c
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef HVC_CONSOLE_H
#define HVC_CONSOLE_H
/*
* This is the max number of console adapters that can/will be found as
* console devices on first stage console init. Any number beyond this range
* can't be used as a console device but is still a valid tty device.
*/
#define MAX_NR_HVC_CONSOLES 16
/*
* The Linux TTY code does not support dynamic addition of tty derived devices
* so we need to know how many tty devices we might need when space is allocated
* for the tty device. Since this driver supports hotplug of vty adapters we
* need to make sure we have enough allocated.
*/
#define HVC_ALLOC_TTY_ADAPTERS 8
/* implemented by a low level driver */
struct hv_ops {
int (*get_chars)(uint32_t vtermno, char *buf, int count);
int (*put_chars)(uint32_t vtermno, const char *buf, int count);
};
struct hvc_struct;
/* Register a vterm and a slot index for use as a console (console_init) */
extern int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops);
/* register a vterm for hvc tty operation (module_init or hotplug add) */
extern struct hvc_struct * __devinit hvc_alloc(uint32_t vtermno, int irq,
struct hv_ops *ops);
/* remove a vterm from hvc tty operation (modele_exit or hotplug remove) */
extern int __devexit hvc_remove(struct hvc_struct *hp);
#endif // HVC_CONSOLE_H

138
drivers/char/hvc_rtas.c Normal file
View file

@ -0,0 +1,138 @@
/*
* IBM RTAS driver interface to hvc_console.c
*
* (C) Copyright IBM Corporation 2001-2005
* (C) Copyright Red Hat, Inc. 2005
*
* Author(s): Maximino Augilar <IBM STI Design Center>
* : Ryan S. Arnold <rsa@us.ibm.com>
* : Utz Bacher <utz.bacher@de.ibm.com>
* : David Woodhouse <dwmw2@infradead.org>
*
* inspired by drivers/char/hvc_console.c
* written by Anton Blanchard and Paul Mackerras
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/console.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/moduleparam.h>
#include <linux/types.h>
#include <asm/irq.h>
#include <asm/rtas.h>
#include "hvc_console.h"
#define hvc_rtas_cookie 0x67781e15
struct hvc_struct *hvc_rtas_dev;
#define RTASCONS_PUT_ATTEMPTS 16
static int rtascons_put_char_token = RTAS_UNKNOWN_SERVICE;
static int rtascons_get_char_token = RTAS_UNKNOWN_SERVICE;
static int rtascons_put_delay = 100;
module_param_named(put_delay, rtascons_put_delay, int, 0644);
static inline int hvc_rtas_write_console(uint32_t vtermno, const char *buf, int count)
{
int done;
/* if there is more than one character to be displayed, wait a bit */
for (done = 0; done < count; done++) {
int result;
result = rtas_call(rtascons_put_char_token, 1, 1, NULL, buf[done]);
if (result)
break;
}
/* the calling routine expects to receive the number of bytes sent */
return done;
}
static int hvc_rtas_read_console(uint32_t vtermno, char *buf, int count)
{
int i;
for (i = 0; i < count; i++) {
int c, err;
err = rtas_call(rtascons_get_char_token, 0, 2, &c);
if (err)
break;
buf[i] = c;
}
return i;
}
static struct hv_ops hvc_rtas_get_put_ops = {
.get_chars = hvc_rtas_read_console,
.put_chars = hvc_rtas_write_console,
};
static int hvc_rtas_init(void)
{
struct hvc_struct *hp;
if (rtascons_put_char_token == RTAS_UNKNOWN_SERVICE)
rtascons_put_char_token = rtas_token("put-term-char");
if (rtascons_put_char_token == RTAS_UNKNOWN_SERVICE)
return -EIO;
if (rtascons_get_char_token == RTAS_UNKNOWN_SERVICE)
rtascons_get_char_token = rtas_token("get-term-char");
if (rtascons_get_char_token == RTAS_UNKNOWN_SERVICE)
return -EIO;
BUG_ON(hvc_rtas_dev);
/* Allocate an hvc_struct for the console device we instantiated
* earlier. Save off hp so that we can return it on exit */
hp = hvc_alloc(hvc_rtas_cookie, NO_IRQ, &hvc_rtas_get_put_ops);
if (IS_ERR(hp))
return PTR_ERR(hp);
hvc_rtas_dev = hp;
return 0;
}
module_init(hvc_rtas_init);
/* This will tear down the tty portion of the driver */
static void __exit hvc_rtas_exit(void)
{
/* Really the fun isn't over until the worker thread breaks down and the
* tty cleans up */
if (hvc_rtas_dev)
hvc_remove(hvc_rtas_dev);
}
module_exit(hvc_rtas_exit);
/* This will happen prior to module init. There is no tty at this time? */
static int hvc_rtas_console_init(void)
{
rtascons_put_char_token = rtas_token("put-term-char");
if (rtascons_put_char_token == RTAS_UNKNOWN_SERVICE)
return -EIO;
rtascons_get_char_token = rtas_token("get-term-char");
if (rtascons_get_char_token == RTAS_UNKNOWN_SERVICE)
return -EIO;
hvc_instantiate(hvc_rtas_cookie, 0, &hvc_rtas_get_put_ops );
add_preferred_console("hvc", 0, NULL);
return 0;
}
console_initcall(hvc_rtas_console_init);

View file

@ -31,10 +31,13 @@
#include <linux/types.h>
#include <linux/init.h>
#include <asm/hvconsole.h>
#include <asm/vio.h>
#include <asm/prom.h>
#include "hvc_console.h"
char hvc_driver_name[] = "hvc_console";
static struct vio_device_id hvc_driver_table[] __devinitdata = {
@ -48,6 +51,14 @@ static int filtered_get_chars(uint32_t vtermno, char *buf, int count)
unsigned long got;
int i;
/*
* Vio firmware will read up to SIZE_VIO_GET_CHARS at its own discretion
* so we play safe and avoid the situation where got > count which could
* overload the flip buffer.
*/
if (count < SIZE_VIO_GET_CHARS)
return -EAGAIN;
got = hvc_get_chars(vtermno, buf, count);
/*

View file

@ -439,7 +439,6 @@ static int hvcs_io(struct hvcs_struct *hvcsd)
char buf[HVCS_BUFF_LEN] __ALIGNED__;
unsigned long flags;
int got = 0;
int i;
spin_lock_irqsave(&hvcsd->lock, flags);