aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/Kconfig5
-rw-r--r--drivers/scsi/Makefile6
-rw-r--r--drivers/scsi/scsi_lib.c38
-rw-r--r--drivers/scsi/scsi_lib_dma.c50
4 files changed, 58 insertions, 41 deletions
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 874cfee29358..6ac3873e4d73 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -10,6 +10,7 @@ config RAID_ATTRS
10config SCSI 10config SCSI
11 tristate "SCSI device support" 11 tristate "SCSI device support"
12 depends on BLOCK 12 depends on BLOCK
13 select SCSI_DMA if HAS_DMA
13 ---help--- 14 ---help---
14 If you want to use a SCSI hard disk, SCSI tape drive, SCSI CD-ROM or 15 If you want to use a SCSI hard disk, SCSI tape drive, SCSI CD-ROM or
15 any other SCSI device under Linux, say Y and make sure that you know 16 any other SCSI device under Linux, say Y and make sure that you know
@@ -29,6 +30,10 @@ config SCSI
29 However, do not compile this as a module if your root file system 30 However, do not compile this as a module if your root file system
30 (the one containing the directory /) is located on a SCSI device. 31 (the one containing the directory /) is located on a SCSI device.
31 32
33config SCSI_DMA
34 bool
35 default n
36
32config SCSI_TGT 37config SCSI_TGT
33 tristate "SCSI target support" 38 tristate "SCSI target support"
34 depends on SCSI && EXPERIMENTAL 39 depends on SCSI && EXPERIMENTAL
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index cbc2e2ba5412..0f8689557158 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -148,9 +148,9 @@ obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o
148obj-$(CONFIG_SCSI_WAIT_SCAN) += scsi_wait_scan.o 148obj-$(CONFIG_SCSI_WAIT_SCAN) += scsi_wait_scan.o
149 149
150scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \ 150scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \
151 scsicam.o scsi_error.o scsi_lib.o \ 151 scsicam.o scsi_error.o scsi_lib.o
152 scsi_scan.o scsi_sysfs.o \ 152scsi_mod-$(CONFIG_SCSI_DMA) += scsi_lib_dma.o
153 scsi_devinfo.o 153scsi_mod-y += scsi_scan.o scsi_sysfs.o scsi_devinfo.o
154scsi_mod-$(CONFIG_SCSI_NETLINK) += scsi_netlink.o 154scsi_mod-$(CONFIG_SCSI_NETLINK) += scsi_netlink.o
155scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o 155scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o
156scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o 156scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 70454b4e8485..1f5a07bf2a75 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2290,41 +2290,3 @@ void scsi_kunmap_atomic_sg(void *virt)
2290 kunmap_atomic(virt, KM_BIO_SRC_IRQ); 2290 kunmap_atomic(virt, KM_BIO_SRC_IRQ);
2291} 2291}
2292EXPORT_SYMBOL(scsi_kunmap_atomic_sg); 2292EXPORT_SYMBOL(scsi_kunmap_atomic_sg);
2293
2294/**
2295 * scsi_dma_map - perform DMA mapping against command's sg lists
2296 * @cmd: scsi command
2297 *
2298 * Returns the number of sg lists actually used, zero if the sg lists
2299 * is NULL, or -ENOMEM if the mapping failed.
2300 */
2301int scsi_dma_map(struct scsi_cmnd *cmd)
2302{
2303 int nseg = 0;
2304
2305 if (scsi_sg_count(cmd)) {
2306 struct device *dev = cmd->device->host->shost_gendev.parent;
2307
2308 nseg = dma_map_sg(dev, scsi_sglist(cmd), scsi_sg_count(cmd),
2309 cmd->sc_data_direction);
2310 if (unlikely(!nseg))
2311 return -ENOMEM;
2312 }
2313 return nseg;
2314}
2315EXPORT_SYMBOL(scsi_dma_map);
2316
2317/**
2318 * scsi_dma_unmap - unmap command's sg lists mapped by scsi_dma_map
2319 * @cmd: scsi command
2320 */
2321void scsi_dma_unmap(struct scsi_cmnd *cmd)
2322{
2323 if (scsi_sg_count(cmd)) {
2324 struct device *dev = cmd->device->host->shost_gendev.parent;
2325
2326 dma_unmap_sg(dev, scsi_sglist(cmd), scsi_sg_count(cmd),
2327 cmd->sc_data_direction);
2328 }
2329}
2330EXPORT_SYMBOL(scsi_dma_unmap);
diff --git a/drivers/scsi/scsi_lib_dma.c b/drivers/scsi/scsi_lib_dma.c
new file mode 100644
index 000000000000..ac6855cd2657
--- /dev/null
+++ b/drivers/scsi/scsi_lib_dma.c
@@ -0,0 +1,50 @@
1/*
2 * SCSI library functions depending on DMA
3 */
4
5#include <linux/blkdev.h>
6#include <linux/device.h>
7#include <linux/kernel.h>
8
9#include <scsi/scsi.h>
10#include <scsi/scsi_cmnd.h>
11#include <scsi/scsi_device.h>
12#include <scsi/scsi_host.h>
13
14/**
15 * scsi_dma_map - perform DMA mapping against command's sg lists
16 * @cmd: scsi command
17 *
18 * Returns the number of sg lists actually used, zero if the sg lists
19 * is NULL, or -ENOMEM if the mapping failed.
20 */
21int scsi_dma_map(struct scsi_cmnd *cmd)
22{
23 int nseg = 0;
24
25 if (scsi_sg_count(cmd)) {
26 struct device *dev = cmd->device->host->shost_gendev.parent;
27
28 nseg = dma_map_sg(dev, scsi_sglist(cmd), scsi_sg_count(cmd),
29 cmd->sc_data_direction);
30 if (unlikely(!nseg))
31 return -ENOMEM;
32 }
33 return nseg;
34}
35EXPORT_SYMBOL(scsi_dma_map);
36
37/**
38 * scsi_dma_unmap - unmap command's sg lists mapped by scsi_dma_map
39 * @cmd: scsi command
40 */
41void scsi_dma_unmap(struct scsi_cmnd *cmd)
42{
43 if (scsi_sg_count(cmd)) {
44 struct device *dev = cmd->device->host->shost_gendev.parent;
45
46 dma_unmap_sg(dev, scsi_sglist(cmd), scsi_sg_count(cmd),
47 cmd->sc_data_direction);
48 }
49}
50EXPORT_SYMBOL(scsi_dma_unmap);