crypto: qat - increase number of supported devices

The unsigned long type for init_status and start_status in
service_hndl are not long enough to represent more than 64
acceleration devices. Use an array instead.

Signed-off-by: Xin Zeng <xin.zeng@intel.com>
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Xin Zeng 2016-12-22 15:01:02 +00:00 committed by Herbert Xu
parent 21aad0b6ca
commit 1043c51468
3 changed files with 19 additions and 14 deletions

View File

@ -61,6 +61,7 @@
#define ADF_CFG_AFFINITY_WHATEVER 0xFF #define ADF_CFG_AFFINITY_WHATEVER 0xFF
#define MAX_DEVICE_NAME_SIZE 32 #define MAX_DEVICE_NAME_SIZE 32
#define ADF_MAX_DEVICES (32 * 32) #define ADF_MAX_DEVICES (32 * 32)
#define ADF_DEVS_ARRAY_SIZE BITS_TO_LONGS(ADF_MAX_DEVICES)
enum adf_cfg_val_type { enum adf_cfg_val_type {
ADF_DEC, ADF_DEC,

View File

@ -87,8 +87,8 @@ enum adf_event {
struct service_hndl { struct service_hndl {
int (*event_hld)(struct adf_accel_dev *accel_dev, int (*event_hld)(struct adf_accel_dev *accel_dev,
enum adf_event event); enum adf_event event);
unsigned long init_status; unsigned long init_status[ADF_DEVS_ARRAY_SIZE];
unsigned long start_status; unsigned long start_status[ADF_DEVS_ARRAY_SIZE];
char *name; char *name;
struct list_head list; struct list_head list;
}; };

View File

@ -64,8 +64,8 @@ static void adf_service_add(struct service_hndl *service)
int adf_service_register(struct service_hndl *service) int adf_service_register(struct service_hndl *service)
{ {
service->init_status = 0; memset(service->init_status, 0, sizeof(service->init_status));
service->start_status = 0; memset(service->start_status, 0, sizeof(service->start_status));
adf_service_add(service); adf_service_add(service);
return 0; return 0;
} }
@ -79,9 +79,13 @@ static void adf_service_remove(struct service_hndl *service)
int adf_service_unregister(struct service_hndl *service) int adf_service_unregister(struct service_hndl *service)
{ {
if (service->init_status || service->start_status) { int i;
pr_err("QAT: Could not remove active service\n");
return -EFAULT; for (i = 0; i < ARRAY_SIZE(service->init_status); i++) {
if (service->init_status[i] || service->start_status[i]) {
pr_err("QAT: Could not remove active service\n");
return -EFAULT;
}
} }
adf_service_remove(service); adf_service_remove(service);
return 0; return 0;
@ -163,7 +167,7 @@ int adf_dev_init(struct adf_accel_dev *accel_dev)
service->name); service->name);
return -EFAULT; return -EFAULT;
} }
set_bit(accel_dev->accel_id, &service->init_status); set_bit(accel_dev->accel_id, service->init_status);
} }
hw_data->enable_error_correction(accel_dev); hw_data->enable_error_correction(accel_dev);
@ -210,7 +214,7 @@ int adf_dev_start(struct adf_accel_dev *accel_dev)
service->name); service->name);
return -EFAULT; return -EFAULT;
} }
set_bit(accel_dev->accel_id, &service->start_status); set_bit(accel_dev->accel_id, service->start_status);
} }
clear_bit(ADF_STATUS_STARTING, &accel_dev->status); clear_bit(ADF_STATUS_STARTING, &accel_dev->status);
@ -259,14 +263,14 @@ void adf_dev_stop(struct adf_accel_dev *accel_dev)
list_for_each(list_itr, &service_table) { list_for_each(list_itr, &service_table) {
service = list_entry(list_itr, struct service_hndl, list); service = list_entry(list_itr, struct service_hndl, list);
if (!test_bit(accel_dev->accel_id, &service->start_status)) if (!test_bit(accel_dev->accel_id, service->start_status))
continue; continue;
ret = service->event_hld(accel_dev, ADF_EVENT_STOP); ret = service->event_hld(accel_dev, ADF_EVENT_STOP);
if (!ret) { if (!ret) {
clear_bit(accel_dev->accel_id, &service->start_status); clear_bit(accel_dev->accel_id, service->start_status);
} else if (ret == -EAGAIN) { } else if (ret == -EAGAIN) {
wait = true; wait = true;
clear_bit(accel_dev->accel_id, &service->start_status); clear_bit(accel_dev->accel_id, service->start_status);
} }
} }
@ -317,14 +321,14 @@ void adf_dev_shutdown(struct adf_accel_dev *accel_dev)
list_for_each(list_itr, &service_table) { list_for_each(list_itr, &service_table) {
service = list_entry(list_itr, struct service_hndl, list); service = list_entry(list_itr, struct service_hndl, list);
if (!test_bit(accel_dev->accel_id, &service->init_status)) if (!test_bit(accel_dev->accel_id, service->init_status))
continue; continue;
if (service->event_hld(accel_dev, ADF_EVENT_SHUTDOWN)) if (service->event_hld(accel_dev, ADF_EVENT_SHUTDOWN))
dev_err(&GET_DEV(accel_dev), dev_err(&GET_DEV(accel_dev),
"Failed to shutdown service %s\n", "Failed to shutdown service %s\n",
service->name); service->name);
else else
clear_bit(accel_dev->accel_id, &service->init_status); clear_bit(accel_dev->accel_id, service->init_status);
} }
hw_data->disable_iov(accel_dev); hw_data->disable_iov(accel_dev);