From: Andi Kleen <andi@firstfloor.org>
To: linux-scsi@vger.kernel.org,
James.Bottomley@HansenPartnership.com, axboe@kernel.dk
Subject: [PATCH] [5/21] SCSI-ISA-DMA: Remove unchecked_isa in BusLogic
Date: Thu, 2 Oct 2008 09:58:43 +0200 (CEST) [thread overview]
Message-ID: <20081002075843.2D4D63E6A09@basil.firstfloor.org> (raw)
In-Reply-To: <20081002958.641114646@firstfloor.org>
- ->cmnd handling audited and does always copy
- Allocate hostdata separately
- Enable sense_buffer isa bounce buffering
- Remove unchecked_isa_dma
- Enable block layer bouncing explicitely for isa adapters
Untested due to lack of hardware
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
drivers/scsi/BusLogic.c | 77 ++++++++++++++++++++++++++++++++++++------------
1 file changed, 59 insertions(+), 18 deletions(-)
Index: linux/drivers/scsi/BusLogic.c
===================================================================
--- linux.orig/drivers/scsi/BusLogic.c
+++ linux/drivers/scsi/BusLogic.c
@@ -62,6 +62,13 @@
static struct scsi_host_template Bus_Logic_template;
+struct host_ptr {
+ struct BusLogic_HostAdapter *host;
+ dma_addr_t dma;
+};
+#define bl_shost_priv(shost) (((struct host_ptr *)shost_priv(shost))->host)
+#define bl_shost_dma(shost) (((struct host_ptr *)shost_priv(shost))->dma)
+
/*
BusLogic_DriverOptionsCount is a count of the number of BusLogic Driver
Options specifications provided via the Linux Kernel Command Line or via
@@ -124,6 +131,12 @@ static int BusLogic_ProbeInfoCount;
static struct BusLogic_ProbeInfo *BusLogic_ProbeInfoList;
+static int buslogic_adjust_queue(struct scsi_device *device)
+{
+ if (device->host->sense_buffer_isa)
+ blk_queue_bounce_limit(device->request_queue, BLK_BOUNCE_ISA);
+ return 0;
+}
/*
BusLogic_CommandFailureReason holds a string identifying the reason why a
@@ -152,7 +165,7 @@ static void BusLogic_AnnounceDriver(stru
static const char *BusLogic_DriverInfo(struct Scsi_Host *Host)
{
- struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) Host->hostdata;
+ struct BusLogic_HostAdapter *HostAdapter = bl_shost_priv(Host);
return HostAdapter->FullModelName;
}
@@ -1610,9 +1623,6 @@ static bool __init BusLogic_ReadHostAdap
BIOS_Address is 0.
*/
HostAdapter->BIOS_Address = ExtendedSetupInformation.BIOS_Address << 12;
- /*
- ISA Host Adapters require Bounce Buffers if there is more than 16MB memory.
- */
if (HostAdapter->HostAdapterBusType == BusLogic_ISA_Bus && (void *) high_memory > (void *) MAX_DMA_ADDRESS)
HostAdapter->BounceBuffersRequired = true;
/*
@@ -2131,7 +2141,9 @@ static void __init BusLogic_InitializeHo
Host->this_id = HostAdapter->SCSI_ID;
Host->can_queue = HostAdapter->DriverQueueDepth;
Host->sg_tablesize = HostAdapter->DriverScatterGatherLimit;
- Host->unchecked_isa_dma = HostAdapter->BounceBuffersRequired;
+ if (HostAdapter->BounceBuffersRequired)
+ Host->sense_buffer_isa = 1;
+
Host->cmd_per_lun = HostAdapter->UntaggedQueueDepth;
}
@@ -2145,7 +2157,7 @@ static void __init BusLogic_InitializeHo
*/
static int BusLogic_SlaveConfigure(struct scsi_device *Device)
{
- struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) Device->host->hostdata;
+ struct BusLogic_HostAdapter *HostAdapter = bl_shost_priv(Device->host);
int TargetID = Device->id;
int QueueDepth = HostAdapter->QueueDepth[TargetID];
@@ -2170,6 +2182,35 @@ static int BusLogic_SlaveConfigure(struc
return 0;
}
+static struct Scsi_Host *buslogic_host_alloc(gfp_t gfp)
+{
+ struct BusLogic_HostAdapter *board;
+ struct Scsi_Host *shost;
+
+
+ shost = scsi_host_alloc(&Bus_Logic_template, sizeof(struct host_ptr));
+ if (!shost)
+ return NULL;
+
+ board = dma_alloc_coherent(NULL, sizeof(struct BusLogic_HostAdapter),
+ &bl_shost_dma(shost), GFP_KERNEL);
+ if (!board) {
+ scsi_host_put(shost);
+ return NULL;
+ }
+
+ bl_shost_priv(shost) = board;
+
+ return shost;
+}
+
+static void buslogic_free_host(struct Scsi_Host *shost)
+{
+ dma_free_coherent(NULL, sizeof(struct BusLogic_HostAdapter),
+ bl_shost_priv(shost), bl_shost_dma(shost));
+ scsi_host_put(shost);
+}
+
/*
BusLogic_DetectHostAdapter probes for BusLogic Host Adapters at the standard
I/O Addresses where they may be located, initializing, registering, and
@@ -2270,12 +2311,12 @@ static int __init BusLogic_init(void)
Register the SCSI Host structure.
*/
- Host = scsi_host_alloc(&Bus_Logic_template, sizeof(struct BusLogic_HostAdapter));
+ Host = buslogic_host_alloc(PrototypeHostAdapter->BounceBuffersRequired ? GFP_DMA : 0);
if (Host == NULL) {
release_region(HostAdapter->IO_Address, HostAdapter->AddressCount);
continue;
}
- HostAdapter = (struct BusLogic_HostAdapter *) Host->hostdata;
+ HostAdapter = bl_shost_priv(Host);
memcpy(HostAdapter, PrototypeHostAdapter, sizeof(struct BusLogic_HostAdapter));
HostAdapter->SCSI_Host = Host;
HostAdapter->HostNumber = Host->host_no;
@@ -2321,7 +2362,7 @@ static int __init BusLogic_init(void)
BusLogic_DestroyCCBs(HostAdapter);
BusLogic_ReleaseResources(HostAdapter);
list_del(&HostAdapter->host_list);
- scsi_host_put(Host);
+ buslogic_free_host(Host);
ret = -ENOMEM;
} else {
BusLogic_InitializeHostStructure(HostAdapter,
@@ -2335,7 +2376,7 @@ static int __init BusLogic_init(void)
BusLogic_DestroyCCBs(HostAdapter);
BusLogic_ReleaseResources(HostAdapter);
list_del(&HostAdapter->host_list);
- scsi_host_put(Host);
+ buslogic_free_host(Host);
ret = -ENODEV;
} else {
scsi_scan_host(Host);
@@ -2354,7 +2395,7 @@ static int __init BusLogic_init(void)
BusLogic_DestroyCCBs(HostAdapter);
BusLogic_ReleaseResources(HostAdapter);
list_del(&HostAdapter->host_list);
- scsi_host_put(Host);
+ buslogic_free_host(Host);
ret = -ENODEV;
}
}
@@ -2398,7 +2439,7 @@ static int __exit BusLogic_ReleaseHostAd
*/
list_del(&HostAdapter->host_list);
- scsi_host_put(Host);
+ buslogic_free_host(Host);
return 0;
}
@@ -2786,7 +2827,7 @@ static bool BusLogic_WriteOutgoingMailbo
static int BusLogic_host_reset(struct scsi_cmnd * SCpnt)
{
- struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) SCpnt->device->host->hostdata;
+ struct BusLogic_HostAdapter *HostAdapter = bl_shost_priv(SCpnt->device->host);
unsigned int id = SCpnt->device->id;
struct BusLogic_TargetStatistics *stats = &HostAdapter->TargetStatistics[id];
@@ -2808,7 +2849,7 @@ static int BusLogic_host_reset(struct sc
static int BusLogic_QueueCommand(struct scsi_cmnd *Command, void (*CompletionRoutine) (struct scsi_cmnd *))
{
- struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) Command->device->host->hostdata;
+ struct BusLogic_HostAdapter *HostAdapter = bl_shost_priv(Command->device->host);
struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[Command->device->id];
struct BusLogic_TargetStatistics *TargetStatistics = HostAdapter->TargetStatistics;
unsigned char *CDB = Command->cmnd;
@@ -3001,7 +3042,7 @@ static int BusLogic_QueueCommand(struct
static int BusLogic_AbortCommand(struct scsi_cmnd *Command)
{
- struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) Command->device->host->hostdata;
+ struct BusLogic_HostAdapter *HostAdapter = bl_shost_priv(Command->device->host);
int TargetID = Command->device->id;
struct BusLogic_CCB *CCB;
@@ -3131,7 +3172,7 @@ static int BusLogic_ResetHostAdapter(str
static int BusLogic_BIOSDiskParameters(struct scsi_device *sdev, struct block_device *Device, sector_t capacity, int *Parameters)
{
- struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) sdev->host->hostdata;
+ struct BusLogic_HostAdapter *HostAdapter = bl_shost_priv(sdev->host);
struct BIOS_DiskParameters *DiskParameters = (struct BIOS_DiskParameters *) Parameters;
unsigned char *buf;
if (HostAdapter->ExtendedTranslationEnabled && capacity >= 2 * 1024 * 1024 /* 1 GB in 512 byte sectors */ ) {
@@ -3202,7 +3243,7 @@ static int BusLogic_BIOSDiskParameters(s
static int BusLogic_ProcDirectoryInfo(struct Scsi_Host *shost, char *ProcBuffer, char **StartPointer, off_t Offset, int BytesAvailable, int WriteFlag)
{
- struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) shost->hostdata;
+ struct BusLogic_HostAdapter *HostAdapter = bl_shost_priv(shost);
struct BusLogic_TargetStatistics *TargetStatistics;
int TargetID, Length;
char *Buffer;
@@ -3575,9 +3616,9 @@ static struct scsi_host_template Bus_Log
#if 0
.eh_abort_handler = BusLogic_AbortCommand,
#endif
- .unchecked_isa_dma = 1,
.max_sectors = 128,
.use_clustering = ENABLE_CLUSTERING,
+ .slave_alloc = buslogic_adjust_queue,
};
/*
next prev parent reply other threads:[~2008-10-02 7:58 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-02 7:58 [PATCH] [0/21] Remove SCSI unchecked_isa_dma try 3 Andi Kleen
2008-10-02 7:58 ` [PATCH] [1/21] SCSI-ISA-DMA: Add the alloc/get_pages_mask calls Andi Kleen
2008-10-02 7:58 ` [PATCH] [2/21] SCSI-ISA-DMA: Add blk_q_mask Andi Kleen
2008-10-02 7:58 ` [PATCH] [3/21] SCSI-ISA-DMA: Pass gfp to scsi_allocate_command Andi Kleen
2008-10-02 7:58 ` [PATCH] [4/21] SCSI-ISA-DMA: Add sense_buffer_isa to host template Andi Kleen
2008-10-02 7:58 ` Andi Kleen [this message]
2008-10-02 7:58 ` [PATCH] [6/21] SCSI-ISA-DMA: Remove unchecked_isa_dma in advansys.c Andi Kleen
2008-10-02 7:58 ` [PATCH] [7/21] SCSI-ISA-DMA: Remove unchecked_isa_dma in gdth Andi Kleen
2008-10-02 7:58 ` [PATCH] [8/21] SCSI-ISA-DMA: Remove unchecked_isa_dma in eata.c Andi Kleen
2008-10-02 7:58 ` [PATCH] [9/21] SCSI-ISA-DMA: Remove unchecked_isa_dma in aha1542 Andi Kleen
2008-10-02 7:58 ` [PATCH] [10/21] SCSI-ISA-DMA: Remove unchecked_isa_dma in aha152x/wd7000/sym53c416/u14-34f/NCR53c406a Andi Kleen
2008-10-02 7:58 ` [PATCH] [11/21] SCSI-ISA-DMA: Remove GFP_DMA uses in st/osst Andi Kleen
2008-10-02 7:58 ` [PATCH] [12/21] SCSI-ISA-DMA: Remove unchecked_isa_dma support for hostdata Andi Kleen
2008-10-02 7:58 ` [PATCH] [13/21] SCSI-ISA-DMA: Use blk_q_mask/get_pages_mask in sg driver Andi Kleen
2008-10-02 7:58 ` [PATCH] [14/21] SCSI-ISA-DMA: Rely on block layer bouncing for ISA DMA devices scanning Andi Kleen
2008-10-02 7:58 ` [PATCH] [15/21] SCSI-ISA-DMA: Don't disable direct_io for unchecked_isa_dma in st.c Andi Kleen
2008-10-02 7:58 ` [PATCH] [16/21] SCSI-ISA-DMA: Remove automatic block layer bouncing for unchecked_isa_dma Andi Kleen
2008-10-02 7:58 ` [PATCH] [17/21] SCSI-ISA-DMA: Remove GFP_DMA use in sr.c Andi Kleen
2008-10-02 7:58 ` [PATCH] [18/21] SCSI-ISA-DMA: Remove unchecked_isa_dma from sysfs Andi Kleen
2008-10-02 7:58 ` [PATCH] [19/21] SCSI-ISA-DMA: Switch to a single SCSI command pool Andi Kleen
2008-10-02 7:58 ` [PATCH] [20/21] SCSI-ISA-DMA: Finally kill unchecked_isa_dma Andi Kleen
2008-10-02 7:58 ` [PATCH] [21/21] SCSI-ISA-DMA: Convert DMA buffers in ch.c to allocate via the block layer Andi Kleen
2008-10-07 23:53 ` [PATCH] [0/21] Remove SCSI unchecked_isa_dma try 3 Andi Kleen
2008-10-08 10:21 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081002075843.2D4D63E6A09@basil.firstfloor.org \
--to=andi@firstfloor.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=axboe@kernel.dk \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox