dasd.c 80 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028
  1. /*
  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. * Copyright IBM Corp. 1999, 2009
  9. */
  10. #define KMSG_COMPONENT "dasd"
  11. #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
  12. #include <linux/kernel_stat.h>
  13. #include <linux/kmod.h>
  14. #include <linux/init.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/ctype.h>
  17. #include <linux/major.h>
  18. #include <linux/slab.h>
  19. #include <linux/buffer_head.h>
  20. #include <linux/hdreg.h>
  21. #include <linux/async.h>
  22. #include <linux/mutex.h>
  23. #include <asm/ccwdev.h>
  24. #include <asm/ebcdic.h>
  25. #include <asm/idals.h>
  26. #include <asm/itcw.h>
  27. #include <asm/diag.h>
  28. /* This is ugly... */
  29. #define PRINTK_HEADER "dasd:"
  30. #include "dasd_int.h"
  31. /*
  32. * SECTION: Constant definitions to be used within this file
  33. */
  34. #define DASD_CHANQ_MAX_SIZE 4
  35. #define DASD_SLEEPON_START_TAG (void *) 1
  36. #define DASD_SLEEPON_END_TAG (void *) 2
  37. /*
  38. * SECTION: exported variables of dasd.c
  39. */
  40. debug_info_t *dasd_debug_area;
  41. struct dasd_discipline *dasd_diag_discipline_pointer;
  42. void dasd_int_handler(struct ccw_device *, unsigned long, struct irb *);
  43. MODULE_AUTHOR("Holger Smolinski <Holger.Smolinski@de.ibm.com>");
  44. MODULE_DESCRIPTION("Linux on S/390 DASD device driver,"
  45. " Copyright 2000 IBM Corporation");
  46. MODULE_SUPPORTED_DEVICE("dasd");
  47. MODULE_LICENSE("GPL");
  48. /*
  49. * SECTION: prototypes for static functions of dasd.c
  50. */
  51. static int dasd_alloc_queue(struct dasd_block *);
  52. static void dasd_setup_queue(struct dasd_block *);
  53. static void dasd_free_queue(struct dasd_block *);
  54. static void dasd_flush_request_queue(struct dasd_block *);
  55. static int dasd_flush_block_queue(struct dasd_block *);
  56. static void dasd_device_tasklet(struct dasd_device *);
  57. static void dasd_block_tasklet(struct dasd_block *);
  58. static void do_kick_device(struct work_struct *);
  59. static void do_restore_device(struct work_struct *);
  60. static void do_reload_device(struct work_struct *);
  61. static void dasd_return_cqr_cb(struct dasd_ccw_req *, void *);
  62. static void dasd_device_timeout(unsigned long);
  63. static void dasd_block_timeout(unsigned long);
  64. static void __dasd_process_erp(struct dasd_device *, struct dasd_ccw_req *);
  65. /*
  66. * SECTION: Operations on the device structure.
  67. */
  68. static wait_queue_head_t dasd_init_waitq;
  69. static wait_queue_head_t dasd_flush_wq;
  70. static wait_queue_head_t generic_waitq;
  71. /*
  72. * Allocate memory for a new device structure.
  73. */
  74. struct dasd_device *dasd_alloc_device(void)
  75. {
  76. struct dasd_device *device;
  77. device = kzalloc(sizeof(struct dasd_device), GFP_ATOMIC);
  78. if (!device)
  79. return ERR_PTR(-ENOMEM);
  80. /* Get two pages for normal block device operations. */
  81. device->ccw_mem = (void *) __get_free_pages(GFP_ATOMIC | GFP_DMA, 1);
  82. if (!device->ccw_mem) {
  83. kfree(device);
  84. return ERR_PTR(-ENOMEM);
  85. }
  86. /* Get one page for error recovery. */
  87. device->erp_mem = (void *) get_zeroed_page(GFP_ATOMIC | GFP_DMA);
  88. if (!device->erp_mem) {
  89. free_pages((unsigned long) device->ccw_mem, 1);
  90. kfree(device);
  91. return ERR_PTR(-ENOMEM);
  92. }
  93. dasd_init_chunklist(&device->ccw_chunks, device->ccw_mem, PAGE_SIZE*2);
  94. dasd_init_chunklist(&device->erp_chunks, device->erp_mem, PAGE_SIZE);
  95. spin_lock_init(&device->mem_lock);
  96. atomic_set(&device->tasklet_scheduled, 0);
  97. tasklet_init(&device->tasklet,
  98. (void (*)(unsigned long)) dasd_device_tasklet,
  99. (unsigned long) device);
  100. INIT_LIST_HEAD(&device->ccw_queue);
  101. init_timer(&device->timer);
  102. device->timer.function = dasd_device_timeout;
  103. device->timer.data = (unsigned long) device;
  104. INIT_WORK(&device->kick_work, do_kick_device);
  105. INIT_WORK(&device->restore_device, do_restore_device);
  106. INIT_WORK(&device->reload_device, do_reload_device);
  107. device->state = DASD_STATE_NEW;
  108. device->target = DASD_STATE_NEW;
  109. mutex_init(&device->state_mutex);
  110. return device;
  111. }
  112. /*
  113. * Free memory of a device structure.
  114. */
  115. void dasd_free_device(struct dasd_device *device)
  116. {
  117. kfree(device->private);
  118. free_page((unsigned long) device->erp_mem);
  119. free_pages((unsigned long) device->ccw_mem, 1);
  120. kfree(device);
  121. }
  122. /*
  123. * Allocate memory for a new device structure.
  124. */
  125. struct dasd_block *dasd_alloc_block(void)
  126. {
  127. struct dasd_block *block;
  128. block = kzalloc(sizeof(*block), GFP_ATOMIC);
  129. if (!block)
  130. return ERR_PTR(-ENOMEM);
  131. /* open_count = 0 means device online but not in use */
  132. atomic_set(&block->open_count, -1);
  133. spin_lock_init(&block->request_queue_lock);
  134. atomic_set(&block->tasklet_scheduled, 0);
  135. tasklet_init(&block->tasklet,
  136. (void (*)(unsigned long)) dasd_block_tasklet,
  137. (unsigned long) block);
  138. INIT_LIST_HEAD(&block->ccw_queue);
  139. spin_lock_init(&block->queue_lock);
  140. init_timer(&block->timer);
  141. block->timer.function = dasd_block_timeout;
  142. block->timer.data = (unsigned long) block;
  143. return block;
  144. }
  145. /*
  146. * Free memory of a device structure.
  147. */
  148. void dasd_free_block(struct dasd_block *block)
  149. {
  150. kfree(block);
  151. }
  152. /*
  153. * Make a new device known to the system.
  154. */
  155. static int dasd_state_new_to_known(struct dasd_device *device)
  156. {
  157. int rc;
  158. /*
  159. * As long as the device is not in state DASD_STATE_NEW we want to
  160. * keep the reference count > 0.
  161. */
  162. dasd_get_device(device);
  163. if (device->block) {
  164. rc = dasd_alloc_queue(device->block);
  165. if (rc) {
  166. dasd_put_device(device);
  167. return rc;
  168. }
  169. }
  170. device->state = DASD_STATE_KNOWN;
  171. return 0;
  172. }
  173. /*
  174. * Let the system forget about a device.
  175. */
  176. static int dasd_state_known_to_new(struct dasd_device *device)
  177. {
  178. /* Disable extended error reporting for this device. */
  179. dasd_eer_disable(device);
  180. /* Forget the discipline information. */
  181. if (device->discipline) {
  182. if (device->discipline->uncheck_device)
  183. device->discipline->uncheck_device(device);
  184. module_put(device->discipline->owner);
  185. }
  186. device->discipline = NULL;
  187. if (device->base_discipline)
  188. module_put(device->base_discipline->owner);
  189. device->base_discipline = NULL;
  190. device->state = DASD_STATE_NEW;
  191. if (device->block)
  192. dasd_free_queue(device->block);
  193. /* Give up reference we took in dasd_state_new_to_known. */
  194. dasd_put_device(device);
  195. return 0;
  196. }
  197. /*
  198. * Request the irq line for the device.
  199. */
  200. static int dasd_state_known_to_basic(struct dasd_device *device)
  201. {
  202. int rc;
  203. /* Allocate and register gendisk structure. */
  204. if (device->block) {
  205. rc = dasd_gendisk_alloc(device->block);
  206. if (rc)
  207. return rc;
  208. }
  209. /* register 'device' debug area, used for all DBF_DEV_XXX calls */
  210. device->debug_area = debug_register(dev_name(&device->cdev->dev), 4, 1,
  211. 8 * sizeof(long));
  212. debug_register_view(device->debug_area, &debug_sprintf_view);
  213. debug_set_level(device->debug_area, DBF_WARNING);
  214. DBF_DEV_EVENT(DBF_EMERG, device, "%s", "debug area created");
  215. device->state = DASD_STATE_BASIC;
  216. return 0;
  217. }
  218. /*
  219. * Release the irq line for the device. Terminate any running i/o.
  220. */
  221. static int dasd_state_basic_to_known(struct dasd_device *device)
  222. {
  223. int rc;
  224. if (device->block) {
  225. dasd_gendisk_free(device->block);
  226. dasd_block_clear_timer(device->block);
  227. }
  228. rc = dasd_flush_device_queue(device);
  229. if (rc)
  230. return rc;
  231. dasd_device_clear_timer(device);
  232. DBF_DEV_EVENT(DBF_EMERG, device, "%p debug area deleted", device);
  233. if (device->debug_area != NULL) {
  234. debug_unregister(device->debug_area);
  235. device->debug_area = NULL;
  236. }
  237. device->state = DASD_STATE_KNOWN;
  238. return 0;
  239. }
  240. /*
  241. * Do the initial analysis. The do_analysis function may return
  242. * -EAGAIN in which case the device keeps the state DASD_STATE_BASIC
  243. * until the discipline decides to continue the startup sequence
  244. * by calling the function dasd_change_state. The eckd disciplines
  245. * uses this to start a ccw that detects the format. The completion
  246. * interrupt for this detection ccw uses the kernel event daemon to
  247. * trigger the call to dasd_change_state. All this is done in the
  248. * discipline code, see dasd_eckd.c.
  249. * After the analysis ccw is done (do_analysis returned 0) the block
  250. * device is setup.
  251. * In case the analysis returns an error, the device setup is stopped
  252. * (a fake disk was already added to allow formatting).
  253. */
  254. static int dasd_state_basic_to_ready(struct dasd_device *device)
  255. {
  256. int rc;
  257. struct dasd_block *block;
  258. rc = 0;
  259. block = device->block;
  260. /* make disk known with correct capacity */
  261. if (block) {
  262. if (block->base->discipline->do_analysis != NULL)
  263. rc = block->base->discipline->do_analysis(block);
  264. if (rc) {
  265. if (rc != -EAGAIN)
  266. device->state = DASD_STATE_UNFMT;
  267. return rc;
  268. }
  269. dasd_setup_queue(block);
  270. set_capacity(block->gdp,
  271. block->blocks << block->s2b_shift);
  272. device->state = DASD_STATE_READY;
  273. rc = dasd_scan_partitions(block);
  274. if (rc)
  275. device->state = DASD_STATE_BASIC;
  276. } else {
  277. device->state = DASD_STATE_READY;
  278. }
  279. return rc;
  280. }
  281. /*
  282. * Remove device from block device layer. Destroy dirty buffers.
  283. * Forget format information. Check if the target level is basic
  284. * and if it is create fake disk for formatting.
  285. */
  286. static int dasd_state_ready_to_basic(struct dasd_device *device)
  287. {
  288. int rc;
  289. device->state = DASD_STATE_BASIC;
  290. if (device->block) {
  291. struct dasd_block *block = device->block;
  292. rc = dasd_flush_block_queue(block);
  293. if (rc) {
  294. device->state = DASD_STATE_READY;
  295. return rc;
  296. }
  297. dasd_flush_request_queue(block);
  298. dasd_destroy_partitions(block);
  299. block->blocks = 0;
  300. block->bp_block = 0;
  301. block->s2b_shift = 0;
  302. }
  303. return 0;
  304. }
  305. /*
  306. * Back to basic.
  307. */
  308. static int dasd_state_unfmt_to_basic(struct dasd_device *device)
  309. {
  310. device->state = DASD_STATE_BASIC;
  311. return 0;
  312. }
  313. /*
  314. * Make the device online and schedule the bottom half to start
  315. * the requeueing of requests from the linux request queue to the
  316. * ccw queue.
  317. */
  318. static int
  319. dasd_state_ready_to_online(struct dasd_device * device)
  320. {
  321. int rc;
  322. struct gendisk *disk;
  323. struct disk_part_iter piter;
  324. struct hd_struct *part;
  325. if (device->discipline->ready_to_online) {
  326. rc = device->discipline->ready_to_online(device);
  327. if (rc)
  328. return rc;
  329. }
  330. device->state = DASD_STATE_ONLINE;
  331. if (device->block) {
  332. dasd_schedule_block_bh(device->block);
  333. disk = device->block->bdev->bd_disk;
  334. disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0);
  335. while ((part = disk_part_iter_next(&piter)))
  336. kobject_uevent(&part_to_dev(part)->kobj, KOBJ_CHANGE);
  337. disk_part_iter_exit(&piter);
  338. }
  339. return 0;
  340. }
  341. /*
  342. * Stop the requeueing of requests again.
  343. */
  344. static int dasd_state_online_to_ready(struct dasd_device *device)
  345. {
  346. int rc;
  347. struct gendisk *disk;
  348. struct disk_part_iter piter;
  349. struct hd_struct *part;
  350. if (device->discipline->online_to_ready) {
  351. rc = device->discipline->online_to_ready(device);
  352. if (rc)
  353. return rc;
  354. }
  355. device->state = DASD_STATE_READY;
  356. if (device->block) {
  357. disk = device->block->bdev->bd_disk;
  358. disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0);
  359. while ((part = disk_part_iter_next(&piter)))
  360. kobject_uevent(&part_to_dev(part)->kobj, KOBJ_CHANGE);
  361. disk_part_iter_exit(&piter);
  362. }
  363. return 0;
  364. }
  365. /*
  366. * Device startup state changes.
  367. */
  368. static int dasd_increase_state(struct dasd_device *device)
  369. {
  370. int rc;
  371. rc = 0;
  372. if (device->state == DASD_STATE_NEW &&
  373. device->target >= DASD_STATE_KNOWN)
  374. rc = dasd_state_new_to_known(device);
  375. if (!rc &&
  376. device->state == DASD_STATE_KNOWN &&
  377. device->target >= DASD_STATE_BASIC)
  378. rc = dasd_state_known_to_basic(device);
  379. if (!rc &&
  380. device->state == DASD_STATE_BASIC &&
  381. device->target >= DASD_STATE_READY)
  382. rc = dasd_state_basic_to_ready(device);
  383. if (!rc &&
  384. device->state == DASD_STATE_UNFMT &&
  385. device->target > DASD_STATE_UNFMT)
  386. rc = -EPERM;
  387. if (!rc &&
  388. device->state == DASD_STATE_READY &&
  389. device->target >= DASD_STATE_ONLINE)
  390. rc = dasd_state_ready_to_online(device);
  391. return rc;
  392. }
  393. /*
  394. * Device shutdown state changes.
  395. */
  396. static int dasd_decrease_state(struct dasd_device *device)
  397. {
  398. int rc;
  399. rc = 0;
  400. if (device->state == DASD_STATE_ONLINE &&
  401. device->target <= DASD_STATE_READY)
  402. rc = dasd_state_online_to_ready(device);
  403. if (!rc &&
  404. device->state == DASD_STATE_READY &&
  405. device->target <= DASD_STATE_BASIC)
  406. rc = dasd_state_ready_to_basic(device);
  407. if (!rc &&
  408. device->state == DASD_STATE_UNFMT &&
  409. device->target <= DASD_STATE_BASIC)
  410. rc = dasd_state_unfmt_to_basic(device);
  411. if (!rc &&
  412. device->state == DASD_STATE_BASIC &&
  413. device->target <= DASD_STATE_KNOWN)
  414. rc = dasd_state_basic_to_known(device);
  415. if (!rc &&
  416. device->state == DASD_STATE_KNOWN &&
  417. device->target <= DASD_STATE_NEW)
  418. rc = dasd_state_known_to_new(device);
  419. return rc;
  420. }
  421. /*
  422. * This is the main startup/shutdown routine.
  423. */
  424. static void dasd_change_state(struct dasd_device *device)
  425. {
  426. int rc;
  427. if (device->state == device->target)
  428. /* Already where we want to go today... */
  429. return;
  430. if (device->state < device->target)
  431. rc = dasd_increase_state(device);
  432. else
  433. rc = dasd_decrease_state(device);
  434. if (rc == -EAGAIN)
  435. return;
  436. if (rc)
  437. device->target = device->state;
  438. if (device->state == device->target)
  439. wake_up(&dasd_init_waitq);
  440. /* let user-space know that the device status changed */
  441. kobject_uevent(&device->cdev->dev.kobj, KOBJ_CHANGE);
  442. }
  443. /*
  444. * Kick starter for devices that did not complete the startup/shutdown
  445. * procedure or were sleeping because of a pending state.
  446. * dasd_kick_device will schedule a call do do_kick_device to the kernel
  447. * event daemon.
  448. */
  449. static void do_kick_device(struct work_struct *work)
  450. {
  451. struct dasd_device *device = container_of(work, struct dasd_device, kick_work);
  452. mutex_lock(&device->state_mutex);
  453. dasd_change_state(device);
  454. mutex_unlock(&device->state_mutex);
  455. dasd_schedule_device_bh(device);
  456. dasd_put_device(device);
  457. }
  458. void dasd_kick_device(struct dasd_device *device)
  459. {
  460. dasd_get_device(device);
  461. /* queue call to dasd_kick_device to the kernel event daemon. */
  462. schedule_work(&device->kick_work);
  463. }
  464. /*
  465. * dasd_reload_device will schedule a call do do_reload_device to the kernel
  466. * event daemon.
  467. */
  468. static void do_reload_device(struct work_struct *work)
  469. {
  470. struct dasd_device *device = container_of(work, struct dasd_device,
  471. reload_device);
  472. device->discipline->reload(device);
  473. dasd_put_device(device);
  474. }
  475. void dasd_reload_device(struct dasd_device *device)
  476. {
  477. dasd_get_device(device);
  478. /* queue call to dasd_reload_device to the kernel event daemon. */
  479. schedule_work(&device->reload_device);
  480. }
  481. EXPORT_SYMBOL(dasd_reload_device);
  482. /*
  483. * dasd_restore_device will schedule a call do do_restore_device to the kernel
  484. * event daemon.
  485. */
  486. static void do_restore_device(struct work_struct *work)
  487. {
  488. struct dasd_device *device = container_of(work, struct dasd_device,
  489. restore_device);
  490. device->cdev->drv->restore(device->cdev);
  491. dasd_put_device(device);
  492. }
  493. void dasd_restore_device(struct dasd_device *device)
  494. {
  495. dasd_get_device(device);
  496. /* queue call to dasd_restore_device to the kernel event daemon. */
  497. schedule_work(&device->restore_device);
  498. }
  499. /*
  500. * Set the target state for a device and starts the state change.
  501. */
  502. void dasd_set_target_state(struct dasd_device *device, int target)
  503. {
  504. dasd_get_device(device);
  505. mutex_lock(&device->state_mutex);
  506. /* If we are in probeonly mode stop at DASD_STATE_READY. */
  507. if (dasd_probeonly && target > DASD_STATE_READY)
  508. target = DASD_STATE_READY;
  509. if (device->target != target) {
  510. if (device->state == target)
  511. wake_up(&dasd_init_waitq);
  512. device->target = target;
  513. }
  514. if (device->state != device->target)
  515. dasd_change_state(device);
  516. mutex_unlock(&device->state_mutex);
  517. dasd_put_device(device);
  518. }
  519. /*
  520. * Enable devices with device numbers in [from..to].
  521. */
  522. static inline int _wait_for_device(struct dasd_device *device)
  523. {
  524. return (device->state == device->target);
  525. }
  526. void dasd_enable_device(struct dasd_device *device)
  527. {
  528. dasd_set_target_state(device, DASD_STATE_ONLINE);
  529. if (device->state <= DASD_STATE_KNOWN)
  530. /* No discipline for device found. */
  531. dasd_set_target_state(device, DASD_STATE_NEW);
  532. /* Now wait for the devices to come up. */
  533. wait_event(dasd_init_waitq, _wait_for_device(device));
  534. }
  535. /*
  536. * SECTION: device operation (interrupt handler, start i/o, term i/o ...)
  537. */
  538. #ifdef CONFIG_DASD_PROFILE
  539. struct dasd_profile_info_t dasd_global_profile;
  540. unsigned int dasd_profile_level = DASD_PROFILE_OFF;
  541. /*
  542. * Increments counter in global and local profiling structures.
  543. */
  544. #define dasd_profile_counter(value, counter, block) \
  545. { \
  546. int index; \
  547. for (index = 0; index < 31 && value >> (2+index); index++); \
  548. dasd_global_profile.counter[index]++; \
  549. block->profile.counter[index]++; \
  550. }
  551. /*
  552. * Add profiling information for cqr before execution.
  553. */
  554. static void dasd_profile_start(struct dasd_block *block,
  555. struct dasd_ccw_req *cqr,
  556. struct request *req)
  557. {
  558. struct list_head *l;
  559. unsigned int counter;
  560. if (dasd_profile_level != DASD_PROFILE_ON)
  561. return;
  562. /* count the length of the chanq for statistics */
  563. counter = 0;
  564. list_for_each(l, &block->ccw_queue)
  565. if (++counter >= 31)
  566. break;
  567. dasd_global_profile.dasd_io_nr_req[counter]++;
  568. block->profile.dasd_io_nr_req[counter]++;
  569. }
  570. /*
  571. * Add profiling information for cqr after execution.
  572. */
  573. static void dasd_profile_end(struct dasd_block *block,
  574. struct dasd_ccw_req *cqr,
  575. struct request *req)
  576. {
  577. long strtime, irqtime, endtime, tottime; /* in microseconds */
  578. long tottimeps, sectors;
  579. if (dasd_profile_level != DASD_PROFILE_ON)
  580. return;
  581. sectors = blk_rq_sectors(req);
  582. if (!cqr->buildclk || !cqr->startclk ||
  583. !cqr->stopclk || !cqr->endclk ||
  584. !sectors)
  585. return;
  586. strtime = ((cqr->startclk - cqr->buildclk) >> 12);
  587. irqtime = ((cqr->stopclk - cqr->startclk) >> 12);
  588. endtime = ((cqr->endclk - cqr->stopclk) >> 12);
  589. tottime = ((cqr->endclk - cqr->buildclk) >> 12);
  590. tottimeps = tottime / sectors;
  591. if (!dasd_global_profile.dasd_io_reqs)
  592. memset(&dasd_global_profile, 0,
  593. sizeof(struct dasd_profile_info_t));
  594. dasd_global_profile.dasd_io_reqs++;
  595. dasd_global_profile.dasd_io_sects += sectors;
  596. if (!block->profile.dasd_io_reqs)
  597. memset(&block->profile, 0,
  598. sizeof(struct dasd_profile_info_t));
  599. block->profile.dasd_io_reqs++;
  600. block->profile.dasd_io_sects += sectors;
  601. dasd_profile_counter(sectors, dasd_io_secs, block);
  602. dasd_profile_counter(tottime, dasd_io_times, block);
  603. dasd_profile_counter(tottimeps, dasd_io_timps, block);
  604. dasd_profile_counter(strtime, dasd_io_time1, block);
  605. dasd_profile_counter(irqtime, dasd_io_time2, block);
  606. dasd_profile_counter(irqtime / sectors, dasd_io_time2ps, block);
  607. dasd_profile_counter(endtime, dasd_io_time3, block);
  608. }
  609. #else
  610. #define dasd_profile_start(block, cqr, req) do {} while (0)
  611. #define dasd_profile_end(block, cqr, req) do {} while (0)
  612. #endif /* CONFIG_DASD_PROFILE */
  613. /*
  614. * Allocate memory for a channel program with 'cplength' channel
  615. * command words and 'datasize' additional space. There are two
  616. * variantes: 1) dasd_kmalloc_request uses kmalloc to get the needed
  617. * memory and 2) dasd_smalloc_request uses the static ccw memory
  618. * that gets allocated for each device.
  619. */
  620. struct dasd_ccw_req *dasd_kmalloc_request(int magic, int cplength,
  621. int datasize,
  622. struct dasd_device *device)
  623. {
  624. struct dasd_ccw_req *cqr;
  625. /* Sanity checks */
  626. BUG_ON(datasize > PAGE_SIZE ||
  627. (cplength*sizeof(struct ccw1)) > PAGE_SIZE);
  628. cqr = kzalloc(sizeof(struct dasd_ccw_req), GFP_ATOMIC);
  629. if (cqr == NULL)
  630. return ERR_PTR(-ENOMEM);
  631. cqr->cpaddr = NULL;
  632. if (cplength > 0) {
  633. cqr->cpaddr = kcalloc(cplength, sizeof(struct ccw1),
  634. GFP_ATOMIC | GFP_DMA);
  635. if (cqr->cpaddr == NULL) {
  636. kfree(cqr);
  637. return ERR_PTR(-ENOMEM);
  638. }
  639. }
  640. cqr->data = NULL;
  641. if (datasize > 0) {
  642. cqr->data = kzalloc(datasize, GFP_ATOMIC | GFP_DMA);
  643. if (cqr->data == NULL) {
  644. kfree(cqr->cpaddr);
  645. kfree(cqr);
  646. return ERR_PTR(-ENOMEM);
  647. }
  648. }
  649. cqr->magic = magic;
  650. set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
  651. dasd_get_device(device);
  652. return cqr;
  653. }
  654. struct dasd_ccw_req *dasd_smalloc_request(int magic, int cplength,
  655. int datasize,
  656. struct dasd_device *device)
  657. {
  658. unsigned long flags;
  659. struct dasd_ccw_req *cqr;
  660. char *data;
  661. int size;
  662. size = (sizeof(struct dasd_ccw_req) + 7L) & -8L;
  663. if (cplength > 0)
  664. size += cplength * sizeof(struct ccw1);
  665. if (datasize > 0)
  666. size += datasize;
  667. spin_lock_irqsave(&device->mem_lock, flags);
  668. cqr = (struct dasd_ccw_req *)
  669. dasd_alloc_chunk(&device->ccw_chunks, size);
  670. spin_unlock_irqrestore(&device->mem_lock, flags);
  671. if (cqr == NULL)
  672. return ERR_PTR(-ENOMEM);
  673. memset(cqr, 0, sizeof(struct dasd_ccw_req));
  674. data = (char *) cqr + ((sizeof(struct dasd_ccw_req) + 7L) & -8L);
  675. cqr->cpaddr = NULL;
  676. if (cplength > 0) {
  677. cqr->cpaddr = (struct ccw1 *) data;
  678. data += cplength*sizeof(struct ccw1);
  679. memset(cqr->cpaddr, 0, cplength*sizeof(struct ccw1));
  680. }
  681. cqr->data = NULL;
  682. if (datasize > 0) {
  683. cqr->data = data;
  684. memset(cqr->data, 0, datasize);
  685. }
  686. cqr->magic = magic;
  687. set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
  688. dasd_get_device(device);
  689. return cqr;
  690. }
  691. /*
  692. * Free memory of a channel program. This function needs to free all the
  693. * idal lists that might have been created by dasd_set_cda and the
  694. * struct dasd_ccw_req itself.
  695. */
  696. void dasd_kfree_request(struct dasd_ccw_req *cqr, struct dasd_device *device)
  697. {
  698. #ifdef CONFIG_64BIT
  699. struct ccw1 *ccw;
  700. /* Clear any idals used for the request. */
  701. ccw = cqr->cpaddr;
  702. do {
  703. clear_normalized_cda(ccw);
  704. } while (ccw++->flags & (CCW_FLAG_CC | CCW_FLAG_DC));
  705. #endif
  706. kfree(cqr->cpaddr);
  707. kfree(cqr->data);
  708. kfree(cqr);
  709. dasd_put_device(device);
  710. }
  711. void dasd_sfree_request(struct dasd_ccw_req *cqr, struct dasd_device *device)
  712. {
  713. unsigned long flags;
  714. spin_lock_irqsave(&device->mem_lock, flags);
  715. dasd_free_chunk(&device->ccw_chunks, cqr);
  716. spin_unlock_irqrestore(&device->mem_lock, flags);
  717. dasd_put_device(device);
  718. }
  719. /*
  720. * Check discipline magic in cqr.
  721. */
  722. static inline int dasd_check_cqr(struct dasd_ccw_req *cqr)
  723. {
  724. struct dasd_device *device;
  725. if (cqr == NULL)
  726. return -EINVAL;
  727. device = cqr->startdev;
  728. if (strncmp((char *) &cqr->magic, device->discipline->ebcname, 4)) {
  729. DBF_DEV_EVENT(DBF_WARNING, device,
  730. " dasd_ccw_req 0x%08x magic doesn't match"
  731. " discipline 0x%08x",
  732. cqr->magic,
  733. *(unsigned int *) device->discipline->name);
  734. return -EINVAL;
  735. }
  736. return 0;
  737. }
  738. /*
  739. * Terminate the current i/o and set the request to clear_pending.
  740. * Timer keeps device runnig.
  741. * ccw_device_clear can fail if the i/o subsystem
  742. * is in a bad mood.
  743. */
  744. int dasd_term_IO(struct dasd_ccw_req *cqr)
  745. {
  746. struct dasd_device *device;
  747. int retries, rc;
  748. char errorstring[ERRORLENGTH];
  749. /* Check the cqr */
  750. rc = dasd_check_cqr(cqr);
  751. if (rc)
  752. return rc;
  753. retries = 0;
  754. device = (struct dasd_device *) cqr->startdev;
  755. while ((retries < 5) && (cqr->status == DASD_CQR_IN_IO)) {
  756. rc = ccw_device_clear(device->cdev, (long) cqr);
  757. switch (rc) {
  758. case 0: /* termination successful */
  759. cqr->retries--;
  760. cqr->status = DASD_CQR_CLEAR_PENDING;
  761. cqr->stopclk = get_clock();
  762. cqr->starttime = 0;
  763. DBF_DEV_EVENT(DBF_DEBUG, device,
  764. "terminate cqr %p successful",
  765. cqr);
  766. break;
  767. case -ENODEV:
  768. DBF_DEV_EVENT(DBF_ERR, device, "%s",
  769. "device gone, retry");
  770. break;
  771. case -EIO:
  772. DBF_DEV_EVENT(DBF_ERR, device, "%s",
  773. "I/O error, retry");
  774. break;
  775. case -EINVAL:
  776. case -EBUSY:
  777. DBF_DEV_EVENT(DBF_ERR, device, "%s",
  778. "device busy, retry later");
  779. break;
  780. default:
  781. /* internal error 10 - unknown rc*/
  782. snprintf(errorstring, ERRORLENGTH, "10 %d", rc);
  783. dev_err(&device->cdev->dev, "An error occurred in the "
  784. "DASD device driver, reason=%s\n", errorstring);
  785. BUG();
  786. break;
  787. }
  788. retries++;
  789. }
  790. dasd_schedule_device_bh(device);
  791. return rc;
  792. }
  793. /*
  794. * Start the i/o. This start_IO can fail if the channel is really busy.
  795. * In that case set up a timer to start the request later.
  796. */
  797. int dasd_start_IO(struct dasd_ccw_req *cqr)
  798. {
  799. struct dasd_device *device;
  800. int rc;
  801. char errorstring[ERRORLENGTH];
  802. /* Check the cqr */
  803. rc = dasd_check_cqr(cqr);
  804. if (rc) {
  805. cqr->intrc = rc;
  806. return rc;
  807. }
  808. device = (struct dasd_device *) cqr->startdev;
  809. if (((cqr->block &&
  810. test_bit(DASD_FLAG_LOCK_STOLEN, &cqr->block->base->flags)) ||
  811. test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags)) &&
  812. !test_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags)) {
  813. DBF_DEV_EVENT(DBF_DEBUG, device, "start_IO: return request %p "
  814. "because of stolen lock", cqr);
  815. cqr->status = DASD_CQR_ERROR;
  816. cqr->intrc = -EPERM;
  817. return -EPERM;
  818. }
  819. if (cqr->retries < 0) {
  820. /* internal error 14 - start_IO run out of retries */
  821. sprintf(errorstring, "14 %p", cqr);
  822. dev_err(&device->cdev->dev, "An error occurred in the DASD "
  823. "device driver, reason=%s\n", errorstring);
  824. cqr->status = DASD_CQR_ERROR;
  825. return -EIO;
  826. }
  827. cqr->startclk = get_clock();
  828. cqr->starttime = jiffies;
  829. cqr->retries--;
  830. if (!test_bit(DASD_CQR_VERIFY_PATH, &cqr->flags)) {
  831. cqr->lpm &= device->path_data.opm;
  832. if (!cqr->lpm)
  833. cqr->lpm = device->path_data.opm;
  834. }
  835. if (cqr->cpmode == 1) {
  836. rc = ccw_device_tm_start(device->cdev, cqr->cpaddr,
  837. (long) cqr, cqr->lpm);
  838. } else {
  839. rc = ccw_device_start(device->cdev, cqr->cpaddr,
  840. (long) cqr, cqr->lpm, 0);
  841. }
  842. switch (rc) {
  843. case 0:
  844. cqr->status = DASD_CQR_IN_IO;
  845. break;
  846. case -EBUSY:
  847. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  848. "start_IO: device busy, retry later");
  849. break;
  850. case -ETIMEDOUT:
  851. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  852. "start_IO: request timeout, retry later");
  853. break;
  854. case -EACCES:
  855. /* -EACCES indicates that the request used only a subset of the
  856. * available paths and all these paths are gone. If the lpm of
  857. * this request was only a subset of the opm (e.g. the ppm) then
  858. * we just do a retry with all available paths.
  859. * If we already use the full opm, something is amiss, and we
  860. * need a full path verification.
  861. */
  862. if (test_bit(DASD_CQR_VERIFY_PATH, &cqr->flags)) {
  863. DBF_DEV_EVENT(DBF_WARNING, device,
  864. "start_IO: selected paths gone (%x)",
  865. cqr->lpm);
  866. } else if (cqr->lpm != device->path_data.opm) {
  867. cqr->lpm = device->path_data.opm;
  868. DBF_DEV_EVENT(DBF_DEBUG, device, "%s",
  869. "start_IO: selected paths gone,"
  870. " retry on all paths");
  871. } else {
  872. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  873. "start_IO: all paths in opm gone,"
  874. " do path verification");
  875. dasd_generic_last_path_gone(device);
  876. device->path_data.opm = 0;
  877. device->path_data.ppm = 0;
  878. device->path_data.npm = 0;
  879. device->path_data.tbvpm =
  880. ccw_device_get_path_mask(device->cdev);
  881. }
  882. break;
  883. case -ENODEV:
  884. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  885. "start_IO: -ENODEV device gone, retry");
  886. break;
  887. case -EIO:
  888. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  889. "start_IO: -EIO device gone, retry");
  890. break;
  891. case -EINVAL:
  892. /* most likely caused in power management context */
  893. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  894. "start_IO: -EINVAL device currently "
  895. "not accessible");
  896. break;
  897. default:
  898. /* internal error 11 - unknown rc */
  899. snprintf(errorstring, ERRORLENGTH, "11 %d", rc);
  900. dev_err(&device->cdev->dev,
  901. "An error occurred in the DASD device driver, "
  902. "reason=%s\n", errorstring);
  903. BUG();
  904. break;
  905. }
  906. cqr->intrc = rc;
  907. return rc;
  908. }
  909. /*
  910. * Timeout function for dasd devices. This is used for different purposes
  911. * 1) missing interrupt handler for normal operation
  912. * 2) delayed start of request where start_IO failed with -EBUSY
  913. * 3) timeout for missing state change interrupts
  914. * The head of the ccw queue will have status DASD_CQR_IN_IO for 1),
  915. * DASD_CQR_QUEUED for 2) and 3).
  916. */
  917. static void dasd_device_timeout(unsigned long ptr)
  918. {
  919. unsigned long flags;
  920. struct dasd_device *device;
  921. device = (struct dasd_device *) ptr;
  922. spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
  923. /* re-activate request queue */
  924. dasd_device_remove_stop_bits(device, DASD_STOPPED_PENDING);
  925. spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
  926. dasd_schedule_device_bh(device);
  927. }
  928. /*
  929. * Setup timeout for a device in jiffies.
  930. */
  931. void dasd_device_set_timer(struct dasd_device *device, int expires)
  932. {
  933. if (expires == 0)
  934. del_timer(&device->timer);
  935. else
  936. mod_timer(&device->timer, jiffies + expires);
  937. }
  938. /*
  939. * Clear timeout for a device.
  940. */
  941. void dasd_device_clear_timer(struct dasd_device *device)
  942. {
  943. del_timer(&device->timer);
  944. }
  945. static void dasd_handle_killed_request(struct ccw_device *cdev,
  946. unsigned long intparm)
  947. {
  948. struct dasd_ccw_req *cqr;
  949. struct dasd_device *device;
  950. if (!intparm)
  951. return;
  952. cqr = (struct dasd_ccw_req *) intparm;
  953. if (cqr->status != DASD_CQR_IN_IO) {
  954. DBF_EVENT_DEVID(DBF_DEBUG, cdev,
  955. "invalid status in handle_killed_request: "
  956. "%02x", cqr->status);
  957. return;
  958. }
  959. device = dasd_device_from_cdev_locked(cdev);
  960. if (IS_ERR(device)) {
  961. DBF_EVENT_DEVID(DBF_DEBUG, cdev, "%s",
  962. "unable to get device from cdev");
  963. return;
  964. }
  965. if (!cqr->startdev ||
  966. device != cqr->startdev ||
  967. strncmp(cqr->startdev->discipline->ebcname,
  968. (char *) &cqr->magic, 4)) {
  969. DBF_EVENT_DEVID(DBF_DEBUG, cdev, "%s",
  970. "invalid device in request");
  971. dasd_put_device(device);
  972. return;
  973. }
  974. /* Schedule request to be retried. */
  975. cqr->status = DASD_CQR_QUEUED;
  976. dasd_device_clear_timer(device);
  977. dasd_schedule_device_bh(device);
  978. dasd_put_device(device);
  979. }
  980. void dasd_generic_handle_state_change(struct dasd_device *device)
  981. {
  982. /* First of all start sense subsystem status request. */
  983. dasd_eer_snss(device);
  984. dasd_device_remove_stop_bits(device, DASD_STOPPED_PENDING);
  985. dasd_schedule_device_bh(device);
  986. if (device->block)
  987. dasd_schedule_block_bh(device->block);
  988. }
  989. /*
  990. * Interrupt handler for "normal" ssch-io based dasd devices.
  991. */
  992. void dasd_int_handler(struct ccw_device *cdev, unsigned long intparm,
  993. struct irb *irb)
  994. {
  995. struct dasd_ccw_req *cqr, *next;
  996. struct dasd_device *device;
  997. unsigned long long now;
  998. int expires;
  999. kstat_cpu(smp_processor_id()).irqs[IOINT_DAS]++;
  1000. if (IS_ERR(irb)) {
  1001. switch (PTR_ERR(irb)) {
  1002. case -EIO:
  1003. break;
  1004. case -ETIMEDOUT:
  1005. DBF_EVENT_DEVID(DBF_WARNING, cdev, "%s: "
  1006. "request timed out\n", __func__);
  1007. break;
  1008. default:
  1009. DBF_EVENT_DEVID(DBF_WARNING, cdev, "%s: "
  1010. "unknown error %ld\n", __func__,
  1011. PTR_ERR(irb));
  1012. }
  1013. dasd_handle_killed_request(cdev, intparm);
  1014. return;
  1015. }
  1016. now = get_clock();
  1017. cqr = (struct dasd_ccw_req *) intparm;
  1018. /* check for conditions that should be handled immediately */
  1019. if (!cqr ||
  1020. !(scsw_dstat(&irb->scsw) == (DEV_STAT_CHN_END | DEV_STAT_DEV_END) &&
  1021. scsw_cstat(&irb->scsw) == 0)) {
  1022. if (cqr)
  1023. memcpy(&cqr->irb, irb, sizeof(*irb));
  1024. device = dasd_device_from_cdev_locked(cdev);
  1025. if (IS_ERR(device))
  1026. return;
  1027. /* ignore unsolicited interrupts for DIAG discipline */
  1028. if (device->discipline == dasd_diag_discipline_pointer) {
  1029. dasd_put_device(device);
  1030. return;
  1031. }
  1032. device->discipline->dump_sense_dbf(device, irb, "int");
  1033. if (device->features & DASD_FEATURE_ERPLOG)
  1034. device->discipline->dump_sense(device, cqr, irb);
  1035. device->discipline->check_for_device_change(device, cqr, irb);
  1036. dasd_put_device(device);
  1037. }
  1038. if (!cqr)
  1039. return;
  1040. device = (struct dasd_device *) cqr->startdev;
  1041. if (!device ||
  1042. strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) {
  1043. DBF_EVENT_DEVID(DBF_DEBUG, cdev, "%s",
  1044. "invalid device in request");
  1045. return;
  1046. }
  1047. /* Check for clear pending */
  1048. if (cqr->status == DASD_CQR_CLEAR_PENDING &&
  1049. scsw_fctl(&irb->scsw) & SCSW_FCTL_CLEAR_FUNC) {
  1050. cqr->status = DASD_CQR_CLEARED;
  1051. dasd_device_clear_timer(device);
  1052. wake_up(&dasd_flush_wq);
  1053. dasd_schedule_device_bh(device);
  1054. return;
  1055. }
  1056. /* check status - the request might have been killed by dyn detach */
  1057. if (cqr->status != DASD_CQR_IN_IO) {
  1058. DBF_DEV_EVENT(DBF_DEBUG, device, "invalid status: bus_id %s, "
  1059. "status %02x", dev_name(&cdev->dev), cqr->status);
  1060. return;
  1061. }
  1062. next = NULL;
  1063. expires = 0;
  1064. if (scsw_dstat(&irb->scsw) == (DEV_STAT_CHN_END | DEV_STAT_DEV_END) &&
  1065. scsw_cstat(&irb->scsw) == 0) {
  1066. /* request was completed successfully */
  1067. cqr->status = DASD_CQR_SUCCESS;
  1068. cqr->stopclk = now;
  1069. /* Start first request on queue if possible -> fast_io. */
  1070. if (cqr->devlist.next != &device->ccw_queue) {
  1071. next = list_entry(cqr->devlist.next,
  1072. struct dasd_ccw_req, devlist);
  1073. }
  1074. } else { /* error */
  1075. /*
  1076. * If we don't want complex ERP for this request, then just
  1077. * reset this and retry it in the fastpath
  1078. */
  1079. if (!test_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags) &&
  1080. cqr->retries > 0) {
  1081. if (cqr->lpm == device->path_data.opm)
  1082. DBF_DEV_EVENT(DBF_DEBUG, device,
  1083. "default ERP in fastpath "
  1084. "(%i retries left)",
  1085. cqr->retries);
  1086. if (!test_bit(DASD_CQR_VERIFY_PATH, &cqr->flags))
  1087. cqr->lpm = device->path_data.opm;
  1088. cqr->status = DASD_CQR_QUEUED;
  1089. next = cqr;
  1090. } else
  1091. cqr->status = DASD_CQR_ERROR;
  1092. }
  1093. if (next && (next->status == DASD_CQR_QUEUED) &&
  1094. (!device->stopped)) {
  1095. if (device->discipline->start_IO(next) == 0)
  1096. expires = next->expires;
  1097. }
  1098. if (expires != 0)
  1099. dasd_device_set_timer(device, expires);
  1100. else
  1101. dasd_device_clear_timer(device);
  1102. dasd_schedule_device_bh(device);
  1103. }
  1104. enum uc_todo dasd_generic_uc_handler(struct ccw_device *cdev, struct irb *irb)
  1105. {
  1106. struct dasd_device *device;
  1107. device = dasd_device_from_cdev_locked(cdev);
  1108. if (IS_ERR(device))
  1109. goto out;
  1110. if (test_bit(DASD_FLAG_OFFLINE, &device->flags) ||
  1111. device->state != device->target ||
  1112. !device->discipline->check_for_device_change){
  1113. dasd_put_device(device);
  1114. goto out;
  1115. }
  1116. if (device->discipline->dump_sense_dbf)
  1117. device->discipline->dump_sense_dbf(device, irb, "uc");
  1118. device->discipline->check_for_device_change(device, NULL, irb);
  1119. dasd_put_device(device);
  1120. out:
  1121. return UC_TODO_RETRY;
  1122. }
  1123. EXPORT_SYMBOL_GPL(dasd_generic_uc_handler);
  1124. /*
  1125. * If we have an error on a dasd_block layer request then we cancel
  1126. * and return all further requests from the same dasd_block as well.
  1127. */
  1128. static void __dasd_device_recovery(struct dasd_device *device,
  1129. struct dasd_ccw_req *ref_cqr)
  1130. {
  1131. struct list_head *l, *n;
  1132. struct dasd_ccw_req *cqr;
  1133. /*
  1134. * only requeue request that came from the dasd_block layer
  1135. */
  1136. if (!ref_cqr->block)
  1137. return;
  1138. list_for_each_safe(l, n, &device->ccw_queue) {
  1139. cqr = list_entry(l, struct dasd_ccw_req, devlist);
  1140. if (cqr->status == DASD_CQR_QUEUED &&
  1141. ref_cqr->block == cqr->block) {
  1142. cqr->status = DASD_CQR_CLEARED;
  1143. }
  1144. }
  1145. };
  1146. /*
  1147. * Remove those ccw requests from the queue that need to be returned
  1148. * to the upper layer.
  1149. */
  1150. static void __dasd_device_process_ccw_queue(struct dasd_device *device,
  1151. struct list_head *final_queue)
  1152. {
  1153. struct list_head *l, *n;
  1154. struct dasd_ccw_req *cqr;
  1155. /* Process request with final status. */
  1156. list_for_each_safe(l, n, &device->ccw_queue) {
  1157. cqr = list_entry(l, struct dasd_ccw_req, devlist);
  1158. /* Stop list processing at the first non-final request. */
  1159. if (cqr->status == DASD_CQR_QUEUED ||
  1160. cqr->status == DASD_CQR_IN_IO ||
  1161. cqr->status == DASD_CQR_CLEAR_PENDING)
  1162. break;
  1163. if (cqr->status == DASD_CQR_ERROR) {
  1164. __dasd_device_recovery(device, cqr);
  1165. }
  1166. /* Rechain finished requests to final queue */
  1167. list_move_tail(&cqr->devlist, final_queue);
  1168. }
  1169. }
  1170. /*
  1171. * the cqrs from the final queue are returned to the upper layer
  1172. * by setting a dasd_block state and calling the callback function
  1173. */
  1174. static void __dasd_device_process_final_queue(struct dasd_device *device,
  1175. struct list_head *final_queue)
  1176. {
  1177. struct list_head *l, *n;
  1178. struct dasd_ccw_req *cqr;
  1179. struct dasd_block *block;
  1180. void (*callback)(struct dasd_ccw_req *, void *data);
  1181. void *callback_data;
  1182. char errorstring[ERRORLENGTH];
  1183. list_for_each_safe(l, n, final_queue) {
  1184. cqr = list_entry(l, struct dasd_ccw_req, devlist);
  1185. list_del_init(&cqr->devlist);
  1186. block = cqr->block;
  1187. callback = cqr->callback;
  1188. callback_data = cqr->callback_data;
  1189. if (block)
  1190. spin_lock_bh(&block->queue_lock);
  1191. switch (cqr->status) {
  1192. case DASD_CQR_SUCCESS:
  1193. cqr->status = DASD_CQR_DONE;
  1194. break;
  1195. case DASD_CQR_ERROR:
  1196. cqr->status = DASD_CQR_NEED_ERP;
  1197. break;
  1198. case DASD_CQR_CLEARED:
  1199. cqr->status = DASD_CQR_TERMINATED;
  1200. break;
  1201. default:
  1202. /* internal error 12 - wrong cqr status*/
  1203. snprintf(errorstring, ERRORLENGTH, "12 %p %x02", cqr, cqr->status);
  1204. dev_err(&device->cdev->dev,
  1205. "An error occurred in the DASD device driver, "
  1206. "reason=%s\n", errorstring);
  1207. BUG();
  1208. }
  1209. if (cqr->callback != NULL)
  1210. (callback)(cqr, callback_data);
  1211. if (block)
  1212. spin_unlock_bh(&block->queue_lock);
  1213. }
  1214. }
  1215. /*
  1216. * Take a look at the first request on the ccw queue and check
  1217. * if it reached its expire time. If so, terminate the IO.
  1218. */
  1219. static void __dasd_device_check_expire(struct dasd_device *device)
  1220. {
  1221. struct dasd_ccw_req *cqr;
  1222. if (list_empty(&device->ccw_queue))
  1223. return;
  1224. cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist);
  1225. if ((cqr->status == DASD_CQR_IN_IO && cqr->expires != 0) &&
  1226. (time_after_eq(jiffies, cqr->expires + cqr->starttime))) {
  1227. if (device->discipline->term_IO(cqr) != 0) {
  1228. /* Hmpf, try again in 5 sec */
  1229. dev_err(&device->cdev->dev,
  1230. "cqr %p timed out (%lus) but cannot be "
  1231. "ended, retrying in 5 s\n",
  1232. cqr, (cqr->expires/HZ));
  1233. cqr->expires += 5*HZ;
  1234. dasd_device_set_timer(device, 5*HZ);
  1235. } else {
  1236. dev_err(&device->cdev->dev,
  1237. "cqr %p timed out (%lus), %i retries "
  1238. "remaining\n", cqr, (cqr->expires/HZ),
  1239. cqr->retries);
  1240. }
  1241. }
  1242. }
  1243. /*
  1244. * Take a look at the first request on the ccw queue and check
  1245. * if it needs to be started.
  1246. */
  1247. static void __dasd_device_start_head(struct dasd_device *device)
  1248. {
  1249. struct dasd_ccw_req *cqr;
  1250. int rc;
  1251. if (list_empty(&device->ccw_queue))
  1252. return;
  1253. cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist);
  1254. if (cqr->status != DASD_CQR_QUEUED)
  1255. return;
  1256. /* when device is stopped, return request to previous layer
  1257. * exception: only the disconnect or unresumed bits are set and the
  1258. * cqr is a path verification request
  1259. */
  1260. if (device->stopped &&
  1261. !(!(device->stopped & ~(DASD_STOPPED_DC_WAIT | DASD_UNRESUMED_PM))
  1262. && test_bit(DASD_CQR_VERIFY_PATH, &cqr->flags))) {
  1263. cqr->intrc = -EAGAIN;
  1264. cqr->status = DASD_CQR_CLEARED;
  1265. dasd_schedule_device_bh(device);
  1266. return;
  1267. }
  1268. rc = device->discipline->start_IO(cqr);
  1269. if (rc == 0)
  1270. dasd_device_set_timer(device, cqr->expires);
  1271. else if (rc == -EACCES) {
  1272. dasd_schedule_device_bh(device);
  1273. } else
  1274. /* Hmpf, try again in 1/2 sec */
  1275. dasd_device_set_timer(device, 50);
  1276. }
  1277. static void __dasd_device_check_path_events(struct dasd_device *device)
  1278. {
  1279. int rc;
  1280. if (device->path_data.tbvpm) {
  1281. if (device->stopped & ~(DASD_STOPPED_DC_WAIT |
  1282. DASD_UNRESUMED_PM))
  1283. return;
  1284. rc = device->discipline->verify_path(
  1285. device, device->path_data.tbvpm);
  1286. if (rc)
  1287. dasd_device_set_timer(device, 50);
  1288. else
  1289. device->path_data.tbvpm = 0;
  1290. }
  1291. };
  1292. /*
  1293. * Go through all request on the dasd_device request queue,
  1294. * terminate them on the cdev if necessary, and return them to the
  1295. * submitting layer via callback.
  1296. * Note:
  1297. * Make sure that all 'submitting layers' still exist when
  1298. * this function is called!. In other words, when 'device' is a base
  1299. * device then all block layer requests must have been removed before
  1300. * via dasd_flush_block_queue.
  1301. */
  1302. int dasd_flush_device_queue(struct dasd_device *device)
  1303. {
  1304. struct dasd_ccw_req *cqr, *n;
  1305. int rc;
  1306. struct list_head flush_queue;
  1307. INIT_LIST_HEAD(&flush_queue);
  1308. spin_lock_irq(get_ccwdev_lock(device->cdev));
  1309. rc = 0;
  1310. list_for_each_entry_safe(cqr, n, &device->ccw_queue, devlist) {
  1311. /* Check status and move request to flush_queue */
  1312. switch (cqr->status) {
  1313. case DASD_CQR_IN_IO:
  1314. rc = device->discipline->term_IO(cqr);
  1315. if (rc) {
  1316. /* unable to terminate requeust */
  1317. dev_err(&device->cdev->dev,
  1318. "Flushing the DASD request queue "
  1319. "failed for request %p\n", cqr);
  1320. /* stop flush processing */
  1321. goto finished;
  1322. }
  1323. break;
  1324. case DASD_CQR_QUEUED:
  1325. cqr->stopclk = get_clock();
  1326. cqr->status = DASD_CQR_CLEARED;
  1327. break;
  1328. default: /* no need to modify the others */
  1329. break;
  1330. }
  1331. list_move_tail(&cqr->devlist, &flush_queue);
  1332. }
  1333. finished:
  1334. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  1335. /*
  1336. * After this point all requests must be in state CLEAR_PENDING,
  1337. * CLEARED, SUCCESS or ERROR. Now wait for CLEAR_PENDING to become
  1338. * one of the others.
  1339. */
  1340. list_for_each_entry_safe(cqr, n, &flush_queue, devlist)
  1341. wait_event(dasd_flush_wq,
  1342. (cqr->status != DASD_CQR_CLEAR_PENDING));
  1343. /*
  1344. * Now set each request back to TERMINATED, DONE or NEED_ERP
  1345. * and call the callback function of flushed requests
  1346. */
  1347. __dasd_device_process_final_queue(device, &flush_queue);
  1348. return rc;
  1349. }
  1350. /*
  1351. * Acquire the device lock and process queues for the device.
  1352. */
  1353. static void dasd_device_tasklet(struct dasd_device *device)
  1354. {
  1355. struct list_head final_queue;
  1356. atomic_set (&device->tasklet_scheduled, 0);
  1357. INIT_LIST_HEAD(&final_queue);
  1358. spin_lock_irq(get_ccwdev_lock(device->cdev));
  1359. /* Check expire time of first request on the ccw queue. */
  1360. __dasd_device_check_expire(device);
  1361. /* find final requests on ccw queue */
  1362. __dasd_device_process_ccw_queue(device, &final_queue);
  1363. __dasd_device_check_path_events(device);
  1364. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  1365. /* Now call the callback function of requests with final status */
  1366. __dasd_device_process_final_queue(device, &final_queue);
  1367. spin_lock_irq(get_ccwdev_lock(device->cdev));
  1368. /* Now check if the head of the ccw queue needs to be started. */
  1369. __dasd_device_start_head(device);
  1370. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  1371. dasd_put_device(device);
  1372. }
  1373. /*
  1374. * Schedules a call to dasd_tasklet over the device tasklet.
  1375. */
  1376. void dasd_schedule_device_bh(struct dasd_device *device)
  1377. {
  1378. /* Protect against rescheduling. */
  1379. if (atomic_cmpxchg (&device->tasklet_scheduled, 0, 1) != 0)
  1380. return;
  1381. dasd_get_device(device);
  1382. tasklet_hi_schedule(&device->tasklet);
  1383. }
  1384. void dasd_device_set_stop_bits(struct dasd_device *device, int bits)
  1385. {
  1386. device->stopped |= bits;
  1387. }
  1388. EXPORT_SYMBOL_GPL(dasd_device_set_stop_bits);
  1389. void dasd_device_remove_stop_bits(struct dasd_device *device, int bits)
  1390. {
  1391. device->stopped &= ~bits;
  1392. if (!device->stopped)
  1393. wake_up(&generic_waitq);
  1394. }
  1395. EXPORT_SYMBOL_GPL(dasd_device_remove_stop_bits);
  1396. /*
  1397. * Queue a request to the head of the device ccw_queue.
  1398. * Start the I/O if possible.
  1399. */
  1400. void dasd_add_request_head(struct dasd_ccw_req *cqr)
  1401. {
  1402. struct dasd_device *device;
  1403. unsigned long flags;
  1404. device = cqr->startdev;
  1405. spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
  1406. cqr->status = DASD_CQR_QUEUED;
  1407. list_add(&cqr->devlist, &device->ccw_queue);
  1408. /* let the bh start the request to keep them in order */
  1409. dasd_schedule_device_bh(device);
  1410. spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
  1411. }
  1412. /*
  1413. * Queue a request to the tail of the device ccw_queue.
  1414. * Start the I/O if possible.
  1415. */
  1416. void dasd_add_request_tail(struct dasd_ccw_req *cqr)
  1417. {
  1418. struct dasd_device *device;
  1419. unsigned long flags;
  1420. device = cqr->startdev;
  1421. spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
  1422. cqr->status = DASD_CQR_QUEUED;
  1423. list_add_tail(&cqr->devlist, &device->ccw_queue);
  1424. /* let the bh start the request to keep them in order */
  1425. dasd_schedule_device_bh(device);
  1426. spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
  1427. }
  1428. /*
  1429. * Wakeup helper for the 'sleep_on' functions.
  1430. */
  1431. static void dasd_wakeup_cb(struct dasd_ccw_req *cqr, void *data)
  1432. {
  1433. spin_lock_irq(get_ccwdev_lock(cqr->startdev->cdev));
  1434. cqr->callback_data = DASD_SLEEPON_END_TAG;
  1435. spin_unlock_irq(get_ccwdev_lock(cqr->startdev->cdev));
  1436. wake_up(&generic_waitq);
  1437. }
  1438. static inline int _wait_for_wakeup(struct dasd_ccw_req *cqr)
  1439. {
  1440. struct dasd_device *device;
  1441. int rc;
  1442. device = cqr->startdev;
  1443. spin_lock_irq(get_ccwdev_lock(device->cdev));
  1444. rc = (cqr->callback_data == DASD_SLEEPON_END_TAG);
  1445. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  1446. return rc;
  1447. }
  1448. /*
  1449. * checks if error recovery is necessary, returns 1 if yes, 0 otherwise.
  1450. */
  1451. static int __dasd_sleep_on_erp(struct dasd_ccw_req *cqr)
  1452. {
  1453. struct dasd_device *device;
  1454. dasd_erp_fn_t erp_fn;
  1455. if (cqr->status == DASD_CQR_FILLED)
  1456. return 0;
  1457. device = cqr->startdev;
  1458. if (test_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags)) {
  1459. if (cqr->status == DASD_CQR_TERMINATED) {
  1460. device->discipline->handle_terminated_request(cqr);
  1461. return 1;
  1462. }
  1463. if (cqr->status == DASD_CQR_NEED_ERP) {
  1464. erp_fn = device->discipline->erp_action(cqr);
  1465. erp_fn(cqr);
  1466. return 1;
  1467. }
  1468. if (cqr->status == DASD_CQR_FAILED)
  1469. dasd_log_sense(cqr, &cqr->irb);
  1470. if (cqr->refers) {
  1471. __dasd_process_erp(device, cqr);
  1472. return 1;
  1473. }
  1474. }
  1475. return 0;
  1476. }
  1477. static int __dasd_sleep_on_loop_condition(struct dasd_ccw_req *cqr)
  1478. {
  1479. if (test_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags)) {
  1480. if (cqr->refers) /* erp is not done yet */
  1481. return 1;
  1482. return ((cqr->status != DASD_CQR_DONE) &&
  1483. (cqr->status != DASD_CQR_FAILED));
  1484. } else
  1485. return (cqr->status == DASD_CQR_FILLED);
  1486. }
  1487. static int _dasd_sleep_on(struct dasd_ccw_req *maincqr, int interruptible)
  1488. {
  1489. struct dasd_device *device;
  1490. int rc;
  1491. struct list_head ccw_queue;
  1492. struct dasd_ccw_req *cqr;
  1493. INIT_LIST_HEAD(&ccw_queue);
  1494. maincqr->status = DASD_CQR_FILLED;
  1495. device = maincqr->startdev;
  1496. list_add(&maincqr->blocklist, &ccw_queue);
  1497. for (cqr = maincqr; __dasd_sleep_on_loop_condition(cqr);
  1498. cqr = list_first_entry(&ccw_queue,
  1499. struct dasd_ccw_req, blocklist)) {
  1500. if (__dasd_sleep_on_erp(cqr))
  1501. continue;
  1502. if (cqr->status != DASD_CQR_FILLED) /* could be failed */
  1503. continue;
  1504. if (test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags) &&
  1505. !test_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags)) {
  1506. cqr->status = DASD_CQR_FAILED;
  1507. cqr->intrc = -EPERM;
  1508. continue;
  1509. }
  1510. /* Non-temporary stop condition will trigger fail fast */
  1511. if (device->stopped & ~DASD_STOPPED_PENDING &&
  1512. test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) &&
  1513. (!dasd_eer_enabled(device))) {
  1514. cqr->status = DASD_CQR_FAILED;
  1515. continue;
  1516. }
  1517. /* Don't try to start requests if device is stopped */
  1518. if (interruptible) {
  1519. rc = wait_event_interruptible(
  1520. generic_waitq, !(device->stopped));
  1521. if (rc == -ERESTARTSYS) {
  1522. cqr->status = DASD_CQR_FAILED;
  1523. maincqr->intrc = rc;
  1524. continue;
  1525. }
  1526. } else
  1527. wait_event(generic_waitq, !(device->stopped));
  1528. cqr->callback = dasd_wakeup_cb;
  1529. cqr->callback_data = DASD_SLEEPON_START_TAG;
  1530. dasd_add_request_tail(cqr);
  1531. if (interruptible) {
  1532. rc = wait_event_interruptible(
  1533. generic_waitq, _wait_for_wakeup(cqr));
  1534. if (rc == -ERESTARTSYS) {
  1535. dasd_cancel_req(cqr);
  1536. /* wait (non-interruptible) for final status */
  1537. wait_event(generic_waitq,
  1538. _wait_for_wakeup(cqr));
  1539. cqr->status = DASD_CQR_FAILED;
  1540. maincqr->intrc = rc;
  1541. continue;
  1542. }
  1543. } else
  1544. wait_event(generic_waitq, _wait_for_wakeup(cqr));
  1545. }
  1546. maincqr->endclk = get_clock();
  1547. if ((maincqr->status != DASD_CQR_DONE) &&
  1548. (maincqr->intrc != -ERESTARTSYS))
  1549. dasd_log_sense(maincqr, &maincqr->irb);
  1550. if (maincqr->status == DASD_CQR_DONE)
  1551. rc = 0;
  1552. else if (maincqr->intrc)
  1553. rc = maincqr->intrc;
  1554. else
  1555. rc = -EIO;
  1556. return rc;
  1557. }
  1558. /*
  1559. * Queue a request to the tail of the device ccw_queue and wait for
  1560. * it's completion.
  1561. */
  1562. int dasd_sleep_on(struct dasd_ccw_req *cqr)
  1563. {
  1564. return _dasd_sleep_on(cqr, 0);
  1565. }
  1566. /*
  1567. * Queue a request to the tail of the device ccw_queue and wait
  1568. * interruptible for it's completion.
  1569. */
  1570. int dasd_sleep_on_interruptible(struct dasd_ccw_req *cqr)
  1571. {
  1572. return _dasd_sleep_on(cqr, 1);
  1573. }
  1574. /*
  1575. * Whoa nelly now it gets really hairy. For some functions (e.g. steal lock
  1576. * for eckd devices) the currently running request has to be terminated
  1577. * and be put back to status queued, before the special request is added
  1578. * to the head of the queue. Then the special request is waited on normally.
  1579. */
  1580. static inline int _dasd_term_running_cqr(struct dasd_device *device)
  1581. {
  1582. struct dasd_ccw_req *cqr;
  1583. if (list_empty(&device->ccw_queue))
  1584. return 0;
  1585. cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist);
  1586. return device->discipline->term_IO(cqr);
  1587. }
  1588. int dasd_sleep_on_immediatly(struct dasd_ccw_req *cqr)
  1589. {
  1590. struct dasd_device *device;
  1591. int rc;
  1592. device = cqr->startdev;
  1593. if (test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags) &&
  1594. !test_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags)) {
  1595. cqr->status = DASD_CQR_FAILED;
  1596. cqr->intrc = -EPERM;
  1597. return -EIO;
  1598. }
  1599. spin_lock_irq(get_ccwdev_lock(device->cdev));
  1600. rc = _dasd_term_running_cqr(device);
  1601. if (rc) {
  1602. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  1603. return rc;
  1604. }
  1605. cqr->callback = dasd_wakeup_cb;
  1606. cqr->callback_data = DASD_SLEEPON_START_TAG;
  1607. cqr->status = DASD_CQR_QUEUED;
  1608. list_add(&cqr->devlist, &device->ccw_queue);
  1609. /* let the bh start the request to keep them in order */
  1610. dasd_schedule_device_bh(device);
  1611. spin_unlock_irq(get_ccwdev_lock(device->cdev));
  1612. wait_event(generic_waitq, _wait_for_wakeup(cqr));
  1613. if (cqr->status == DASD_CQR_DONE)
  1614. rc = 0;
  1615. else if (cqr->intrc)
  1616. rc = cqr->intrc;
  1617. else
  1618. rc = -EIO;
  1619. return rc;
  1620. }
  1621. /*
  1622. * Cancels a request that was started with dasd_sleep_on_req.
  1623. * This is useful to timeout requests. The request will be
  1624. * terminated if it is currently in i/o.
  1625. * Returns 1 if the request has been terminated.
  1626. * 0 if there was no need to terminate the request (not started yet)
  1627. * negative error code if termination failed
  1628. * Cancellation of a request is an asynchronous operation! The calling
  1629. * function has to wait until the request is properly returned via callback.
  1630. */
  1631. int dasd_cancel_req(struct dasd_ccw_req *cqr)
  1632. {
  1633. struct dasd_device *device = cqr->startdev;
  1634. unsigned long flags;
  1635. int rc;
  1636. rc = 0;
  1637. spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
  1638. switch (cqr->status) {
  1639. case DASD_CQR_QUEUED:
  1640. /* request was not started - just set to cleared */
  1641. cqr->status = DASD_CQR_CLEARED;
  1642. break;
  1643. case DASD_CQR_IN_IO:
  1644. /* request in IO - terminate IO and release again */
  1645. rc = device->discipline->term_IO(cqr);
  1646. if (rc) {
  1647. dev_err(&device->cdev->dev,
  1648. "Cancelling request %p failed with rc=%d\n",
  1649. cqr, rc);
  1650. } else {
  1651. cqr->stopclk = get_clock();
  1652. }
  1653. break;
  1654. default: /* already finished or clear pending - do nothing */
  1655. break;
  1656. }
  1657. spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
  1658. dasd_schedule_device_bh(device);
  1659. return rc;
  1660. }
  1661. /*
  1662. * SECTION: Operations of the dasd_block layer.
  1663. */
  1664. /*
  1665. * Timeout function for dasd_block. This is used when the block layer
  1666. * is waiting for something that may not come reliably, (e.g. a state
  1667. * change interrupt)
  1668. */
  1669. static void dasd_block_timeout(unsigned long ptr)
  1670. {
  1671. unsigned long flags;
  1672. struct dasd_block *block;
  1673. block = (struct dasd_block *) ptr;
  1674. spin_lock_irqsave(get_ccwdev_lock(block->base->cdev), flags);
  1675. /* re-activate request queue */
  1676. dasd_device_remove_stop_bits(block->base, DASD_STOPPED_PENDING);
  1677. spin_unlock_irqrestore(get_ccwdev_lock(block->base->cdev), flags);
  1678. dasd_schedule_block_bh(block);
  1679. }
  1680. /*
  1681. * Setup timeout for a dasd_block in jiffies.
  1682. */
  1683. void dasd_block_set_timer(struct dasd_block *block, int expires)
  1684. {
  1685. if (expires == 0)
  1686. del_timer(&block->timer);
  1687. else
  1688. mod_timer(&block->timer, jiffies + expires);
  1689. }
  1690. /*
  1691. * Clear timeout for a dasd_block.
  1692. */
  1693. void dasd_block_clear_timer(struct dasd_block *block)
  1694. {
  1695. del_timer(&block->timer);
  1696. }
  1697. /*
  1698. * Process finished error recovery ccw.
  1699. */
  1700. static void __dasd_process_erp(struct dasd_device *device,
  1701. struct dasd_ccw_req *cqr)
  1702. {
  1703. dasd_erp_fn_t erp_fn;
  1704. if (cqr->status == DASD_CQR_DONE)
  1705. DBF_DEV_EVENT(DBF_NOTICE, device, "%s", "ERP successful");
  1706. else
  1707. dev_err(&device->cdev->dev, "ERP failed for the DASD\n");
  1708. erp_fn = device->discipline->erp_postaction(cqr);
  1709. erp_fn(cqr);
  1710. }
  1711. /*
  1712. * Fetch requests from the block device queue.
  1713. */
  1714. static void __dasd_process_request_queue(struct dasd_block *block)
  1715. {
  1716. struct request_queue *queue;
  1717. struct request *req;
  1718. struct dasd_ccw_req *cqr;
  1719. struct dasd_device *basedev;
  1720. unsigned long flags;
  1721. queue = block->request_queue;
  1722. basedev = block->base;
  1723. /* No queue ? Then there is nothing to do. */
  1724. if (queue == NULL)
  1725. return;
  1726. /*
  1727. * We requeue request from the block device queue to the ccw
  1728. * queue only in two states. In state DASD_STATE_READY the
  1729. * partition detection is done and we need to requeue requests
  1730. * for that. State DASD_STATE_ONLINE is normal block device
  1731. * operation.
  1732. */
  1733. if (basedev->state < DASD_STATE_READY) {
  1734. while ((req = blk_fetch_request(block->request_queue)))
  1735. __blk_end_request_all(req, -EIO);
  1736. return;
  1737. }
  1738. /* Now we try to fetch requests from the request queue */
  1739. while (!blk_queue_plugged(queue) && (req = blk_peek_request(queue))) {
  1740. if (basedev->features & DASD_FEATURE_READONLY &&
  1741. rq_data_dir(req) == WRITE) {
  1742. DBF_DEV_EVENT(DBF_ERR, basedev,
  1743. "Rejecting write request %p",
  1744. req);
  1745. blk_start_request(req);
  1746. __blk_end_request_all(req, -EIO);
  1747. continue;
  1748. }
  1749. cqr = basedev->discipline->build_cp(basedev, block, req);
  1750. if (IS_ERR(cqr)) {
  1751. if (PTR_ERR(cqr) == -EBUSY)
  1752. break; /* normal end condition */
  1753. if (PTR_ERR(cqr) == -ENOMEM)
  1754. break; /* terminate request queue loop */
  1755. if (PTR_ERR(cqr) == -EAGAIN) {
  1756. /*
  1757. * The current request cannot be build right
  1758. * now, we have to try later. If this request
  1759. * is the head-of-queue we stop the device
  1760. * for 1/2 second.
  1761. */
  1762. if (!list_empty(&block->ccw_queue))
  1763. break;
  1764. spin_lock_irqsave(
  1765. get_ccwdev_lock(basedev->cdev), flags);
  1766. dasd_device_set_stop_bits(basedev,
  1767. DASD_STOPPED_PENDING);
  1768. spin_unlock_irqrestore(
  1769. get_ccwdev_lock(basedev->cdev), flags);
  1770. dasd_block_set_timer(block, HZ/2);
  1771. break;
  1772. }
  1773. DBF_DEV_EVENT(DBF_ERR, basedev,
  1774. "CCW creation failed (rc=%ld) "
  1775. "on request %p",
  1776. PTR_ERR(cqr), req);
  1777. blk_start_request(req);
  1778. __blk_end_request_all(req, -EIO);
  1779. continue;
  1780. }
  1781. /*
  1782. * Note: callback is set to dasd_return_cqr_cb in
  1783. * __dasd_block_start_head to cover erp requests as well
  1784. */
  1785. cqr->callback_data = (void *) req;
  1786. cqr->status = DASD_CQR_FILLED;
  1787. blk_start_request(req);
  1788. list_add_tail(&cqr->blocklist, &block->ccw_queue);
  1789. dasd_profile_start(block, cqr, req);
  1790. }
  1791. }
  1792. static void __dasd_cleanup_cqr(struct dasd_ccw_req *cqr)
  1793. {
  1794. struct request *req;
  1795. int status;
  1796. int error = 0;
  1797. req = (struct request *) cqr->callback_data;
  1798. dasd_profile_end(cqr->block, cqr, req);
  1799. status = cqr->block->base->discipline->free_cp(cqr, req);
  1800. if (status <= 0)
  1801. error = status ? status : -EIO;
  1802. __blk_end_request_all(req, error);
  1803. }
  1804. /*
  1805. * Process ccw request queue.
  1806. */
  1807. static void __dasd_process_block_ccw_queue(struct dasd_block *block,
  1808. struct list_head *final_queue)
  1809. {
  1810. struct list_head *l, *n;
  1811. struct dasd_ccw_req *cqr;
  1812. dasd_erp_fn_t erp_fn;
  1813. unsigned long flags;
  1814. struct dasd_device *base = block->base;
  1815. restart:
  1816. /* Process request with final status. */
  1817. list_for_each_safe(l, n, &block->ccw_queue) {
  1818. cqr = list_entry(l, struct dasd_ccw_req, blocklist);
  1819. if (cqr->status != DASD_CQR_DONE &&
  1820. cqr->status != DASD_CQR_FAILED &&
  1821. cqr->status != DASD_CQR_NEED_ERP &&
  1822. cqr->status != DASD_CQR_TERMINATED)
  1823. continue;
  1824. if (cqr->status == DASD_CQR_TERMINATED) {
  1825. base->discipline->handle_terminated_request(cqr);
  1826. goto restart;
  1827. }
  1828. /* Process requests that may be recovered */
  1829. if (cqr->status == DASD_CQR_NEED_ERP) {
  1830. erp_fn = base->discipline->erp_action(cqr);
  1831. if (IS_ERR(erp_fn(cqr)))
  1832. continue;
  1833. goto restart;
  1834. }
  1835. /* log sense for fatal error */
  1836. if (cqr->status == DASD_CQR_FAILED) {
  1837. dasd_log_sense(cqr, &cqr->irb);
  1838. }
  1839. /* First of all call extended error reporting. */
  1840. if (dasd_eer_enabled(base) &&
  1841. cqr->status == DASD_CQR_FAILED) {
  1842. dasd_eer_write(base, cqr, DASD_EER_FATALERROR);
  1843. /* restart request */
  1844. cqr->status = DASD_CQR_FILLED;
  1845. cqr->retries = 255;
  1846. spin_lock_irqsave(get_ccwdev_lock(base->cdev), flags);
  1847. dasd_device_set_stop_bits(base, DASD_STOPPED_QUIESCE);
  1848. spin_unlock_irqrestore(get_ccwdev_lock(base->cdev),
  1849. flags);
  1850. goto restart;
  1851. }
  1852. /* Process finished ERP request. */
  1853. if (cqr->refers) {
  1854. __dasd_process_erp(base, cqr);
  1855. goto restart;
  1856. }
  1857. /* Rechain finished requests to final queue */
  1858. cqr->endclk = get_clock();
  1859. list_move_tail(&cqr->blocklist, final_queue);
  1860. }
  1861. }
  1862. static void dasd_return_cqr_cb(struct dasd_ccw_req *cqr, void *data)
  1863. {
  1864. dasd_schedule_block_bh(cqr->block);
  1865. }
  1866. static void __dasd_block_start_head(struct dasd_block *block)
  1867. {
  1868. struct dasd_ccw_req *cqr;
  1869. if (list_empty(&block->ccw_queue))
  1870. return;
  1871. /* We allways begin with the first requests on the queue, as some
  1872. * of previously started requests have to be enqueued on a
  1873. * dasd_device again for error recovery.
  1874. */
  1875. list_for_each_entry(cqr, &block->ccw_queue, blocklist) {
  1876. if (cqr->status != DASD_CQR_FILLED)
  1877. continue;
  1878. if (test_bit(DASD_FLAG_LOCK_STOLEN, &block->base->flags) &&
  1879. !test_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags)) {
  1880. cqr->status = DASD_CQR_FAILED;
  1881. cqr->intrc = -EPERM;
  1882. dasd_schedule_block_bh(block);
  1883. continue;
  1884. }
  1885. /* Non-temporary stop condition will trigger fail fast */
  1886. if (block->base->stopped & ~DASD_STOPPED_PENDING &&
  1887. test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) &&
  1888. (!dasd_eer_enabled(block->base))) {
  1889. cqr->status = DASD_CQR_FAILED;
  1890. dasd_schedule_block_bh(block);
  1891. continue;
  1892. }
  1893. /* Don't try to start requests if device is stopped */
  1894. if (block->base->stopped)
  1895. return;
  1896. /* just a fail safe check, should not happen */
  1897. if (!cqr->startdev)
  1898. cqr->startdev = block->base;
  1899. /* make sure that the requests we submit find their way back */
  1900. cqr->callback = dasd_return_cqr_cb;
  1901. dasd_add_request_tail(cqr);
  1902. }
  1903. }
  1904. /*
  1905. * Central dasd_block layer routine. Takes requests from the generic
  1906. * block layer request queue, creates ccw requests, enqueues them on
  1907. * a dasd_device and processes ccw requests that have been returned.
  1908. */
  1909. static void dasd_block_tasklet(struct dasd_block *block)
  1910. {
  1911. struct list_head final_queue;
  1912. struct list_head *l, *n;
  1913. struct dasd_ccw_req *cqr;
  1914. atomic_set(&block->tasklet_scheduled, 0);
  1915. INIT_LIST_HEAD(&final_queue);
  1916. spin_lock(&block->queue_lock);
  1917. /* Finish off requests on ccw queue */
  1918. __dasd_process_block_ccw_queue(block, &final_queue);
  1919. spin_unlock(&block->queue_lock);
  1920. /* Now call the callback function of requests with final status */
  1921. spin_lock_irq(&block->request_queue_lock);
  1922. list_for_each_safe(l, n, &final_queue) {
  1923. cqr = list_entry(l, struct dasd_ccw_req, blocklist);
  1924. list_del_init(&cqr->blocklist);
  1925. __dasd_cleanup_cqr(cqr);
  1926. }
  1927. spin_lock(&block->queue_lock);
  1928. /* Get new request from the block device request queue */
  1929. __dasd_process_request_queue(block);
  1930. /* Now check if the head of the ccw queue needs to be started. */
  1931. __dasd_block_start_head(block);
  1932. spin_unlock(&block->queue_lock);
  1933. spin_unlock_irq(&block->request_queue_lock);
  1934. dasd_put_device(block->base);
  1935. }
  1936. static void _dasd_wake_block_flush_cb(struct dasd_ccw_req *cqr, void *data)
  1937. {
  1938. wake_up(&dasd_flush_wq);
  1939. }
  1940. /*
  1941. * Go through all request on the dasd_block request queue, cancel them
  1942. * on the respective dasd_device, and return them to the generic
  1943. * block layer.
  1944. */
  1945. static int dasd_flush_block_queue(struct dasd_block *block)
  1946. {
  1947. struct dasd_ccw_req *cqr, *n;
  1948. int rc, i;
  1949. struct list_head flush_queue;
  1950. INIT_LIST_HEAD(&flush_queue);
  1951. spin_lock_bh(&block->queue_lock);
  1952. rc = 0;
  1953. restart:
  1954. list_for_each_entry_safe(cqr, n, &block->ccw_queue, blocklist) {
  1955. /* if this request currently owned by a dasd_device cancel it */
  1956. if (cqr->status >= DASD_CQR_QUEUED)
  1957. rc = dasd_cancel_req(cqr);
  1958. if (rc < 0)
  1959. break;
  1960. /* Rechain request (including erp chain) so it won't be
  1961. * touched by the dasd_block_tasklet anymore.
  1962. * Replace the callback so we notice when the request
  1963. * is returned from the dasd_device layer.
  1964. */
  1965. cqr->callback = _dasd_wake_block_flush_cb;
  1966. for (i = 0; cqr != NULL; cqr = cqr->refers, i++)
  1967. list_move_tail(&cqr->blocklist, &flush_queue);
  1968. if (i > 1)
  1969. /* moved more than one request - need to restart */
  1970. goto restart;
  1971. }
  1972. spin_unlock_bh(&block->queue_lock);
  1973. /* Now call the callback function of flushed requests */
  1974. restart_cb:
  1975. list_for_each_entry_safe(cqr, n, &flush_queue, blocklist) {
  1976. wait_event(dasd_flush_wq, (cqr->status < DASD_CQR_QUEUED));
  1977. /* Process finished ERP request. */
  1978. if (cqr->refers) {
  1979. spin_lock_bh(&block->queue_lock);
  1980. __dasd_process_erp(block->base, cqr);
  1981. spin_unlock_bh(&block->queue_lock);
  1982. /* restart list_for_xx loop since dasd_process_erp
  1983. * might remove multiple elements */
  1984. goto restart_cb;
  1985. }
  1986. /* call the callback function */
  1987. spin_lock_irq(&block->request_queue_lock);
  1988. cqr->endclk = get_clock();
  1989. list_del_init(&cqr->blocklist);
  1990. __dasd_cleanup_cqr(cqr);
  1991. spin_unlock_irq(&block->request_queue_lock);
  1992. }
  1993. return rc;
  1994. }
  1995. /*
  1996. * Schedules a call to dasd_tasklet over the device tasklet.
  1997. */
  1998. void dasd_schedule_block_bh(struct dasd_block *block)
  1999. {
  2000. /* Protect against rescheduling. */
  2001. if (atomic_cmpxchg(&block->tasklet_scheduled, 0, 1) != 0)
  2002. return;
  2003. /* life cycle of block is bound to it's base device */
  2004. dasd_get_device(block->base);
  2005. tasklet_hi_schedule(&block->tasklet);
  2006. }
  2007. /*
  2008. * SECTION: external block device operations
  2009. * (request queue handling, open, release, etc.)
  2010. */
  2011. /*
  2012. * Dasd request queue function. Called from ll_rw_blk.c
  2013. */
  2014. static void do_dasd_request(struct request_queue *queue)
  2015. {
  2016. struct dasd_block *block;
  2017. block = queue->queuedata;
  2018. spin_lock(&block->queue_lock);
  2019. /* Get new request from the block device request queue */
  2020. __dasd_process_request_queue(block);
  2021. /* Now check if the head of the ccw queue needs to be started. */
  2022. __dasd_block_start_head(block);
  2023. spin_unlock(&block->queue_lock);
  2024. }
  2025. /*
  2026. * Allocate and initialize request queue and default I/O scheduler.
  2027. */
  2028. static int dasd_alloc_queue(struct dasd_block *block)
  2029. {
  2030. int rc;
  2031. block->request_queue = blk_init_queue(do_dasd_request,
  2032. &block->request_queue_lock);
  2033. if (block->request_queue == NULL)
  2034. return -ENOMEM;
  2035. block->request_queue->queuedata = block;
  2036. elevator_exit(block->request_queue->elevator);
  2037. block->request_queue->elevator = NULL;
  2038. rc = elevator_init(block->request_queue, "deadline");
  2039. if (rc) {
  2040. blk_cleanup_queue(block->request_queue);
  2041. return rc;
  2042. }
  2043. return 0;
  2044. }
  2045. /*
  2046. * Allocate and initialize request queue.
  2047. */
  2048. static void dasd_setup_queue(struct dasd_block *block)
  2049. {
  2050. int max;
  2051. blk_queue_logical_block_size(block->request_queue, block->bp_block);
  2052. max = block->base->discipline->max_blocks << block->s2b_shift;
  2053. blk_queue_max_hw_sectors(block->request_queue, max);
  2054. blk_queue_max_segments(block->request_queue, -1L);
  2055. /* with page sized segments we can translate each segement into
  2056. * one idaw/tidaw
  2057. */
  2058. blk_queue_max_segment_size(block->request_queue, PAGE_SIZE);
  2059. blk_queue_segment_boundary(block->request_queue, PAGE_SIZE - 1);
  2060. }
  2061. /*
  2062. * Deactivate and free request queue.
  2063. */
  2064. static void dasd_free_queue(struct dasd_block *block)
  2065. {
  2066. if (block->request_queue) {
  2067. blk_cleanup_queue(block->request_queue);
  2068. block->request_queue = NULL;
  2069. }
  2070. }
  2071. /*
  2072. * Flush request on the request queue.
  2073. */
  2074. static void dasd_flush_request_queue(struct dasd_block *block)
  2075. {
  2076. struct request *req;
  2077. if (!block->request_queue)
  2078. return;
  2079. spin_lock_irq(&block->request_queue_lock);
  2080. while ((req = blk_fetch_request(block->request_queue)))
  2081. __blk_end_request_all(req, -EIO);
  2082. spin_unlock_irq(&block->request_queue_lock);
  2083. }
  2084. static int dasd_open(struct block_device *bdev, fmode_t mode)
  2085. {
  2086. struct dasd_block *block = bdev->bd_disk->private_data;
  2087. struct dasd_device *base;
  2088. int rc;
  2089. if (!block)
  2090. return -ENODEV;
  2091. base = block->base;
  2092. atomic_inc(&block->open_count);
  2093. if (test_bit(DASD_FLAG_OFFLINE, &base->flags)) {
  2094. rc = -ENODEV;
  2095. goto unlock;
  2096. }
  2097. if (!try_module_get(base->discipline->owner)) {
  2098. rc = -EINVAL;
  2099. goto unlock;
  2100. }
  2101. if (dasd_probeonly) {
  2102. dev_info(&base->cdev->dev,
  2103. "Accessing the DASD failed because it is in "
  2104. "probeonly mode\n");
  2105. rc = -EPERM;
  2106. goto out;
  2107. }
  2108. if (base->state <= DASD_STATE_BASIC) {
  2109. DBF_DEV_EVENT(DBF_ERR, base, " %s",
  2110. " Cannot open unrecognized device");
  2111. rc = -ENODEV;
  2112. goto out;
  2113. }
  2114. if ((mode & FMODE_WRITE) &&
  2115. (test_bit(DASD_FLAG_DEVICE_RO, &base->flags) ||
  2116. (base->features & DASD_FEATURE_READONLY))) {
  2117. rc = -EROFS;
  2118. goto out;
  2119. }
  2120. return 0;
  2121. out:
  2122. module_put(base->discipline->owner);
  2123. unlock:
  2124. atomic_dec(&block->open_count);
  2125. return rc;
  2126. }
  2127. static int dasd_release(struct gendisk *disk, fmode_t mode)
  2128. {
  2129. struct dasd_block *block = disk->private_data;
  2130. atomic_dec(&block->open_count);
  2131. module_put(block->base->discipline->owner);
  2132. return 0;
  2133. }
  2134. /*
  2135. * Return disk geometry.
  2136. */
  2137. static int dasd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
  2138. {
  2139. struct dasd_block *block;
  2140. struct dasd_device *base;
  2141. block = bdev->bd_disk->private_data;
  2142. if (!block)
  2143. return -ENODEV;
  2144. base = block->base;
  2145. if (!base->discipline ||
  2146. !base->discipline->fill_geometry)
  2147. return -EINVAL;
  2148. base->discipline->fill_geometry(block, geo);
  2149. geo->start = get_start_sect(bdev) >> block->s2b_shift;
  2150. return 0;
  2151. }
  2152. const struct block_device_operations
  2153. dasd_device_operations = {
  2154. .owner = THIS_MODULE,
  2155. .open = dasd_open,
  2156. .release = dasd_release,
  2157. .ioctl = dasd_ioctl,
  2158. .compat_ioctl = dasd_ioctl,
  2159. .getgeo = dasd_getgeo,
  2160. };
  2161. /*******************************************************************************
  2162. * end of block device operations
  2163. */
  2164. static void
  2165. dasd_exit(void)
  2166. {
  2167. #ifdef CONFIG_PROC_FS
  2168. dasd_proc_exit();
  2169. #endif
  2170. dasd_eer_exit();
  2171. if (dasd_page_cache != NULL) {
  2172. kmem_cache_destroy(dasd_page_cache);
  2173. dasd_page_cache = NULL;
  2174. }
  2175. dasd_gendisk_exit();
  2176. dasd_devmap_exit();
  2177. if (dasd_debug_area != NULL) {
  2178. debug_unregister(dasd_debug_area);
  2179. dasd_debug_area = NULL;
  2180. }
  2181. }
  2182. /*
  2183. * SECTION: common functions for ccw_driver use
  2184. */
  2185. /*
  2186. * Is the device read-only?
  2187. * Note that this function does not report the setting of the
  2188. * readonly device attribute, but how it is configured in z/VM.
  2189. */
  2190. int dasd_device_is_ro(struct dasd_device *device)
  2191. {
  2192. struct ccw_dev_id dev_id;
  2193. struct diag210 diag_data;
  2194. int rc;
  2195. if (!MACHINE_IS_VM)
  2196. return 0;
  2197. ccw_device_get_id(device->cdev, &dev_id);
  2198. memset(&diag_data, 0, sizeof(diag_data));
  2199. diag_data.vrdcdvno = dev_id.devno;
  2200. diag_data.vrdclen = sizeof(diag_data);
  2201. rc = diag210(&diag_data);
  2202. if (rc == 0 || rc == 2) {
  2203. return diag_data.vrdcvfla & 0x80;
  2204. } else {
  2205. DBF_EVENT(DBF_WARNING, "diag210 failed for dev=%04x with rc=%d",
  2206. dev_id.devno, rc);
  2207. return 0;
  2208. }
  2209. }
  2210. EXPORT_SYMBOL_GPL(dasd_device_is_ro);
  2211. static void dasd_generic_auto_online(void *data, async_cookie_t cookie)
  2212. {
  2213. struct ccw_device *cdev = data;
  2214. int ret;
  2215. ret = ccw_device_set_online(cdev);
  2216. if (ret)
  2217. pr_warning("%s: Setting the DASD online failed with rc=%d\n",
  2218. dev_name(&cdev->dev), ret);
  2219. }
  2220. /*
  2221. * Initial attempt at a probe function. this can be simplified once
  2222. * the other detection code is gone.
  2223. */
  2224. int dasd_generic_probe(struct ccw_device *cdev,
  2225. struct dasd_discipline *discipline)
  2226. {
  2227. int ret;
  2228. ret = dasd_add_sysfs_files(cdev);
  2229. if (ret) {
  2230. DBF_EVENT_DEVID(DBF_WARNING, cdev, "%s",
  2231. "dasd_generic_probe: could not add "
  2232. "sysfs entries");
  2233. return ret;
  2234. }
  2235. cdev->handler = &dasd_int_handler;
  2236. /*
  2237. * Automatically online either all dasd devices (dasd_autodetect)
  2238. * or all devices specified with dasd= parameters during
  2239. * initial probe.
  2240. */
  2241. if ((dasd_get_feature(cdev, DASD_FEATURE_INITIAL_ONLINE) > 0 ) ||
  2242. (dasd_autodetect && dasd_busid_known(dev_name(&cdev->dev)) != 0))
  2243. async_schedule(dasd_generic_auto_online, cdev);
  2244. return 0;
  2245. }
  2246. /*
  2247. * This will one day be called from a global not_oper handler.
  2248. * It is also used by driver_unregister during module unload.
  2249. */
  2250. void dasd_generic_remove(struct ccw_device *cdev)
  2251. {
  2252. struct dasd_device *device;
  2253. struct dasd_block *block;
  2254. cdev->handler = NULL;
  2255. dasd_remove_sysfs_files(cdev);
  2256. device = dasd_device_from_cdev(cdev);
  2257. if (IS_ERR(device))
  2258. return;
  2259. if (test_and_set_bit(DASD_FLAG_OFFLINE, &device->flags)) {
  2260. /* Already doing offline processing */
  2261. dasd_put_device(device);
  2262. return;
  2263. }
  2264. /*
  2265. * This device is removed unconditionally. Set offline
  2266. * flag to prevent dasd_open from opening it while it is
  2267. * no quite down yet.
  2268. */
  2269. dasd_set_target_state(device, DASD_STATE_NEW);
  2270. /* dasd_delete_device destroys the device reference. */
  2271. block = device->block;
  2272. device->block = NULL;
  2273. dasd_delete_device(device);
  2274. /*
  2275. * life cycle of block is bound to device, so delete it after
  2276. * device was safely removed
  2277. */
  2278. if (block)
  2279. dasd_free_block(block);
  2280. }
  2281. /*
  2282. * Activate a device. This is called from dasd_{eckd,fba}_probe() when either
  2283. * the device is detected for the first time and is supposed to be used
  2284. * or the user has started activation through sysfs.
  2285. */
  2286. int dasd_generic_set_online(struct ccw_device *cdev,
  2287. struct dasd_discipline *base_discipline)
  2288. {
  2289. struct dasd_discipline *discipline;
  2290. struct dasd_device *device;
  2291. int rc;
  2292. /* first online clears initial online feature flag */
  2293. dasd_set_feature(cdev, DASD_FEATURE_INITIAL_ONLINE, 0);
  2294. device = dasd_create_device(cdev);
  2295. if (IS_ERR(device))
  2296. return PTR_ERR(device);
  2297. discipline = base_discipline;
  2298. if (device->features & DASD_FEATURE_USEDIAG) {
  2299. if (!dasd_diag_discipline_pointer) {
  2300. pr_warning("%s Setting the DASD online failed because "
  2301. "of missing DIAG discipline\n",
  2302. dev_name(&cdev->dev));
  2303. dasd_delete_device(device);
  2304. return -ENODEV;
  2305. }
  2306. discipline = dasd_diag_discipline_pointer;
  2307. }
  2308. if (!try_module_get(base_discipline->owner)) {
  2309. dasd_delete_device(device);
  2310. return -EINVAL;
  2311. }
  2312. if (!try_module_get(discipline->owner)) {
  2313. module_put(base_discipline->owner);
  2314. dasd_delete_device(device);
  2315. return -EINVAL;
  2316. }
  2317. device->base_discipline = base_discipline;
  2318. device->discipline = discipline;
  2319. /* check_device will allocate block device if necessary */
  2320. rc = discipline->check_device(device);
  2321. if (rc) {
  2322. pr_warning("%s Setting the DASD online with discipline %s "
  2323. "failed with rc=%i\n",
  2324. dev_name(&cdev->dev), discipline->name, rc);
  2325. module_put(discipline->owner);
  2326. module_put(base_discipline->owner);
  2327. dasd_delete_device(device);
  2328. return rc;
  2329. }
  2330. dasd_set_target_state(device, DASD_STATE_ONLINE);
  2331. if (device->state <= DASD_STATE_KNOWN) {
  2332. pr_warning("%s Setting the DASD online failed because of a "
  2333. "missing discipline\n", dev_name(&cdev->dev));
  2334. rc = -ENODEV;
  2335. dasd_set_target_state(device, DASD_STATE_NEW);
  2336. if (device->block)
  2337. dasd_free_block(device->block);
  2338. dasd_delete_device(device);
  2339. } else
  2340. pr_debug("dasd_generic device %s found\n",
  2341. dev_name(&cdev->dev));
  2342. wait_event(dasd_init_waitq, _wait_for_device(device));
  2343. dasd_put_device(device);
  2344. return rc;
  2345. }
  2346. int dasd_generic_set_offline(struct ccw_device *cdev)
  2347. {
  2348. struct dasd_device *device;
  2349. struct dasd_block *block;
  2350. int max_count, open_count;
  2351. device = dasd_device_from_cdev(cdev);
  2352. if (IS_ERR(device))
  2353. return PTR_ERR(device);
  2354. if (test_and_set_bit(DASD_FLAG_OFFLINE, &device->flags)) {
  2355. /* Already doing offline processing */
  2356. dasd_put_device(device);
  2357. return 0;
  2358. }
  2359. /*
  2360. * We must make sure that this device is currently not in use.
  2361. * The open_count is increased for every opener, that includes
  2362. * the blkdev_get in dasd_scan_partitions. We are only interested
  2363. * in the other openers.
  2364. */
  2365. if (device->block) {
  2366. max_count = device->block->bdev ? 0 : -1;
  2367. open_count = atomic_read(&device->block->open_count);
  2368. if (open_count > max_count) {
  2369. if (open_count > 0)
  2370. pr_warning("%s: The DASD cannot be set offline "
  2371. "with open count %i\n",
  2372. dev_name(&cdev->dev), open_count);
  2373. else
  2374. pr_warning("%s: The DASD cannot be set offline "
  2375. "while it is in use\n",
  2376. dev_name(&cdev->dev));
  2377. clear_bit(DASD_FLAG_OFFLINE, &device->flags);
  2378. dasd_put_device(device);
  2379. return -EBUSY;
  2380. }
  2381. }
  2382. dasd_set_target_state(device, DASD_STATE_NEW);
  2383. /* dasd_delete_device destroys the device reference. */
  2384. block = device->block;
  2385. device->block = NULL;
  2386. dasd_delete_device(device);
  2387. /*
  2388. * life cycle of block is bound to device, so delete it after
  2389. * device was safely removed
  2390. */
  2391. if (block)
  2392. dasd_free_block(block);
  2393. return 0;
  2394. }
  2395. int dasd_generic_last_path_gone(struct dasd_device *device)
  2396. {
  2397. struct dasd_ccw_req *cqr;
  2398. dev_warn(&device->cdev->dev, "No operational channel path is left "
  2399. "for the device\n");
  2400. DBF_DEV_EVENT(DBF_WARNING, device, "%s", "last path gone");
  2401. /* First of all call extended error reporting. */
  2402. dasd_eer_write(device, NULL, DASD_EER_NOPATH);
  2403. if (device->state < DASD_STATE_BASIC)
  2404. return 0;
  2405. /* Device is active. We want to keep it. */
  2406. list_for_each_entry(cqr, &device->ccw_queue, devlist)
  2407. if ((cqr->status == DASD_CQR_IN_IO) ||
  2408. (cqr->status == DASD_CQR_CLEAR_PENDING)) {
  2409. cqr->status = DASD_CQR_QUEUED;
  2410. cqr->retries++;
  2411. }
  2412. dasd_device_set_stop_bits(device, DASD_STOPPED_DC_WAIT);
  2413. dasd_device_clear_timer(device);
  2414. dasd_schedule_device_bh(device);
  2415. return 1;
  2416. }
  2417. EXPORT_SYMBOL_GPL(dasd_generic_last_path_gone);
  2418. int dasd_generic_path_operational(struct dasd_device *device)
  2419. {
  2420. dev_info(&device->cdev->dev, "A channel path to the device has become "
  2421. "operational\n");
  2422. DBF_DEV_EVENT(DBF_WARNING, device, "%s", "path operational");
  2423. dasd_device_remove_stop_bits(device, DASD_STOPPED_DC_WAIT);
  2424. if (device->stopped & DASD_UNRESUMED_PM) {
  2425. dasd_device_remove_stop_bits(device, DASD_UNRESUMED_PM);
  2426. dasd_restore_device(device);
  2427. return 1;
  2428. }
  2429. dasd_schedule_device_bh(device);
  2430. if (device->block)
  2431. dasd_schedule_block_bh(device->block);
  2432. return 1;
  2433. }
  2434. EXPORT_SYMBOL_GPL(dasd_generic_path_operational);
  2435. int dasd_generic_notify(struct ccw_device *cdev, int event)
  2436. {
  2437. struct dasd_device *device;
  2438. int ret;
  2439. device = dasd_device_from_cdev_locked(cdev);
  2440. if (IS_ERR(device))
  2441. return 0;
  2442. ret = 0;
  2443. switch (event) {
  2444. case CIO_GONE:
  2445. case CIO_BOXED:
  2446. case CIO_NO_PATH:
  2447. device->path_data.opm = 0;
  2448. device->path_data.ppm = 0;
  2449. device->path_data.npm = 0;
  2450. ret = dasd_generic_last_path_gone(device);
  2451. break;
  2452. case CIO_OPER:
  2453. ret = 1;
  2454. if (device->path_data.opm)
  2455. ret = dasd_generic_path_operational(device);
  2456. break;
  2457. }
  2458. dasd_put_device(device);
  2459. return ret;
  2460. }
  2461. void dasd_generic_path_event(struct ccw_device *cdev, int *path_event)
  2462. {
  2463. int chp;
  2464. __u8 oldopm, eventlpm;
  2465. struct dasd_device *device;
  2466. device = dasd_device_from_cdev_locked(cdev);
  2467. if (IS_ERR(device))
  2468. return;
  2469. for (chp = 0; chp < 8; chp++) {
  2470. eventlpm = 0x80 >> chp;
  2471. if (path_event[chp] & PE_PATH_GONE) {
  2472. oldopm = device->path_data.opm;
  2473. device->path_data.opm &= ~eventlpm;
  2474. device->path_data.ppm &= ~eventlpm;
  2475. device->path_data.npm &= ~eventlpm;
  2476. if (oldopm && !device->path_data.opm)
  2477. dasd_generic_last_path_gone(device);
  2478. }
  2479. if (path_event[chp] & PE_PATH_AVAILABLE) {
  2480. device->path_data.opm &= ~eventlpm;
  2481. device->path_data.ppm &= ~eventlpm;
  2482. device->path_data.npm &= ~eventlpm;
  2483. device->path_data.tbvpm |= eventlpm;
  2484. dasd_schedule_device_bh(device);
  2485. }
  2486. }
  2487. dasd_put_device(device);
  2488. }
  2489. EXPORT_SYMBOL_GPL(dasd_generic_path_event);
  2490. int dasd_generic_verify_path(struct dasd_device *device, __u8 lpm)
  2491. {
  2492. if (!device->path_data.opm && lpm) {
  2493. device->path_data.opm = lpm;
  2494. dasd_generic_path_operational(device);
  2495. } else
  2496. device->path_data.opm |= lpm;
  2497. return 0;
  2498. }
  2499. EXPORT_SYMBOL_GPL(dasd_generic_verify_path);
  2500. int dasd_generic_pm_freeze(struct ccw_device *cdev)
  2501. {
  2502. struct dasd_ccw_req *cqr, *n;
  2503. int rc;
  2504. struct list_head freeze_queue;
  2505. struct dasd_device *device = dasd_device_from_cdev(cdev);
  2506. if (IS_ERR(device))
  2507. return PTR_ERR(device);
  2508. if (device->discipline->freeze)
  2509. rc = device->discipline->freeze(device);
  2510. /* disallow new I/O */
  2511. dasd_device_set_stop_bits(device, DASD_STOPPED_PM);
  2512. /* clear active requests */
  2513. INIT_LIST_HEAD(&freeze_queue);
  2514. spin_lock_irq(get_ccwdev_lock(cdev));
  2515. rc = 0;
  2516. list_for_each_entry_safe(cqr, n, &device->ccw_queue, devlist) {
  2517. /* Check status and move request to flush_queue */
  2518. if (cqr->status == DASD_CQR_IN_IO) {
  2519. rc = device->discipline->term_IO(cqr);
  2520. if (rc) {
  2521. /* unable to terminate requeust */
  2522. dev_err(&device->cdev->dev,
  2523. "Unable to terminate request %p "
  2524. "on suspend\n", cqr);
  2525. spin_unlock_irq(get_ccwdev_lock(cdev));
  2526. dasd_put_device(device);
  2527. return rc;
  2528. }
  2529. }
  2530. list_move_tail(&cqr->devlist, &freeze_queue);
  2531. }
  2532. spin_unlock_irq(get_ccwdev_lock(cdev));
  2533. list_for_each_entry_safe(cqr, n, &freeze_queue, devlist) {
  2534. wait_event(dasd_flush_wq,
  2535. (cqr->status != DASD_CQR_CLEAR_PENDING));
  2536. if (cqr->status == DASD_CQR_CLEARED)
  2537. cqr->status = DASD_CQR_QUEUED;
  2538. }
  2539. /* move freeze_queue to start of the ccw_queue */
  2540. spin_lock_irq(get_ccwdev_lock(cdev));
  2541. list_splice_tail(&freeze_queue, &device->ccw_queue);
  2542. spin_unlock_irq(get_ccwdev_lock(cdev));
  2543. dasd_put_device(device);
  2544. return rc;
  2545. }
  2546. EXPORT_SYMBOL_GPL(dasd_generic_pm_freeze);
  2547. int dasd_generic_restore_device(struct ccw_device *cdev)
  2548. {
  2549. struct dasd_device *device = dasd_device_from_cdev(cdev);
  2550. int rc = 0;
  2551. if (IS_ERR(device))
  2552. return PTR_ERR(device);
  2553. /* allow new IO again */
  2554. dasd_device_remove_stop_bits(device,
  2555. (DASD_STOPPED_PM | DASD_UNRESUMED_PM));
  2556. dasd_schedule_device_bh(device);
  2557. /*
  2558. * call discipline restore function
  2559. * if device is stopped do nothing e.g. for disconnected devices
  2560. */
  2561. if (device->discipline->restore && !(device->stopped))
  2562. rc = device->discipline->restore(device);
  2563. if (rc || device->stopped)
  2564. /*
  2565. * if the resume failed for the DASD we put it in
  2566. * an UNRESUMED stop state
  2567. */
  2568. device->stopped |= DASD_UNRESUMED_PM;
  2569. if (device->block)
  2570. dasd_schedule_block_bh(device->block);
  2571. dasd_put_device(device);
  2572. return 0;
  2573. }
  2574. EXPORT_SYMBOL_GPL(dasd_generic_restore_device);
  2575. static struct dasd_ccw_req *dasd_generic_build_rdc(struct dasd_device *device,
  2576. void *rdc_buffer,
  2577. int rdc_buffer_size,
  2578. int magic)
  2579. {
  2580. struct dasd_ccw_req *cqr;
  2581. struct ccw1 *ccw;
  2582. unsigned long *idaw;
  2583. cqr = dasd_smalloc_request(magic, 1 /* RDC */, rdc_buffer_size, device);
  2584. if (IS_ERR(cqr)) {
  2585. /* internal error 13 - Allocating the RDC request failed*/
  2586. dev_err(&device->cdev->dev,
  2587. "An error occurred in the DASD device driver, "
  2588. "reason=%s\n", "13");
  2589. return cqr;
  2590. }
  2591. ccw = cqr->cpaddr;
  2592. ccw->cmd_code = CCW_CMD_RDC;
  2593. if (idal_is_needed(rdc_buffer, rdc_buffer_size)) {
  2594. idaw = (unsigned long *) (cqr->data);
  2595. ccw->cda = (__u32)(addr_t) idaw;
  2596. ccw->flags = CCW_FLAG_IDA;
  2597. idaw = idal_create_words(idaw, rdc_buffer, rdc_buffer_size);
  2598. } else {
  2599. ccw->cda = (__u32)(addr_t) rdc_buffer;
  2600. ccw->flags = 0;
  2601. }
  2602. ccw->count = rdc_buffer_size;
  2603. cqr->startdev = device;
  2604. cqr->memdev = device;
  2605. cqr->expires = 10*HZ;
  2606. cqr->retries = 256;
  2607. cqr->buildclk = get_clock();
  2608. cqr->status = DASD_CQR_FILLED;
  2609. return cqr;
  2610. }
  2611. int dasd_generic_read_dev_chars(struct dasd_device *device, int magic,
  2612. void *rdc_buffer, int rdc_buffer_size)
  2613. {
  2614. int ret;
  2615. struct dasd_ccw_req *cqr;
  2616. cqr = dasd_generic_build_rdc(device, rdc_buffer, rdc_buffer_size,
  2617. magic);
  2618. if (IS_ERR(cqr))
  2619. return PTR_ERR(cqr);
  2620. ret = dasd_sleep_on(cqr);
  2621. dasd_sfree_request(cqr, cqr->memdev);
  2622. return ret;
  2623. }
  2624. EXPORT_SYMBOL_GPL(dasd_generic_read_dev_chars);
  2625. /*
  2626. * In command mode and transport mode we need to look for sense
  2627. * data in different places. The sense data itself is allways
  2628. * an array of 32 bytes, so we can unify the sense data access
  2629. * for both modes.
  2630. */
  2631. char *dasd_get_sense(struct irb *irb)
  2632. {
  2633. struct tsb *tsb = NULL;
  2634. char *sense = NULL;
  2635. if (scsw_is_tm(&irb->scsw) && (irb->scsw.tm.fcxs == 0x01)) {
  2636. if (irb->scsw.tm.tcw)
  2637. tsb = tcw_get_tsb((struct tcw *)(unsigned long)
  2638. irb->scsw.tm.tcw);
  2639. if (tsb && tsb->length == 64 && tsb->flags)
  2640. switch (tsb->flags & 0x07) {
  2641. case 1: /* tsa_iostat */
  2642. sense = tsb->tsa.iostat.sense;
  2643. break;
  2644. case 2: /* tsa_ddpc */
  2645. sense = tsb->tsa.ddpc.sense;
  2646. break;
  2647. default:
  2648. /* currently we don't use interrogate data */
  2649. break;
  2650. }
  2651. } else if (irb->esw.esw0.erw.cons) {
  2652. sense = irb->ecw;
  2653. }
  2654. return sense;
  2655. }
  2656. EXPORT_SYMBOL_GPL(dasd_get_sense);
  2657. static int __init dasd_init(void)
  2658. {
  2659. int rc;
  2660. init_waitqueue_head(&dasd_init_waitq);
  2661. init_waitqueue_head(&dasd_flush_wq);
  2662. init_waitqueue_head(&generic_waitq);
  2663. /* register 'common' DASD debug area, used for all DBF_XXX calls */
  2664. dasd_debug_area = debug_register("dasd", 1, 1, 8 * sizeof(long));
  2665. if (dasd_debug_area == NULL) {
  2666. rc = -ENOMEM;
  2667. goto failed;
  2668. }
  2669. debug_register_view(dasd_debug_area, &debug_sprintf_view);
  2670. debug_set_level(dasd_debug_area, DBF_WARNING);
  2671. DBF_EVENT(DBF_EMERG, "%s", "debug area created");
  2672. dasd_diag_discipline_pointer = NULL;
  2673. rc = dasd_devmap_init();
  2674. if (rc)
  2675. goto failed;
  2676. rc = dasd_gendisk_init();
  2677. if (rc)
  2678. goto failed;
  2679. rc = dasd_parse();
  2680. if (rc)
  2681. goto failed;
  2682. rc = dasd_eer_init();
  2683. if (rc)
  2684. goto failed;
  2685. #ifdef CONFIG_PROC_FS
  2686. rc = dasd_proc_init();
  2687. if (rc)
  2688. goto failed;
  2689. #endif
  2690. return 0;
  2691. failed:
  2692. pr_info("The DASD device driver could not be initialized\n");
  2693. dasd_exit();
  2694. return rc;
  2695. }
  2696. module_init(dasd_init);
  2697. module_exit(dasd_exit);
  2698. EXPORT_SYMBOL(dasd_debug_area);
  2699. EXPORT_SYMBOL(dasd_diag_discipline_pointer);
  2700. EXPORT_SYMBOL(dasd_add_request_head);
  2701. EXPORT_SYMBOL(dasd_add_request_tail);
  2702. EXPORT_SYMBOL(dasd_cancel_req);
  2703. EXPORT_SYMBOL(dasd_device_clear_timer);
  2704. EXPORT_SYMBOL(dasd_block_clear_timer);
  2705. EXPORT_SYMBOL(dasd_enable_device);
  2706. EXPORT_SYMBOL(dasd_int_handler);
  2707. EXPORT_SYMBOL(dasd_kfree_request);
  2708. EXPORT_SYMBOL(dasd_kick_device);
  2709. EXPORT_SYMBOL(dasd_kmalloc_request);
  2710. EXPORT_SYMBOL(dasd_schedule_device_bh);
  2711. EXPORT_SYMBOL(dasd_schedule_block_bh);
  2712. EXPORT_SYMBOL(dasd_set_target_state);
  2713. EXPORT_SYMBOL(dasd_device_set_timer);
  2714. EXPORT_SYMBOL(dasd_block_set_timer);
  2715. EXPORT_SYMBOL(dasd_sfree_request);
  2716. EXPORT_SYMBOL(dasd_sleep_on);
  2717. EXPORT_SYMBOL(dasd_sleep_on_immediatly);
  2718. EXPORT_SYMBOL(dasd_sleep_on_interruptible);
  2719. EXPORT_SYMBOL(dasd_smalloc_request);
  2720. EXPORT_SYMBOL(dasd_start_IO);
  2721. EXPORT_SYMBOL(dasd_term_IO);
  2722. EXPORT_SYMBOL_GPL(dasd_generic_probe);
  2723. EXPORT_SYMBOL_GPL(dasd_generic_remove);
  2724. EXPORT_SYMBOL_GPL(dasd_generic_notify);
  2725. EXPORT_SYMBOL_GPL(dasd_generic_set_online);
  2726. EXPORT_SYMBOL_GPL(dasd_generic_set_offline);
  2727. EXPORT_SYMBOL_GPL(dasd_generic_handle_state_change);
  2728. EXPORT_SYMBOL_GPL(dasd_flush_device_queue);
  2729. EXPORT_SYMBOL_GPL(dasd_alloc_block);
  2730. EXPORT_SYMBOL_GPL(dasd_free_block);