Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fb8c7fb2 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86:
  xen: fix UP setup of shared_info
  xen: fix RMW when unmasking events
  x86, documentation: nmi_watchdog=2 works on x86_64
  x86: stricter check in follow_huge_addr()
  rdc321x: GPIO routines bugfixes
  x86: ptrace.c: fix defined-but-unused warnings
  x86: fix prefetch workaround
parents 074fcab5 2e8fe719
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -23,8 +23,7 @@ kernel debugging options, such as Kernel Stack Meter or Kernel Tracer,
may implicitly disable the NMI watchdog.]

For x86-64, the needed APIC is always compiled in, and the NMI watchdog is
always enabled with I/O-APIC mode (nmi_watchdog=1). Currently, local APIC
mode (nmi_watchdog=2) does not work on x86-64.
always enabled with I/O-APIC mode (nmi_watchdog=1).

Using local APIC (nmi_watchdog=2) needs the first performance register, so
you can't use it for other purposes (such as high precision performance
+85 −84
Original line number Diff line number Diff line
@@ -600,21 +600,6 @@ static int ptrace_bts_read_record(struct task_struct *child,
	return sizeof(ret);
}

static int ptrace_bts_write_record(struct task_struct *child,
				   const struct bts_struct *in)
{
	int retval;

	if (!child->thread.ds_area_msr)
		return -ENXIO;

	retval = ds_write_bts((void *)child->thread.ds_area_msr, in);
	if (retval)
		return retval;

	return sizeof(*in);
}

