All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCHSET] libata: prep for new EH
From: Tejun Heo @ 2006-04-01 10:51 UTC (permalink / raw)
  To: jgarzik, alan, albertcc, linux-ide
In-Reply-To: <11438885151530-git-send-email-htejun@gmail.com>

On Sat, Apr 01, 2006 at 07:48:36PM +0900, Tejun Heo wrote:
> Hello, Jeff, Alan and Albert.
> 
> This patchset contains various fixes and updates in preparation for
> new EH.  Most patches are straight-forward and even trivial.
> 
> This patchset has 15 patches and is against

 14, obviously.  I was counting the scsi_eh_schdule() patch I've just
sent.  BTW, that SCSI patch and this patchset are the last ones before
the real EH patchset.  So, there now remain only two more patchsets -
the actual EH patchset and NCQ patchset.  I think I'll be able to post
both of them before monday.

Thanks.

-- 
tejun

^ permalink raw reply

* [PATCH 08/14] libata: pass qc around intead of ap during PIO
From: Tejun Heo @ 2006-04-01 10:48 UTC (permalink / raw)
  To: jgarzik, alan, albertcc, linux-ide; +Cc: Tejun Heo
In-Reply-To: <11438885151530-git-send-email-htejun@gmail.com>

The current code passes pointer to ap around and repeatedly performs
ata_qc_from_tag() to access the ongoing qc.  This is unnatural and
makes EH synchronization cumbersome.  Make PIO codes deal with qc
instead of ap.

Signed-off-by: Tejun Heo <htejun@gmail.com>

---

 drivers/scsi/libata-core.c |   71 ++++++++++++++++----------------------------
 1 files changed, 26 insertions(+), 45 deletions(-)

2a820c9abd25983f2776412030a5ff67f842590e
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index fe66e04..ab7a654 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -3405,7 +3405,7 @@ void ata_poll_qc_complete(struct ata_que
 
 /**
  *	ata_pio_poll - poll using PIO, depending on current state
- *	@ap: the target ata_port
+ *	@qc: qc in progress
  *
  *	LOCKING:
  *	None.  (executing in kernel thread context)
@@ -3413,17 +3413,13 @@ void ata_poll_qc_complete(struct ata_que
  *	RETURNS:
  *	timeout value to use
  */
-
-static unsigned long ata_pio_poll(struct ata_port *ap)
+static unsigned long ata_pio_poll(struct ata_queued_cmd *qc)
 {
-	struct ata_queued_cmd *qc;
+	struct ata_port *ap = qc->ap;
 	u8 status;
 	unsigned int poll_state = HSM_ST_UNKNOWN;
 	unsigned int reg_state = HSM_ST_UNKNOWN;
 
-	qc = ata_qc_from_tag(ap, ap->active_tag);
-	WARN_ON(qc == NULL);
-
 	switch (ap->hsm_task_state) {
 	case HSM_ST:
 	case HSM_ST_POLL:
@@ -3457,7 +3453,7 @@ static unsigned long ata_pio_poll(struct
 
 /**
  *	ata_pio_complete - check if drive is busy or idle
- *	@ap: the target ata_port
+ *	@qc: qc to complete
  *
  *	LOCKING:
  *	None.  (executing in kernel thread context)
@@ -3465,10 +3461,9 @@ static unsigned long ata_pio_poll(struct
  *	RETURNS:
  *	Non-zero if qc completed, zero otherwise.
  */
-
-static int ata_pio_complete (struct ata_port *ap)
+static int ata_pio_complete(struct ata_queued_cmd *qc)
 {
-	struct ata_queued_cmd *qc;
+	struct ata_port *ap = qc->ap;
 	u8 drv_stat;
 
 	/*
@@ -3489,9 +3484,6 @@ static int ata_pio_complete (struct ata_
 		}
 	}
 
-	qc = ata_qc_from_tag(ap, ap->active_tag);
-	WARN_ON(qc == NULL);
-
 	drv_stat = ata_wait_idle(ap);
 	if (!ata_ok(drv_stat)) {
 		qc->err_mask |= __ac_err_mask(drv_stat);
@@ -3827,15 +3819,14 @@ err_out:
 
 /**
  *	ata_pio_block - start PIO on a block
- *	@ap: the target ata_port
+ *	@qc: qc to transfer block for
  *
  *	LOCKING:
  *	None.  (executing in kernel thread context)
  */
-
-static void ata_pio_block(struct ata_port *ap)
+static void ata_pio_block(struct ata_queued_cmd *qc)
 {
-	struct ata_queued_cmd *qc;
+	struct ata_port *ap = qc->ap;
 	u8 status;
 
 	/*
@@ -3857,9 +3848,6 @@ static void ata_pio_block(struct ata_por
 		}
 	}
 
-	qc = ata_qc_from_tag(ap, ap->active_tag);
-	WARN_ON(qc == NULL);
-
 	/* check error */
 	if (status & (ATA_ERR | ATA_DF)) {
 		qc->err_mask |= AC_ERR_DEV;
@@ -3888,12 +3876,9 @@ static void ata_pio_block(struct ata_por
 	}
 }
 
-static void ata_pio_error(struct ata_port *ap)
+static void ata_pio_error(struct ata_queued_cmd *qc)
 {
-	struct ata_queued_cmd *qc;
-
-	qc = ata_qc_from_tag(ap, ap->active_tag);
-	WARN_ON(qc == NULL);
+	struct ata_port *ap = qc->ap;
 
 	if (qc->tf.command != ATA_CMD_PACKET)
 		printk(KERN_WARNING "ata%u: dev %u PIO error\n",
@@ -3911,7 +3896,8 @@ static void ata_pio_error(struct ata_por
 
 static void ata_pio_task(void *_data)
 {
-	struct ata_port *ap = _data;
+	struct ata_queued_cmd *qc = _data;
+	struct ata_port *ap = qc->ap;
 	unsigned long timeout;
 	int qc_completed;
 
@@ -3924,33 +3910,33 @@ fsm_start:
 		return;
 
 	case HSM_ST:
-		ata_pio_block(ap);
+		ata_pio_block(qc);
 		break;
 
 	case HSM_ST_LAST:
-		qc_completed = ata_pio_complete(ap);
+		qc_completed = ata_pio_complete(qc);
 		break;
 
 	case HSM_ST_POLL:
 	case HSM_ST_LAST_POLL:
-		timeout = ata_pio_poll(ap);
+		timeout = ata_pio_poll(qc);
 		break;
 
 	case HSM_ST_TMOUT:
 	case HSM_ST_ERR:
-		ata_pio_error(ap);
+		ata_pio_error(qc);
 		return;
 	}
 
 	if (timeout)
-		ata_port_queue_task(ap, ata_pio_task, ap, timeout);
+		ata_port_queue_task(ap, ata_pio_task, qc, timeout);
 	else if (!qc_completed)
 		goto fsm_start;
 }
 
 /**
  *	atapi_packet_task - Write CDB bytes to hardware
- *	@_data: Port to which ATAPI device is attached.
+ *	@_data: qc in progress
  *
  *	When device has indicated its readiness to accept
  *	a CDB, this function is called.  Send the CDB.
@@ -3961,17 +3947,12 @@ fsm_start:
  *	LOCKING:
  *	Kernel thread context (may sleep)
  */
-
 static void atapi_packet_task(void *_data)
 {
-	struct ata_port *ap = _data;
-	struct ata_queued_cmd *qc;
+	struct ata_queued_cmd *qc = _data;
+	struct ata_port *ap = qc->ap;
 	u8 status;
 
-	qc = ata_qc_from_tag(ap, ap->active_tag);
-	WARN_ON(qc == NULL);
-	WARN_ON(!(qc->flags & ATA_QCFLAG_ACTIVE));
-
 	/* sleep-wait for BSY to clear */
 	DPRINTK("busy wait\n");
 	if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) {
@@ -4011,7 +3992,7 @@ static void atapi_packet_task(void *_dat
 
 		/* PIO commands are handled by polling */
 		ap->hsm_task_state = HSM_ST;
-		ata_port_queue_task(ap, ata_pio_task, ap, 0);
+		ata_port_queue_task(ap, ata_pio_task, qc, 0);
 	}
 
 	return;
@@ -4317,26 +4298,26 @@ unsigned int ata_qc_issue_prot(struct at
 		ata_qc_set_polling(qc);
 		ata_tf_to_host(ap, &qc->tf);
 		ap->hsm_task_state = HSM_ST;
-		ata_port_queue_task(ap, ata_pio_task, ap, 0);
+		ata_port_queue_task(ap, ata_pio_task, qc, 0);
 		break;
 
 	case ATA_PROT_ATAPI:
 		ata_qc_set_polling(qc);
 		ata_tf_to_host(ap, &qc->tf);
-		ata_port_queue_task(ap, atapi_packet_task, ap, 0);
+		ata_port_queue_task(ap, atapi_packet_task, qc, 0);
 		break;
 
 	case ATA_PROT_ATAPI_NODATA:
 		ap->flags |= ATA_FLAG_NOINTR;
 		ata_tf_to_host(ap, &qc->tf);
-		ata_port_queue_task(ap, atapi_packet_task, ap, 0);
+		ata_port_queue_task(ap, atapi_packet_task, qc, 0);
 		break;
 
 	case ATA_PROT_ATAPI_DMA:
 		ap->flags |= ATA_FLAG_NOINTR;
 		ap->ops->tf_load(ap, &qc->tf);	 /* load tf registers */
 		ap->ops->bmdma_setup(qc);	    /* set up bmdma */
-		ata_port_queue_task(ap, atapi_packet_task, ap, 0);
+		ata_port_queue_task(ap, atapi_packet_task, qc, 0);
 		break;
 
 	default:
-- 
1.2.4



^ permalink raw reply related

* [PATCH 13/14] libata: separate out libata-eh.c
From: Tejun Heo @ 2006-04-01 10:48 UTC (permalink / raw)
  To: jgarzik, alan, albertcc, linux-ide; +Cc: Tejun Heo
In-Reply-To: <11438885151530-git-send-email-htejun@gmail.com>

A lot of EH codes are about to be added to libata.  Separate out
libata-eh.c.  ata_scsi_timed_out(), ata_scsi_error(),
ata_qc_timeout(), ata_eng_timeout(), ata_eh_qc_complete() and
ata_eh_qc_retry() are moved.  No code is changed by this patch.

Signed-off-by: Tejun Heo <htejun@gmail.com>

---

 drivers/scsi/Makefile      |    2 
 drivers/scsi/libata-core.c |  102 +----------------
 drivers/scsi/libata-eh.c   |  264 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/scsi/libata-scsi.c |  130 ----------------------
 drivers/scsi/libata.h      |    4 +
 include/linux/libata.h     |   12 +-
 6 files changed, 281 insertions(+), 233 deletions(-)
 create mode 100644 drivers/scsi/libata-eh.c

b573806bbddcc9467450b7b91ce0b31236fc871c
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index e513c31..503f189 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -165,7 +165,7 @@ ncr53c8xx-flags-$(CONFIG_SCSI_ZALON) \
 CFLAGS_ncr53c8xx.o	:= $(ncr53c8xx-flags-y) $(ncr53c8xx-flags-m)
 zalon7xx-objs	:= zalon.o ncr53c8xx.o
 NCR_Q720_mod-objs	:= NCR_Q720.o ncr53c8xx.o
-libata-objs	:= libata-core.o libata-scsi.o libata-bmdma.o
+libata-objs	:= libata-core.o libata-scsi.o libata-bmdma.o libata-eh.o
 oktagon_esp_mod-objs	:= oktagon_esp.o oktagon_io.o
 
 # Files generated that shall be removed upon make clean
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 4c9aa75..c893129 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -4005,99 +4005,6 @@ err_out:
 }
 
 /**
- *	ata_qc_timeout - Handle timeout of queued command
- *	@qc: Command that timed out
- *
- *	Some part of the kernel (currently, only the SCSI layer)
- *	has noticed that the active command on port @ap has not
- *	completed after a specified length of time.  Handle this
- *	condition by disabling DMA (if necessary) and completing
- *	transactions, with error if necessary.
- *
- *	This also handles the case of the "lost interrupt", where
- *	for some reason (possibly hardware bug, possibly driver bug)
- *	an interrupt was not delivered to the driver, even though the
- *	transaction completed successfully.
- *
- *	LOCKING:
- *	Inherited from SCSI layer (none, can sleep)
- */
-
-static void ata_qc_timeout(struct ata_queued_cmd *qc)
-{
-	struct ata_port *ap = qc->ap;
-	struct ata_host_set *host_set = ap->host_set;
-	u8 host_stat = 0, drv_stat;
-	unsigned long flags;
-
-	DPRINTK("ENTER\n");
-
-	ap->hsm_task_state = HSM_ST_IDLE;
-
-	spin_lock_irqsave(&host_set->lock, flags);
-
-	switch (qc->tf.protocol) {
-
-	case ATA_PROT_DMA:
-	case ATA_PROT_ATAPI_DMA:
-		host_stat = ap->ops->bmdma_status(ap);
-
-		/* before we do anything else, clear DMA-Start bit */
-		ap->ops->bmdma_stop(qc);
-
-		/* fall through */
-
-	default:
-		ata_altstatus(ap);
-		drv_stat = ata_chk_status(ap);
-
-		/* ack bmdma irq events */
-		ap->ops->irq_clear(ap);
-
-		printk(KERN_ERR "ata%u: command 0x%x timeout, stat 0x%x host_stat 0x%x\n",
-		       ap->id, qc->tf.command, drv_stat, host_stat);
-
-		/* complete taskfile transaction */
-		qc->err_mask |= ac_err_mask(drv_stat);
-		break;
-	}
-
-	spin_unlock_irqrestore(&host_set->lock, flags);
-
-	ata_eh_qc_complete(qc);
-
-	DPRINTK("EXIT\n");
-}
-
-/**
- *	ata_eng_timeout - Handle timeout of queued command
- *	@ap: Port on which timed-out command is active
- *
- *	Some part of the kernel (currently, only the SCSI layer)
- *	has noticed that the active command on port @ap has not
- *	completed after a specified length of time.  Handle this
- *	condition by disabling DMA (if necessary) and completing
- *	transactions, with error if necessary.
- *
- *	This also handles the case of the "lost interrupt", where
- *	for some reason (possibly hardware bug, possibly driver bug)
- *	an interrupt was not delivered to the driver, even though the
- *	transaction completed successfully.
- *
- *	LOCKING:
- *	Inherited from SCSI layer (none, can sleep)
- */
-
-void ata_eng_timeout(struct ata_port *ap)
-{
-	DPRINTK("ENTER\n");
-
-	ata_qc_timeout(ata_qc_from_tag(ap, ap->active_tag));
-
-	DPRINTK("EXIT\n");
-}
-
-/**
  *	ata_qc_new - Request an available ATA command, for queueing
  *	@ap: Port associated with device @dev
  *	@dev: Device from whom we request an available command structure
@@ -5134,7 +5041,6 @@ EXPORT_SYMBOL_GPL(ata_sg_init);
 EXPORT_SYMBOL_GPL(ata_sg_init_one);
 EXPORT_SYMBOL_GPL(__ata_qc_complete);
 EXPORT_SYMBOL_GPL(ata_qc_issue_prot);
-EXPORT_SYMBOL_GPL(ata_eng_timeout);
 EXPORT_SYMBOL_GPL(ata_tf_load);
 EXPORT_SYMBOL_GPL(ata_tf_read);
 EXPORT_SYMBOL_GPL(ata_noop_dev_select);
@@ -5174,15 +5080,12 @@ EXPORT_SYMBOL_GPL(ata_busy_sleep);
 EXPORT_SYMBOL_GPL(ata_port_queue_task);
 EXPORT_SYMBOL_GPL(ata_scsi_ioctl);
 EXPORT_SYMBOL_GPL(ata_scsi_queuecmd);
-EXPORT_SYMBOL_GPL(ata_scsi_error);
 EXPORT_SYMBOL_GPL(ata_scsi_slave_config);
 EXPORT_SYMBOL_GPL(ata_scsi_release);
 EXPORT_SYMBOL_GPL(ata_host_intr);
 EXPORT_SYMBOL_GPL(ata_id_string);
 EXPORT_SYMBOL_GPL(ata_id_c_string);
 EXPORT_SYMBOL_GPL(ata_scsi_simulate);
-EXPORT_SYMBOL_GPL(ata_eh_qc_complete);
-EXPORT_SYMBOL_GPL(ata_eh_qc_retry);
 
 EXPORT_SYMBOL_GPL(ata_pio_need_iordy);
 EXPORT_SYMBOL_GPL(ata_timing_compute);
@@ -5204,3 +5107,8 @@ EXPORT_SYMBOL_GPL(ata_device_suspend);
 EXPORT_SYMBOL_GPL(ata_device_resume);
 EXPORT_SYMBOL_GPL(ata_scsi_device_suspend);
 EXPORT_SYMBOL_GPL(ata_scsi_device_resume);
+
+EXPORT_SYMBOL_GPL(ata_scsi_error);
+EXPORT_SYMBOL_GPL(ata_eng_timeout);
+EXPORT_SYMBOL_GPL(ata_eh_qc_complete);
+EXPORT_SYMBOL_GPL(ata_eh_qc_retry);
diff --git a/drivers/scsi/libata-eh.c b/drivers/scsi/libata-eh.c
new file mode 100644
index 0000000..e73f561
--- /dev/null
+++ b/drivers/scsi/libata-eh.c
@@ -0,0 +1,264 @@
+/*
+ *  libata-eh.c - libata error handling
+ *
+ *  Maintained by:  Jeff Garzik <jgarzik@pobox.com>
+ *    		    Please ALWAYS copy linux-ide@vger.kernel.org
+ *		    on emails.
+ *
+ *  Copyright 2006 Tejun Heo <htejun@gmail.com>
+ *
+ *
+ *  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, 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; see the file COPYING.  If not, write to
+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
+ *  USA.
+ *
+ *
+ *  libata documentation is available via 'make {ps|pdf}docs',
+ *  as Documentation/DocBook/libata.*
+ *
+ *  Hardware documentation available from http://www.t13.org/ and
+ *  http://www.sata-io.org/
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <scsi/scsi.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_eh.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_cmnd.h>
+
+#include <linux/libata.h>
+
+#include "libata.h"
+
+/**
+ *	ata_scsi_timed_out - SCSI layer time out callback
+ *	@cmd: timed out SCSI command
+ *
+ *	Handles SCSI layer timeout.  We race with normal completion of
+ *	the qc for @cmd.  If the qc is already gone, we lose and let
+ *	the scsi command finish (EH_HANDLED).  Otherwise, the qc has
+ *	timed out and EH should be invoked.  Prevent ata_qc_complete()
+ *	from finishing it by setting EH_SCHEDULED and return
+ *	EH_NOT_HANDLED.
+ *
+ *	LOCKING:
+ *	Called from timer context
+ *
+ *	RETURNS:
+ *	EH_HANDLED or EH_NOT_HANDLED
+ */
+enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd)
+{
+	struct Scsi_Host *host = cmd->device->host;
+	struct ata_port *ap = (struct ata_port *) &host->hostdata[0];
+	unsigned long flags;
+	struct ata_queued_cmd *qc;
+	enum scsi_eh_timer_return ret = EH_HANDLED;
+
+	DPRINTK("ENTER\n");
+
+	spin_lock_irqsave(&ap->host_set->lock, flags);
+	qc = ata_qc_from_tag(ap, ap->active_tag);
+	if (qc) {
+		WARN_ON(qc->scsicmd != cmd);
+		qc->flags |= ATA_QCFLAG_EH_SCHEDULED;
+		qc->err_mask |= AC_ERR_TIMEOUT;
+		ret = EH_NOT_HANDLED;
+	}
+	spin_unlock_irqrestore(&ap->host_set->lock, flags);
+
+	DPRINTK("EXIT, ret=%d\n", ret);
+	return ret;
+}
+
+/**
+ *	ata_scsi_error - SCSI layer error handler callback
+ *	@host: SCSI host on which error occurred
+ *
+ *	Handles SCSI-layer-thrown error events.
+ *
+ *	LOCKING:
+ *	Inherited from SCSI layer (none, can sleep)
+ *
+ *	RETURNS:
+ *	Zero.
+ */
+int ata_scsi_error(struct Scsi_Host *host)
+{
+	struct ata_port *ap = (struct ata_port *)&host->hostdata[0];
+
+	DPRINTK("ENTER\n");
+
+	/* synchronize with IRQ handler and port task */
+	spin_unlock_wait(&ap->host_set->lock);
+	ata_port_flush_task(ap);
+
+	WARN_ON(ata_qc_from_tag(ap, ap->active_tag) == NULL);
+
+	ap->ops->eng_timeout(ap);
+
+	WARN_ON(host->host_failed || !list_empty(&host->eh_cmd_q));
+
+	scsi_eh_flush_done_q(&ap->eh_done_q);
+
+	DPRINTK("EXIT\n");
+	return 0;
+}
+
+/**
+ *	ata_qc_timeout - Handle timeout of queued command
+ *	@qc: Command that timed out
+ *
+ *	Some part of the kernel (currently, only the SCSI layer)
+ *	has noticed that the active command on port @ap has not
+ *	completed after a specified length of time.  Handle this
+ *	condition by disabling DMA (if necessary) and completing
+ *	transactions, with error if necessary.
+ *
+ *	This also handles the case of the "lost interrupt", where
+ *	for some reason (possibly hardware bug, possibly driver bug)
+ *	an interrupt was not delivered to the driver, even though the
+ *	transaction completed successfully.
+ *
+ *	LOCKING:
+ *	Inherited from SCSI layer (none, can sleep)
+ */
+static void ata_qc_timeout(struct ata_queued_cmd *qc)
+{
+	struct ata_port *ap = qc->ap;
+	struct ata_host_set *host_set = ap->host_set;
+	u8 host_stat = 0, drv_stat;
+	unsigned long flags;
+
+	DPRINTK("ENTER\n");
+
+	ap->hsm_task_state = HSM_ST_IDLE;
+
+	spin_lock_irqsave(&host_set->lock, flags);
+
+	switch (qc->tf.protocol) {
+
+	case ATA_PROT_DMA:
+	case ATA_PROT_ATAPI_DMA:
+		host_stat = ap->ops->bmdma_status(ap);
+
+		/* before we do anything else, clear DMA-Start bit */
+		ap->ops->bmdma_stop(qc);
+
+		/* fall through */
+
+	default:
+		ata_altstatus(ap);
+		drv_stat = ata_chk_status(ap);
+
+		/* ack bmdma irq events */
+		ap->ops->irq_clear(ap);
+
+		printk(KERN_ERR "ata%u: command 0x%x timeout, stat 0x%x host_stat 0x%x\n",
+		       ap->id, qc->tf.command, drv_stat, host_stat);
+
+		/* complete taskfile transaction */
+		qc->err_mask |= ac_err_mask(drv_stat);
+		break;
+	}
+
+	spin_unlock_irqrestore(&host_set->lock, flags);
+
+	ata_eh_qc_complete(qc);
+
+	DPRINTK("EXIT\n");
+}
+
+/**
+ *	ata_eng_timeout - Handle timeout of queued command
+ *	@ap: Port on which timed-out command is active
+ *
+ *	Some part of the kernel (currently, only the SCSI layer)
+ *	has noticed that the active command on port @ap has not
+ *	completed after a specified length of time.  Handle this
+ *	condition by disabling DMA (if necessary) and completing
+ *	transactions, with error if necessary.
+ *
+ *	This also handles the case of the "lost interrupt", where
+ *	for some reason (possibly hardware bug, possibly driver bug)
+ *	an interrupt was not delivered to the driver, even though the
+ *	transaction completed successfully.
+ *
+ *	LOCKING:
+ *	Inherited from SCSI layer (none, can sleep)
+ */
+void ata_eng_timeout(struct ata_port *ap)
+{
+	DPRINTK("ENTER\n");
+
+	ata_qc_timeout(ata_qc_from_tag(ap, ap->active_tag));
+
+	DPRINTK("EXIT\n");
+}
+
+static void ata_eh_scsidone(struct scsi_cmnd *scmd)
+{
+	/* nada */
+}
+
+static void __ata_eh_qc_complete(struct ata_queued_cmd *qc)
+{
+	struct ata_port *ap = qc->ap;
+	struct scsi_cmnd *scmd = qc->scsicmd;
+	unsigned long flags;
+
+	spin_lock_irqsave(&ap->host_set->lock, flags);
+	qc->scsidone = ata_eh_scsidone;
+	__ata_qc_complete(qc);
+	WARN_ON(ata_tag_valid(qc->tag));
+	spin_unlock_irqrestore(&ap->host_set->lock, flags);
+
+	scsi_eh_finish_cmd(scmd, &ap->eh_done_q);
+}
+
+/**
+ *	ata_eh_qc_complete - Complete an active ATA command from EH
+ *	@qc: Command to complete
+ *
+ *	Indicate to the mid and upper layers that an ATA command has
+ *	completed.  To be used from EH.
+ */
+void ata_eh_qc_complete(struct ata_queued_cmd *qc)
+{
+	struct scsi_cmnd *scmd = qc->scsicmd;
+	scmd->retries = scmd->allowed;
+	__ata_eh_qc_complete(qc);
+}
+
+/**
+ *	ata_eh_qc_retry - Tell midlayer to retry an ATA command after EH
+ *	@qc: Command to retry
+ *
+ *	Indicate to the mid and upper layers that an ATA command
+ *	should be retried.  To be used from EH.
+ *
+ *	SCSI midlayer limits the number of retries to scmd->allowed.
+ *	scmd->retries is decremented for commands which get retried
+ *	due to unrelated failures (qc->err_mask is zero).
+ */
+void ata_eh_qc_retry(struct ata_queued_cmd *qc)
+{
+	struct scsi_cmnd *scmd = qc->scsicmd;
+	if (!qc->err_mask && scmd->retries)
+		scmd->retries--;
+	__ata_eh_qc_complete(qc);
+}
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 4400815..745fc26 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -53,7 +53,6 @@
 typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd);
 static struct ata_device *
 ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev);
-enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd);
 
 #define RW_RECOVERY_MPAGE 0x1
 #define RW_RECOVERY_MPAGE_LEN 12
@@ -714,135 +713,6 @@ int ata_scsi_slave_config(struct scsi_de
 }
 
 /**
- *	ata_scsi_timed_out - SCSI layer time out callback
- *	@cmd: timed out SCSI command
- *
- *	Handles SCSI layer timeout.  We race with normal completion of
- *	the qc for @cmd.  If the qc is already gone, we lose and let
- *	the scsi command finish (EH_HANDLED).  Otherwise, the qc has
- *	timed out and EH should be invoked.  Prevent ata_qc_complete()
- *	from finishing it by setting EH_SCHEDULED and return
- *	EH_NOT_HANDLED.
- *
- *	LOCKING:
- *	Called from timer context
- *
- *	RETURNS:
- *	EH_HANDLED or EH_NOT_HANDLED
- */
-enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd)
-{
-	struct Scsi_Host *host = cmd->device->host;
-	struct ata_port *ap = (struct ata_port *) &host->hostdata[0];
-	unsigned long flags;
-	struct ata_queued_cmd *qc;
-	enum scsi_eh_timer_return ret = EH_HANDLED;
-
-	DPRINTK("ENTER\n");
-
-	spin_lock_irqsave(&ap->host_set->lock, flags);
-	qc = ata_qc_from_tag(ap, ap->active_tag);
-	if (qc) {
-		WARN_ON(qc->scsicmd != cmd);
-		qc->flags |= ATA_QCFLAG_EH_SCHEDULED;
-		qc->err_mask |= AC_ERR_TIMEOUT;
-		ret = EH_NOT_HANDLED;
-	}
-	spin_unlock_irqrestore(&ap->host_set->lock, flags);
-
-	DPRINTK("EXIT, ret=%d\n", ret);
-	return ret;
-}
-
-/**
- *	ata_scsi_error - SCSI layer error handler callback
- *	@host: SCSI host on which error occurred
- *
- *	Handles SCSI-layer-thrown error events.
- *
- *	LOCKING:
- *	Inherited from SCSI layer (none, can sleep)
- *
- *	RETURNS:
- *	Zero.
- */
-
-int ata_scsi_error(struct Scsi_Host *host)
-{
-	struct ata_port *ap = (struct ata_port *)&host->hostdata[0];
-
-	DPRINTK("ENTER\n");
-
-	/* synchronize with IRQ handler and port task */
-	spin_unlock_wait(&ap->host_set->lock);
-	ata_port_flush_task(ap);
-
-	WARN_ON(ata_qc_from_tag(ap, ap->active_tag) == NULL);
-
-	ap->ops->eng_timeout(ap);
-
-	WARN_ON(host->host_failed || !list_empty(&host->eh_cmd_q));
-
-	scsi_eh_flush_done_q(&ap->eh_done_q);
-
-	DPRINTK("EXIT\n");
-	return 0;
-}
-
-static void ata_eh_scsidone(struct scsi_cmnd *scmd)
-{
-	/* nada */
-}
-
-static void __ata_eh_qc_complete(struct ata_queued_cmd *qc)
-{
-	struct ata_port *ap = qc->ap;
-	struct scsi_cmnd *scmd = qc->scsicmd;
-	unsigned long flags;
-
-	spin_lock_irqsave(&ap->host_set->lock, flags);
-	qc->scsidone = ata_eh_scsidone;
-	__ata_qc_complete(qc);
-	WARN_ON(ata_tag_valid(qc->tag));
-	spin_unlock_irqrestore(&ap->host_set->lock, flags);
-
-	scsi_eh_finish_cmd(scmd, &ap->eh_done_q);
-}
-
-/**
- *	ata_eh_qc_complete - Complete an active ATA command from EH
- *	@qc: Command to complete
- *
- *	Indicate to the mid and upper layers that an ATA command has
- *	completed.  To be used from EH.
- */
-void ata_eh_qc_complete(struct ata_queued_cmd *qc)
-{
-	struct scsi_cmnd *scmd = qc->scsicmd;
-	scmd->retries = scmd->allowed;
-	__ata_eh_qc_complete(qc);
-}
-
-/**
- *	ata_eh_qc_retry - Tell midlayer to retry an ATA command after EH
- *	@qc: Command to retry
- *
- *	Indicate to the mid and upper layers that an ATA command
- *	should be retried.  To be used from EH.
- *
- *	SCSI midlayer limits the number of retries to scmd->allowed.
- *	scmd->retries is decremented for commands which get retried
- *	due to unrelated failures (qc->err_mask is zero).
- */
-void ata_eh_qc_retry(struct ata_queued_cmd *qc)
-{
-	struct scsi_cmnd *scmd = qc->scsicmd;
-	if (!qc->err_mask && scmd->retries)
-		scmd->retries--;
-	__ata_eh_qc_complete(qc);
-}
-
-/**
  *	ata_scsi_start_stop_xlat - Translate SCSI START STOP UNIT command
  *	@qc: Storage for translated ATA taskfile
  *	@scsicmd: SCSI command to translate
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h
index 1c755b1..75e9bd5 100644
--- a/drivers/scsi/libata.h
+++ b/drivers/scsi/libata.h
@@ -60,7 +60,6 @@ extern int ata_cmd_ioctl(struct scsi_dev
 extern struct scsi_transport_template ata_scsi_transport_template;
 
 extern void ata_scsi_scan_host(struct ata_port *ap);
-extern int ata_scsi_error(struct Scsi_Host *host);
 extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
 			       unsigned int buflen);
 
@@ -90,4 +89,7 @@ extern void ata_scsi_rbuf_fill(struct at
                         unsigned int (*actor) (struct ata_scsi_args *args,
                                            u8 *rbuf, unsigned int buflen));
 
+/* libata-eh.c */
+extern enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd);
+
 #endif /* __LIBATA_H__ */
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 1f9e6ea..7162f05 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -533,9 +533,6 @@ extern void ata_host_set_remove(struct a
 extern int ata_scsi_detect(struct scsi_host_template *sht);
 extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
 extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *));
-extern int ata_scsi_error(struct Scsi_Host *host);
-extern void ata_eh_qc_complete(struct ata_queued_cmd *qc);
-extern void ata_eh_qc_retry(struct ata_queued_cmd *qc);
 extern int ata_scsi_release(struct Scsi_Host *host);
 extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
 extern int ata_scsi_device_resume(struct scsi_device *);
@@ -584,7 +581,6 @@ extern void ata_bmdma_stop(struct ata_qu
 extern u8   ata_bmdma_status(struct ata_port *ap);
 extern void ata_bmdma_irq_clear(struct ata_port *ap);
 extern void __ata_qc_complete(struct ata_queued_cmd *qc);
-extern void ata_eng_timeout(struct ata_port *ap);
 extern void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev,
 			      struct scsi_cmnd *cmd,
 			      void (*done)(struct scsi_cmnd *));
@@ -639,6 +635,14 @@ extern int pci_test_config_bits(struct p
 extern unsigned long ata_pci_default_filter(const struct ata_port *, struct ata_device *, unsigned long);
 #endif /* CONFIG_PCI */
 
+/*
+ * EH
+ */
+extern int ata_scsi_error(struct Scsi_Host *host);
+extern void ata_eng_timeout(struct ata_port *ap);
+extern void ata_eh_qc_complete(struct ata_queued_cmd *qc);
+extern void ata_eh_qc_retry(struct ata_queued_cmd *qc);
+
 
 static inline int
 ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc)
-- 
1.2.4



^ permalink raw reply related

* [PATCH 14/14] libata: make some libata-core routines extern
From: Tejun Heo @ 2006-04-01 10:48 UTC (permalink / raw)
  To: jgarzik, alan, albertcc, linux-ide; +Cc: Tejun Heo
In-Reply-To: <11438885151530-git-send-email-htejun@gmail.com>

Make libata-core routines which will be used by EH implementation
extern.

Signed-off-by: Tejun Heo <htejun@gmail.com>

---

 drivers/scsi/libata-core.c |   31 +++++++++++++------------------
 drivers/scsi/libata.h      |   14 ++++++++++++++
 2 files changed, 27 insertions(+), 18 deletions(-)

5349c724ad0a9c179ff3e56c235dfd4b20fa12d1
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index c893129..681ef82 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -65,10 +65,6 @@ static unsigned int ata_dev_init_params(
 					struct ata_device *dev,
 					u16 heads,
 					u16 sectors);
-static int ata_down_sata_spd_limit(struct ata_port *ap, struct ata_device *dev);
-static int ata_down_xfermask_limit(struct ata_port *ap, struct ata_device *dev,
-				   int force_pio0);
-static int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev);
 static unsigned int ata_dev_set_xfermode(struct ata_port *ap,
 					 struct ata_device *dev);
 static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev);
