drivers/scsi/a3000.c
Source file repositories/reference/linux-study-clean/drivers/scsi/a3000.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/a3000.c- Extension
.c- Size
- 8438 bytes
- Lines
- 316
- Domain
- Driver Families
- Bucket
- drivers/scsi
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/mm.hlinux/ioport.hlinux/init.hlinux/slab.hlinux/spinlock.hlinux/interrupt.hlinux/platform_device.hlinux/dma-mapping.hlinux/module.hasm/page.hasm/amigaints.hasm/amigahw.hscsi/scsi.hscsi/scsi_cmnd.hscsi/scsi_device.hscsi/scsi_eh.hscsi/scsi_tcq.hwd33c93.ha3000.h
Detected Declarations
struct a3000_hostdatafunction a3000_intrfunction dma_setupfunction dma_stopfunction amiga_a3000_scsi_probefunction amiga_a3000_scsi_remove
Annotated Snippet
struct a3000_hostdata {
struct WD33C93_hostdata wh;
struct a3000_scsiregs *regs;
struct device *dev;
};
#define DMA_DIR(d) ((d == DATA_OUT_DIR) ? DMA_TO_DEVICE : DMA_FROM_DEVICE)
static irqreturn_t a3000_intr(int irq, void *data)
{
struct Scsi_Host *instance = data;
struct a3000_hostdata *hdata = shost_priv(instance);
unsigned int status = hdata->regs->ISTR;
unsigned long flags;
if (!(status & ISTR_INT_P))
return IRQ_NONE;
if (status & ISTR_INTS) {
spin_lock_irqsave(instance->host_lock, flags);
wd33c93_intr(instance);
spin_unlock_irqrestore(instance->host_lock, flags);
return IRQ_HANDLED;
}
pr_warn("Non-serviced A3000 SCSI-interrupt? ISTR = %02x\n", status);
return IRQ_NONE;
}
static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
{
struct scsi_pointer *scsi_pointer = WD33C93_scsi_pointer(cmd);
unsigned long len = scsi_pointer->this_residual;
struct Scsi_Host *instance = cmd->device->host;
struct a3000_hostdata *hdata = shost_priv(instance);
struct WD33C93_hostdata *wh = &hdata->wh;
struct a3000_scsiregs *regs = hdata->regs;
unsigned short cntr = CNTR_PDMD | CNTR_INTEN;
dma_addr_t addr;
addr = dma_map_single(hdata->dev, scsi_pointer->ptr,
len, DMA_DIR(dir_in));
if (dma_mapping_error(hdata->dev, addr)) {
dev_warn(hdata->dev, "cannot map SCSI data block %p\n",
scsi_pointer->ptr);
return 1;
}
scsi_pointer->dma_handle = addr;
/*
* if the physical address has the wrong alignment, or if
* physical address is bad, or if it is a write and at the
* end of a physical memory chunk, then allocate a bounce
* buffer
* MSch 20220629 - only wrong alignment tested - bounce
* buffer returned by kmalloc is guaranteed to be aligned
*/
if (addr & A3000_XFER_MASK) {
WARN_ONCE(1, "Invalid alignment for DMA!");
/* drop useless mapping */
dma_unmap_single(hdata->dev, scsi_pointer->dma_handle,
scsi_pointer->this_residual,
DMA_DIR(dir_in));
wh->dma_bounce_len = (scsi_pointer->this_residual + 511) & ~0x1ff;
wh->dma_bounce_buffer = kmalloc(wh->dma_bounce_len,
GFP_KERNEL);
/* can't allocate memory; use PIO */
if (!wh->dma_bounce_buffer) {
wh->dma_bounce_len = 0;
scsi_pointer->dma_handle = (dma_addr_t) NULL;
return 1;
}
if (!dir_in) {
/* copy to bounce buffer for a write */
memcpy(wh->dma_bounce_buffer, scsi_pointer->ptr,
scsi_pointer->this_residual);
}
addr = dma_map_single(hdata->dev, scsi_pointer->ptr,
len, DMA_DIR(dir_in));
if (dma_mapping_error(hdata->dev, addr)) {
dev_warn(hdata->dev,
"cannot map SCSI data block %p\n",
scsi_pointer->ptr);
return 1;
}
scsi_pointer->dma_handle = addr;
}
Annotation
- Immediate include surface: `linux/types.h`, `linux/mm.h`, `linux/ioport.h`, `linux/init.h`, `linux/slab.h`, `linux/spinlock.h`, `linux/interrupt.h`, `linux/platform_device.h`.
- Detected declarations: `struct a3000_hostdata`, `function a3000_intr`, `function dma_setup`, `function dma_stop`, `function amiga_a3000_scsi_probe`, `function amiga_a3000_scsi_remove`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.