Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: qat - fix state restore for banks with exceptions

Change the logic in the restore function to properly handle bank
exceptions.

The check for exceptions in the saved state should be performed before
conducting any other ringstat register checks.
If a bank was saved with an exception, the ringstat will have the
appropriate rp_halt/rp_exception bits set, causing the driver to exit
the restore process with an error. Instead, the restore routine should
first check the ringexpstat register, and if any exception was raised,
it should stop further checks and return without any error. In other
words, if a ring pair is in an exception state at the source, it should
be restored the same way at the destination but without raising an error.

Even though this approach might lead to losing the exception state
during migration, the driver will log the exception from the saved state
during the restore process.

Signed-off-by: Svyatoslav Pankratov <svyatoslav.pankratov@intel.com>
Fixes: bbfdde7d195f ("crypto: qat - add bank save and restore flows")
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Svyatoslav Pankratov and committed by
Herbert Xu
254923ca 53669ff5

+22 -7
+22 -7
drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.c
··· 581 581 ops->write_csr_int_srcsel_w_val(base, bank, state->iaintflagsrcsel0); 582 582 ops->write_csr_exp_int_en(base, bank, state->ringexpintenable); 583 583 ops->write_csr_int_col_ctl(base, bank, state->iaintcolctl); 584 + 585 + /* 586 + * Verify whether any exceptions were raised during the bank save process. 587 + * If exceptions occurred, the status and exception registers cannot 588 + * be directly restored. Consequently, further restoration is not 589 + * feasible, and the current state of the ring should be maintained. 590 + */ 591 + val = state->ringexpstat; 592 + if (val) { 593 + pr_info("QAT: Bank %u state not fully restored due to exception in saved state (%#x)\n", 594 + bank, val); 595 + return 0; 596 + } 597 + 598 + /* Ensure that the restoration process completed without exceptions */ 599 + tmp_val = ops->read_csr_exp_stat(base, bank); 600 + if (tmp_val) { 601 + pr_err("QAT: Bank %u restored with exception: %#x\n", 602 + bank, tmp_val); 603 + return -EFAULT; 604 + } 605 + 584 606 ops->write_csr_ring_srv_arb_en(base, bank, state->ringsrvarben); 585 607 586 608 /* Check that all ring statuses match the saved state. */ ··· 635 613 base, bank); 636 614 if (ret) 637 615 return ret; 638 - 639 - tmp_val = ops->read_csr_exp_stat(base, bank); 640 - val = state->ringexpstat; 641 - if (tmp_val && !val) { 642 - pr_err("QAT: Bank was restored with exception: 0x%x\n", val); 643 - return -EINVAL; 644 - } 645 616 646 617 return 0; 647 618 }