| .. | .. |
|---|
| 3 | 3 | * VFIO based Physical Subchannel device driver |
|---|
| 4 | 4 | * |
|---|
| 5 | 5 | * Copyright IBM Corp. 2017 |
|---|
| 6 | + * Copyright Red Hat, Inc. 2019 |
|---|
| 6 | 7 | * |
|---|
| 7 | 8 | * Author(s): Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com> |
|---|
| 8 | 9 | * Xiao Feng Ren <renxiaof@linux.vnet.ibm.com> |
|---|
| 10 | + * Cornelia Huck <cohuck@redhat.com> |
|---|
| 9 | 11 | */ |
|---|
| 10 | 12 | |
|---|
| 11 | 13 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 17 | 19 | |
|---|
| 18 | 20 | #include <asm/isc.h> |
|---|
| 19 | 21 | |
|---|
| 22 | +#include "chp.h" |
|---|
| 20 | 23 | #include "ioasm.h" |
|---|
| 21 | 24 | #include "css.h" |
|---|
| 22 | 25 | #include "vfio_ccw_private.h" |
|---|
| 23 | 26 | |
|---|
| 24 | 27 | struct workqueue_struct *vfio_ccw_work_q; |
|---|
| 25 | | -struct kmem_cache *vfio_ccw_io_region; |
|---|
| 28 | +static struct kmem_cache *vfio_ccw_io_region; |
|---|
| 29 | +static struct kmem_cache *vfio_ccw_cmd_region; |
|---|
| 30 | +static struct kmem_cache *vfio_ccw_schib_region; |
|---|
| 31 | +static struct kmem_cache *vfio_ccw_crw_region; |
|---|
| 32 | + |
|---|
| 33 | +debug_info_t *vfio_ccw_debug_msg_id; |
|---|
| 34 | +debug_info_t *vfio_ccw_debug_trace_id; |
|---|
| 26 | 35 | |
|---|
| 27 | 36 | /* |
|---|
| 28 | 37 | * Helpers |
|---|
| .. | .. |
|---|
| 77 | 86 | struct vfio_ccw_private *private; |
|---|
| 78 | 87 | struct irb *irb; |
|---|
| 79 | 88 | bool is_final; |
|---|
| 89 | + bool cp_is_finished = false; |
|---|
| 80 | 90 | |
|---|
| 81 | 91 | private = container_of(work, struct vfio_ccw_private, io_work); |
|---|
| 82 | 92 | irb = &private->irb; |
|---|
| .. | .. |
|---|
| 85 | 95 | (SCSW_ACTL_DEVACT | SCSW_ACTL_SCHACT)); |
|---|
| 86 | 96 | if (scsw_is_solicited(&irb->scsw)) { |
|---|
| 87 | 97 | cp_update_scsw(&private->cp, &irb->scsw); |
|---|
| 88 | | - if (is_final) |
|---|
| 98 | + if (is_final && private->state == VFIO_CCW_STATE_CP_PENDING) { |
|---|
| 89 | 99 | cp_free(&private->cp); |
|---|
| 100 | + cp_is_finished = true; |
|---|
| 101 | + } |
|---|
| 90 | 102 | } |
|---|
| 103 | + mutex_lock(&private->io_mutex); |
|---|
| 91 | 104 | memcpy(private->io_region->irb_area, irb, sizeof(*irb)); |
|---|
| 105 | + mutex_unlock(&private->io_mutex); |
|---|
| 106 | + |
|---|
| 107 | + /* |
|---|
| 108 | + * Reset to IDLE only if processing of a channel program |
|---|
| 109 | + * has finished. Do not overwrite a possible processing |
|---|
| 110 | + * state if the final interrupt was for HSCH or CSCH. |
|---|
| 111 | + */ |
|---|
| 112 | + if (private->mdev && cp_is_finished) |
|---|
| 113 | + private->state = VFIO_CCW_STATE_IDLE; |
|---|
| 92 | 114 | |
|---|
| 93 | 115 | if (private->io_trigger) |
|---|
| 94 | 116 | eventfd_signal(private->io_trigger, 1); |
|---|
| 117 | +} |
|---|
| 95 | 118 | |
|---|
| 96 | | - if (private->mdev && is_final) |
|---|
| 97 | | - private->state = VFIO_CCW_STATE_IDLE; |
|---|
| 119 | +static void vfio_ccw_crw_todo(struct work_struct *work) |
|---|
| 120 | +{ |
|---|
| 121 | + struct vfio_ccw_private *private; |
|---|
| 122 | + |
|---|
| 123 | + private = container_of(work, struct vfio_ccw_private, crw_work); |
|---|
| 124 | + |
|---|
| 125 | + if (!list_empty(&private->crw) && private->crw_trigger) |
|---|
| 126 | + eventfd_signal(private->crw_trigger, 1); |
|---|
| 98 | 127 | } |
|---|
| 99 | 128 | |
|---|
| 100 | 129 | /* |
|---|
| .. | .. |
|---|
| 108 | 137 | vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_INTERRUPT); |
|---|
| 109 | 138 | } |
|---|
| 110 | 139 | |
|---|
| 140 | +static void vfio_ccw_free_regions(struct vfio_ccw_private *private) |
|---|
| 141 | +{ |
|---|
| 142 | + if (private->crw_region) |
|---|
| 143 | + kmem_cache_free(vfio_ccw_crw_region, private->crw_region); |
|---|
| 144 | + if (private->schib_region) |
|---|
| 145 | + kmem_cache_free(vfio_ccw_schib_region, private->schib_region); |
|---|
| 146 | + if (private->cmd_region) |
|---|
| 147 | + kmem_cache_free(vfio_ccw_cmd_region, private->cmd_region); |
|---|
| 148 | + if (private->io_region) |
|---|
| 149 | + kmem_cache_free(vfio_ccw_io_region, private->io_region); |
|---|
| 150 | +} |
|---|
| 151 | + |
|---|
| 111 | 152 | static int vfio_ccw_sch_probe(struct subchannel *sch) |
|---|
| 112 | 153 | { |
|---|
| 113 | 154 | struct pmcw *pmcw = &sch->schib.pmcw; |
|---|
| 114 | 155 | struct vfio_ccw_private *private; |
|---|
| 115 | | - int ret; |
|---|
| 156 | + int ret = -ENOMEM; |
|---|
| 116 | 157 | |
|---|
| 117 | 158 | if (pmcw->qf) { |
|---|
| 118 | 159 | dev_warn(&sch->dev, "vfio: ccw: does not support QDIO: %s\n", |
|---|
| .. | .. |
|---|
| 124 | 165 | if (!private) |
|---|
| 125 | 166 | return -ENOMEM; |
|---|
| 126 | 167 | |
|---|
| 168 | + private->cp.guest_cp = kcalloc(CCWCHAIN_LEN_MAX, sizeof(struct ccw1), |
|---|
| 169 | + GFP_KERNEL); |
|---|
| 170 | + if (!private->cp.guest_cp) |
|---|
| 171 | + goto out_free; |
|---|
| 172 | + |
|---|
| 127 | 173 | private->io_region = kmem_cache_zalloc(vfio_ccw_io_region, |
|---|
| 128 | 174 | GFP_KERNEL | GFP_DMA); |
|---|
| 129 | | - if (!private->io_region) { |
|---|
| 130 | | - kfree(private); |
|---|
| 131 | | - return -ENOMEM; |
|---|
| 132 | | - } |
|---|
| 175 | + if (!private->io_region) |
|---|
| 176 | + goto out_free; |
|---|
| 177 | + |
|---|
| 178 | + private->cmd_region = kmem_cache_zalloc(vfio_ccw_cmd_region, |
|---|
| 179 | + GFP_KERNEL | GFP_DMA); |
|---|
| 180 | + if (!private->cmd_region) |
|---|
| 181 | + goto out_free; |
|---|
| 182 | + |
|---|
| 183 | + private->schib_region = kmem_cache_zalloc(vfio_ccw_schib_region, |
|---|
| 184 | + GFP_KERNEL | GFP_DMA); |
|---|
| 185 | + |
|---|
| 186 | + if (!private->schib_region) |
|---|
| 187 | + goto out_free; |
|---|
| 188 | + |
|---|
| 189 | + private->crw_region = kmem_cache_zalloc(vfio_ccw_crw_region, |
|---|
| 190 | + GFP_KERNEL | GFP_DMA); |
|---|
| 191 | + |
|---|
| 192 | + if (!private->crw_region) |
|---|
| 193 | + goto out_free; |
|---|
| 133 | 194 | |
|---|
| 134 | 195 | private->sch = sch; |
|---|
| 135 | 196 | dev_set_drvdata(&sch->dev, private); |
|---|
| 197 | + mutex_init(&private->io_mutex); |
|---|
| 136 | 198 | |
|---|
| 137 | 199 | spin_lock_irq(sch->lock); |
|---|
| 138 | 200 | private->state = VFIO_CCW_STATE_NOT_OPER; |
|---|
| .. | .. |
|---|
| 142 | 204 | if (ret) |
|---|
| 143 | 205 | goto out_free; |
|---|
| 144 | 206 | |
|---|
| 207 | + INIT_LIST_HEAD(&private->crw); |
|---|
| 208 | + INIT_WORK(&private->io_work, vfio_ccw_sch_io_todo); |
|---|
| 209 | + INIT_WORK(&private->crw_work, vfio_ccw_crw_todo); |
|---|
| 210 | + atomic_set(&private->avail, 1); |
|---|
| 211 | + private->state = VFIO_CCW_STATE_STANDBY; |
|---|
| 212 | + |
|---|
| 145 | 213 | ret = vfio_ccw_mdev_reg(sch); |
|---|
| 146 | 214 | if (ret) |
|---|
| 147 | 215 | goto out_disable; |
|---|
| 148 | 216 | |
|---|
| 149 | | - INIT_WORK(&private->io_work, vfio_ccw_sch_io_todo); |
|---|
| 150 | | - atomic_set(&private->avail, 1); |
|---|
| 151 | | - private->state = VFIO_CCW_STATE_STANDBY; |
|---|
| 217 | + if (dev_get_uevent_suppress(&sch->dev)) { |
|---|
| 218 | + dev_set_uevent_suppress(&sch->dev, 0); |
|---|
| 219 | + kobject_uevent(&sch->dev.kobj, KOBJ_ADD); |
|---|
| 220 | + } |
|---|
| 152 | 221 | |
|---|
| 222 | + VFIO_CCW_MSG_EVENT(4, "bound to subchannel %x.%x.%04x\n", |
|---|
| 223 | + sch->schid.cssid, sch->schid.ssid, |
|---|
| 224 | + sch->schid.sch_no); |
|---|
| 153 | 225 | return 0; |
|---|
| 154 | 226 | |
|---|
| 155 | 227 | out_disable: |
|---|
| 156 | 228 | cio_disable_subchannel(sch); |
|---|
| 157 | 229 | out_free: |
|---|
| 158 | 230 | dev_set_drvdata(&sch->dev, NULL); |
|---|
| 159 | | - kmem_cache_free(vfio_ccw_io_region, private->io_region); |
|---|
| 231 | + vfio_ccw_free_regions(private); |
|---|
| 232 | + kfree(private->cp.guest_cp); |
|---|
| 160 | 233 | kfree(private); |
|---|
| 161 | 234 | return ret; |
|---|
| 162 | 235 | } |
|---|
| .. | .. |
|---|
| 164 | 237 | static int vfio_ccw_sch_remove(struct subchannel *sch) |
|---|
| 165 | 238 | { |
|---|
| 166 | 239 | struct vfio_ccw_private *private = dev_get_drvdata(&sch->dev); |
|---|
| 240 | + struct vfio_ccw_crw *crw, *temp; |
|---|
| 167 | 241 | |
|---|
| 168 | 242 | vfio_ccw_sch_quiesce(sch); |
|---|
| 243 | + |
|---|
| 244 | + list_for_each_entry_safe(crw, temp, &private->crw, next) { |
|---|
| 245 | + list_del(&crw->next); |
|---|
| 246 | + kfree(crw); |
|---|
| 247 | + } |
|---|
| 169 | 248 | |
|---|
| 170 | 249 | vfio_ccw_mdev_unreg(sch); |
|---|
| 171 | 250 | |
|---|
| 172 | 251 | dev_set_drvdata(&sch->dev, NULL); |
|---|
| 173 | 252 | |
|---|
| 174 | | - kmem_cache_free(vfio_ccw_io_region, private->io_region); |
|---|
| 253 | + vfio_ccw_free_regions(private); |
|---|
| 254 | + kfree(private->cp.guest_cp); |
|---|
| 175 | 255 | kfree(private); |
|---|
| 176 | 256 | |
|---|
| 257 | + VFIO_CCW_MSG_EVENT(4, "unbound from subchannel %x.%x.%04x\n", |
|---|
| 258 | + sch->schid.cssid, sch->schid.ssid, |
|---|
| 259 | + sch->schid.sch_no); |
|---|
| 177 | 260 | return 0; |
|---|
| 178 | 261 | } |
|---|
| 179 | 262 | |
|---|
| .. | .. |
|---|
| 205 | 288 | if (work_pending(&sch->todo_work)) |
|---|
| 206 | 289 | goto out_unlock; |
|---|
| 207 | 290 | |
|---|
| 208 | | - if (cio_update_schib(sch)) { |
|---|
| 209 | | - vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_NOT_OPER); |
|---|
| 210 | | - rc = 0; |
|---|
| 211 | | - goto out_unlock; |
|---|
| 212 | | - } |
|---|
| 213 | | - |
|---|
| 214 | | - private = dev_get_drvdata(&sch->dev); |
|---|
| 215 | | - if (private->state == VFIO_CCW_STATE_NOT_OPER) { |
|---|
| 216 | | - private->state = private->mdev ? VFIO_CCW_STATE_IDLE : |
|---|
| 217 | | - VFIO_CCW_STATE_STANDBY; |
|---|
| 218 | | - } |
|---|
| 219 | 291 | rc = 0; |
|---|
| 292 | + |
|---|
| 293 | + if (cio_update_schib(sch)) |
|---|
| 294 | + vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_NOT_OPER); |
|---|
| 220 | 295 | |
|---|
| 221 | 296 | out_unlock: |
|---|
| 222 | 297 | spin_unlock_irqrestore(sch->lock, flags); |
|---|
| 223 | 298 | |
|---|
| 224 | 299 | return rc; |
|---|
| 300 | +} |
|---|
| 301 | + |
|---|
| 302 | +static void vfio_ccw_queue_crw(struct vfio_ccw_private *private, |
|---|
| 303 | + unsigned int rsc, |
|---|
| 304 | + unsigned int erc, |
|---|
| 305 | + unsigned int rsid) |
|---|
| 306 | +{ |
|---|
| 307 | + struct vfio_ccw_crw *crw; |
|---|
| 308 | + |
|---|
| 309 | + /* |
|---|
| 310 | + * If unable to allocate a CRW, just drop the event and |
|---|
| 311 | + * carry on. The guest will either see a later one or |
|---|
| 312 | + * learn when it issues its own store subchannel. |
|---|
| 313 | + */ |
|---|
| 314 | + crw = kzalloc(sizeof(*crw), GFP_ATOMIC); |
|---|
| 315 | + if (!crw) |
|---|
| 316 | + return; |
|---|
| 317 | + |
|---|
| 318 | + /* |
|---|
| 319 | + * Build the CRW based on the inputs given to us. |
|---|
| 320 | + */ |
|---|
| 321 | + crw->crw.rsc = rsc; |
|---|
| 322 | + crw->crw.erc = erc; |
|---|
| 323 | + crw->crw.rsid = rsid; |
|---|
| 324 | + |
|---|
| 325 | + list_add_tail(&crw->next, &private->crw); |
|---|
| 326 | + queue_work(vfio_ccw_work_q, &private->crw_work); |
|---|
| 327 | +} |
|---|
| 328 | + |
|---|
| 329 | +static int vfio_ccw_chp_event(struct subchannel *sch, |
|---|
| 330 | + struct chp_link *link, int event) |
|---|
| 331 | +{ |
|---|
| 332 | + struct vfio_ccw_private *private = dev_get_drvdata(&sch->dev); |
|---|
| 333 | + int mask = chp_ssd_get_mask(&sch->ssd_info, link); |
|---|
| 334 | + int retry = 255; |
|---|
| 335 | + |
|---|
| 336 | + if (!private || !mask) |
|---|
| 337 | + return 0; |
|---|
| 338 | + |
|---|
| 339 | + trace_vfio_ccw_chp_event(private->sch->schid, mask, event); |
|---|
| 340 | + VFIO_CCW_MSG_EVENT(2, "%pUl (%x.%x.%04x): mask=0x%x event=%d\n", |
|---|
| 341 | + mdev_uuid(private->mdev), sch->schid.cssid, |
|---|
| 342 | + sch->schid.ssid, sch->schid.sch_no, |
|---|
| 343 | + mask, event); |
|---|
| 344 | + |
|---|
| 345 | + if (cio_update_schib(sch)) |
|---|
| 346 | + return -ENODEV; |
|---|
| 347 | + |
|---|
| 348 | + switch (event) { |
|---|
| 349 | + case CHP_VARY_OFF: |
|---|
| 350 | + /* Path logically turned off */ |
|---|
| 351 | + sch->opm &= ~mask; |
|---|
| 352 | + sch->lpm &= ~mask; |
|---|
| 353 | + if (sch->schib.pmcw.lpum & mask) |
|---|
| 354 | + cio_cancel_halt_clear(sch, &retry); |
|---|
| 355 | + break; |
|---|
| 356 | + case CHP_OFFLINE: |
|---|
| 357 | + /* Path is gone */ |
|---|
| 358 | + if (sch->schib.pmcw.lpum & mask) |
|---|
| 359 | + cio_cancel_halt_clear(sch, &retry); |
|---|
| 360 | + vfio_ccw_queue_crw(private, CRW_RSC_CPATH, CRW_ERC_PERRN, |
|---|
| 361 | + link->chpid.id); |
|---|
| 362 | + break; |
|---|
| 363 | + case CHP_VARY_ON: |
|---|
| 364 | + /* Path logically turned on */ |
|---|
| 365 | + sch->opm |= mask; |
|---|
| 366 | + sch->lpm |= mask; |
|---|
| 367 | + break; |
|---|
| 368 | + case CHP_ONLINE: |
|---|
| 369 | + /* Path became available */ |
|---|
| 370 | + sch->lpm |= mask & sch->opm; |
|---|
| 371 | + vfio_ccw_queue_crw(private, CRW_RSC_CPATH, CRW_ERC_INIT, |
|---|
| 372 | + link->chpid.id); |
|---|
| 373 | + break; |
|---|
| 374 | + } |
|---|
| 375 | + |
|---|
| 376 | + return 0; |
|---|
| 225 | 377 | } |
|---|
| 226 | 378 | |
|---|
| 227 | 379 | static struct css_device_id vfio_ccw_sch_ids[] = { |
|---|
| .. | .. |
|---|
| 241 | 393 | .remove = vfio_ccw_sch_remove, |
|---|
| 242 | 394 | .shutdown = vfio_ccw_sch_shutdown, |
|---|
| 243 | 395 | .sch_event = vfio_ccw_sch_event, |
|---|
| 396 | + .chp_event = vfio_ccw_chp_event, |
|---|
| 244 | 397 | }; |
|---|
| 398 | + |
|---|
| 399 | +static int __init vfio_ccw_debug_init(void) |
|---|
| 400 | +{ |
|---|
| 401 | + vfio_ccw_debug_msg_id = debug_register("vfio_ccw_msg", 16, 1, |
|---|
| 402 | + 11 * sizeof(long)); |
|---|
| 403 | + if (!vfio_ccw_debug_msg_id) |
|---|
| 404 | + goto out_unregister; |
|---|
| 405 | + debug_register_view(vfio_ccw_debug_msg_id, &debug_sprintf_view); |
|---|
| 406 | + debug_set_level(vfio_ccw_debug_msg_id, 2); |
|---|
| 407 | + vfio_ccw_debug_trace_id = debug_register("vfio_ccw_trace", 16, 1, 16); |
|---|
| 408 | + if (!vfio_ccw_debug_trace_id) |
|---|
| 409 | + goto out_unregister; |
|---|
| 410 | + debug_register_view(vfio_ccw_debug_trace_id, &debug_hex_ascii_view); |
|---|
| 411 | + debug_set_level(vfio_ccw_debug_trace_id, 2); |
|---|
| 412 | + return 0; |
|---|
| 413 | + |
|---|
| 414 | +out_unregister: |
|---|
| 415 | + debug_unregister(vfio_ccw_debug_msg_id); |
|---|
| 416 | + debug_unregister(vfio_ccw_debug_trace_id); |
|---|
| 417 | + return -1; |
|---|
| 418 | +} |
|---|
| 419 | + |
|---|
| 420 | +static void vfio_ccw_debug_exit(void) |
|---|
| 421 | +{ |
|---|
| 422 | + debug_unregister(vfio_ccw_debug_msg_id); |
|---|
| 423 | + debug_unregister(vfio_ccw_debug_trace_id); |
|---|
| 424 | +} |
|---|
| 425 | + |
|---|
| 426 | +static void vfio_ccw_destroy_regions(void) |
|---|
| 427 | +{ |
|---|
| 428 | + kmem_cache_destroy(vfio_ccw_crw_region); |
|---|
| 429 | + kmem_cache_destroy(vfio_ccw_schib_region); |
|---|
| 430 | + kmem_cache_destroy(vfio_ccw_cmd_region); |
|---|
| 431 | + kmem_cache_destroy(vfio_ccw_io_region); |
|---|
| 432 | +} |
|---|
| 245 | 433 | |
|---|
| 246 | 434 | static int __init vfio_ccw_sch_init(void) |
|---|
| 247 | 435 | { |
|---|
| 248 | 436 | int ret; |
|---|
| 249 | 437 | |
|---|
| 438 | + ret = vfio_ccw_debug_init(); |
|---|
| 439 | + if (ret) |
|---|
| 440 | + return ret; |
|---|
| 441 | + |
|---|
| 250 | 442 | vfio_ccw_work_q = create_singlethread_workqueue("vfio-ccw"); |
|---|
| 251 | | - if (!vfio_ccw_work_q) |
|---|
| 252 | | - return -ENOMEM; |
|---|
| 443 | + if (!vfio_ccw_work_q) { |
|---|
| 444 | + ret = -ENOMEM; |
|---|
| 445 | + goto out_err; |
|---|
| 446 | + } |
|---|
| 253 | 447 | |
|---|
| 254 | 448 | vfio_ccw_io_region = kmem_cache_create_usercopy("vfio_ccw_io_region", |
|---|
| 255 | 449 | sizeof(struct ccw_io_region), 0, |
|---|
| 256 | 450 | SLAB_ACCOUNT, 0, |
|---|
| 257 | 451 | sizeof(struct ccw_io_region), NULL); |
|---|
| 258 | 452 | if (!vfio_ccw_io_region) { |
|---|
| 259 | | - destroy_workqueue(vfio_ccw_work_q); |
|---|
| 260 | | - return -ENOMEM; |
|---|
| 453 | + ret = -ENOMEM; |
|---|
| 454 | + goto out_err; |
|---|
| 455 | + } |
|---|
| 456 | + |
|---|
| 457 | + vfio_ccw_cmd_region = kmem_cache_create_usercopy("vfio_ccw_cmd_region", |
|---|
| 458 | + sizeof(struct ccw_cmd_region), 0, |
|---|
| 459 | + SLAB_ACCOUNT, 0, |
|---|
| 460 | + sizeof(struct ccw_cmd_region), NULL); |
|---|
| 461 | + if (!vfio_ccw_cmd_region) { |
|---|
| 462 | + ret = -ENOMEM; |
|---|
| 463 | + goto out_err; |
|---|
| 464 | + } |
|---|
| 465 | + |
|---|
| 466 | + vfio_ccw_schib_region = kmem_cache_create_usercopy("vfio_ccw_schib_region", |
|---|
| 467 | + sizeof(struct ccw_schib_region), 0, |
|---|
| 468 | + SLAB_ACCOUNT, 0, |
|---|
| 469 | + sizeof(struct ccw_schib_region), NULL); |
|---|
| 470 | + |
|---|
| 471 | + if (!vfio_ccw_schib_region) { |
|---|
| 472 | + ret = -ENOMEM; |
|---|
| 473 | + goto out_err; |
|---|
| 474 | + } |
|---|
| 475 | + |
|---|
| 476 | + vfio_ccw_crw_region = kmem_cache_create_usercopy("vfio_ccw_crw_region", |
|---|
| 477 | + sizeof(struct ccw_crw_region), 0, |
|---|
| 478 | + SLAB_ACCOUNT, 0, |
|---|
| 479 | + sizeof(struct ccw_crw_region), NULL); |
|---|
| 480 | + |
|---|
| 481 | + if (!vfio_ccw_crw_region) { |
|---|
| 482 | + ret = -ENOMEM; |
|---|
| 483 | + goto out_err; |
|---|
| 261 | 484 | } |
|---|
| 262 | 485 | |
|---|
| 263 | 486 | isc_register(VFIO_CCW_ISC); |
|---|
| 264 | 487 | ret = css_driver_register(&vfio_ccw_sch_driver); |
|---|
| 265 | 488 | if (ret) { |
|---|
| 266 | 489 | isc_unregister(VFIO_CCW_ISC); |
|---|
| 267 | | - kmem_cache_destroy(vfio_ccw_io_region); |
|---|
| 268 | | - destroy_workqueue(vfio_ccw_work_q); |
|---|
| 490 | + goto out_err; |
|---|
| 269 | 491 | } |
|---|
| 270 | 492 | |
|---|
| 493 | + return ret; |
|---|
| 494 | + |
|---|
| 495 | +out_err: |
|---|
| 496 | + vfio_ccw_destroy_regions(); |
|---|
| 497 | + destroy_workqueue(vfio_ccw_work_q); |
|---|
| 498 | + vfio_ccw_debug_exit(); |
|---|
| 271 | 499 | return ret; |
|---|
| 272 | 500 | } |
|---|
| 273 | 501 | |
|---|
| .. | .. |
|---|
| 275 | 503 | { |
|---|
| 276 | 504 | css_driver_unregister(&vfio_ccw_sch_driver); |
|---|
| 277 | 505 | isc_unregister(VFIO_CCW_ISC); |
|---|
| 278 | | - kmem_cache_destroy(vfio_ccw_io_region); |
|---|
| 506 | + vfio_ccw_destroy_regions(); |
|---|
| 279 | 507 | destroy_workqueue(vfio_ccw_work_q); |
|---|
| 508 | + vfio_ccw_debug_exit(); |
|---|
| 280 | 509 | } |
|---|
| 281 | 510 | module_init(vfio_ccw_sch_init); |
|---|
| 282 | 511 | module_exit(vfio_ccw_sch_exit); |
|---|