Lines Matching +full:fails +full:- +full:without +full:- +full:test +full:- +full:cd
1 // SPDX-License-Identifier: GPL-2.0-only
8 * Author: Joerg-Stephan Vogt <jsvogt@de.ibm.com>
26 #include <linux/dma-mapping.h>
37 MODULE_AUTHOR("Joerg-Stephan Vogt <jsvogt@de.ibm.com>");
59 /* Initial SR-IOV bring-up image */
108 * genwqe_devnode() - Set default access mode for genwqe devices.
110 * @mode: Carrier to pass-back given mode (permissions)
128 * genwqe_dev_alloc() - Create and prepare a new card descriptor
135 struct genwqe_dev *cd; in genwqe_dev_alloc() local
142 return ERR_PTR(-ENODEV); in genwqe_dev_alloc()
144 cd = kzalloc(sizeof(struct genwqe_dev), GFP_KERNEL); in genwqe_dev_alloc()
145 if (!cd) in genwqe_dev_alloc()
146 return ERR_PTR(-ENOMEM); in genwqe_dev_alloc()
148 cd->card_idx = i; in genwqe_dev_alloc()
149 cd->class_genwqe = &class_genwqe; in genwqe_dev_alloc()
150 cd->debugfs_genwqe = debugfs_genwqe; in genwqe_dev_alloc()
156 cd->use_platform_recovery = CONFIG_GENWQE_PLATFORM_ERROR_RECOVERY; in genwqe_dev_alloc()
158 init_waitqueue_head(&cd->queue_waitq); in genwqe_dev_alloc()
160 spin_lock_init(&cd->file_lock); in genwqe_dev_alloc()
161 INIT_LIST_HEAD(&cd->file_list); in genwqe_dev_alloc()
163 cd->card_state = GENWQE_CARD_UNUSED; in genwqe_dev_alloc()
164 spin_lock_init(&cd->print_lock); in genwqe_dev_alloc()
166 cd->ddcb_software_timeout = GENWQE_DDCB_SOFTWARE_TIMEOUT; in genwqe_dev_alloc()
167 cd->kill_timeout = GENWQE_KILL_TIMEOUT; in genwqe_dev_alloc()
170 cd->vf_jobtimeout_msec[j] = GENWQE_VF_JOBTIMEOUT_MSEC; in genwqe_dev_alloc()
172 genwqe_devices[i] = cd; in genwqe_dev_alloc()
173 return cd; in genwqe_dev_alloc()
176 static void genwqe_dev_free(struct genwqe_dev *cd) in genwqe_dev_free() argument
178 if (!cd) in genwqe_dev_free()
181 genwqe_devices[cd->card_idx] = NULL; in genwqe_dev_free()
182 kfree(cd); in genwqe_dev_free()
186 * genwqe_bus_reset() - Card recovery
187 * @cd: GenWQE device information
194 static int genwqe_bus_reset(struct genwqe_dev *cd) in genwqe_bus_reset() argument
197 struct pci_dev *pci_dev = cd->pci_dev; in genwqe_bus_reset()
200 if (cd->err_inject & GENWQE_INJECT_BUS_RESET_FAILURE) in genwqe_bus_reset()
201 return -EIO; in genwqe_bus_reset()
203 mmio = cd->mmio; in genwqe_bus_reset()
204 cd->mmio = NULL; in genwqe_bus_reset()
211 * Settings like enable bus-mastering, ... are backuped and in genwqe_bus_reset()
214 dev_dbg(&pci_dev->dev, "[%s] pci_reset function ...\n", __func__); in genwqe_bus_reset()
217 dev_err(&pci_dev->dev, in genwqe_bus_reset()
221 dev_dbg(&pci_dev->dev, "[%s] done with rc=%d\n", __func__, rc); in genwqe_bus_reset()
227 cd->err_inject &= ~(GENWQE_INJECT_HARDWARE_FAILURE | in genwqe_bus_reset()
233 dev_err(&pci_dev->dev, in genwqe_bus_reset()
235 return -EIO; in genwqe_bus_reset()
238 cd->mmio = pci_iomap(pci_dev, 0, 0); in genwqe_bus_reset()
239 if (cd->mmio == NULL) { in genwqe_bus_reset()
240 dev_err(&pci_dev->dev, in genwqe_bus_reset()
242 return -ENOMEM; in genwqe_bus_reset()
248 * Hardware circumvention section. Certain bitstreams in our test-lab
259 bool genwqe_need_err_masking(struct genwqe_dev *cd) in genwqe_need_err_masking() argument
261 return (cd->slu_unitcfg & 0xFFFF0ull) < 0x32170ull; in genwqe_need_err_masking()
264 static void genwqe_tweak_hardware(struct genwqe_dev *cd) in genwqe_tweak_hardware() argument
266 struct pci_dev *pci_dev = cd->pci_dev; in genwqe_tweak_hardware()
269 if (((cd->slu_unitcfg & 0xFFFF0ull) >= 0x32000ull) && in genwqe_tweak_hardware()
270 ((cd->slu_unitcfg & 0xFFFF0ull) <= 0x33250ull)) { in genwqe_tweak_hardware()
271 dev_warn(&pci_dev->dev, in genwqe_tweak_hardware()
273 cd->slu_unitcfg, cd->app_unitcfg); in genwqe_tweak_hardware()
275 __genwqe_writeq(cd, IO_APP_SEC_LEM_DEBUG_OVR, in genwqe_tweak_hardware()
278 __genwqe_writeq(cd, IO_APP_ERR_ACT_MASK, in genwqe_tweak_hardware()
284 * genwqe_recovery_on_fatal_gfir_required() - Version depended actions
285 * @cd: GenWQE device information
287 * Bitstreams older than 2013-02-17 have a bug where fatal GFIRs must
290 * test-lab.
292 int genwqe_recovery_on_fatal_gfir_required(struct genwqe_dev *cd) in genwqe_recovery_on_fatal_gfir_required() argument
294 return (cd->slu_unitcfg & 0xFFFF0ull) >= 0x32170ull; in genwqe_recovery_on_fatal_gfir_required()
297 int genwqe_flash_readback_fails(struct genwqe_dev *cd) in genwqe_flash_readback_fails() argument
299 return (cd->slu_unitcfg & 0xFFFF0ull) < 0x32170ull; in genwqe_flash_readback_fails()
303 * genwqe_T_psec() - Calculate PF/VF timeout register content
304 * @cd: GenWQE device information
314 static int genwqe_T_psec(struct genwqe_dev *cd) in genwqe_T_psec() argument
316 u16 speed; /* 1/f -> 250, 200, 166, 175 */ in genwqe_T_psec()
319 speed = (u16)((cd->slu_unitcfg >> 28) & 0x0full); in genwqe_T_psec()
321 return -1; /* illegal value */ in genwqe_T_psec()
327 * genwqe_setup_pf_jtimer() - Setup PF hardware timeouts for DDCB execution
328 * @cd: GenWQE device information
336 static bool genwqe_setup_pf_jtimer(struct genwqe_dev *cd) in genwqe_setup_pf_jtimer() argument
338 u32 T = genwqe_T_psec(cd); in genwqe_setup_pf_jtimer()
346 16000000000uL/(T * 15)) - 10; in genwqe_setup_pf_jtimer()
348 genwqe_write_vreg(cd, IO_SLC_VF_APPJOB_TIMEOUT, in genwqe_setup_pf_jtimer()
354 * genwqe_setup_vf_jtimer() - Setup VF hardware timeouts for DDCB execution
355 * @cd: GenWQE device information
357 static bool genwqe_setup_vf_jtimer(struct genwqe_dev *cd) in genwqe_setup_vf_jtimer() argument
359 struct pci_dev *pci_dev = cd->pci_dev; in genwqe_setup_vf_jtimer()
361 u32 T = genwqe_T_psec(cd); in genwqe_setup_vf_jtimer()
371 if (cd->vf_jobtimeout_msec[vf] == 0) in genwqe_setup_vf_jtimer()
374 x = ilog2(cd->vf_jobtimeout_msec[vf] * in genwqe_setup_vf_jtimer()
375 16000000000uL/(T * 15)) - 10; in genwqe_setup_vf_jtimer()
377 genwqe_write_vreg(cd, IO_SLC_VF_APPJOB_TIMEOUT, in genwqe_setup_vf_jtimer()
383 static int genwqe_ffdc_buffs_alloc(struct genwqe_dev *cd) in genwqe_ffdc_buffs_alloc() argument
390 e = genwqe_ffdc_buff_size(cd, 0); in genwqe_ffdc_buffs_alloc()
393 e = genwqe_ffdc_buff_size(cd, 1); in genwqe_ffdc_buffs_alloc()
396 e = genwqe_ffdc_buff_size(cd, 2); in genwqe_ffdc_buffs_alloc()
404 cd->ffdc[type].entries = e; in genwqe_ffdc_buffs_alloc()
405 cd->ffdc[type].regs = in genwqe_ffdc_buffs_alloc()
416 static void genwqe_ffdc_buffs_free(struct genwqe_dev *cd) in genwqe_ffdc_buffs_free() argument
421 kfree(cd->ffdc[type].regs); in genwqe_ffdc_buffs_free()
422 cd->ffdc[type].regs = NULL; in genwqe_ffdc_buffs_free()
426 static int genwqe_read_ids(struct genwqe_dev *cd) in genwqe_read_ids() argument
430 struct pci_dev *pci_dev = cd->pci_dev; in genwqe_read_ids()
432 cd->slu_unitcfg = __genwqe_readq(cd, IO_SLU_UNITCFG); in genwqe_read_ids()
433 if (cd->slu_unitcfg == IO_ILLEGAL_VALUE) { in genwqe_read_ids()
434 dev_err(&pci_dev->dev, in genwqe_read_ids()
435 "err: SLUID=%016llx\n", cd->slu_unitcfg); in genwqe_read_ids()
436 err = -EIO; in genwqe_read_ids()
440 slu_id = genwqe_get_slu_id(cd); in genwqe_read_ids()
442 dev_err(&pci_dev->dev, in genwqe_read_ids()
444 err = -ENOENT; in genwqe_read_ids()
448 cd->app_unitcfg = __genwqe_readq(cd, IO_APP_UNITCFG); in genwqe_read_ids()
449 if (cd->app_unitcfg == IO_ILLEGAL_VALUE) { in genwqe_read_ids()
450 dev_err(&pci_dev->dev, in genwqe_read_ids()
451 "err: APPID=%016llx\n", cd->app_unitcfg); in genwqe_read_ids()
452 err = -EIO; in genwqe_read_ids()
455 genwqe_read_app_id(cd, cd->app_name, sizeof(cd->app_name)); in genwqe_read_ids()
464 if (pci_dev->is_virtfn) in genwqe_read_ids()
465 cd->is_privileged = 0; in genwqe_read_ids()
467 cd->is_privileged = (__genwqe_readq(cd, IO_SLU_BITSTREAM) in genwqe_read_ids()
474 static int genwqe_start(struct genwqe_dev *cd) in genwqe_start() argument
477 struct pci_dev *pci_dev = cd->pci_dev; in genwqe_start()
479 err = genwqe_read_ids(cd); in genwqe_start()
483 if (genwqe_is_privileged(cd)) { in genwqe_start()
485 genwqe_ffdc_buffs_alloc(cd); in genwqe_start()
486 genwqe_stop_traps(cd); in genwqe_start()
489 genwqe_read_ffdc_regs(cd, cd->ffdc[GENWQE_DBG_REGS].regs, in genwqe_start()
490 cd->ffdc[GENWQE_DBG_REGS].entries, 0); in genwqe_start()
492 genwqe_ffdc_buff_read(cd, GENWQE_DBG_UNIT0, in genwqe_start()
493 cd->ffdc[GENWQE_DBG_UNIT0].regs, in genwqe_start()
494 cd->ffdc[GENWQE_DBG_UNIT0].entries); in genwqe_start()
496 genwqe_ffdc_buff_read(cd, GENWQE_DBG_UNIT1, in genwqe_start()
497 cd->ffdc[GENWQE_DBG_UNIT1].regs, in genwqe_start()
498 cd->ffdc[GENWQE_DBG_UNIT1].entries); in genwqe_start()
500 genwqe_ffdc_buff_read(cd, GENWQE_DBG_UNIT2, in genwqe_start()
501 cd->ffdc[GENWQE_DBG_UNIT2].regs, in genwqe_start()
502 cd->ffdc[GENWQE_DBG_UNIT2].entries); in genwqe_start()
504 genwqe_start_traps(cd); in genwqe_start()
506 if (cd->card_state == GENWQE_CARD_FATAL_ERROR) { in genwqe_start()
507 dev_warn(&pci_dev->dev, in genwqe_start()
514 cd->softreset = 0x7Cull; in genwqe_start()
515 __genwqe_writeq(cd, IO_SLC_CFGREG_SOFTRESET, in genwqe_start()
516 cd->softreset); in genwqe_start()
518 err = genwqe_bus_reset(cd); in genwqe_start()
520 dev_err(&pci_dev->dev, in genwqe_start()
527 * Re-read the IDs because in genwqe_start()
531 err = genwqe_read_ids(cd); in genwqe_start()
537 err = genwqe_setup_service_layer(cd); /* does a reset to the card */ in genwqe_start()
539 dev_err(&pci_dev->dev, in genwqe_start()
541 err = -ENODEV; in genwqe_start()
545 if (genwqe_is_privileged(cd)) { /* code is running _after_ reset */ in genwqe_start()
546 genwqe_tweak_hardware(cd); in genwqe_start()
548 genwqe_setup_pf_jtimer(cd); in genwqe_start()
549 genwqe_setup_vf_jtimer(cd); in genwqe_start()
552 err = genwqe_device_create(cd); in genwqe_start()
554 dev_err(&pci_dev->dev, in genwqe_start()
561 genwqe_release_service_layer(cd); in genwqe_start()
563 if (genwqe_is_privileged(cd)) in genwqe_start()
564 genwqe_ffdc_buffs_free(cd); in genwqe_start()
565 return -EIO; in genwqe_start()
569 * genwqe_stop() - Stop card operation
570 * @cd: GenWQE device information
575 * When genwqe_bus_reset() fails this function might called two times:
581 static int genwqe_stop(struct genwqe_dev *cd) in genwqe_stop() argument
583 genwqe_finish_queue(cd); /* no register access */ in genwqe_stop()
584 genwqe_device_remove(cd); /* device removed, procs killed */ in genwqe_stop()
585 genwqe_release_service_layer(cd); /* here genwqe_thread is stopped */ in genwqe_stop()
587 if (genwqe_is_privileged(cd)) { in genwqe_stop()
588 pci_disable_sriov(cd->pci_dev); /* access pci config space */ in genwqe_stop()
589 genwqe_ffdc_buffs_free(cd); in genwqe_stop()
596 * genwqe_recover_card() - Try to recover the card if it is possible
597 * @cd: GenWQE device information
601 * likely that genwqe_start fails in that situation. Proper error
607 static int genwqe_recover_card(struct genwqe_dev *cd, int fatal_err) in genwqe_recover_card() argument
610 struct pci_dev *pci_dev = cd->pci_dev; in genwqe_recover_card()
612 genwqe_stop(cd); in genwqe_recover_card()
619 cd->softreset = 0x70ull; in genwqe_recover_card()
620 __genwqe_writeq(cd, IO_SLC_CFGREG_SOFTRESET, cd->softreset); in genwqe_recover_card()
623 rc = genwqe_bus_reset(cd); in genwqe_recover_card()
625 dev_err(&pci_dev->dev, in genwqe_recover_card()
630 rc = genwqe_start(cd); in genwqe_recover_card()
632 dev_err(&pci_dev->dev, in genwqe_recover_card()
639 static int genwqe_health_check_cond(struct genwqe_dev *cd, u64 *gfir) in genwqe_health_check_cond() argument
641 *gfir = __genwqe_readq(cd, IO_SLC_CFGREG_GFIR); in genwqe_health_check_cond()
643 genwqe_recovery_on_fatal_gfir_required(cd); in genwqe_health_check_cond()
647 * genwqe_fir_checking() - Check the fault isolation registers of the card
648 * @cd: GenWQE device information
656 static u64 genwqe_fir_checking(struct genwqe_dev *cd) in genwqe_fir_checking() argument
661 struct pci_dev *pci_dev = cd->pci_dev; in genwqe_fir_checking()
666 dev_err(&pci_dev->dev, "* exit looping after %d times\n", in genwqe_fir_checking()
671 gfir = __genwqe_readq(cd, IO_SLC_CFGREG_GFIR); in genwqe_fir_checking()
673 dev_err(&pci_dev->dev, "* 0x%08x 0x%016llx\n", in genwqe_fir_checking()
681 * FIR set without a 2ndary FIR/FIR cannot be cleared in genwqe_fir_checking()
693 fir = __genwqe_readq(cd, fir_addr); in genwqe_fir_checking()
697 dev_err(&pci_dev->dev, "* 0x%08x 0x%016llx\n", fir_addr, fir); in genwqe_fir_checking()
703 fec = __genwqe_readq(cd, fec_addr); in genwqe_fir_checking()
705 dev_err(&pci_dev->dev, "* 0x%08x 0x%016llx\n", fec_addr, fec); in genwqe_fir_checking()
716 sfir = __genwqe_readq(cd, sfir_addr); in genwqe_fir_checking()
720 dev_err(&pci_dev->dev, in genwqe_fir_checking()
724 sfec = __genwqe_readq(cd, sfec_addr); in genwqe_fir_checking()
728 dev_err(&pci_dev->dev, in genwqe_fir_checking()
731 gfir = __genwqe_readq(cd, IO_SLC_CFGREG_GFIR); in genwqe_fir_checking()
747 __genwqe_writeq(cd, sfir_addr, sfir); in genwqe_fir_checking()
749 dev_dbg(&pci_dev->dev, in genwqe_fir_checking()
754 * note, these cannot be error-Firs in genwqe_fir_checking()
764 __genwqe_writeq(cd, fir_clr_addr, mask); in genwqe_fir_checking()
766 dev_dbg(&pci_dev->dev, in genwqe_fir_checking()
772 gfir = __genwqe_readq(cd, IO_SLC_CFGREG_GFIR); in genwqe_fir_checking()
781 dev_dbg(&pci_dev->dev, "ACK! Another FIR! Recursing %d!\n", in genwqe_fir_checking()
792 * genwqe_pci_fundamental_reset() - trigger a PCIe fundamental reset on the slot
824 static int genwqe_platform_recovery(struct genwqe_dev *cd) in genwqe_platform_recovery() argument
826 struct pci_dev *pci_dev = cd->pci_dev; in genwqe_platform_recovery()
829 dev_info(&pci_dev->dev, in genwqe_platform_recovery()
833 cd->err_inject &= ~(GENWQE_INJECT_HARDWARE_FAILURE | in genwqe_platform_recovery()
837 genwqe_stop(cd); in genwqe_platform_recovery()
842 rc = genwqe_start(cd); in genwqe_platform_recovery()
844 dev_info(&pci_dev->dev, in genwqe_platform_recovery()
847 dev_err(&pci_dev->dev, in genwqe_platform_recovery()
851 dev_err(&pci_dev->dev, in genwqe_platform_recovery()
859 * genwqe_reload_bistream() - reload card bitstream
860 * @cd: GenWQE device information
867 static int genwqe_reload_bistream(struct genwqe_dev *cd) in genwqe_reload_bistream() argument
869 struct pci_dev *pci_dev = cd->pci_dev; in genwqe_reload_bistream()
872 dev_info(&pci_dev->dev, in genwqe_reload_bistream()
876 genwqe_stop(cd); in genwqe_reload_bistream()
882 __genwqe_writeq(cd, IO_SLC_CFGREG_SOFTRESET, in genwqe_reload_bistream()
883 (cd->softreset & 0xcull) | 0x70ull); in genwqe_reload_bistream()
893 dev_err(&pci_dev->dev, in genwqe_reload_bistream()
898 rc = genwqe_start(cd); in genwqe_reload_bistream()
900 dev_err(&pci_dev->dev, in genwqe_reload_bistream()
905 dev_info(&pci_dev->dev, in genwqe_reload_bistream()
912 * genwqe_health_thread() - Health checking thread
918 * is when we read registers which contain -1 (IO_ILLEGAL_VALUE). In
924 * Condition for the health-thread to trigger:
934 struct genwqe_dev *cd = data; in genwqe_health_thread() local
935 struct pci_dev *pci_dev = cd->pci_dev; in genwqe_health_thread()
940 rc = wait_event_interruptible_timeout(cd->health_waitq, in genwqe_health_thread()
941 (genwqe_health_check_cond(cd, &gfir) || in genwqe_health_thread()
949 dev_err(&pci_dev->dev, in genwqe_health_thread()
954 slu_unitcfg = __genwqe_readq(cd, IO_SLU_UNITCFG); in genwqe_health_thread()
956 dev_err(&pci_dev->dev, in genwqe_health_thread()
962 app_unitcfg = __genwqe_readq(cd, IO_APP_UNITCFG); in genwqe_health_thread()
964 dev_err(&pci_dev->dev, in genwqe_health_thread()
970 gfir = __genwqe_readq(cd, IO_SLC_CFGREG_GFIR); in genwqe_health_thread()
972 dev_err(&pci_dev->dev, in genwqe_health_thread()
979 gfir_masked = genwqe_fir_checking(cd); in genwqe_health_thread()
987 if ((gfir_masked) && !cd->skip_recovery && in genwqe_health_thread()
988 genwqe_recovery_on_fatal_gfir_required(cd)) { in genwqe_health_thread()
990 cd->card_state = GENWQE_CARD_FATAL_ERROR; in genwqe_health_thread()
992 rc = genwqe_recover_card(cd, 0); in genwqe_health_thread()
999 if (cd->card_state == GENWQE_CARD_RELOAD_BITSTREAM) { in genwqe_health_thread()
1001 rc = genwqe_reload_bistream(cd); in genwqe_health_thread()
1006 cd->last_gfir = gfir; in genwqe_health_thread()
1013 if (cd->use_platform_recovery) { in genwqe_health_thread()
1016 * by the platform until we do a non-raw MMIO or config space in genwqe_health_thread()
1019 readq(cd->mmio + IO_SLC_CFGREG_GFIR); in genwqe_health_thread()
1023 return -EIO; in genwqe_health_thread()
1030 rc = genwqe_platform_recovery(cd); in genwqe_health_thread()
1035 dev_err(&pci_dev->dev, in genwqe_health_thread()
1039 cd->card_state = GENWQE_CARD_FATAL_ERROR; in genwqe_health_thread()
1040 genwqe_stop(cd); in genwqe_health_thread()
1046 return -EIO; in genwqe_health_thread()
1049 static int genwqe_health_check_start(struct genwqe_dev *cd) in genwqe_health_check_start() argument
1057 /* init_waitqueue_head(&cd->health_waitq); */ in genwqe_health_check_start()
1059 cd->health_thread = kthread_run(genwqe_health_thread, cd, in genwqe_health_check_start()
1061 cd->card_idx); in genwqe_health_check_start()
1062 if (IS_ERR(cd->health_thread)) { in genwqe_health_check_start()
1063 rc = PTR_ERR(cd->health_thread); in genwqe_health_check_start()
1064 cd->health_thread = NULL; in genwqe_health_check_start()
1070 static int genwqe_health_thread_running(struct genwqe_dev *cd) in genwqe_health_thread_running() argument
1072 return cd->health_thread != NULL; in genwqe_health_thread_running()
1075 static int genwqe_health_check_stop(struct genwqe_dev *cd) in genwqe_health_check_stop() argument
1077 if (!genwqe_health_thread_running(cd)) in genwqe_health_check_stop()
1078 return -EIO; in genwqe_health_check_stop()
1080 kthread_stop(cd->health_thread); in genwqe_health_check_stop()
1081 cd->health_thread = NULL; in genwqe_health_check_stop()
1086 * genwqe_pci_setup() - Allocate PCIe related resources for our card
1087 * @cd: GenWQE device information
1089 static int genwqe_pci_setup(struct genwqe_dev *cd) in genwqe_pci_setup() argument
1092 struct pci_dev *pci_dev = cd->pci_dev; in genwqe_pci_setup()
1096 dev_err(&pci_dev->dev, in genwqe_pci_setup()
1104 dev_err(&pci_dev->dev, in genwqe_pci_setup()
1106 err = -EIO; in genwqe_pci_setup()
1110 /* check for 64-bit DMA address supported (DAC) */ in genwqe_pci_setup()
1111 /* check for 32-bit DMA address supported (SAC) */ in genwqe_pci_setup()
1112 if (dma_set_mask_and_coherent(&pci_dev->dev, DMA_BIT_MASK(64)) && in genwqe_pci_setup()
1113 dma_set_mask_and_coherent(&pci_dev->dev, DMA_BIT_MASK(32))) { in genwqe_pci_setup()
1114 dev_err(&pci_dev->dev, in genwqe_pci_setup()
1116 err = -EIO; in genwqe_pci_setup()
1123 pci_dev->needs_freset = 1; in genwqe_pci_setup()
1125 /* request complete BAR-0 space (length = 0) */ in genwqe_pci_setup()
1126 cd->mmio_len = pci_resource_len(pci_dev, 0); in genwqe_pci_setup()
1127 cd->mmio = pci_iomap(pci_dev, 0, 0); in genwqe_pci_setup()
1128 if (cd->mmio == NULL) { in genwqe_pci_setup()
1129 dev_err(&pci_dev->dev, in genwqe_pci_setup()
1131 err = -ENOMEM; in genwqe_pci_setup()
1135 cd->num_vfs = pci_sriov_get_totalvfs(pci_dev); in genwqe_pci_setup()
1136 if (cd->num_vfs < 0) in genwqe_pci_setup()
1137 cd->num_vfs = 0; in genwqe_pci_setup()
1139 err = genwqe_read_ids(cd); in genwqe_pci_setup()
1146 pci_iounmap(pci_dev, cd->mmio); in genwqe_pci_setup()
1156 * genwqe_pci_remove() - Free PCIe related resources for our card
1157 * @cd: GenWQE device information
1159 static void genwqe_pci_remove(struct genwqe_dev *cd) in genwqe_pci_remove() argument
1161 struct pci_dev *pci_dev = cd->pci_dev; in genwqe_pci_remove()
1163 if (cd->mmio) in genwqe_pci_remove()
1164 pci_iounmap(pci_dev, cd->mmio); in genwqe_pci_remove()
1171 * genwqe_probe() - Device initialization
1183 struct genwqe_dev *cd; in genwqe_probe() local
1187 cd = genwqe_dev_alloc(); in genwqe_probe()
1188 if (IS_ERR(cd)) { in genwqe_probe()
1189 dev_err(&pci_dev->dev, "err: could not alloc mem (err=%d)!\n", in genwqe_probe()
1190 (int)PTR_ERR(cd)); in genwqe_probe()
1191 return PTR_ERR(cd); in genwqe_probe()
1194 dev_set_drvdata(&pci_dev->dev, cd); in genwqe_probe()
1195 cd->pci_dev = pci_dev; in genwqe_probe()
1197 err = genwqe_pci_setup(cd); in genwqe_probe()
1199 dev_err(&pci_dev->dev, in genwqe_probe()
1204 err = genwqe_start(cd); in genwqe_probe()
1206 dev_err(&pci_dev->dev, in genwqe_probe()
1211 if (genwqe_is_privileged(cd)) { in genwqe_probe()
1212 err = genwqe_health_check_start(cd); in genwqe_probe()
1214 dev_err(&pci_dev->dev, in genwqe_probe()
1223 genwqe_stop(cd); in genwqe_probe()
1225 genwqe_pci_remove(cd); in genwqe_probe()
1227 genwqe_dev_free(cd); in genwqe_probe()
1232 * genwqe_remove() - Called when device is removed (hot-plugable)
1239 struct genwqe_dev *cd = dev_get_drvdata(&pci_dev->dev); in genwqe_remove() local
1241 genwqe_health_check_stop(cd); in genwqe_remove()
1246 * and fails on genwqe_bus_reset(). in genwqe_remove()
1248 genwqe_stop(cd); in genwqe_remove()
1249 genwqe_pci_remove(cd); in genwqe_remove()
1250 genwqe_dev_free(cd); in genwqe_remove()
1254 * genwqe_err_error_detected() - Error detection callback
1264 struct genwqe_dev *cd; in genwqe_err_error_detected() local
1266 dev_err(&pci_dev->dev, "[%s] state=%d\n", __func__, state); in genwqe_err_error_detected()
1268 cd = dev_get_drvdata(&pci_dev->dev); in genwqe_err_error_detected()
1269 if (cd == NULL) in genwqe_err_error_detected()
1273 genwqe_health_check_stop(cd); in genwqe_err_error_detected()
1274 genwqe_stop(cd); in genwqe_err_error_detected()
1284 genwqe_pci_remove(cd); in genwqe_err_error_detected()
1292 struct genwqe_dev *cd = dev_get_drvdata(&pci_dev->dev); in genwqe_err_slot_reset() local
1294 rc = genwqe_pci_setup(cd); in genwqe_err_slot_reset()
1298 dev_err(&pci_dev->dev, in genwqe_err_slot_reset()
1312 struct genwqe_dev *cd = dev_get_drvdata(&pci_dev->dev); in genwqe_err_resume() local
1314 rc = genwqe_start(cd); in genwqe_err_resume()
1316 rc = genwqe_health_check_start(cd); in genwqe_err_resume()
1318 dev_err(&pci_dev->dev, in genwqe_err_resume()
1322 dev_err(&pci_dev->dev, in genwqe_err_resume()
1330 struct genwqe_dev *cd = dev_get_drvdata(&dev->dev); in genwqe_sriov_configure() local
1333 genwqe_setup_vf_jtimer(cd); in genwqe_sriov_configure()
1363 * genwqe_init_module() - Driver registration and initialization
1372 return -ENOMEM; in genwqe_init_module()
1392 * genwqe_exit_module() - Driver exit