Lines Matching +full:cache +full:- +full:op +full:- +full:block +full:- +full:size

1 // SPDX-License-Identifier: GPL-2.0-only
10 #include <linux/blk-mq.h>
55 u32 size; member
68 DIR_WRITE = 0, /* memory -> device */
69 DIR_READ = 1 /* device -> memory */
89 memcpy_from_bvec(dev->bounce_buf + offset, &bvec); in ps3disk_scatter_gather()
91 memcpy_to_bvec(&bvec, dev->bounce_buf + offset); in ps3disk_scatter_gather()
98 struct ps3disk_private *priv = ps3_system_bus_get_drvdata(&dev->sbd); in ps3disk_submit_request_sg()
100 const char *op = write ? "write" : "read"; in ps3disk_submit_request_sg() local
102 unsigned int region_id = dev->regions[dev->region_idx].id; in ps3disk_submit_request_sg()
111 dev_dbg(&dev->sbd.core, in ps3disk_submit_request_sg()
113 __func__, __LINE__, op, n, blk_rq_sectors(req)); in ps3disk_submit_request_sg()
116 start_sector = blk_rq_pos(req) * priv->blocking_factor; in ps3disk_submit_request_sg()
117 sectors = blk_rq_sectors(req) * priv->blocking_factor; in ps3disk_submit_request_sg()
118 dev_dbg(&dev->sbd.core, "%s:%u: %s %llu sectors starting at %llu\n", in ps3disk_submit_request_sg()
119 __func__, __LINE__, op, sectors, start_sector); in ps3disk_submit_request_sg()
124 res = lv1_storage_write(dev->sbd.dev_id, region_id, in ps3disk_submit_request_sg()
126 dev->bounce_lpar, &dev->tag); in ps3disk_submit_request_sg()
128 res = lv1_storage_read(dev->sbd.dev_id, region_id, in ps3disk_submit_request_sg()
130 dev->bounce_lpar, &dev->tag); in ps3disk_submit_request_sg()
133 dev_err(&dev->sbd.core, "%s:%u: %s failed %d\n", __func__, in ps3disk_submit_request_sg()
134 __LINE__, op, res); in ps3disk_submit_request_sg()
138 priv->req = req; in ps3disk_submit_request_sg()
145 struct ps3disk_private *priv = ps3_system_bus_get_drvdata(&dev->sbd); in ps3disk_submit_flush_request()
148 dev_dbg(&dev->sbd.core, "%s:%u: flush request\n", __func__, __LINE__); in ps3disk_submit_flush_request()
150 res = lv1_storage_send_device_command(dev->sbd.dev_id, in ps3disk_submit_flush_request()
152 0, &dev->tag); in ps3disk_submit_flush_request()
154 dev_err(&dev->sbd.core, "%s:%u: sync cache failed 0x%llx\n", in ps3disk_submit_flush_request()
159 priv->req = req; in ps3disk_submit_flush_request()
166 dev_dbg(&dev->sbd.core, "%s:%u\n", __func__, __LINE__); in ps3disk_do_request()
183 struct request_queue *q = hctx->queue; in ps3disk_queue_rq()
184 struct ps3_storage_device *dev = q->queuedata; in ps3disk_queue_rq()
185 struct ps3disk_private *priv = ps3_system_bus_get_drvdata(&dev->sbd); in ps3disk_queue_rq()
188 blk_mq_start_request(bd->rq); in ps3disk_queue_rq()
190 spin_lock_irq(&priv->lock); in ps3disk_queue_rq()
191 ret = ps3disk_do_request(dev, bd->rq); in ps3disk_queue_rq()
192 spin_unlock_irq(&priv->lock); in ps3disk_queue_rq()
205 const char *op; in ps3disk_interrupt() local
207 res = lv1_storage_get_async_status(dev->sbd.dev_id, &tag, &status); in ps3disk_interrupt()
209 if (tag != dev->tag) in ps3disk_interrupt()
210 dev_err(&dev->sbd.core, in ps3disk_interrupt()
212 __func__, __LINE__, tag, dev->tag); in ps3disk_interrupt()
215 dev_err(&dev->sbd.core, "%s:%u: res=%d status=0x%llx\n", in ps3disk_interrupt()
220 priv = ps3_system_bus_get_drvdata(&dev->sbd); in ps3disk_interrupt()
221 req = priv->req; in ps3disk_interrupt()
223 dev_dbg(&dev->sbd.core, in ps3disk_interrupt()
224 "%s:%u non-block layer request completed\n", __func__, in ps3disk_interrupt()
226 dev->lv1_status = status; in ps3disk_interrupt()
227 complete(&dev->done); in ps3disk_interrupt()
233 op = "flush"; in ps3disk_interrupt()
236 op = read ? "read" : "write"; in ps3disk_interrupt()
239 dev_dbg(&dev->sbd.core, "%s:%u: %s failed 0x%llx\n", __func__, in ps3disk_interrupt()
240 __LINE__, op, status); in ps3disk_interrupt()
243 dev_dbg(&dev->sbd.core, "%s:%u: %s completed\n", __func__, in ps3disk_interrupt()
244 __LINE__, op); in ps3disk_interrupt()
250 spin_lock(&priv->lock); in ps3disk_interrupt()
251 priv->req = NULL; in ps3disk_interrupt()
253 spin_unlock(&priv->lock); in ps3disk_interrupt()
255 blk_mq_run_hw_queues(priv->gendisk->queue, true); in ps3disk_interrupt()
263 dev_dbg(&dev->sbd.core, "%s:%u: sync cache\n", __func__, __LINE__); in ps3disk_sync_cache()
267 dev_err(&dev->sbd.core, "%s:%u: sync cache failed 0x%llx\n", in ps3disk_sync_cache()
269 return -EIO; in ps3disk_sync_cache()
275 /* ATA helpers copied from drivers/ata/libata-core.c */
317 len -= 2; in ata_id_string()
328 ata_id_string(id, s, ofs, len - 1); in ata_id_c_string()
330 p = s + strnlen(s, len - 1); in ata_id_c_string()
331 while (p > s && p[-1] == ' ') in ata_id_c_string()
332 p--; in ata_id_c_string()
338 struct ps3disk_private *priv = ps3_system_bus_get_drvdata(&dev->sbd); in ps3disk_identify()
340 u16 *id = dev->bounce_buf; in ps3disk_identify()
343 dev_dbg(&dev->sbd.core, "%s:%u: identify disk\n", __func__, __LINE__); in ps3disk_identify()
348 ata_cmnd.size = ata_cmnd.arglen = ATA_ID_WORDS * 2; in ps3disk_identify()
349 ata_cmnd.buffer = dev->bounce_lpar; in ps3disk_identify()
358 dev_err(&dev->sbd.core, "%s:%u: identify disk failed 0x%llx\n", in ps3disk_identify()
360 return -EIO; in ps3disk_identify()
366 priv->raw_capacity = ata_id_n_sectors(id); in ps3disk_identify()
367 ata_id_c_string(id, priv->model, ATA_ID_PROD, sizeof(priv->model)); in ps3disk_identify()
381 struct ps3_storage_device *dev = to_ps3_storage_device(&_dev->core); in ps3disk_probe()
386 .logical_block_size = dev->blk_size, in ps3disk_probe()
387 .max_hw_sectors = dev->bounce_size >> 9, in ps3disk_probe()
388 .max_segments = -1, in ps3disk_probe()
389 .max_segment_size = dev->bounce_size, in ps3disk_probe()
390 .dma_alignment = dev->blk_size - 1, in ps3disk_probe()
396 if (dev->blk_size < 512) { in ps3disk_probe()
397 dev_err(&dev->sbd.core, in ps3disk_probe()
398 "%s:%u: cannot handle block size %llu\n", __func__, in ps3disk_probe()
399 __LINE__, dev->blk_size); in ps3disk_probe()
400 return -EINVAL; in ps3disk_probe()
407 dev_err(&dev->sbd.core, "%s:%u: Too many disks\n", __func__, in ps3disk_probe()
410 return -ENOSPC; in ps3disk_probe()
417 error = -ENOMEM; in ps3disk_probe()
422 spin_lock_init(&priv->lock); in ps3disk_probe()
424 dev->bounce_size = BOUNCE_SIZE; in ps3disk_probe()
425 dev->bounce_buf = kmalloc(BOUNCE_SIZE, GFP_DMA); in ps3disk_probe()
426 if (!dev->bounce_buf) { in ps3disk_probe()
427 error = -ENOMEM; in ps3disk_probe()
437 error = blk_mq_alloc_sq_tag_set(&priv->tag_set, &ps3disk_mq_ops, 1, in ps3disk_probe()
442 gendisk = blk_mq_alloc_disk(&priv->tag_set, &lim, dev); in ps3disk_probe()
444 dev_err(&dev->sbd.core, "%s:%u: blk_mq_alloc_disk failed\n", in ps3disk_probe()
450 priv->gendisk = gendisk; in ps3disk_probe()
451 gendisk->major = ps3disk_major; in ps3disk_probe()
452 gendisk->first_minor = devidx * PS3DISK_MINORS; in ps3disk_probe()
453 gendisk->minors = PS3DISK_MINORS; in ps3disk_probe()
454 gendisk->fops = &ps3disk_fops; in ps3disk_probe()
455 gendisk->private_data = dev; in ps3disk_probe()
456 snprintf(gendisk->disk_name, sizeof(gendisk->disk_name), PS3DISK_NAME, in ps3disk_probe()
458 priv->blocking_factor = dev->blk_size >> 9; in ps3disk_probe()
460 dev->regions[dev->region_idx].size*priv->blocking_factor); in ps3disk_probe()
462 dev_info(&dev->sbd.core, in ps3disk_probe()
464 gendisk->disk_name, priv->model, priv->raw_capacity >> 11, in ps3disk_probe()
467 error = device_add_disk(&dev->sbd.core, gendisk, NULL); in ps3disk_probe()
475 blk_mq_free_tag_set(&priv->tag_set); in ps3disk_probe()
479 kfree(dev->bounce_buf); in ps3disk_probe()
492 struct ps3_storage_device *dev = to_ps3_storage_device(&_dev->core); in ps3disk_remove()
493 struct ps3disk_private *priv = ps3_system_bus_get_drvdata(&dev->sbd); in ps3disk_remove()
496 __clear_bit(MINOR(disk_devt(priv->gendisk)) / PS3DISK_MINORS, in ps3disk_remove()
499 del_gendisk(priv->gendisk); in ps3disk_remove()
500 put_disk(priv->gendisk); in ps3disk_remove()
501 blk_mq_free_tag_set(&priv->tag_set); in ps3disk_remove()
502 dev_notice(&dev->sbd.core, "Synchronizing disk cache\n"); in ps3disk_remove()
505 kfree(dev->bounce_buf); in ps3disk_remove()
525 return -ENODEV; in ps3disk_init()
535 pr_info("%s:%u: registered block device major %d\n", __func__, in ps3disk_init()