diff options
| author | Marek Vasut <[email protected]> | 2023-08-14 01:50:00 +0200 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2023-08-22 15:17:53 -0400 |
| commit | 4f543e82b9831333bc0effe9540d8e6a9dde3cb5 (patch) | |
| tree | f228a79d79aa17bc67221bb341c3c92a869b8f98 /drivers/scsi | |
| parent | 75191f75bce45f3b9aff607c88f17778d3805c61 (diff) | |
scsi: Add buffer_aligned check pass-through
Some devices have limited DMA capabilities and require that the
buffers passed to them fit specific properties. Add new optional
callback which can be used at driver level to indicate whether a
buffer alignment is suitable for the device DMA or not. This is
a pass-through callback from block uclass to drivers.
Signed-off-by: Marek Vasut <[email protected]>
Diffstat (limited to 'drivers/scsi')
| -rw-r--r-- | drivers/scsi/scsi.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 6498f998ad6..7411660d465 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -274,6 +274,18 @@ static ulong scsi_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, __func__, start, smallblks, buf_addr); return blkcnt; } + +#if IS_ENABLED(CONFIG_BOUNCE_BUFFER) +static int scsi_buffer_aligned(struct udevice *dev, struct bounce_buffer *state) +{ + struct scsi_ops *ops = scsi_get_ops(dev->parent); + + if (ops->buffer_aligned) + return ops->buffer_aligned(dev->parent, state); + + return 1; +} +#endif /* CONFIG_BOUNCE_BUFFER */ #endif #if defined(CONFIG_PCI) && !defined(CONFIG_SCSI_AHCI_PLAT) && \ @@ -720,6 +732,9 @@ int scsi_scan(bool verbose) static const struct blk_ops scsi_blk_ops = { .read = scsi_read, .write = scsi_write, +#if IS_ENABLED(CONFIG_BOUNCE_BUFFER) + .buffer_aligned = scsi_buffer_aligned, +#endif /* CONFIG_BOUNCE_BUFFER */ }; U_BOOT_DRIVER(scsi_blk) = { |
