aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/kernel/syscall.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/kernel/syscall.c')
-rw-r--r--arch/um/kernel/syscall.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/arch/um/kernel/syscall.c b/arch/um/kernel/syscall.c
index ebb29f5259a9..b9d92b2089ae 100644
--- a/arch/um/kernel/syscall.c
+++ b/arch/um/kernel/syscall.c
@@ -1,25 +1,17 @@
1/* 1/*
2 * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com) 2 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include "linux/sched.h"
7#include "linux/file.h" 6#include "linux/file.h"
8#include "linux/smp_lock.h"
9#include "linux/mm.h"
10#include "linux/fs.h" 7#include "linux/fs.h"
8#include "linux/mm.h"
9#include "linux/sched.h"
11#include "linux/utsname.h" 10#include "linux/utsname.h"
12#include "linux/msg.h" 11#include "asm/current.h"
13#include "linux/shm.h"
14#include "linux/sys.h"
15#include "linux/syscalls.h"
16#include "linux/unistd.h"
17#include "linux/slab.h"
18#include "linux/utime.h"
19#include "asm/mman.h" 12#include "asm/mman.h"
20#include "asm/uaccess.h" 13#include "asm/uaccess.h"
21#include "kern_util.h" 14#include "asm/unistd.h"
22#include "sysdep/syscalls.h"
23 15
24/* Unlocked, I don't care if this is a bit off */ 16/* Unlocked, I don't care if this is a bit off */
25int nsyscalls = 0; 17int nsyscalls = 0;
@@ -32,7 +24,7 @@ long sys_fork(void)
32 ret = do_fork(SIGCHLD, UPT_SP(&current->thread.regs.regs), 24 ret = do_fork(SIGCHLD, UPT_SP(&current->thread.regs.regs),
33 &current->thread.regs, 0, NULL, NULL); 25 &current->thread.regs, 0, NULL, NULL);
34 current->thread.forking = 0; 26 current->thread.forking = 0;
35 return(ret); 27 return ret;
36} 28}
37 29
38long sys_vfork(void) 30long sys_vfork(void)
@@ -44,7 +36,7 @@ long sys_vfork(void)
44 UPT_SP(&current->thread.regs.regs), 36 UPT_SP(&current->thread.regs.regs),
45 &current->thread.regs, 0, NULL, NULL); 37 &current->thread.regs, 0, NULL, NULL);
46 current->thread.forking = 0; 38 current->thread.forking = 0;
47 return(ret); 39 return ret;
48} 40}
49 41
50/* common code for old and new mmaps */ 42/* common code for old and new mmaps */
@@ -90,15 +82,15 @@ long old_mmap(unsigned long addr, unsigned long len,
90 */ 82 */
91long sys_pipe(unsigned long __user * fildes) 83long sys_pipe(unsigned long __user * fildes)
92{ 84{
93 int fd[2]; 85 int fd[2];
94 long error; 86 long error;
95 87
96 error = do_pipe(fd); 88 error = do_pipe(fd);
97 if (!error) { 89 if (!error) {
98 if (copy_to_user(fildes, fd, sizeof(fd))) 90 if (copy_to_user(fildes, fd, sizeof(fd)))
99 error = -EFAULT; 91 error = -EFAULT;
100 } 92 }
101 return error; 93 return error;
102} 94}
103 95
104 96
@@ -122,7 +114,7 @@ long sys_olduname(struct oldold_utsname __user * name)
122 if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname))) 114 if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
123 return -EFAULT; 115 return -EFAULT;
124 116
125 down_read(&uts_sem); 117 down_read(&uts_sem);
126 118
127 error = __copy_to_user(&name->sysname, &utsname()->sysname, 119 error = __copy_to_user(&name->sysname, &utsname()->sysname,
128 __OLD_UTS_LEN); 120 __OLD_UTS_LEN);
7 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817
/*
 * Support for SATA devices on Serial Attached SCSI (SAS) controllers
 *
 * Copyright (C) 2006 IBM Corporation
 *
 * Written by: Darrick J. Wong <djwong@us.ibm.com>, IBM 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; 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/scatterlist.h>

#include <scsi/sas_ata.h>
#include "sas_internal.h"
#include <scsi/scsi_host.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_tcq.h>
#include <scsi/scsi.h>
#include <scsi/scsi_transport.h>
#include <scsi/scsi_transport_sas.h>
#include "../scsi_sas_internal.h"
#include "../scsi_transport_api.h"
#include <scsi/scsi_eh.h>

static enum ata_completion_errors sas_to_ata_err(struct task_status_struct *ts)
{
	/* Cheesy attempt to translate SAS errors into ATA.  Hah! */

	/* transport error */
	if (ts->resp == SAS_TASK_UNDELIVERED)
		return AC_ERR_ATA_BUS;

	/* ts->resp == SAS_TASK_COMPLETE */
	/* task delivered, what happened afterwards? */
	switch (ts->stat) {
		case SAS_DEV_NO_RESPONSE:
			return AC_ERR_TIMEOUT;

		case SAS_INTERRUPTED:
		case SAS_PHY_DOWN:
		case SAS_NAK_R_ERR:
			return AC_ERR_ATA_BUS;


		case SAS_DATA_UNDERRUN:
			/*
			 * Some programs that use the taskfile interface
			 * (smartctl in particular) can cause underrun
			 * problems.  Ignore these errors, perhaps at our
			 * peril.
			 */
			return 0;

		case SAS_DATA_OVERRUN:
		case SAS_QUEUE_FULL:
		case SAS_DEVICE_UNKNOWN:
		case SAS_SG_ERR:
			return AC_ERR_INVALID;

		case SAM_CHECK_COND:
		case SAS_OPEN_TO:
		case SAS_OPEN_REJECT:
			SAS_DPRINTK("%s: Saw error %d.  What to do?\n",
				    __FUNCTION__, ts->stat);
			return AC_ERR_OTHER;

		case SAS_ABORTED_TASK:
			return AC_ERR_DEV;

		case SAS_PROTO_RESPONSE:
			/* This means the ending_fis has the error
			 * value; return 0 here to collect it */
			return 0;
		default:
			return 0;
	}
}

static void sas_ata_task_done(struct sas_task *task)
{
	struct ata_queued_cmd *qc = task->uldd_task;
	struct domain_device *dev;
	struct task_status_struct *stat = &task->task_status;
	struct ata_task_resp *resp = (struct ata_task_resp *)stat->buf;
	struct sas_ha_struct *sas_ha;
	enum ata_completion_errors ac;
	unsigned long flags;

	if (!qc)
		goto qc_already_gone;

	dev = qc->ap->private_data;
	sas_ha = dev->port->ha;

	spin_lock_irqsave(dev->sata_dev.ap->lock, flags);
	if (stat->stat == SAS_PROTO_RESPONSE || stat->stat == SAM_GOOD) {
		ata_tf_from_fis(resp->ending_fis, &dev->sata_dev.tf);
		qc->err_mask |= ac_err_mask(dev->sata_dev.tf.command);
		dev->sata_dev.sstatus = resp->sstatus;
		dev->sata_dev.serror = resp->serror;
		dev->sata_dev.scontrol = resp->scontrol;
	} else if (stat->stat != SAM_STAT_GOOD) {
		ac = sas_to_ata_err(stat);
		if (ac) {
			SAS_DPRINTK("%s: SAS error %x\n", __FUNCTION__,
				    stat->stat);
			/* We saw a SAS error. Send a vague error. */
			qc->err_mask = ac;
			dev->sata_dev.tf.feature = 0x04; /* status err */
			dev->sata_dev.tf.command = ATA_ERR;
		}
	}

	qc->lldd_task = NULL;
	if (qc->scsicmd)
		ASSIGN_SAS_TASK(qc->scsicmd, NULL);
	ata_qc_complete(qc);
	spin_unlock_irqrestore(dev->sata_dev.ap->lock, flags);

	/*
	 * If the sas_task has an ata qc, a scsi_cmnd and the aborted
	 * flag is set, then we must have come in via the libsas EH
	 * functions.  When we exit this function, we need to put the
	 * scsi_cmnd on the list of finished errors.  The ata_qc_complete
	 * call cleans up the libata side of things but we're protected
	 * from the scsi_cmnd going away because the scsi_cmnd is owned
	 * by the EH, making libata's call to scsi_done a NOP.
	 */
	spin_lock_irqsave(&task->task_state_lock, flags);
	if (qc->scsicmd && task->task_state_flags & SAS_TASK_STATE_ABORTED)
		scsi_eh_finish_cmd(qc->scsicmd, &sas_ha->eh_done_q);
	spin_unlock_irqrestore(&task->task_state_lock, flags);

qc_already_gone:
	list_del_init(&task->list);
	sas_free_task(task);
}

static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc)
{
	int res;
	struct sas_task *task;
	struct domain_device *dev = qc->ap->private_data;
	struct sas_ha_struct *sas_ha = dev->port->ha;
	struct Scsi_Host *host = sas_ha->core.shost;
	struct sas_internal *i = to_sas_internal(host->transportt);
	struct scatterlist *sg;
	unsigned int num = 0;
	unsigned int xfer = 0;

	task = sas_alloc_task(GFP_ATOMIC);
	if (!task)
		return AC_ERR_SYSTEM;
	task->dev = dev;
	task->task_proto = SAS_PROTOCOL_STP;
	task->task_done = sas_ata_task_done;

	if (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
	    qc->tf.command == ATA_CMD_FPDMA_READ) {
		/* Need to zero out the tag libata assigned us */
		qc->tf.nsect = 0;
	}

	ata_tf_to_fis(&qc->tf, 1, 0, (u8*)&task->ata_task.fis);
	task->uldd_task = qc;
	if (is_atapi_taskfile(&qc->tf)) {
		memcpy(task->ata_task.atapi_packet, qc->cdb, qc->dev->cdb_len);
		task->total_xfer_len = qc->nbytes + qc->pad_len;
		task->num_scatter = qc->pad_len ? qc->n_elem + 1 : qc->n_elem;
	} else {
		ata_for_each_sg(sg, qc) {
			num++;
			xfer += sg->length;
		}

		task->total_xfer_len = xfer;
		task->num_scatter = num;
	}