crypto: octeontx - Remove custom swap function in favor of built-in sort swap
authorKuan-Wei Chiu <visitorckw@gmail.com>
Sun, 11 Aug 2024 06:28:16 +0000 (14:28 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 17 Aug 2024 05:55:50 +0000 (13:55 +0800)
The custom swap function used in octeontx driver do not perform any
special operations and can be replaced with the built-in swap function
of sort. This change not only reduces code size but also improves
efficiency, especially in scenarios where CONFIG_RETPOLINE is enabled,
as it makes indirect function calls more expensive.

By using the built-in swap, we avoid these costly indirect function
calls, leading to better performance.

Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/marvell/octeontx/otx_cptvf_algs.c

index 3c5d577..e53c79f 100644 (file)
@@ -1613,14 +1613,6 @@ static int compare_func(const void *lptr, const void *rptr)
        return 0;
 }
 
-static void swap_func(void *lptr, void *rptr, int size)
-{
-       struct cpt_device_desc *ldesc = (struct cpt_device_desc *) lptr;
-       struct cpt_device_desc *rdesc = (struct cpt_device_desc *) rptr;
-
-       swap(*ldesc, *rdesc);
-}
-
 int otx_cpt_crypto_init(struct pci_dev *pdev, struct module *mod,
                        enum otx_cptpf_type pf_type,
                        enum otx_cptvf_type engine_type,
@@ -1655,7 +1647,7 @@ int otx_cpt_crypto_init(struct pci_dev *pdev, struct module *mod,
                        is_crypto_registered = true;
                }
                sort(se_devices.desc, count, sizeof(struct cpt_device_desc),
-                    compare_func, swap_func);
+                    compare_func, NULL);
                break;
 
        case OTX_CPT_AE_TYPES:
@@ -1670,7 +1662,7 @@ int otx_cpt_crypto_init(struct pci_dev *pdev, struct module *mod,
                ae_devices.desc[count++].dev = pdev;
                atomic_inc(&ae_devices.count);
                sort(ae_devices.desc, count, sizeof(struct cpt_device_desc),
-                    compare_func, swap_func);
+                    compare_func, NULL);
                break;
 
        default: