Skip to content

Commit 7829b37

Browse files
committed
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/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents aa77b11 + 0e1a4d4 commit 7829b37

File tree

5 files changed

+64
-13
lines changed

5 files changed

+64
-13
lines changed

drivers/crypto/caam/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ config CRYPTO_DEV_FSL_CAAM_AHASH_API_DESC
1010

1111
config CRYPTO_DEV_FSL_CAAM
1212
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
1414
select SOC_BUS
1515
select CRYPTO_DEV_FSL_CAAM_COMMON
1616
imply FSL_MC_BUS

drivers/crypto/caam/caamalg_qi2.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4990,11 +4990,23 @@ static int dpaa2_dpseci_congestion_setup(struct dpaa2_caam_priv *priv,
49904990
return err;
49914991
}
49924992

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+
49935004
static int __cold dpaa2_dpseci_setup(struct fsl_mc_device *ls_dev)
49945005
{
49955006
struct device *dev = &ls_dev->dev;
49965007
struct dpaa2_caam_priv *priv;
49975008
struct dpaa2_caam_priv_per_cpu *ppriv;
5009+
cpumask_t clean_mask;
49985010
int err, cpu;
49995011
u8 i;
50005012

@@ -5073,6 +5085,7 @@ static int __cold dpaa2_dpseci_setup(struct fsl_mc_device *ls_dev)
50735085
}
50745086
}
50755087

5088+
cpumask_clear(&clean_mask);
50765089
i = 0;
50775090
for_each_online_cpu(cpu) {
50785091
u8 j;
@@ -5096,15 +5109,23 @@ static int __cold dpaa2_dpseci_setup(struct fsl_mc_device *ls_dev)
50965109
priv->rx_queue_attr[j].fqid,
50975110
priv->tx_queue_attr[j].fqid);
50985111

5099-
ppriv->net_dev.dev = *dev;
5100-
INIT_LIST_HEAD(&ppriv->net_dev.napi_list);
5101-
netif_napi_add_tx_weight(&ppriv->net_dev, &ppriv->napi,
5112+
ppriv->net_dev = alloc_netdev_dummy(0);
5113+
if (!ppriv->net_dev) {
5114+
err = -ENOMEM;
5115+
goto err_alloc_netdev;
5116+
}
5117+
cpumask_set_cpu(cpu, &clean_mask);
5118+
ppriv->net_dev->dev = *dev;
5119+
5120+
netif_napi_add_tx_weight(ppriv->net_dev, &ppriv->napi,
51025121
dpaa2_dpseci_poll,
51035122
DPAA2_CAAM_NAPI_WEIGHT);
51045123
}
51055124

51065125
return 0;
51075126

5127+
err_alloc_netdev:
5128+
free_dpaa2_pcpu_netdev(priv, &clean_mask);
51085129
err_get_rx_queue:
51095130
dpaa2_dpseci_congestion_free(priv);
51105131
err_get_vers:
@@ -5153,6 +5174,7 @@ static int __cold dpaa2_dpseci_disable(struct dpaa2_caam_priv *priv)
51535174
ppriv = per_cpu_ptr(priv->ppriv, i);
51545175
napi_disable(&ppriv->napi);
51555176
netif_napi_del(&ppriv->napi);
5177+
free_netdev(ppriv->net_dev);
51565178
}
51575179

51585180
return 0;

drivers/crypto/caam/caamalg_qi2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct dpaa2_caam_priv {
8181
*/
8282
struct dpaa2_caam_priv_per_cpu {
8383
struct napi_struct napi;
84-
struct net_device net_dev;
84+
struct net_device *net_dev;
8585
int req_fqid;
8686
int rsp_fqid;
8787
int prio;

drivers/crypto/caam/ctrl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ static void build_deinstantiation_desc(u32 *desc, int handle)
8080
append_jump(desc, JUMP_CLASS_CLASS1 | JUMP_TYPE_HALT);
8181
}
8282

83+
#ifdef CONFIG_OF
8384
static const struct of_device_id imx8m_machine_match[] = {
8485
{ .compatible = "fsl,imx8mm", },
8586
{ .compatible = "fsl,imx8mn", },
@@ -88,6 +89,7 @@ static const struct of_device_id imx8m_machine_match[] = {
8889
{ .compatible = "fsl,imx8ulp", },
8990
{ }
9091
};
92+
#endif
9193

9294
/*
9395
* run_descriptor_deco0 - runs a descriptor on DECO0, under direct control of

drivers/crypto/caam/qi.c

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct caam_napi {
5757
*/
5858
struct caam_qi_pcpu_priv {
5959
struct caam_napi caam_napi;
60-
struct net_device net_dev;
60+
struct net_device *net_dev;
6161
struct qman_fq *rsp_fq;
6262
} ____cacheline_aligned;
6363

@@ -144,7 +144,7 @@ static void caam_fq_ern_cb(struct qman_portal *qm, struct qman_fq *fq,
144144
{
145145
const struct qm_fd *fd;
146146
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);
148148
struct caam_drv_private *priv = dev_get_drvdata(qidev);
149149

150150
fd = &msg->ern.fd;
@@ -530,6 +530,7 @@ static void caam_qi_shutdown(void *data)
530530

531531
if (kill_fq(qidev, per_cpu(pcpu_qipriv.rsp_fq, i)))
532532
dev_err(qidev, "Rsp FQ kill failed, cpu: %d\n", i);
533+
free_netdev(per_cpu(pcpu_qipriv.net_dev, i));
533534
}
534535

535536
qman_delete_cgr_safe(&priv->cgr);
@@ -573,7 +574,7 @@ static enum qman_cb_dqrr_result caam_rsp_fq_dqrr_cb(struct qman_portal *p,
573574
struct caam_napi *caam_napi = raw_cpu_ptr(&pcpu_qipriv.caam_napi);
574575
struct caam_drv_req *drv_req;
575576
const struct qm_fd *fd;
576-
struct device *qidev = &(raw_cpu_ptr(&pcpu_qipriv)->net_dev.dev);
577+
struct device *qidev = &(raw_cpu_ptr(&pcpu_qipriv)->net_dev->dev);
577578
struct caam_drv_private *priv = dev_get_drvdata(qidev);
578579
u32 status;
579580

@@ -718,12 +719,24 @@ static void free_rsp_fqs(void)
718719
kfree(per_cpu(pcpu_qipriv.rsp_fq, i));
719720
}
720721

722+
static void free_caam_qi_pcpu_netdev(const cpumask_t *cpus)
723+
{
724+
struct caam_qi_pcpu_priv *priv;
725+
int i;
726+
727+
for_each_cpu(i, cpus) {
728+
priv = per_cpu_ptr(&pcpu_qipriv, i);
729+
free_netdev(priv->net_dev);
730+
}
731+
}
732+
721733
int caam_qi_init(struct platform_device *caam_pdev)
722734
{
723735
int err, i;
724736
struct device *ctrldev = &caam_pdev->dev, *qidev;
725737
struct caam_drv_private *ctrlpriv;
726738
const cpumask_t *cpus = qman_affine_cpus();
739+
cpumask_t clean_mask;
727740

728741
ctrlpriv = dev_get_drvdata(ctrldev);
729742
qidev = ctrldev;
@@ -743,6 +756,8 @@ int caam_qi_init(struct platform_device *caam_pdev)
743756
return err;
744757
}
745758

759+
cpumask_clear(&clean_mask);
760+
746761
/*
747762
* Enable the NAPI contexts on each of the core which has an affine
748763
* portal.
@@ -751,10 +766,16 @@ int caam_qi_init(struct platform_device *caam_pdev)
751766
struct caam_qi_pcpu_priv *priv = per_cpu_ptr(&pcpu_qipriv, i);
752767
struct caam_napi *caam_napi = &priv->caam_napi;
753768
struct napi_struct *irqtask = &caam_napi->irqtask;
754-
struct net_device *net_dev = &priv->net_dev;
769+
struct net_device *net_dev;
755770

771+
net_dev = alloc_netdev_dummy(0);
772+
if (!net_dev) {
773+
err = -ENOMEM;
774+
goto fail;
775+
}
776+
cpumask_set_cpu(i, &clean_mask);
777+
priv->net_dev = net_dev;
756778
net_dev->dev = *qidev;
757-
INIT_LIST_HEAD(&net_dev->napi_list);
758779

759780
netif_napi_add_tx_weight(net_dev, irqtask, caam_qi_poll,
760781
CAAM_NAPI_WEIGHT);
@@ -766,16 +787,22 @@ int caam_qi_init(struct platform_device *caam_pdev)
766787
dma_get_cache_alignment(), 0, NULL);
767788
if (!qi_cache) {
768789
dev_err(qidev, "Can't allocate CAAM cache\n");
769-
free_rsp_fqs();
770-
return -ENOMEM;
790+
err = -ENOMEM;
791+
goto fail2;
771792
}
772793

773794
caam_debugfs_qi_init(ctrlpriv);
774795

775796
err = devm_add_action_or_reset(qidev, caam_qi_shutdown, ctrlpriv);
776797
if (err)
777-
return err;
798+
goto fail2;
778799

779800
dev_info(qidev, "Linux CAAM Queue I/F driver initialised\n");
780801
return 0;
802+
803+
fail2:
804+
free_rsp_fqs();
805+
fail:
806+
free_caam_qi_pcpu_netdev(&clean_mask);
807+
return err;
781808
}

0 commit comments

Comments
 (0)