qdio_main.c (ad0bf4eb91c2f9b93479b679e5472094ddb76da8) | qdio_main.c (3db1db93e34325e14bb29f8f1d904020c409bea6) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Linux for s390 qdio support, buffer handling, qdio API and module support. 4 * 5 * Copyright IBM Corp. 2000, 2008 6 * Author(s): Utz Bacher <utz.bacher@de.ibm.com> 7 * Jan Glauber <jang@linux.vnet.ibm.com> 8 * 2.6 cio integration by Cornelia Huck <cornelia.huck@de.ibm.com> --- 1206 unchanged lines hidden (view full) --- 1215 1216 qdio_release_memory(irq_ptr); 1217 return 0; 1218} 1219EXPORT_SYMBOL_GPL(qdio_free); 1220 1221/** 1222 * qdio_allocate - allocate qdio queues and associated data | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Linux for s390 qdio support, buffer handling, qdio API and module support. 4 * 5 * Copyright IBM Corp. 2000, 2008 6 * Author(s): Utz Bacher <utz.bacher@de.ibm.com> 7 * Jan Glauber <jang@linux.vnet.ibm.com> 8 * 2.6 cio integration by Cornelia Huck <cornelia.huck@de.ibm.com> --- 1206 unchanged lines hidden (view full) --- 1215 1216 qdio_release_memory(irq_ptr); 1217 return 0; 1218} 1219EXPORT_SYMBOL_GPL(qdio_free); 1220 1221/** 1222 * qdio_allocate - allocate qdio queues and associated data |
1223 * @init_data: initialization data | 1223 * @cdev: associated ccw device 1224 * @no_input_qs: allocate this number of Input Queues 1225 * @no_output_qs: allocate this number of Output Queues |
1224 */ | 1226 */ |
1225int qdio_allocate(struct qdio_initialize *init_data) | 1227int qdio_allocate(struct ccw_device *cdev, unsigned int no_input_qs, 1228 unsigned int no_output_qs) |
1226{ | 1229{ |
1227 struct ccw_device *cdev = init_data->cdev; | |
1228 struct subchannel_id schid; 1229 struct qdio_irq *irq_ptr; 1230 1231 ccw_device_get_schid(cdev, &schid); 1232 DBF_EVENT("qallocate:%4x", schid.sch_no); 1233 | 1230 struct subchannel_id schid; 1231 struct qdio_irq *irq_ptr; 1232 1233 ccw_device_get_schid(cdev, &schid); 1234 DBF_EVENT("qallocate:%4x", schid.sch_no); 1235 |
1234 if ((init_data->no_input_qs && !init_data->input_handler) || 1235 (init_data->no_output_qs && !init_data->output_handler)) | 1236 if (no_input_qs > QDIO_MAX_QUEUES_PER_IRQ || 1237 no_output_qs > QDIO_MAX_QUEUES_PER_IRQ) |
1236 return -EINVAL; 1237 | 1238 return -EINVAL; 1239 |
1238 if ((init_data->no_input_qs > QDIO_MAX_QUEUES_PER_IRQ) || 1239 (init_data->no_output_qs > QDIO_MAX_QUEUES_PER_IRQ)) 1240 return -EINVAL; 1241 1242 if ((!init_data->input_sbal_addr_array) || 1243 (!init_data->output_sbal_addr_array)) 1244 return -EINVAL; 1245 | |
1246 /* irq_ptr must be in GFP_DMA since it contains ccw1.cda */ 1247 irq_ptr = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA); 1248 if (!irq_ptr) 1249 goto out_err; 1250 1251 irq_ptr->cdev = cdev; 1252 mutex_init(&irq_ptr->setup_mutex); | 1240 /* irq_ptr must be in GFP_DMA since it contains ccw1.cda */ 1241 irq_ptr = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA); 1242 if (!irq_ptr) 1243 goto out_err; 1244 1245 irq_ptr->cdev = cdev; 1246 mutex_init(&irq_ptr->setup_mutex); |
1253 if (qdio_allocate_dbf(init_data, irq_ptr)) | 1247 if (qdio_allocate_dbf(irq_ptr)) |
1254 goto out_rel; 1255 | 1248 goto out_rel; 1249 |
1250 DBF_DEV_EVENT(DBF_ERR, irq_ptr, "alloc niq:%1u noq:%1u", no_input_qs, 1251 no_output_qs); 1252 |
|
1256 /* 1257 * Allocate a page for the chsc calls in qdio_establish. 1258 * Must be pre-allocated since a zfcp recovery will call 1259 * qdio_establish. In case of low memory and swap on a zfcp disk 1260 * we may not be able to allocate memory otherwise. 1261 */ 1262 irq_ptr->chsc_page = get_zeroed_page(GFP_KERNEL); 1263 if (!irq_ptr->chsc_page) 1264 goto out_rel; 1265 1266 /* qdr is used in ccw1.cda which is u32 */ 1267 irq_ptr->qdr = (struct qdr *) get_zeroed_page(GFP_KERNEL | GFP_DMA); 1268 if (!irq_ptr->qdr) 1269 goto out_rel; 1270 | 1253 /* 1254 * Allocate a page for the chsc calls in qdio_establish. 1255 * Must be pre-allocated since a zfcp recovery will call 1256 * qdio_establish. In case of low memory and swap on a zfcp disk 1257 * we may not be able to allocate memory otherwise. 1258 */ 1259 irq_ptr->chsc_page = get_zeroed_page(GFP_KERNEL); 1260 if (!irq_ptr->chsc_page) 1261 goto out_rel; 1262 1263 /* qdr is used in ccw1.cda which is u32 */ 1264 irq_ptr->qdr = (struct qdr *) get_zeroed_page(GFP_KERNEL | GFP_DMA); 1265 if (!irq_ptr->qdr) 1266 goto out_rel; 1267 |
1271 if (qdio_allocate_qs(irq_ptr, init_data->no_input_qs, 1272 init_data->no_output_qs)) | 1268 if (qdio_allocate_qs(irq_ptr, no_input_qs, no_output_qs)) |
1273 goto out_rel; 1274 1275 INIT_LIST_HEAD(&irq_ptr->entry); 1276 cdev->private->qdio_data = irq_ptr; 1277 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_INACTIVE); 1278 return 0; 1279out_rel: 1280 qdio_release_memory(irq_ptr); --- 19 unchanged lines hidden (view full) --- 1300 continue; 1301 } 1302 } else 1303 qdio_disable_async_operation(&q->u.out); 1304 } 1305 DBF_EVENT("use_cq:%d", use_cq); 1306} 1307 | 1269 goto out_rel; 1270 1271 INIT_LIST_HEAD(&irq_ptr->entry); 1272 cdev->private->qdio_data = irq_ptr; 1273 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_INACTIVE); 1274 return 0; 1275out_rel: 1276 qdio_release_memory(irq_ptr); --- 19 unchanged lines hidden (view full) --- 1296 continue; 1297 } 1298 } else 1299 qdio_disable_async_operation(&q->u.out); 1300 } 1301 DBF_EVENT("use_cq:%d", use_cq); 1302} 1303 |
1304static void qdio_trace_init_data(struct qdio_irq *irq, 1305 struct qdio_initialize *data) 1306{ 1307 DBF_DEV_EVENT(DBF_ERR, irq, "qfmt:%1u", data->q_format); 1308 DBF_DEV_HEX(irq, data->adapter_name, 8, DBF_ERR); 1309 DBF_DEV_EVENT(DBF_ERR, irq, "qpff%4x", data->qib_param_field_format); 1310 DBF_DEV_HEX(irq, &data->qib_param_field, sizeof(void *), DBF_ERR); 1311 DBF_DEV_HEX(irq, &data->input_slib_elements, sizeof(void *), DBF_ERR); 1312 DBF_DEV_HEX(irq, &data->output_slib_elements, sizeof(void *), DBF_ERR); 1313 DBF_DEV_EVENT(DBF_ERR, irq, "niq:%1u noq:%1u", data->no_input_qs, 1314 data->no_output_qs); 1315 DBF_DEV_HEX(irq, &data->input_handler, sizeof(void *), DBF_ERR); 1316 DBF_DEV_HEX(irq, &data->output_handler, sizeof(void *), DBF_ERR); 1317 DBF_DEV_HEX(irq, &data->int_parm, sizeof(long), DBF_ERR); 1318 DBF_DEV_HEX(irq, &data->input_sbal_addr_array, sizeof(void *), DBF_ERR); 1319 DBF_DEV_HEX(irq, &data->output_sbal_addr_array, sizeof(void *), 1320 DBF_ERR); 1321} 1322 |
|
1308/** 1309 * qdio_establish - establish queues on a qdio subchannel 1310 * @init_data: initialization data 1311 */ 1312int qdio_establish(struct qdio_initialize *init_data) 1313{ 1314 struct ccw_device *cdev = init_data->cdev; 1315 struct qdio_irq *irq_ptr = cdev->private->qdio_data; 1316 struct subchannel_id schid; 1317 int rc; 1318 1319 ccw_device_get_schid(cdev, &schid); 1320 DBF_EVENT("qestablish:%4x", schid.sch_no); 1321 1322 if (!irq_ptr) 1323 return -ENODEV; 1324 | 1323/** 1324 * qdio_establish - establish queues on a qdio subchannel 1325 * @init_data: initialization data 1326 */ 1327int qdio_establish(struct qdio_initialize *init_data) 1328{ 1329 struct ccw_device *cdev = init_data->cdev; 1330 struct qdio_irq *irq_ptr = cdev->private->qdio_data; 1331 struct subchannel_id schid; 1332 int rc; 1333 1334 ccw_device_get_schid(cdev, &schid); 1335 DBF_EVENT("qestablish:%4x", schid.sch_no); 1336 1337 if (!irq_ptr) 1338 return -ENODEV; 1339 |
1340 if ((init_data->no_input_qs && !init_data->input_handler) || 1341 (init_data->no_output_qs && !init_data->output_handler)) 1342 return -EINVAL; 1343 1344 if (!init_data->input_sbal_addr_array || 1345 !init_data->output_sbal_addr_array) 1346 return -EINVAL; 1347 |
|
1325 mutex_lock(&irq_ptr->setup_mutex); | 1348 mutex_lock(&irq_ptr->setup_mutex); |
1349 qdio_trace_init_data(irq_ptr, init_data); |
|
1326 qdio_setup_irq(irq_ptr, init_data); 1327 1328 rc = qdio_establish_thinint(irq_ptr); 1329 if (rc) { 1330 mutex_unlock(&irq_ptr->setup_mutex); 1331 qdio_shutdown(cdev, QDIO_FLAG_CLEANUP_USING_CLEAR); 1332 return rc; 1333 } --- 541 unchanged lines hidden --- | 1350 qdio_setup_irq(irq_ptr, init_data); 1351 1352 rc = qdio_establish_thinint(irq_ptr); 1353 if (rc) { 1354 mutex_unlock(&irq_ptr->setup_mutex); 1355 qdio_shutdown(cdev, QDIO_FLAG_CLEANUP_USING_CLEAR); 1356 return rc; 1357 } --- 541 unchanged lines hidden --- |