Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'crypto-caam-unembed-net_dev'

Breno Leitao says:

====================
crypto: caam: Unembed net_dev

This will un-embed the net_device struct from inside other struct, so we
can add flexible array into net_device.

This also enable COMPILE test for FSL_CAAM, as any config option that
depends on ARCH_LAYERSCAPE.
====================

Link: https://patch.msgid.link/20240702185557.3699991-1-leitao@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+64 -13
+1 -1
drivers/crypto/caam/Kconfig
··· 10 10 11 11 config CRYPTO_DEV_FSL_CAAM 12 12 tristate "Freescale CAAM-Multicore platform driver backend" 13 - depends on FSL_SOC || ARCH_MXC || ARCH_LAYERSCAPE 13 + depends on FSL_SOC || ARCH_MXC || ARCH_LAYERSCAPE || COMPILE_TEST 14 14 select SOC_BUS 15 15 select CRYPTO_DEV_FSL_CAAM_COMMON 16 16 imply FSL_MC_BUS
+25 -3
drivers/crypto/caam/caamalg_qi2.c
··· 4990 4990 return err; 4991 4991 } 4992 4992 4993 + static void free_dpaa2_pcpu_netdev(struct dpaa2_caam_priv *priv, const cpumask_t *cpus) 4994 + { 4995 + struct dpaa2_caam_priv_per_cpu *ppriv; 4996 + int i; 4997 + 4998 + for_each_cpu(i, cpus) { 4999 + ppriv = per_cpu_ptr(priv->ppriv, i); 5000 + free_netdev(ppriv->net_dev); 5001 + } 5002 + } 5003 + 4993 5004 static int __cold dpaa2_dpseci_setup(struct fsl_mc_device *ls_dev) 4994 5005 { 4995 5006 struct device *dev = &ls_dev->dev; 4996 5007 struct dpaa2_caam_priv *priv; 4997 5008 struct dpaa2_caam_priv_per_cpu *ppriv; 5009 + cpumask_t clean_mask; 4998 5010 int err, cpu; 4999 5011 u8 i; 5000 5012 ··· 5085 5073 } 5086 5074 } 5087 5075 5076 + cpumask_clear(&clean_mask); 5088 5077 i = 0; 5089 5078 for_each_online_cpu(cpu) { 5090 5079 u8 j; ··· 5109 5096 priv->rx_queue_attr[j].fqid, 5110 5097 priv->tx_queue_attr[j].fqid); 5111 5098 5112 - ppriv->net_dev.dev = *dev; 5113 - INIT_LIST_HEAD(&ppriv->net_dev.napi_list); 5114 - netif_napi_add_tx_weight(&ppriv->net_dev, &ppriv->napi, 5099 + ppriv->net_dev = alloc_netdev_dummy(0); 5100 + if (!ppriv->net_dev) { 5101 + err = -ENOMEM; 5102 + goto err_alloc_netdev; 5103 + } 5104 + cpumask_set_cpu(cpu, &clean_mask); 5105 + ppriv->net_dev->dev = *dev; 5106 + 5107 + netif_napi_add_tx_weight(ppriv->net_dev, &ppriv->napi, 5115 5108 dpaa2_dpseci_poll, 5116 5109 DPAA2_CAAM_NAPI_WEIGHT); 5117 5110 } 5118 5111 5119 5112 return 0; 5120 5113 5114 + err_alloc_netdev: 5115 + free_dpaa2_pcpu_netdev(priv, &clean_mask); 5121 5116 err_get_rx_queue: 5122 5117 dpaa2_dpseci_congestion_free(priv); 5123 5118 err_get_vers: ··· 5174 5153 ppriv = per_cpu_ptr(priv->ppriv, i); 5175 5154 napi_disable(&ppriv->napi); 5176 5155 netif_napi_del(&ppriv->napi); 5156 + free_netdev(ppriv->net_dev); 5177 5157 } 5178 5158 5179 5159 return 0;
+1 -1
drivers/crypto/caam/caamalg_qi2.h
··· 81 81 */ 82 82 struct dpaa2_caam_priv_per_cpu { 83 83 struct napi_struct napi; 84 - struct net_device net_dev; 84 + struct net_device *net_dev; 85 85 int req_fqid; 86 86 int rsp_fqid; 87 87 int prio;
+2
drivers/crypto/caam/ctrl.c
··· 80 80 append_jump(desc, JUMP_CLASS_CLASS1 | JUMP_TYPE_HALT); 81 81 } 82 82 83 + #ifdef CONFIG_OF 83 84 static const struct of_device_id imx8m_machine_match[] = { 84 85 { .compatible = "fsl,imx8mm", }, 85 86 { .compatible = "fsl,imx8mn", }, ··· 89 88 { .compatible = "fsl,imx8ulp", }, 90 89 { } 91 90 }; 91 + #endif 92 92 93 93 /* 94 94 * run_descriptor_deco0 - runs a descriptor on DECO0, under direct control of
+35 -8
drivers/crypto/caam/qi.c
··· 57 57 */ 58 58 struct caam_qi_pcpu_priv { 59 59 struct caam_napi caam_napi; 60 - struct net_device net_dev; 60 + struct net_device *net_dev; 61 61 struct qman_fq *rsp_fq; 62 62 } ____cacheline_aligned; 63 63 ··· 144 144 { 145 145 const struct qm_fd *fd; 146 146 struct caam_drv_req *drv_req; 147 - struct device *qidev = &(raw_cpu_ptr(&pcpu_qipriv)->net_dev.dev); 147 + struct device *qidev = &(raw_cpu_ptr(&pcpu_qipriv)->net_dev->dev); 148 148 struct caam_drv_private *priv = dev_get_drvdata(qidev); 149 149 150 150 fd = &msg->ern.fd; ··· 530 530 531 531 if (kill_fq(qidev, per_cpu(pcpu_qipriv.rsp_fq, i))) 532 532 dev_err(qidev, "Rsp FQ kill failed, cpu: %d\n", i); 533 + free_netdev(per_cpu(pcpu_qipriv.net_dev, i)); 533 534 } 534 535 535 536 qman_delete_cgr_safe(&priv->cgr); ··· 574 573 struct caam_napi *caam_napi = raw_cpu_ptr(&pcpu_qipriv.caam_napi); 575 574 struct caam_drv_req *drv_req; 576 575 const struct qm_fd *fd; 577 - struct device *qidev = &(raw_cpu_ptr(&pcpu_qipriv)->net_dev.dev); 576 + struct device *qidev = &(raw_cpu_ptr(&pcpu_qipriv)->net_dev->dev); 578 577 struct caam_drv_private *priv = dev_get_drvdata(qidev); 579 578 u32 status; 580 579 ··· 719 718 kfree(per_cpu(pcpu_qipriv.rsp_fq, i)); 720 719 } 721 720 721 + static void free_caam_qi_pcpu_netdev(const cpumask_t *cpus) 722 + { 723 + struct caam_qi_pcpu_priv *priv; 724 + int i; 725 + 726 + for_each_cpu(i, cpus) { 727 + priv = per_cpu_ptr(&pcpu_qipriv, i); 728 + free_netdev(priv->net_dev); 729 + } 730 + } 731 + 722 732 int caam_qi_init(struct platform_device *caam_pdev) 723 733 { 724 734 int err, i; 725 735 struct device *ctrldev = &caam_pdev->dev, *qidev; 726 736 struct caam_drv_private *ctrlpriv; 727 737 const cpumask_t *cpus = qman_affine_cpus(); 738 + cpumask_t clean_mask; 728 739 729 740 ctrlpriv = dev_get_drvdata(ctrldev); 730 741 qidev = ctrldev; ··· 756 743 return err; 757 744 } 758 745 746 + cpumask_clear(&clean_mask); 747 + 759 748 /* 760 749 * Enable the NAPI contexts on each of the core which has an affine 761 750 * portal. ··· 766 751 struct caam_qi_pcpu_priv *priv = per_cpu_ptr(&pcpu_qipriv, i); 767 752 struct caam_napi *caam_napi = &priv->caam_napi; 768 753 struct napi_struct *irqtask = &caam_napi->irqtask; 769 - struct net_device *net_dev = &priv->net_dev; 754 + struct net_device *net_dev; 770 755 756 + net_dev = alloc_netdev_dummy(0); 757 + if (!net_dev) { 758 + err = -ENOMEM; 759 + goto fail; 760 + } 761 + cpumask_set_cpu(i, &clean_mask); 762 + priv->net_dev = net_dev; 771 763 net_dev->dev = *qidev; 772 - INIT_LIST_HEAD(&net_dev->napi_list); 773 764 774 765 netif_napi_add_tx_weight(net_dev, irqtask, caam_qi_poll, 775 766 CAAM_NAPI_WEIGHT); ··· 787 766 dma_get_cache_alignment(), 0, NULL); 788 767 if (!qi_cache) { 789 768 dev_err(qidev, "Can't allocate CAAM cache\n"); 790 - free_rsp_fqs(); 791 - return -ENOMEM; 769 + err = -ENOMEM; 770 + goto fail2; 792 771 } 793 772 794 773 caam_debugfs_qi_init(ctrlpriv); 795 774 796 775 err = devm_add_action_or_reset(qidev, caam_qi_shutdown, ctrlpriv); 797 776 if (err) 798 - return err; 777 + goto fail2; 799 778 800 779 dev_info(qidev, "Linux CAAM Queue I/F driver initialised\n"); 801 780 return 0; 781 + 782 + fail2: 783 + free_rsp_fqs(); 784 + fail: 785 + free_caam_qi_pcpu_netdev(&clean_mask); 786 + return err; 802 787 }