crypto: qat - force an edge when re-enabling all VF2PF interrupts
Subsystems (2)
PATCH 1/1 crypto: qat - force an edge when re-enabling all VF2PF interrupts
VF2PF interrupts are edge-triggered: a source only fires on a masked -> unmasked transition of VM2PF_MSK, not by being unmasked. adf_enable_all_vf2pf_interrupts() does a plain read-modify-write unmask, assuming VM2PF_MSK still holds the all-masked value left by adf_disable_all_vf2pf_interrupts().
That breaks across a device reset: adf_dev_autoreset() (and AER recovery) FLR the PF while VFs stay alive, so a VF can latch a source in VM2PF_SOU with no vectors set up to deliver it. The FLR then resets VM2PF_MSK to its power-on default of 0 (unmasked) without a software write, so the following RMW unmask writes 0 over an already-0
register: no edge occurs and the latched VF2PF message is never delivered.
Fix by having adf_enable_all_vf2pf_interrupts() mask all sources immediately before unmasking them, mirroring the idiom already used in adf_gen4_disable_pending_vf2pf_interrupts(), forcing the required edge regardless of the prior state of VM2PF_MSK.
--- drivers/crypto/intel/qat/qat_common/adf_isr.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/crypto/intel/qat/qat_common/adf_isr.c +14 -1
@@ -70,6 +70,7 @@ void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev, u32 vf_mask)void adf_enable_all_vf2pf_interrupts (struct adf_accel_dev *accel_dev,u32 num_vfs) {void __iomem *pmisc_addr =adf_get_pmisc_base (accel_dev); +struct adf_pfvf_ops *pfvf_ops =GET_PFVF_OPS (accel_dev);unsigned long flags;u32 vf_mask;
@@ -79,7 +80,19 @@ void adf_enable_all_vf2pf_interrupts(struct adf_accel_dev *accel_dev, u32 num_vfspin_lock_irqsave (&accel_dev->pf.vf2pf_ints_lock, flags);WRITE_ONCE (accel_dev->pf.vf2pf_disabled, false); -GET_PFVF_OPS (accel_dev)->enable_vf2pf_interrupts (pmisc_addr, vf_mask); +/* +* A VF2PF interrupt is only generated when a source transitions from +* masked to unmasked. A VF may write to its VF2PF CSR while the source +* is masked or while the MSI-X vectors are torn down, for example +* during a device reset, leaving the source latched with no interrupt +* pending. The FLR performed as part of a device reset returns the mask +* register to its default value, which leaves all the sources unmasked, +* so simply unmasking is not guaranteed to be a transition. Mask all the +* sources first, so that unmasking always generates an interrupt for +* the sources latched in the meantime. +*/ + pfvf_ops->disable_all_vf2pf_interrupts (pmisc_addr); + pfvf_ops->enable_vf2pf_interrupts (pmisc_addr, vf_mask);spin_unlock_irqrestore (&accel_dev->pf.vf2pf_ints_lock, flags); }
Signature · 1 line
2.40.1
Herbert Xu
maintainerQuoted 19 lines · George Abraham P
VF2PF interrupts are edge-triggered: a source only fires on a masked -> unmasked transition of
VM2PF_MSK, not by being unmasked.adf_enable_all_vf2pf_interrupts()does a plain read-modify-write unmask, assumingVM2PF_MSKstill holds the all-masked value left byadf_disable_all_vf2pf_interrupts().That breaks across a device reset:
adf_dev_autoreset()(and AER recovery) FLR the PF while VFs stay alive, so a VF can latch a source inVM2PF_SOUwith no vectors set up to deliver it. The FLR then resetsVM2PF_MSKto its power-on default of 0 (unmasked) without a software write, so the following RMW unmask writes 0 over an already-0
register: no edge occurs and the latched VF2PF message is never delivered.Fix by having
adf_enable_all_vf2pf_interrupts()mask all sources immediately before unmasking them, mirroring the idiom already used inadf_gen4_disable_pending_vf2pf_interrupts(), forcing the required edge regardless of the prior state ofVM2PF_MSK.
Quoted 6 lines
Fixes 575185000539 ("crypto: qat - keep VFs enabled during reset")Signed-off-by George Abraham P <[email protected]>Reviewed-by Giovanni Cabiddu <[email protected]>--- drivers/crypto/intel/qat/qat_common/adf_isr.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt