Remove isa_unchecked_dma and some more GFP_DMAs in the mid layer
Subsystems (13)
cover Remove isa_unchecked_dma and some more GFP_DMAs in the mid layer
This patchkit fixes all existing drivers that used isa_unchecked_dma to not need that anymore. I have some upcoming infrastructure changes for DMA memory management and isa_unchecked_dma was in the way.
Enabling isa_unchecked_dma had several effects:
- All incoming scsi_cmnds were in GFP_DMA memory.
Only one driver relied on that actually (advansys), the others all accessed the scsi_cmnds only with the CPU.
- scsi hostdata is allocated with GFP_DMA
A lot of drivers relied on that. I converted them all to allocate hostdata in a separate buffer linked to rom the scsi host structure.
- Enabling block layer bouncing for all data. That's the most important one. I changed all drivers to do that directly instead of relying on the mid layer for it.
- sense_buffer is allocated with GFP_DMA. That was also commonly required and not easy to fix so I created a separate host template field that enables sense_buffer bouncing.
Also while I was it I removed also a lot of GFP_DMAs in the frontend drivers which are not needed anymore because the block layer does the bouncing for all data anyways.
The main problem of the patchkit is that is that I wasn't able to test the drivers because I don't have any of the hardware. All changes (except perhaps advansys) were relatively simple and straight forward so I don't expect many problems though.
If anybody has any of these ISA SCSI adapters and would be willing to test them with these patches that would be appreciated.
I suspect actually that some of the ISA drivers are actually already bitrotted independently of these changes. Hopefully they won't make anything worse though.
Patches against 2.6.25rc2
These are a lot of patches. I can set up a git tree if that makes merging easier. Please let me now if I should do that.
-Andi
PATCH 1/22 Add new sense_buffer_mask host template field
sense buffers are something that still needs to be explicitely bounced in the scsi layer. Instead of using the global unchecked_isa_dma flag define a special fine grained mask for this.
I decided to use a full dma mask because that is most useful for some future infrastructure work I'm doing.
Needed for followup patches.
--- Documentation/scsi/scsi_mid_low_api.txt | 4 ++++ drivers/scsi/hosts.c | 1 + drivers/scsi/scsi.c | 12 +++++++++++- include/scsi/scsi_host.h | 10 +++++++++- 4 files changed, 25 insertions(+), 2 deletions(-)
drivers/scsi/scsi.c +11 -1
@@ -299,6 +299,15 @@ void scsi_put_command(struct scsi_cmnd * }EXPORT_SYMBOL (scsi_put_command); +static int sense_buffer_isa (struct Scsi_Host *shost) +{ +if (!shost->sense_buffer_mask) +return 0 ; +if (~shost->sense_buffer_mask &BLK_BOUNCE_HIGH ) +return 1 ; +return 0 ; +} +/** * scsi_setup_command_freelist - Setup the command freelist for a scsi host. * @shost: host to allocate the freelist for.
@@ -322,7 +331,8 @@ int scsi_setup_command_freelist(struct S* yet existent. */ mutex_lock (&host_cmd_pool_mutex); - pool = (shost->unchecked_isa_dma ? &scsi_cmd_dma_pool : &scsi_cmd_pool); + pool = (shost->unchecked_isa_dma ||sense_buffer_isa (shost)) ? + &scsi_cmd_dma_pool : &scsi_cmd_pool;if (!pool->users) { pool->cmd_slab = kmem_cache_create(pool->cmd_name, sizeof(struct scsi_cmnd), 0,
include/scsi/scsi_host.h +9 -1
@@ -484,6 +484,14 @@ struct scsi_host_template {* module_init/module_exit. */ struct list_head legacy_hosts; + +/* +* DMA Mask of the sense buffer. +* 0 means any in lowmem and subject to the pci device mask +* This should only be set by ISA drivers doing direct DMA to the sense buffer +* Status: optional. +*/ +u64 sense_buffer_mask; };/*
@@ -649,7 +657,7 @@ struct Scsi_Host {unsigned char n_io_port;unsigned char dma_channel;unsigned int irq; - +u64 sense_buffer_mask;enum scsi_host_state shost_state;
Documentation/scsi/scsi_mid_low_api.txt +4 -0
@@ -1268,6 +1268,10 @@ of interest: instances (currently ordered by ascending host_no) my_devices - a double linked list of pointers to struct scsi_device instances that belong to this host. + sense_buffer_mask - dma mask for the sense buffer. Only needed when + the dma mask is below the minimum supported by the + PCI IOMMU on that platform. + Ignored when 0. Normally only needed on ISA host adapters. hostdata[0] - area reserved for LLD at end of struct Scsi_Host. Size is set by the second argument (named 'xtr_bytes') to scsi_host_alloc() or scsi_register().
drivers/scsi/hosts.c +1 -0
@@ -342,6 +342,7 @@ struct Scsi_Host *scsi_host_alloc(struct shost->use_clustering = sht->use_clustering; shost->ordered_tag = sht->ordered_tag; shost->active_mode = sht->supported_mode; + shost->sense_buffer_mask = sht->sense_buffer_mask;if (sht->supported_mode ==MODE_UNKNOWN )/* means we didn't set it ... default to INITIATOR */
James Bottomley
maintainerRe: [PATCH] [1/22] Add new sense_buffer_mask host template field
Quoted 6 lines · Andi Kleen
sense buffers are something that still needs to be explicitely bounced in the scsi layer. Instead of using the global
unchecked_isa_dmaflag define a special fine grained mask for this.I decided to use a full dma mask because that is most useful for some future infrastructure work I'm doing.
Why do we need a separate mask? Why can't we just use the device dma_mask?
James
Re: [PATCH] [1/22] Add new sense_buffer_mask host template field
Quoted 10 lines · James Bottomley
Quoted 6 lines · Andi Kleen
sense buffers are something that still needs to be explicitely bounced in the scsi layer. Instead of using the global
unchecked_isa_dmaflag define a special fine grained mask for this.I decided to use a full dma mask because that is most useful for some future infrastructure work I'm doing.
Why do we need a separate mask? Why can't we just use the device
dma_mask?
First a lot of drivers don't need it because they handle the sense buffers without DMA. So if we just used a device mask we would either do unnecessary work for those or require a special sense buffer mask in the device (which wouldn't belong into the device layer)
Then there isn't really a device anywhere in these drivers and I didn't plan to rewrite them to add one.
So just having a SCSI specific sense buffer mask seemed best. It is only set when a ISA driver actually does sense buffer DMA, which is only true in a handful of drivers.
-Andi
PATCH 2/22 Remove unchecked_isa in BusLogic
In reply to Andi Kleen- ->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
--- drivers/scsi/BusLogic.c | 74 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 18 deletions(-)
drivers/scsi/BusLogic.c +56 -18
@@ -62,6 +62,11 @@static struct scsi_host_template Bus_Logic_template; +struct host_ptr { +struct BusLogic_HostAdapter *host; +}; +#define bl_shost_priv (shost) (((struct host_ptr *)shost_priv(shost))->host) +/* BusLogic_DriverOptionsCount is a count of the number of BusLogic Driver Options specifications provided via the Linux Kernel Command Line or via
@@ -124,6 +129,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_mask) +blk_queue_bounce_limit (device->request_queue,BLK_BOUNCE_ISA ); +return 0 ; +}/* BusLogic_CommandFailureReason holds a string identifying the reason why a
@@ -152,7 +163,7 @@ static void BusLogic_AnnounceDriver(strustatic 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; }
@@ -1607,9 +1618,6 @@ static bool __init BusLogic_ReadHostAdapBIOS_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;/*
@@ -2128,7 +2136,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_mask =DMA_24BIT_MASK ; + } Host->cmd_per_lun = HostAdapter->UntaggedQueueDepth; }
@@ -2142,7 +2152,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];
@@ -2167,6 +2177,34 @@ static int BusLogic_SlaveConfigure(strucreturn 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 = (void *)__get_free_pages (gfp|GFP_KERNEL , +get_order (sizeof (struct BusLogic_HostAdapter ))); +if (!board) { +scsi_host_put (shost); +return NULL ; + } + +memset (board,0 ,sizeof (struct BusLogic_HostAdapter )); +bl_shost_priv (shost) = board; + +return shost; +} + +static void buslogic_free_host (struct Scsi_Host *shost) +{ +free_pages ((unsigned long )bl_shost_priv (shost), +get_order (sizeof (struct BusLogic_HostAdapter ))); +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
@@ -2267,12 +2305,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;
@@ -2318,7 +2356,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,
@@ -2332,7 +2370,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);
@@ -2351,7 +2389,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 ; } }
@@ -2395,7 +2433,7 @@ static int __exit BusLogic_ReleaseHostAd*/ list_del (&HostAdapter->host_list); -scsi_host_put (Host); +buslogic_free_host (Host);return 0 ; }
@@ -2783,7 +2821,7 @@ static bool BusLogic_WriteOutgoingMailbostatic 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];
@@ -2805,7 +2843,7 @@ static int BusLogic_host_reset(struct scstatic 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;
@@ -2998,7 +3036,7 @@ static int BusLogic_QueueCommand(structstatic 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 ;
@@ -3128,7 +3166,7 @@ static int BusLogic_ResetHostAdapter(strstatic 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 */ ) {
@@ -3199,7 +3237,7 @@ static int BusLogic_BIOSDiskParameters(sstatic 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;
@@ -3572,9 +3610,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, };/*
PATCH 3/22 Remove unchecked_isa_dma in advansys.c
In reply to Andi KleenThat patch is a little more complicated than the others. advansys was the only ISA driver who actually passed ->cmnd to the firmware. So I implemented a simple own bounce buffer scheme for this case. Also did sense_buffer bouncing in the driver while I was at it; which means it doesn't require the mid layer to do this anymore.
- allocate hostdata with GFP_DMA separately for the ISA case
- Tell block layer explicitely to bounce for ISA case
- remove unchecked_isa_dma
Untested due to lack of hardware
--- drivers/scsi/advansys.c | 216 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 151 insertions(+), 65 deletions(-)
drivers/scsi/advansys.c +159 -65
@@ -2212,7 +2212,7 @@ do { \#define ASC_STATS_ADD (shost, counter, count)#else /* ADVANSYS_STATS */ #define ASC_STATS_ADD (shost, counter, count) \ - (((struct asc_board *) shost_priv(shost))->asc_stats.counter += (count)) + (asc_shost_priv(shost)->asc_stats.counter += (count))#endif /* ADVANSYS_STATS */ /* If the result wraps when calculating tenths, return 0. */
@@ -2352,12 +2352,16 @@ struct asc_stats { };#endif /* ADVANSYS_STATS */ +union adv_cmnd { +struct { +char cmnd[MAX_COMMAND_SIZE ]; +char sense_buffer[SCSI_SENSE_BUFFERSIZE ]; + }; +struct list_head l; +}; +/* * Structure allocated for each board. -* -* This structure is allocated by scsi_host_alloc() at the end -* of the 'Scsi_Host' structure starting at the 'hostdata' -* field. It is guaranteed to be allocated from DMA-able memory. */ struct asc_board {struct device *dev;
@@ -2388,6 +2392,10 @@ struct asc_board {#ifdef ADVANSYS_STATS struct asc_stats asc_stats;/* Board statistics */ #endif /* ADVANSYS_STATS */ + +void *adv_bounce; +struct list_head adv_cmnd_free; +/* * The following fields are used only for Narrow Boards. */
@@ -2403,8 +2411,17 @@ struct asc_board {ushort bios_version;/* BIOS Version. */ ushort bios_codeseg;/* BIOS Code Segment. */ ushort bios_codelen;/* BIOS Code Segment Length. */ + +}; + +struct asc_board_ptr { +struct asc_board *b; }; +#define ADV_BOUNCE_SIZE (sizeof(union adv_cmnd) * (ASC_DEF_MAX_HOST_QNG + 1)) + +#define asc_shost_priv (h) (((struct asc_board_ptr *)shost_priv(h))->b) +#define asc_dvc_to_board (asc_dvc) container_of(asc_dvc, struct asc_board, \ dvc_var.asc_dvc_var)#define adv_dvc_to_board (adv_dvc) container_of(adv_dvc, struct asc_board, \
@@ -2525,7 +2542,7 @@ static void asc_prt_adv_dvc_cfg(ADV_DVC_*/ static void asc_prt_scsi_host (struct Scsi_Host *s) { -struct asc_board *boardp =shost_priv (s); +struct asc_board *boardp =asc_shost_priv (s);printk ("Scsi_Host at addr 0x%p, device %s\n" , s, boardp->dev->bus_id); printk(" host_busy %u, host_no %d, last_reset %d,\n",
@@ -2537,8 +2554,8 @@ static void asc_prt_scsi_host(struct Scsprintk (" dma_channel %d, this_id %d, can_queue %d,\n" , s->dma_channel, s->this_id, s->can_queue); -printk (" cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n" , - s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma); +printk (" cmd_per_lun %d, sg_tablesize %d\n" , + s->cmd_per_lun, s->sg_tablesize);if (ASC_NARROW_BOARD (boardp)) {asc_prt_asc_dvc_var (&boardp->dvc_var.asc_dvc_var);
@@ -2803,7 +2820,7 @@ static void * advansys_srb_to_ptr(structstatic const char *advansys_info (struct Scsi_Host *shost) {static char info[ASC_INFO_SIZE ]; -struct asc_board *boardp =shost_priv (shost); +struct asc_board *boardp =asc_shost_priv (shost);ASC_DVC_VAR *asc_dvc_varp;ADV_DVC_VAR *adv_dvc_varp;char *busname;
@@ -2919,7 +2936,7 @@ static int asc_prt_line(char *buf, int b*/ static int asc_prt_board_devices (struct Scsi_Host *shost,char *cp,int cplen) { -struct asc_board *boardp =shost_priv (shost); +struct asc_board *boardp =asc_shost_priv (shost);int leftlen;int totlen;int len;
@@ -2959,7 +2976,7 @@ static int asc_prt_board_devices(struct*/ static int asc_prt_adv_bios (struct Scsi_Host *shost,char *cp,int cplen) { -struct asc_board *boardp =shost_priv (shost); +struct asc_board *boardp =asc_shost_priv (shost);int leftlen;int totlen;int len;
@@ -3124,7 +3141,7 @@ static int asc_get_eeprom_string(ushort*/ static int asc_prt_asc_board_eeprom (struct Scsi_Host *shost,char *cp,int cplen) { -struct asc_board *boardp =shost_priv (shost); +struct asc_board *boardp =asc_shost_priv (shost);ASC_DVC_VAR *asc_dvc_varp;int leftlen;int totlen;
@@ -3257,7 +3274,7 @@ static int asc_prt_asc_board_eeprom(stru*/ static int asc_prt_adv_board_eeprom (struct Scsi_Host *shost,char *cp,int cplen) { -struct asc_board *boardp =shost_priv (shost); +struct asc_board *boardp =asc_shost_priv (shost);ADV_DVC_VAR *adv_dvc_varp;int leftlen;int totlen;
@@ -3543,7 +3560,7 @@ static int asc_prt_adv_board_eeprom(stru*/ static int asc_prt_driver_conf (struct Scsi_Host *shost,char *cp,int cplen) { -struct asc_board *boardp =shost_priv (shost); +struct asc_board *boardp =asc_shost_priv (shost);int leftlen;int totlen;int len;
@@ -3569,9 +3586,7 @@ static int asc_prt_driver_conf(struct Sc shost->sg_tablesize, shost->cmd_per_lun);ASC_PRT_NEXT (); - len =asc_prt_line (cp, leftlen, -" unchecked_isa_dma %d, use_clustering %d\n" , - shost->unchecked_isa_dma, shost->use_clustering); + len =asc_prt_line (cp, leftlen," use_clustering %d\n" , shost->use_clustering);ASC_PRT_NEXT (); len = asc_prt_line(cp, leftlen,
@@ -3605,7 +3620,7 @@ static int asc_prt_driver_conf(struct Sc*/ static int asc_prt_asc_board_info (struct Scsi_Host *shost,char *cp,int cplen) { -struct asc_board *boardp =shost_priv (shost); +struct asc_board *boardp =asc_shost_priv (shost);int chip_scsi_id;int leftlen;int totlen;
@@ -3787,7 +3802,7 @@ static int asc_prt_asc_board_info(struct*/ static int asc_prt_adv_board_info (struct Scsi_Host *shost,char *cp,int cplen) { -struct asc_board *boardp =shost_priv (shost); +struct asc_board *boardp =asc_shost_priv (shost);int leftlen;int totlen;int len;
@@ -4065,7 +4080,7 @@ asc_proc_copy(off_t advoffset, off_t off*/ static int asc_prt_board_stats (struct Scsi_Host *shost,char *cp,int cplen) { -struct asc_board *boardp =shost_priv (shost); +struct asc_board *boardp =asc_shost_priv (shost);struct asc_stats *s = &boardp->asc_stats;int leftlen = cplen;
@@ -4151,7 +4166,7 @@ static int advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start, off_t offset, int length, int inout) { - struct asc_board *boardp = shost_priv(shost); + struct asc_board *boardp = asc_shost_priv(shost);char *cp;int cplen;int cnt;
@@ -8200,7 +8215,7 @@ static void adv_isr_callback(ADV_DVC_VARASC_STATS (shost, callback);ASC_DBG (1 ,"shost 0x%p\n" , shost); - boardp =shost_priv (shost); + boardp =asc_shost_priv (shost);BUG_ON (adv_dvc_varp != &boardp->dvc_var.adv_dvc_var);/*
@@ -9132,9 +9147,18 @@ static void asc_isr_callback(ASC_DVC_VARASC_STATS (shost, callback);ASC_DBG (1 ,"shost 0x%p\n" , shost); - boardp =shost_priv (shost); + boardp =asc_shost_priv (shost);BUG_ON (asc_dvc_varp != &boardp->dvc_var.asc_dvc_var); +/* bounce sense buffer back and free bounce buffer */ +if (scp->host_scribble) { +union adv_cmnd *h = (union adv_cmnd *)scp->host_scribble; +if (scp->cmnd[0 ] ==REQUEST_SENSE && scp->sense_buffer) +memcpy (scp->sense_buffer, h->sense_buffer, +SCSI_SENSE_BUFFERSIZE ); +list_add (&boardp->adv_cmnd_free, &h->l); + } +dma_unmap_single (boardp->dev, scp->SCp.dma_handle,SCSI_SENSE_BUFFERSIZE ,DMA_FROM_DEVICE );/*
@@ -9484,7 +9508,7 @@ static int AscISR(ASC_DVC_VAR *asc_dvc)static int advansys_reset (struct scsi_cmnd *scp) {struct Scsi_Host *shost = scp->device->host; -struct asc_board *boardp =shost_priv (shost); +struct asc_board *boardp =asc_shost_priv (shost);unsigned long flags;int status;int ret =SUCCESS ;
@@ -9567,7 +9591,7 @@ static int advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev, sector_t capacity, int ip[]) { - struct asc_board *boardp = shost_priv(sdev->host); + struct asc_board *boardp = asc_shost_priv(sdev->host);ASC_DBG (1 ,"begin\n" );ASC_STATS (sdev->host, biosparam);
@@ -9603,7 +9627,7 @@ advansys_biosparam(struct scsi_device *sstatic irqreturn_t advansys_interrupt (int irq,void *dev_id) {struct Scsi_Host *shost = dev_id; -struct asc_board *boardp =shost_priv (shost); +struct asc_board *boardp =asc_shost_priv (shost);irqreturn_t result =IRQ_NONE ;ASC_DBG (2 ,"boardp 0x%p\n" , boardp);
@@ -9691,6 +9715,9 @@ advansys_narrow_slave_configure(struct sASC_SCSI_BIT_ID_TYPE tid_bit =1 << sdev->id;ASC_SCSI_BIT_ID_TYPE orig_use_tagged_qng = asc_dvc->use_tagged_qng; +if (asc_shost_priv (sdev->host)->adv_bounce) +blk_queue_bounce_limit (sdev->request_queue,BLK_BOUNCE_ISA ); +if (sdev->lun ==0 ) {ASC_SCSI_BIT_ID_TYPE orig_init_sdtr = asc_dvc->init_sdtr;if ((asc_dvc->cfg->sdtr_enable & tid_bit) && sdev->sdtr) {
@@ -9865,7 +9892,7 @@ advansys_wide_slave_configure(struct scs*/ static int advansys_slave_configure (struct scsi_device *sdev) { -struct asc_board *boardp =shost_priv (sdev->host); +struct asc_board *boardp =asc_shost_priv (sdev->host);if (ASC_NARROW_BOARD (boardp)) advansys_narrow_slave_configure(sdev,
@@ -9877,12 +9904,14 @@ static int advansys_slave_configure(strureturn 0 ; } -static __le32 advansys_get_sense_buffer_dma (struct scsi_cmnd *scp) +static __le32 advansys_get_sense_buffer_dma (struct scsi_cmnd *scp, +union adv_cmnd *h) { -struct asc_board *board =shost_priv (scp->device->host); - scp->SCp.dma_handle =dma_map_single (board->dev, scp->sense_buffer, +struct asc_board *board =asc_shost_priv (scp->device->host); +void *buf = h ? (void *)h->sense_buffer : (void *)scp->sense_buffer; + scp->SCp.dma_handle =dma_map_single (board->dev, buf,SCSI_SENSE_BUFFERSIZE ,DMA_FROM_DEVICE ); -dma_cache_sync (board->dev, scp->sense_buffer, +dma_cache_sync (board->dev, buf,SCSI_SENSE_BUFFERSIZE ,DMA_FROM_DEVICE );return cpu_to_le32 (scp->SCp.dma_handle); }
@@ -9892,6 +9921,8 @@ static int asc_build_req(struct asc_boar {struct asc_dvc_var *asc_dvc = &boardp->dvc_var.asc_dvc_var;int use_sg; +union adv_cmnd *h =NULL ; +memset (asc_scsi_q,0 ,sizeof (*asc_scsi_q));
@@ -9907,13 +9938,23 @@ static int asc_build_req(struct asc_boar/* * Build the ASC_SCSI_Q request. */ - asc_scsi_q->cdbptr = &scp->cmnd[0 ]; +if (boardp->adv_bounce) { +/* get a isa bounce cmnd buffer. protected by host_lock */ + h = (union adv_cmnd *)(boardp->adv_cmnd_free.next); +list_del (boardp->adv_cmnd_free.next); + asc_scsi_q->cdbptr = h->cmnd; +memcpy (h->cmnd, scp->cmnd,MAX_COMMAND_SIZE ); + scp->host_scribble = (void *)h; + }else { + asc_scsi_q->cdbptr = &scp->cmnd[0 ]; + scp->host_scribble =NULL ; + } asc_scsi_q->q2.cdb_len = scp->cmd_len; asc_scsi_q->q1.target_id =ASC_TID_TO_TARGET_ID (scp->device->id); asc_scsi_q->q1.target_lun = scp->device->lun; asc_scsi_q->q2.target_ix =ASC_TIDLUN_TO_IX (scp->device->id, scp->device->lun); - asc_scsi_q->q1.sense_addr =advansys_get_sense_buffer_dma (scp); + asc_scsi_q->q1.sense_addr =advansys_get_sense_buffer_dma (scp, h); asc_scsi_q->q1.sense_len =SCSI_SENSE_BUFFERSIZE ;/*
@@ -10925,7 +10966,7 @@ static int AdvExeScsiQueue(ADV_DVC_VAR *static int asc_execute_scsi_cmnd (struct scsi_cmnd *scp) {int ret, err_code; -struct asc_board *boardp =shost_priv (scp->device->host); +struct asc_board *boardp =asc_shost_priv (scp->device->host);ASC_DBG (1 ,"scp 0x%p\n" , scp);
@@ -11725,7 +11766,7 @@ static ushort __devinit AscInitFromEEP(Astatic int __devinit AscInitGetConfig (struct Scsi_Host *shost) { -struct asc_board *board =shost_priv (shost); +struct asc_board *board =asc_shost_priv (shost);ASC_DVC_VAR *asc_dvc = &board->dvc_var.asc_dvc_var;unsigned short warn_code =0 ;
@@ -11779,7 +11820,7 @@ static int __devinit AscInitGetConfig(ststatic int __devinit AscInitSetConfig (struct pci_dev *pdev,struct Scsi_Host *shost) { -struct asc_board *board =shost_priv (shost); +struct asc_board *board =asc_shost_priv (shost);ASC_DVC_VAR *asc_dvc = &board->dvc_var.asc_dvc_var;PortAddr iop_base = asc_dvc->iop_base;unsigned short cfg_msw;
@@ -13172,7 +13213,7 @@ static int __devinit AdvInitFrom38C1600Estatic int __devinit AdvInitGetConfig (struct pci_dev *pdev,struct Scsi_Host *shost) { -struct asc_board *board =shost_priv (shost); +struct asc_board *board =asc_shost_priv (shost);ADV_DVC_VAR *asc_dvc = &board->dvc_var.adv_dvc_var;unsigned short warn_code =0 ;AdvPortAddr iop_base = asc_dvc->iop_base;
@@ -13250,6 +13291,13 @@ AdvInitGetConfig(struct pci_dev *pdev, s }#endif +static int advansys_adjust_queue (struct scsi_device *device) +{ +if (asc_shost_priv (device->host)->adv_bounce) +blk_queue_bounce_limit (device->request_queue,BLK_BOUNCE_ISA ); +return 0 ; +} +static struct scsi_host_template advansys_template = { .proc_name =DRV_NAME , #ifdef CONFIG_PROC_FS
@@ -13261,12 +13309,7 @@ static struct scsi_host_template advansy .eh_bus_reset_handler = advansys_reset, .bios_param = advansys_biosparam, .slave_configure = advansys_slave_configure, -/* -* Because the driver may control an ISA adapter 'unchecked_isa_dma' -* must be set. The flag will be cleared in advansys_board_found -* for non-ISA adapters. -*/ - .unchecked_isa_dma = 1, + .slave_alloc = advansys_adjust_queue,/* * All adapters controlled by this driver are capable of large * scatter-gather lists. According to the mid-level SCSI documentation
@@ -13279,7 +13322,7 @@ static struct scsi_host_template advansystatic int __devinit advansys_wide_init_chip (struct Scsi_Host *shost) { -struct asc_board *board =shost_priv (shost); +struct asc_board *board =asc_shost_priv (shost);struct adv_dvc_var *adv_dvc = &board->dvc_var.adv_dvc_var;int req_cnt =0 ;adv_req_t *reqp =NULL ;
@@ -13390,11 +13433,27 @@ static void advansys_wide_free_mem(struc } } +static int __devinit alloc_cmnd_bounce (struct asc_board *board) +{ +union adv_cmnd *h; +int i; + + board->adv_bounce = (void *)__get_free_pages (GFP_KERNEL |GFP_DMA , +get_order (ADV_BOUNCE_SIZE )); +if (!board->adv_bounce) +return -ENOMEM ; + h = board->adv_bounce; +INIT_LIST_HEAD (&board->adv_cmnd_free); +for (i =0 ; i <ASC_DEF_MAX_HOST_QNG ; i++, h++) +list_add_tail (&board->adv_cmnd_free, &h->l); +return 0 ; +} +static int __devinit advansys_board_found (struct Scsi_Host *shost,unsigned int iop,int bus_type) {struct pci_dev *pdev; -struct asc_board *boardp =shost_priv (shost); +struct asc_board *boardp =asc_shost_priv (shost);ASC_DVC_VAR *asc_dvc_varp =NULL ;ADV_DVC_VAR *adv_dvc_varp =NULL ;int share_irq, warn_code, ret;
@@ -13464,6 +13523,8 @@ static int __devinit advansys_board_foun }#endif /* CONFIG_PROC_FS */ + ret =0 ; +if (ASC_NARROW_BOARD (boardp)) {/* * Set the board bus type and PCI IRQ before
@@ -13472,28 +13533,23 @@ static int __devinit advansys_board_founswitch (asc_dvc_varp->bus_type) {#ifdef CONFIG_ISA case ASC_IS_ISA : - shost->unchecked_isa_dma = TRUE; share_irq =0 ;break ;case ASC_IS_VL : - shost->unchecked_isa_dma = FALSE; share_irq =0 ;break ;case ASC_IS_EISA : - shost->unchecked_isa_dma = FALSE; share_irq =IRQF_SHARED ;break ;#endif /* CONFIG_ISA */ #ifdef CONFIG_PCI case ASC_IS_PCI : - shost->unchecked_isa_dma = FALSE; share_irq =IRQF_SHARED ;break ;#endif /* CONFIG_PCI */ default :shost_printk (KERN_ERR , shost,"unknown adapter type: " "%d\n" , asc_dvc_varp->bus_type); - shost->unchecked_isa_dma = TRUE; share_irq =0 ;break ; }
@@ -13505,14 +13561,14 @@ static int __devinit advansys_board_foun* referenced only use the bit-wise AND operator "&". */ ASC_DBG (2 ,"AscInitGetConfig()\n" ); - ret =AscInitGetConfig (shost) ? -ENODEV :0 ; +if (!ret) + ret =AscInitGetConfig (shost) ? -ENODEV :0 ; }else {#ifdef CONFIG_PCI /* * For Wide boards set PCI information before calling * AdvInitGetConfig(). */ - shost->unchecked_isa_dma = FALSE; share_irq =IRQF_SHARED ;ASC_DBG (2 ,"AdvInitGetConfig()\n" );
@@ -13883,6 +13939,16 @@ static int __devinit advansys_board_founreturn ret; } +static void adv_free_host (struct Scsi_Host *shost) +{ +struct asc_board *board =asc_shost_priv (shost); +if (board->adv_bounce) +free_pages ((unsigned long )board->adv_bounce,get_order (ADV_BOUNCE_SIZE )); +free_pages ((unsigned long )asc_shost_priv (shost), +get_order (sizeof (struct asc_board ))); +scsi_host_put (shost); +} +/* * advansys_release() *
@@ -13890,7 +13956,7 @@ static int __devinit advansys_board_foun*/ static int advansys_release (struct Scsi_Host *shost) { -struct asc_board *board =shost_priv (shost); +struct asc_board *board =asc_shost_priv (shost);ASC_DBG (1 ,"begin\n" );scsi_remove_host (shost);free_irq (board->irq, shost);
@@ -13908,11 +13974,37 @@ static int advansys_release(struct Scsi_advansys_wide_free_mem (board); }kfree (board->prtbuf); -scsi_host_put (shost); +adv_free_host (shost);ASC_DBG (1 ,"end\n" );return 0 ; } +static struct Scsi_Host *adv_host_alloc (gfp_t gfp) +{ +struct asc_board *board; +struct Scsi_Host *shost; + shost =scsi_host_alloc (&advansys_template,sizeof (struct asc_board_ptr )); +if (!shost) +return NULL ; + + board = (void *)__get_free_pages (gfp|GFP_KERNEL , +get_order (sizeof (struct asc_board ))); +if (!board) { +scsi_host_put (shost); +return NULL ; + } + +memset (board,0 ,sizeof (struct asc_board )); + ((struct asc_board_ptr *)shost_priv (shost))->b = board; + +if ((gfp &GFP_DMA ) &&alloc_cmnd_bounce (board) <0 ) { +adv_free_host (shost); + shost =NULL ; + } + +return shost; +} +#define ASC_IOADR_TABLE_MAX_IX 11static PortAddr _asc_def_iop_base[ASC_IOADR_TABLE_MAX_IX ] = {
@@ -13954,11 +14046,12 @@ static int __devinit advansys_isa_probe( goto release_region; err = -ENOMEM ; - shost =scsi_host_alloc (&advansys_template,sizeof (*board)); + shost =adv_host_alloc (GFP_DMA );if (!shost) goto release_region; - board =shost_priv (shost); + board =asc_shost_priv (shost); + board->irq =advansys_isa_irq_no (iop_base); board->dev = dev;
@@ -13970,7 +14063,7 @@ static int __devinit advansys_isa_probe(return 0 ; free_host: -scsi_host_put (shost); +adv_free_host (shost); release_region:release_region (iop_base,ASC_IOADR_GAP );return err;
@@ -14036,11 +14129,11 @@ static int __devinit advansys_vlb_probe( goto release_region; err = -ENOMEM ; - shost =scsi_host_alloc (&advansys_template,sizeof (*board)); + shost =adv_host_alloc (GFP_DMA );/* or 0? */ if (!shost) goto release_region; - board =shost_priv (shost); + board =asc_shost_priv (shost); board->irq =advansys_vlb_irq_no (iop_base); board->dev = dev;
@@ -14052,7 +14145,7 @@ static int __devinit advansys_vlb_probe(return 0 ; free_host: -scsi_host_put (shost); +adv_free_host (shost); release_region:release_region (iop_base,ASC_IOADR_GAP );return -ENODEV ;
@@ -14143,11 +14236,12 @@ static int __devinit advansys_eisa_probe irq =advansys_eisa_irq_no (edev); err = -ENOMEM ; - shost =scsi_host_alloc (&advansys_template,sizeof (*board)); + shost =adv_host_alloc (GFP_DMA ); +if (!shost) goto release_region; - board =shost_priv (shost); + board =asc_shost_priv (shost); board->irq = irq; board->dev = dev;
@@ -14259,11 +14353,11 @@ advansys_pci_probe(struct pci_dev *pdev, ioport =pci_resource_start (pdev,0 ); err = -ENOMEM ; - shost =scsi_host_alloc (&advansys_template,sizeof (*board)); + shost =adv_host_alloc (0 );if (!shost) goto release_region; - board =shost_priv (shost); + board =asc_shost_priv (shost); board->irq = pdev->irq; board->dev = &pdev->dev;
@@ -14281,7 +14375,7 @@ advansys_pci_probe(struct pci_dev *pdev,return 0 ; free_host: -scsi_host_put (shost); +adv_free_host (shost); release_region:pci_release_regions (pdev); disable_device:
Re: [PATCH] [3/22] Remove unchecked_isa_dma in advansys.c
Quoted 5 lines · Andi Kleen
That patch is a little more complicated than the others. advansys was the only ISA driver who actually passed ->cmnd to the firmware. So I implemented a simple own bounce buffer scheme for this case. Also did
sense_bufferbouncing in the driver while I was at it; which means it doesn't require the mid layer to do this anymore.
I have to say I really don't like this patch. I'll look up my current patch queue for this driver next week -- I think I fixed this differently. (I must have fixed it somehow because it works on parisc, which is most unforgiving of drivers which do DMA without the DMA API).
Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
Re: [PATCH] [3/22] Remove unchecked_isa_dma in advansys.c
Quoted 8 lines · Matthew Wilcox
Quoted 5 lines · Andi Kleen
That patch is a little more complicated than the others. advansys was the only ISA driver who actually passed ->cmnd to the firmware. So I implemented a simple own bounce buffer scheme for this case. Also did
sense_bufferbouncing in the driver while I was at it; which means it doesn't require the mid layer to do this anymore.I have to say I really don't like this patch. I'll look up my current
Why do you not like it? What would you do better?
Quoted 3 lines
patch queue for this driver next week -- I think I fixed this differently. (I must have fixed it somehow because it works on parisc, which is most unforgiving of drivers which do DMA without the DMA API).
At least on x86 the DMA API cannot do ISA bouncing.
-Andi
Re: [PATCH] [3/22] Remove unchecked_isa_dma in advansys.c
Quoted 4 lines · Andi Kleen
Quoted 2 lines
(I must have fixed it somehow because it works on parisc, which is most unforgiving of drivers which do DMA without the DMA API).
At least on x86 the DMA API cannot do ISA bouncing.
You're saying that if I set a 24-bit DMA mask, and then do a pci_alloc_coherent(), x86 might hand me back something that's not accessible? That would be just broken.
Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
Re: [PATCH] [3/22] Remove unchecked_isa_dma in advansys.c
Quoted 8 lines · Matthew Wilcox
Quoted 3 lines · Andi Kleen
Quoted 2 lines
(I must have fixed it somehow because it works on parisc, which is most unforgiving of drivers which do DMA without the DMA API).
At least on x86 the DMA API cannot do ISA bouncing.
You're saying that if I set a 24-bit DMA mask, and then do a
pci_alloc_coherent(), x86 might hand me back something that's not accessible? That would be just broken.
Indeed.
Jeff
James Bottomley
maintainerRe: [PATCH] [3/22] Remove unchecked_isa_dma in advansys.c
Quoted 11 lines · Jeff Garzik
Quoted 8 lines · Matthew Wilcox
Quoted 3 lines · Andi Kleen
Quoted 2 lines
(I must have fixed it somehow because it works on parisc, which is most unforgiving of drivers which do DMA without the DMA API).
At least on x86 the DMA API cannot do ISA bouncing.
You're saying that if I set a 24-bit DMA mask, and then do a
pci_alloc_coherent(), x86 might hand me back something that's not accessible? That would be just broken.Indeed.
It's doing the right thing (from pci-dma_32.c):
void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t gfp)
[...]
if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff)) gfp |= GFP_DMA; ret = (void *)__get_free_pages(gfp, order);
Which correctly allocates the region.
James
Re: [PATCH] [3/22] Remove unchecked_isa_dma in advansys.c
In reply to Matthew WilcoxQuoted 9 lines · Matthew Wilcox
Quoted 4 lines · Andi Kleen
Quoted 2 lines
(I must have fixed it somehow because it works on parisc, which is most unforgiving of drivers which do DMA without the DMA API).
At least on x86 the DMA API cannot do ISA bouncing.
You're saying that if I set a 24-bit DMA mask, and then do a
pci_alloc_coherent(), x86 might hand me back something that's not accessible? That would be just broken.
No pci_alloc_coherent works, but pci_map_* will not.
-Andi
James Bottomley
maintainerRe: [PATCH] [3/22] Remove unchecked_isa_dma in advansys.c
Quoted 5 lines · Andi Kleen
Quoted 4 lines · Matthew Wilcox
Quoted 3 lines · Andi Kleen
Quoted 2 lines
(I must have fixed it somehow because it works on parisc, which is most unforgiving of drivers which do DMA without the DMA API).
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
At least on x86 the DMA API cannot do ISA bouncing.
You're saying that if I set a 24-bit DMA mask, and then do a
pci_alloc_coherent(), x86 might hand me back something that's not accessible? That would be just broken.No
pci_alloc_coherentworks, but pci_map_* will not.
Yes, it does ... dma_map is a flush/virt_to_phys on x86. so of course it works. If you mean it doesn't transform from > 24 bit phys to < 24 bit phys, then yes; but that's not an API requirement; that's what bounce buffering is all about, so for ISA devices we always only call dma_map on < 24 bit phys addresses and it all works.
James
Re: [PATCH] [3/22] Remove unchecked_isa_dma in advansys.c
Quoted 8 lines · James Bottomley
Quoted 1 line · Andi Kleen
No
pci_alloc_coherentworks, but pci_map_* will not.Yes, it does ...
dma_mapis a flush/virt_to_phys on x86. so of course it works. If you mean it doesn't transform from > 24 bit phys to < 24 bit phys, then yes; but that's not an API requirement; that's what bounce buffering is all about, so for ISA devices we always only calldma_mapon < 24 bit phys addresses and it all works.
Actually, tomo's patch violates that ...
asc_dvc_varp->overrun_buf = kzalloc(ASC_OVERRUN_BSIZE, GFP_KERNEL);
[...]
asc_dvc->overrun_dma = dma_map_single(board->dev, asc_dvc->overrun_buf, ASC_OVERRUN_BSIZE, DMA_FROM_DEVICE);
There's a missing check for ISA boards and GFP_DMA.
Honestly, I'd rather over-allocate asc_dvc_varp->overrun_buf by 4 bytes and map the appropriate alignment. Patch next week, probably.
Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
Re: [PATCH] [3/22] Remove unchecked_isa_dma in advansys.c
In reply to Andi KleenQuoted 8 lines · Andi Kleen
Quoted 1 line · Matthew Wilcox
I have to say I really don't like this patch. I'll look up my current
Why do you not like it? What would you do better?
Quoted 3 lines
patch queue for this driver next week -- I think I fixed this differently. (I must have fixed it somehow because it works on parisc, which is most unforgiving of drivers which do DMA without the DMA API).
This patch is unnecessary. The driver does not access the cmnd field using DMA. See AscPutReadyQueue where it calls:
AscMemWordCopyPtrToLram(iop_base,
q_addr + ASC_SCSIQ_CDB_BEG,
(uchar *)scsiq->cdbptr, scsiq->q2.cdb_len >> 1);
Despite the name, it doesn't actually copy a pointer to Lram. It copies the thing pointed at to Lram. (ie it's memcpy_toio with a minor twist).
Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
PATCH 4/22 Remove unchecked_isa_dma in gdth
In reply to Andi Kleen- Audited ->cmnd use and it always copies
- Allocate hostdata separately with GFP_DMA for the ISA case
- Tell scsi layer to bounce sense_buffer for ISA case
- Tell block layer to bounce for isa case
- Remove unchecked_isa_dma
Untested due to lack of hardware
--- drivers/scsi/gdth.c | 79 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 60 insertions(+), 19 deletions(-)
drivers/scsi/gdth.c +60 -19
@@ -138,6 +138,13 @@#include <scsi/scsi_host.h> #include "gdth.h" + +struct host_ptr { +gdth_ha_str *host_ptr; +}; + +#define gdth_shost_priv (host) (((struct host_ptr *)shost_priv(host))->host_ptr) +static void gdth_delay (int milliseconds);static void gdth_eval_mapping (ulong32 size,ulong32 *cyls,int *heads,int *secs);static irqreturn_t gdth_interrupt (int irq,void *dev_id);
@@ -490,7 +497,7 @@ static void gdth_scsi_done(struct scsi_cint __gdth_execute (struct scsi_device *sdev,gdth_cmd_str *gdtcmd,char *cmnd,int timeout,u32 *info) { -gdth_ha_str *ha =shost_priv (sdev->host); +gdth_ha_str *ha =gdth_shost_priv (sdev->host);Scsi_Cmnd *scp;struct gdth_cmndinfo cmndinfo;struct scatterlist one_sg;
@@ -3933,7 +3940,7 @@ static const char *gdth_ctr_name(gdth_hastatic const char *gdth_info (struct Scsi_Host *shp) { -gdth_ha_str *ha =shost_priv (shp); +gdth_ha_str *ha =gdth_shost_priv (shp);TRACE2 (("gdth_info()\n" ));return ((const char *)ha->binfo.type_string);
@@ -3941,7 +3948,7 @@ static const char *gdth_info(struct Scsistatic int gdth_eh_bus_reset (Scsi_Cmnd *scp) { -gdth_ha_str *ha =shost_priv (scp->device->host); +gdth_ha_str *ha =gdth_shost_priv (scp->device->host);int i;ulong flags;Scsi_Cmnd *cmnd;
@@ -3994,7 +4001,7 @@ static int gdth_eh_bus_reset(Scsi_Cmnd *static int gdth_bios_param (struct scsi_device *sdev,struct block_device *bdev,sector_t cap,int *ip) {unchar b, t; -gdth_ha_str *ha =shost_priv (sdev->host); +gdth_ha_str *ha =gdth_shost_priv (sdev->host);struct scsi_device *sd;unsigned capacity;
@@ -4023,7 +4030,7 @@ static int gdth_bios_param(struct scsi_dstatic int gdth_queuecommand (struct scsi_cmnd *scp,void (*done)(struct scsi_cmnd *)) { -gdth_ha_str *ha =shost_priv (scp->device->host); +gdth_ha_str *ha =gdth_shost_priv (scp->device->host);struct gdth_cmndinfo *cmndinfo;TRACE (("gdth_queuecommand() cmd 0x%x\n" , scp->cmnd[0 ]));
@@ -4717,6 +4724,13 @@ static int gdth_slave_configure(struct sreturn 0 ; } +static int gdth_adjust_queue (struct scsi_device *device) +{ +if (device->host->sense_buffer_mask) +blk_queue_bounce_limit (device->request_queue,BLK_BOUNCE_ISA ); +return 0 ; +} +static struct scsi_host_template gdth_template = { .name ="GDT SCSI Disk Array Controller" , .info = gdth_info,
@@ -4730,10 +4744,39 @@ static struct scsi_host_template gdth_te .this_id = -1, .sg_tablesize = GDTH_MAXSG, .cmd_per_lun = GDTH_MAXC_P_L, - .unchecked_isa_dma = 1, .use_clustering = ENABLE_CLUSTERING, + .slave_alloc = gdth_adjust_queue, }; +static struct Scsi_Host *gdth_host_alloc (gfp_t gfp) +{ +struct Scsi_Host *shost; +gdth_ha_str *board; + shost =scsi_host_alloc (&gdth_template,sizeof (struct host_ptr )); +if (!shost) +return NULL ; + + board = (void *)__get_free_pages (gfp|GFP_KERNEL , +get_order (sizeof (gdth_ha_str))); +if (!board) { +scsi_host_put (shost); +return NULL ; + } + +memset (board,0 ,sizeof (gdth_ha_str)); +gdth_shost_priv (shost) = board; + +return shost; +} + +static void gdth_free_host (struct Scsi_Host *shost) +{ +free_pages ((unsigned long )gdth_shost_priv (shost), +get_order (sizeof (gdth_ha_str))); +scsi_host_put (shost); +} + +#ifdef CONFIG_ISA static int __init gdth_isa_probe_one (ulong32 isa_bios) {
@@ -4745,10 +4788,10 @@ static int __init gdth_isa_probe_one(uloif (!gdth_search_isa (isa_bios))return -ENXIO ; - shp =scsi_host_alloc (&gdth_template,sizeof (gdth_ha_str)); + shp =gdth_host_alloc (GFP_DMA );if (!shp)return -ENOMEM ; - ha =shost_priv (shp); + ha =gdth_shost_priv (shp); error = -ENODEV ;if (!gdth_init_isa (isa_bios,ha))
@@ -4772,7 +4815,7 @@ static int __init gdth_isa_probe_one(uloset_dma_mode (ha->drq,DMA_MODE_CASCADE );enable_dma (ha->drq); - shp->unchecked_isa_dma =1 ; + shp->sense_buffer_mask =DMA_24BIT_MASK ; shp->irq = ha->irq; shp->dma_channel = ha->drq;
@@ -4860,7 +4903,7 @@ static int __init gdth_isa_probe_one(ulo out_free_irq:free_irq (ha->irq, ha); out_host_put: -scsi_host_put (shp); +gdth_free_host (shp); return error; }#endif /* CONFIG_ISA */
@@ -4876,10 +4919,10 @@ static int __init gdth_eisa_probe_one(usif (!gdth_search_eisa (eisa_slot))return -ENXIO ; - shp =scsi_host_alloc (&gdth_template,sizeof (gdth_ha_str)); + shp =gdth_host_alloc (0 );if (!shp)return -ENOMEM ; - ha =shost_priv (shp); + ha =gdth_shost_priv (shp); error = -ENODEV ;if (!gdth_init_eisa (eisa_slot,ha))
@@ -4895,7 +4938,6 @@ static int __init gdth_eisa_probe_one(us goto out_host_put; } - shp->unchecked_isa_dma =0 ; shp->irq = ha->irq; shp->dma_channel =0xff ;
@@ -4992,7 +5034,7 @@ static int __init gdth_eisa_probe_one(usfree_irq (ha->irq, ha); gdth_ctr_count--; out_host_put: -scsi_host_put (shp); +gdth_free_host (shp); return error; }#endif /* CONFIG_EISA */
@@ -5005,10 +5047,10 @@ static int __init gdth_pci_probe_one(gdtdma_addr_t scratch_dma_handle =0 ;int error, i; - shp =scsi_host_alloc (&gdth_template,sizeof (gdth_ha_str)); + shp =gdth_host_alloc (0 );if (!shp)return -ENOMEM ; - ha =shost_priv (shp); + ha =gdth_shost_priv (shp); error = -ENODEV ;if (!gdth_init_pci (&pcistr[ctr],ha))
@@ -5027,7 +5069,6 @@ static int __init gdth_pci_probe_one(gdt goto out_host_put; } - shp->unchecked_isa_dma =0 ; shp->irq = ha->irq; shp->dma_channel =0xff ;
@@ -5129,7 +5170,7 @@ static int __init gdth_pci_probe_one(gdtfree_irq (ha->irq, ha); gdth_ctr_count--; out_host_put: -scsi_host_put (shp); +gdth_free_host (shp); return error; }#endif /* CONFIG_PCI */
@@ -5171,7 +5212,7 @@ static void gdth_remove_one(gdth_ha_strpci_unmap_single (ha->pdev,ha->ccb_phys,sizeof (gdth_cmd_str),PCI_DMA_BIDIRECTIONAL ); -scsi_host_put (shp); +gdth_free_host (shp); }static int __init gdth_init (void )
PATCH 6/22 Remove unchecked_isa_dma in aha1542
In reply to Andi Kleen- Audited ->cmnd use and it always copies
- Allocate DMAable hostdata separately
- Tell block layer explicitely to bounce
- Audited sense_buffer use and it always copies
- Remove unchecked_isa_dma finally
Untested due to lack of hardware
--- drivers/scsi/aha1542.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-)
drivers/scsi/aha1542.c +28 -10
@@ -151,7 +151,11 @@ struct aha1542_hostdata {struct ccb ccb[AHA1542_MAILBOXES ]; }; -#define HOSTDATA (host) ((struct aha1542_hostdata *) &host->hostdata) +struct hd_ptr { +struct aha1542_hostdata *hostptr; +}; + +#define HOSTDATA (host) (((struct hd_ptr *)shost_priv(host))->hostptr)static struct Scsi_Host *aha_host[7 ];/* One for each IRQ level (9-15) */
@@ -1132,23 +1136,28 @@ static int __init aha1542_detect(struct }for (indx =0 ; indx <ARRAY_SIZE (bases); indx++)if (bases[indx] !=0 &&request_region (bases[indx],4 ,"aha1542" )) { - shpnt =scsi_register (tpnt, -sizeof (struct aha1542_hostdata )); +struct aha1542_hostdata *host; + + shpnt =scsi_register (tpnt,sizeof (struct hd_ptr ));if (shpnt==NULL ) {release_region (bases[indx],4 );continue ; } -/* For now we do this - until kmalloc is more intelligent -we are resigned to stupid hacks like this */ -if (SCSI_BUF_PA (shpnt) >=ISA_DMA_THRESHOLD ) { -printk (KERN_ERR "Invalid address for shpnt with 1542.\n" ); - goto unregister; + + host = (void *)__get_free_pages (GFP_DMA |GFP_KERNEL , +get_order (sizeof (*host))); +if (!host) { +scsi_unregister (shpnt); +release_region (bases[indx],4 ); +continue ; } + +HOSTDATA (shpnt) = host; +if (!aha1542_test_port (bases[indx], shpnt)) goto unregister; - base_io = bases[indx];/* Set the Bus on/off-times as not to ruin floppy performance */
@@ -1265,6 +1274,8 @@ fail:continue ; unregister:release_region (bases[indx],4 ); +free_pages ((unsigned long )HOSTDATA (shpnt), +get_order (sizeof (struct aha1542_hostdata )));scsi_unregister (shpnt);continue ;
@@ -1281,6 +1292,8 @@ static int aha1542_release(struct Scsi_Hfree_dma (shost->dma_channel);if (shost->io_port && shost->n_io_port)release_region (shost->io_port, shost->n_io_port); +free_pages ((unsigned long )HOSTDATA (shost), +get_order (sizeof (struct aha1542_hostdata )));scsi_unregister (shost);return 0 ; }
@@ -1752,6 +1765,11 @@ static int aha1542_biosparam(struct scsi }MODULE_LICENSE ("GPL" ); +static int aha154x_adjust_queue (struct scsi_device *device) +{ +blk_queue_bounce_limit (device->request_queue,BLK_BOUNCE_ISA ); +return 0 ; +}static struct scsi_host_template driver_template = { .proc_name ="aha1542" ,
@@ -1767,7 +1785,7 @@ static struct scsi_host_template driver_ .this_id = 7, .sg_tablesize = AHA1542_SCATTER, .cmd_per_lun = AHA1542_CMDLUN, - .unchecked_isa_dma = 1, .use_clustering = ENABLE_CLUSTERING, + .slave_alloc = aha154x_adjust_queue, };#include "scsi_module.c"
PATCH 7/22 Remove unchecked_isa_dma in aha152x/wd7000/sym53c416/u14-34f/NCR53c406a
In reply to Andi KleenI lumped these all together because these old ISA only drivers all look very unmaintained and the changes were relatively simple.
I audited them for possible use of unchecked_isa_dma and fixed the cases who needed them:
- Allocate separate dma'able hostdata when needed
- Checked that they all always copy ->cmnd
- Checked if they need sense_buffer bouncing and enable when needed (i'm not 100% sure what it means if a driver does not reference sense_buffer, but all except ultrastor and u14-34f do not)
- Add a explicit slave_alloc callback to enable block layer bouncing
Untested due to lack of hardware.
--- drivers/scsi/NCR53c406a.c | 8 ++++++- drivers/scsi/aha152x.c | 22 ++++++++++++++++--- drivers/scsi/sym53c416.c | 9 +++++++ drivers/scsi/u14-34f.c | 52 +++++++++++++++++++++++++++++++++++----------- drivers/scsi/ultrastor.c | 13 ++++++++--- drivers/scsi/wd7000.c | 45 +++++++++++++++++++++++++-------------- 6 files changed, 113 insertions(+), 36 deletions(-)
drivers/scsi/aha152x.c +19 -3
@@ -551,6 +551,9 @@ struct aha152x_hostdata {struct list_head host_list; }; +struct aha152x_hostdata_ptr { +struct aha152x_hostdata *host; +};/* * host specific command extension
@@ -564,7 +567,7 @@ struct aha152x_scdata {/* access macros for hostdata */ -#define HOSTDATA (shpnt) ((struct aha152x_hostdata *) &shpnt->hostdata) +#define HOSTDATA (shpnt) (((struct aha152x_hostdata_ptr *) shost_priv(shpnt))->host)#define HOSTNO ((shpnt)->host_no)
@@ -771,13 +774,22 @@ static irqreturn_t swintr(int irqno, voistruct Scsi_Host *aha152x_probe_one (struct aha152x_setup *setup) {struct Scsi_Host *shpnt; +struct aha152x_hostdata *host; - shpnt =scsi_host_alloc (&aha152x_driver_template,sizeof (struct aha152x_hostdata )); + shpnt =scsi_host_alloc (&aha152x_driver_template,sizeof (struct aha152x_hostdata_ptr ));if (!shpnt) {printk (KERN_ERR "aha152x: scsi_host_alloc failed\n" );return NULL ; } + host = (void *)__get_free_pages (GFP_KERNEL |GFP_DMA , +get_order (sizeof (struct aha152x_hostdata ))); +if (!host) { +scsi_host_put (shpnt); +printk (KERN_ERR "aha152x: dma alloc of hostdata failed\n" ); +return NULL ; + } +memset (HOSTDATA (shpnt),0 ,sizeof *HOSTDATA (shpnt));INIT_LIST_HEAD (&HOSTDATA (shpnt)->host_list);
@@ -899,6 +911,8 @@ struct Scsi_Host *aha152x_probe_one(stru out_host_put:list_del (&HOSTDATA (shpnt)->host_list); +free_pages ((unsigned long )HOSTDATA (shpnt), +get_order (sizeof (struct aha152x_hostdata )));scsi_host_put (shpnt);return NULL ;
@@ -924,6 +938,8 @@ void aha152x_release(struct Scsi_Host *s#endif list_del (&HOSTDATA (shpnt)->host_list); +free_pages ((unsigned long )HOSTDATA (shpnt), +get_order (sizeof (struct aha152x_hostdata )));scsi_host_put (shpnt); }
@@ -3456,7 +3472,7 @@ static int aha152x_proc_info(struct Scsistatic int aha152x_adjust_queue (struct scsi_device *device) { -blk_queue_bounce_limit (device->request_queue,BLK_BOUNCE_HIGH ); +blk_queue_bounce_limit (device->request_queue,BLK_BOUNCE_ISA );return 0 ; }
drivers/scsi/wd7000.c +29 -16
120 lines not on this page · raw message
drivers/scsi/NCR53c406a.c +7 -1
@@ -1045,6 +1045,12 @@ static void __init calc_port_addr(void)MODULE_LICENSE ("GPL" ); +static int NCR53c406a_adjust_queue (struct scsi_device *device) +{ +blk_queue_bounce_limit (device->request_queue,BLK_BOUNCE_ISA ); +return 0 ; +} +/* NOTE: scatter-gather support only works in PIO mode. * Use SG_NONE if DMA mode is enabled! */
@@ -1063,8 +1069,8 @@ static struct scsi_host_template driver_ .this_id = 7 /* SCSI ID of the chip */, .sg_tablesize = 32 /*SG_ALL*/ /*SG_NONE*/, .cmd_per_lun = 1 /* commands per lun */, - .unchecked_isa_dma = 1 /* unchecked_isa_dma */, .use_clustering = ENABLE_CLUSTERING, + .slave_alloc = NCR53c406a_adjust_queue, };#include "scsi_module.c"
drivers/scsi/u14-34f.c +40 -12
147 lines not on this page · raw message
drivers/scsi/sym53c416.c +8 -1
@@ -825,6 +825,12 @@ module_param_array(sym53c416_3, uint, NU#endif +static int sym53c416_adjust_queue (struct scsi_device *device) +{ +blk_queue_bounce_limit (device->request_queue,BLK_BOUNCE_ISA ); +return 0 ; +} +static struct scsi_host_template driver_template = { .proc_name ="sym53c416" , .name ="Symbios Logic 53c416" ,
@@ -838,7 +844,8 @@ static struct scsi_host_template driver_ .this_id = SYM53C416_SCSI_ID, .sg_tablesize = 32, .cmd_per_lun = 1, - .unchecked_isa_dma = 1, .use_clustering = ENABLE_CLUSTERING, + .slave_alloc = sym53c416_adjust_queue, + };#include "scsi_module.c"
drivers/scsi/ultrastor.c +10 -3
@@ -350,6 +350,12 @@ static void log_ultrastor_abort(struct u }#endif +static int ultrastor_adjust_queue (struct scsi_device *device) +{ +blk_queue_bounce_limit (device->request_queue,BLK_BOUNCE_ISA ); +return 0 ; +} +static int ultrastor_14f_detect (struct scsi_host_template * tpnt) {size_t i;
@@ -501,7 +507,10 @@ static int ultrastor_14f_detect(struct s config.dma_channel, config.ha_scsi_id, config.subversion);#endif tpnt->this_id = config.ha_scsi_id; - tpnt->unchecked_isa_dma = (config.subversion !=U34F ); +if (config.subversion !=U34F ) { + tpnt->sense_buffer_mask =DMA_24BIT_MASK ; + tpnt->slave_alloc = ultrastor_adjust_queue; + }#if ULTRASTOR_MAX_CMDS >1 config.mscp_free = ~0 ;
@@ -605,7 +614,6 @@ static int ultrastor_24f_detect(struct s config.interrupt, config.ha_scsi_id);#endif tpnt->this_id = config.ha_scsi_id; - tpnt->unchecked_isa_dma =0 ; tpnt->sg_tablesize =ULTRASTOR_24F_MAX_SG ; shpnt =scsi_register (tpnt,0 );
@@ -1202,7 +1210,6 @@ static struct scsi_host_template driver_ .can_queue = ULTRASTOR_MAX_CMDS, .sg_tablesize = ULTRASTOR_14F_MAX_SG, .cmd_per_lun = ULTRASTOR_MAX_CMDS_PER_LUN, - .unchecked_isa_dma = 1, .use_clustering = ENABLE_CLUSTERING, };#include "scsi_module.c"
PATCH 8/22 Remove random noop unchecked_isa_dma users
In reply to Andi KleenLots of drivers set it to 0. Remove that. Patch should be a nop.
--- drivers/scsi/arm/acornscsi.c | 1 - drivers/scsi/arm/cumana_1.c | 1 - drivers/scsi/dc395x.c | 1 - drivers/scsi/eata_pio.c | 2 -- drivers/scsi/hptiop.c | 1 - drivers/scsi/ips.c | 1 - drivers/scsi/mac_scsi.c | 1 - drivers/scsi/scsi_debug.c | 1 - 8 files changed, 9 deletions(-)
drivers/scsi/arm/acornscsi.c +0 -1
@@ -2983,7 +2983,6 @@ static struct scsi_host_template acornsc .this_id = 7, .sg_tablesize = SG_ALL, .cmd_per_lun = 2, - .unchecked_isa_dma = 0, .use_clustering = DISABLE_CLUSTERING, .proc_name = "acornscsi", };
drivers/scsi/arm/cumana_1.c +0 -1
@@ -222,7 +222,6 @@ static struct scsi_host_template cumanas .this_id = 7, .sg_tablesize = SG_ALL, .cmd_per_lun = 2, - .unchecked_isa_dma = 0, .use_clustering = DISABLE_CLUSTERING, .proc_name = "CumanaSCSI-1", };
drivers/scsi/dc395x.c +0 -1
@@ -4761,7 +4761,6 @@ static struct scsi_host_template dc395x_ .cmd_per_lun = DC395x_MAX_CMD_PER_LUN, .eh_abort_handler = dc395x_eh_abort, .eh_bus_reset_handler = dc395x_eh_bus_reset, - .unchecked_isa_dma = 0, .use_clustering = DISABLE_CLUSTERING, };
drivers/scsi/eata_pio.c +0 -2
@@ -815,8 +815,6 @@ static int register_pio_HBA(long base, selse hd->primary =1 ; - sh->unchecked_isa_dma =0 ;/* We can only do PIO */ - hd->next =NULL ;/* build a linked list of all HBAs */ hd->prev = last_HBA;if (hd->prev !=NULL )
drivers/scsi/hptiop.c +0 -1
@@ -903,7 +903,6 @@ static struct scsi_host_template driver_ .eh_device_reset_handler = hptiop_reset, .eh_bus_reset_handler = hptiop_reset, .info = hptiop_info, - .unchecked_isa_dma = 0, .emulated = 0, .use_clustering = ENABLE_CLUSTERING, .proc_name = driver_name,
drivers/scsi/ips.c +0 -1
@@ -6842,7 +6842,6 @@ ips_register_scsi(int index) sh->sg_tablesize = sh->hostt->sg_tablesize; sh->can_queue = sh->hostt->can_queue; sh->cmd_per_lun = sh->hostt->cmd_per_lun; - sh->unchecked_isa_dma = sh->hostt->unchecked_isa_dma; sh->use_clustering = sh->hostt->use_clustering; sh->max_sectors =128 ;
drivers/scsi/mac_scsi.c +0 -1
@@ -592,7 +592,6 @@ static struct scsi_host_template driver_ .this_id = 7, .sg_tablesize = SG_ALL, .cmd_per_lun = CMD_PER_LUN, - .unchecked_isa_dma = 0, .use_clustering = DISABLE_CLUSTERING };
drivers/scsi/scsi_debug.c +0 -1
@@ -221,7 +221,6 @@ static struct scsi_host_template sdebug_ .sg_tablesize = 256, .cmd_per_lun = 16, .max_sectors = 0xffff, - .unchecked_isa_dma = 0, .use_clustering = ENABLE_CLUSTERING, .module = THIS_MODULE, };
RE: [PATCH] [8/22] Remove random noop unchecked_isa_dma users
ACK (for ips portion, see no harm other chunks).
Sincerely -- Mark Salyzyn
Quoted 120 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Andi Kleen
Sent: Sunday, February 24, 2008 6:35 PM
To: [email protected]; [email protected]
Subject: [PATCH] [8/22] Remove random noopunchecked_isa_dmausersLots of drivers set it to 0. Remove that. Patch should be a nop.
Signed-off-by Andi Kleen <[email protected]>--- drivers/scsi/arm/acornscsi.c | 1 - drivers/scsi/arm/cumana_1.c | 1 - drivers/scsi/dc395x.c | 1 - drivers/scsi/eata_pio.c | 2 -- drivers/scsi/hptiop.c | 1 - drivers/scsi/ips.c | 1 - drivers/scsi/mac_scsi.c | 1 - drivers/scsi/scsi_debug.c | 1 - 8 files changed, 9 deletions(-)Index:
linux/drivers/scsi/arm/acornscsi.c
===================================================================drivers/scsi/arm/acornscsi.c +0
-1@@ -2983,7 +2983,6 @@ static struct scsi_host_template acornsc .this_id = 7, .sg_tablesize = SG_ALL, .cmd_per_lun = 2, - .unchecked_isa_dma = 0, .use_clustering = DISABLE_CLUSTERING, .proc_name = "acornscsi", };Index:
linux/drivers/scsi/arm/cumana_1.c
===================================================================drivers/scsi/arm/cumana_1.c +0
-1@@ -222,7 +222,6 @@ static struct scsi_host_template cumanas .this_id = 7, .sg_tablesize = SG_ALL, .cmd_per_lun = 2, - .unchecked_isa_dma = 0, .use_clustering = DISABLE_CLUSTERING, .proc_name = "CumanaSCSI-1", };Index:
linux/drivers/scsi/dc395x.c
===================================================================drivers/scsi/dc395x.c +0
-1@@ -4761,7 +4761,6 @@ static struct scsi_host_template dc395x_ .cmd_per_lun = DC395x_MAX_CMD_PER_LUN, .eh_abort_handler = dc395x_eh_abort, .eh_bus_reset_handler = dc395x_eh_bus_reset, - .unchecked_isa_dma = 0, .use_clustering = DISABLE_CLUSTERING, };Index:
linux/drivers/scsi/eata_pio.c
===================================================================drivers/scsi/eata_pio.c +0
-2@@ -815,8 +815,6 @@ static int register_pio_HBA(long base, selse hd->primary =1 ; - sh->unchecked_isa_dma =0 ;/* We can only do PIO */ - hd->next =NULL ;/* build a linked list of all HBAs */ hd->prev = last_HBA;if (hd->prev !=NULL )Index:
linux/drivers/scsi/hptiop.c
===================================================================drivers/scsi/hptiop.c +0
-1@@ -903,7 +903,6 @@ static struct scsi_host_template driver_ .eh_device_reset_handler = hptiop_reset, .eh_bus_reset_handler = hptiop_reset, .info = hptiop_info, - .unchecked_isa_dma = 0, .emulated = 0, .use_clustering = ENABLE_CLUSTERING, .proc_name = driver_name,Index:
linux/drivers/scsi/ips.c
===================================================================drivers/scsi/ips.c +0
-1@@ -6842,7 +6842,6 @@ ips_register_scsi(int index) sh->sg_tablesize = sh->hostt->sg_tablesize; sh->can_queue = sh->hostt->can_queue; sh->cmd_per_lun = sh->hostt->cmd_per_lun; - sh->unchecked_isa_dma = sh->hostt->unchecked_isa_dma; sh->use_clustering = sh->hostt->use_clustering; sh->max_sectors =128 ;Index:
linux/drivers/scsi/mac_scsi.c
===================================================================drivers/scsi/mac_scsi.c +0
-1@@ -592,7 +592,6 @@ static struct scsi_host_template driver_ .this_id = 7, .sg_tablesize = SG_ALL, .cmd_per_lun = CMD_PER_LUN, - .unchecked_isa_dma = 0, .use_clustering = DISABLE_CLUSTERING };Index:
linux/drivers/scsi/scsi_debug.c
===================================================================drivers/scsi/scsi_debug.c +0
-1@@ -221,7 +221,6 @@ static struct scsi_host_template sdebug_ .sg_tablesize = 256, .cmd_per_lun = 16, .max_sectors = 0xffff, - .unchecked_isa_dma = 0, .use_clustering = ENABLE_CLUSTERING, .module = THIS_MODULE, };
PATCH 10/22 Remove unchecked_isa_dma support for hostdata
In reply to Andi KleenAll ISA drivers who relied on dma able hostdata have been converted to allocate it separately. So remove the unchecked_isa_dma hostdata support in the mid layer
--- drivers/scsi/hosts.c | 3 --- 1 file changed, 3 deletions(-)
drivers/scsi/hosts.c +0 -3
@@ -297,9 +297,6 @@ struct Scsi_Host *scsi_host_alloc(structgfp_t gfp_mask =GFP_KERNEL ;int rval; -if (sht->unchecked_isa_dma && privsize) - gfp_mask |= __GFP_DMA; - shost =kzalloc (sizeof (struct Scsi_Host ) + privsize, gfp_mask);if (!shost)return NULL ;
PATCH 11/22 Remove unchecked_isa_dma checks in sg.c
In reply to Andi KleenThey are only used to allocate data buffers, and those are bounced by the block layer anyways.
--- drivers/scsi/sg.c | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-)
drivers/scsi/sg.c +9 -27
@@ -150,7 +150,6 @@ typedef struct sg_fd { /* holds the staSg_request *headrp;/* head of request slist, NULL->empty */ struct fasync_struct *async_qp;/* used by asynchronous notification */ Sg_request req_arr[SG_MAX_QUEUE ];/* used as singly-linked list */ -char low_dma;/* as in parent but possibly overridden to 1 */ char force_packid;/* 1 -> pack_id input to read(), 0 -> ignored */ volatile char closed;/* 1 -> fd closed but request(s) outstanding */ char cmd_q;/* 1 -> allow command queuing, 0 -> don't */
@@ -195,7 +194,7 @@ static void sg_remove_scat(Sg_scatter_hostatic void sg_build_reserve (Sg_fd * sfp,int req_size);static void sg_link_reserve (Sg_fd * sfp,Sg_request * srp,int size);static void sg_unlink_reserve (Sg_fd * sfp,Sg_request * srp); -static struct page *sg_page_malloc (int rqSz,int lowDma,int *retSzp); +static struct page *sg_page_malloc (int rqSz,int *retSzp);static void sg_page_free (struct page *page,int size);static Sg_fd *sg_add_sfp (Sg_device * sdp,int dev);static int sg_remove_sfp (Sg_device * sdp,Sg_fd * sfp);
@@ -844,8 +843,7 @@ sg_ioctl(struct inode *inode, struct filif (result)return result;if (val) { - sfp->low_dma =1 ; -if ((0 == sfp->low_dma) && (0 ==sg_res_in_use (sfp))) { +if (0 ==sg_res_in_use (sfp)) { val = (int ) sfp->reserve.bufflen;sg_remove_scat (&sfp->reserve);sg_build_reserve (sfp, val);
@@ -853,11 +851,10 @@ sg_ioctl(struct inode *inode, struct fil }else {if (sdp->detached)return -ENODEV ; - sfp->low_dma = sdp->device->host->unchecked_isa_dma; }return 0 ;case SG_GET_LOW_DMA : -return put_user ((int ) sfp->low_dma, ip); +return put_user (0 , ip);case SG_GET_SCSI_ID :if (!access_ok (VERIFY_WRITE , p,sizeof (sg_scsi_id_t)))return -EFAULT ;
@@ -1622,8 +1619,7 @@ sg_start_req(Sg_request * srp)if ((dxfer_len <=0 ) || (dxfer_dir ==SG_DXFER_NONE ))return 0 ;if (sg_allow_dio && (hp->flags &SG_FLAG_DIRECT_IO ) && - (dxfer_dir !=SG_DXFER_UNKNOWN ) && (0 == hp->iovec_count) && - (!sfp->parentdp->device->host->unchecked_isa_dma)) { + (dxfer_dir !=SG_DXFER_UNKNOWN ) && (0 == hp->iovec_count)) { res =sg_build_direct (srp, sfp, dxfer_len);if (res <=0 )/* -ve -> error, 0 -> done, 1 -> try indirect */ return res;
@@ -1660,14 +1656,6 @@ sg_build_sgat(Sg_scatter_hold * schp, coint sg_bufflen = tablesize *sizeof (struct scatterlist );gfp_t gfp_flags =GFP_ATOMIC | __GFP_NOWARN; -/* -* TODO: test without low_dma, we should not need it since -* the block layer will bounce the buffer for us -* -* XXX(hch): we shouldn't need GFP_DMA for the actual S/G list. -*/ -if (sfp->low_dma) - gfp_flags |=GFP_DMA ; schp->buffer =kzalloc (sg_bufflen, gfp_flags);if (!schp->buffer)return -ENOMEM ;
@@ -1860,7 +1848,7 @@ sg_build_indirect(Sg_scatter_hold * schp num = (rem_sz > scatter_elem_sz_prev) ? scatter_elem_sz_prev : rem_sz; - p =sg_page_malloc (num, sfp->low_dma, &ret_sz); + p =sg_page_malloc (num, &ret_sz);if (!p)return -ENOMEM ;
@@ -2345,8 +2333,6 @@ sg_add_sfp(Sg_device * sdp, int dev) sfp->timeout =SG_DEFAULT_TIMEOUT ; sfp->timeout_user =SG_DEFAULT_TIMEOUT_USER ; sfp->force_packid =SG_DEF_FORCE_PACK_ID ; - sfp->low_dma = (SG_DEF_FORCE_LOW_DMA ==0 ) ? - sdp->device->host->unchecked_isa_dma :1 ; sfp->cmd_q =SG_DEF_COMMAND_Q ; sfp->keep_orphan =SG_DEF_KEEP_ORPHAN ; sfp->parentdp = sdp;
@@ -2456,7 +2442,7 @@ sg_res_in_use(Sg_fd * sfp)/* The size fetched (value output via retSzp) set when non-NULL return */ static struct page * -sg_page_malloc (int rqSz,int lowDma,int *retSzp) +sg_page_malloc (int rqSz,int *retSzp) {struct page *resp =NULL ;gfp_t page_mask;
@@ -2466,10 +2452,7 @@ sg_page_malloc(int rqSz, int lowDma, intif ((rqSz <=0 ) || (NULL == retSzp))return resp; -if (lowDma) - page_mask =GFP_ATOMIC |GFP_DMA | __GFP_COMP | __GFP_NOWARN; -else - page_mask =GFP_ATOMIC | __GFP_COMP | __GFP_NOWARN; + page_mask =GFP_ATOMIC | __GFP_COMP | __GFP_NOWARN;for (order =0 , a_size =PAGE_SIZE ; a_size < rqSz; order++, a_size <<=1 ) ;
@@ -2869,11 +2852,10 @@ static void sg_proc_debug_helper(structfor (k =0 ; (fp =sg_get_nth_sfp (sdp, k)); ++k) {seq_printf (s," FD(%d): timeout=%dms bufflen=%d " -"(res)sgat=%d low_dma=%d\n" , k +1 , +"(res)sgat=%d\n" , k +1 ,jiffies_to_msecs (fp->timeout), fp->reserve.bufflen, - (int ) fp->reserve.k_use_sg, - (int ) fp->low_dma); + (int ) fp->reserve.k_use_sg);seq_printf (s," cmd_q=%d f_packid=%d k_orphan=%d closed=%d\n" , (int ) fp->cmd_q, (int ) fp->force_packid, (int ) fp->keep_orphan, (int ) fp->closed);
PATCH 12/22 Remove GFP_DMAs/unchecked_isa_dma checks in scsi_scan.c
In reply to Andi KleenShould not be needed because the block layer bounces that all.
--- drivers/scsi/scsi_scan.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/scsi_scan.c +2 -4
@@ -1010,8 +1010,7 @@ static int scsi_probe_and_add_lun(structif (!sdev) goto out; - result =kmalloc (result_len,GFP_ATOMIC | - ((shost->unchecked_isa_dma) ? __GFP_DMA :0 )); + result =kmalloc (result_len,GFP_ATOMIC );if (!result) goto out_free_sdev;
@@ -1328,8 +1327,7 @@ static int scsi_report_lun_scan(struct s* prevent us from finding any LUNs on this target. */ length = (max_scsi_report_luns +1 ) *sizeof (struct scsi_lun ); - lun_data =kmalloc (length,GFP_ATOMIC | - (sdev->host->unchecked_isa_dma ? __GFP_DMA :0 )); + lun_data =kmalloc (length,GFP_ATOMIC );if (!lun_data) {printk (ALLOC_FAILURE_MSG , __FUNCTION__); goto out;
James Bottomley
maintainerRe: [PATCH] [12/22] Remove GFP_DMAs/unchecked_isa_dma checks in scsi_scan.c
Quoted 23 lines · Andi Kleen
Should not be needed because the block layer bounces that all.
Signed-off-by Andi Kleen <[email protected]>--- drivers/scsi/scsi_scan.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)Index:
linux/drivers/scsi/scsi_scan.c
===================================================================drivers/scsi/scsi_scan.c +1
-2@@ -1010,8 +1010,7 @@ static int scsi_probe_and_add_lun(structif (!sdev) goto out; - result =kmalloc (result_len,GFP_ATOMIC | - ((shost->unchecked_isa_dma) ? __GFP_DMA :0 )); + result =kmalloc (result_len,GFP_ATOMIC );if (!result) goto out_free_sdev;
drivers/scsi/scsi_scan.c static int scsi_report_lun_scan(struct s · line 1333
Quoted 9 lines
drivers/scsi/scsi_scan.c +1
-2@@ -1328,8 +1327,7 @@ static int scsi_report_lun_scan(struct s* prevent us from finding any LUNs on this target. */ length = (max_scsi_report_luns +1 ) *sizeof (struct scsi_lun ); - lun_data =kmalloc (length,GFP_ATOMIC | - (sdev->host->unchecked_isa_dma ? __GFP_DMA :0 )); + lun_data =kmalloc (length,GFP_ATOMIC );if (!lun_data) {printk (ALLOC_FAILURE_MSG , __FUNCTION__); goto out;
Andi, this can't be right.
You're removing something that's actually useful. I'm happy to substitute this kmalloc for kmalloc_mask on the device dma mask which will do the same thing and so junk unchecked_isa_dma() that way (and actually fix us up for other weird mask devices), but just using ZONE_NORMAL is wrong because we'll then bounce all the time for something we knew a priori how to avoid.
James
Re: [PATCH] [12/22] Remove GFP_DMAs/unchecked_isa_dma checks in scsi_scan.c
Quoted 24 lines · James Bottomley
Quoted 22 lines · Andi Kleen
Should not be needed because the block layer bounces that all.
Signed-off-by Andi Kleen <[email protected]>--- drivers/scsi/scsi_scan.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)Index:
linux/drivers/scsi/scsi_scan.c
===================================================================drivers/scsi/scsi_scan.c +1
-2@@ -1010,8 +1010,7 @@ static int scsi_probe_and_add_lun(structif (!sdev) goto out; - result =kmalloc (result_len,GFP_ATOMIC | - ((shost->unchecked_isa_dma) ? __GFP_DMA :0 )); + result =kmalloc (result_len,GFP_ATOMIC );if (!result) goto out_free_sdev;
Quoted 12 lines
drivers/scsi/scsi_scan.c static int scsi_report_lun_scan(struct s · line 1333
Quoted 10 lines
drivers/scsi/scsi_scan.c +1
-2@@ -1328,8 +1327,7 @@ static int scsi_report_lun_scan(struct s* prevent us from finding any LUNs on this target. */ length = (max_scsi_report_luns +1 ) *sizeof (struct scsi_lun ); - lun_data =kmalloc (length,GFP_ATOMIC | - (sdev->host->unchecked_isa_dma ? __GFP_DMA :0 )); + lun_data =kmalloc (length,GFP_ATOMIC );if (!lun_data) {printk (ALLOC_FAILURE_MSG , __FUNCTION__); goto out;Andi, this can't be right.
You mean it is incorrect or just not optimal?
Quoted 7 lines
You're removing something that's actually useful. I'm happy to substitute this kmalloc for
kmalloc_maskon the device dma mask which will do the same thing and so junkunchecked_isa_dma()that way (and actually fix us up for other weird mask devices), but just usingZONE_NORMALis wrong because we'll then bounce all the time for something we knew a priori how to avoid.
That would require adding a separate mask just for this to the template. I figured the SCSI scan was not performance critical so a few more copies just for this case was an ok trade off for simpler code.
You think it makes sense to optimize scsi scan?
-Andi
James Bottomley
maintainerRe: [PATCH] [12/22] Remove GFP_DMAs/unchecked_isa_dma checks in scsi_scan.c
Quoted 38 lines · Andi Kleen
Quoted 24 lines · James Bottomley
Quoted 22 lines · Andi Kleen
Should not be needed because the block layer bounces that all.
Signed-off-by Andi Kleen <[email protected]>--- drivers/scsi/scsi_scan.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)Index:
linux/drivers/scsi/scsi_scan.c
===================================================================drivers/scsi/scsi_scan.c +1
-2@@ -1010,8 +1010,7 @@ static int scsi_probe_and_add_lun(structif (!sdev) goto out; - result =kmalloc (result_len,GFP_ATOMIC | - ((shost->unchecked_isa_dma) ? __GFP_DMA :0 )); + result =kmalloc (result_len,GFP_ATOMIC );if (!result) goto out_free_sdev;Quoted 12 lines
drivers/scsi/scsi_scan.c static int scsi_report_lun_scan(struct s · line 1333
Quoted 10 lines
drivers/scsi/scsi_scan.c +1
-2@@ -1328,8 +1327,7 @@ static int scsi_report_lun_scan(struct s* prevent us from finding any LUNs on this target. */ length = (max_scsi_report_luns +1 ) *sizeof (struct scsi_lun ); - lun_data =kmalloc (length,GFP_ATOMIC | - (sdev->host->unchecked_isa_dma ? __GFP_DMA :0 )); + lun_data =kmalloc (length,GFP_ATOMIC );if (!lun_data) {printk (ALLOC_FAILURE_MSG , __FUNCTION__); goto out;Andi, this can't be right.
Quoted 1 line
You mean it is incorrect or just not optimal?
It's not optimal ... but that's sufficient an objection.
Quoted 8 lines
Quoted 7 lines
You're removing something that's actually useful. I'm happy to substitute this kmalloc for
kmalloc_maskon the device dma mask which will do the same thing and so junkunchecked_isa_dma()that way (and actually fix us up for other weird mask devices), but just usingZONE_NORMALis wrong because we'll then bounce all the time for something we knew a priori how to avoid.
Quoted 4 lines
That would require adding a separate mask just for this to the template. I figured the SCSI scan was not performance critical so a few more copies just for this case was an ok trade off for simpler code.
Why? We already have the device; can't we just use its mask?
Quoted 1 line
You think it makes sense to optimize scsi scan?
It makes sense to use information we already know to optimise the path, yes, when it's something as simple as keeping the dma buffer within the mask bounds of the device.
James
Re: [PATCH] [12/22] Remove GFP_DMAs/unchecked_isa_dma checks in scsi_scan.c
Quoted 51 lines · James Bottomley
Quoted 38 lines · Andi Kleen
Quoted 24 lines · James Bottomley
Quoted 22 lines · Andi Kleen
Should not be needed because the block layer bounces that all.
Signed-off-by Andi Kleen <[email protected]>--- drivers/scsi/scsi_scan.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)Index:
linux/drivers/scsi/scsi_scan.c
===================================================================drivers/scsi/scsi_scan.c +1
-2@@ -1010,8 +1010,7 @@ static int scsi_probe_and_add_lun(structif (!sdev) goto out; - result =kmalloc (result_len,GFP_ATOMIC | - ((shost->unchecked_isa_dma) ? __GFP_DMA :0 )); + result =kmalloc (result_len,GFP_ATOMIC );if (!result) goto out_free_sdev;Quoted 12 lines
drivers/scsi/scsi_scan.c static int scsi_report_lun_scan(struct s · line 1333
Quoted 10 lines
drivers/scsi/scsi_scan.c +1
-2@@ -1328,8 +1327,7 @@ static int scsi_report_lun_scan(struct s* prevent us from finding any LUNs on this target. */ length = (max_scsi_report_luns +1 ) *sizeof (struct scsi_lun ); - lun_data =kmalloc (length,GFP_ATOMIC | - (sdev->host->unchecked_isa_dma ? __GFP_DMA :0 )); + lun_data =kmalloc (length,GFP_ATOMIC );if (!lun_data) {printk (ALLOC_FAILURE_MSG , __FUNCTION__); goto out;Andi, this can't be right.
Quoted 1 line
You mean it is incorrect or just not optimal?
It's not optimal ... but that's sufficient an objection.
Quoted 8 lines
Quoted 7 lines
You're removing something that's actually useful. I'm happy to substitute this kmalloc for
kmalloc_maskon the device dma mask which will do the same thing and so junkunchecked_isa_dma()that way (and actually fix us up for other weird mask devices), but just usingZONE_NORMALis wrong because we'll then bounce all the time for something we knew a priori how to avoid.
Quoted 6 lines
Quoted 4 lines
That would require adding a separate mask just for this to the template. I figured the SCSI scan was not performance critical so a few more copies just for this case was an ok trade off for simpler code.
Why? We already have the device; can't we just use its mask?
These ISA drivers I worked with definitely don't know anything about a device in any form.
Also there is the issue that 50+% of the ISA drivers actually don't need it even if they had a ISA device.
Quoted 4 lines
Quoted 2 lines
You think it makes sense to optimize scsi scan?
It makes sense to use information we already know to optimise the path,
In this case we would need to add a special new field for this to the SCSI template (assume unchecked_isa_dma is already gone). You think that is worth it?
-Andi
James Bottomley
maintainerRe: [PATCH] [12/22] Remove GFP_DMAs/unchecked_isa_dma checks in scsi_scan.c
Quoted 66 lines · Andi Kleen
Quoted 51 lines · James Bottomley
Quoted 38 lines · Andi Kleen
Quoted 24 lines · James Bottomley
Quoted 22 lines · Andi Kleen
Should not be needed because the block layer bounces that all.
Signed-off-by Andi Kleen <[email protected]>--- drivers/scsi/scsi_scan.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)Index:
linux/drivers/scsi/scsi_scan.c
===================================================================drivers/scsi/scsi_scan.c +1
-2@@ -1010,8 +1010,7 @@ static int scsi_probe_and_add_lun(structif (!sdev) goto out; - result =kmalloc (result_len,GFP_ATOMIC | - ((shost->unchecked_isa_dma) ? __GFP_DMA :0 )); + result =kmalloc (result_len,GFP_ATOMIC );if (!result) goto out_free_sdev;Quoted 12 lines
drivers/scsi/scsi_scan.c static int scsi_report_lun_scan(struct s · line 1333
Quoted 10 lines
drivers/scsi/scsi_scan.c +1
-2@@ -1328,8 +1327,7 @@ static int scsi_report_lun_scan(struct s* prevent us from finding any LUNs on this target. */ length = (max_scsi_report_luns +1 ) *sizeof (struct scsi_lun ); - lun_data =kmalloc (length,GFP_ATOMIC | - (sdev->host->unchecked_isa_dma ? __GFP_DMA :0 )); + lun_data =kmalloc (length,GFP_ATOMIC );if (!lun_data) {printk (ALLOC_FAILURE_MSG , __FUNCTION__); goto out;Andi, this can't be right.
Quoted 1 line
You mean it is incorrect or just not optimal?
It's not optimal ... but that's sufficient an objection.
Quoted 8 lines
Quoted 7 lines
You're removing something that's actually useful. I'm happy to substitute this kmalloc for
kmalloc_maskon the device dma mask which will do the same thing and so junkunchecked_isa_dma()that way (and actually fix us up for other weird mask devices), but just usingZONE_NORMALis wrong because we'll then bounce all the time for something we knew a priori how to avoid.Quoted 6 lines
Quoted 4 lines
That would require adding a separate mask just for this to the template. I figured the SCSI scan was not performance critical so a few more copies just for this case was an ok trade off for simpler code.
Why? We already have the device; can't we just use its mask?
These ISA drivers I worked with definitely don't know anything about a device in any form.
Also there is the issue that 50+% of the ISA drivers actually don't need it even if they had a ISA device.
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
You think it makes sense to optimize scsi scan?
It makes sense to use information we already know to optimise the path,
In this case we would need to add a special new field for this to the SCSI template (assume
unchecked_isa_dmais already gone). You think that is worth it?
You've already added a new special field with your u64 sense_buffer_mask;
It's a special case field for ISA devices because everything else has a dev->dma_mask you can use.
So, in fact, you're removing my single bit isa_unchecked_dma flag and using 64 bits in its place that preserves essentially the same information. It just doesn't look like a bargain to me. Particularly as you're removing a lot of the memory allocation optimisation paths at the same time.
Don't get me wrong; I'm all for removing the special casing of isa devices we have to do, of which isa_unchecked_dma is the switch ... I just want to do it properly, and that would have to be by bringing isa devices under the device model, so we don't have to special case them.
There is a proposal that's been under consideration for a while because it might solve other issues ATA has with mdma (they need to use different DMA masks for different devices on the same host). The proposal was to use the struct device in the struct scsi_device as the device for the dma_ API ... this has all the properties you need ... you can give it a DMA_24BIT_MASK for isa devices, and use it to key the allocations off, since it's always present ... then we can junk isa_unchecked_dma and not add any other strange flags.
James
Re: [PATCH] [12/22] Remove GFP_DMAs/unchecked_isa_dma checks in scsi_scan.c
Quoted 2 lines
You've already added a new special field with your u64
sense_buffer_mask;
Ok I'll add another one for this case so that you can still have zero copy SCSI scan. Or maybe it can check the block layer bounce information directly here.
Quoted 2 lines
It's a special case field for ISA devices because everything else has a
dev->dma_maskyou can use.
I'm not sure that trying to use ->dma_mask for this is all that useful. The issue is that a lot of drivers do not actually DMA specific areas because either they don't care about the data or the data is passed in some other implicit way.
Trying to lump it all together into a single mask would be a mistake I think.
Quoted 5 lines
So, in fact, you're removing my single bit
isa_unchecked_dmaflag and using 64 bits in its place that preserves essentially the same information. It just doesn't look like a bargain to me. Particularly as you're removing a lot of the memory allocation optimisation paths at the same time.
Essentially it removes an ISA specific optimization and makes ISA work like all other IO without IOMMU.
Quoted 2 lines
There is a proposal that's been under consideration for a while because it might solve other issues ATA has with mdma (they need to use
... that'll have to be done by someone else.
-Andi
PATCH 13/22 Don't disable direct_io for unchecked_isa_dma in st.c
In reply to Andi KleenBlock layer bounces anyways.
--- drivers/scsi/st.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/st.c +1 -1
@@ -3993,7 +3993,7 @@ static int st_probe(struct device *dev) tpnt->nbr_partitions =0 ; tpnt->device->timeout =ST_TIMEOUT ; tpnt->long_timeout =ST_LONG_TIMEOUT ; - tpnt->try_dio = try_direct_io && !SDp->host->unchecked_isa_dma; + tpnt->try_dio = try_direct_io;for (i =0 ; i <ST_NBR_MODES ; i++) { STm = &(tpnt->modes[i]);
PATCH 14/22 Remove automatic block layer bouncing for unchecked_isa_dma
In reply to Andi KleenAll ISA drivers explicitely tell the block layer now that it needs to bounce for them, so SCSI mid layer doesn't need to do that automatically for unchecked_isa_dma anymore.
--- drivers/scsi/scsi_lib.c | 2 -- 1 file changed, 2 deletions(-)
drivers/scsi/scsi_lib.c +0 -2
@@ -1547,8 +1547,6 @@ u64 scsi_calculate_bounce_limit(struct Sstruct device *host_dev;u64 bounce_limit =0xffffffff ; -if (shost->unchecked_isa_dma) -return BLK_BOUNCE_ISA ;/* * Platforms with virtual-DMA translation * hardware have no practical limit.
PATCH 15/22 Remove GFP_DMA use in sr_ioctl
In reply to Andi KleenEverything should be bounced by the block layer now
--- drivers/scsi/sr_ioctl.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/scsi/sr_ioctl.c +4 -9
@@ -30,11 +30,6 @@ static int xa_test = 0;module_param (xa_test, int,S_IRUGO |S_IWUSR ); -/* primitive to determine whether we need to have GFP_DMA set based on -* the status of the unchecked_isa_dma flag in the host structure */ -#define SR_GFP_DMA (cd) (((cd)->device->host->unchecked_isa_dma) ? GFP_DMA : 0) - -static int sr_read_tochdr (struct cdrom_device_info *cdi,struct cdrom_tochdr *tochdr) {
@@ -43,7 +38,7 @@ static int sr_read_tochdr(struct cdrom_dint result;unsigned char *buffer; - buffer =kmalloc (32 ,GFP_KERNEL |SR_GFP_DMA (cd)); + buffer =kmalloc (32 ,GFP_KERNEL );if (!buffer)return -ENOMEM ;
@@ -73,7 +68,7 @@ static int sr_read_tocentry(struct cdromint result;unsigned char *buffer; - buffer =kmalloc (32 ,GFP_KERNEL |SR_GFP_DMA (cd)); + buffer =kmalloc (32 ,GFP_KERNEL );if (!buffer)return -ENOMEM ;
@@ -385,7 +380,7 @@ int sr_get_mcn(struct cdrom_device_info {Scsi_CD *cd = cdi->handle;struct packet_command cgc; -char *buffer =kmalloc (32 ,GFP_KERNEL |SR_GFP_DMA (cd)); +char *buffer =kmalloc (32 ,GFP_KERNEL );int result;if (!buffer)
@@ -564,7 +559,7 @@ int sr_is_xa(Scsi_CD *cd)if (!xa_test)return 0 ; - raw_sector =kmalloc (2048 ,GFP_KERNEL |SR_GFP_DMA (cd)); + raw_sector =kmalloc (2048 ,GFP_KERNEL );if (!raw_sector)return -ENOMEM ; if (0 == sr_read_sector(cd, cd->ms_offset + 16,
PATCH 16/22 Remove unchecked_isa_dma from sysfs
In reply to Andi KleenI opted to remove it because it's unlikely that user space uses it.
An alternative would be to always make it report 0 now.
--- drivers/scsi/scsi_sysfs.c | 2 -- 1 file changed, 2 deletions(-)
drivers/scsi/scsi_sysfs.c +0 -2
@@ -237,7 +237,6 @@ shost_rd_attr(host_busy, "%hu\n");shost_rd_attr (cmd_per_lun,"%hd\n" );shost_rd_attr (can_queue,"%hd\n" );shost_rd_attr (sg_tablesize,"%hu\n" ); -shost_rd_attr (unchecked_isa_dma,"%d\n" );shost_rd_attr2 (proc_name, hostt->proc_name,"%s\n" );static struct class_device_attribute *scsi_sysfs_shost_attrs[] = {
@@ -246,7 +245,6 @@ static struct class_device_attribute *sc &class_device_attr_cmd_per_lun, &class_device_attr_can_queue, &class_device_attr_sg_tablesize, - &class_device_attr_unchecked_isa_dma, &class_device_attr_proc_name, &class_device_attr_scan, &class_device_attr_state,
PATCH 17/22 Switch to a single SCSI command pool
In reply to Andi KleenNow that no low level driver relies on ISA DMAable scsi_cmnds anymore it is safe to always use the same static slab for them.
--- drivers/scsi/scsi.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-)
drivers/scsi/scsi.c +24 -23
@@ -140,24 +140,22 @@ const char * scsi_device_type(unsigned tEXPORT_SYMBOL (scsi_device_type); +static struct kmem_cache *scsi_cmd_slab; +struct scsi_host_cmd_pool { -struct kmem_cache *cmd_slab;struct kmem_cache *sense_slab;unsigned int users; -char *cmd_name;char *sense_name;unsigned int slab_flags;gfp_t gfp_mask; };static struct scsi_host_cmd_pool scsi_cmd_pool = { - .cmd_name ="scsi_cmd_cache" , .sense_name ="scsi_sense_cache" , .slab_flags =SLAB_HWCACHE_ALIGN , };static struct scsi_host_cmd_pool scsi_cmd_dma_pool = { - .cmd_name ="scsi_cmd_cache(DMA)" , .sense_name ="scsi_sense_cache(DMA)" , .slab_flags =SLAB_HWCACHE_ALIGN |SLAB_CACHE_DMA , .gfp_mask = __GFP_DMA,
@@ -178,10 +176,8 @@ struct scsi_cmnd *__scsi_get_command(strstruct scsi_cmnd *cmd;unsigned char *buf; - cmd =kmem_cache_alloc (shost->cmd_pool->cmd_slab, - gfp_mask | shost->cmd_pool->gfp_mask); - -if (unlikely (!cmd)) { + cmd =kmem_cache_alloc (scsi_cmd_slab, gfp_mask); +if (!cmd) {unsigned long flags;spin_lock_irqsave (&shost->free_list_lock, flags);
@@ -204,7 +200,7 @@ struct scsi_cmnd *__scsi_get_command(strmemset (cmd,0 ,sizeof (*cmd)); cmd->sense_buffer = buf; }else { -kmem_cache_free (shost->cmd_pool->cmd_slab, cmd); +kmem_cache_free (scsi_cmd_slab, cmd); cmd =NULL ; } }
@@ -269,7 +265,7 @@ void __scsi_put_command(struct Scsi_Hostif (likely (cmd !=NULL )) {kmem_cache_free (shost->cmd_pool->sense_slab, cmd->sense_buffer); -kmem_cache_free (shost->cmd_pool->cmd_slab, cmd); +kmem_cache_free (scsi_cmd_slab, cmd); }put_device (dev);
@@ -331,20 +327,24 @@ int scsi_setup_command_freelist(struct S* yet existent. */ mutex_lock (&host_cmd_pool_mutex); + +if (!scsi_cmd_slab) { + scsi_cmd_slab =kmem_cache_create ("scsi_cmd_cache" , +sizeof (struct scsi_cmnd ),0 , +SLAB_HWCACHE_ALIGN ,NULL ); +if (!scsi_cmd_slab) + goto fail; + } + pool = (shost->unchecked_isa_dma ||sense_buffer_isa (shost)) ? &scsi_cmd_dma_pool : &scsi_cmd_pool;if (!pool->users) { - pool->cmd_slab =kmem_cache_create (pool->cmd_name, -sizeof (struct scsi_cmnd ),0 , - pool->slab_flags,NULL ); -if (!pool->cmd_slab) - goto fail; - pool->sense_slab =kmem_cache_create (pool->sense_name,SCSI_SENSE_BUFFERSIZE ,0 , pool->slab_flags,NULL );if (!pool->sense_slab) { -kmem_cache_destroy (pool->cmd_slab); +kmem_cache_destroy (scsi_cmd_slab); + scsi_cmd_slab =NULL ; goto fail; } }
@@ -356,8 +356,7 @@ int scsi_setup_command_freelist(struct S/* * Get one backup command for this host. */ - cmd =kmem_cache_alloc (shost->cmd_pool->cmd_slab, -GFP_KERNEL | shost->cmd_pool->gfp_mask); + cmd =kmem_cache_alloc (scsi_cmd_slab,GFP_KERNEL );if (!cmd) goto fail2;
@@ -372,10 +371,11 @@ int scsi_setup_command_freelist(struct S fail2:if (cmd) -kmem_cache_free (shost->cmd_pool->cmd_slab, cmd); +kmem_cache_free (scsi_cmd_slab, cmd);mutex_lock (&host_cmd_pool_mutex);if (!--pool->users) { -kmem_cache_destroy (pool->cmd_slab); +kmem_cache_destroy (scsi_cmd_slab); + scsi_cmd_slab =NULL ;kmem_cache_destroy (pool->sense_slab); } fail:
@@ -396,12 +396,13 @@ void scsi_destroy_command_freelist(struclist_del_init (&cmd->list);kmem_cache_free (shost->cmd_pool->sense_slab, cmd->sense_buffer); -kmem_cache_free (shost->cmd_pool->cmd_slab, cmd); +kmem_cache_free (scsi_cmd_slab, cmd); }mutex_lock (&host_cmd_pool_mutex);if (!--shost->cmd_pool->users) { -kmem_cache_destroy (shost->cmd_pool->cmd_slab); +kmem_cache_destroy (scsi_cmd_slab); + scsi_cmd_slab =NULL ;kmem_cache_destroy (shost->cmd_pool->sense_slab); }mutex_unlock (&host_cmd_pool_mutex);
PATCH 18/22 Finally remove unchecked_isa_dma support for Cmnds
In reply to Andi KleenNo drivers need it anymore
--- drivers/scsi/scsi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/scsi.c +1 -2
@@ -337,8 +337,7 @@ int scsi_setup_command_freelist(struct S goto fail; } - pool = (shost->unchecked_isa_dma ||sense_buffer_isa (shost)) ? - &scsi_cmd_dma_pool : &scsi_cmd_pool; + pool =sense_buffer_isa (shost) ? &scsi_cmd_dma_pool : &scsi_cmd_pool;if (!pool->users) { pool->sense_slab = kmem_cache_create(pool->sense_name, SCSI_SENSE_BUFFERSIZE, 0,
PATCH 19/22 Finally kill unchecked_isa_dma
In reply to Andi KleenNow that all users are gone it can be safely completely removed.
--- Documentation/scsi/scsi_mid_low_api.txt | 3 --- drivers/scsi/hosts.c | 1 - include/scsi/scsi_host.h | 6 ------ 3 files changed, 10 deletions(-)
Documentation/scsi/scsi_mid_low_api.txt +0 -3
@@ -1254,9 +1254,6 @@ of interest: cmd_per_lun - maximum number of commands that can be queued on devices controlled by the host. Overridden by LLD calls to scsi_adjust_queue_depth(). - unchecked_isa_dma - 1=>only use bottom 16 MB of ram (ISA DMA addressing - restriction), 0=>can use full 32 bit (or better) DMA - address space use_clustering - 1=>SCSI commands in mid level's queue can be merged, 0=>disallow SCSI command merging hostt - pointer to driver's struct scsi_host_template from which
drivers/scsi/hosts.c +0 -1
@@ -335,7 +335,6 @@ struct Scsi_Host *scsi_host_alloc(struct shost->can_queue = sht->can_queue; shost->sg_tablesize = sht->sg_tablesize; shost->cmd_per_lun = sht->cmd_per_lun; - shost->unchecked_isa_dma = sht->unchecked_isa_dma; shost->use_clustering = sht->use_clustering; shost->ordered_tag = sht->ordered_tag; shost->active_mode = sht->supported_mode;
include/scsi/scsi_host.h +0 -6
@@ -423,11 +423,6 @@ struct scsi_host_template { unsigned supported_mode:2;/* -* True if this host adapter uses unchecked DMA onto an ISA bus. -*/ - unsigned unchecked_isa_dma:1; - -/* * True if this host adapter can make good use of clustering. * I originally thought that if the tablesize was large that it * was a waste of CPU cycles to prepare a cluster list, but
@@ -601,7 +596,6 @@ struct Scsi_Host {unsigned long cmd_serial_number; unsigned active_mode:2; - unsigned unchecked_isa_dma:1; unsigned use_clustering:1; unsigned use_blk_tcq:1;
PATCH 20/22 Remove GFP_DMA in sr.c
In reply to Andi KleenAll buffers are bounced by the block layer
drivers/scsi/sr.c +2 -2
@@ -674,7 +674,7 @@ static void get_sectorsize(struct scsi_cint sector_size;struct request_queue *queue; - buffer =kmalloc (512 ,GFP_KERNEL |GFP_DMA ); + buffer =kmalloc (512 ,GFP_KERNEL );if (!buffer) goto Enomem;
@@ -772,7 +772,7 @@ static void get_capabilities(struct scsi/* allocate transfer buffer */ - buffer =kmalloc (512 ,GFP_KERNEL |GFP_DMA ); + buffer =kmalloc (512 ,GFP_KERNEL );if (!buffer) {printk (KERN_ERR "sr: out of memory.\n" );return ;
PATCH 21/22 Remove GFP_DMA in ch.c
In reply to Andi KleenAll buffers are bounced by the block layer
drivers/scsi/ch.c +3 -3
@@ -231,7 +231,7 @@ ch_read_element_status(scsi_changer *ch,u_char *buffer;int result; - buffer =kmalloc (512 ,GFP_KERNEL |GFP_DMA ); + buffer =kmalloc (512 ,GFP_KERNEL );if (!buffer)return -ENOMEM ;
@@ -288,7 +288,7 @@ ch_readconfig(scsi_changer *ch)int result,id,lun,i;u_int elem; - buffer =kzalloc (512 ,GFP_KERNEL |GFP_DMA ); + buffer =kzalloc (512 ,GFP_KERNEL );if (!buffer)return -ENOMEM ;
@@ -733,7 +733,7 @@ static long ch_ioctl(struct file *file,return -EINVAL ; elem = ch->firsts[cge.cge_type] + cge.cge_unit; - buffer =kmalloc (512 ,GFP_KERNEL |GFP_DMA ); + buffer =kmalloc (512 ,GFP_KERNEL );if (!buffer)return -ENOMEM ;mutex_lock (&ch->lock);
PATCH 22/22 Remove GFP_DMA in sr_vendor.c
In reply to Andi KleenBounced by the block layer anyways
drivers/scsi/sr_vendor.c +2 -2
@@ -117,7 +117,7 @@ int sr_set_blocklength(Scsi_CD *cd, int density = (blocklength >2048 ) ?0x81 :0x83 ;#endif - buffer =kmalloc (512 ,GFP_KERNEL |GFP_DMA ); + buffer =kmalloc (512 ,GFP_KERNEL );if (!buffer)return -ENOMEM ;
@@ -164,7 +164,7 @@ int sr_cd_check(struct cdrom_device_infoif (cd->cdi.mask &CDC_MULTI_SESSION )return 0 ; - buffer =kmalloc (512 ,GFP_KERNEL |GFP_DMA ); + buffer =kmalloc (512 ,GFP_KERNEL );if (!buffer)return -ENOMEM ;