Commit f512f4dd authored by Dave Olien's avatar Dave Olien Committed by James Bottomley

[PATCH] 2.5.68 scsi/gdth compile warnings and stack usage

James Bottomley, please apply this patch.  It was sent out on
linux-scsi last week and drew no responses.

This is a patch for the scsi/gdth driver.  It was originally
done in 2.5.67, but the patch applies to 2.5.68.

There are two components to this patch.  The first component fixes
with compilation warnings (which did uncover real bugs).  The other component
(by Randy Dunlap) reduces stack size usage in gdth_ioctl().

The compilation warnings occur only when CONFIG_HIGHMEM=y in the kernel
configuration file (enable either 4gig or 64gig memory support).  This
changes the size of the dma_addr_t from u32 to u64.
The calls to pci_alloc_consistent return a value of type dma_addr_t.
But the code was casting a pointer to what was ony a 32-bit memory location.

This seonc component of the patch reduces stack size in
scsi/gdth.c::gdth_ioctl() by making each separate ioctl have its own
handler function, so that several large data structs are all declared on
the stack at the same time.

patch_name:     gdth-stack_warnings.patch
patch_version:  2003-04-14.16:31:30
author:         Randy.Dunlap <rddunlap@osdl.org>, Dave.Olien<dmo@osdl.org)
description:    reduce stack usage in drivers/scsi/gdth.c::gdth_ioctl()
                from 0xb50 to 0x5c (on P4, gcc 2.96); the large (ioctl)
                function sizes in gdth.o now are:
                        150 ioc_event
                        178 ioc_resetdrv
                        190 ioc_general
                        30c ioc_hdrlist
                        324 ioc_rescan
                so the largest cumulative size of calling gdth_ioctl() +
                a specific ioctl is 0x5c + 0x324 = 0x380.
		Fix compilation warnings in calls to pci_alloc_consistent()
		that occur only when CONFIG_HIGHMEM=y.  The compiler
		warnings result from dma_addr_t changing in size from u32
		to u64.
product:        Linux
product_versions: 2.5.67
changelog:      make each ioctl that uses large stack space into its own
                function;
                mostly moving lines of code around;
                duplicates some local data in multiple functions;
		fix compiler warnings by adding intermediate dma_addr_t local
		variables to hold returns from pci_alloc_consistent.
maintainer:     Achim Leubner (achim.leubner@intel.com)
diffstat:	=
 drivers/scsi/gdth.c      |  664 ++++++++++++++++++++++++++---------------------
 drivers/scsi/gdth_proc.c |    5
 2 files changed, 374 insertions(+), 295 deletions(-)

FYI:  The killer data structs in gdth_ioctl() (on x86, P4, gcc 2.96) are:
                sizeof gdth_cmd_str: 336 bytes
                sizeof gdth_ioctl_general: 356 bytes
                sizeof gdth_ioctl_event: 308 bytes
                sizeof gdth_ioctl_lockdrv: 204 bytes
                sizeof gdth_ioctl_rescan: 406 bytes

###
parent ceb6a7fc
This diff is collapsed.
......@@ -1471,7 +1471,10 @@ static char *gdth_ioctl_alloc(int hanum, int size, int scratch,
ret_val = NULL;
} else {
#if LINUX_VERSION_CODE >= 0x020400
ret_val = pci_alloc_consistent(ha->pdev, size, paddr);
dma_addr_t dma_addr;
ret_val = pci_alloc_consistent(ha->pdev, size, &dma_addr);
*paddr = (ulong32)dma_addr;
#else
ret_val = scsi_init_malloc(size, GFP_ATOMIC | GFP_DMA);
if (ret_val)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment