Skip to content

Commit 4e190a5

Browse files
aguerinIntelherbertx
authored andcommitted
crypto: qat - preserve ADF_GENERAL_SEC
The ADF_GENERAL_SEC configuration section contains values that must be preserved during state transitions (down -> up, up -> down). This patch modifies the logic in adf_dev_shutdown() to maintain all key values within this section, rather than selectively saving and restoring only the ADF_SERVICES_ENABLED attribute. To achieve this, a new function has been introduced that deletes all configuration sections except for the one specified by name. This function is invoked during adf_dev_down(), with ADF_GENERAL_SEC as the argument. Consequently, the adf_dev_shutdown_cache_cfg() function has been removed as it is now redundant. Additionally, this patch eliminates the cache_config parameter from the adf_dev_down() function since ADF_GENERAL_SEC should always be retained. This change does not cause any side effects because all entries in the key-value store are cleared when a module is unloaded. Signed-off-by: Adam Guerin <adam.guerin@intel.com> Co-developed-by: Michal Witwicki <michal.witwicki@intel.com> Signed-off-by: Michal Witwicki <michal.witwicki@intel.com> Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 47d9625 commit 4e190a5

File tree

17 files changed

+60
-61
lines changed

17 files changed

+60
-61
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
163163
return ret;
164164

165165
out_err_dev_stop:
166-
adf_dev_down(accel_dev, false);
166+
adf_dev_down(accel_dev);
167167
out_err:
168168
adf_cleanup_accel(accel_dev);
169169
return ret;
@@ -177,7 +177,7 @@ static void adf_remove(struct pci_dev *pdev)
177177
pr_err("QAT: Driver removal failed\n");
178178
return;
179179
}
180-
adf_dev_down(accel_dev, false);
180+
adf_dev_down(accel_dev);
181181
adf_cleanup_accel(accel_dev);
182182
}
183183

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
165165
return ret;
166166

167167
out_err_dev_stop:
168-
adf_dev_down(accel_dev, false);
168+
adf_dev_down(accel_dev);
169169
out_err:
170170
adf_cleanup_accel(accel_dev);
171171
return ret;
@@ -179,7 +179,7 @@ static void adf_remove(struct pci_dev *pdev)
179179
pr_err("QAT: Driver removal failed\n");
180180
return;
181181
}
182-
adf_dev_down(accel_dev, false);
182+
adf_dev_down(accel_dev);
183183
adf_cleanup_accel(accel_dev);
184184
}
185185

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
202202
return ret;
203203

204204
out_err_dev_stop:
205-
adf_dev_down(accel_dev, false);
205+
adf_dev_down(accel_dev);
206206
out_err_free_reg:
207207
pci_release_regions(accel_pci_dev->pci_dev);
208208
out_err_disable:
@@ -221,7 +221,7 @@ static void adf_remove(struct pci_dev *pdev)
221221
pr_err("QAT: Driver removal failed\n");
222222
return;
223223
}
224-
adf_dev_down(accel_dev, false);
224+
adf_dev_down(accel_dev);
225225
adf_cleanup_accel(accel_dev);
226226
adf_cleanup_pci_dev(accel_dev);
227227
kfree(accel_dev);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
176176
return ret;
177177

178178
out_err_dev_stop:
179-
adf_dev_down(accel_dev, false);
179+
adf_dev_down(accel_dev);
180180
out_err_free_reg:
181181
pci_release_regions(accel_pci_dev->pci_dev);
182182
out_err_disable:
@@ -196,7 +196,7 @@ static void adf_remove(struct pci_dev *pdev)
196196
return;
197197
}
198198
adf_flush_vf_wq(accel_dev);
199-
adf_dev_down(accel_dev, false);
199+
adf_dev_down(accel_dev);
200200
adf_cleanup_accel(accel_dev);
201201
adf_cleanup_pci_dev(accel_dev);
202202
kfree(accel_dev);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
202202
return ret;
203203

204204
out_err_dev_stop:
205-
adf_dev_down(accel_dev, false);
205+
adf_dev_down(accel_dev);
206206
out_err_free_reg:
207207
pci_release_regions(accel_pci_dev->pci_dev);
208208
out_err_disable:
@@ -221,7 +221,7 @@ static void adf_remove(struct pci_dev *pdev)
221221
pr_err("QAT: Driver removal failed\n");
222222
return;
223223
}
224-
adf_dev_down(accel_dev, false);
224+
adf_dev_down(accel_dev);
225225
adf_cleanup_accel(accel_dev);
226226
adf_cleanup_pci_dev(accel_dev);
227227
kfree(accel_dev);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
176176
return ret;
177177

178178
out_err_dev_stop:
179-
adf_dev_down(accel_dev, false);
179+
adf_dev_down(accel_dev);
180180
out_err_free_reg:
181181
pci_release_regions(accel_pci_dev->pci_dev);
182182
out_err_disable:
@@ -196,7 +196,7 @@ static void adf_remove(struct pci_dev *pdev)
196196
return;
197197
}
198198
adf_flush_vf_wq(accel_dev);
199-
adf_dev_down(accel_dev, false);
199+
adf_dev_down(accel_dev);
200200
adf_cleanup_accel(accel_dev);
201201
adf_cleanup_pci_dev(accel_dev);
202202
kfree(accel_dev);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static pci_ers_result_t adf_error_detected(struct pci_dev *pdev,
4444
adf_pf2vf_notify_restarting(accel_dev);
4545
adf_pf2vf_wait_for_restarting_complete(accel_dev);
4646
pci_clear_master(pdev);
47-
adf_dev_down(accel_dev, false);
47+
adf_dev_down(accel_dev);
4848

4949
return PCI_ERS_RESULT_NEED_RESET;
5050
}

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ void adf_cfg_dev_dbgfs_rm(struct adf_accel_dev *accel_dev)
100100
}
101101

102102
static void adf_cfg_section_del_all(struct list_head *head);
103+
static void adf_cfg_section_del_all_except(struct list_head *head,
104+
const char *section_name);
103105

104106
void adf_cfg_del_all(struct adf_accel_dev *accel_dev)
105107
{
@@ -111,6 +113,17 @@ void adf_cfg_del_all(struct adf_accel_dev *accel_dev)
111113
clear_bit(ADF_STATUS_CONFIGURED, &accel_dev->status);
112114
}
113115

116+
void adf_cfg_del_all_except(struct adf_accel_dev *accel_dev,
117+
const char *section_name)
118+
{
119+
struct adf_cfg_device_data *dev_cfg_data = accel_dev->cfg;
120+
121+
down_write(&dev_cfg_data->lock);
122+
adf_cfg_section_del_all_except(&dev_cfg_data->sec_list, section_name);
123+
up_write(&dev_cfg_data->lock);
124+
clear_bit(ADF_STATUS_CONFIGURED, &accel_dev->status);
125+
}
126+
114127
/**
115128
* adf_cfg_dev_remove() - Clears acceleration device configuration table.
116129
* @accel_dev: Pointer to acceleration device.
@@ -185,6 +198,22 @@ static void adf_cfg_section_del_all(struct list_head *head)
185198
}
186199
}
187200

201+
static void adf_cfg_section_del_all_except(struct list_head *head,
202+
const char *section_name)
203+
{
204+
struct list_head *list, *tmp;
205+
struct adf_cfg_section *ptr;
206+
207+
list_for_each_prev_safe(list, tmp, head) {
208+
ptr = list_entry(list, struct adf_cfg_section, list);
209+
if (!strcmp(ptr->name, section_name))
210+
continue;
211+
adf_cfg_keyval_del_all(&ptr->param_head);
212+
list_del(list);
213+
kfree(ptr);
214+
}
215+
}
216+
188217
static struct adf_cfg_key_val *adf_cfg_key_value_find(struct adf_cfg_section *s,
189218
const char *key)
190219
{

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ void adf_cfg_dev_dbgfs_add(struct adf_accel_dev *accel_dev);
3535
void adf_cfg_dev_dbgfs_rm(struct adf_accel_dev *accel_dev);
3636
int adf_cfg_section_add(struct adf_accel_dev *accel_dev, const char *name);
3737
void adf_cfg_del_all(struct adf_accel_dev *accel_dev);
38+
void adf_cfg_del_all_except(struct adf_accel_dev *accel_dev,
39+
const char *section_name);
3840
int adf_cfg_add_key_value_param(struct adf_accel_dev *accel_dev,
3941
const char *section_name,
4042
const char *key, const void *val,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ int adf_service_register(struct service_hndl *service);
5656
int adf_service_unregister(struct service_hndl *service);
5757

5858
int adf_dev_up(struct adf_accel_dev *accel_dev, bool init_config);
59-
int adf_dev_down(struct adf_accel_dev *accel_dev, bool cache_config);
59+
int adf_dev_down(struct adf_accel_dev *accel_dev);
6060
int adf_dev_restart(struct adf_accel_dev *accel_dev);
6161

6262
void adf_devmgr_update_class_index(struct adf_hw_device_data *hw_data);

0 commit comments

Comments
 (0)