hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/drivers/soc/fsl/qbman/bman_ccsr.c
....@@ -97,17 +97,40 @@
9797 /* signal transactions for FBPRs with higher priority */
9898 #define FBPR_AR_RPRIO_HI BIT(30)
9999
100
-static void bm_set_memory(u64 ba, u32 size)
100
+/* Track if probe has occurred and if cleanup is required */
101
+static int __bman_probed;
102
+static int __bman_requires_cleanup;
103
+
104
+
105
+static int bm_set_memory(u64 ba, u32 size)
101106 {
107
+ u32 bar, bare;
102108 u32 exp = ilog2(size);
103109 /* choke if size isn't within range */
104110 DPAA_ASSERT(size >= 4096 && size <= 1024*1024*1024 &&
105111 is_power_of_2(size));
106112 /* choke if '[e]ba' has lower-alignment than 'size' */
107113 DPAA_ASSERT(!(ba & (size - 1)));
114
+
115
+ /* Check to see if BMan has already been initialized */
116
+ bar = bm_ccsr_in(REG_FBPR_BAR);
117
+ if (bar) {
118
+ /* Maker sure ba == what was programmed) */
119
+ bare = bm_ccsr_in(REG_FBPR_BARE);
120
+ if (bare != upper_32_bits(ba) || bar != lower_32_bits(ba)) {
121
+ pr_err("Attempted to reinitialize BMan with different BAR, got 0x%llx read BARE=0x%x BAR=0x%x\n",
122
+ ba, bare, bar);
123
+ return -ENOMEM;
124
+ }
125
+ pr_info("BMan BAR already configured\n");
126
+ __bman_requires_cleanup = 1;
127
+ return 1;
128
+ }
129
+
108130 bm_ccsr_out(REG_FBPR_BARE, upper_32_bits(ba));
109131 bm_ccsr_out(REG_FBPR_BAR, lower_32_bits(ba));
110132 bm_ccsr_out(REG_FBPR_AR, exp - 1);
133
+ return 0;
111134 }
112135
113136 /*
....@@ -120,7 +143,6 @@
120143 */
121144 static dma_addr_t fbpr_a;
122145 static size_t fbpr_sz;
123
-static int __bman_probed;
124146
125147 static int bman_fbpr(struct reserved_mem *rmem)
126148 {
....@@ -173,6 +195,16 @@
173195 }
174196 EXPORT_SYMBOL_GPL(bman_is_probed);
175197
198
+int bman_requires_cleanup(void)
199
+{
200
+ return __bman_requires_cleanup;
201
+}
202
+
203
+void bman_done_cleanup(void)
204
+{
205
+ __bman_requires_cleanup = 0;
206
+}
207
+
176208 static int fsl_bman_probe(struct platform_device *pdev)
177209 {
178210 int ret, err_irq;