2 * File...........: linux/drivers/s390/block/dasd.c
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Horst Hummel <Horst.Hummel@de.ibm.com>
5 * Carsten Otte <Cotte@de.ibm.com>
6 * Martin Schwidefsky <schwidefsky@de.ibm.com>
7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
12 #define KMSG_COMPONENT "dasd"
14 #include <linux/ctype.h>
15 #include <linux/init.h>
17 #include <asm/debug.h>
18 #include <asm/ebcdic.h>
19 #include <asm/uaccess.h>
22 #define PRINTK_HEADER "dasd_erp:"
27 dasd_alloc_erp_request(char *magic, int cplength, int datasize,
28 struct dasd_device * device)
31 struct dasd_ccw_req *cqr;
36 BUG_ON( magic == NULL || datasize > PAGE_SIZE ||
37 (cplength*sizeof(struct ccw1)) > PAGE_SIZE);
39 size = (sizeof(struct dasd_ccw_req) + 7L) & -8L;
41 size += cplength * sizeof(struct ccw1);
44 spin_lock_irqsave(&device->mem_lock, flags);
45 cqr = (struct dasd_ccw_req *)
46 dasd_alloc_chunk(&device->erp_chunks, size);
47 spin_unlock_irqrestore(&device->mem_lock, flags);
49 return ERR_PTR(-ENOMEM);
50 memset(cqr, 0, sizeof(struct dasd_ccw_req));
51 INIT_LIST_HEAD(&cqr->devlist);
52 INIT_LIST_HEAD(&cqr->blocklist);
53 data = (char *) cqr + ((sizeof(struct dasd_ccw_req) + 7L) & -8L);
56 cqr->cpaddr = (struct ccw1 *) data;
57 data += cplength*sizeof(struct ccw1);
58 memset(cqr->cpaddr, 0, cplength*sizeof(struct ccw1));
63 memset(cqr->data, 0, datasize);
65 strncpy((char *) &cqr->magic, magic, 4);
66 ASCEBC((char *) &cqr->magic, 4);
67 set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
68 dasd_get_device(device);
73 dasd_free_erp_request(struct dasd_ccw_req *cqr, struct dasd_device * device)
77 spin_lock_irqsave(&device->mem_lock, flags);
78 dasd_free_chunk(&device->erp_chunks, cqr);
79 spin_unlock_irqrestore(&device->mem_lock, flags);
80 atomic_dec(&device->ref_count);
85 * dasd_default_erp_action just retries the current cqr
88 dasd_default_erp_action(struct dasd_ccw_req *cqr)
90 struct dasd_device *device;
92 device = cqr->startdev;
94 /* just retry - there is nothing to save ... I got no sense data.... */
95 if (cqr->retries > 0) {
96 DBF_DEV_EVENT(DBF_DEBUG, device,
97 "default ERP called (%i retries left)",
99 cqr->lpm = LPM_ANYPATH;
100 cqr->status = DASD_CQR_FILLED;
102 dev_err(&device->cdev->dev,
103 "default ERP has run out of retries and failed\n");
104 cqr->status = DASD_CQR_FAILED;
105 cqr->stopclk = get_clock();
108 } /* end dasd_default_erp_action */
112 * Frees all ERPs of the current ERP Chain and set the status
113 * of the original CQR either to DASD_CQR_DONE if ERP was successful
114 * or to DASD_CQR_FAILED if ERP was NOT successful.
115 * NOTE: This function is only called if no discipline postaction
119 * erp current erp_head
122 * cqr pointer to the original CQR
124 struct dasd_ccw_req *dasd_default_erp_postaction(struct dasd_ccw_req *cqr)
128 BUG_ON(cqr->refers == NULL || cqr->function == NULL);
130 success = cqr->status == DASD_CQR_DONE;
132 /* free all ERPs - but NOT the original cqr */
133 while (cqr->refers != NULL) {
134 struct dasd_ccw_req *refers;
136 refers = cqr->refers;
137 /* remove the request from the block queue */
138 list_del(&cqr->blocklist);
139 /* free the finished erp request */
140 dasd_free_erp_request(cqr, cqr->memdev);
144 /* set corresponding status to original cqr */
146 cqr->status = DASD_CQR_DONE;
148 cqr->status = DASD_CQR_FAILED;
149 cqr->stopclk = get_clock();
154 } /* end default_erp_postaction */
157 dasd_log_sense(struct dasd_ccw_req *cqr, struct irb *irb)
159 struct dasd_device *device;
161 device = cqr->startdev;
162 /* dump sense data */
163 if (device->discipline && device->discipline->dump_sense)
164 device->discipline->dump_sense(device, cqr, irb);
168 dasd_log_sense_dbf(struct dasd_ccw_req *cqr, struct irb *irb)
170 struct dasd_device *device;
172 device = cqr->startdev;
173 /* dump sense data to s390 debugfeature*/
174 if (device->discipline && device->discipline->dump_sense_dbf)
175 device->discipline->dump_sense_dbf(device, cqr, irb, "log");
177 EXPORT_SYMBOL(dasd_log_sense_dbf);
179 EXPORT_SYMBOL(dasd_default_erp_action);
180 EXPORT_SYMBOL(dasd_default_erp_postaction);
181 EXPORT_SYMBOL(dasd_alloc_erp_request);
182 EXPORT_SYMBOL(dasd_free_erp_request);
183 EXPORT_SYMBOL(dasd_log_sense);