sata_mv ncq Fix EDMA configuration
[safe/jmp/linux-2.6] / drivers / s390 / cio / device_status.c
index 12a24d4..ebe0848 100644 (file)
@@ -3,13 +3,12 @@
  *
  *    Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
  *                      IBM Corporation
- *    Author(s): Cornelia Huck(cohuck@de.ibm.com)
+ *    Author(s): Cornelia Huck (cornelia.huck@de.ibm.com)
  *              Martin Schwidefsky (schwidefsky@de.ibm.com)
  *
  * Status accumulation and basic sense functions.
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/init.h>
 
 #include "css.h"
 #include "device.h"
 #include "ioasm.h"
+#include "io_sch.h"
 
 /*
  * Check for any kind of channel or interface control check but don't
  * issue the message for the console device
  */
-static inline void
+static void
 ccw_device_msg_control_check(struct ccw_device *cdev, struct irb *irb)
 {
        if (!(irb->scsw.cstat & (SCHN_STAT_CHN_DATA_CHK |
                                 SCHN_STAT_CHN_CTRL_CHK |
                                 SCHN_STAT_INTF_CTRL_CHK)))
                return;
-               
        CIO_MSG_EVENT(0, "Channel-Check or Interface-Control-Check "
                      "received"
-                     " ... device %04X on subchannel %04X, dev_stat "
+                     " ... device %04x on subchannel 0.%x.%04x, dev_stat "
                      ": %02X sch_stat : %02X\n",
-                     cdev->private->devno, cdev->private->irq,
+                     cdev->private->dev_id.devno, cdev->private->schid.ssid,
+                     cdev->private->schid.sch_no,
                      irb->scsw.dstat, irb->scsw.cstat);
 
        if (irb->scsw.cc != 3) {
                char dbf_text[15];
 
-               sprintf(dbf_text, "chk%x", cdev->private->irq);
+               sprintf(dbf_text, "chk%x", cdev->private->schid.sch_no);
                CIO_TRACE_EVENT(0, dbf_text);
                CIO_HEX_EVENT(0, irb, sizeof (struct irb));
        }
@@ -59,21 +59,21 @@ ccw_device_path_notoper(struct ccw_device *cdev)
        struct subchannel *sch;
 
        sch = to_subchannel(cdev->dev.parent);
-       stsch (sch->irq, &sch->schib);
+       stsch (sch->schid, &sch->schib);
 
-       CIO_MSG_EVENT(0, "%s(%04x) - path(s) %02x are "
-                     "not operational \n", __FUNCTION__, sch->irq,
+       CIO_MSG_EVENT(0, "%s(0.%x.%04x) - path(s) %02x are "
+                     "not operational \n", __FUNCTION__,
+                     sch->schid.ssid, sch->schid.sch_no,
                      sch->schib.pmcw.pnom);
 
        sch->lpm &= ~sch->schib.pmcw.pnom;
-       if (cdev->private->options.pgroup)
-               cdev->private->flags.doverify = 1;
+       cdev->private->flags.doverify = 1;
 }
 
 /*
  * Copy valid bits from the extended control word to device irb.
  */
-static inline void
+static void
 ccw_device_accumulate_ecw(struct ccw_device *cdev, struct irb *irb)
 {
        /*
@@ -95,7 +95,7 @@ ccw_device_accumulate_ecw(struct ccw_device *cdev, struct irb *irb)
 /*
  * Check if extended status word is valid.
  */
-static inline int
+static int
 ccw_device_accumulate_esw_valid(struct irb *irb)
 {
        if (!irb->scsw.eswf && irb->scsw.stctl == SCSW_STCTL_STATUS_PEND)
@@ -110,7 +110,7 @@ ccw_device_accumulate_esw_valid(struct irb *irb)
 /*
  * Copy valid bits from the extended status word to device irb.
  */
-static inline void
+static void
 ccw_device_accumulate_esw(struct ccw_device *cdev, struct irb *irb)
 {
        struct irb *cdev_irb;
@@ -179,7 +179,7 @@ ccw_device_accumulate_esw(struct ccw_device *cdev, struct irb *irb)
        cdev_irb->esw.esw0.erw.auth = irb->esw.esw0.erw.auth;
        /* Copy path verification required flag. */
        cdev_irb->esw.esw0.erw.pvrf = irb->esw.esw0.erw.pvrf;
-       if (irb->esw.esw0.erw.pvrf && cdev->private->options.pgroup)
+       if (irb->esw.esw0.erw.pvrf)
                cdev->private->flags.doverify = 1;
        /* Copy concurrent sense bit. */
        cdev_irb->esw.esw0.erw.cons = irb->esw.esw0.erw.cons;
@@ -222,6 +222,14 @@ ccw_device_accumulate_irb(struct ccw_device *cdev, struct irb *irb)
 
        cdev_irb = &cdev->private->irb;
 
+       /*
+        * If the clear function had been performed, all formerly pending
+        * status at the subchannel has been cleared and we must not pass
+        * intermediate accumulated status to the device driver.
+        */
+       if (irb->scsw.fctl & SCSW_FCTL_CLEAR_FUNC)
+               memset(&cdev->private->irb, 0, sizeof(struct irb));
+
        /* Copy bits which are valid only for the start function. */
        if (irb->scsw.fctl & SCSW_FCTL_START_FUNC) {
                /* Copy key. */
@@ -264,7 +272,11 @@ ccw_device_accumulate_irb(struct ccw_device *cdev, struct irb *irb)
                cdev_irb->scsw.cpa = irb->scsw.cpa;
        /* Accumulate device status, but not the device busy flag. */
        cdev_irb->scsw.dstat &= ~DEV_STAT_BUSY;
-       cdev_irb->scsw.dstat |= irb->scsw.dstat;
+       /* dstat is not always valid. */
+       if (irb->scsw.stctl &
+           (SCSW_STCTL_PRIM_STATUS | SCSW_STCTL_SEC_STATUS
+            | SCSW_STCTL_INTER_STATUS | SCSW_STCTL_ALERT_STATUS))
+               cdev_irb->scsw.dstat |= irb->scsw.dstat;
        /* Accumulate subchannel status. */
        cdev_irb->scsw.cstat |= irb->scsw.cstat;
        /* Copy residual count if it is valid. */
@@ -299,6 +311,7 @@ int
 ccw_device_do_sense(struct ccw_device *cdev, struct irb *irb)
 {
        struct subchannel *sch;
+       struct ccw1 *sense_ccw;
 
        sch = to_subchannel(cdev->dev.parent);
 
@@ -315,13 +328,16 @@ ccw_device_do_sense(struct ccw_device *cdev, struct irb *irb)
        /*
         * We have ending status but no sense information. Do a basic sense.
         */
-       sch = to_subchannel(cdev->dev.parent);
-       sch->sense_ccw.cmd_code = CCW_CMD_BASIC_SENSE;
-       sch->sense_ccw.cda = (__u32) __pa(cdev->private->irb.ecw);
-       sch->sense_ccw.count = SENSE_MAX_COUNT;
-       sch->sense_ccw.flags = CCW_FLAG_SLI;
+       sense_ccw = &to_io_private(sch)->sense_ccw;
+       sense_ccw->cmd_code = CCW_CMD_BASIC_SENSE;
+       sense_ccw->cda = (__u32) __pa(cdev->private->irb.ecw);
+       sense_ccw->count = SENSE_MAX_COUNT;
+       sense_ccw->flags = CCW_FLAG_SLI;
+
+       /* Reset internal retry indication. */
+       cdev->private->flags.intretry = 0;
 
-       return cio_start (sch, &sch->sense_ccw, 0xff);
+       return cio_start(sch, sense_ccw, 0xff);
 }
 
 /*
@@ -354,7 +370,7 @@ ccw_device_accumulate_basic_sense(struct ccw_device *cdev, struct irb *irb)
        }
        /* Check if path verification is required. */
        if (ccw_device_accumulate_esw_valid(irb) &&
-           irb->esw.esw0.erw.pvrf && cdev->private->options.pgroup) 
+           irb->esw.esw0.erw.pvrf)
                cdev->private->flags.doverify = 1;
 }