patch-2.4.22 linux-2.4.22/drivers/s390/block/dasd_diag.c
Next file: linux-2.4.22/drivers/s390/block/dasd_diag.h
Previous file: linux-2.4.22/drivers/s390/block/dasd_3990_erp.c
Back to the patch index
Back to the overall index
- Lines: 509
- Date:
2003-08-25 04:44:42.000000000 -0700
- Orig file:
linux-2.4.21/drivers/s390/block/dasd_diag.c
- Orig date:
2001-09-30 12:26:07.000000000 -0700
diff -urN linux-2.4.21/drivers/s390/block/dasd_diag.c linux-2.4.22/drivers/s390/block/dasd_diag.c
@@ -5,13 +5,16 @@
* ...............: by Hartmunt Penner <hpenner@de.ibm.com>
* Bugreports.to..: <Linux390@de.ibm.com>
* (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
-
+ *
+ * $Revision: 1.47 $
+ *
* History of changes
* 07/13/00 Added fixup sections for diagnoses ans saved some registers
* 07/14/00 fixed constraints in newly generated inline asm
* 10/05/00 adapted to 'new' DASD driver
* fixed return codes of dia250()
* fixed partition handling and HDIO_GETGEO
+ * 10/01/02 fixed Bugzilla 1341
*/
#include <linux/config.h>
@@ -20,7 +23,7 @@
#include <asm/debug.h>
#include <linux/slab.h>
-#include <linux/hdreg.h> /* HDIO_GETGEO */
+#include <linux/hdreg.h>
#include <linux/blk.h>
#include <asm/ccwcache.h>
#include <asm/dasd.h>
@@ -29,6 +32,7 @@
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/s390dyn.h>
+#include <asm/s390_ext.h>
#include "dasd_int.h"
#include "dasd_diag.h"
@@ -38,62 +42,50 @@
#endif /* PRINTK_HEADER */
#define PRINTK_HEADER DASD_NAME"(diag):"
+#ifdef MODULE
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,12))
+MODULE_LICENSE("GPL");
+#endif
+#endif
+
dasd_discipline_t dasd_diag_discipline;
typedef struct
dasd_diag_private_t {
- dasd_diag_characteristics_t rdc_data;
+ diag210_t rdc_data;
diag_rw_io_t iob;
diag_init_io_t iib;
unsigned long *label;
} dasd_diag_private_t;
static __inline__ int
-dia210 (void *devchar)
-{
- int rc;
-
- __asm__ __volatile__ (" diag %1,0,0x210\n"
- "0: ipm %0\n"
- " srl %0,28\n"
- "1:\n"
- ".section .fixup,\"ax\"\n"
- "2: lhi %0,3\n"
- " bras 1,3f\n"
- " .long 1b\n"
- "3: l 1,0(1)\n"
- " br 1\n"
- ".previous\n"
- ".section __ex_table,\"a\"\n"
- " .align 4\n"
- " .long 0b,2b\n" ".previous\n":"=d" (rc)
- :"d" ((void *) __pa (devchar))
- :"1");
- return rc;
-}
-
-static __inline__ int
dia250 (void *iob, int cmd)
{
- __asm__ __volatile__ (" lr 0,%1\n"
- " diag 0,%0,0x250\n"
+ unsigned long addr;
+ int rc;
+
+ addr = __pa(iob);
+ __asm__ __volatile__ (" lhi %0,11\n"
+ " lr 0,%2\n"
+ " diag 0,%1,0x250\n"
"0: ipm %0\n"
" srl %0,28\n"
" or %0,1\n"
"1:\n"
- ".section .fixup,\"ax\"\n"
- "2: lhi %0,3\n"
- " bras 1,3f\n"
- " .long 1b\n"
- "3: l 1,0(1)\n"
- " br 1\n"
- ".previous\n"
+#ifndef CONFIG_ARCH_S390X
".section __ex_table,\"a\"\n"
" .align 4\n"
- " .long 0b,2b\n" ".previous\n":"+d" (cmd)
- :"d" ((void *) __pa (iob))
- :"0", "1", "cc");
- return cmd;
+ " .long 0b,1b\n"
+ ".previous\n"
+#else
+ ".section __ex_table,\"a\"\n"
+ " .align 8\n"
+ " .quad 0b,1b\n"
+ ".previous\n"
+#endif
+ : "+&d" (rc)
+ : "d" (cmd), "d" (addr) : "0", "1", "cc");
+ return rc;
}
static __inline__ int
@@ -144,13 +136,18 @@
iob->key = 0;
iob->flags = 2;
iob->block_count = cqr->cplength >> 1;
- iob->interrupt_params = (u32) cqr;
+ iob->interrupt_params = (u32)(addr_t) cqr;
iob->bio_list = __pa (cqr->cpaddr);
- asm volatile ("STCK %0":"=m" (cqr->startclk));
+ cqr->startclk = get_clock ();
+
rc = dia250 (iob, RW_BIO);
if (rc > 8) {
- PRINT_WARN ("dia250 returned CC %d\n", rc);
+
+ MESSAGE (KERN_WARNING,
+ "dia250 returned CC %d",
+ rc);
+
check_then_set (&cqr->status,
CQR_STATUS_QUEUED, CQR_STATUS_ERROR);
} else if (rc == 0) {
@@ -176,41 +173,56 @@
int done_fast_io = 0;
int devno;
unsigned long flags;
+ int subcode;
+ /*
+ * Get the external interruption subcode. VM stores
+ * this in the 'cpu address' field associated with
+ * the external interrupt. For diag 250 the subcode
+ * needs to be 3.
+ */
+ subcode = S390_lowcore.cpu_addr;
+ if ((subcode & 0xff00) != 0x0300)
+ return;
irq_enter(cpu, -1);
if (!ip) { /* no intparm: unsolicited interrupt */
- printk (KERN_WARNING PRINTK_HEADER
- "caught unsolicited interrupt\n");
+
+ MESSAGE (KERN_DEBUG, "%s",
+ "caught unsolicited interrupt");
+
irq_exit(cpu, -1);
return;
}
if (ip & 0x80000001) {
- printk (KERN_WARNING PRINTK_HEADER
- "caught spurious interrupt with parm %08x\n", ip);
+
+ MESSAGE (KERN_DEBUG,
+ "caught spurious interrupt with parm %08x",
+ ip);
+
irq_exit(cpu, -1);
return;
}
- cqr = (ccw_req_t *) ip;
+ cqr = (ccw_req_t *)(addr_t) ip;
device = (dasd_device_t *) cqr->device;
devno = device->devinfo.devno;
+
if (device == NULL) {
- printk (KERN_WARNING PRINTK_HEADER
- " INT on devno 0x%04X = /dev/%s (%d:%d)"
- " belongs to NULL device\n",
- devno, device->name, MAJOR (device->kdev),
- MINOR (device->kdev));
+
+ DEV_MESSAGE (KERN_WARNING, device, "%s",
+ " belongs to NULL device");
}
+
if (strncmp (device->discipline->ebcname, (char *) &cqr->magic, 4)) {
- printk (KERN_WARNING PRINTK_HEADER
- "0x%04X : /dev/%s (%d:%d)"
- " magic number of ccw_req_t 0x%08X doesn't match"
- " discipline 0x%08X\n",
- devno, device->name,
- MAJOR (device->kdev), MINOR (device->kdev),
- cqr->magic, *(int *) (&device->discipline->name));
+
+ DEV_MESSAGE (KERN_WARNING, device,
+ " magic number of ccw_req_t 0x%08X doesn't match"
+ " discipline 0x%08X",
+ cqr->magic,
+ *(int *) (&device->discipline->name));
+
irq_exit(cpu, -1);
return;
}
@@ -219,7 +231,7 @@
s390irq_spin_lock_irqsave (device->devinfo.irq,
flags);
- asm volatile ("STCK %0":"=m" (cqr->stopclk));
+ cqr->stopclk = get_clock ();
switch (status) {
case 0x00:
@@ -254,52 +266,60 @@
{
int rc = 0;
int bsize;
- int label_block;
dasd_diag_private_t *private;
- dasd_diag_characteristics_t *rdc_data;
+ diag210_t *rdc_data;
ccw_req_t *cqr;
long *label;
int sb;
if (device == NULL) {
- printk (KERN_WARNING PRINTK_HEADER
- "Null device pointer passed to characteristics checker\n");
+
+ MESSAGE (KERN_WARNING, "%s",
+ "Null device pointer passed to characteristics "
+ "checker");
+
return -ENODEV;
}
device->private = kmalloc (sizeof (dasd_diag_private_t), GFP_KERNEL);
+
if (device->private == NULL) {
- printk (KERN_WARNING PRINTK_HEADER
- "memory allocation failed for private data\n");
+
+ MESSAGE (KERN_WARNING, "%s",
+ "memory allocation failed for private data");
+
rc = -ENOMEM;
goto fail;
}
private = (dasd_diag_private_t *) device->private;
rdc_data = (void *) &(private->rdc_data);
- rdc_data->dev_nr = device->devinfo.devno;
- rdc_data->rdc_len = sizeof (dasd_diag_characteristics_t);
+ rdc_data->vrdcdvno = device->devinfo.devno;
+ rdc_data->vrdclen = sizeof (diag210_t);
- rc = dia210 (rdc_data);
+ rc = diag210 (rdc_data);
if ( rc != 0) {
goto fail;
}
- if (rdc_data->vdev_class != DEV_CLASS_FBA &&
- rdc_data->vdev_class != DEV_CLASS_ECKD &&
- rdc_data->vdev_class != DEV_CLASS_CKD) {
+ if (rdc_data->vrdcvcla != DEV_CLASS_FBA &&
+ rdc_data->vrdcvcla != DEV_CLASS_ECKD &&
+ rdc_data->vrdcvcla != DEV_CLASS_CKD) {
rc = -ENOTSUPP;
goto fail;
}
-#if 0
- printk (KERN_INFO PRINTK_HEADER
- "%04X: %04X on real %04X/%02X\n",
- rdc_data->dev_nr,
- rdc_data->vdev_type, rdc_data->rdev_type, rdc_data->rdev_model);
-#endif
+
+ DBF_EVENT (DBF_INFO,
+ "%04X: %04X on real %04X/%02X",
+ rdc_data->vrdcdvno,
+ rdc_data->vrdcvtyp,
+ rdc_data->vrdccrty,
+ rdc_data->vrdccrmd);
+
+
/* Figure out position of label block */
- if (private->rdc_data.vdev_class == DEV_CLASS_FBA) {
+ if (private->rdc_data.vrdcvcla == DEV_CLASS_FBA) {
device->sizes.pt_block = 1;
- } else if (private->rdc_data.vdev_class == DEV_CLASS_ECKD ||
- private->rdc_data.vdev_class == DEV_CLASS_CKD) {
+ } else if (private->rdc_data.vrdcvcla == DEV_CLASS_ECKD ||
+ private->rdc_data.vrdcvcla == DEV_CLASS_CKD) {
device->sizes.pt_block = 2;
} else {
BUG();
@@ -319,9 +339,12 @@
cqr = dasd_alloc_request (dasd_diag_discipline.name,
sizeof (diag_bio_t) / sizeof (ccw1_t),
0, device);
+
if (cqr == NULL) {
- printk (KERN_WARNING PRINTK_HEADER
- "No memory to allocate initialization request\n");
+
+ MESSAGE (KERN_WARNING, "%s",
+ "No memory to allocate initialization request");
+
free_page ((long) private->label);
rc = -ENOMEM;
goto fail;
@@ -334,11 +357,12 @@
cqr->device = device;
cqr->status = CQR_STATUS_FILLED;
memset (iob, 0, sizeof (diag_rw_io_t));
- iob->dev_nr = rdc_data->dev_nr;
+ iob->dev_nr = rdc_data->vrdcdvno;
iob->block_count = 1;
- iob->interrupt_params = (u32) cqr;
+ iob->interrupt_params = (u32)(addr_t) cqr;
iob->bio_list = __pa (bio);
rc = dia250 (iob, RW_BIO);
+ dasd_free_request(cqr, device);
if (rc == 0) {
if (label[3] != bsize ||
label[0] != 0xc3d4e2f1 || /* != CMS1 */
@@ -357,13 +381,16 @@
device->sizes.blocks = label[7];
device->sizes.bp_block = bsize;
device->sizes.s2b_shift = 0; /* bits to shift 512 to get a block */
+
for (sb = 512; sb < bsize; sb = sb << 1)
+
device->sizes.s2b_shift++;
- printk (KERN_INFO PRINTK_HEADER
- "/dev/%s (%04X): capacity (%dkB blks): %ldkB\n",
- device->name, device->devinfo.devno,
- (device->sizes.bp_block >> 10),
- (device->sizes.blocks << device->sizes.s2b_shift) >> 1);
+
+ DEV_MESSAGE (KERN_INFO, device,
+ "capacity (%dkB blks): %ldkB",
+ (device->sizes.bp_block >> 10),
+ (device->sizes.blocks << device->sizes.s2b_shift) >> 1);
+
free_page ((long) private->label);
rc = 0;
goto out;
@@ -380,12 +407,9 @@
dasd_diag_fill_geometry (struct dasd_device_t *device, struct hd_geometry *geo)
{
int rc = 0;
- dasd_diag_private_t *private = (dasd_diag_private_t *) device->private;
unsigned long sectors = device->sizes.blocks << device->sizes.s2b_shift;
unsigned long tracks = sectors >> 6;
- unsigned long trk_rem = sectors & ((1 << 6) - 1); /* 64k per track */
unsigned long cyls = tracks >> 4;
- unsigned long cyls_rem = tracks & ((1 << 4) - 1); /* 16 head per cyl */
switch (device->sizes.bp_block) {
case 512:
@@ -420,14 +444,19 @@
diag_bio_t *bio;
int bhct;
long size;
+ unsigned long reloc_sector = req->sector +
+ device->major_info->gendisk.part[MINOR (req->rq_dev)].start_sect;
if (!noblk) {
- PRINT_ERR ("No blocks to read/write...returning\n");
- return NULL;
+
+ MESSAGE (KERN_ERR, "%s",
+ "No blocks to read/write...returning");
+
+ return ERR_PTR(-EINVAL);
}
if (req->cmd == READ) {
rw_cmd = MDSK_READ_REQ;
- } else if (req->cmd == WRITE) {
+ } else {
rw_cmd = MDSK_WRITE_REQ;
}
bhct = 0;
@@ -439,11 +468,11 @@
/* Build the request */
rw_cp = dasd_alloc_request (dasd_diag_discipline.name, bhct << 1, 0, device);
if (!rw_cp) {
- return NULL;
+ return ERR_PTR(-ENOMEM);
}
bio = (diag_bio_t *) (rw_cp->cpaddr);
- block = req->sector >> device->sizes.s2b_shift;
+ block = reloc_sector >> device->sizes.s2b_shift;
for (bh = req->bh; bh; bh = bh->b_reqnext) {
memset (bio, 0, sizeof (diag_bio_t));
for (size = 0; size < bh->b_size; size += byt_per_blk) {
@@ -454,7 +483,9 @@
block++;
}
}
- asm volatile ("STCK %0":"=m" (rw_cp->buildclk));
+
+ rw_cp->buildclk = get_clock ();
+
rw_cp->device = device;
rw_cp->expires = 50 * TOD_SEC; /* 50 seconds */
rw_cp->req = req;
@@ -463,14 +494,15 @@
}
static int
-dasd_diag_fill_info (dasd_device_t * device, dasd_information_t * info)
+dasd_diag_fill_info (dasd_device_t * device, dasd_information2_t * info)
{
int rc = 0;
info->FBA_layout = 1;
- info->characteristics_size = sizeof (dasd_diag_characteristics_t);
+ info->format = DASD_FORMAT_LDL;
+ info->characteristics_size = sizeof (diag210_t);
memcpy (info->characteristics,
&((dasd_diag_private_t *) device->private)->rdc_data,
- sizeof (dasd_diag_characteristics_t));
+ sizeof (diag210_t));
info->confdata_size = 0;
return rc;
}
@@ -501,26 +533,32 @@
examine_error:dasd_diag_examine_error,
build_cp_from_req:dasd_diag_build_cp_from_req,
dump_sense:dasd_diag_dump_sense,
- int_handler:dasd_ext_handler,
+ int_handler:(void *) dasd_ext_handler,
fill_info:dasd_diag_fill_info,
+ list:LIST_HEAD_INIT(dasd_diag_discipline.list),
};
int
dasd_diag_init (void)
{
int rc = 0;
+
if (MACHINE_IS_VM) {
- printk (KERN_INFO PRINTK_HEADER
- "%s discipline initializing\n",
- dasd_diag_discipline.name);
+
+ MESSAGE (KERN_INFO,
+ "%s discipline initializing",
+ dasd_diag_discipline.name);
+
ASCEBC (dasd_diag_discipline.ebcname, 4);
ctl_set_bit (0, 9);
register_external_interrupt (0x2603, dasd_ext_handler);
dasd_discipline_add (&dasd_diag_discipline);
} else {
- printk (KERN_INFO PRINTK_HEADER
- "Machine is not VM: %s discipline not initializing\n",
- dasd_diag_discipline.name);
+
+ MESSAGE (KERN_INFO,
+ "Machine is not VM: %s discipline not initializing",
+ dasd_diag_discipline.name);
+
rc = -EINVAL;
}
return rc;
@@ -530,16 +568,19 @@
dasd_diag_cleanup (void)
{
if (MACHINE_IS_VM) {
- printk (KERN_INFO PRINTK_HEADER
- "%s discipline cleaning up\n",
- dasd_diag_discipline.name);
+
+ MESSAGE (KERN_INFO,
+ "%s discipline cleaning up",
+ dasd_diag_discipline.name);
+
dasd_discipline_del (&dasd_diag_discipline);
unregister_external_interrupt (0x2603, dasd_ext_handler);
ctl_clear_bit (0, 9);
} else {
- printk (KERN_INFO PRINTK_HEADER
- "Machine is not VM: %s discipline not initializing\n",
- dasd_diag_discipline.name);
+
+ MESSAGE (KERN_INFO,
+ "Machine is not VM: %s discipline not initializing",
+ dasd_diag_discipline.name);
}
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)