static int ptrace_bts_clear(struct task_struct *child)
{
	if (!child->thread.ds_area_msr)
@@ -657,75 +642,6 @@ static int ptrace_bts_drain(struct task_struct *child,
	return end;
}

static int ptrace_bts_realloc(struct task_struct *child,
			      int size, int reduce_size)
{
	unsigned long rlim, vm;
	int ret, old_size;

	if (size < 0)
		return -EINVAL;

	old_size = ds_get_bts_size((void *)child->thread.ds_area_msr);
	if (old_size < 0)
		return old_size;

	ret = ds_free((void **)&child->thread.ds_area_msr);
	if (ret < 0)
		goto out;

	size >>= PAGE_SHIFT;
	old_size >>= PAGE_SHIFT;

	current->mm->total_vm  -= old_size;
	current->mm->locked_vm -= old_size;

	if (size == 0)
		goto out;

	rlim = current->signal->rlim[RLIMIT_AS].rlim_cur >> PAGE_SHIFT;
	vm = current->mm->total_vm  + size;
	if (rlim < vm) {
		ret = -ENOMEM;

		if (!reduce_size)
			goto out;

		size = rlim - current->mm->total_vm;
		if (size <= 0)
			goto out;
	}

	rlim = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >> PAGE_SHIFT;
	vm = current->mm->locked_vm  + size;
	if (rlim < vm) {
		ret = -ENOMEM;

		if (!reduce_size)
			goto out;

		size = rlim - current->mm->locked_vm;
		if (size <= 0)
			goto out;
	}

	ret = ds_allocate((void **)&child->thread.ds_area_msr,
			  size << PAGE_SHIFT);
	if (ret < 0)
		goto out;

	current->mm->total_vm  += size;
	current->mm->locked_vm += size;

out:
	if (child->thread.ds_area_msr)
		set_tsk_thread_flag(child, TIF_DS_AREA_MSR);
	else
		clear_tsk_thread_flag(child, TIF_DS_AREA_MSR);

	return ret;
}

static int ptrace_bts_config(struct task_struct *child,
			     long cfg_size,
			     const struct ptrace_bts_config __user *ucfg)
@@ -828,6 +744,91 @@ static int ptrace_bts_status(struct task_struct *child,
	return sizeof(cfg);
}


static int ptrace_bts_write_record(struct task_struct *child,
				   const struct bts_struct *in)
{
	int retval;

	if (!child->thread.ds_area_msr)
		return -ENXIO;

	retval = ds_write_bts((void *)child->thread.ds_area_msr, in);
	if (retval)
		return retval;

	return sizeof(*in);
}

static int ptrace_bts_realloc(struct task_struct *child,
			      int size, int reduce_size)
{
	unsigned long rlim, vm;
	int ret, old_size;

	if (size < 0)
		return -EINVAL;

	old_size = ds_get_bts_size((void *)child->thread.ds_area_msr);
	if (old_size < 0)
		return old_size;

	ret = ds_free((void **)&child->thread.ds_area_msr);
	if (ret < 0)
		goto out;

	size >>= PAGE_SHIFT;
	old_size >>= PAGE_SHIFT;

	current->mm->total_vm  -= old_size;
	current->mm->locked_vm -= old_size;

	if (size == 0)
		goto out;

	rlim = current->signal->rlim[RLIMIT_AS].rlim_cur >> PAGE_SHIFT;
	vm = current->mm->total_vm  + size;
	if (rlim < vm) {
		ret = -ENOMEM;

		if (!reduce_size)
			goto out;

		size = rlim - current->mm->total_vm;
		if (size <= 0)
			goto out;
	}

	rlim = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >> PAGE_SHIFT;
	vm = current->mm->locked_vm  + size;
	if (rlim < vm) {
		ret = -ENOMEM;

		if (!reduce_size)
			goto out;

		size = rlim - current->mm->locked_vm;
		if (size <= 0)
			goto out;
	}

	ret = ds_allocate((void **)&child->thread.ds_area_msr,
			  size << PAGE_SHIFT);
	if (ret < 0)
		goto out;

	current->mm->total_vm  += size;
	current->mm->locked_vm += size;

out:
	if (child->thread.ds_area_msr)
		set_tsk_thread_flag(child, TIF_DS_AREA_MSR);
	else
		clear_tsk_thread_flag(child, TIF_DS_AREA_MSR);

	return ret;
}

void ptrace_bts_take_timestamp(struct task_struct *tsk,
			       enum bts_qualifier qualifier)
{
+151 −48
Original line number Diff line number Diff line
/*
 *  Copyright (C) 2007, OpenWrt.org, Florian Fainelli <florian@openwrt.org>
 *  	RDC321x architecture specific GPIO support
 *  GPIO support for RDC SoC R3210/R8610
 *
 *  Copyright (C) 2007, Florian Fainelli <florian@openwrt.org>
 *  Copyright (C) 2008, Volker Weiss <dev@tintuc.de>
 *
 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  This program is free software; you can redistribute  it and/or modify it
 *  under  the terms of  the GNU General  Public License as published by the
 *  Free Software Foundation;  either version 2 of the  License, or (at your
 *  option) any later version.
 */

#include <linux/autoconf.h>
#include <linux/init.h>

#include <linux/spinlock.h>
#include <linux/io.h>
#include <linux/types.h>
#include <linux/module.h>
#include <linux/delay.h>

#include <asm/gpio.h>
#include <asm/mach-rdc321x/rdc321x_defs.h>

static inline int rdc_gpio_is_valid(unsigned gpio)

/* spin lock to protect our private copy of GPIO data register plus
   the access to PCI conf registers. */
static DEFINE_SPINLOCK(gpio_lock);

/* copy of GPIO data registers */
static u32 gpio_data_reg1;
static u32 gpio_data_reg2;

static u32 gpio_request_data[2];


static inline void rdc321x_conf_write(unsigned addr, u32 value)
{
	return (gpio <= RDC_MAX_GPIO);
	outl((1 << 31) | (7 << 11) | addr, RDC3210_CFGREG_ADDR);
	outl(value, RDC3210_CFGREG_DATA);
}

static unsigned int rdc_gpio_read(unsigned gpio)
static inline void rdc321x_conf_or(unsigned addr, u32 value)
{
	unsigned int val;

	val = 0x80000000 | (7 << 11) | ((gpio&0x20?0x84:0x48));
	outl(val, RDC3210_CFGREG_ADDR);
	udelay(10);
	val = inl(RDC3210_CFGREG_DATA);
	val |= (0x1 << (gpio & 0x1F));
	outl(val, RDC3210_CFGREG_DATA);
	udelay(10);
	val = 0x80000000 | (7 << 11) | ((gpio&0x20?0x88:0x4C));
	outl(val, RDC3210_CFGREG_ADDR);
	udelay(10);
	val = inl(RDC3210_CFGREG_DATA);

	return val;
	outl((1 << 31) | (7 << 11) | addr, RDC3210_CFGREG_ADDR);
	value |= inl(RDC3210_CFGREG_DATA);
	outl(value, RDC3210_CFGREG_DATA);
}

static void rdc_gpio_write(unsigned int val)
static inline u32 rdc321x_conf_read(unsigned addr)
{
	if (val) {
		outl(val, RDC3210_CFGREG_DATA);
		udelay(10);
	outl((1 << 31) | (7 << 11) | addr, RDC3210_CFGREG_ADDR);

	return inl(RDC3210_CFGREG_DATA);
}

/* configure pin as GPIO */
static void rdc321x_configure_gpio(unsigned gpio)
{
	unsigned long flags;

	spin_lock_irqsave(&gpio_lock, flags);
	rdc321x_conf_or(gpio < 32
		? RDC321X_GPIO_CTRL_REG1 : RDC321X_GPIO_CTRL_REG2,
		1 << (gpio & 0x1f));
	spin_unlock_irqrestore(&gpio_lock, flags);
}

int rdc_gpio_get_value(unsigned gpio)
/* initially setup the 2 copies of the gpio data registers.
   This function must be called by the platform setup code. */
void __init rdc321x_gpio_setup()
{
	if (rdc_gpio_is_valid(gpio))
		return (int)rdc_gpio_read(gpio);
	else
	/* this might not be, what others (BIOS, bootloader, etc.)
	   wrote to these registers before, but it's a good guess. Still
	   better than just using 0xffffffff. */

	gpio_data_reg1 = rdc321x_conf_read(RDC321X_GPIO_DATA_REG1);
	gpio_data_reg2 = rdc321x_conf_read(RDC321X_GPIO_DATA_REG2);
}

/* determine, if gpio number is valid */
static inline int rdc321x_is_gpio(unsigned gpio)
{
	return gpio <= RDC321X_MAX_GPIO;
}

/* request GPIO */
int rdc_gpio_request(unsigned gpio, const char *label)
{
	unsigned long flags;

	if (!rdc321x_is_gpio(gpio))
		return -EINVAL;

	spin_lock_irqsave(&gpio_lock, flags);
	if (gpio_request_data[(gpio & 0x20) ? 1 : 0] & (1 << (gpio & 0x1f)))
		goto inuse;
	gpio_request_data[(gpio & 0x20) ? 1 : 0] |= (1 << (gpio & 0x1f));
	spin_unlock_irqrestore(&gpio_lock, flags);

	return 0;
inuse:
	spin_unlock_irqrestore(&gpio_lock, flags);
	return -EINVAL;
}
EXPORT_SYMBOL(rdc_gpio_get_value);
EXPORT_SYMBOL(rdc_gpio_request);

void rdc_gpio_set_value(unsigned gpio, int value)
/* release previously-claimed GPIO */
void rdc_gpio_free(unsigned gpio)
{
	unsigned int val;
	unsigned long flags;

	if (!rdc_gpio_is_valid(gpio))
	if (!rdc321x_is_gpio(gpio))
		return;

	val = rdc_gpio_read(gpio);
	spin_lock_irqsave(&gpio_lock, flags);
	gpio_request_data[(gpio & 0x20) ? 1 : 0] &= ~(1 << (gpio & 0x1f));
	spin_unlock_irqrestore(&gpio_lock, flags);
}
EXPORT_SYMBOL(rdc_gpio_free);

/* read GPIO pin */
int rdc_gpio_get_value(unsigned gpio)
{
	u32 reg;
	unsigned long flags;

	spin_lock_irqsave(&gpio_lock, flags);
	reg = rdc321x_conf_read(gpio < 32
		? RDC321X_GPIO_DATA_REG1 : RDC321X_GPIO_DATA_REG2);
	spin_unlock_irqrestore(&gpio_lock, flags);

	return (1 << (gpio & 0x1f)) & reg ? 1 : 0;
}
EXPORT_SYMBOL(rdc_gpio_get_value);

/* set GPIO pin to value */
void rdc_gpio_set_value(unsigned gpio, int value)
{
	unsigned long flags;
	u32 reg;

	reg = 1 << (gpio & 0x1f);
	if (gpio < 32) {
		spin_lock_irqsave(&gpio_lock, flags);
		if (value)
		val &= ~(0x1 << (gpio & 0x1F));
			gpio_data_reg1 |= reg;
		else
		val |= (0x1 << (gpio & 0x1F));

	rdc_gpio_write(val);
			gpio_data_reg1 &= ~reg;
		rdc321x_conf_write(RDC321X_GPIO_DATA_REG1, gpio_data_reg1);
		spin_unlock_irqrestore(&gpio_lock, flags);
	} else {
		spin_lock_irqsave(&gpio_lock, flags);
		if (value)
			gpio_data_reg2 |= reg;
		else
			gpio_data_reg2 &= ~reg;
		rdc321x_conf_write(RDC321X_GPIO_DATA_REG2, gpio_data_reg2);
		spin_unlock_irqrestore(&gpio_lock, flags);
	}
}
EXPORT_SYMBOL(rdc_gpio_set_value);

/* configure GPIO pin as input */
int rdc_gpio_direction_input(unsigned gpio)
{
	if (!rdc321x_is_gpio(gpio))
		return -EINVAL;

	rdc321x_configure_gpio(gpio);

	return 0;
}
EXPORT_SYMBOL(rdc_gpio_direction_input);

/* configure GPIO pin as output and set value */
int rdc_gpio_direction_output(unsigned gpio, int value)
{
	if (!rdc321x_is_gpio(gpio))
		return -EINVAL;

	gpio_set_value(gpio, value);
	rdc321x_configure_gpio(gpio);

	return 0;
}
EXPORT_SYMBOL(rdc_gpio_direction_output);

+2 −0
Original line number Diff line number Diff line
@@ -62,6 +62,8 @@ static struct platform_device *rdc321x_devs[] = {

static int __init rdc_board_setup(void)
{
	rdc321x_gpio_setup();

	return platform_add_devices(rdc321x_devs, ARRAY_SIZE(rdc321x_devs));
}

+2 −1
Original line number Diff line number Diff line
@@ -92,7 +92,8 @@ static int is_prefetch(struct pt_regs *regs, unsigned long addr,
	unsigned char *max_instr;

#ifdef CONFIG_X86_32
	if (!(__supported_pte_mask & _PAGE_NX))
	/* Catch an obscure case of prefetch inside an NX page: */
	if ((__supported_pte_mask & _PAGE_NX) && (error_code & 16))
		return 0;
#endif

Loading