[Bug 10050] message/fusion/mptbase.c: fix use-after-free's
http://bugzilla.kernel.org/show_bug.cgi?id=10050 [EMAIL PROTECTED] changed: What|Removed |Added Status|NEW |CLOSED Resolution||CODE_FIX --- Comment #1 from [EMAIL PROTECTED] 2008-02-24 23:57 --- Fixed by commit ad008d42bcec99911b3270a8349f8ec8405a1c4e. -- Configure bugmail: http://bugzilla.kernel.org/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are the assignee for the bug, or are watching the assignee. - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: Aborted commands with arcmsr and 2xWD1500ADFD in RAID1
Hi Aron, >From our field experiences and customers' feedbacks, all of them direct to vibration and power issues. The vibration could be caused by FANs not only by themselves. You mentioned it could be the F/W issue. If the environment does not meet the prerequisite, FW could not work correctly. Actually FW just reacts to the situations not it causes the issue. Please check it out!! Thank you, -Original Message- From: Aron Stansvik [mailto:[EMAIL PROTECTED] Sent: Sunday, February 24, 2008 1:54 AM To: [EMAIL PROTECTED] Cc: erich; [EMAIL PROTECTED]; linux-scsi@vger.kernel.org; [EMAIL PROTECTED] Subject: Re: Aborted commands with arcmsr and 2xWD1500ADFD in RAID1 Hello again Areca and LKML hackers. 2008/2/18, Aron Stansvik <[EMAIL PROTECTED]>: > Hello Nick. > > Sorry that I'm not answering until now. I've been busy. > > 2008/2/13, nickcheng <[EMAIL PROTECTED]>: > > > Hi Aron, > > From our experience and some customers' feedback, your issue could be caused > > by power instability or vibration to your HDs. > > Please check step by step: > > (1).under your original environment, increase the SCSI command value, > > default=30, with the shell script, set_scsicmd_timeout(). 90 or 120 is > > enough. > > (2).if method 1 does not work, find out the vibration source or change the > > power supply > > > I will try to increase that value. I don't think it's vibration; the > disks are firmly in place in a very heavy chassi (Silverstone > SST-TJ05B-T). And I really don't think there's something wrong with > the power supply, it's a pretty new Silverstone ST65ZF 650W. This is > my own personal workstation, so I don't just have another power supply > to test with :/ > > I will report back on my success/failure. Thanks for your answer. I've now tried with both 90 and 120 for the timeout value, and the problem still persists. It seems to happen when lots of small writes are occuring, e.g. when installing something. I really don't think the disks are vibrating, I don't see how they could. One more thing I'm going to test is to use the legacy ATA power connector instead of the SATA power connector. This was what I was using before when I only had a single drive and no RAID controller. Maybe my power supply is malfunctioning and not giving enough power on the SATA power connectors.. but I doubt it. Is there anything else that could cause this? Have you guys at Areca tested the ARC-1200 with Raptors in RAID1? :( Regards, Aron > > > Aron > > > > If your still have any questions, please feel free to let me know. > > > > P.S. The attached driver source, arcmsr-1.20.00.15-71224, has been > > upstreamed to kernel.org and will be released in kernel 2.6.25. If you like, > > you could update your driver with it. > > It fixes some minor bugs, but these bugs are nothing to do with your issue. > > > > > > -Original Message- > > From: erich [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, February 13, 2008 4:33 PM > > To: (廣安科技)鄭守謙 > > Subject: Fw: Aborted commands with arcmsr and 2xWD1500ADFD in RAID1 > > > > > > > > - Original Message - > > From: "Andrew Morton" <[EMAIL PROTECTED]> > > To: "Aron Stansvik" <[EMAIL PROTECTED]> > > Cc: <[EMAIL PROTECTED]>; ; "erich" > > <[EMAIL PROTECTED]> > > Sent: Wednesday, February 13, 2008 4:03 PM > > Subject: Re: Aborted commands with arcmsr and 2xWD1500ADFD in RAID1 > > > > > > > > > > (cc's added) > > > > > > On Mon, 11 Feb 2008 17:44:08 +0100 "Aron Stansvik" <[EMAIL PROTECTED]> > > > wrote: > > > > > >> Hello LKML. > > >> > > >> Under semi-high disk I/O (e.g. installing a compiled KDE), I get the > > >> following (accompanied by seconds of lock-ups on the machine): > > >> > > >> [ 7727.345183] arcmsr0: abort device command of scsi id = 0 lun = 0 > > >> [ 7730.348776] arcmsr0: scsi id = 0 lun = 0 ccb = > > >> '0xdfb461c0' poll command abort successfully > > >> [ 8053.795943] arcmsr0: abort device command of scsi id = 0 lun = 0 > > >> [ 8056.799528] arcmsr0: scsi id = 0 lun = 0 ccb = > > >> '0xdfb595e0' poll command abort successfully > > >> [ 8884.592810] arcmsr0: abort device command of scsi id = 0 lun = 0 > > >> [ 8887.596392] arcmsr0: scsi id = 0 lun = 0 ccb = > > >> '0xdfb56d80' poll command abort successfully > > >> [ 8917.760216] arcmsr0: abort device command of scsi id = 0 lun = 0 > > >> [ 8920.763797] arcmsr0: scsi id = 0 lun = 0 ccb = > > >> '0xdfb472c0' poll command abort successfully > > >> [ 9074.106547] arcmsr0: abort device command of scsi id = 0 lun = 0 > > >> > > >> This is my setup: > > >> > > >> 1 x MSI K8N Master2-FAR > > >> 1 x Opteron 252 > > >> 1 x Areca ARC1200 (sitting in a PCIe x4 socket) > > >> 2 x WD1500ADFD in RAID1 > > >> > > >> [EMAIL PROTECTED]:~$ uname -a > > >> Linux rubik 2.6.24-7-generic #1 SMP Thu Feb 7 01:29:58 UTC 2008 i686 > > >> GNU/Li
Re: arcmsr & areca-1660 - strange behaviour under heavy load
On Sat, 23 Feb 2008 12:20:12 +0100 (CET) Nikola Ciprich <[EMAIL PROTECTED]> wrote: > Hi, > > I've found strange problem either in arcmsr driver, or maybe in > areca-1660 card... > When system on SAS discs RAID connected to areca-1660 card > gets under heavy I/O load, it gets unusable after some time. I can 100% > reproduce > this, although it needs quite speciffic conditions: > It can be reproduced on 2x quad core machine, RAM has to be limited to > ~192MB to cause heavy paging. > Only thing needed to cause the problem is to start loop doing kernel > compilation using make -j 8 - this loads the system heavily, because of > lack of memory. After few correct compile runs the system gets into > state when all programs including the basic ones (ls, cp, ..) start > crashing... dmesg (when it works) doesn't say anything strange... > After reboot, the system is OK again. > I have tested it on different motherboards, with different CPUs, RAMs(all > were properly tested with memtest), with two different areca cards and > different drives. I can't reproduce the problem on same hardware when > using different RAID card (ie adaptec). All testing systems were properly > cooled.. > I have tried all available areca firmwares, two different distributions > (oracle linux, and centos), and kernels ranging from distribution ones, to > last GIT snapshot. > Could somebody please give me some hints on how to hunt this problem? > Areca support doesn't seem to be very interested in the problem :-( (cc's added) Please get the machine into this state of memory exhaustion then take copies of the output of the following, and send them via reply-to-all to this email: - cat /proc/meminfo - cat /proc/slabinfo - dmesg -c > /dev/null ; echo m > /proc/sysrq-trigger ; dmesg -c Thanks. - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] [0/22] 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 - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] [3/22] Remove unchecked_isa_dma in advansys.c
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_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 Signed-off-by: Andi Kleen <[EMAIL PROTECTED]> --- drivers/scsi/advansys.c | 216 +--- 1 file changed, 151 insertions(+), 65 deletions(-) Index: linux/drivers/scsi/advansys.c === --- linux.orig/drivers/scsi/advansys.c +++ linux/drivers/scsi/advansys.c @@ -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 Scs printk(" 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(struct static 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(s
[PATCH] [17/22] Switch to a single SCSI command pool
Now that no low level driver relies on ISA DMAable scsi_cmnds anymore it is safe to always use the same static slab for them. Signed-off-by: Andi Kleen <[EMAIL PROTECTED]> --- drivers/scsi/scsi.c | 46 +++--- 1 file changed, 23 insertions(+), 23 deletions(-) Index: linux/drivers/scsi/scsi.c === --- linux.orig/drivers/scsi/scsi.c +++ linux/drivers/scsi/scsi.c @@ -140,24 +140,22 @@ const char * scsi_device_type(unsigned t EXPORT_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 intusers; - char*cmd_name; char*sense_name; unsigned intslab_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(str struct 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(str memset(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_Host if (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(struc list
[PATCH] [16/22] Remove unchecked_isa_dma from sysfs
I opted to remove it because it's unlikely that user space uses it. An alternative would be to always make it report 0 now. Signed-off-by: Andi Kleen <[EMAIL PROTECTED]> --- drivers/scsi/scsi_sysfs.c |2 -- 1 file changed, 2 deletions(-) Index: linux/drivers/scsi/scsi_sysfs.c === --- linux.orig/drivers/scsi/scsi_sysfs.c +++ linux/drivers/scsi/scsi_sysfs.c @@ -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, - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] [15/22] Remove GFP_DMA use in sr_ioctl
Everything should be bounced by the block layer now Signed-off-by: Andi Kleen <[EMAIL PROTECTED]> --- drivers/scsi/sr_ioctl.c | 13 - 1 file changed, 4 insertions(+), 9 deletions(-) Index: linux/drivers/scsi/sr_ioctl.c === --- linux.orig/drivers/scsi/sr_ioctl.c +++ linux/drivers/scsi/sr_ioctl.c @@ -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_d int 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 cdrom int 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, - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] Don't use unnecessary GFP_ATOMIC in sg.c
Don't use unnecessary GFP_ATOMIC in sg.c sg.c uses GFP_ATOMIC for a lot of allocations where it isn't necessary. There are no locks hold and I don't see any other reasons why GFP_ATOMIC should be needed here. So remove them for more reliable allocations. Depends on the earlier GFP_DMA patchkit, but only because it happens to patch the same places (no real functional dependency) Tested by burning a CD on a kernel with all lock/sleep/etc. debugging enabled. Signed-off-by: Andi Kleen <[EMAIL PROTECTED]> --- drivers/scsi/sg.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) Index: linux/drivers/scsi/sg.c === --- linux.orig/drivers/scsi/sg.c +++ linux/drivers/scsi/sg.c @@ -745,7 +745,7 @@ sg_common_write(Sg_fd * sfp, Sg_request if (scsi_execute_async(sdp->device, cmnd, hp->cmd_len, data_dir, srp->data.buffer, hp->dxfer_len, srp->data.k_use_sg, timeout, SG_DEFAULT_RETRIES, srp, sg_cmd_done, - GFP_ATOMIC)) { + 0)) { SCSI_LOG_TIMEOUT(1, printk("sg_common_write: scsi_execute_async failed\n")); /* * most likely out of mem, but could also be a bad map @@ -1654,7 +1654,7 @@ static int sg_build_sgat(Sg_scatter_hold * schp, const Sg_fd * sfp, int tablesize) { int sg_bufflen = tablesize * sizeof(struct scatterlist); - gfp_t gfp_flags = GFP_ATOMIC | __GFP_NOWARN; + gfp_t gfp_flags = __GFP_NOWARN; schp->buffer = kzalloc(sg_bufflen, gfp_flags); if (!schp->buffer) @@ -1694,7 +1694,7 @@ st_map_user_pages(struct scatterlist *sg if (count == 0) return 0; - if ((pages = kmalloc(max_pages * sizeof(*pages), GFP_ATOMIC)) == NULL) + if ((pages = kmalloc(max_pages * sizeof(*pages), 0)) == NULL) return -ENOMEM; /* Try to fault in all of the necessary pages */ @@ -2323,7 +2323,7 @@ sg_add_sfp(Sg_device * sdp, int dev) unsigned long iflags; int bufflen; - sfp = kzalloc(sizeof(*sfp), GFP_ATOMIC | __GFP_NOWARN); + sfp = kzalloc(sizeof(*sfp), GFP_KERNEL|__GFP_NOWARN); if (!sfp) return NULL; @@ -2452,7 +2452,7 @@ sg_page_malloc(int rqSz, int *retSzp) if ((rqSz <= 0) || (NULL == retSzp)) return resp; - page_mask = GFP_ATOMIC | __GFP_COMP | __GFP_NOWARN; + page_mask = __GFP_COMP | __GFP_NOWARN; for (order = 0, a_size = PAGE_SIZE; a_size < rqSz; order++, a_size <<= 1) ; - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] [11/22] Remove unchecked_isa_dma checks in sg.c
They are only used to allocate data buffers, and those are bounced by the block layer anyways. Signed-off-by: Andi Kleen <[EMAIL PROTECTED]> --- drivers/scsi/sg.c | 36 +--- 1 file changed, 9 insertions(+), 27 deletions(-) Index: linux/drivers/scsi/sg.c === --- linux.orig/drivers/scsi/sg.c +++ linux/drivers/scsi/sg.c @@ -150,7 +150,6 @@ typedef struct sg_fd { /* holds the sta Sg_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_ho static 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 fil if (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, co int 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_m
[PATCH] [2/22] Remove unchecked_isa in BusLogic
- ->cmnd handling audited and does always copy - Allocate hostdata separately - Enable sense_buffer isa bounce buffering - Remove unchecked_isa_dma - Enable block layer bouncing explicitely for isa adapters Untested due to lack of hardware Signed-off-by: Andi Kleen <[EMAIL PROTECTED]> --- drivers/scsi/BusLogic.c | 74 1 file changed, 56 insertions(+), 18 deletions(-) Index: linux/drivers/scsi/BusLogic.c === --- linux.orig/drivers/scsi/BusLogic.c +++ linux/drivers/scsi/BusLogic.c @@ -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(stru static const char *BusLogic_DriverInfo(struct Scsi_Host *Host) { - struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) Host->hostdata; + struct BusLogic_HostAdapter *HostAdapter = bl_shost_priv(Host); return HostAdapter->FullModelName; } @@ -1607,9 +1618,6 @@ static bool __init BusLogic_ReadHostAdap BIOS_Address is 0. */ HostAdapter->BIOS_Address = ExtendedSetupInformation.BIOS_Address << 12; - /* - ISA Host Adapters require Bounce Buffers if there is more than 16MB memory. -*/ if (HostAdapter->HostAdapterBusType == BusLogic_ISA_Bus && (void *) high_memory > (void *) MAX_DMA_ADDRESS) HostAdapter->BounceBuffersRequired = true; /* @@ -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(struc return 0; } +static struct Scsi_Host *buslogic_host_alloc(gfp_t gfp) +{ + struct BusLogic_HostAdapter *board; + struct Scsi_Host *shost; + shost = scsi_host_alloc(&Bus_Logic_template, sizeof(struct host_ptr)); + if (!shost) + return NULL; + + board = (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));
[PATCH] [8/22] Remove random noop unchecked_isa_dma users
Lots 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 === --- linux.orig/drivers/scsi/arm/acornscsi.c +++ linux/drivers/scsi/arm/acornscsi.c @@ -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 === --- linux.orig/drivers/scsi/arm/cumana_1.c +++ linux/drivers/scsi/arm/cumana_1.c @@ -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 === --- linux.orig/drivers/scsi/dc395x.c +++ linux/drivers/scsi/dc395x.c @@ -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 === --- linux.orig/drivers/scsi/eata_pio.c +++ linux/drivers/scsi/eata_pio.c @@ -815,8 +815,6 @@ static int register_pio_HBA(long base, s else 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 === --- linux.orig/drivers/scsi/hptiop.c +++ linux/drivers/scsi/hptiop.c @@ -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 === --- linux.orig/drivers/scsi/ips.c +++ linux/drivers/scsi/ips.c @@ -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 === --- linux.orig/drivers/scsi/mac_scsi.c +++ linux/drivers/scsi/mac_scsi.c @@ -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 === --- linux.orig/drivers/scsi/scsi_debug.c +++ linux/drivers/scsi/scsi_debug.c @@ -221,7 +221,6 @@ static struct scsi_host_template sdebug_ .sg_tablesize = 256, .cmd_per_lun = 16, .max_sectors = 0x, - .unchecked_isa_dma =0, .use_clustering = ENABLE_CLUSTERING, .module = THIS_MODULE, }; - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] [22/22] Remove GFP_DMA in sr_vendor.c
Bounced by the block layer anyways Signed-off-by: Andi Kleen <[EMAIL PROTECTED]> Index: linux/drivers/scsi/sr_vendor.c === --- linux.orig/drivers/scsi/sr_vendor.c +++ linux/drivers/scsi/sr_vendor.c @@ -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_info if (cd->cdi.mask & CDC_MULTI_SESSION) return 0; - buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); + buffer = kmalloc(512, GFP_KERNEL); if (!buffer) return -ENOMEM; - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] [21/22] Remove GFP_DMA in ch.c
All buffers are bounced by the block layer Signed-off-by: Andi Kleen <[EMAIL PROTECTED]> Index: linux/drivers/scsi/ch.c === --- linux.orig/drivers/scsi/ch.c +++ linux/drivers/scsi/ch.c @@ -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); - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] [18/22] Finally remove unchecked_isa_dma support for Cmnds
No drivers need it anymore Signed-off-by: Andi Kleen <[EMAIL PROTECTED]> --- drivers/scsi/scsi.c |3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) Index: linux/drivers/scsi/scsi.c === --- linux.orig/drivers/scsi/scsi.c +++ linux/drivers/scsi/scsi.c @@ -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, - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] [7/22] Remove unchecked_isa_dma in aha152x/wd7000/sym53c416/u14-34f/NCR53c406a
I 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. Signed-off-by: Andi Kleen <[EMAIL PROTECTED]> --- 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(-) Index: linux/drivers/scsi/aha152x.c === --- linux.orig/drivers/scsi/aha152x.c +++ linux/drivers/scsi/aha152x.c @@ -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, voi struct 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 Scsi static 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; } Index: linux/drivers/scsi/wd7000.c === --- linux.orig/drivers/scsi/wd7000.c +++ linux/drivers/scsi/wd7000.c @@ -189,7 +189,6 @@ #include #include - #undef WD7000_DEBUG /* general debug*/ #ifdef WD7000_DEBUG #define dprintk printk @@ -260,6 +259,12 @@ typedef struct adapter { unchar rev1, rev2; /* filled in by wd7000_revision */ } Adapter; +struct adapter_ptr { + Adapter *host; +}; + +#define wd_host(shost) (((struct adapter_ptr *)shost_priv(shost))->host) + /* * (linear) base address for ROM BIOS */ @@ -1092,7 +1097,7 @@ static int wd7000_queuecommand(struct sc unchar idlun; short cdblen; int nseg; - Adapter *host = (Adapter *) SCpnt->device->host->hostdata; + Adapter *host = wd_host(SCpnt->device->host); cdblen = SCpnt->cmd_len; idlun = ((SCpnt->device->id << 5) & 0xe0) | (SCpnt->device->lun & 7); @@ -1312,7 +1317,7 @@ static int wd7000_set_info(char *buffer, static int wd7000_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int inout) { - Adapter *adapter = (Adapter *)host->hostdata; + Adapter *adapter = wd_host(host); unsigned long flags; char *pos = buffer; #ifdef WD7000_DEBUG @@ -1485,18 +1490,16 @@ static __init int wd7000_detect(stru
[PATCH] [14/22] Remove automatic block layer bouncing for unchecked_isa_dma
All 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. Signed-off-by: Andi Kleen <[EMAIL PROTECTED]> --- drivers/scsi/scsi_lib.c |2 -- 1 file changed, 2 deletions(-) Index: linux/drivers/scsi/scsi_lib.c === --- linux.orig/drivers/scsi/scsi_lib.c +++ linux/drivers/scsi/scsi_lib.c @@ -1547,8 +1547,6 @@ u64 scsi_calculate_bounce_limit(struct S struct device *host_dev; u64 bounce_limit = 0x; - if (shost->unchecked_isa_dma) - return BLK_BOUNCE_ISA; /* * Platforms with virtual-DMA translation * hardware have no practical limit. - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] [6/22] Remove unchecked_isa_dma in aha1542
- 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 Signed-off-by: Andi Kleen <[EMAIL PROTECTED]> --- drivers/scsi/aha1542.c | 38 -- 1 file changed, 28 insertions(+), 10 deletions(-) Index: linux/drivers/scsi/aha1542.c === --- linux.orig/drivers/scsi/aha1542.c +++ linux/drivers/scsi/aha1542.c @@ -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_H free_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" - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] [4/22] Remove unchecked_isa_dma in gdth
- 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 Signed-off-by: Andi Kleen <[EMAIL PROTECTED]> --- drivers/scsi/gdth.c | 79 +++- 1 file changed, 60 insertions(+), 19 deletions(-) Index: linux/drivers/scsi/gdth.c === --- linux.orig/drivers/scsi/gdth.c +++ linux/drivers/scsi/gdth.c @@ -138,6 +138,13 @@ #include #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_c int __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_ha static 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 Scsi static 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_d static 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 s return 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(ulo if (!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(ulo set_dma_mode(ha->drq,DMA_MODE_CASCADE); enable_dma(ha->drq); - shp->unchecked_isa_dma = 1; + shp->sense_buffer_mas
[PATCH] [10/22] Remove unchecked_isa_dma support for hostdata
All 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 Signed-off-by: Andi Kleen <[EMAIL PROTECTED]> --- drivers/scsi/hosts.c |3 --- 1 file changed, 3 deletions(-) Index: linux/drivers/scsi/hosts.c === --- linux.orig/drivers/scsi/hosts.c +++ linux/drivers/scsi/hosts.c @@ -297,9 +297,6 @@ struct Scsi_Host *scsi_host_alloc(struct gfp_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; - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[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. Signed-off-by: Andi Kleen <[EMAIL PROTECTED]> --- 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(-) Index: linux/drivers/scsi/scsi.c === --- linux.orig/drivers/scsi/scsi.c +++ linux/drivers/scsi/scsi.c @@ -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, Index: linux/include/scsi/scsi_host.h === --- linux.orig/include/scsi/scsi_host.h +++ linux/include/scsi/scsi_host.h @@ -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; Index: linux/Documentation/scsi/scsi_mid_low_api.txt === --- linux.orig/Documentation/scsi/scsi_mid_low_api.txt +++ linux/Documentation/scsi/scsi_mid_low_api.txt @@ -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(). Index: linux/drivers/scsi/hosts.c === --- linux.orig/drivers/scsi/hosts.c +++ linux/drivers/scsi/hosts.c @@ -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 */ - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] [20/22] Remove GFP_DMA in sr.c
All buffers are bounced by the block layer Signed-off-by: Andi Kleen <[EMAIL PROTECTED]> Index: linux/drivers/scsi/sr.c === --- linux.orig/drivers/scsi/sr.c +++ linux/drivers/scsi/sr.c @@ -674,7 +674,7 @@ static void get_sectorsize(struct scsi_c int 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; - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] [13/22] Don't disable direct_io for unchecked_isa_dma in st.c
Block layer bounces anyways. Signed-off-by: Andi Kleen <[EMAIL PROTECTED]> --- drivers/scsi/st.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: linux/drivers/scsi/st.c === --- linux.orig/drivers/scsi/st.c +++ linux/drivers/scsi/st.c @@ -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]); - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] [19/22] Finally kill unchecked_isa_dma
Now that all users are gone it can be safely completely removed. Signed-off-by: Andi Kleen <[EMAIL PROTECTED]> --- Documentation/scsi/scsi_mid_low_api.txt |3 --- drivers/scsi/hosts.c|1 - include/scsi/scsi_host.h|6 -- 3 files changed, 10 deletions(-) Index: linux/Documentation/scsi/scsi_mid_low_api.txt === --- linux.orig/Documentation/scsi/scsi_mid_low_api.txt +++ linux/Documentation/scsi/scsi_mid_low_api.txt @@ -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 Index: linux/drivers/scsi/hosts.c === --- linux.orig/drivers/scsi/hosts.c +++ linux/drivers/scsi/hosts.c @@ -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; Index: linux/include/scsi/scsi_host.h === --- linux.orig/include/scsi/scsi_host.h +++ linux/include/scsi/scsi_host.h @@ -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; - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] [12/22] Remove GFP_DMAs/unchecked_isa_dma checks in scsi_scan.c
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 === --- linux.orig/drivers/scsi/scsi_scan.c +++ linux/drivers/scsi/scsi_scan.c @@ -1010,8 +1010,7 @@ static int scsi_probe_and_add_lun(struct if (!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; - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] ps3rom: fix wrong resid calculation bug
sg driver rounds up the length in struct scatterlist to be a multiple of 512 in some conditions. So LLDs can't use the data length in a sg list to calculate residual. Instead, the length in struct scsi_cmnd should be used. Signed-off-by: FUJITA Tomonori <[EMAIL PROTECTED]> Cc: Geert Uytterhoeven <[EMAIL PROTECTED]> Cc: James Bottomley <[EMAIL PROTECTED]> --- drivers/scsi/ps3rom.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/scsi/ps3rom.c b/drivers/scsi/ps3rom.c index 0cd614a..6944bda 100644 --- a/drivers/scsi/ps3rom.c +++ b/drivers/scsi/ps3rom.c @@ -124,7 +124,7 @@ static int fill_from_dev_buffer(struct scsi_cmnd *cmd, const void *buf) } req_len += sgpnt->length; } - scsi_set_resid(cmd, req_len - act_len); + scsi_set_resid(cmd, scsi_bufflen(cmd) - act_len); return 0; } -- 1.5.3.7 - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] scsi_debug: fix wrong resid calculation bug
sg driver rounds up the length in struct scatterlist to be a multiple of 512 in some conditions. So LLDs can't use the data length in a sg list to calculate residual. Instead, the length in struct scsi_cmnd should be used. Signed-off-by: FUJITA Tomonori <[EMAIL PROTECTED]> Cc: Douglas Gilbert <[EMAIL PROTECTED]> Cc: James Bottomley <[EMAIL PROTECTED]> --- drivers/scsi/scsi_debug.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index d1777a9..691efd9 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -651,7 +651,7 @@ static int fill_from_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr, if (sdb->resid) sdb->resid -= act_len; else - sdb->resid = req_len - act_len; + sdb->resid = scsi_bufflen(scp) - act_len; return 0; } -- 1.5.3.7 - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] aacraid: READ_CAPACITY_16 shouldn't trust allocation length in cdb
When aacraid spoofs READ_CAPACITY_16, it assumes that the data length in the sg list is equal to allocation length in cdb. But sg can put any value in scb so the driver needs to check both the data length in the sg list and allocation length in cdb. If allocation length is larger than the response length that the driver expects, it clears the data buffer in the sg list to zero but it doesn't need to do. Just setting resid is fine. Signed-off-by: FUJITA Tomonori <[EMAIL PROTECTED]> Cc: Mark Salyzyn <[EMAIL PROTECTED]> Cc: James Bottomley <[EMAIL PROTECTED]> --- drivers/scsi/aacraid/aachba.c | 22 +++--- 1 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index c05092f..b9fc9b1 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -2047,6 +2047,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) { u64 capacity; char cp[13]; + unsigned int alloc_len; dprintk((KERN_DEBUG "READ CAPACITY_16 command.\n")); capacity = fsa_dev_ptr[cid].size - 1; @@ -2063,18 +2064,17 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) cp[10] = 2; cp[11] = 0; cp[12] = 0; - aac_internal_transfer(scsicmd, cp, 0, - min_t(size_t, scsicmd->cmnd[13], sizeof(cp))); - if (sizeof(cp) < scsicmd->cmnd[13]) { - unsigned int len, offset = sizeof(cp); - memset(cp, 0, offset); - do { - len = min_t(size_t, scsicmd->cmnd[13] - offset, - sizeof(cp)); - aac_internal_transfer(scsicmd, cp, offset, len); - } while ((offset += len) < scsicmd->cmnd[13]); - } + alloc_len = ((scsicmd->cmnd[10] << 24) ++ (scsicmd->cmnd[11] << 16) ++ (scsicmd->cmnd[12] << 8) + scsicmd->cmnd[13]); + + alloc_len = min_t(size_t, alloc_len, sizeof(cp)); + aac_internal_transfer(scsicmd, cp, 0, alloc_len); + + if (alloc_len < scsi_bufflen(scsicmd)) + scsi_set_resid(scsicmd, + scsi_bufflen(scsicmd) - alloc_len); /* Do not cache partition table for arrays */ scsicmd->device->removable = 1; -- 1.5.3.7 - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] SCSI tape: show options currently set in sysfs
On Sun, 24 Feb 2008 22:29:12 +0200 (EET) Kai Makisara wrote: > Documentation/scsi/st.txt |7 ++- > Index: linux-2.6.25-rc2-q/Documentation/scsi/st.txt > === > --- linux-2.6.25-rc2-q.orig/Documentation/scsi/st.txt > +++ linux-2.6.25-rc2-q/Documentation/scsi/st.txt > @@ -133,6 +133,11 @@ the defaults set by the user. The value > file 'dev' contains the device numbers corresponding to this device. The > links > 'device' and 'driver' point to the SCSI device and driver entries. > > +Each directory acontains also the entry 'options' which shows the currently also contains the entry 'options' > +enabled driver and mode options. The value in the file is a bit mask where > the > +bit definitions are the same as those used with MTSETDRVBUFFER in setting the > +options. > + > A link named 'tape' is made from the SCSI device directory to the class > directory corresponding to the mode 0 auto-rewind device (e.g., st0). --- ~Randy - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Need help with libata error handling in libsas
I keep hearing that we need to convert libsas to use libata's new error handling. Unfortunately, I have very little conception of what that means. Right at the moment, libsas doesn't use any error handling functions of libata at all. I've looked through the libata-eh functions, and I find them frankly incomprehensible. Firstly, let me say what SAS error handling actually does: First of all, we may (or may not) get early warning of problems, so we have callbacks to allow drivers to trigger the error handler early (There's a particular event from the aic94xx sequencer which says "I've detected a screw up on this task, begin error handling now"), which seems to correspond with ata_qc_schedule_eh(). Then we quiesce the host (standard eh practice, so libata does this to because SCSI forces it). Then we go through the remaining tasks. The first thing we try is to abort a task. This is basically asking the HBA to give me back my task, and is applicable to both ATA and SAS tasks. Abort serves a dual purpose; if the task is pending or completed, it can just be flushed from the HBA issue queue. If the task is actually active on the end device, then we can send a SCSI TMF after it. For ATA, we can't do this, but the docs recommend sending a register D2H FIS with a soft reset after a non-NCQ task or a CHECK POWER MODE fis after an NCQ command. I just don't see anywhere in libata where this is done? After this, libsas uses a query function (which has no ATA parallel) to find what the target is doing with the task. Finally we come to the escalating reset sequece (LUN (hard), phy, pathway) which seems to mirror what libata-eh would do (well, barring the pathway reset, since ATA has no concept of that). All of this leads me to conclude, that all libsas needs is to plumb in the ATA equivalent of abort, junk the task query for libata devices and simply proceed, as if the task is held at the target, along the escalating reset path. We might be able to weld the error handlers of libsas and libata together (i.e. use the libata one for everything up to pathway reset and then move to the libsas one for pathway reset on), the problem is I just don't see any way of doing this. Plus abort and TMF query skip are fairly small alterations to the current libsas eh, so it's not clear there's any value to acutally welding in the libsas eh, even if I could get it to provide the information I need. So, my conclusion is tending towards simply adding an ATA component to libsas and keeping all eh libsas local. In that case, is there anything I need to do to convince libata that I don't care whether it uses old or new error handling? James - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] SCSI tape: show options currently set in sysfs
Show the current binary tape driver and mode options is sysfs. A file (options) is created in each directory in /sys/class/scsi_tape. The files contain masks showing the options. The mask bit definitions are the same as used when setting the options using the MTSETDRVBUFFER function in the MTIOCTOP ioctl (defined in include/linux/mtio.h). For example: > cat /sys/class/scsi_tape/nst0/options 0x0d07 Signed-off-by: Kai Makisara <[EMAIL PROTECTED]> --- The patch is against Feb 24 git version of 2.6.25-rc2. Candidate for inclusion into 2.6.26. Documentation/scsi/st.txt |7 ++- drivers/scsi/st.c | 43 +++ 2 files changed, 49 insertions(+), 1 deletion(-) Index: linux-2.6.25-rc2-q/drivers/scsi/st.c === --- linux-2.6.25-rc2-q.orig/drivers/scsi/st.c +++ linux-2.6.25-rc2-q/drivers/scsi/st.c @@ -4365,6 +4365,46 @@ static ssize_t st_defcompression_show(st CLASS_DEVICE_ATTR(default_compression, S_IRUGO, st_defcompression_show, NULL); +static ssize_t st_options_show(struct class_device *class_dev, char *buf) +{ + struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev); + struct scsi_tape *STp; + int i, j, options; + ssize_t l = 0; + + for (i=0; i < st_dev_max; i++) { + for (j=0; j < ST_NBR_MODES; j++) + if (&scsi_tapes[i]->modes[j] == STm) + break; + if (j < ST_NBR_MODES) + break; + } + if (i == st_dev_max) + return 0; /* should never happen */ + + STp = scsi_tapes[i]; + + options = STm->do_buffer_writes ? MT_ST_BUFFER_WRITES : 0; + options |= STm->do_async_writes ? MT_ST_ASYNC_WRITES : 0; + options |= STm->do_read_ahead ? MT_ST_READ_AHEAD : 0; + DEB( options |= debugging ? MT_ST_DEBUGGING : 0 ); + options |= STp->two_fm ? MT_ST_TWO_FM : 0; + options |= STp->fast_mteom ? MT_ST_FAST_MTEOM : 0; + options |= STm->defaults_for_writes ? MT_ST_DEF_WRITES : 0; + options |= STp->can_bsr ? MT_ST_CAN_BSR : 0; + options |= STp->omit_blklims ? MT_ST_NO_BLKLIMS : 0; + options |= STp->can_partitions ? MT_ST_CAN_PARTITIONS : 0; + options |= STp->scsi2_logical ? MT_ST_SCSI2LOGICAL : 0; + options |= STm->sysv ? MT_ST_SYSV : 0; + options |= STp->immediate ? MT_ST_NOWAIT : 0; + options |= STp->sili ? MT_ST_SILI : 0; + + l = snprintf(buf, PAGE_SIZE, "0x%08x\n", options); + return l; +} + +CLASS_DEVICE_ATTR(options, S_IRUGO, st_options_show, NULL); + static int do_create_class_files(struct scsi_tape *STp, int dev_num, int mode) { int i, rew, error; @@ -4402,6 +4442,9 @@ static int do_create_class_files(struct error = class_device_create_file(st_class_member, &class_device_attr_default_compression); if (error) goto out; + error = class_device_create_file(st_class_member, + &class_device_attr_options); + if (error) goto out; if (mode == 0 && rew == 0) { error = sysfs_create_link(&STp->device->sdev_gendev.kobj, Index: linux-2.6.25-rc2-q/Documentation/scsi/st.txt === --- linux-2.6.25-rc2-q.orig/Documentation/scsi/st.txt +++ linux-2.6.25-rc2-q/Documentation/scsi/st.txt @@ -2,7 +2,7 @@ This file contains brief information abo The driver is currently maintained by Kai Mäkisara (email [EMAIL PROTECTED]) -Last modified: Thu Feb 21 21:54:16 2008 by kai.makisara +Last modified: Sun Feb 24 21:59:07 2008 by kai.makisara BASICS @@ -133,6 +133,11 @@ the defaults set by the user. The value file 'dev' contains the device numbers corresponding to this device. The links 'device' and 'driver' point to the SCSI device and driver entries. +Each directory acontains also the entry 'options' which shows the currently +enabled driver and mode options. The value in the file is a bit mask where the +bit definitions are the same as those used with MTSETDRVBUFFER in setting the +options. + A link named 'tape' is made from the SCSI device directory to the class directory corresponding to the mode 0 auto-rewind device (e.g., st0).
[PATCH 1/2] SCSI tape: add option to use SILI in variable block reads
Add new option MT_ST_SILI to enable setting the SILI bit in reads in variable block mode. If SILI is set, reading a block shorter than the byte count does not result in CHECK CONDITION. The length of the block is determined using the residual count from the HBA. Avoiding the REQUEST SENSE command for every block speeds up some real applications considerably. Signed-off-by: Kai Makisara <[EMAIL PROTECTED]> --- The patch is against Feb 24 git version of 2.5.25-rc2. Candidate for inclusion into 2.6.26. Documentation/scsi/st.txt |7 ++- drivers/scsi/st.c | 40 drivers/scsi/st.h |3 +++ drivers/scsi/st_options.h |6 +- include/linux/mtio.h |1 + 5 files changed, 51 insertions(+), 6 deletions(-) Index: linux-2.6.25-rc2-q/drivers/scsi/st.c === --- linux-2.6.25-rc2-q.orig/drivers/scsi/st.c +++ linux-2.6.25-rc2-q/drivers/scsi/st.c @@ -17,7 +17,7 @@ Last modified: 18-JAN-1998 Richard Gooch <[EMAIL PROTECTED]> Devfs support */ -static const char *verstr = "20080221"; +static const char *verstr = "20080224"; #include @@ -183,6 +183,7 @@ static int modes_defined; static struct st_buffer *new_tape_buffer(int, int, int); static int enlarge_buffer(struct st_buffer *, int, int); +static void clear_buffer(struct st_buffer *); static void normalize_buffer(struct st_buffer *); static int append_to_buffer(const char __user *, struct st_buffer *, int); static int from_buffer(struct st_buffer *, char __user *, int); @@ -442,6 +443,7 @@ static void st_sleep_done(void *data, ch memcpy(SRpnt->sense, sense, SCSI_SENSE_BUFFERSIZE); (STp->buffer)->cmdstat.midlevel_result = SRpnt->result = result; + (STp->buffer)->cmdstat.residual = resid; DEB( STp->write_pending = 0; ) if (SRpnt->waiting) @@ -1159,6 +1161,7 @@ static int st_open(struct inode *inode, goto err_out; } + (STp->buffer)->cleared = 0; (STp->buffer)->writing = 0; (STp->buffer)->syscall_result = 0; @@ -1432,8 +1435,14 @@ static int setup_buffering(struct scsi_t if (STp->block_size) bufsize = STp->block_size > st_fixed_buffer_size ? STp->block_size : st_fixed_buffer_size; - else + else { bufsize = count; + /* Make sure that data from previous user is not leaked even if + HBA does not return correct residual */ + if (is_read && STp->sili && !STbp->cleared) + clear_buffer(STbp); + } + if (bufsize > STbp->buffer_size && !enlarge_buffer(STbp, bufsize, STp->restr_dma)) { printk(KERN_WARNING "%s: Can't allocate %d byte tape buffer.\n", @@ -1783,6 +1792,8 @@ static long read_tape(struct scsi_tape * memset(cmd, 0, MAX_COMMAND_SIZE); cmd[0] = READ_6; cmd[1] = (STp->block_size != 0); + if (!cmd[1] && STp->sili) + cmd[1] |= 2; cmd[2] = blks >> 16; cmd[3] = blks >> 8; cmd[4] = blks; @@ -1911,8 +1922,11 @@ static long read_tape(struct scsi_tape * } /* End of error handling */ - else/* Read successful */ + else { /* Read successful */ STbp->buffer_bytes = bytes; + if (STp->sili) /* In fixed block mode residual is always zero here */ + STbp->buffer_bytes -= STp->buffer->cmdstat.residual; + } if (STps->drv_block >= 0) { if (STp->block_size == 0) @@ -2090,7 +2104,8 @@ static void st_log_options(struct scsi_t name, STm->defaults_for_writes, STp->omit_blklims, STp->can_partitions, STp->scsi2_logical); printk(KERN_INFO - "%s:sysv: %d nowait: %d\n", name, STm->sysv, STp->immediate); + "%s:sysv: %d nowait: %d sili: %d\n", name, STm->sysv, STp->immediate, + STp->sili); printk(KERN_INFO "%s:debugging: %d\n", name, debugging); } @@ -2133,6 +2148,7 @@ static int st_set_options(struct scsi_ta STp->scsi2_logical = (options & MT_ST_SCSI2LOGICAL) != 0; STp->immediate = (options & MT_ST_NOWAIT) != 0; STm->sysv = (options & MT_ST_SYSV) != 0; + STp->sili = (options & MT_ST_SILI) != 0; DEB( debugging = (o
Re: [PATCH] mvsas: convert from rough draft to working driver
On Sat, Feb 23, 2008 at 11:28:50AM -0500, Jeff Garzik wrote: > Ke Wei wrote: > >Convert rough draft Marvell 6440 driver to a working driver. > >Added support for SAS and SATA devices, hotplug, wide port, and expanders. > >This patch is based on: > >branch 'mvsas' of > >git.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6.git > > Yay! Perfect patch: good tech content, applyable to #mvsas, and the > most important part, the driver works :) > > One minor (though important) detail: may we assume this patch has the > same Signed-off-by as previous patches? > Oah, I have no idea how to diff between the previous 5th commit and current to use git-format-patch command, so I had to use git-diff to create patch. As a result, I format to place my Signed-off-by when sending email. Jeff, Do you have a good suggestion? Thank you for your help. Now, Signed-off-by: Ke Wei <[EMAIL PROTECTED]> > Thanks and have a good weekend, > > Jeff > - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html