Skip to content

Commit 050bded

Browse files
Ahsan-Attagregkh
authored andcommitted
crypto: qat - centralize bus master enable
commit e5712ff upstream. QAT driver currently toggles PCI bus mastering in multiple places (probe paths, and reset callbacks). This makes BME state depend on call ordering and on what PCI command bits were captured in saved PCI config state. Make BME control explicit and deterministic: - remove pci_set_master() from device-specific probe paths - add adf_set_bme() and call it from adf_dev_init() so BME is enabled at one point before device bring-up - drop redundant pci_set_master() and pci_clear_master from adf_aer.c and rely on the unified init path for BME enablement This is in preparation for adding reset_prepare() and reset_done() hooks. In the PCI reset callback flow, the PCI core saves and restores device configuration state around reset_prepare() and reset_done(). This change is needed to ensure that we are able to properly shutdown or reinitialize the device post sysfs triggered resets. Cc: stable@vger.kernel.org Signed-off-by: Ahsan Atta <ahsan.atta@intel.com> Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com> Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5337b5c commit 050bded

12 files changed

Lines changed: 10 additions & 15 deletions

File tree

drivers/crypto/intel/qat/qat_420xx/adf_drv.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
146146
}
147147
}
148148

149-
pci_set_master(pdev);
150-
151149
if (pci_save_state(pdev)) {
152150
dev_err(&pdev->dev, "Failed to save pci state.\n");
153151
ret = -ENOMEM;

drivers/crypto/intel/qat/qat_4xxx/adf_drv.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
148148
}
149149
}
150150

151-
pci_set_master(pdev);
152-
153151
if (pci_save_state(pdev)) {
154152
dev_err(&pdev->dev, "Failed to save pci state.\n");
155153
ret = -ENOMEM;

drivers/crypto/intel/qat/qat_6xxx/adf_drv.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
162162
}
163163
}
164164

165-
pci_set_master(pdev);
166-
167165
/*
168166
* The PCI config space is saved at this point and will be restored
169167
* after a Function Level Reset (FLR) as the FLR does not completely

drivers/crypto/intel/qat/qat_c3xxx/adf_drv.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
167167
goto out_err_free_reg;
168168
}
169169
}
170-
pci_set_master(pdev);
171170

172171
if (pci_save_state(pdev)) {
173172
dev_err(&pdev->dev, "Failed to save pci state\n");

drivers/crypto/intel/qat/qat_c3xxxvf/adf_drv.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
163163
goto out_err_free_reg;
164164
}
165165
}
166-
pci_set_master(pdev);
167166
/* Completion for VF2PF request/response message exchange */
168167
init_completion(&accel_dev->vf.msg_received);
169168

drivers/crypto/intel/qat/qat_c62x/adf_drv.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
167167
goto out_err_free_reg;
168168
}
169169
}
170-
pci_set_master(pdev);
171170

172171
if (pci_save_state(pdev)) {
173172
dev_err(&pdev->dev, "Failed to save pci state\n");

drivers/crypto/intel/qat/qat_c62xvf/adf_drv.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
163163
goto out_err_free_reg;
164164
}
165165
}
166-
pci_set_master(pdev);
167166
/* Completion for VF2PF request/response message exchange */
168167
init_completion(&accel_dev->vf.msg_received);
169168

drivers/crypto/intel/qat/qat_common/adf_aer.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ static pci_ers_result_t adf_error_detected(struct pci_dev *pdev,
4141
adf_error_notifier(accel_dev);
4242
adf_pf2vf_notify_fatal_error(accel_dev);
4343
adf_dev_restarting_notify(accel_dev);
44-
pci_clear_master(pdev);
4544
adf_dev_down(accel_dev);
4645

4746
return PCI_ERS_RESULT_NEED_RESET;
@@ -106,6 +105,13 @@ void adf_dev_restore(struct adf_accel_dev *accel_dev)
106105
}
107106
}
108107

108+
void adf_set_bme(struct adf_accel_dev *accel_dev)
109+
{
110+
struct pci_dev *pdev = accel_to_pci_dev(accel_dev);
111+
112+
pci_set_master(pdev);
113+
}
114+
109115
static void adf_device_sriov_worker(struct work_struct *work)
110116
{
111117
struct adf_sriov_dev_data *sriov_data =
@@ -198,8 +204,6 @@ static pci_ers_result_t adf_slot_reset(struct pci_dev *pdev)
198204
return PCI_ERS_RESULT_DISCONNECT;
199205
}
200206

201-
if (!pdev->is_busmaster)
202-
pci_set_master(pdev);
203207
pci_restore_state(pdev);
204208
res = adf_dev_up(accel_dev, false);
205209
if (res && res != -EALREADY)

drivers/crypto/intel/qat/qat_common/adf_common_drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ extern const struct pci_error_handlers adf_err_handler;
8484
void adf_reset_sbr(struct adf_accel_dev *accel_dev);
8585
void adf_reset_flr(struct adf_accel_dev *accel_dev);
8686
void adf_dev_restore(struct adf_accel_dev *accel_dev);
87+
void adf_set_bme(struct adf_accel_dev *accel_dev);
8788
int adf_init_aer(void);
8889
void adf_exit_aer(void);
8990
int adf_init_arb(struct adf_accel_dev *accel_dev);

drivers/crypto/intel/qat/qat_common/adf_init.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ static int adf_dev_init(struct adf_accel_dev *accel_dev)
7373
return -EFAULT;
7474
}
7575

76+
adf_set_bme(accel_dev);
77+
7678
if (!test_bit(ADF_STATUS_CONFIGURED, &accel_dev->status) &&
7779
!accel_dev->is_vf) {
7880
dev_err(&GET_DEV(accel_dev), "Device not configured\n");

0 commit comments

Comments
 (0)