diff options
author | Vaibhav Jain <vaibhav@linux.vnet.ibm.com> | 2017-04-27 01:23:25 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2017-05-02 08:41:41 -0400 |
commit | ea9a26d117cf0637c71d3e0076f4a124bf5859df (patch) | |
tree | fbf66bb66073e35cac76916f9df693a127834632 /drivers/misc/cxl/pci.c | |
parent | 084a275e4c9477c432b05e872c3a297eab41638a (diff) |
cxl: Force context lock during EEH flow
During an eeh event when the cxl card is fenced and card sysfs attr
perst_reloads_same_image is set following warning message is seen in the
kernel logs:
Adapter context unlocked with 0 active contexts
------------[ cut here ]------------
WARNING: CPU: 12 PID: 627 at
../drivers/misc/cxl/main.c:325 cxl_adapter_context_unlock+0x60/0x80 [cxl]
Even though this warning is harmless, it clutters the kernel log
during an eeh event. This warning is triggered as the EEH callback
cxl_pci_error_detected doesn't obtain a context-lock before forcibly
detaching all active context and when context-lock is released during
call to cxl_configure_adapter from cxl_pci_slot_reset, a warning in
cxl_adapter_context_unlock is triggered.
To fix this warning, we acquire the adapter context-lock via
cxl_adapter_context_lock() in the eeh callback
cxl_pci_error_detected() once all the virtual AFU PHBs are notified
and their contexts detached. The context-lock is released in
cxl_pci_slot_reset() after the adapter is successfully reconfigured
and before the we call the slot_reset callback on slice attached
device-drivers.
Fixes: 70b565bbdb91 ("cxl: Prevent adapter reset if an active context exists")
Cc: stable@vger.kernel.org # v4.9+
Reported-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Vaibhav Jain <vaibhav@linux.vnet.ibm.com>
Acked-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Tested-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'drivers/misc/cxl/pci.c')
-rw-r--r-- | drivers/misc/cxl/pci.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c index fe01a0e00f37..556ef910a651 100644 --- a/drivers/misc/cxl/pci.c +++ b/drivers/misc/cxl/pci.c | |||
@@ -1716,8 +1716,6 @@ static int cxl_configure_adapter(struct cxl *adapter, struct pci_dev *dev) | |||
1716 | if ((rc = cxl_native_register_psl_err_irq(adapter))) | 1716 | if ((rc = cxl_native_register_psl_err_irq(adapter))) |
1717 | goto err; | 1717 | goto err; |
1718 | 1718 | ||
1719 | /* Release the context lock as adapter is configured */ | ||
1720 | cxl_adapter_context_unlock(adapter); | ||
1721 | return 0; | 1719 | return 0; |
1722 | 1720 | ||
1723 | err: | 1721 | err: |
@@ -1861,6 +1859,9 @@ static struct cxl *cxl_pci_init_adapter(struct pci_dev *dev) | |||
1861 | if ((rc = cxl_sysfs_adapter_add(adapter))) | 1859 | if ((rc = cxl_sysfs_adapter_add(adapter))) |
1862 | goto err_put1; | 1860 | goto err_put1; |
1863 | 1861 | ||
1862 | /* Release the context lock as adapter is configured */ | ||
1863 | cxl_adapter_context_unlock(adapter); | ||
1864 | |||
1864 | return adapter; | 1865 | return adapter; |
1865 | 1866 | ||
1866 | err_put1: | 1867 | err_put1: |
@@ -2171,6 +2172,13 @@ static pci_ers_result_t cxl_pci_error_detected(struct pci_dev *pdev, | |||
2171 | cxl_ops->afu_deactivate_mode(afu, afu->current_mode); | 2172 | cxl_ops->afu_deactivate_mode(afu, afu->current_mode); |
2172 | pci_deconfigure_afu(afu); | 2173 | pci_deconfigure_afu(afu); |
2173 | } | 2174 | } |
2175 | |||
2176 | /* should take the context lock here */ | ||
2177 | if (cxl_adapter_context_lock(adapter) != 0) | ||
2178 | dev_warn(&adapter->dev, | ||
2179 | "Couldn't take context lock with %d active-contexts\n", | ||
2180 | atomic_read(&adapter->contexts_num)); | ||
2181 | |||
2174 | cxl_deconfigure_adapter(adapter); | 2182 | cxl_deconfigure_adapter(adapter); |
2175 | 2183 | ||
2176 | return result; | 2184 | return result; |
@@ -2189,6 +2197,13 @@ static pci_ers_result_t cxl_pci_slot_reset(struct pci_dev *pdev) | |||
2189 | if (cxl_configure_adapter(adapter, pdev)) | 2197 | if (cxl_configure_adapter(adapter, pdev)) |
2190 | goto err; | 2198 | goto err; |
2191 | 2199 | ||
2200 | /* | ||
2201 | * Unlock context activation for the adapter. Ideally this should be | ||
2202 | * done in cxl_pci_resume but cxlflash module tries to activate the | ||
2203 | * master context as part of slot_reset callback. | ||
2204 | */ | ||
2205 | cxl_adapter_context_unlock(adapter); | ||
2206 | |||
2192 | for (i = 0; i < adapter->slices; i++) { | 2207 | for (i = 0; i < adapter->slices; i++) { |
2193 | afu = adapter->afu[i]; | 2208 | afu = adapter->afu[i]; |
2194 | 2209 | ||