@@ -412,7 +408,7 @@ static const char *sata_spd_string(unsig
 	return spd_str[spd - 1];
 }
 
-static void ata_dev_disable(struct ata_port *ap, struct ata_device *dev)
+void ata_dev_disable(struct ata_port *ap, struct ata_device *dev)
 {
 	if (ata_dev_enabled(dev)) {
 		printk(KERN_WARNING "ata%u: dev %u disabled\n",
@@ -979,10 +975,9 @@ void ata_qc_complete_internal(struct ata
  *	None.  Should be called with kernel context, might sleep.
  */
 
-static unsigned
-ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
-		  struct ata_taskfile *tf, const u8 *cdb,
-		  int dma_dir, void *buf, unsigned int buflen)
+unsigned ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
+			   struct ata_taskfile *tf, const u8 *cdb,
+			   int dma_dir, void *buf, unsigned int buflen)
 {
 	u8 command = tf->command;
 	struct ata_queued_cmd *qc;
@@ -1650,7 +1645,7 @@ void ata_port_disable(struct ata_port *a
  *	RETURNS:
  *	0 on success, negative errno on failure
  */
-static int ata_down_sata_spd_limit(struct ata_port *ap, struct ata_device *dev)
+int ata_down_sata_spd_limit(struct ata_port *ap, struct ata_device *dev)
 {
 	u32 spd, mask;
 	int highbit;
@@ -1715,7 +1710,7 @@ static int __ata_set_sata_spd_needed(str
  *	RETURNS:
  *	1 if SATA spd configuration is needed, 0 otherwise.
  */
-static int ata_set_sata_spd_needed(struct ata_port *ap, struct ata_device *dev)
+int ata_set_sata_spd_needed(struct ata_port *ap, struct ata_device *dev)
 {
 	u32 scontrol;
 
@@ -1742,7 +1737,7 @@ static int ata_set_sata_spd_needed(struc
  *	0 if spd doesn't need to be changed, 1 if spd has been
  *	changed.  -EOPNOTSUPP if SCR registers are inaccessible.
  */
-static int ata_set_sata_spd(struct ata_port *ap, struct ata_device *dev)
+int ata_set_sata_spd(struct ata_port *ap, struct ata_device *dev)
 {
 	u32 scontrol;
 
@@ -1924,8 +1919,8 @@ int ata_timing_compute(struct ata_device
  *	RETURNS:
  *	0 on success, negative errno on failure
  */
-static int ata_down_xfermask_limit(struct ata_port *ap, struct ata_device *dev,
-				   int force_pio0)
+int ata_down_xfermask_limit(struct ata_port *ap, struct ata_device *dev,
+			    int force_pio0)
 {
 	unsigned long xfer_mask;
 	int highbit;
@@ -2003,7 +1998,7 @@ static int ata_dev_set_mode(struct ata_p
  *	RETURNS:
  *	0 on success, negative errno otherwise
  */
-static int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev)
+int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev)
 {
 	struct ata_device *dev;
 	int i, rc = 0, used_dma = 0, found = 0;
@@ -2589,9 +2584,9 @@ int ata_std_probe_reset(struct ata_port 
 				     ata_std_postreset, classes);
 }
 
-static int ata_do_reset(struct ata_port *ap,
-			ata_reset_fn_t reset, ata_postreset_fn_t postreset,
-			int verbose, unsigned int *classes)
+int ata_do_reset(struct ata_port *ap,
+		 ata_reset_fn_t reset, ata_postreset_fn_t postreset,
+		 int verbose, unsigned int *classes)
 {
 	int i, rc;
 
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h
index 75e9bd5..3bebca9 100644
--- a/drivers/scsi/libata.h
+++ b/drivers/scsi/libata.h
@@ -45,7 +45,21 @@ extern int libata_fua;
 extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
 				      struct ata_device *dev);
 extern int ata_rwcmd_protocol(struct ata_queued_cmd *qc);
+extern void ata_dev_disable(struct ata_port *ap, struct ata_device *dev);
 extern void ata_port_flush_task(struct ata_port *ap);
+extern unsigned ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
+				  struct ata_taskfile *tf, const u8 *cdb,
+				  int dma_dir, void *buf, unsigned int buflen);
+extern int ata_down_sata_spd_limit(struct ata_port *ap, struct ata_device *dev);
+extern int ata_set_sata_spd_needed(struct ata_port *ap, struct ata_device *dev);
+extern int ata_set_sata_spd(struct ata_port *ap, struct ata_device *dev);
+extern int ata_down_xfermask_limit(struct ata_port *ap, struct ata_device *dev,
+				   int force_pio0);
+extern int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev);
+extern int ata_do_reset(struct ata_port *ap,
+			ata_reset_fn_t reset,
+			ata_postreset_fn_t postreset,
+			int verbose, unsigned int *classes);
 extern void ata_qc_free(struct ata_queued_cmd *qc);
 extern void ata_qc_issue(struct ata_queued_cmd *qc);
 extern int ata_check_atapi_dma(struct ata_queued_cmd *qc);
-- 
1.2.4



^ permalink raw reply related

* [PATCH 11/14] libata: add @cdb to ata_exec_internal()
From: Tejun Heo @ 2006-04-01 10:48 UTC (permalink / raw)
  To: jgarzik, alan, albertcc, linux-ide; +Cc: Tejun Heo
In-Reply-To: <11438885151530-git-send-email-htejun@gmail.com>

Add @cdb to ata_exec_internal().  It will be used by new EH.

Signed-off-by: Tejun Heo <htejun@gmail.com>

---

 drivers/scsi/libata-core.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

528fe36d4d09b5200e52503210298c5569eeb6ff
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index ab7a654..4c9aa75 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -964,6 +964,7 @@ void ata_qc_complete_internal(struct ata
  *	@ap: Port to which the command is sent
  *	@dev: Device to which the command is sent
  *	@tf: Taskfile registers for the command and the result
+ *	@cdb: CDB for packet command
  *	@dma_dir: Data tranfer direction of the command
  *	@buf: Data buffer of the command
  *	@buflen: Length of data buffer
@@ -980,7 +981,7 @@ void ata_qc_complete_internal(struct ata
 
 static unsigned
 ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
-		  struct ata_taskfile *tf,
+		  struct ata_taskfile *tf, const u8 *cdb,
 		  int dma_dir, void *buf, unsigned int buflen)
 {
 	u8 command = tf->command;
@@ -995,6 +996,8 @@ ata_exec_internal(struct ata_port *ap, s
 	BUG_ON(qc == NULL);
 
 	qc->tf = *tf;
+	if (cdb)
+		memcpy(qc->cdb, cdb, ATAPI_CDB_LEN);
 	qc->dma_dir = dma_dir;
 	if (dma_dir != DMA_NONE) {
 		ata_sg_init_one(qc, buf, buflen);
@@ -1144,7 +1147,7 @@ static int ata_dev_read_id(struct ata_po
 
 	tf.protocol = ATA_PROT_PIO;
 
-	err_mask = ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE,
+	err_mask = ata_exec_internal(ap, dev, &tf, NULL, DMA_FROM_DEVICE,
 				     id, sizeof(id[0]) * ATA_ID_WORDS);
 	if (err_mask) {
 		rc = -EIO;
@@ -2977,7 +2980,7 @@ static unsigned int ata_dev_set_xfermode
 	tf.protocol = ATA_PROT_NODATA;
 	tf.nsect = dev->xfer_mode;
 
-	err_mask = ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0);
+	err_mask = ata_exec_internal(ap, dev, &tf, NULL, DMA_NONE, NULL, 0);
 
 	DPRINTK("EXIT, err_mask=%x\n", err_mask);
 	return err_mask;
@@ -3017,7 +3020,7 @@ static unsigned int ata_dev_init_params(
 	tf.nsect = sectors;
 	tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */
 
-	err_mask = ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0);
+	err_mask = ata_exec_internal(ap, dev, &tf, NULL, DMA_NONE, NULL, 0);
 
 	DPRINTK("EXIT, err_mask=%x\n", err_mask);
 	return err_mask;
@@ -4471,7 +4474,7 @@ static int ata_do_simple_cmd(struct ata_
 	tf.flags |= ATA_TFLAG_DEVICE;
 	tf.protocol = ATA_PROT_NODATA;
 
-	err = ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0);
+	err = ata_exec_internal(ap, dev, &tf, NULL, DMA_NONE, NULL, 0);
 	if (err)
 		printk(KERN_ERR "%s: ata command failed: %d\n",
 				__FUNCTION__, err);
-- 
1.2.4



^ permalink raw reply related

* [PATCH 12/14] libata: dec scmd->retries for qcs with zero err_mask
From: Tejun Heo @ 2006-04-01 10:48 UTC (permalink / raw)
  To: jgarzik, alan, albertcc, linux-ide; +Cc: Tejun Heo
In-Reply-To: <11438885151530-git-send-email-htejun@gmail.com>

qcs might get retried because of unrelated failure.  e.g. NCQ command
failure causes the whole command set to be aborted.  Decrement
scmd->retries for such retrials to avoid unnecessarily failing
commands.  Note that scmd->retries will be incremented the first time.

Signed-off-by: Tejun Heo <htejun@gmail.com>

---

 drivers/scsi/libata-scsi.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

712ea26a9289746c7887ef8878ea6b32c16d85c9
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 2870652..4400815 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -831,11 +831,14 @@ void ata_eh_qc_complete(struct ata_queue
  *	should be retried.  To be used from EH.
  *
  *	SCSI midlayer limits the number of retries to scmd->allowed.
- *	This function might need to adjust scmd->retries for commands
- *	which get retried due to unrelated NCQ failures.
+ *	scmd->retries is decremented for commands which get retried
+ *	due to unrelated failures (qc->err_mask is zero).
  */
 void ata_eh_qc_retry(struct ata_queued_cmd *qc)
 {
+	struct scsi_cmnd *scmd = qc->scsicmd;
+	if (!qc->err_mask && scmd->retries)
+		scmd->retries--;
 	__ata_eh_qc_complete(qc);
 }
 
-- 
1.2.4



^ permalink raw reply related

* [PATCH 07/14] libata: add ATA_QCFLAG_IO
From: Tejun Heo @ 2006-04-01 10:48 UTC (permalink / raw)
  To: jgarzik, alan, albertcc, linux-ide; +Cc: Tejun Heo
In-Reply-To: <11438885151530-git-send-email-htejun@gmail.com>

Add a new qc flag ATA_QCFLAG_IO.  This flag gets set for normal IO
commands originating from SCSI midlayer.  This information will be
used by EH to determine transfer speed reconfiguration.

Signed-off-by: Tejun Heo <htejun@gmail.com>

---

 drivers/scsi/libata-scsi.c |    1 +
 include/linux/libata.h     |    3 ++-
 2 files changed, 3 insertions(+), 1 deletions(-)

15c24fd9b6d0f94db93b29f21b9d96efadc6220a
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 096bdff..234e1ca 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -1188,6 +1188,7 @@ static unsigned int ata_scsi_rw_xlat(str
 	u64 block;
 	u32 n_block;
 
+	qc->flags |= ATA_QCFLAG_IO;
 	tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
 
 	if (scsicmd[0] == WRITE_10 || scsicmd[0] == WRITE_6 ||
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 9f942d4..1f9e6ea 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -161,7 +161,8 @@ enum {
 	ATA_QCFLAG_SG		= (1 << 1), /* have s/g table? */
 	ATA_QCFLAG_SINGLE	= (1 << 2), /* no s/g, just a single buffer */
 	ATA_QCFLAG_DMAMAP	= ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE,
-	ATA_QCFLAG_EH_SCHEDULED = (1 << 3), /* EH scheduled */
+	ATA_QCFLAG_IO		= (1 << 3), /* standard IO command */
+	ATA_QCFLAG_EH_SCHEDULED = (1 << 4), /* EH scheduled */
 
 	/* host set flags */
 	ATA_HOST_SIMPLEX	= (1 << 0),	/* Host is simplex, one DMA channel per host_set only */
-- 
1.2.4



^ permalink raw reply related

* [PATCH 10/14] libata: don't read TF directly from sense generation functions
From: Tejun Heo @ 2006-04-01 10:48 UTC (permalink / raw)
  To: jgarzik, alan, albertcc, linux-ide; +Cc: Tejun Heo
In-Reply-To: <11438885151530-git-send-email-htejun@gmail.com>

TF register might not be directly accessible depending on errors.
e.g. TF of failed NCQ command is in log page 10h.  Make reading TF
responsibility of error handlers.  For the current EH, simply push TF
reading into qc completion functions as they are practically part of
EH.  New EH will fill qc->tf with status registers before complting
qcs.

Signed-off-by: Tejun Heo <htejun@gmail.com>

---

 drivers/scsi/libata-scsi.c |   27 +++++++++------------------
 1 files changed, 9 insertions(+), 18 deletions(-)

d7387c910d1b6c1e9019e71e014758e77aff18e6
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index ec628ce..2870652 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -546,12 +546,6 @@ void ata_gen_ata_desc_sense(struct ata_q
 	cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
 
 	/*
-	 * Read the controller registers.
-	 */
-	WARN_ON(qc->ap->ops->tf_read == NULL);
-	qc->ap->ops->tf_read(qc->ap, tf);
-
-	/*
 	 * Use ata_to_sense_error() to map status register bits
 	 * onto sense key, asc & ascq.
 	 */
@@ -622,12 +616,6 @@ void ata_gen_fixed_sense(struct ata_queu
 	cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
 
 	/*
-	 * Read the controller registers.
-	 */
-	WARN_ON(qc->ap->ops->tf_read == NULL);
-	qc->ap->ops->tf_read(qc->ap, tf);
-
-	/*
 	 * Use ata_to_sense_error() to map status register bits
 	 * onto sense key, asc & ascq.
 	 */
@@ -1337,11 +1325,14 @@ static void ata_scsi_qc_complete(struct 
 	 */
 	if (((cdb[0] == ATA_16) || (cdb[0] == ATA_12)) &&
  	    ((cdb[2] & 0x20) || need_sense)) {
+		qc->ap->ops->tf_read(qc->ap, &qc->tf);
  		ata_gen_ata_desc_sense(qc);
 	} else {
 		if (!need_sense) {
 			cmd->result = SAM_STAT_GOOD;
 		} else {
+			qc->ap->ops->tf_read(qc->ap, &qc->tf);
+
 			/* TODO: decide which descriptor format to use
 			 * for 48b LBA devices and call that here
 			 * instead of the fixed desc, which is only
@@ -2133,13 +2124,15 @@ void ata_scsi_badcmd(struct scsi_cmnd *c
 
 static void atapi_sense_complete(struct ata_queued_cmd *qc)
 {
-	if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0))
+	if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0)) {
 		/* FIXME: not quite right; we don't want the
 		 * translation of taskfile registers into
 		 * a sense descriptors, since that's only
 		 * correct for ATA, not ATAPI
 		 */
+		qc->ap->ops->tf_read(qc->ap, &qc->tf);
 		ata_gen_ata_desc_sense(qc);
+	}
 
 	qc->scsidone(qc->scsicmd);
 	ata_qc_free(qc);
@@ -2207,17 +2200,15 @@ static void atapi_qc_complete(struct ata
 		cmd->result = SAM_STAT_CHECK_CONDITION;
 		atapi_request_sense(qc);
 		return;
-	}
-
-	else if (unlikely(err_mask))
+	} else if (unlikely(err_mask)) {
 		/* FIXME: not quite right; we don't want the
 		 * translation of taskfile registers into
 		 * a sense descriptors, since that's only
 		 * correct for ATA, not ATAPI
 		 */
+		qc->ap->ops->tf_read(qc->ap, &qc->tf);
 		ata_gen_ata_desc_sense(qc);
-
-	else {
+	} else {
 		u8 *scsicmd = cmd->cmnd;
 
 		if ((scsicmd[0] == INQUIRY) && ((scsicmd[1] & 0x03) == 0)) {
-- 
1.2.4



^ permalink raw reply related

* [PATCH 09/14] libata: always generate sense if qc->err_mask is non-zero
From: Tejun Heo @ 2006-04-01 10:48 UTC (permalink / raw)
  To: jgarzik, alan, albertcc, linux-ide; +Cc: Tejun Heo
In-Reply-To: <11438885151530-git-send-email-htejun@gmail.com>

Current sense generation code does not generate sense error if status
register value doesn't indicate error condition.  However, LLDD's may
indicate errors which 't show up in status register.  Completing such
qc's without generating sense results in successful completion of
failed commands.

Invoke ata_to_sense_error() regardless of status register if
qc->err_mask is not zero such that ata_to_sense_error() generates
default sense error.

Signed-off-by: Tejun Heo <htejun@gmail.com>

---

 drivers/scsi/libata-scsi.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

4b4b53a7eed5541587578c6226b72e766b12ec4b
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 234e1ca..ec628ce 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -555,7 +555,8 @@ void ata_gen_ata_desc_sense(struct ata_q
 	 * Use ata_to_sense_error() to map status register bits
 	 * onto sense key, asc & ascq.
 	 */
-	if (tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) {
+	if (qc->err_mask ||
+	    tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) {
 		ata_to_sense_error(qc->ap->id, tf->command, tf->feature,
 				   &sb[1], &sb[2], &sb[3]);
 		sb[1] &= 0x0f;
@@ -630,7 +631,8 @@ void ata_gen_fixed_sense(struct ata_queu
 	 * Use ata_to_sense_error() to map status register bits
 	 * onto sense key, asc & ascq.
 	 */
-	if (tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) {
+	if (qc->err_mask ||
+	    tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) {
 		ata_to_sense_error(qc->ap->id, tf->command, tf->feature,
 				   &sb[2], &sb[12], &sb[13]);
 		sb[2] &= 0x0f;
-- 
1.2.4



^ permalink raw reply related

* [PATCH 03/14] libata: ATA_FLAG_IN_EH is not used, kill it
From: Tejun Heo @ 2006-04-01 10:48 UTC (permalink / raw)
  To: jgarzik, alan, albertcc, linux-ide; +Cc: Tejun Heo
In-Reply-To: <11438885151530-git-send-email-htejun@gmail.com>

Kill unused flag ATA_FLAG_IN_EH.

Signed-off-by: Tejun Heo <htejun@gmail.com>

---

 drivers/scsi/libata-scsi.c |   17 ++++-------------
 include/linux/libata.h     |    1 -
 2 files changed, 4 insertions(+), 14 deletions(-)

2b41377fa3c3134fdce3e2366f16c6df4e27d3df
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index c1a4b29..bcbf71e 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -779,20 +779,15 @@ enum scsi_eh_timer_return ata_scsi_timed
 
 int ata_scsi_error(struct Scsi_Host *host)
 {
-	struct ata_port *ap;
-	unsigned long flags;
+	struct ata_port *ap = (struct ata_port *)&host->hostdata[0];
 
 	DPRINTK("ENTER\n");
 
-	ap = (struct ata_port *) &host->hostdata[0];
+	/* synchronize with IRQ handler and port task */
+	spin_unlock_wait(&ap->host_set->lock);
+	ata_port_flush_task(ap);
 
-	spin_lock_irqsave(&ap->host_set->lock, flags);
-	WARN_ON(ap->flags & ATA_FLAG_IN_EH);
-	ap->flags |= ATA_FLAG_IN_EH;
 	WARN_ON(ata_qc_from_tag(ap, ap->active_tag) == NULL);
-	spin_unlock_irqrestore(&ap->host_set->lock, flags);
-
-	ata_port_flush_task(ap);
 
 	ap->ops->eng_timeout(ap);
 
@@ -800,10 +795,6 @@ int ata_scsi_error(struct Scsi_Host *hos
 
 	scsi_eh_flush_done_q(&ap->eh_done_q);
 
-	spin_lock_irqsave(&ap->host_set->lock, flags);
-	ap->flags &= ~ATA_FLAG_IN_EH;
-	spin_unlock_irqrestore(&ap->host_set->lock, flags);
-
 	DPRINTK("EXIT\n");
 	return 0;
 }
diff --git a/include/linux/libata.h b/include/linux/libata.h
index c246a15..036b737 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -152,7 +152,6 @@ enum {
 	ATA_FLAG_IRQ_MASK	= (1 << 14), /* Mask IRQ in PIO xfers */
 
 	ATA_FLAG_FLUSH_PORT_TASK = (1 << 15), /* Flush port task */
-	ATA_FLAG_IN_EH		= (1 << 16), /* EH in progress */
 
 	ATA_QCFLAG_ACTIVE	= (1 << 1), /* cmd not yet ack'd to scsi lyer */
 	ATA_QCFLAG_SG		= (1 << 3), /* have s/g table? */
-- 
1.2.4



^ permalink raw reply related

* [PATCH 05/14] libata: clear only affected flags during ata_dev_configure()
From: Tejun Heo @ 2006-04-01 10:48 UTC (permalink / raw)
  To: jgarzik, alan, albertcc, linux-ide; +Cc: Tejun Heo
In-Reply-To: <11438885151530-git-send-email-htejun@gmail.com>

ata_dev_configure() should not clear dynamic device flags determined
elsewhere.  Only mask out ATA_DFLAG_CFG_MASK before configuring.
Without this patch, ATA_DFLAG_PIO gets turned off during revalidation
making PIO mode unuseable.

Signed-off-by: Tejun Heo <htejun@gmail.com>

---

 drivers/scsi/libata-core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

b5318e739bed15eb68a16b4d61bcd7d7c21ea8fa
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 0df994d..0bc81c3 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -1241,7 +1241,7 @@ static int ata_dev_configure(struct ata_
 		       id[84], id[85], id[86], id[87], id[88]);
 
 	/* initialize to-be-configured parameters */
-	dev->flags = 0;
+	dev->flags &= ~ATA_DFLAG_CFG_MASK;
 	dev->max_sectors = 0;
 	dev->cdb_len = 0;
 	dev->n_sectors = 0;
-- 
1.2.4



^ permalink raw reply related

* [PATCH 06/14] libata: clear ATA_DFLAG_PIO before setting it
From: Tejun Heo @ 2006-04-01 10:48 UTC (permalink / raw)
  To: jgarzik, alan, albertcc, linux-ide; +Cc: Tejun Heo
In-Reply-To: <11438885151530-git-send-email-htejun@gmail.com>

ata_dev_set_mode() is now responsible for managing ATA_DFLAG_PIO.
Clear it before setting it.

Signed-off-by: Tejun Heo <htejun@gmail.com>

---

 drivers/scsi/libata-core.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

24040601836bac07896b6be91011b217e7eb8083
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 0bc81c3..fe66e04 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -1960,6 +1960,7 @@ static int ata_dev_set_mode(struct ata_p
 	unsigned int err_mask;
 	int rc;
 
+	dev->flags &= ~ATA_DFLAG_PIO;
 	if (dev->xfer_shift == ATA_SHIFT_PIO)
 		dev->flags |= ATA_DFLAG_PIO;
 
-- 
1.2.4



^ permalink raw reply related

* [PATCH 04/14] libata: clean up constants
From: Tejun Heo @ 2006-04-01 10:48 UTC (permalink / raw)
  To: jgarzik, alan, albertcc, linux-ide; +Cc: Tejun Heo
In-Reply-To: <11438885151530-git-send-email-htejun@gmail.com>

* Reorder ATA_DFLAG_* such that feature flags determined by
  ata_dev_configure() are on lower bits.  Reserve lower eight bits
  for this purpose and allocate dynamic flags from bit 8.

* Reorder ATA_FLAG_* such that feature flags determined during driver
  initiailization are on bits 0:15, dynamic flags on 16:23 and LLDD
  specific flags on 24:31.

* Rename ATA_FLAG_PORT_DISABLED to ATA_FLAG_DISABLED for consistency.
  (ATA_FLAG_* are always about ports).

* Kill trailing white space and lower-case an one line comment for
  consistency.

Signed-off-by: Tejun Heo <htejun@gmail.com>

---

 drivers/scsi/libata-core.c  |   18 ++++++------
 drivers/scsi/libata-scsi.c  |    2 +
 drivers/scsi/pdc_adma.c     |    4 +--
 drivers/scsi/sata_mv.c      |    2 +
 drivers/scsi/sata_nv.c      |    2 +
 drivers/scsi/sata_promise.c |    2 +
 drivers/scsi/sata_qstor.c   |    4 +--
 drivers/scsi/sata_sil24.c   |    2 +
 drivers/scsi/sata_sx4.c     |    2 +
 drivers/scsi/sata_vsc.c     |    2 +
 include/linux/libata.h      |   62 +++++++++++++++++++++++--------------------
 11 files changed, 53 insertions(+), 49 deletions(-)

100a767c9b63a902301def9c45f9f258f382223a
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 402c0e4..0df994d 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -1045,7 +1045,7 @@ ata_exec_internal(struct ata_port *ap, s
 	 *
 	 * Kill the following code as soon as those drivers are fixed.
 	 */
-	if (ap->flags & ATA_FLAG_PORT_DISABLED) {
+	if (ap->flags & ATA_FLAG_DISABLED) {
 		err_mask |= AC_ERR_SYSTEM;
 		ata_port_probe(ap);
 	}
@@ -1395,7 +1395,7 @@ static int ata_bus_probe(struct ata_port
 	} else {
 		ap->ops->phy_reset(ap);
 
-		if (!(ap->flags & ATA_FLAG_PORT_DISABLED))
+		if (!(ap->flags & ATA_FLAG_DISABLED))
 			for (i = 0; i < ATA_MAX_DEVICES; i++)
 				classes[i] = ap->device[i].class;
 
@@ -1491,7 +1491,7 @@ static int ata_bus_probe(struct ata_port
 
 void ata_port_probe(struct ata_port *ap)
 {
-	ap->flags &= ~ATA_FLAG_PORT_DISABLED;
+	ap->flags &= ~ATA_FLAG_DISABLED;
 }
 
 /**
@@ -1565,7 +1565,7 @@ void __sata_phy_reset(struct ata_port *a
 	else
 		ata_port_disable(ap);
 
-	if (ap->flags & ATA_FLAG_PORT_DISABLED)
+	if (ap->flags & ATA_FLAG_DISABLED)
 		return;
 
 	if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) {
@@ -1590,7 +1590,7 @@ void __sata_phy_reset(struct ata_port *a
 void sata_phy_reset(struct ata_port *ap)
 {
 	__sata_phy_reset(ap);
-	if (ap->flags & ATA_FLAG_PORT_DISABLED)
+	if (ap->flags & ATA_FLAG_DISABLED)
 		return;
 	ata_bus_reset(ap);
 }
@@ -1629,7 +1629,7 @@ void ata_port_disable(struct ata_port *a
 {
 	ap->device[0].class = ATA_DEV_NONE;
 	ap->device[1].class = ATA_DEV_NONE;
-	ap->flags |= ATA_FLAG_PORT_DISABLED;
+	ap->flags |= ATA_FLAG_DISABLED;
 }
 
 /**
@@ -2262,7 +2262,7 @@ static unsigned int ata_bus_softreset(st
  *	Obtains host_set lock.
  *
  *	SIDE EFFECTS:
- *	Sets ATA_FLAG_PORT_DISABLED if bus reset fails.
+ *	Sets ATA_FLAG_DISABLED if bus reset fails.
  */
 
 void ata_bus_reset(struct ata_port *ap)
@@ -4457,7 +4457,7 @@ irqreturn_t ata_interrupt (int irq, void
 
 		ap = host_set->ports[i];
 		if (ap &&
-		    !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) {
+		    !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) {
 			struct ata_queued_cmd *qc;
 
 			qc = ata_qc_from_tag(ap, ap->active_tag);
@@ -4678,7 +4678,7 @@ static void ata_host_init(struct ata_por
 	host->unique_id = ata_unique_id++;
 	host->max_cmd_len = 12;
 
-	ap->flags = ATA_FLAG_PORT_DISABLED;
+	ap->flags = ATA_FLAG_DISABLED;
 	ap->id = host->unique_id;
 	ap->host = host;
 	ap->ctl = ATA_DEVCTL_OBS;
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index bcbf71e..096bdff 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -2728,7 +2728,7 @@ void ata_scsi_scan_host(struct ata_port 
 	struct ata_device *dev;
 	unsigned int i;
 
-	if (ap->flags & ATA_FLAG_PORT_DISABLED)
+	if (ap->flags & ATA_FLAG_DISABLED)
 		return;
 
 	for (i = 0; i < ATA_MAX_DEVICES; i++) {
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c
index 3c85c4b..d64073d 100644
--- a/drivers/scsi/pdc_adma.c
+++ b/drivers/scsi/pdc_adma.c
@@ -456,7 +456,7 @@ static inline unsigned int adma_intr_pkt
 			continue;
 		handled = 1;
 		adma_enter_reg_mode(ap);
-		if (ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))
+		if (ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))
 			continue;
 		pp = ap->private_data;
 		if (!pp || pp->state != adma_state_pkt)
@@ -481,7 +481,7 @@ static inline unsigned int adma_intr_mmi
 	for (port_no = 0; port_no < host_set->n_ports; ++port_no) {
 		struct ata_port *ap;
 		ap = host_set->ports[port_no];
-		if (ap && (!(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR)))) {
+		if (ap && (!(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR)))) {
 			struct ata_queued_cmd *qc;
 			struct adma_port_priv *pp = ap->private_data;
 			if (!pp || pp->state != adma_state_mmio)
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
index 0f7d334..e9152f8 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/scsi/sata_mv.c
@@ -1397,7 +1397,7 @@ static void mv_host_intr(struct ata_host
 			}
 		}
 
-		if (ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))
+		if (ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))
 			continue;
 
 		err_mask = ac_err_mask(ata_status);
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c
index f77bf18..72721ac 100644
--- a/drivers/scsi/sata_nv.c
+++ b/drivers/scsi/sata_nv.c
@@ -280,7 +280,7 @@ static irqreturn_t nv_interrupt (int irq
 
 		ap = host_set->ports[i];
 		if (ap &&
-		    !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) {
+		    !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) {
 			struct ata_queued_cmd *qc;
 
 			qc = ata_qc_from_tag(ap, ap->active_tag);
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c
index cc928c6..9557c7a 100644
--- a/drivers/scsi/sata_promise.c
+++ b/drivers/scsi/sata_promise.c
@@ -534,7 +534,7 @@ static irqreturn_t pdc_interrupt (int ir
 		ap = host_set->ports[i];
 		tmp = mask & (1 << (i + 1));
 		if (tmp && ap &&
-		    !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) {
+		    !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) {
 			struct ata_queued_cmd *qc;
 
 			qc = ata_qc_from_tag(ap, ap->active_tag);
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c
index 9ffe1ef..8ef042a 100644
--- a/drivers/scsi/sata_qstor.c
+++ b/drivers/scsi/sata_qstor.c
@@ -396,7 +396,7 @@ static inline unsigned int qs_intr_pkt(s
 					sff1, sff0, port_no, sHST, sDST);
 			handled = 1;
 			if (ap && !(ap->flags &
-				    (ATA_FLAG_PORT_DISABLED|ATA_FLAG_NOINTR))) {
+				    (ATA_FLAG_DISABLED|ATA_FLAG_NOINTR))) {
 				struct ata_queued_cmd *qc;
 				struct qs_port_priv *pp = ap->private_data;
 				if (!pp || pp->state != qs_state_pkt)
@@ -429,7 +429,7 @@ static inline unsigned int qs_intr_mmio(
 		struct ata_port *ap;
 		ap = host_set->ports[port_no];
 		if (ap &&
-		    !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) {
+		    !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) {
 			struct ata_queued_cmd *qc;
 			struct qs_port_priv *pp = ap->private_data;
 			if (!pp || pp->state != qs_state_mmio)
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c
index 068c98a..c34f6da 100644
--- a/drivers/scsi/sata_sil24.c
+++ b/drivers/scsi/sata_sil24.c
@@ -770,7 +770,7 @@ static irqreturn_t sil24_interrupt(int i
 	for (i = 0; i < host_set->n_ports; i++)
 		if (status & (1 << i)) {
 			struct ata_port *ap = host_set->ports[i];
-			if (ap && !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
+			if (ap && !(ap->flags & ATA_FLAG_DISABLED)) {
 				sil24_host_intr(host_set->ports[i]);
 				handled++;
 			} else
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c
index ae70f60..3af28ef 100644
--- a/drivers/scsi/sata_sx4.c
+++ b/drivers/scsi/sata_sx4.c
@@ -834,7 +834,7 @@ static irqreturn_t pdc20621_interrupt (i
 		tmp = mask & (1 << i);
 		VPRINTK("seq %u, port_no %u, ap %p, tmp %x\n", i, port_no, ap, tmp);
 		if (tmp && ap &&
-		    !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) {
+		    !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) {
 			struct ata_queued_cmd *qc;
 
 			qc = ata_qc_from_tag(ap, ap->active_tag);
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c
index 836bbbb..cecc1f7 100644
--- a/drivers/scsi/sata_vsc.c
+++ b/drivers/scsi/sata_vsc.c
@@ -222,7 +222,7 @@ static irqreturn_t vsc_sata_interrupt (i
 			ap = host_set->ports[i];
 
 			if (ap && !(ap->flags &
-				    (ATA_FLAG_PORT_DISABLED|ATA_FLAG_NOINTR))) {
+				    (ATA_FLAG_DISABLED|ATA_FLAG_NOINTR))) {
 				struct ata_queued_cmd *qc;
 
 				qc = ata_qc_from_tag(ap, ap->active_tag);
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 036b737..9f942d4 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -120,9 +120,11 @@ enum {
 	ATA_SHT_USE_CLUSTERING	= 1,
 
 	/* struct ata_device stuff */
-	ATA_DFLAG_LBA48		= (1 << 0), /* device supports LBA48 */
-	ATA_DFLAG_PIO		= (1 << 1), /* device currently in PIO mode */
-	ATA_DFLAG_LBA		= (1 << 2), /* device supports LBA */
+	ATA_DFLAG_LBA		= (1 << 0), /* device supports LBA */
+	ATA_DFLAG_LBA48		= (1 << 1), /* device supports LBA48 */
+	ATA_DFLAG_CFG_MASK	= (1 << 8) - 1,
+
+	ATA_DFLAG_PIO		= (1 << 8), /* device currently in PIO mode */
 
 	ATA_DEV_UNKNOWN		= 0,	/* unknown device */
 	ATA_DEV_ATA		= 1,	/* ATA device */
@@ -132,32 +134,34 @@ enum {
 	ATA_DEV_NONE		= 5,	/* no device */
 
 	/* struct ata_port flags */
-	ATA_FLAG_SLAVE_POSS	= (1 << 1), /* host supports slave dev */
+	ATA_FLAG_SLAVE_POSS	= (1 << 0), /* host supports slave dev */
 					    /* (doesn't imply presence) */
-	ATA_FLAG_PORT_DISABLED	= (1 << 2), /* port is disabled, ignore it */
-	ATA_FLAG_SATA		= (1 << 3),
-	ATA_FLAG_NO_LEGACY	= (1 << 4), /* no legacy mode check */
-	ATA_FLAG_SRST		= (1 << 5), /* (obsolete) use ATA SRST, not E.D.D. */
-	ATA_FLAG_MMIO		= (1 << 6), /* use MMIO, not PIO */
-	ATA_FLAG_SATA_RESET	= (1 << 7), /* (obsolete) use COMRESET */
-	ATA_FLAG_PIO_DMA	= (1 << 8), /* PIO cmds via DMA */
-	ATA_FLAG_NOINTR		= (1 << 9), /* FIXME: Remove this once
-					     * proper HSM is in place. */
-	ATA_FLAG_DEBUGMSG	= (1 << 10),
-	ATA_FLAG_NO_ATAPI	= (1 << 11), /* No ATAPI support */
-
-	ATA_FLAG_SUSPENDED	= (1 << 12), /* port is suspended */
-
-	ATA_FLAG_PIO_LBA48	= (1 << 13), /* Host DMA engine is LBA28 only */
-	ATA_FLAG_IRQ_MASK	= (1 << 14), /* Mask IRQ in PIO xfers */
-
-	ATA_FLAG_FLUSH_PORT_TASK = (1 << 15), /* Flush port task */
-
-	ATA_QCFLAG_ACTIVE	= (1 << 1), /* cmd not yet ack'd to scsi lyer */
-	ATA_QCFLAG_SG		= (1 << 3), /* have s/g table? */
-	ATA_QCFLAG_SINGLE	= (1 << 4), /* no s/g, just a single buffer */
+	ATA_FLAG_SATA		= (1 << 1),
+	ATA_FLAG_NO_LEGACY	= (1 << 2), /* no legacy mode check */
+	ATA_FLAG_MMIO		= (1 << 3), /* use MMIO, not PIO */
+	ATA_FLAG_SRST		= (1 << 4), /* (obsolete) use ATA SRST, not E.D.D. */
+	ATA_FLAG_SATA_RESET	= (1 << 5), /* (obsolete) use COMRESET */
+	ATA_FLAG_NO_ATAPI	= (1 << 6), /* No ATAPI support */
+	ATA_FLAG_PIO_DMA	= (1 << 7), /* PIO cmds via DMA */
+	ATA_FLAG_PIO_LBA48	= (1 << 8), /* Host DMA engine is LBA28 only */
+	ATA_FLAG_IRQ_MASK	= (1 << 9), /* Mask IRQ in PIO xfers */
+
+	ATA_FLAG_NOINTR		= (1 << 16), /* FIXME: Remove this once
+					      * proper HSM is in place. */
+	ATA_FLAG_DEBUGMSG	= (1 << 17),
+	ATA_FLAG_FLUSH_PORT_TASK = (1 << 18), /* flush port task */
+
+	ATA_FLAG_DISABLED	= (1 << 19), /* port is disabled, ignore it */
+	ATA_FLAG_SUSPENDED	= (1 << 20), /* port is suspended */
+
+	/* bits 24:31 of ap->flags are reserved for LLDD specific flags */
+
+	/* struct ata_queued_cmd flags */
+	ATA_QCFLAG_ACTIVE	= (1 << 0), /* cmd not yet ack'd to scsi lyer */
+	ATA_QCFLAG_SG		= (1 << 1), /* have s/g table? */
+	ATA_QCFLAG_SINGLE	= (1 << 2), /* no s/g, just a single buffer */
 	ATA_QCFLAG_DMAMAP	= ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE,
-	ATA_QCFLAG_EH_SCHEDULED = (1 << 5), /* EH scheduled */
+	ATA_QCFLAG_EH_SCHEDULED = (1 << 3), /* EH scheduled */
 
 	/* host set flags */
 	ATA_HOST_SIMPLEX	= (1 << 0),	/* Host is simplex, one DMA channel per host_set only */
@@ -206,8 +210,8 @@ enum {
 	/* size of buffer to pad xfers ending on unaligned boundaries */
 	ATA_DMA_PAD_SZ		= 4,
 	ATA_DMA_PAD_BUF_SZ	= ATA_DMA_PAD_SZ * ATA_MAX_QUEUE,
-	
-	/* Masks for port functions */
+
+	/* masks for port functions */
 	ATA_PORT_PRIMARY	= (1 << 0),
 	ATA_PORT_SECONDARY	= (1 << 1),
 
-- 
1.2.4



^ permalink raw reply related

* [PATCHSET] libata: prep for new EH
From: Tejun Heo @ 2006-04-01 10:48 UTC (permalink / raw)
  To: jgarzik, alan, albertcc, linux-ide, htejun

Hello, Jeff, Alan and Albert.

This patchset contains various fixes and updates in preparation for
new EH.  Most patches are straight-forward and even trivial.

This patchset has 15 patches and is against
  #upstream [1]
  + improve-ata_bus_probe-failure-handling patchset[2]

Thanks.

--
tejun

[1] 8b316a3973f05e572b4edeeda9072987f6bbaa44
[2] http://article.gmane.org/gmane.linux.ide/9170



^ permalink raw reply

* [PATCH 02/14] libata: ata_dev_revalidate() printk update
From: Tejun Heo @ 2006-04-01 10:48 UTC (permalink / raw)
  To: jgarzik, alan, albertcc, linux-ide; +Cc: Tejun Heo
In-Reply-To: <11438885151530-git-send-email-htejun@gmail.com>

Make sure ata_dev_revalidate() complains on failures and kill
revalidation failure message printed from ata_dev_set_mode().

Signed-off-by: Tejun Heo <htejun@gmail.com>

---

 drivers/scsi/libata-core.c |   23 ++++++++++-------------
 1 files changed, 10 insertions(+), 13 deletions(-)

48633a90b26ada7104a8e320636f20f642ee2de4
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 93f8bce..402c0e4 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -1972,12 +1972,8 @@ static int ata_dev_set_mode(struct ata_p
 	}
 
 	rc = ata_dev_revalidate(ap, dev, 0);
-	if (rc) {
-		printk(KERN_ERR
-		       "ata%u: failed to revalidate after set xfermode\n",
-		       ap->id);
+	if (rc)
 		return rc;
-	}
 
 	DPRINTK("xfer_shift=%u, xfer_mode=0x%x\n",
 		dev->xfer_shift, (int)dev->xfer_mode);
@@ -2775,15 +2771,14 @@ static int ata_dev_same_device(struct at
 int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev,
 		       int post_reset)
 {
-	unsigned int class;
-	u16 *id;
+	unsigned int class = dev->class;
+	u16 *id = NULL;
 	int rc;
 
-	if (!ata_dev_enabled(dev))
-		return -ENODEV;
-
-	class = dev->class;
-	id = NULL;
+	if (!ata_dev_enabled(dev)) {
+		rc = -ENODEV;
+		goto fail;
+	}
 
 	/* allocate & read ID data */
 	rc = ata_dev_read_id(ap, dev, &class, post_reset, &id);
@@ -2800,7 +2795,9 @@ int ata_dev_revalidate(struct ata_port *
 	dev->id = id;
 
 	/* configure device according to the new ID */
-	return ata_dev_configure(ap, dev, 0);
+	rc = ata_dev_configure(ap, dev, 0);
+	if (rc == 0)
+		return 0;
 
  fail:
 	printk(KERN_ERR "ata%u: dev %u revalidation failed (errno=%d)\n",
-- 
1.2.4



^ permalink raw reply related

* [PATCH 01/14] libata: report device number when PIO fails
From: Tejun Heo @ 2006-04-01 10:48 UTC (permalink / raw)
  To: jgarzik, alan, albertcc, linux-ide; +Cc: Tejun Heo
In-Reply-To: <11438885151530-git-send-email-htejun@gmail.com>

Report device number on PIO failure.

Signed-off-by: Tejun Heo <htejun@gmail.com>

---

 drivers/scsi/libata-core.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

75ac0de9ac24614a2a75d80cb7f5bc1e7dc509ba
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 0d72792..93f8bce 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -3898,7 +3898,8 @@ static void ata_pio_error(struct ata_por
 	WARN_ON(qc == NULL);
 
 	if (qc->tf.command != ATA_CMD_PACKET)
-		printk(KERN_WARNING "ata%u: PIO error\n", ap->id);
+		printk(KERN_WARNING "ata%u: dev %u PIO error\n",
+		       ap->id, qc->dev->devno);
 
 	/* make sure qc->err_mask is available to
 	 * know what's wrong and recover
-- 
1.2.4



^ permalink raw reply related

* Re: removal of EXPORT_SYMBOL(insert_resource)?
From: Adrian Bunk @ 2006-04-01 10:46 UTC (permalink / raw)
  To: Greg KH, Kumar Gala, Andrew Morton, linux-kernel
In-Reply-To: <20060304005935.GA27548@kroah.com>

Kumar,

any news regarding a submission of your code?

cu
Adrian


On Fri, Mar 03, 2006 at 04:59:35PM -0800, Greg KH wrote:
> On Thu, Mar 02, 2006 at 01:31:08PM -0600, Kumar Gala wrote:
> > I have a situation that I believe warrants leaving insert_resource as an 
> > exported API.
> > 
> > I've got a bus implementation that it done as a module.  While I'm more 
> > than happy to provide this bus implementation to be included in the 
> > mainline, I dont think it makes much sense to do so.  The code is only 
> > useful to an extremely small handful of people.  If we want to clutter the 
> > kernel with it I'm happy to provide a patch for it.
> 
> Please do, keeping code outside the kernel makes it _very_ hard on you.
> It makes it easier if everything is in-the-tree, as you know.
> 
> Hell, we have two whole x86 subarchs with only 4 machines each in
> existance, a simple bus is nothing :)
> 
> > The situation I have is a FPGA connect over PCI.  The FPGA implements a 
> > number of different "functions" but uses PCI more like an SoC bus than a 
> > true PCI device.  Anyways, in some discussions with gregkh, it was 
> > suggested the best thing was to create a new bus type that the "fpga" 
> > drivers would bind to.
> > 
> > I use insert_resource to handle registering the MMIO regions for each 
> > device (similar to how platform devices are registered).
> 
> All the better reason to get it into the tree...
> 
> thanks,
> 
> greg k-h

^ permalink raw reply

* RE: [PATCH] This patch fixes several issues related tovmxassist
From: Li, Xin B @ 2006-04-01 10:45 UTC (permalink / raw)
  To: Li, Xin B, Keir Fraser; +Cc: Xen Devel

>>Well, it's impossible to know for certain without looking at hidden 
>>descriptor state isn't it. Big real mode is only possible because the 
>>hidden state can be out of sync with the current execution mode.
>>
>>If that state can be made available to the address() function 
>>then it's 
>>implementation, and confidence in its correctness, becomes 
>trivial. Do 
>>we have that state available directly in the guest at that point? Or 
>>would we need to grab the state from Xen?
>>
>
>Keir, do you think this one seems better?
>When in real mode, we should always calculate address as ((seg 
>& 0xFFFF)
><< 4) + off, big real mode obey the same rule.
>When in real mode to protected mode transition, only the IP address
>calculation should use real mode addressing.
>-Xin

At this time, I'd like to push this patch in, since it really fixes
quite a few bugs, anyway, we still need revisit it later, to be
watertight is hard for now :-(
-Xin

^ permalink raw reply

* please pull from the trivial tree
From: Adrian Bunk @ 2006-04-01 10:43 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel

Linus, please pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial.git


This tree contains the following:


Adrian Bunk:
      help text: SOFTWARE_SUSPEND doesn't need ACPI
      fix a typo in the AIC7XXX_DEBUG_MASK help text
      fix the email address of Wendy Xiong
      typos: s/ducument/document/

Anders Larsen:
      MTD: remove obsolete Kconfig options

Cal Peake:
      BFP->BPF in Documentation/networking/tuntap.txt

Eric Sesterhenn:
      BUG_ON() Conversion in md/dm-target.c
      BUG_ON() Conversion in md/raid1.c
      BUG_ON() Conversion in fs/direct-io.c
      BUG_ON() Conversion in fs/exec.c
      BUG_ON() Conversion in fs/hfsplus/
      BUG_ON() Conversion in fs/jffs2/
      BUG_ON() Conversion in fs/smbfs/
      BUG_ON() Conversion in fs/sysfs/
      BUG_ON() Conversion in ipc/util.c
      BUG_ON() Conversion in kernel/printk.c
      BUG_ON() Conversion in mm/mmap.c
      BUG_ON() Conversion in mm/swap_state.c
      BUG_ON() Conversion in mm/vmalloc.c
      BUG_ON() Conversion in drivers/s390/block/dasd_erp.c
      BUG_ON() Conversion in drivers/s390/char/tape_block.c

Horms:
      Documentation: Reorder documentation of nomca and nomce
      Documentation: Make fujitsu/frv/kernel-ABI.txt 80 columns wide
      kexec: grammar fix for crash_save_this_cpu()

Kalin KOZHUHAROV:
      Fix comments: s/granuality/granularity/

Michael Hayes:
      Fix minor documentation typo

Stefan Richter:
      Doc/kernel-parameters.txt: delete false version information and history
      Doc/kernel-parameters.txt: mention modinfo and sysfs
      Doc/kernel-parameters.txt: slightly reword sentence about restrictions

Uwe Zeisberger:
      fix typo "Suposse" -> "Suppose"


 Documentation/DocBook/Makefile           |    2 
 Documentation/acpi-hotkey.txt            |    2 
 Documentation/fujitsu/frv/kernel-ABI.txt |  196 +++++++++++++----------
 Documentation/kernel-parameters.txt      |   34 +--
 Documentation/networking/packet_mmap.txt |    2 
 Documentation/networking/tuntap.txt      |    2 
 arch/i386/kernel/crash.c                 |    2 
 drivers/md/dm-target.c                   |    3 
 drivers/md/raid1.c                       |    6 
 drivers/mtd/chips/Kconfig                |   21 --
 drivers/s390/block/dasd_erp.c            |    8 
 drivers/s390/char/sclp_rw.c              |    2 
 drivers/s390/char/tape_block.c           |   13 -
 drivers/scsi/aic7xxx/Kconfig.aic7xxx     |    2 
 drivers/serial/jsm/jsm.h                 |    2 
 drivers/serial/jsm/jsm_driver.c          |    2 
 drivers/serial/jsm/jsm_neo.c             |    2 
 fs/direct-io.c                           |    3 
 fs/exec.c                                |    2 
 fs/hfsplus/bnode.c                       |    6 
 fs/hfsplus/btree.c                       |    3 
 fs/jffs2/background.c                    |    3 
 fs/smbfs/file.c                          |    6 
 fs/sysfs/inode.c                         |    3 
 include/linux/fs.h                       |    2 
 ipc/util.c                               |    6 
 kernel/power/Kconfig                     |    2 
 kernel/printk.c                          |    6 
 kernel/time.c                            |    8 
 mm/mmap.c                                |    9 -
 mm/swap_state.c                          |    3 
 mm/vmalloc.c                             |    3 
 32 files changed, 170 insertions(+), 196 deletions(-)


diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index 7d87dd7..5a2882d 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -2,7 +2,7 @@
 # This makefile is used to generate the kernel documentation,
 # primarily based on in-line comments in various source files.
 # See Documentation/kernel-doc-nano-HOWTO.txt for instruction in how
-# to ducument the SRC - and how to read it.
+# to document the SRC - and how to read it.
 # To add a new book the only step required is to add the book to the
 # list of DOCBOOKS.
 
diff --git a/Documentation/acpi-hotkey.txt b/Documentation/acpi-hotkey.txt
index 744f1ae..38040fa 100644
--- a/Documentation/acpi-hotkey.txt
+++ b/Documentation/acpi-hotkey.txt
@@ -30,7 +30,7 @@ specific hotkey(event))
 echo "event_num:event_type:event_argument" > 
 	/proc/acpi/hotkey/action.
 The result of the execution of this aml method is 
-attached to /proc/acpi/hotkey/poll_method, which is dnyamically
+attached to /proc/acpi/hotkey/poll_method, which is dynamically
 created.  Please use command "cat /proc/acpi/hotkey/polling_method" 
 to retrieve it.
 
diff --git a/Documentation/fujitsu/frv/kernel-ABI.txt b/Documentation/fujitsu/frv/kernel-ABI.txt
index 0ed9b0a..8b0a5fc 100644
--- a/Documentation/fujitsu/frv/kernel-ABI.txt
+++ b/Documentation/fujitsu/frv/kernel-ABI.txt
@@ -1,17 +1,19 @@
-				 =================================
-				 INTERNAL KERNEL ABI FOR FR-V ARCH
-				 =================================
-
-The internal FRV kernel ABI is not quite the same as the userspace ABI. A number of the registers
-are used for special purposed, and the ABI is not consistent between modules vs core, and MMU vs
-no-MMU.
-
-This partly stems from the fact that FRV CPUs do not have a separate supervisor stack pointer, and
-most of them do not have any scratch registers, thus requiring at least one general purpose
-register to be clobbered in such an event. Also, within the kernel core, it is possible to simply
-jump or call directly between functions using a relative offset. This cannot be extended to modules
-for the displacement is likely to be too far. Thus in modules the address of a function to call
-must be calculated in a register and then used, requiring two extra instructions.
+			=================================
+			INTERNAL KERNEL ABI FOR FR-V ARCH
+			=================================
+
+The internal FRV kernel ABI is not quite the same as the userspace ABI. A
+number of the registers are used for special purposed, and the ABI is not
+consistent between modules vs core, and MMU vs no-MMU.
+
+This partly stems from the fact that FRV CPUs do not have a separate
+supervisor stack pointer, and most of them do not have any scratch
+registers, thus requiring at least one general purpose register to be
+clobbered in such an event. Also, within the kernel core, it is possible to
+simply jump or call directly between functions using a relative offset.
+This cannot be extended to modules for the displacement is likely to be too
+far. Thus in modules the address of a function to call must be calculated
+in a register and then used, requiring two extra instructions.
 
 This document has the following sections:
 
@@ -39,7 +41,8 @@ When a system call is made, the followin
 CPU OPERATING MODES
 ===================
 
-The FR-V CPU has three basic operating modes. In order of increasing capability:
+The FR-V CPU has three basic operating modes. In order of increasing
+capability:
 
   (1) User mode.
 
@@ -47,42 +50,46 @@ The FR-V CPU has three basic operating m
 
   (2) Kernel mode.
 
-      Normal kernel mode. There are many additional control registers available that may be
-      accessed in this mode, in addition to all the stuff available to user mode. This has two
-      submodes:
+      Normal kernel mode. There are many additional control registers
+      available that may be accessed in this mode, in addition to all the
+      stuff available to user mode. This has two submodes:
 
       (a) Exceptions enabled (PSR.T == 1).
 
-      	  Exceptions will invoke the appropriate normal kernel mode handler. On entry to the
-      	  handler, the PSR.T bit will be cleared.
+	  Exceptions will invoke the appropriate normal kernel mode
+	  handler. On entry to the handler, the PSR.T bit will be cleared.
 
       (b) Exceptions disabled (PSR.T == 0).
 
-      	  No exceptions or interrupts may happen. Any mandatory exceptions will cause the CPU to
-      	  halt unless the CPU is told to jump into debug mode instead.
+	  No exceptions or interrupts may happen. Any mandatory exceptions
+	  will cause the CPU to halt unless the CPU is told to jump into
+	  debug mode instead.
 
   (3) Debug mode.
 
-      No exceptions may happen in this mode. Memory protection and management exceptions will be
-      flagged for later consideration, but the exception handler won't be invoked. Debugging traps
-      such as hardware breakpoints and watchpoints will be ignored. This mode is entered only by
-      debugging events obtained from the other two modes.
+      No exceptions may happen in this mode. Memory protection and
+      management exceptions will be flagged for later consideration, but
+      the exception handler won't be invoked. Debugging traps such as
+      hardware breakpoints and watchpoints will be ignored. This mode is
+      entered only by debugging events obtained from the other two modes.
 
-      All kernel mode registers may be accessed, plus a few extra debugging specific registers.
+      All kernel mode registers may be accessed, plus a few extra debugging
+      specific registers.
 
 
 =================================
 INTERNAL KERNEL-MODE REGISTER ABI
 =================================
 
-There are a number of permanent register assignments that are set up by entry.S in the exception
-prologue. Note that there is a complete set of exception prologues for each of user->kernel
-transition and kernel->kernel transition. There are also user->debug and kernel->debug mode
-transition prologues.
+There are a number of permanent register assignments that are set up by
+entry.S in the exception prologue. Note that there is a complete set of
+exception prologues for each of user->kernel transition and kernel->kernel
+transition. There are also user->debug and kernel->debug mode transition
+prologues.
 
 
 	REGISTER	FLAVOUR	USE
-	===============	=======	====================================================
+	===============	=======	==============================================
 	GR1			Supervisor stack pointer
 	GR15			Current thread info pointer
 	GR16			GP-Rel base register for small data
@@ -92,10 +99,12 @@ transition prologues.
 	GR31		NOMMU	Destroyed by debug mode entry
 	GR31		MMU	Destroyed by TLB miss kernel mode entry
 	CCR.ICC2		Virtual interrupt disablement tracking
-	CCCR.CC3		Cleared by exception prologue (atomic op emulation)
+	CCCR.CC3		Cleared by exception prologue 
+				(atomic op emulation)
 	SCR0		MMU	See mmu-layout.txt.
 	SCR1		MMU	See mmu-layout.txt.
-	SCR2		MMU	Save for EAR0 (destroyed by icache insns in debug mode)
+	SCR2		MMU	Save for EAR0 (destroyed by icache insns 
+					       in debug mode)
 	SCR3		MMU	Save for GR31 during debug exceptions
 	DAMR/IAMR	NOMMU	Fixed memory protection layout.
 	DAMR/IAMR	MMU	See mmu-layout.txt.
@@ -104,18 +113,21 @@ transition prologues.
 Certain registers are also used or modified across function calls:
 
 	REGISTER	CALL				RETURN
-	===============	===============================	===============================
+	===============	===============================	======================
 	GR0		Fixed Zero			-
 	GR2		Function call frame pointer
 	GR3		Special				Preserved
 	GR3-GR7		-				Clobbered
-	GR8		Function call arg #1		Return value (or clobbered)
-	GR9		Function call arg #2		Return value MSW (or clobbered)
+	GR8		Function call arg #1		Return value 
+							(or clobbered)
+	GR9		Function call arg #2		Return value MSW 
+							(or clobbered)
 	GR10-GR13	Function call arg #3-#6		Clobbered
 	GR14		-				Clobbered
 	GR15-GR16	Special				Preserved
 	GR17-GR27	-				Preserved
-	GR28-GR31	Special				Only accessed explicitly
+	GR28-GR31	Special				Only accessed 
+							explicitly
 	LR		Return address after CALL	Clobbered
 	CCR/CCCR	-				Mostly Clobbered
 
@@ -124,46 +136,53 @@ Certain registers are also used or modif
 INTERNAL DEBUG-MODE REGISTER ABI
 ================================
 
-This is the same as the kernel-mode register ABI for functions calls. The difference is that in
-debug-mode there's a different stack and a different exception frame. Almost all the global
-registers from kernel-mode (including the stack pointer) may be changed.
+This is the same as the kernel-mode register ABI for functions calls. The
+difference is that in debug-mode there's a different stack and a different
+exception frame. Almost all the global registers from kernel-mode
+(including the stack pointer) may be changed.
 
 	REGISTER	FLAVOUR	USE
-	===============	=======	====================================================
+	===============	=======	==============================================
 	GR1			Debug stack pointer
 	GR16			GP-Rel base register for small data
-	GR31			Current debug exception frame pointer (__debug_frame)
+	GR31			Current debug exception frame pointer 
+				(__debug_frame)
 	SCR3		MMU	Saved value of GR31
 
 
-Note that debug mode is able to interfere with the kernel's emulated atomic ops, so it must be
-exceedingly careful not to do any that would interact with the main kernel in this regard. Hence
-the debug mode code (gdbstub) is almost completely self-contained. The only external code used is
-the sprintf family of functions.
-
-Futhermore, break.S is so complicated because single-step mode does not switch off on entry to an
-exception. That means unless manually disabled, single-stepping will blithely go on stepping into
-things like interrupts. See gdbstub.txt for more information.
+Note that debug mode is able to interfere with the kernel's emulated atomic
+ops, so it must be exceedingly careful not to do any that would interact
+with the main kernel in this regard. Hence the debug mode code (gdbstub) is
+almost completely self-contained. The only external code used is the
+sprintf family of functions.
+
+Futhermore, break.S is so complicated because single-step mode does not
+switch off on entry to an exception. That means unless manually disabled,
+single-stepping will blithely go on stepping into things like interrupts.
+See gdbstub.txt for more information.
 
 
 ==========================
 VIRTUAL INTERRUPT HANDLING
 ==========================
 
-Because accesses to the PSR is so slow, and to disable interrupts we have to access it twice (once
-to read and once to write), we don't actually disable interrupts at all if we don't have to. What
-we do instead is use the ICC2 condition code flags to note virtual disablement, such that if we
-then do take an interrupt, we note the flag, really disable interrupts, set another flag and resume
-execution at the point the interrupt happened. Setting condition flags as a side effect of an
-arithmetic or logical instruction is really fast. This use of the ICC2 only occurs within the
+Because accesses to the PSR is so slow, and to disable interrupts we have
+to access it twice (once to read and once to write), we don't actually
+disable interrupts at all if we don't have to. What we do instead is use
+the ICC2 condition code flags to note virtual disablement, such that if we
+then do take an interrupt, we note the flag, really disable interrupts, set
+another flag and resume execution at the point the interrupt happened.
+Setting condition flags as a side effect of an arithmetic or logical
+instruction is really fast. This use of the ICC2 only occurs within the
 kernel - it does not affect userspace.
 
 The flags we use are:
 
  (*) CCR.ICC2.Z [Zero flag]
 
-     Set to virtually disable interrupts, clear when interrupts are virtually enabled. Can be
-     modified by logical instructions without affecting the Carry flag.
+     Set to virtually disable interrupts, clear when interrupts are
+     virtually enabled. Can be modified by logical instructions without
+     affecting the Carry flag.
 
  (*) CCR.ICC2.C [Carry flag]
 
@@ -176,8 +195,9 @@ What happens is this:
 
 	ICC2.Z is 0, ICC2.C is 1.
 
- (2) An interrupt occurs. The exception prologue examines ICC2.Z and determines that nothing needs
-     doing. This is done simply with an unlikely BEQ instruction.
+ (2) An interrupt occurs. The exception prologue examines ICC2.Z and
+     determines that nothing needs doing. This is done simply with an
+     unlikely BEQ instruction.
 
  (3) The interrupts are disabled (local_irq_disable)
 
@@ -187,48 +207,56 @@ What happens is this:
 
 	ICC2.Z would be set to 0.
 
-     A TIHI #2 instruction (trap #2 if condition HI - Z==0 && C==0) would be used to trap if
-     interrupts were now virtually enabled, but physically disabled - which they're not, so the
-     trap isn't taken. The kernel would then be back to state (1).
-
- (5) An interrupt occurs. The exception prologue examines ICC2.Z and determines that the interrupt
-     shouldn't actually have happened. It jumps aside, and there disabled interrupts by setting
-     PSR.PIL to 14 and then it clears ICC2.C.
+     A TIHI #2 instruction (trap #2 if condition HI - Z==0 && C==0) would
+     be used to trap if interrupts were now virtually enabled, but
+     physically disabled - which they're not, so the trap isn't taken. The
+     kernel would then be back to state (1).
+
+ (5) An interrupt occurs. The exception prologue examines ICC2.Z and
+     determines that the interrupt shouldn't actually have happened. It
+     jumps aside, and there disabled interrupts by setting PSR.PIL to 14
+     and then it clears ICC2.C.
 
  (6) If interrupts were then saved and disabled again (local_irq_save):
 
-	ICC2.Z would be shifted into the save variable and masked off (giving a 1).
+	ICC2.Z would be shifted into the save variable and masked off 
+	(giving a 1).
 
-	ICC2.Z would then be set to 1 (thus unchanged), and ICC2.C would be unaffected (ie: 0).
+	ICC2.Z would then be set to 1 (thus unchanged), and ICC2.C would be
+	unaffected (ie: 0).
 
  (7) If interrupts were then restored from state (6) (local_irq_restore):
 
-	ICC2.Z would be set to indicate the result of XOR'ing the saved value (ie: 1) with 1, which
-	gives a result of 0 - thus leaving ICC2.Z set.
+	ICC2.Z would be set to indicate the result of XOR'ing the saved
+	value (ie: 1) with 1, which gives a result of 0 - thus leaving
+	ICC2.Z set.
 
 	ICC2.C would remain unaffected (ie: 0).
 
-     A TIHI #2 instruction would be used to again assay the current state, but this would do
-     nothing as Z==1.
+     A TIHI #2 instruction would be used to again assay the current state,
+     but this would do nothing as Z==1.
 
  (8) If interrupts were then enabled (local_irq_enable):
 
-	ICC2.Z would be cleared. ICC2.C would be left unaffected. Both flags would now be 0.
+	ICC2.Z would be cleared. ICC2.C would be left unaffected. Both
+	flags would now be 0.
 
-     A TIHI #2 instruction again issued to assay the current state would then trap as both Z==0
-     [interrupts virtually enabled] and C==0 [interrupts really disabled] would then be true.
+     A TIHI #2 instruction again issued to assay the current state would
+     then trap as both Z==0 [interrupts virtually enabled] and C==0
+     [interrupts really disabled] would then be true.
 
- (9) The trap #2 handler would simply enable hardware interrupts (set PSR.PIL to 0), set ICC2.C to
-     1 and return.
+ (9) The trap #2 handler would simply enable hardware interrupts 
+     (set PSR.PIL to 0), set ICC2.C to 1 and return.
 
 (10) Immediately upon returning, the pending interrupt would be taken.
 
-(11) The interrupt handler would take the path of actually processing the interrupt (ICC2.Z is
-     clear, BEQ fails as per step (2)).
+(11) The interrupt handler would take the path of actually processing the
+     interrupt (ICC2.Z is clear, BEQ fails as per step (2)).
 
-(12) The interrupt handler would then set ICC2.C to 1 since hardware interrupts are definitely
-     enabled - or else the kernel wouldn't be here.
+(12) The interrupt handler would then set ICC2.C to 1 since hardware
+     interrupts are definitely enabled - or else the kernel wouldn't be here.
 
 (13) On return from the interrupt handler, things would be back to state (1).
 
-This trap (#2) is only available in kernel mode. In user mode it will result in SIGILL.
+This trap (#2) is only available in kernel mode. In user mode it will
+result in SIGILL.
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index f8cb55c..b3a6187 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1,4 +1,4 @@
-February 2003             Kernel Parameters                     v2.5.59
+                          Kernel Parameters
                           ~~~~~~~~~~~~~~~~~
 
 The following is a consolidated list of the kernel parameters as implemented
@@ -17,9 +17,17 @@ are specified on the kernel command line
 
 	usbcore.blinkenlights=1
 
-The text in square brackets at the beginning of the description states the
-restrictions on the kernel for the said kernel parameter to be valid. The
-restrictions referred to are that the relevant option is valid if:
+This document may not be entirely up to date and comprehensive. The command
+"modinfo -p ${modulename}" shows a current list of all parameters of a loadable
+module. Loadable modules, after being loaded into the running kernel, also
+reveal their parameters in /sys/module/${modulename}/parameters/. Some of these
+parameters may be changed at runtime by the command
+"echo -n ${value} > /sys/module/${modulename}/parameters/${parm}".
+
+The parameters listed below are only valid if certain kernel build options were
+enabled and if respective hardware is present. The text in square brackets at
+the beginning of each description states the restrictions within which a
+parameter is applicable:
 
 	ACPI	ACPI support is enabled.
 	ALSA	ALSA sound support is enabled.
@@ -1046,10 +1054,10 @@ running once the system is up.
 	noltlbs		[PPC] Do not use large page/tlb entries for kernel
 			lowmem mapping on PPC40x.
 
-	nomce		[IA-32] Machine Check Exception
-
 	nomca		[IA-64] Disable machine check abort handling
 
+	nomce		[IA-32] Machine Check Exception
+
 	noresidual	[PPC] Don't use residual data on PReP machines.
 
 	noresume	[SWSUSP] Disables resume and restores original swap
@@ -1682,20 +1690,6 @@ running once the system is up.
 
 
 ______________________________________________________________________
-Changelog:
-
-2000-06-??	Mr. Unknown
-	The last known update (for 2.4.0) - the changelog was not kept before.
-
-2002-11-24	Petr Baudis <pasky@ucw.cz>
-		Randy Dunlap <randy.dunlap@verizon.net>
-	Update for 2.5.49, description for most of the options introduced,
-	references to other documentation (C files, READMEs, ..), added S390,
-	PPC, SPARC, MTD, ALSA and OSS category. Minor corrections and
-	reformatting.
-
-2005-10-19	Randy Dunlap <rdunlap@xenotime.net>
-	Lots of typos, whitespace, some reformatting.
 
 TODO:
 
diff --git a/Documentation/networking/packet_mmap.txt b/Documentation/networking/packet_mmap.txt
index 4fc8e98..aaf99d5 100644
--- a/Documentation/networking/packet_mmap.txt
+++ b/Documentation/networking/packet_mmap.txt
@@ -254,7 +254,7 @@ and, the number of frames be
 
 	<block number> * <block size> / <frame size>
 
-Suposse the following parameters, which apply for 2.6 kernel and an
+Suppose the following parameters, which apply for 2.6 kernel and an
 i386 architecture:
 
 	<size-max> = 131072 bytes
diff --git a/Documentation/networking/tuntap.txt b/Documentation/networking/tuntap.txt
index ec3d109..76750fb 100644
--- a/Documentation/networking/tuntap.txt
+++ b/Documentation/networking/tuntap.txt
@@ -138,7 +138,7 @@ This means that you have to read/write I
 ethernet frames when using tap.
 
 5. What is the difference between BPF and TUN/TAP driver?
-BFP is an advanced packet filter. It can be attached to existing
+BPF is an advanced packet filter. It can be attached to existing
 network interface. It does not provide a virtual network interface.
 A TUN/TAP driver does provide a virtual network interface and it is possible
 to attach BPF to this interface.
diff --git a/arch/i386/kernel/crash.c b/arch/i386/kernel/crash.c
index e3c5fca..2b0cfce 100644
--- a/arch/i386/kernel/crash.c
+++ b/arch/i386/kernel/crash.c
@@ -69,7 +69,7 @@ static void crash_save_this_cpu(struct p
 	 * for the data I pass, and I need tags
 	 * on the data to indicate what information I have
 	 * squirrelled away.  ELF notes happen to provide
-	 * all of that that no need to invent something new.
+	 * all of that, so there is no need to invent something new.
 	 */
 	buf = (u32*)per_cpu_ptr(crash_notes, cpu);
 	if (!buf)
diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c
index aecd9e0..64fd8e7 100644
--- a/drivers/md/dm-target.c
+++ b/drivers/md/dm-target.c
@@ -78,8 +78,7 @@ void dm_put_target_type(struct target_ty
 	if (--ti->use == 0)
 		module_put(ti->tt.module);
 
-	if (ti->use < 0)
-		BUG();
+	BUG_ON(ti->use < 0);
 	up_read(&_lock);
 
 	return;
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 9b374c9..6081941 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1558,8 +1558,7 @@ static int init_resync(conf_t *conf)
 	int buffs;
 
 	buffs = RESYNC_WINDOW / RESYNC_BLOCK_SIZE;
-	if (conf->r1buf_pool)
-		BUG();
+	BUG_ON(conf->r1buf_pool);
 	conf->r1buf_pool = mempool_create(buffs, r1buf_pool_alloc, r1buf_pool_free,
 					  conf->poolinfo);
 	if (!conf->r1buf_pool)
@@ -1732,8 +1731,7 @@ static sector_t sync_request(mddev_t *md
 			    !conf->fullsync &&
 			    !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery))
 				break;
-			if (sync_blocks < (PAGE_SIZE>>9))
-				BUG();
+			BUG_ON(sync_blocks < (PAGE_SIZE>>9));
 			if (len > (sync_blocks<<9))
 				len = sync_blocks<<9;
 		}
diff --git a/drivers/mtd/chips/Kconfig b/drivers/mtd/chips/Kconfig
index 0f6bb2e..a7ec595 100644
--- a/drivers/mtd/chips/Kconfig
+++ b/drivers/mtd/chips/Kconfig
@@ -200,27 +200,6 @@ config MTD_CFI_AMDSTD
 	  provides support for one of those command sets, used on chips
 	  including the AMD Am29LV320.
 
-config MTD_CFI_AMDSTD_RETRY
-	int "Retry failed commands (erase/program)"
-	depends on MTD_CFI_AMDSTD
-	default "0"
-	help
-	  Some chips, when attached to a shared bus, don't properly filter
-	  bus traffic that is destined to other devices.  This broken
-	  behavior causes erase and program sequences to be aborted when
-	  the sequences are mixed with traffic for other devices.
-
-	  SST49LF040 (and related) chips are know to be broken.
-
-config MTD_CFI_AMDSTD_RETRY_MAX
-	int "Max retries of failed commands (erase/program)"
-	depends on MTD_CFI_AMDSTD_RETRY
-	default "0"
-	help
-	  If you have an SST49LF040 (or related chip) then this value should
-	  be set to at least 1.  This can also be adjusted at driver load
-	  time with the retry_cmd_max module parameter.
-
 config MTD_CFI_STAA
 	tristate "Support for ST (Advanced Architecture) flash chips"
 	depends on MTD_GEN_PROBE
diff --git a/drivers/s390/block/dasd_erp.c b/drivers/s390/block/dasd_erp.c
index 8fd71ab..b842377 100644
--- a/drivers/s390/block/dasd_erp.c
+++ b/drivers/s390/block/dasd_erp.c
@@ -32,9 +32,8 @@ dasd_alloc_erp_request(char *magic, int 
 	int size;
 
 	/* Sanity checks */
-	if ( magic == NULL || datasize > PAGE_SIZE ||
-	     (cplength*sizeof(struct ccw1)) > PAGE_SIZE)
-		BUG();
+	BUG_ON( magic == NULL || datasize > PAGE_SIZE ||
+	     (cplength*sizeof(struct ccw1)) > PAGE_SIZE);
 
 	size = (sizeof(struct dasd_ccw_req) + 7L) & -8L;
 	if (cplength > 0)
@@ -125,8 +124,7 @@ dasd_default_erp_postaction(struct dasd_
 	struct dasd_device *device;
 	int success;
 
-	if (cqr->refers == NULL || cqr->function == NULL)
-		BUG();
+	BUG_ON(cqr->refers == NULL || cqr->function == NULL);
 
 	device = cqr->device;
 	success = cqr->status == DASD_CQR_DONE;
diff --git a/drivers/s390/char/sclp_rw.c b/drivers/s390/char/sclp_rw.c
index ac10dfb..91e93c7 100644
--- a/drivers/s390/char/sclp_rw.c
+++ b/drivers/s390/char/sclp_rw.c
@@ -24,7 +24,7 @@
 
 /*
  * The room for the SCCB (only for writing) is not equal to a pages size
- * (as it is specified as the maximum size in the the SCLP ducumentation)
+ * (as it is specified as the maximum size in the the SCLP documentation)
  * because of the additional data structure described above.
  */
 #define MAX_SCCB_ROOM (PAGE_SIZE - sizeof(struct sclp_buffer))
diff --git a/drivers/s390/char/tape_block.c b/drivers/s390/char/tape_block.c
index 5ced272..5c65cf3 100644
--- a/drivers/s390/char/tape_block.c
+++ b/drivers/s390/char/tape_block.c
@@ -198,9 +198,7 @@ tapeblock_request_fn(request_queue_t *qu
 
 	device = (struct tape_device *) queue->queuedata;
 	DBF_LH(6, "tapeblock_request_fn(device=%p)\n", device);
-	if (device == NULL)
-		BUG();
-
+	BUG_ON(device == NULL);
 	tapeblock_trigger_requeue(device);
 }
 
@@ -307,8 +305,7 @@ tapeblock_revalidate_disk(struct gendisk
 	int			rc;
 
 	device = (struct tape_device *) disk->private_data;
-	if (!device)
-		BUG();
+	BUG_ON(!device);
 
 	if (!device->blk_data.medium_changed)
 		return 0;
@@ -440,11 +437,9 @@ tapeblock_ioctl(
 
 	rc     = 0;
 	disk   = inode->i_bdev->bd_disk;
-	if (!disk)
-		BUG();
+	BUG_ON(!disk);
 	device = disk->private_data;
-	if (!device)
-		BUG();
+	BUG_ON(!device);
 	minor  = iminor(inode);
 
 	DBF_LH(6, "tapeblock_ioctl(0x%0x)\n", command);
diff --git a/drivers/scsi/aic7xxx/Kconfig.aic7xxx b/drivers/scsi/aic7xxx/Kconfig.aic7xxx
index 6c2c395..5517da5 100644
--- a/drivers/scsi/aic7xxx/Kconfig.aic7xxx
+++ b/drivers/scsi/aic7xxx/Kconfig.aic7xxx
@@ -86,7 +86,7 @@ config AIC7XXX_DEBUG_MASK
         default "0"
         help
 	Bit mask of debug options that is only valid if the
-	CONFIG_AIC7XXX_DEBUG_ENBLE option is enabled.  The bits in this mask
+	CONFIG_AIC7XXX_DEBUG_ENABLE option is enabled.  The bits in this mask
 	are defined in the drivers/scsi/aic7xxx/aic7xxx.h - search for the
 	variable ahc_debug in that file to find them.
 
diff --git a/drivers/serial/jsm/jsm.h b/drivers/serial/jsm/jsm.h
index dfc1e86..043f50b 100644
--- a/drivers/serial/jsm/jsm.h
+++ b/drivers/serial/jsm/jsm.h
@@ -20,7 +20,7 @@
  *
  * Contact Information:
  * Scott H Kilau <Scott_Kilau@digi.com>
- * Wendy Xiong   <wendyx@us.ltcfwd.linux.ibm.com>
+ * Wendy Xiong   <wendyx@us.ibm.com>
  *
  ***********************************************************************/
 
diff --git a/drivers/serial/jsm/jsm_driver.c b/drivers/serial/jsm/jsm_driver.c
index b1b66e7..b3e1f71 100644
--- a/drivers/serial/jsm/jsm_driver.c
+++ b/drivers/serial/jsm/jsm_driver.c
@@ -20,7 +20,7 @@
  *
  * Contact Information:
  * Scott H Kilau <Scott_Kilau@digi.com>
- * Wendy Xiong   <wendyx@us.ltcfwd.linux.ibm.com>
+ * Wendy Xiong   <wendyx@us.ibm.com>
  *
  *
  ***********************************************************************/
diff --git a/drivers/serial/jsm/jsm_neo.c b/drivers/serial/jsm/jsm_neo.c
index 87e4e2c..a5fc589 100644
--- a/drivers/serial/jsm/jsm_neo.c
+++ b/drivers/serial/jsm/jsm_neo.c
@@ -20,7 +20,7 @@
  *
  * Contact Information:
  * Scott H Kilau <Scott_Kilau@digi.com>
- * Wendy Xiong   <wendyx@us.ltcfwd.linux.ibm.com>
+ * Wendy Xiong   <wendyx@us.ibm.com>
  *
  ***********************************************************************/
 #include <linux/delay.h>	/* For udelay */
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 910a8ed..b05d1b2 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -929,8 +929,7 @@ do_holes:
 			block_in_page += this_chunk_blocks;
 			dio->blocks_available -= this_chunk_blocks;
 next_block:
-			if (dio->block_in_file > dio->final_block_in_request)
-				BUG();
+			BUG_ON(dio->block_in_file > dio->final_block_in_request);
 			if (dio->block_in_file == dio->final_block_in_request)
 				break;
 		}
diff --git a/fs/exec.c b/fs/exec.c
index 950ebd4..0291a68 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -561,7 +561,7 @@ static int exec_mmap(struct mm_struct *m
 	arch_pick_mmap_layout(mm);
 	if (old_mm) {
 		up_read(&old_mm->mmap_sem);
-		if (active_mm != old_mm) BUG();
+		BUG_ON(active_mm != old_mm);
 		mmput(old_mm);
 		return 0;
 	}
diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c
index 8f07e8f..746abc9 100644
--- a/fs/hfsplus/bnode.c
+++ b/fs/hfsplus/bnode.c
@@ -466,8 +466,7 @@ void hfs_bnode_unhash(struct hfs_bnode *
 	for (p = &node->tree->node_hash[hfs_bnode_hash(node->this)];
 	     *p && *p != node; p = &(*p)->next_hash)
 		;
-	if (!*p)
-		BUG();
+	BUG_ON(!*p);
 	*p = node->next_hash;
 	node->tree->node_hash_cnt--;
 }
@@ -622,8 +621,7 @@ void hfs_bnode_put(struct hfs_bnode *nod
 
 		dprint(DBG_BNODE_REFS, "put_node(%d:%d): %d\n",
 		       node->tree->cnid, node->this, atomic_read(&node->refcnt));
-		if (!atomic_read(&node->refcnt))
-			BUG();
+		BUG_ON(!atomic_read(&node->refcnt));
 		if (!atomic_dec_and_lock(&node->refcnt, &tree->hash_lock))
 			return;
 		for (i = 0; i < tree->pages_per_bnode; i++) {
diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c
index a67edfa..effa899 100644
--- a/fs/hfsplus/btree.c
+++ b/fs/hfsplus/btree.c
@@ -269,8 +269,7 @@ void hfs_bmap_free(struct hfs_bnode *nod
 	u8 *data, byte, m;
 
 	dprint(DBG_BNODE_MOD, "btree_free_node: %u\n", node->this);
-	if (!node->this)
-		BUG();
+	BUG_ON(!node->this);
 	tree = node->tree;
 	nidx = node->this;
 	node = hfs_bnode_find(tree, 0);
diff --git a/fs/jffs2/background.c b/fs/jffs2/background.c
index 7b77a95..ff2a872 100644
--- a/fs/jffs2/background.c
+++ b/fs/jffs2/background.c
@@ -35,8 +35,7 @@ int jffs2_start_garbage_collect_thread(s
 	pid_t pid;
 	int ret = 0;
 
-	if (c->gc_task)
-		BUG();
+	BUG_ON(c->gc_task);
 
 	init_completion(&c->gc_thread_start);
 	init_completion(&c->gc_thread_exit);
diff --git a/fs/smbfs/file.c b/fs/smbfs/file.c
index c56bd99..ed9a24d 100644
--- a/fs/smbfs/file.c
+++ b/fs/smbfs/file.c
@@ -178,11 +178,9 @@ smb_writepage(struct page *page, struct 
 	unsigned offset = PAGE_CACHE_SIZE;
 	int err;
 
-	if (!mapping)
-		BUG();
+	BUG_ON(!mapping);
 	inode = mapping->host;
-	if (!inode)
-		BUG();
+	BUG_ON(!inode);
 
 	end_index = inode->i_size >> PAGE_CACHE_SHIFT;
 
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index 4c29ac4..f0b347b 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -175,8 +175,7 @@ const unsigned char * sysfs_get_name(str
 	struct bin_attribute * bin_attr;
 	struct sysfs_symlink  * sl;
 
-	if (!sd || !sd->s_element)
-		BUG();
+	BUG_ON(!sd || !sd->s_element);
 
 	switch (sd->s_type) {
 		case SYSFS_DIR:
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 4ed7e60..1e9ebab 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -864,7 +864,7 @@ struct super_block {
 	 */
 	struct mutex s_vfs_rename_mutex;	/* Kludge */
 
-	/* Granuality of c/m/atime in ns.
+	/* Granularity of c/m/atime in ns.
 	   Cannot be worse than a second */
 	u32		   s_time_gran;
 };
diff --git a/ipc/util.c b/ipc/util.c
index 23151ef..5e785a2 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -266,8 +266,7 @@ struct kern_ipc_perm* ipc_rmid(struct ip
 {
 	struct kern_ipc_perm* p;
 	int lid = id % SEQ_MULTIPLIER;
-	if(lid >= ids->entries->size)
-		BUG();
+	BUG_ON(lid >= ids->entries->size);
 
 	/* 
 	 * do not need a rcu_dereference()() here to force ordering
@@ -275,8 +274,7 @@ struct kern_ipc_perm* ipc_rmid(struct ip
 	 */	
 	p = ids->entries->p[lid];
 	ids->entries->p[lid] = NULL;
-	if(p==NULL)
-		BUG();
+	BUG_ON(p==NULL);
 	ids->in_use--;
 
 	if (lid == ids->max_id) {
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index 9fd8d4f..ce0dfb8 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -41,7 +41,7 @@ config SOFTWARE_SUSPEND
 	depends on PM && SWAP && (X86 && (!SMP || SUSPEND_SMP)) || ((FRV || PPC32) && !SMP)
 	---help---
 	  Enable the possibility of suspending the machine.
-	  It doesn't need APM.
+	  It doesn't need ACPI or APM.
 	  You may suspend your machine by 'swsusp' or 'shutdown -z <time>' 
 	  (patch for sysvinit needed). 
 
diff --git a/kernel/printk.c b/kernel/printk.c
index 8cc1943..c056f33 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -360,8 +360,7 @@ static void call_console_drivers(unsigne
 	unsigned long cur_index, start_print;
 	static int msg_level = -1;
 
-	if (((long)(start - end)) > 0)
-		BUG();
+	BUG_ON(((long)(start - end)) > 0);
 
 	cur_index = start;
 	start_print = start;
@@ -708,8 +707,7 @@ int __init add_preferred_console(char *n
  */
 void acquire_console_sem(void)
 {
-	if (in_interrupt())
-		BUG();
+	BUG_ON(in_interrupt());
 	down(&console_sem);
 	console_locked = 1;
 	console_may_schedule = 1;
diff --git a/kernel/time.c b/kernel/time.c
index ff8e701..b00ddc7 100644
--- a/kernel/time.c
+++ b/kernel/time.c
@@ -410,7 +410,7 @@ EXPORT_SYMBOL(current_kernel_time);
  * current_fs_time - Return FS time
  * @sb: Superblock.
  *
- * Return the current time truncated to the time granuality supported by
+ * Return the current time truncated to the time granularity supported by
  * the fs.
  */
 struct timespec current_fs_time(struct super_block *sb)
@@ -421,11 +421,11 @@ struct timespec current_fs_time(struct s
 EXPORT_SYMBOL(current_fs_time);
 
 /**
- * timespec_trunc - Truncate timespec to a granuality
+ * timespec_trunc - Truncate timespec to a granularity
  * @t: Timespec
- * @gran: Granuality in ns.
+ * @gran: Granularity in ns.
  *
- * Truncate a timespec to a granuality. gran must be smaller than a second.
+ * Truncate a timespec to a granularity. gran must be smaller than a second.
  * Always rounds down.
  *
  * This function should be only used for timestamps returned by
diff --git a/mm/mmap.c b/mm/mmap.c
index 4f5b570..e780d19 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -294,8 +294,7 @@ void validate_mm(struct mm_struct *mm)
 	i = browse_rb(&mm->mm_rb);
 	if (i != mm->map_count)
 		printk("map_count %d rb %d\n", mm->map_count, i), bug = 1;
-	if (bug)
-		BUG();
+	BUG_ON(bug);
 }
 #else
 #define validate_mm(mm) do { } while (0)
@@ -432,8 +431,7 @@ __insert_vm_struct(struct mm_struct * mm
 	struct rb_node ** rb_link, * rb_parent;
 
 	__vma = find_vma_prepare(mm, vma->vm_start,&prev, &rb_link, &rb_parent);
-	if (__vma && __vma->vm_start < vma->vm_end)
-		BUG();
+	BUG_ON(__vma && __vma->vm_start < vma->vm_end);
 	__vma_link(mm, vma, prev, rb_link, rb_parent);
 	mm->map_count++;
 }
@@ -813,8 +811,7 @@ try_prev:
 	 * (e.g. stash info in next's anon_vma_node when assigning
 	 * an anon_vma, or when trying vma_merge).  Another time.
 	 */
-	if (find_vma_prev(vma->vm_mm, vma->vm_start, &near) != vma)
-		BUG();
+	BUG_ON(find_vma_prev(vma->vm_mm, vma->vm_start, &near) != vma);
 	if (!near)
 		goto none;
 
diff --git a/mm/swap_state.c b/mm/swap_state.c
index d7af296..e0e1583 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -148,8 +148,7 @@ int add_to_swap(struct page * page, gfp_
 	swp_entry_t entry;
 	int err;
 
-	if (!PageLocked(page))
-		BUG();
+	BUG_ON(!PageLocked(page));
 
 	for (;;) {
 		entry = get_swap_page();
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 729eb3e..c0504f1 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -321,8 +321,7 @@ void __vunmap(void *addr, int deallocate
 		int i;
 
 		for (i = 0; i < area->nr_pages; i++) {
-			if (unlikely(!area->pages[i]))
-				BUG();
+			BUG_ON(!area->pages[i]);
 			__free_page(area->pages[i]);
 		}
 


^ permalink raw reply related

* [-mm patch] fix a superfluous kmem_set_shrinker() prototype
From: Adrian Bunk @ 2006-04-01 10:42 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Bharata B Rao, Yoichi Yuasa

This patch fixes a bug I introduced in 
slab-cache-shrinker-statistics.patch.

Signed-off-by: Adrian Bunk <bunk@stusta.de>

--- linux-2.6.16-mm2-full/include/linux/slab.h.old	2006-03-31 15:56:09.000000000 +0200
+++ linux-2.6.16-mm2-full/include/linux/slab.h	2006-03-31 15:56:24.000000000 +0200
@@ -222,9 +222,6 @@
 
 extern atomic_t slab_reclaim_pages;
 
-struct shrinker;
-extern void kmem_set_shrinker(kmem_cache_t *cachep, struct shrinker *shrinker);
-
 #endif	/* __KERNEL__ */
 
 #endif	/* _LINUX_SLAB_H */


^ permalink raw reply

* [PATCH] SCSI: implement scsi_eh_schedule()
From: Tejun Heo @ 2006-04-01 10:38 UTC (permalink / raw)
  To: hch, James.Bottomley, Jeff Garzik, alan, albertcc, linux-ide,
	linux-scsi

[PATCH] SCSI: implement scsi_eh_schedule()

This patch implements scsi_eh_schedule() which provides a way to
directly invoke SCSI EH from drivers which implement EH using
->eh_strategy_handler.  Combined with scsi_eh_flush_done_q(), this
gives such drivers complete control over when and how to invoke EH and
handle failed commands.

scsi_eh_schedule() can also be invoked without a scmd.  This is useful
for handling exception conditions occurring while no command is in
progress.  New Scsi_Host field host_eh_invoked is added for this.

Signed-off-by: Tejun Heo <htejun@gmail.com>

---

Hello, all.

This patch is in preparation for new libata EH implementation.  As
described above, this is to allow LLDD's direct access to SCSI EH
rather than invoking it indirectly with CHECK SENSE without sense data
hack.

This patch applies cleanly to both scsi-misc-2.6 and libata-dev.  If
this gets ACKed, it would be better to merge via libata-dev as this
change is necessary for new libata EH.

Thanks.

 drivers/scsi/scsi_error.c |   40 +++++++++++++++++++++++++++++++++++++++-
 include/scsi/scsi_eh.h    |    1 +
 include/scsi/scsi_host.h  |    1 +
 3 files changed, 41 insertions(+), 1 deletion(-)

Index: work/drivers/scsi/scsi_error.c
===================================================================
--- work.orig/drivers/scsi/scsi_error.c	2006-04-01 16:42:51.000000000 +0900
+++ work/drivers/scsi/scsi_error.c	2006-04-01 16:42:58.000000000 +0900
@@ -90,6 +90,44 @@ int scsi_eh_scmd_add(struct scsi_cmnd *s
 }
 
 /**
+ * scsi_eh_schedule - schedule error handling.
+ * @shost:	SCSI host to invoke error handling on.
+ * @scmd:	scmd to run eh on (can be NULL)
+ *
+ * Return value:
+ *	0 on failure.
+ **/
+int scsi_eh_schedule(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
+{
+	unsigned long flags;
+	int ret = 0;
+
+	WARN_ON(!shost->hostt->eh_strategy_handler);
+
+	if (!shost->ehandler)
+		return 0;
+
+	if (scmd && !scsi_delete_timer(scmd))
+		return 0;	/* timeout won */
+
+	spin_lock_irqsave(shost->host_lock, flags);
+	if (scsi_host_set_state(shost, SHOST_RECOVERY))
+		if (scsi_host_set_state(shost, SHOST_CANCEL_RECOVERY))
+			goto out_unlock;
+	ret = 1;
+	if (scmd) {
+		list_add_tail(&scmd->eh_entry, &shost->eh_cmd_q);
+		shost->host_failed++;
+	} else
+		shost->host_eh_invoked++;
+	scsi_eh_wakeup(shost);
+ out_unlock:
+	spin_unlock_irqrestore(shost->host_lock, flags);
+	return ret;
+}
+EXPORT_SYMBOL(scsi_eh_schedule);
+
+/**
  * scsi_add_timer - Start timeout timer for a single scsi command.
  * @scmd:	scsi command that is about to start running.
  * @timeout:	amount of time to allow this command to run.
@@ -1517,7 +1555,7 @@ int scsi_error_handler(void *data)
 	 */
 	set_current_state(TASK_INTERRUPTIBLE);
 	while (!kthread_should_stop()) {
-		if (shost->host_failed == 0 ||
+		if ((shost->host_failed == 0 && shost->host_eh_invoked == 0) ||
 		    shost->host_failed != shost->host_busy) {
 			SCSI_LOG_ERROR_RECOVERY(1,
 				printk("Error handler scsi_eh_%d sleeping\n",
Index: work/include/scsi/scsi_eh.h
===================================================================
--- work.orig/include/scsi/scsi_eh.h	2006-04-01 16:42:51.000000000 +0900
+++ work/include/scsi/scsi_eh.h	2006-04-01 16:42:58.000000000 +0900
@@ -35,6 +35,7 @@ static inline int scsi_sense_valid(struc
 }
 
 
+extern int scsi_eh_schedule(struct Scsi_Host *shost, struct scsi_cmnd *scmd);
 extern void scsi_eh_finish_cmd(struct scsi_cmnd *scmd,
 			       struct list_head *done_q);
 extern void scsi_eh_flush_done_q(struct list_head *done_q);
Index: work/include/scsi/scsi_host.h
===================================================================
--- work.orig/include/scsi/scsi_host.h	2006-04-01 16:42:51.000000000 +0900
+++ work/include/scsi/scsi_host.h	2006-04-01 16:42:58.000000000 +0900
@@ -473,6 +473,7 @@ struct Scsi_Host {
 	 */
 	unsigned int host_busy;		   /* commands actually active on low-level */
 	unsigned int host_failed;	   /* commands that failed. */
+	unsigned int host_eh_invoked;	   /* EH invocations without command */
     
 	unsigned short host_no;  /* Used for IOCTL_GET_IDLUN, /proc/scsi et al. */
 	int resetting; /* if set, it means that last_reset is a valid value */

^ permalink raw reply

* Re: Regarding LIBIPQ problem
From: David Vogt @ 2006-04-01 10:36 UTC (permalink / raw)
  To: Vasantha Kumar Puttappa; +Cc: netfilter-devel
In-Reply-To: <1411.10.12.25.5.1143825446.squirrel@gpo.iitb.ac.in>

2006/3/31, Vasantha Kumar Puttappa <vasanthakumar@iitb.ac.in>:
> Then I am setting the verdict as accept ,shown below
>
> status = ipq_set_verdict(h, m->packet_id,NF_ACCEPT, new_iphdr->tot_len,
> (unsigned char *)packet);
Shouldn't this look like this (ntohs missing?):

status =
  ipq_set_verdict(
    h, m->packet_id,NF_ACCEPT, ntohs(new_iphdr->tot_len), (unsigned
char *)packet
  );


> Problem:
>   Even though ipq_set_verdict is being executed successfully, the new
> packets are being dropped silently without any error message.
If the value is not interpreted correctly, the length value might be
negative or too large and thus the packet gets dropped.

Was the first thing that came to my mind. Tought I give it a shot.

Regards,
David

^ permalink raw reply

* RE: [PATCH] This patch fixes several issues related to vmxassist
From: Li, Xin B @ 2006-04-01 10:35 UTC (permalink / raw)
  To: Keir Fraser; +Cc: Xen Devel

[-- Attachment #1: Type: text/plain, Size: 3007 bytes --]

>>> I don't know the heritage of that code. I expect someone
>>> decided it was
>>> good enough to be getting on with but maybe now it is time 
>to revisit
>>> and see if we can implement a watertight version which 
>correctly uses
>>> hidden segment descriptor state which is readily available
>>> when running
>>> on VMX.
>>
>> My patch just enhanced the current implementation, and actually it
>> breaks windows, but I have a updated version in hand, and tests show
>> that all the combinations is OK till now.
>>
>> In my mind, the correct way is to identify whether a cpu is 
>in big real
>> mode, but seems this is a little bit hard to do.
>
>Well, it's impossible to know for certain without looking at hidden 
>descriptor state isn't it. Big real mode is only possible because the 
>hidden state can be out of sync with the current execution mode.
>
>If that state can be made available to the address() function 
>then it's 
>implementation, and confidence in its correctness, becomes trivial. Do 
>we have that state available directly in the guest at that point? Or 
>would we need to grab the state from Xen?
>

Keir, do you think this one seems better?
When in real mode, we should always calculate address as ((seg & 0xFFFF)
<< 4) + off, big real mode obey the same rule.
When in real mode to protected mode transition, only the IP address
calculation should use real mode addressing.
-Xin

@@ -50,23 +50,42 @@ static char *rnames[] = { "ax", "cx", "d
 static char *rnames[] = { "ax", "cx", "dx", "bx", "sp", "bp", "si",
"di" };
 #endif /* DEBUG */
 
-unsigned
+static unsigned
 address(struct regs *regs, unsigned seg, unsigned off)
 {
 	unsigned long long entry;
-	unsigned addr;
+	unsigned seg_base, seg_limit;
+	unsigned entry_low, entry_high;
 
 	if (seg == 0)
-		return off;
-
-	if (seg > oldctx.gdtr_limit)
+	{
+		if (mode == VM86_REAL || mode == VM86_REAL_TO_PROTECTED)
+			return off;
+		else
+			panic("segment is zero, but not in real
mode!\n");
+	}
+
+	if (mode == VM86_REAL || seg > oldctx.gdtr_limit ||
+	    (mode == VM86_REAL_TO_PROTECTED && regs->cs == seg))
 		return ((seg & 0xFFFF) << 4) + off;
 
 	entry = ((unsigned long long *) oldctx.gdtr_base)[seg >> 3];
-	addr = (((entry >> (56-24)) & 0xFF000000) |
-		((entry >> (32-16)) & 0x00FF0000) |
-		((entry >> (   16)) & 0x0000FFFF)) + off;
-	return addr;
+	entry_high = entry >> 32;
+	entry_low = entry & 0xFFFFFFFF;
+
+	seg_base  = (entry_high & 0xFF000000) | ((entry >> 16) &
0xFFFFFF);
+	seg_limit = (entry_high & 0xF0000) | (entry_low & 0xFFFF);
+
+	if (entry_high & 0x8000 &&
+	    ((entry_high & 0x800000 && off >> 12 <= seg_limit) ||
+	    (!(entry_high & 0x800000) && off <= seg_limit)))
+		return seg_base + off;
+
+	panic("should never reach here in function address():\n\t"
+	      "entry=0x%08x%08x, mode=%d, seg=0x%08x, offset=0x%08x\n",
+	      entry_high, entry_low, mode, seg, off);
+
+	return 0;
 }
 
 #ifdef DEBUG

[-- Attachment #2: fix_vmxassist..1.patch --]
[-- Type: application/octet-stream, Size: 9818 bytes --]

diff -r d76a7a40f3a9 tools/firmware/vmxassist/Makefile
--- a/tools/firmware/vmxassist/Makefile	Fri Mar 31 17:44:26 2006 +0100
+++ b/tools/firmware/vmxassist/Makefile	Sat Apr  1 17:41:29 2006 +0800
@@ -53,25 +53,25 @@ vmxassist.bin: vmxassist.ld $(OBJECTS)
 	dd if=vmxassist.tmp of=vmxassist.bin ibs=512 conv=sync
 	rm -f vmxassist.tmp
 
-head.o: machine.h head.S
+head.o: machine.h vm86.h head.S
 	$(CC) $(CFLAGS) -D__ASSEMBLY__ $(DEFINES) -c head.S
 
-trap.o: machine.h offsets.h trap.S
+trap.o: machine.h vm86.h offsets.h trap.S
 	$(CC) $(CFLAGS) -D__ASSEMBLY__ $(DEFINES) -c trap.S
 
-vm86.o: machine.h vm86.c
+vm86.o: machine.h vm86.h vm86.c
 	$(CC) $(CFLAGS) -c vm86.c
 
-setup.o: machine.h setup.c
+setup.o: machine.h vm86.h setup.c
 	$(CC) $(CFLAGS) -c setup.c
 
-util.o: machine.h util.c
+util.o: machine.h vm86.h util.c
 	$(CC) $(CFLAGS) -c util.c
 
 offsets.h: gen
 	./gen > offsets.h
 
-gen:	gen.c
+gen:	vm86.h gen.c
 	$(HOSTCC) $(HOSTCFLAGS) -I. $(XENINC) -o gen gen.c
 
 clean:
diff -r d76a7a40f3a9 tools/firmware/vmxassist/trap.S
--- a/tools/firmware/vmxassist/trap.S	Fri Mar 31 17:44:26 2006 +0100
+++ b/tools/firmware/vmxassist/trap.S	Sat Apr  1 17:41:29 2006 +0800
@@ -18,6 +18,7 @@
  * Place - Suite 330, Boston, MA 02111-1307 USA.
  */
 #include "machine.h"
+#include "vm86.h"
 #include "offsets.h"
 
 /*
diff -r d76a7a40f3a9 tools/firmware/vmxassist/util.c
--- a/tools/firmware/vmxassist/util.c	Fri Mar 31 17:44:26 2006 +0100
+++ b/tools/firmware/vmxassist/util.c	Sat Apr  1 17:41:29 2006 +0800
@@ -18,7 +18,6 @@
  * Place - Suite 330, Boston, MA 02111-1307 USA.
  */
 #include <stdarg.h>
-#include <vm86.h>
 
 #include "util.h"
 #include "machine.h"
diff -r d76a7a40f3a9 tools/firmware/vmxassist/vm86.c
--- a/tools/firmware/vmxassist/vm86.c	Fri Mar 31 17:44:26 2006 +0100
+++ b/tools/firmware/vmxassist/vm86.c	Sat Apr  1 17:41:29 2006 +0800
@@ -34,7 +34,7 @@
 #define	SEG_FS		0x0040
 #define	SEG_GS		0x0080
 
-unsigned prev_eip = 0;
+static unsigned prev_eip = 0;
 enum vm86_mode mode = 0;
 
 #ifdef DEBUG
@@ -50,23 +50,42 @@ static char *rnames[] = { "ax", "cx", "d
 static char *rnames[] = { "ax", "cx", "dx", "bx", "sp", "bp", "si", "di" };
 #endif /* DEBUG */
 
-unsigned
+static unsigned
 address(struct regs *regs, unsigned seg, unsigned off)
 {
 	unsigned long long entry;
-	unsigned addr;
+	unsigned seg_base, seg_limit;
+	unsigned entry_low, entry_high;
 
 	if (seg == 0)
-		return off;
-
-	if (seg > oldctx.gdtr_limit)
+	{
+		if (mode == VM86_REAL || mode == VM86_REAL_TO_PROTECTED)
+			return off;
+		else
+			panic("segment is zero, but not in real mode!\n");
+	}
+
+	if (mode == VM86_REAL || seg > oldctx.gdtr_limit ||
+	    (mode == VM86_REAL_TO_PROTECTED && regs->cs == seg))
 		return ((seg & 0xFFFF) << 4) + off;
 
 	entry = ((unsigned long long *) oldctx.gdtr_base)[seg >> 3];
-	addr = (((entry >> (56-24)) & 0xFF000000) |
-		((entry >> (32-16)) & 0x00FF0000) |
-		((entry >> (   16)) & 0x0000FFFF)) + off;
-	return addr;
+	entry_high = entry >> 32;
+	entry_low = entry & 0xFFFFFFFF;
+
+	seg_base  = (entry_high & 0xFF000000) | ((entry >> 16) & 0xFFFFFF);
+	seg_limit = (entry_high & 0xF0000) | (entry_low & 0xFFFF);
+
+	if (entry_high & 0x8000 &&
+	    ((entry_high & 0x800000 && off >> 12 <= seg_limit) ||
+	    (!(entry_high & 0x800000) && off <= seg_limit)))
+		return seg_base + off;
+
+	panic("should never reach here in function address():\n\t"
+	      "entry=0x%08x%08x, mode=%d, seg=0x%08x, offset=0x%08x\n",
+	      entry_high, entry_low, mode, seg, off);
+
+	return 0;
 }
 
 #ifdef DEBUG
@@ -194,7 +213,7 @@ fetch8(struct regs *regs)
 	return read8(addr);
 }
 
-unsigned
+static unsigned
 getreg32(struct regs *regs, int r)
 {
 	switch (r & 7) {
@@ -210,13 +229,13 @@ getreg32(struct regs *regs, int r)
 	return ~0;
 }
 
-unsigned
+static unsigned
 getreg16(struct regs *regs, int r)
 {
 	return MASK16(getreg32(regs, r));
 }
 
-unsigned
+static unsigned
 getreg8(struct regs *regs, int r)
 {
 	switch (r & 7) {
@@ -232,7 +251,7 @@ getreg8(struct regs *regs, int r)
 	return ~0;
 }
 
-void
+static void
 setreg32(struct regs *regs, int r, unsigned v)
 {
 	switch (r & 7) {
@@ -247,13 +266,13 @@ setreg32(struct regs *regs, int r, unsig
 	}
 }
 
-void
+static void
 setreg16(struct regs *regs, int r, unsigned v)
 {
 	setreg32(regs, r, (getreg32(regs, r) & ~0xFFFF) | MASK16(v));
 }
 
-void
+static void
 setreg8(struct regs *regs, int r, unsigned v)
 {
 	v &= 0xFF;
@@ -269,7 +288,7 @@ setreg8(struct regs *regs, int r, unsign
 	}
 }
 
-unsigned
+static unsigned
 segment(unsigned prefix, struct regs *regs, unsigned seg)
 {
 	if (prefix & SEG_ES)
@@ -287,7 +306,7 @@ segment(unsigned prefix, struct regs *re
 	return seg;
 }
 
-unsigned
+static unsigned
 sib(struct regs *regs, int mod, unsigned byte)
 {
 	unsigned scale = (byte >> 6) & 3;
@@ -319,7 +338,7 @@ sib(struct regs *regs, int mod, unsigned
 /*
  * Operand (modrm) decode
  */
-unsigned
+static unsigned
 operand(unsigned prefix, struct regs *regs, unsigned modrm)
 {
 	int mod, disp = 0, seg;
@@ -418,7 +437,7 @@ operand(unsigned prefix, struct regs *re
 /*
  * Load new IDT
  */
-int
+static int
 lidt(struct regs *regs, unsigned prefix, unsigned modrm)
 {
 	unsigned eip = regs->eip - 3;
@@ -438,7 +457,7 @@ lidt(struct regs *regs, unsigned prefix,
 /*
  * Load new GDT
  */
-int
+static int
 lgdt(struct regs *regs, unsigned prefix, unsigned modrm)
 {
 	unsigned eip = regs->eip - 3;
@@ -458,7 +477,7 @@ lgdt(struct regs *regs, unsigned prefix,
 /*
  * Modify CR0 either through an lmsw instruction.
  */
-int
+static int
 lmsw(struct regs *regs, unsigned prefix, unsigned modrm)
 {
 	unsigned eip = regs->eip - 3;
@@ -481,7 +500,7 @@ lmsw(struct regs *regs, unsigned prefix,
  * We need to handle moves that address memory beyond the 64KB segment
  * limit that VM8086 mode enforces.
  */
-int
+static int
 movr(struct regs *regs, unsigned prefix, unsigned opc)
 {
 	unsigned eip = regs->eip - 1;
@@ -546,7 +565,7 @@ movr(struct regs *regs, unsigned prefix,
 /*
  * Move to and from a control register.
  */
-int
+static int
 movcr(struct regs *regs, unsigned prefix, unsigned opc)
 {
 	unsigned eip = regs->eip - 2;
@@ -618,7 +637,7 @@ static inline void set_eflags_ZF(unsigne
  * We need to handle cmp opcodes that address memory beyond the 64KB
  * segment limit that VM8086 mode enforces.
  */
-int
+static int
 cmp(struct regs *regs, unsigned prefix, unsigned opc)
 {
 	unsigned eip = regs->eip - 1;
@@ -658,7 +677,7 @@ cmp(struct regs *regs, unsigned prefix, 
  * We need to handle test opcodes that address memory beyond the 64KB
  * segment limit that VM8086 mode enforces.
  */
-int
+static int
 test(struct regs *regs, unsigned prefix, unsigned opc)
 {
 	unsigned eip = regs->eip - 1;
@@ -691,7 +710,7 @@ test(struct regs *regs, unsigned prefix,
  * We need to handle pop opcodes that address memory beyond the 64KB
  * segment limit that VM8086 mode enforces.
  */
-int
+static int
 pop(struct regs *regs, unsigned prefix, unsigned opc)
 {
 	unsigned eip = regs->eip - 1;
@@ -721,7 +740,7 @@ pop(struct regs *regs, unsigned prefix, 
 /*
  * Emulate a segment load in protected mode
  */
-int
+static int
 load_seg(unsigned long sel, uint32_t *base, uint32_t *limit, union vmcs_arbytes *arbytes)
 {
 	unsigned long long entry;
@@ -768,7 +787,7 @@ load_seg(unsigned long sel, uint32_t *ba
 /*
  * Transition to protected mode
  */
-void
+static void
 protected_mode(struct regs *regs)
 {
 	regs->eflags &= ~(EFLAGS_TF|EFLAGS_VM);
@@ -842,7 +861,7 @@ protected_mode(struct regs *regs)
 /*
  * Start real-mode emulation
  */
-void
+static void
 real_mode(struct regs *regs)
 {
 	regs->eflags |= EFLAGS_VM | 0x02;
@@ -935,7 +954,7 @@ set_mode(struct regs *regs, enum vm86_mo
 	TRACE((regs, 0, states[mode]));
 }
 
-void
+static void
 jmpl(struct regs *regs, int prefix)
 {
 	unsigned n = regs->eip;
@@ -963,7 +982,7 @@ jmpl(struct regs *regs, int prefix)
 		panic("jmpl");
 }
 
-void
+static void
 retl(struct regs *regs, int prefix)
 {
 	unsigned cs, eip;
@@ -990,7 +1009,7 @@ retl(struct regs *regs, int prefix)
 		panic("retl");
 }
 
-void
+static void
 interrupt(struct regs *regs, int n)
 {
 	TRACE((regs, 0, "external interrupt %d", n));
@@ -1008,7 +1027,7 @@ interrupt(struct regs *regs, int n)
  * interrupt vectors. The following simple state machine catches
  * these attempts and rewrites them.
  */
-int
+static int
 outbyte(struct regs *regs, unsigned prefix, unsigned opc)
 {
 	static char icw2[2] = { 0 };
@@ -1059,7 +1078,7 @@ outbyte(struct regs *regs, unsigned pref
 	return 1;
 }
 
-int
+static int
 inbyte(struct regs *regs, unsigned prefix, unsigned opc)
 {
 	int port;
@@ -1086,7 +1105,7 @@ enum { OPC_INVALID, OPC_EMULATED };
  * a small subset of the opcodes, and not all opcodes are implemented for each
  * of the four modes we can operate in.
  */
-int
+static int
 opcode(struct regs *regs)
 {
 	unsigned eip = regs->eip;
@@ -1246,7 +1265,7 @@ opcode(struct regs *regs)
 			if ((mode == VM86_REAL_TO_PROTECTED) ||
 			    (mode == VM86_PROTECTED_TO_REAL)) {
 				retl(regs, prefix);
-				return OPC_EMULATED;
+				return OPC_INVALID;
 			}
 			goto invalid;
 
@@ -1284,7 +1303,7 @@ opcode(struct regs *regs)
 			if ((mode == VM86_REAL_TO_PROTECTED) ||
 			    (mode == VM86_PROTECTED_TO_REAL)) {
 				jmpl(regs, prefix);
-				return OPC_EMULATED;
+				return OPC_INVALID;
 			}
 			goto invalid;
 
diff -r d76a7a40f3a9 tools/firmware/vmxassist/vm86.h
--- a/tools/firmware/vmxassist/vm86.h	Fri Mar 31 17:44:26 2006 +0100
+++ b/tools/firmware/vmxassist/vm86.h	Sat Apr  1 17:41:29 2006 +0800
@@ -58,7 +58,6 @@ extern struct vmx_assist_context newctx;
 extern struct vmx_assist_context newctx;
 
 extern void emulate(struct regs *);
-extern void interrupt(struct regs *, int);
 extern void dump_regs(struct regs *);
 extern void trace(struct regs *, int, char *, ...);
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply

* [lm-sensors] update to fancontroller
From: Paul Andreassen @ 2006-04-01 10:34 UTC (permalink / raw)
  To: lm-sensors

Hi lm-sensors developers,

Attached is a replacement for 'fancontrol' written in c.  It uses a lot less 
memory and processor resources.

I've also added four more options for the '/etc/fancontrol' file.
    - VERBOSE=1 to show whats going on to screen
    - KEEPON=1 always keep fans moving at least MINSTOP
    - SMOOTH=0-4 use temperature smoother/dampener of +/- SMOOTH for noisy 
readings
    - WORKKICK=0-100,0-255 if cpu working more that 1-100% of the time 
interval add 0-255 to pwm

Thanks,
Paul
-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fancontroller.c
Type: text/x-csrc
Size: 22334 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20060401/aac2b87c/fancontroller.bin

^ permalink raw reply

* Re: [PATCH 1/2] scsi: Add scsi_device max_cmd_len
From: Stefan Richter @ 2006-04-01 10:31 UTC (permalink / raw)
  To: Jeff Garzik
  Cc: Christoph Hellwig, Brian King, James.Bottomley, linux-ide,
	linux-scsi
In-Reply-To: <442B15F4.30506@pobox.com>

Jeff Garzik wrote on 2006-03-30:
> James Bottomley wrote:
>> This really doesn't look correct.  What you want is a sata transport
>> class with a max command length in the host device.
> 
> Christoph Hellwig wrote:
>> this sounds wrong to me.  cdb length is a limitation of the host 
>> (driver).
>> A target will reject unknown commands, no matter what length they have.
> 
> In practice, CDB length may be limited by both the host and the device. 
>  This applies to ATAPI, and some USB storage too IIRC.  For ATAPI, you 
> read the CDB length from the device's IDENTIFY PACKET DEVICE info page.

BTW, in case of SBP-2 devices, the CDB length is a property of the 
logical unit and is read from the IEEE 1394 node's configuration ROM. 
Linux' sbp2 driver implements only a CDB length of 12 bytes though.
-- 
Stefan Richter
-=====-=-==- -=-- ----=
http://arcgraph.de/sr/

^ permalink raw reply


This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.