• Dave Olien's avatar
    [PATCH] 2.5.68 scsi/gdth compile warnings and stack usage · f512f4dd
    Dave Olien authored
    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
    
    ###
    f512f4dd
gdth.c 202 KB