1*4882a593Smuzhiyun=========================== 2*4882a593SmuzhiyunLinux for S/390 and zSeries 3*4882a593Smuzhiyun=========================== 4*4882a593Smuzhiyun 5*4882a593SmuzhiyunCommon Device Support (CDS) 6*4882a593SmuzhiyunDevice Driver I/O Support Routines 7*4882a593Smuzhiyun 8*4882a593SmuzhiyunAuthors: 9*4882a593Smuzhiyun - Ingo Adlung 10*4882a593Smuzhiyun - Cornelia Huck 11*4882a593Smuzhiyun 12*4882a593SmuzhiyunCopyright, IBM Corp. 1999-2002 13*4882a593Smuzhiyun 14*4882a593SmuzhiyunIntroduction 15*4882a593Smuzhiyun============ 16*4882a593Smuzhiyun 17*4882a593SmuzhiyunThis document describes the common device support routines for Linux/390. 18*4882a593SmuzhiyunDifferent than other hardware architectures, ESA/390 has defined a unified 19*4882a593SmuzhiyunI/O access method. This gives relief to the device drivers as they don't 20*4882a593Smuzhiyunhave to deal with different bus types, polling versus interrupt 21*4882a593Smuzhiyunprocessing, shared versus non-shared interrupt processing, DMA versus port 22*4882a593SmuzhiyunI/O (PIO), and other hardware features more. However, this implies that 23*4882a593Smuzhiyuneither every single device driver needs to implement the hardware I/O 24*4882a593Smuzhiyunattachment functionality itself, or the operating system provides for a 25*4882a593Smuzhiyununified method to access the hardware, providing all the functionality that 26*4882a593Smuzhiyunevery single device driver would have to provide itself. 27*4882a593Smuzhiyun 28*4882a593SmuzhiyunThe document does not intend to explain the ESA/390 hardware architecture in 29*4882a593Smuzhiyunevery detail.This information can be obtained from the ESA/390 Principles of 30*4882a593SmuzhiyunOperation manual (IBM Form. No. SA22-7201). 31*4882a593Smuzhiyun 32*4882a593SmuzhiyunIn order to build common device support for ESA/390 I/O interfaces, a 33*4882a593Smuzhiyunfunctional layer was introduced that provides generic I/O access methods to 34*4882a593Smuzhiyunthe hardware. 35*4882a593Smuzhiyun 36*4882a593SmuzhiyunThe common device support layer comprises the I/O support routines defined 37*4882a593Smuzhiyunbelow. Some of them implement common Linux device driver interfaces, while 38*4882a593Smuzhiyunsome of them are ESA/390 platform specific. 39*4882a593Smuzhiyun 40*4882a593SmuzhiyunNote: 41*4882a593Smuzhiyun In order to write a driver for S/390, you also need to look into the interface 42*4882a593Smuzhiyun described in Documentation/s390/driver-model.rst. 43*4882a593Smuzhiyun 44*4882a593SmuzhiyunNote for porting drivers from 2.4: 45*4882a593Smuzhiyun 46*4882a593SmuzhiyunThe major changes are: 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun* The functions use a ccw_device instead of an irq (subchannel). 49*4882a593Smuzhiyun* All drivers must define a ccw_driver (see driver-model.txt) and the associated 50*4882a593Smuzhiyun functions. 51*4882a593Smuzhiyun* request_irq() and free_irq() are no longer done by the driver. 52*4882a593Smuzhiyun* The oper_handler is (kindof) replaced by the probe() and set_online() functions 53*4882a593Smuzhiyun of the ccw_driver. 54*4882a593Smuzhiyun* The not_oper_handler is (kindof) replaced by the remove() and set_offline() 55*4882a593Smuzhiyun functions of the ccw_driver. 56*4882a593Smuzhiyun* The channel device layer is gone. 57*4882a593Smuzhiyun* The interrupt handlers must be adapted to use a ccw_device as argument. 58*4882a593Smuzhiyun Moreover, they don't return a devstat, but an irb. 59*4882a593Smuzhiyun* Before initiating an io, the options must be set via ccw_device_set_options(). 60*4882a593Smuzhiyun* Instead of calling read_dev_chars()/read_conf_data(), the driver issues 61*4882a593Smuzhiyun the channel program and handles the interrupt itself. 62*4882a593Smuzhiyun 63*4882a593Smuzhiyunccw_device_get_ciw() 64*4882a593Smuzhiyun get commands from extended sense data. 65*4882a593Smuzhiyun 66*4882a593Smuzhiyunccw_device_start(), ccw_device_start_timeout(), ccw_device_start_key(), ccw_device_start_key_timeout() 67*4882a593Smuzhiyun initiate an I/O request. 68*4882a593Smuzhiyun 69*4882a593Smuzhiyunccw_device_resume() 70*4882a593Smuzhiyun resume channel program execution. 71*4882a593Smuzhiyun 72*4882a593Smuzhiyunccw_device_halt() 73*4882a593Smuzhiyun terminate the current I/O request processed on the device. 74*4882a593Smuzhiyun 75*4882a593Smuzhiyundo_IRQ() 76*4882a593Smuzhiyun generic interrupt routine. This function is called by the interrupt entry 77*4882a593Smuzhiyun routine whenever an I/O interrupt is presented to the system. The do_IRQ() 78*4882a593Smuzhiyun routine determines the interrupt status and calls the device specific 79*4882a593Smuzhiyun interrupt handler according to the rules (flags) defined during I/O request 80*4882a593Smuzhiyun initiation with do_IO(). 81*4882a593Smuzhiyun 82*4882a593SmuzhiyunThe next chapters describe the functions other than do_IRQ() in more details. 83*4882a593SmuzhiyunThe do_IRQ() interface is not described, as it is called from the Linux/390 84*4882a593Smuzhiyunfirst level interrupt handler only and does not comprise a device driver 85*4882a593Smuzhiyuncallable interface. Instead, the functional description of do_IO() also 86*4882a593Smuzhiyundescribes the input to the device specific interrupt handler. 87*4882a593Smuzhiyun 88*4882a593SmuzhiyunNote: 89*4882a593Smuzhiyun All explanations apply also to the 64 bit architecture s390x. 90*4882a593Smuzhiyun 91*4882a593Smuzhiyun 92*4882a593SmuzhiyunCommon Device Support (CDS) for Linux/390 Device Drivers 93*4882a593Smuzhiyun======================================================== 94*4882a593Smuzhiyun 95*4882a593SmuzhiyunGeneral Information 96*4882a593Smuzhiyun------------------- 97*4882a593Smuzhiyun 98*4882a593SmuzhiyunThe following chapters describe the I/O related interface routines the 99*4882a593SmuzhiyunLinux/390 common device support (CDS) provides to allow for device specific 100*4882a593Smuzhiyundriver implementations on the IBM ESA/390 hardware platform. Those interfaces 101*4882a593Smuzhiyunintend to provide the functionality required by every device driver 102*4882a593Smuzhiyunimplementation to allow to drive a specific hardware device on the ESA/390 103*4882a593Smuzhiyunplatform. Some of the interface routines are specific to Linux/390 and some 104*4882a593Smuzhiyunof them can be found on other Linux platforms implementations too. 105*4882a593SmuzhiyunMiscellaneous function prototypes, data declarations, and macro definitions 106*4882a593Smuzhiyuncan be found in the architecture specific C header file 107*4882a593Smuzhiyunlinux/arch/s390/include/asm/irq.h. 108*4882a593Smuzhiyun 109*4882a593SmuzhiyunOverview of CDS interface concepts 110*4882a593Smuzhiyun---------------------------------- 111*4882a593Smuzhiyun 112*4882a593SmuzhiyunDifferent to other hardware platforms, the ESA/390 architecture doesn't define 113*4882a593Smuzhiyuninterrupt lines managed by a specific interrupt controller and bus systems 114*4882a593Smuzhiyunthat may or may not allow for shared interrupts, DMA processing, etc.. Instead, 115*4882a593Smuzhiyunthe ESA/390 architecture has implemented a so called channel subsystem, that 116*4882a593Smuzhiyunprovides a unified view of the devices physically attached to the systems. 117*4882a593SmuzhiyunThough the ESA/390 hardware platform knows about a huge variety of different 118*4882a593Smuzhiyunperipheral attachments like disk devices (aka. DASDs), tapes, communication 119*4882a593Smuzhiyuncontrollers, etc. they can all be accessed by a well defined access method and 120*4882a593Smuzhiyunthey are presenting I/O completion a unified way : I/O interruptions. Every 121*4882a593Smuzhiyunsingle device is uniquely identified to the system by a so called subchannel, 122*4882a593Smuzhiyunwhere the ESA/390 architecture allows for 64k devices be attached. 123*4882a593Smuzhiyun 124*4882a593SmuzhiyunLinux, however, was first built on the Intel PC architecture, with its two 125*4882a593Smuzhiyuncascaded 8259 programmable interrupt controllers (PICs), that allow for a 126*4882a593Smuzhiyunmaximum of 15 different interrupt lines. All devices attached to such a system 127*4882a593Smuzhiyunshare those 15 interrupt levels. Devices attached to the ISA bus system must 128*4882a593Smuzhiyunnot share interrupt levels (aka. IRQs), as the ISA bus bases on edge triggered 129*4882a593Smuzhiyuninterrupts. MCA, EISA, PCI and other bus systems base on level triggered 130*4882a593Smuzhiyuninterrupts, and therewith allow for shared IRQs. However, if multiple devices 131*4882a593Smuzhiyunpresent their hardware status by the same (shared) IRQ, the operating system 132*4882a593Smuzhiyunhas to call every single device driver registered on this IRQ in order to 133*4882a593Smuzhiyundetermine the device driver owning the device that raised the interrupt. 134*4882a593Smuzhiyun 135*4882a593SmuzhiyunUp to kernel 2.4, Linux/390 used to provide interfaces via the IRQ (subchannel). 136*4882a593SmuzhiyunFor internal use of the common I/O layer, these are still there. However, 137*4882a593Smuzhiyundevice drivers should use the new calling interface via the ccw_device only. 138*4882a593Smuzhiyun 139*4882a593SmuzhiyunDuring its startup the Linux/390 system checks for peripheral devices. Each 140*4882a593Smuzhiyunof those devices is uniquely defined by a so called subchannel by the ESA/390 141*4882a593Smuzhiyunchannel subsystem. While the subchannel numbers are system generated, each 142*4882a593Smuzhiyunsubchannel also takes a user defined attribute, the so called device number. 143*4882a593SmuzhiyunBoth subchannel number and device number cannot exceed 65535. During sysfs 144*4882a593Smuzhiyuninitialisation, the information about control unit type and device types that 145*4882a593Smuzhiyunimply specific I/O commands (channel command words - CCWs) in order to operate 146*4882a593Smuzhiyunthe device are gathered. Device drivers can retrieve this set of hardware 147*4882a593Smuzhiyuninformation during their initialization step to recognize the devices they 148*4882a593Smuzhiyunsupport using the information saved in the struct ccw_device given to them. 149*4882a593SmuzhiyunThis methods implies that Linux/390 doesn't require to probe for free (not 150*4882a593Smuzhiyunarmed) interrupt request lines (IRQs) to drive its devices with. Where 151*4882a593Smuzhiyunapplicable, the device drivers can use issue the READ DEVICE CHARACTERISTICS 152*4882a593Smuzhiyunccw to retrieve device characteristics in its online routine. 153*4882a593Smuzhiyun 154*4882a593SmuzhiyunIn order to allow for easy I/O initiation the CDS layer provides a 155*4882a593Smuzhiyunccw_device_start() interface that takes a device specific channel program (one 156*4882a593Smuzhiyunor more CCWs) as input sets up the required architecture specific control blocks 157*4882a593Smuzhiyunand initiates an I/O request on behalf of the device driver. The 158*4882a593Smuzhiyunccw_device_start() routine allows to specify whether it expects the CDS layer 159*4882a593Smuzhiyunto notify the device driver for every interrupt it observes, or with final status 160*4882a593Smuzhiyunonly. See ccw_device_start() for more details. A device driver must never issue 161*4882a593SmuzhiyunESA/390 I/O commands itself, but must use the Linux/390 CDS interfaces instead. 162*4882a593Smuzhiyun 163*4882a593SmuzhiyunFor long running I/O request to be canceled, the CDS layer provides the 164*4882a593Smuzhiyunccw_device_halt() function. Some devices require to initially issue a HALT 165*4882a593SmuzhiyunSUBCHANNEL (HSCH) command without having pending I/O requests. This function is 166*4882a593Smuzhiyunalso covered by ccw_device_halt(). 167*4882a593Smuzhiyun 168*4882a593Smuzhiyun 169*4882a593Smuzhiyunget_ciw() - get command information word 170*4882a593Smuzhiyun 171*4882a593SmuzhiyunThis call enables a device driver to get information about supported commands 172*4882a593Smuzhiyunfrom the extended SenseID data. 173*4882a593Smuzhiyun 174*4882a593Smuzhiyun:: 175*4882a593Smuzhiyun 176*4882a593Smuzhiyun struct ciw * 177*4882a593Smuzhiyun ccw_device_get_ciw(struct ccw_device *cdev, __u32 cmd); 178*4882a593Smuzhiyun 179*4882a593Smuzhiyun==== ======================================================== 180*4882a593Smuzhiyuncdev The ccw_device for which the command is to be retrieved. 181*4882a593Smuzhiyuncmd The command type to be retrieved. 182*4882a593Smuzhiyun==== ======================================================== 183*4882a593Smuzhiyun 184*4882a593Smuzhiyunccw_device_get_ciw() returns: 185*4882a593Smuzhiyun 186*4882a593Smuzhiyun===== ================================================================ 187*4882a593Smuzhiyun NULL No extended data available, invalid device or command not found. 188*4882a593Smuzhiyun!NULL The command requested. 189*4882a593Smuzhiyun===== ================================================================ 190*4882a593Smuzhiyun 191*4882a593Smuzhiyun:: 192*4882a593Smuzhiyun 193*4882a593Smuzhiyun ccw_device_start() - Initiate I/O Request 194*4882a593Smuzhiyun 195*4882a593SmuzhiyunThe ccw_device_start() routines is the I/O request front-end processor. All 196*4882a593Smuzhiyundevice driver I/O requests must be issued using this routine. A device driver 197*4882a593Smuzhiyunmust not issue ESA/390 I/O commands itself. Instead the ccw_device_start() 198*4882a593Smuzhiyunroutine provides all interfaces required to drive arbitrary devices. 199*4882a593Smuzhiyun 200*4882a593SmuzhiyunThis description also covers the status information passed to the device 201*4882a593Smuzhiyundriver's interrupt handler as this is related to the rules (flags) defined 202*4882a593Smuzhiyunwith the associated I/O request when calling ccw_device_start(). 203*4882a593Smuzhiyun 204*4882a593Smuzhiyun:: 205*4882a593Smuzhiyun 206*4882a593Smuzhiyun int ccw_device_start(struct ccw_device *cdev, 207*4882a593Smuzhiyun struct ccw1 *cpa, 208*4882a593Smuzhiyun unsigned long intparm, 209*4882a593Smuzhiyun __u8 lpm, 210*4882a593Smuzhiyun unsigned long flags); 211*4882a593Smuzhiyun int ccw_device_start_timeout(struct ccw_device *cdev, 212*4882a593Smuzhiyun struct ccw1 *cpa, 213*4882a593Smuzhiyun unsigned long intparm, 214*4882a593Smuzhiyun __u8 lpm, 215*4882a593Smuzhiyun unsigned long flags, 216*4882a593Smuzhiyun int expires); 217*4882a593Smuzhiyun int ccw_device_start_key(struct ccw_device *cdev, 218*4882a593Smuzhiyun struct ccw1 *cpa, 219*4882a593Smuzhiyun unsigned long intparm, 220*4882a593Smuzhiyun __u8 lpm, 221*4882a593Smuzhiyun __u8 key, 222*4882a593Smuzhiyun unsigned long flags); 223*4882a593Smuzhiyun int ccw_device_start_key_timeout(struct ccw_device *cdev, 224*4882a593Smuzhiyun struct ccw1 *cpa, 225*4882a593Smuzhiyun unsigned long intparm, 226*4882a593Smuzhiyun __u8 lpm, 227*4882a593Smuzhiyun __u8 key, 228*4882a593Smuzhiyun unsigned long flags, 229*4882a593Smuzhiyun int expires); 230*4882a593Smuzhiyun 231*4882a593Smuzhiyun============= ============================================================= 232*4882a593Smuzhiyuncdev ccw_device the I/O is destined for 233*4882a593Smuzhiyuncpa logical start address of channel program 234*4882a593Smuzhiyunuser_intparm user specific interrupt information; will be presented 235*4882a593Smuzhiyun back to the device driver's interrupt handler. Allows a 236*4882a593Smuzhiyun device driver to associate the interrupt with a 237*4882a593Smuzhiyun particular I/O request. 238*4882a593Smuzhiyunlpm defines the channel path to be used for a specific I/O 239*4882a593Smuzhiyun request. A value of 0 will make cio use the opm. 240*4882a593Smuzhiyunkey the storage key to use for the I/O (useful for operating on a 241*4882a593Smuzhiyun storage with a storage key != default key) 242*4882a593Smuzhiyunflag defines the action to be performed for I/O processing 243*4882a593Smuzhiyunexpires timeout value in jiffies. The common I/O layer will terminate 244*4882a593Smuzhiyun the running program after this and call the interrupt handler 245*4882a593Smuzhiyun with ERR_PTR(-ETIMEDOUT) as irb. 246*4882a593Smuzhiyun============= ============================================================= 247*4882a593Smuzhiyun 248*4882a593SmuzhiyunPossible flag values are: 249*4882a593Smuzhiyun 250*4882a593Smuzhiyun========================= ============================================= 251*4882a593SmuzhiyunDOIO_ALLOW_SUSPEND channel program may become suspended 252*4882a593SmuzhiyunDOIO_DENY_PREFETCH don't allow for CCW prefetch; usually 253*4882a593Smuzhiyun this implies the channel program might 254*4882a593Smuzhiyun become modified 255*4882a593SmuzhiyunDOIO_SUPPRESS_INTER don't call the handler on intermediate status 256*4882a593Smuzhiyun========================= ============================================= 257*4882a593Smuzhiyun 258*4882a593SmuzhiyunThe cpa parameter points to the first format 1 CCW of a channel program:: 259*4882a593Smuzhiyun 260*4882a593Smuzhiyun struct ccw1 { 261*4882a593Smuzhiyun __u8 cmd_code;/* command code */ 262*4882a593Smuzhiyun __u8 flags; /* flags, like IDA addressing, etc. */ 263*4882a593Smuzhiyun __u16 count; /* byte count */ 264*4882a593Smuzhiyun __u32 cda; /* data address */ 265*4882a593Smuzhiyun } __attribute__ ((packed,aligned(8))); 266*4882a593Smuzhiyun 267*4882a593Smuzhiyunwith the following CCW flags values defined: 268*4882a593Smuzhiyun 269*4882a593Smuzhiyun=================== ========================= 270*4882a593SmuzhiyunCCW_FLAG_DC data chaining 271*4882a593SmuzhiyunCCW_FLAG_CC command chaining 272*4882a593SmuzhiyunCCW_FLAG_SLI suppress incorrect length 273*4882a593SmuzhiyunCCW_FLAG_SKIP skip 274*4882a593SmuzhiyunCCW_FLAG_PCI PCI 275*4882a593SmuzhiyunCCW_FLAG_IDA indirect addressing 276*4882a593SmuzhiyunCCW_FLAG_SUSPEND suspend 277*4882a593Smuzhiyun=================== ========================= 278*4882a593Smuzhiyun 279*4882a593Smuzhiyun 280*4882a593SmuzhiyunVia ccw_device_set_options(), the device driver may specify the following 281*4882a593Smuzhiyunoptions for the device: 282*4882a593Smuzhiyun 283*4882a593Smuzhiyun========================= ====================================== 284*4882a593SmuzhiyunDOIO_EARLY_NOTIFICATION allow for early interrupt notification 285*4882a593SmuzhiyunDOIO_REPORT_ALL report all interrupt conditions 286*4882a593Smuzhiyun========================= ====================================== 287*4882a593Smuzhiyun 288*4882a593Smuzhiyun 289*4882a593SmuzhiyunThe ccw_device_start() function returns: 290*4882a593Smuzhiyun 291*4882a593Smuzhiyun======== ====================================================================== 292*4882a593Smuzhiyun 0 successful completion or request successfully initiated 293*4882a593Smuzhiyun -EBUSY The device is currently processing a previous I/O request, or there is 294*4882a593Smuzhiyun a status pending at the device. 295*4882a593Smuzhiyun-ENODEV cdev is invalid, the device is not operational or the ccw_device is 296*4882a593Smuzhiyun not online. 297*4882a593Smuzhiyun======== ====================================================================== 298*4882a593Smuzhiyun 299*4882a593SmuzhiyunWhen the I/O request completes, the CDS first level interrupt handler will 300*4882a593Smuzhiyunaccumulate the status in a struct irb and then call the device interrupt handler. 301*4882a593SmuzhiyunThe intparm field will contain the value the device driver has associated with a 302*4882a593Smuzhiyunparticular I/O request. If a pending device status was recognized, 303*4882a593Smuzhiyunintparm will be set to 0 (zero). This may happen during I/O initiation or delayed 304*4882a593Smuzhiyunby an alert status notification. In any case this status is not related to the 305*4882a593Smuzhiyuncurrent (last) I/O request. In case of a delayed status notification no special 306*4882a593Smuzhiyuninterrupt will be presented to indicate I/O completion as the I/O request was 307*4882a593Smuzhiyunnever started, even though ccw_device_start() returned with successful completion. 308*4882a593Smuzhiyun 309*4882a593SmuzhiyunThe irb may contain an error value, and the device driver should check for this 310*4882a593Smuzhiyunfirst: 311*4882a593Smuzhiyun 312*4882a593Smuzhiyun========== ================================================================= 313*4882a593Smuzhiyun-ETIMEDOUT the common I/O layer terminated the request after the specified 314*4882a593Smuzhiyun timeout value 315*4882a593Smuzhiyun-EIO the common I/O layer terminated the request due to an error state 316*4882a593Smuzhiyun========== ================================================================= 317*4882a593Smuzhiyun 318*4882a593SmuzhiyunIf the concurrent sense flag in the extended status word (esw) in the irb is 319*4882a593Smuzhiyunset, the field erw.scnt in the esw describes the number of device specific 320*4882a593Smuzhiyunsense bytes available in the extended control word irb->scsw.ecw[]. No device 321*4882a593Smuzhiyunsensing by the device driver itself is required. 322*4882a593Smuzhiyun 323*4882a593SmuzhiyunThe device interrupt handler can use the following definitions to investigate 324*4882a593Smuzhiyunthe primary unit check source coded in sense byte 0 : 325*4882a593Smuzhiyun 326*4882a593Smuzhiyun======================= ==== 327*4882a593SmuzhiyunSNS0_CMD_REJECT 0x80 328*4882a593SmuzhiyunSNS0_INTERVENTION_REQ 0x40 329*4882a593SmuzhiyunSNS0_BUS_OUT_CHECK 0x20 330*4882a593SmuzhiyunSNS0_EQUIPMENT_CHECK 0x10 331*4882a593SmuzhiyunSNS0_DATA_CHECK 0x08 332*4882a593SmuzhiyunSNS0_OVERRUN 0x04 333*4882a593SmuzhiyunSNS0_INCOMPL_DOMAIN 0x01 334*4882a593Smuzhiyun======================= ==== 335*4882a593Smuzhiyun 336*4882a593SmuzhiyunDepending on the device status, multiple of those values may be set together. 337*4882a593SmuzhiyunPlease refer to the device specific documentation for details. 338*4882a593Smuzhiyun 339*4882a593SmuzhiyunThe irb->scsw.cstat field provides the (accumulated) subchannel status : 340*4882a593Smuzhiyun 341*4882a593Smuzhiyun========================= ============================ 342*4882a593SmuzhiyunSCHN_STAT_PCI program controlled interrupt 343*4882a593SmuzhiyunSCHN_STAT_INCORR_LEN incorrect length 344*4882a593SmuzhiyunSCHN_STAT_PROG_CHECK program check 345*4882a593SmuzhiyunSCHN_STAT_PROT_CHECK protection check 346*4882a593SmuzhiyunSCHN_STAT_CHN_DATA_CHK channel data check 347*4882a593SmuzhiyunSCHN_STAT_CHN_CTRL_CHK channel control check 348*4882a593SmuzhiyunSCHN_STAT_INTF_CTRL_CHK interface control check 349*4882a593SmuzhiyunSCHN_STAT_CHAIN_CHECK chaining check 350*4882a593Smuzhiyun========================= ============================ 351*4882a593Smuzhiyun 352*4882a593SmuzhiyunThe irb->scsw.dstat field provides the (accumulated) device status : 353*4882a593Smuzhiyun 354*4882a593Smuzhiyun===================== ================= 355*4882a593SmuzhiyunDEV_STAT_ATTENTION attention 356*4882a593SmuzhiyunDEV_STAT_STAT_MOD status modifier 357*4882a593SmuzhiyunDEV_STAT_CU_END control unit end 358*4882a593SmuzhiyunDEV_STAT_BUSY busy 359*4882a593SmuzhiyunDEV_STAT_CHN_END channel end 360*4882a593SmuzhiyunDEV_STAT_DEV_END device end 361*4882a593SmuzhiyunDEV_STAT_UNIT_CHECK unit check 362*4882a593SmuzhiyunDEV_STAT_UNIT_EXCEP unit exception 363*4882a593Smuzhiyun===================== ================= 364*4882a593Smuzhiyun 365*4882a593SmuzhiyunPlease see the ESA/390 Principles of Operation manual for details on the 366*4882a593Smuzhiyunindividual flag meanings. 367*4882a593Smuzhiyun 368*4882a593SmuzhiyunUsage Notes: 369*4882a593Smuzhiyun 370*4882a593Smuzhiyunccw_device_start() must be called disabled and with the ccw device lock held. 371*4882a593Smuzhiyun 372*4882a593SmuzhiyunThe device driver is allowed to issue the next ccw_device_start() call from 373*4882a593Smuzhiyunwithin its interrupt handler already. It is not required to schedule a 374*4882a593Smuzhiyunbottom-half, unless a non deterministically long running error recovery procedure 375*4882a593Smuzhiyunor similar needs to be scheduled. During I/O processing the Linux/390 generic 376*4882a593SmuzhiyunI/O device driver support has already obtained the IRQ lock, i.e. the handler 377*4882a593Smuzhiyunmust not try to obtain it again when calling ccw_device_start() or we end in a 378*4882a593Smuzhiyundeadlock situation! 379*4882a593Smuzhiyun 380*4882a593SmuzhiyunIf a device driver relies on an I/O request to be completed prior to start the 381*4882a593Smuzhiyunnext it can reduce I/O processing overhead by chaining a NoOp I/O command 382*4882a593SmuzhiyunCCW_CMD_NOOP to the end of the submitted CCW chain. This will force Channel-End 383*4882a593Smuzhiyunand Device-End status to be presented together, with a single interrupt. 384*4882a593SmuzhiyunHowever, this should be used with care as it implies the channel will remain 385*4882a593Smuzhiyunbusy, not being able to process I/O requests for other devices on the same 386*4882a593Smuzhiyunchannel. Therefore e.g. read commands should never use this technique, as the 387*4882a593Smuzhiyunresult will be presented by a single interrupt anyway. 388*4882a593Smuzhiyun 389*4882a593SmuzhiyunIn order to minimize I/O overhead, a device driver should use the 390*4882a593SmuzhiyunDOIO_REPORT_ALL only if the device can report intermediate interrupt 391*4882a593Smuzhiyuninformation prior to device-end the device driver urgently relies on. In this 392*4882a593Smuzhiyuncase all I/O interruptions are presented to the device driver until final 393*4882a593Smuzhiyunstatus is recognized. 394*4882a593Smuzhiyun 395*4882a593SmuzhiyunIf a device is able to recover from asynchronously presented I/O errors, it can 396*4882a593Smuzhiyunperform overlapping I/O using the DOIO_EARLY_NOTIFICATION flag. While some 397*4882a593Smuzhiyundevices always report channel-end and device-end together, with a single 398*4882a593Smuzhiyuninterrupt, others present primary status (channel-end) when the channel is 399*4882a593Smuzhiyunready for the next I/O request and secondary status (device-end) when the data 400*4882a593Smuzhiyuntransmission has been completed at the device. 401*4882a593Smuzhiyun 402*4882a593SmuzhiyunAbove flag allows to exploit this feature, e.g. for communication devices that 403*4882a593Smuzhiyuncan handle lost data on the network to allow for enhanced I/O processing. 404*4882a593Smuzhiyun 405*4882a593SmuzhiyunUnless the channel subsystem at any time presents a secondary status interrupt, 406*4882a593Smuzhiyunexploiting this feature will cause only primary status interrupts to be 407*4882a593Smuzhiyunpresented to the device driver while overlapping I/O is performed. When a 408*4882a593Smuzhiyunsecondary status without error (alert status) is presented, this indicates 409*4882a593Smuzhiyunsuccessful completion for all overlapping ccw_device_start() requests that have 410*4882a593Smuzhiyunbeen issued since the last secondary (final) status. 411*4882a593Smuzhiyun 412*4882a593SmuzhiyunChannel programs that intend to set the suspend flag on a channel command word 413*4882a593Smuzhiyun(CCW) must start the I/O operation with the DOIO_ALLOW_SUSPEND option or the 414*4882a593Smuzhiyunsuspend flag will cause a channel program check. At the time the channel program 415*4882a593Smuzhiyunbecomes suspended an intermediate interrupt will be generated by the channel 416*4882a593Smuzhiyunsubsystem. 417*4882a593Smuzhiyun 418*4882a593Smuzhiyunccw_device_resume() - Resume Channel Program Execution 419*4882a593Smuzhiyun 420*4882a593SmuzhiyunIf a device driver chooses to suspend the current channel program execution by 421*4882a593Smuzhiyunsetting the CCW suspend flag on a particular CCW, the channel program execution 422*4882a593Smuzhiyunis suspended. In order to resume channel program execution the CIO layer 423*4882a593Smuzhiyunprovides the ccw_device_resume() routine. 424*4882a593Smuzhiyun 425*4882a593Smuzhiyun:: 426*4882a593Smuzhiyun 427*4882a593Smuzhiyun int ccw_device_resume(struct ccw_device *cdev); 428*4882a593Smuzhiyun 429*4882a593Smuzhiyun==== ================================================ 430*4882a593Smuzhiyuncdev ccw_device the resume operation is requested for 431*4882a593Smuzhiyun==== ================================================ 432*4882a593Smuzhiyun 433*4882a593SmuzhiyunThe ccw_device_resume() function returns: 434*4882a593Smuzhiyun 435*4882a593Smuzhiyun========= ============================================== 436*4882a593Smuzhiyun 0 suspended channel program is resumed 437*4882a593Smuzhiyun -EBUSY status pending 438*4882a593Smuzhiyun -ENODEV cdev invalid or not-operational subchannel 439*4882a593Smuzhiyun -EINVAL resume function not applicable 440*4882a593Smuzhiyun-ENOTCONN there is no I/O request pending for completion 441*4882a593Smuzhiyun========= ============================================== 442*4882a593Smuzhiyun 443*4882a593SmuzhiyunUsage Notes: 444*4882a593Smuzhiyun 445*4882a593SmuzhiyunPlease have a look at the ccw_device_start() usage notes for more details on 446*4882a593Smuzhiyunsuspended channel programs. 447*4882a593Smuzhiyun 448*4882a593Smuzhiyunccw_device_halt() - Halt I/O Request Processing 449*4882a593Smuzhiyun 450*4882a593SmuzhiyunSometimes a device driver might need a possibility to stop the processing of 451*4882a593Smuzhiyuna long-running channel program or the device might require to initially issue 452*4882a593Smuzhiyuna halt subchannel (HSCH) I/O command. For those purposes the ccw_device_halt() 453*4882a593Smuzhiyuncommand is provided. 454*4882a593Smuzhiyun 455*4882a593Smuzhiyunccw_device_halt() must be called disabled and with the ccw device lock held. 456*4882a593Smuzhiyun 457*4882a593Smuzhiyun:: 458*4882a593Smuzhiyun 459*4882a593Smuzhiyun int ccw_device_halt(struct ccw_device *cdev, 460*4882a593Smuzhiyun unsigned long intparm); 461*4882a593Smuzhiyun 462*4882a593Smuzhiyun======= ===================================================== 463*4882a593Smuzhiyuncdev ccw_device the halt operation is requested for 464*4882a593Smuzhiyunintparm interruption parameter; value is only used if no I/O 465*4882a593Smuzhiyun is outstanding, otherwise the intparm associated with 466*4882a593Smuzhiyun the I/O request is returned 467*4882a593Smuzhiyun======= ===================================================== 468*4882a593Smuzhiyun 469*4882a593SmuzhiyunThe ccw_device_halt() function returns: 470*4882a593Smuzhiyun 471*4882a593Smuzhiyun======= ============================================================== 472*4882a593Smuzhiyun 0 request successfully initiated 473*4882a593Smuzhiyun-EBUSY the device is currently busy, or status pending. 474*4882a593Smuzhiyun-ENODEV cdev invalid. 475*4882a593Smuzhiyun-EINVAL The device is not operational or the ccw device is not online. 476*4882a593Smuzhiyun======= ============================================================== 477*4882a593Smuzhiyun 478*4882a593SmuzhiyunUsage Notes: 479*4882a593Smuzhiyun 480*4882a593SmuzhiyunA device driver may write a never-ending channel program by writing a channel 481*4882a593Smuzhiyunprogram that at its end loops back to its beginning by means of a transfer in 482*4882a593Smuzhiyunchannel (TIC) command (CCW_CMD_TIC). Usually this is performed by network 483*4882a593Smuzhiyundevice drivers by setting the PCI CCW flag (CCW_FLAG_PCI). Once this CCW is 484*4882a593Smuzhiyunexecuted a program controlled interrupt (PCI) is generated. The device driver 485*4882a593Smuzhiyuncan then perform an appropriate action. Prior to interrupt of an outstanding 486*4882a593Smuzhiyunread to a network device (with or without PCI flag) a ccw_device_halt() 487*4882a593Smuzhiyunis required to end the pending operation. 488*4882a593Smuzhiyun 489*4882a593Smuzhiyun:: 490*4882a593Smuzhiyun 491*4882a593Smuzhiyun ccw_device_clear() - Terminage I/O Request Processing 492*4882a593Smuzhiyun 493*4882a593SmuzhiyunIn order to terminate all I/O processing at the subchannel, the clear subchannel 494*4882a593Smuzhiyun(CSCH) command is used. It can be issued via ccw_device_clear(). 495*4882a593Smuzhiyun 496*4882a593Smuzhiyunccw_device_clear() must be called disabled and with the ccw device lock held. 497*4882a593Smuzhiyun 498*4882a593Smuzhiyun:: 499*4882a593Smuzhiyun 500*4882a593Smuzhiyun int ccw_device_clear(struct ccw_device *cdev, unsigned long intparm); 501*4882a593Smuzhiyun 502*4882a593Smuzhiyun======= =============================================== 503*4882a593Smuzhiyuncdev ccw_device the clear operation is requested for 504*4882a593Smuzhiyunintparm interruption parameter (see ccw_device_halt()) 505*4882a593Smuzhiyun======= =============================================== 506*4882a593Smuzhiyun 507*4882a593SmuzhiyunThe ccw_device_clear() function returns: 508*4882a593Smuzhiyun 509*4882a593Smuzhiyun======= ============================================================== 510*4882a593Smuzhiyun 0 request successfully initiated 511*4882a593Smuzhiyun-ENODEV cdev invalid 512*4882a593Smuzhiyun-EINVAL The device is not operational or the ccw device is not online. 513*4882a593Smuzhiyun======= ============================================================== 514*4882a593Smuzhiyun 515*4882a593SmuzhiyunMiscellaneous Support Routines 516*4882a593Smuzhiyun------------------------------ 517*4882a593Smuzhiyun 518*4882a593SmuzhiyunThis chapter describes various routines to be used in a Linux/390 device 519*4882a593Smuzhiyundriver programming environment. 520*4882a593Smuzhiyun 521*4882a593Smuzhiyunget_ccwdev_lock() 522*4882a593Smuzhiyun 523*4882a593SmuzhiyunGet the address of the device specific lock. This is then used in 524*4882a593Smuzhiyunspin_lock() / spin_unlock() calls. 525*4882a593Smuzhiyun 526*4882a593Smuzhiyun:: 527*4882a593Smuzhiyun 528*4882a593Smuzhiyun __u8 ccw_device_get_path_mask(struct ccw_device *cdev); 529*4882a593Smuzhiyun 530*4882a593SmuzhiyunGet the mask of the path currently available for cdev. 531