forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/s390/char/sclp_sdias.c
....@@ -29,7 +29,7 @@
2929 .send_mask = EVTYP_SDIAS_MASK,
3030 };
3131
32
-static struct sdias_sccb sccb __attribute__((aligned(4096)));
32
+static struct sdias_sccb *sclp_sdias_sccb;
3333 static struct sdias_evbuf sdias_evbuf;
3434
3535 static DECLARE_COMPLETION(evbuf_accepted);
....@@ -58,6 +58,7 @@
5858
5959 static int sdias_sclp_send(struct sclp_req *req)
6060 {
61
+ struct sdias_sccb *sccb = sclp_sdias_sccb;
6162 int retries;
6263 int rc;
6364
....@@ -78,16 +79,16 @@
7879 continue;
7980 }
8081 /* if not accepted, retry */
81
- if (!(sccb.evbuf.hdr.flags & 0x80)) {
82
+ if (!(sccb->evbuf.hdr.flags & 0x80)) {
8283 TRACE("sclp request failed: flags=%x\n",
83
- sccb.evbuf.hdr.flags);
84
+ sccb->evbuf.hdr.flags);
8485 continue;
8586 }
8687 /*
8788 * for the sync interface the response is in the initial sccb
8889 */
8990 if (!sclp_sdias_register.receiver_fn) {
90
- memcpy(&sdias_evbuf, &sccb.evbuf, sizeof(sdias_evbuf));
91
+ memcpy(&sdias_evbuf, &sccb->evbuf, sizeof(sdias_evbuf));
9192 TRACE("sync request done\n");
9293 return 0;
9394 }
....@@ -104,23 +105,24 @@
104105 */
105106 int sclp_sdias_blk_count(void)
106107 {
108
+ struct sdias_sccb *sccb = sclp_sdias_sccb;
107109 struct sclp_req request;
108110 int rc;
109111
110112 mutex_lock(&sdias_mutex);
111113
112
- memset(&sccb, 0, sizeof(sccb));
114
+ memset(sccb, 0, sizeof(*sccb));
113115 memset(&request, 0, sizeof(request));
114116
115
- sccb.hdr.length = sizeof(sccb);
116
- sccb.evbuf.hdr.length = sizeof(struct sdias_evbuf);
117
- sccb.evbuf.hdr.type = EVTYP_SDIAS;
118
- sccb.evbuf.event_qual = SDIAS_EQ_SIZE;
119
- sccb.evbuf.data_id = SDIAS_DI_FCP_DUMP;
120
- sccb.evbuf.event_id = 4712;
121
- sccb.evbuf.dbs = 1;
117
+ sccb->hdr.length = sizeof(*sccb);
118
+ sccb->evbuf.hdr.length = sizeof(struct sdias_evbuf);
119
+ sccb->evbuf.hdr.type = EVTYP_SDIAS;
120
+ sccb->evbuf.event_qual = SDIAS_EQ_SIZE;
121
+ sccb->evbuf.data_id = SDIAS_DI_FCP_DUMP;
122
+ sccb->evbuf.event_id = 4712;
123
+ sccb->evbuf.dbs = 1;
122124
123
- request.sccb = &sccb;
125
+ request.sccb = sccb;
124126 request.command = SCLP_CMDW_WRITE_EVENT_DATA;
125127 request.status = SCLP_REQ_FILLED;
126128 request.callback = sdias_callback;
....@@ -130,8 +132,8 @@
130132 pr_err("sclp_send failed for get_nr_blocks\n");
131133 goto out;
132134 }
133
- if (sccb.hdr.response_code != 0x0020) {
134
- TRACE("send failed: %x\n", sccb.hdr.response_code);
135
+ if (sccb->hdr.response_code != 0x0020) {
136
+ TRACE("send failed: %x\n", sccb->hdr.response_code);
135137 rc = -EIO;
136138 goto out;
137139 }
....@@ -163,30 +165,31 @@
163165 */
164166 int sclp_sdias_copy(void *dest, int start_blk, int nr_blks)
165167 {
168
+ struct sdias_sccb *sccb = sclp_sdias_sccb;
166169 struct sclp_req request;
167170 int rc;
168171
169172 mutex_lock(&sdias_mutex);
170173
171
- memset(&sccb, 0, sizeof(sccb));
174
+ memset(sccb, 0, sizeof(*sccb));
172175 memset(&request, 0, sizeof(request));
173176
174
- sccb.hdr.length = sizeof(sccb);
175
- sccb.evbuf.hdr.length = sizeof(struct sdias_evbuf);
176
- sccb.evbuf.hdr.type = EVTYP_SDIAS;
177
- sccb.evbuf.hdr.flags = 0;
178
- sccb.evbuf.event_qual = SDIAS_EQ_STORE_DATA;
179
- sccb.evbuf.data_id = SDIAS_DI_FCP_DUMP;
180
- sccb.evbuf.event_id = 4712;
181
- sccb.evbuf.asa_size = SDIAS_ASA_SIZE_64;
182
- sccb.evbuf.event_status = 0;
183
- sccb.evbuf.blk_cnt = nr_blks;
184
- sccb.evbuf.asa = (unsigned long)dest;
185
- sccb.evbuf.fbn = start_blk;
186
- sccb.evbuf.lbn = 0;
187
- sccb.evbuf.dbs = 1;
177
+ sccb->hdr.length = sizeof(*sccb);
178
+ sccb->evbuf.hdr.length = sizeof(struct sdias_evbuf);
179
+ sccb->evbuf.hdr.type = EVTYP_SDIAS;
180
+ sccb->evbuf.hdr.flags = 0;
181
+ sccb->evbuf.event_qual = SDIAS_EQ_STORE_DATA;
182
+ sccb->evbuf.data_id = SDIAS_DI_FCP_DUMP;
183
+ sccb->evbuf.event_id = 4712;
184
+ sccb->evbuf.asa_size = SDIAS_ASA_SIZE_64;
185
+ sccb->evbuf.event_status = 0;
186
+ sccb->evbuf.blk_cnt = nr_blks;
187
+ sccb->evbuf.asa = (unsigned long)dest;
188
+ sccb->evbuf.fbn = start_blk;
189
+ sccb->evbuf.lbn = 0;
190
+ sccb->evbuf.dbs = 1;
188191
189
- request.sccb = &sccb;
192
+ request.sccb = sccb;
190193 request.command = SCLP_CMDW_WRITE_EVENT_DATA;
191194 request.status = SCLP_REQ_FILLED;
192195 request.callback = sdias_callback;
....@@ -196,8 +199,8 @@
196199 pr_err("sclp_send failed: %x\n", rc);
197200 goto out;
198201 }
199
- if (sccb.hdr.response_code != 0x0020) {
200
- TRACE("copy failed: %x\n", sccb.hdr.response_code);
202
+ if (sccb->hdr.response_code != 0x0020) {
203
+ TRACE("copy failed: %x\n", sccb->hdr.response_code);
201204 rc = -EIO;
202205 goto out;
203206 }
....@@ -211,7 +214,7 @@
211214 break;
212215 case SDIAS_EVSTATE_NO_DATA:
213216 TRACE("no data\n");
214
- /* fall through */
217
+ fallthrough;
215218 default:
216219 pr_err("Error from SCLP while copying hsa. Event status = %x\n",
217220 sdias_evbuf.event_status);
....@@ -254,8 +257,10 @@
254257
255258 int __init sclp_sdias_init(void)
256259 {
257
- if (ipl_info.type != IPL_TYPE_FCP_DUMP)
260
+ if (!is_ipl_type_dump())
258261 return 0;
262
+ sclp_sdias_sccb = (void *) __get_free_page(GFP_KERNEL | GFP_DMA);
263
+ BUG_ON(!sclp_sdias_sccb);
259264 sdias_dbf = debug_register("dump_sdias", 4, 1, 4 * sizeof(long));
260265 debug_register_view(sdias_dbf, &debug_sprintf_view);
261266 debug_set_level(sdias_dbf, 6);
....@@ -264,14 +269,9 @@
264269 if (sclp_sdias_init_async() == 0)
265270 goto out;
266271 TRACE("init failed\n");
272
+ free_page((unsigned long) sclp_sdias_sccb);
267273 return -ENODEV;
268274 out:
269275 TRACE("init done\n");
270276 return 0;
271
-}
272
-
273
-void __exit sclp_sdias_exit(void)
274
-{
275
- debug_unregister(sdias_dbf);
276
- sclp_unregister(&sclp_sdias_register);
277277 }