@@ -57,7 +57,7 @@ struct caam_napi {
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,7 +144,7 @@ static void caam_fq_ern_cb(struct qman_portal *qm, struct qman_fq *fq,
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,6 +530,7 @@ static void caam_qi_shutdown(void *data)
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 );
@@ -573,7 +574,7 @@ static enum qman_cb_dqrr_result caam_rsp_fq_dqrr_cb(struct qman_portal *p,
573
574
struct caam_napi * caam_napi = raw_cpu_ptr (& pcpu_qipriv .caam_napi );
574
575
struct caam_drv_req * drv_req ;
575
576
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 );
577
578
struct caam_drv_private * priv = dev_get_drvdata (qidev );
578
579
u32 status ;
579
580
@@ -718,12 +719,24 @@ static void free_rsp_fqs(void)
718
719
kfree (per_cpu (pcpu_qipriv .rsp_fq , i ));
719
720
}
720
721
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
+
721
733
int caam_qi_init (struct platform_device * caam_pdev )
722
734
{
723
735
int err , i ;
724
736
struct device * ctrldev = & caam_pdev -> dev , * qidev ;
725
737
struct caam_drv_private * ctrlpriv ;
726
738
const cpumask_t * cpus = qman_affine_cpus ();
739
+ cpumask_t clean_mask ;
727
740
728
741
ctrlpriv = dev_get_drvdata (ctrldev );
729
742
qidev = ctrldev ;
@@ -743,6 +756,8 @@ int caam_qi_init(struct platform_device *caam_pdev)
743
756
return err ;
744
757
}
745
758
759
+ cpumask_clear (& clean_mask );
760
+
746
761
/*
747
762
* Enable the NAPI contexts on each of the core which has an affine
748
763
* portal.
@@ -751,10 +766,16 @@ int caam_qi_init(struct platform_device *caam_pdev)
751
766
struct caam_qi_pcpu_priv * priv = per_cpu_ptr (& pcpu_qipriv , i );
752
767
struct caam_napi * caam_napi = & priv -> caam_napi ;
753
768
struct napi_struct * irqtask = & caam_napi -> irqtask ;
754
- struct net_device * net_dev = & priv -> net_dev ;
769
+ struct net_device * net_dev ;
755
770
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 ;
756
778
net_dev -> dev = * qidev ;
757
- INIT_LIST_HEAD (& net_dev -> napi_list );
758
779
759
780
netif_napi_add_tx_weight (net_dev , irqtask , caam_qi_poll ,
760
781
CAAM_NAPI_WEIGHT );
@@ -766,16 +787,22 @@ int caam_qi_init(struct platform_device *caam_pdev)
766
787
dma_get_cache_alignment (), 0 , NULL );
767
788
if (!qi_cache ) {
768
789
dev_err (qidev , "Can't allocate CAAM cache\n" );
769
- free_rsp_fqs () ;
770
- return - ENOMEM ;
790
+ err = - ENOMEM ;
791
+ goto fail2 ;
771
792
}
772
793
773
794
caam_debugfs_qi_init (ctrlpriv );
774
795
775
796
err = devm_add_action_or_reset (qidev , caam_qi_shutdown , ctrlpriv );
776
797
if (err )
777
- return err ;
798
+ goto fail2 ;
778
799
779
800
dev_info (qidev , "Linux CAAM Queue I/F driver initialised\n" );
780
801
return 0 ;
802
+
803
+ fail2 :
804
+ free_rsp_fqs ();
805
+ fail :
806
+ free_caam_qi_pcpu_netdev (& clean_mask );
807
+ return err ;
781
808
}
0 commit comments