## Automatically generated incremental diff ## From: linux-2.5.69-bk17 ## To: linux-2.5.69-bk18 ## Robot: $Id: make-incremental-diff,v 1.11 2002/02/20 02:59:33 hpa Exp $ diff -urN linux-2.5.69-bk17/Makefile linux-2.5.69-bk18/Makefile --- linux-2.5.69-bk17/Makefile 2003-05-25 04:38:49.000000000 -0700 +++ linux-2.5.69-bk18/Makefile 2003-05-25 04:38:55.000000000 -0700 @@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 5 SUBLEVEL = 69 -EXTRAVERSION = -bk17 +EXTRAVERSION = -bk18 # *DOCUMENTATION* # To see a list of typical targets execute "make help" diff -urN linux-2.5.69-bk17/arch/ppc/Kconfig linux-2.5.69-bk18/arch/ppc/Kconfig --- linux-2.5.69-bk17/arch/ppc/Kconfig 2003-05-04 16:53:56.000000000 -0700 +++ linux-2.5.69-bk18/arch/ppc/Kconfig 2003-05-25 04:38:55.000000000 -0700 @@ -1111,7 +1111,7 @@ config LOWMEM_SIZE_BOOL bool "Set maximum low memory" - depends on ADVANCED_OPTIONS && HIGHMEM + depends on ADVANCED_OPTIONS help This option allows you to set the maximum amount of memory which will be used as "low memory", that is, memory which the kernel can diff -urN linux-2.5.69-bk17/arch/ppc/Makefile linux-2.5.69-bk18/arch/ppc/Makefile --- linux-2.5.69-bk17/arch/ppc/Makefile 2003-05-04 16:53:01.000000000 -0700 +++ linux-2.5.69-bk18/arch/ppc/Makefile 2003-05-25 04:38:55.000000000 -0700 @@ -11,10 +11,10 @@ # # This must match PAGE_OFFSET in include/asm-ppc/page.h. -KERNELLOAD =$(CONFIG_KERNEL_START) +KERNELLOAD := $(CONFIG_KERNEL_START) LDFLAGS_BLOB := --format binary --oformat elf32-powerpc -LDFLAGS_vmlinux = -Ttext $(KERNELLOAD) -Bstatic +LDFLAGS_vmlinux := -Ttext $(KERNELLOAD) -Bstatic CPPFLAGS += -Iarch/$(ARCH) AFLAGS += -Iarch/$(ARCH) cflags-y += -Iarch/$(ARCH) -msoft-float -pipe \ diff -urN linux-2.5.69-bk17/arch/ppc/boot/Makefile linux-2.5.69-bk18/arch/ppc/boot/Makefile --- linux-2.5.69-bk17/arch/ppc/boot/Makefile 2003-05-04 16:53:32.000000000 -0700 +++ linux-2.5.69-bk18/arch/ppc/boot/Makefile 2003-05-25 04:38:55.000000000 -0700 @@ -13,28 +13,17 @@ CFLAGS += -fno-builtin -D__BOOTER__ -Iarch/$(ARCH)/boot/include HOSTCFLAGS += -Iarch/$(ARCH)/boot/include -BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd +BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd bootdir-y := simple bootdir-$(CONFIG_ALL_PPC) := openfirmware prep -subdir-y := lib common images -subdir-$(CONFIG_ALL_PPC) += of1275 +subdir-y := lib/ common/ images/ +subdir-$(CONFIG_ALL_PPC) += of1275/ # for cleaning subdir- += simple/ openfirmware/ prep/ -tools-$(CONFIG_ALL_PPC) := addnote mknote hack-coff mkprep -tools-$(CONFIG_PPLUS) := mkbugboot mkprep -tools-$(CONFIG_4xx) := mktree -tools-$(CONFIG_LOPEC) := mkbugboot mkprep -tools-$(CONFIG_MCPN765) := mkbugboot mkprep -tools-$(CONFIG_MENF1) := mkprep -tools-$(CONFIG_MVME5100) := mkbugboot mkprep -tools-$(CONFIG_PRPMC750) := mkbugboot mkprep -tools-$(CONFIG_PRPMC800) := mkbugboot mkprep -tools-$(CONFIG_SPRUCE) := mktree - -host-progs := $(addprefix utils/,$(tools-y)) +host-progs := $(addprefix utils/, addnote mknote hack-coff mkprep mkbugboot mktree) .PHONY: $(BOOT_TARGETS) $(bootdir-y) diff -urN linux-2.5.69-bk17/arch/ppc/boot/common/dummy.c linux-2.5.69-bk18/arch/ppc/boot/common/dummy.c --- linux-2.5.69-bk17/arch/ppc/boot/common/dummy.c 2003-05-04 16:53:40.000000000 -0700 +++ linux-2.5.69-bk18/arch/ppc/boot/common/dummy.c 1969-12-31 16:00:00.000000000 -0800 @@ -1,4 +0,0 @@ -int main(void) -{ - return 0; -} diff -urN linux-2.5.69-bk17/arch/ppc/boot/images/Makefile linux-2.5.69-bk18/arch/ppc/boot/images/Makefile --- linux-2.5.69-bk17/arch/ppc/boot/images/Makefile 2003-05-04 16:53:01.000000000 -0700 +++ linux-2.5.69-bk18/arch/ppc/boot/images/Makefile 2003-05-25 04:38:55.000000000 -0700 @@ -2,12 +2,14 @@ # This dir holds all of the images for PPC machines. # Tom Rini January 2001 -extra-y := vmlinux.gz -GZIP_FLAGS := -v9f +extra-y := vmlinux.bin vmlinux.gz -$(obj)/vmlinux.gz: vmlinux - $(OBJCOPY) -O binary $< $(@:.gz=) - gzip $(GZIP_FLAGS) $(@:.gz=) +OBJCOPYFLAGS_vmlinux.bin := -O binary +$(obj)/vmlinux.bin: vmlinux FORCE + $(call if_changed,objcopy) + +$(obj)/vmlinux.gz: $(obj)/vmlinux.bin FORCE + $(call if_changed,gzip) # Files generated that shall be removed upon make clean clean-files := sImage vmapus vmlinux* miboot* zImage* diff -urN linux-2.5.69-bk17/arch/ppc/boot/openfirmware/Makefile linux-2.5.69-bk18/arch/ppc/boot/openfirmware/Makefile --- linux-2.5.69-bk17/arch/ppc/boot/openfirmware/Makefile 2003-05-04 16:53:09.000000000 -0700 +++ linux-2.5.69-bk18/arch/ppc/boot/openfirmware/Makefile 2003-05-25 04:38:55.000000000 -0700 @@ -10,36 +10,34 @@ # Merged 'chrp' and 'pmac' into 'openfirmware', and cleaned up the # rules. -clean-files := note coffboot coffboot.initrd +zImage.initrd znetboot.initrd: del-ramdisk-sec := -R .ramdisk +zImage.initrd znetboot.initrd: initrd := .initrd -boot: zImage -boot := arch/ppc/boot -common := $(boot)/common -utils := $(boot)/utils -bootlib := $(boot)/lib -of1275 := $(boot)/of1275 -images := $(boot)/images - -OBJCOPY_ARGS = -O aixcoff-rs6000 -R .stab -R .stabstr -R .comment -COFF_LD_ARGS = -T $(boot)/ld.script -e _start -Ttext 0x00700000 -Bstatic -CHRP_LD_ARGS = -T $(boot)/ld.script -e _start -Ttext 0x00800000 -NEWWORLD_LD_ARGS = -T $(boot)/ld.script -e _start -Ttext 0x01000000 +boot := arch/ppc/boot +common := $(boot)/common +utils := $(boot)/utils +bootlib := $(boot)/lib +of1275 := $(boot)/of1275 +images := $(boot)/images + +OBJCOPY_ARGS := -O aixcoff-rs6000 -R .stab -R .stabstr -R .comment +COFF_LD_ARGS := -T $(boot)/ld.script -e _start -Ttext 0x00700000 -Bstatic +CHRP_LD_ARGS := -T $(boot)/ld.script -e _start -Ttext 0x00800000 +NEWWORLD_LD_ARGS:= -T $(boot)/ld.script -e _start -Ttext 0x01000000 COMMONOBJS := start.o misc.o common.o COFFOBJS := coffcrt0.o $(COMMONOBJS) coffmain.o -CHRPOBJS := crt0.o $(COMMONOBJS) chrpmain.o -NEWWORLDOBJS := crt0.o $(COMMONOBJS) newworldmain.o +CHRPOBJS := crt0.o $(COMMONOBJS) chrpmain.o +NEWWORLDOBJS := crt0.o $(COMMONOBJS) newworldmain.o -EXTRA_TARGETS := $(COFFOBJS) $(CHRPOBJS) $(NEWWORLDOBJS) +targets := $(COFFOBJS) $(CHRPOBJS) $(NEWWORLDOBJS) dummy.o COFFOBJS := $(addprefix $(obj)/, $(COFFOBJS)) CHRPOBJS := $(addprefix $(obj)/, $(CHRPOBJS)) NEWWORLDOBJS := $(addprefix $(obj)/, $(NEWWORLDOBJS)) -LIBS = lib/lib.a $(bootlib)/lib.a $(of1275)/lib.a $(common)/lib.a +LIBS := lib/lib.a $(bootlib)/lib.a $(of1275)/lib.a $(common)/lib.a -ADDNOTE := $(utils)/addnote -MKNOTE := $(utils)/mknote HACKCOFF := $(utils)/hack-coff ifdef CONFIG_SMP @@ -49,108 +47,136 @@ END += .64 endif -TFTPIMAGE=/tftpboot/zImage. -$(obj)/dummy.o: $(common)/dummy.c - $(CC) -c -o $@ $(common)/dummy.c - -$(obj)/image.o: $(images)/vmlinux.gz $(obj)/dummy.o - $(OBJCOPY) $(obj)/dummy.o $@ -R .comment \ - --add-section=.image=$(images)/vmlinux.gz \ - --set-section-flags=.image=contents,alloc,load,readonly,data -ifdef CONFIG_XMON - $(OBJCOPY) $@ $@ \ - --add-section=.sysmap=$(TOPDIR)/System.map \ - --set-section-flags=.sysmap=contents,alloc,load,readonly,data -endif +$(images)/ramdisk.image.gz: + @echo ' MISSING $@' + @echo ' RAM disk image must be provided seperatly' + @/bin/false + +objcpxmon-$(CONFIG_XMON) := --add-section=.sysmap=System.map \ + --set-section-flags=.sysmap=contents,alloc,load,readonly,data +quiet_cmd_genimage = GEN $@ + cmd_genimage = $(OBJCOPY) -R .comment \ + --add-section=.image=$(images)/vmlinux.gz \ + --set-section-flags=.image=contents,alloc,load,readonly,data \ + $(objcpxmon-y) $< $@ + +targets += image.o +$(obj)/image.o: $(obj)/dummy.o $(images)/vmlinux.gz FORCE + $(call if_changed,genimage) # Place the ramdisk in the initrd image. -$(obj)/image-initrd.o: $(obj)/image.o $(images)/ramdisk.image.gz - $(OBJCOPY) $(obj)/image.o $@ \ - --add-section=.ramdisk=$(images)/ramdisk.image.gz \ - --set-section-flags=.ramdisk=contents,alloc,load,readonly,data +quiet_cmd_genimage-initrd = GEN $@ + cmd_genimage-initrd = $(OBJCOPY) $< $@ \ + --add-section=.ramdisk=$(images)/ramdisk.image.gz \ + --set-section-flags=.ramdisk=contents,alloc,load,readonly,data +targets += image.initrd.o +$(obj)/image.initrd.o: $(obj)/image.o $(images)/ramdisk.image.gz FORCE + $(call if_changed,genimage-initrd) # Create the note section for New-World PowerMacs. -$(obj)/note: $(MKNOTE) - $(MKNOTE) > $(obj)/note - -znetboot: $(images)/vmlinux.coff $(images)/vmlinux.elf-pmac $(images)/zImage.chrp - cp $(images)/vmlinux.coff $(TFTPIMAGE).pmac$(END) - cp $(images)/vmlinux.elf-pmac $(TFTPIMAGE).pmac$(END)elf - cp $(images)/zImage.chrp $(TFTPIMAGE).chrp$(END) - -znetboot.initrd: $(images)/vmlinux.initrd.coff \ - $(images)/vmlinux.initrd.elf-pmac \ - $(images)/zImage.initrd.chrp - cp $(images)/vmlinux.initrd.coff $(TFTPIMAGE).pmac$(END) - cp $(images)/vmlinux.initrd.elf-pmac $(TFTPIMAGE).pmac$(END).elf - cp $(images)/zImage.initrd.chrp $(TFTPIMAGE).chrp$(END) +quit_cmd_mknote = MKNOTE $@ + cmd_mknote = $(utils)/mknote > $@ +targets += note +$(obj)/note: $(utils)/mknote FORCE + $(call if_changed,mknote) + + +$(obj)/coffcrt0.o: EXTRA_AFLAGS := -traditional -DXCOFF +$(obj)/crt0.o: EXTRA_AFLAGS := -traditional +targets += coffcrt0.o crt0.o +$(obj)/coffcrt0.o $(obj)/crt0.o: $(common)/crt0.S FORCE + $(call if_changed_dep,as_o_S) + +quiet_cmd_gencoffb = COFF $@ + cmd_gencoffb = $(LD) -o $@ $(COFF_LD_ARGS) $(filter-out FORCE,$^) && \ + $(OBJCOPY) $@ $@ -R .comment $(del-ramdisk-sec) +targets += coffboot +$(obj)/coffboot: $(COFFOBJS) $(obj)/image.o $(LIBS) FORCE + $(call if_changed,gencoffb) +targets += coffboot.initrd +$(obj)/coffboot.initrd: $(COFFOBJS) $(obj)/image.initrd.o $(LIBS) FORCE + $(call if_changed,gencoffb) + + +quiet_cmd_gen-coff = COFF $@ + cmd_gen-coff = $(OBJCOPY) $(OBJCOPY_ARGS) $< $@ && \ + $(HACKCOFF) $@ && \ + ln -sf $(notdir $@) $(images)/zImage$(initrd).pmac + +$(images)/vmlinux.coff: $(obj)/coffboot + $(call cmd,gen-coff) + +$(images)/vmlinux.initrd.coff: $(obj)/coffboot.initrd + $(call cmd,gen-coff) + +quiet_cmd_gen-elf-pmac = ELF $@ + cmd_gen-elf-pmac = $(LD) $(NEWWORLD_LD_ARGS) -o $@ \ + $(NEWWORLDOBJS) $(LIBS) $< && \ + $(OBJCOPY) $@ $@ --add-section=.note=$(obj)/note \ + -R .comment $(del-ramdisk-sec) + +$(images)/vmlinux.elf-pmac: $(obj)/image.o $(NEWWORLDOBJS) $(LIBS) $(obj)/note + $(call cmd,gen-elf-pmac) +$(images)/vmlinux.initrd.elf-pmac: $(obj)/image.initrd.o $(NEWWORLDOBJS) \ + $(LIBS) $(obj)/note + $(call cmd,gen-elf-pmac) + +quiet_cmd_gen-chrp = CHRP $@ + cmd_gen-chrp = $(LD) $(CHRP_LD_ARGS) -o $@ $^ && \ + $(OBJCOPY) $@ $@ -R .comment $(del-ramdisk-sec) +$(images)/zImage.chrp: $(CHRPOBJS) $(obj)/image.o $(LIBS) + $(call cmd,gen-chrp) +$(images)/zImage.initrd.chrp: $(CHRPOBJS) $(obj)/image.initrd.o $(LIBS) + $(call cmd,gen-chrp) + +quiet_cmd_addnote = ADDNOTE $@ + cmd_addnote = cat $< > $@ && $(utils)/addnote $@ +$(images)/zImage.chrp-rs6k $(images)/zImage.initrd.chrp-rs6k: \ + %-rs6k: % + $(call cmd,addnote) + +quiet_cmd_gen-miboot = GEN $@ + cmd_gen-miboot = $(OBJCOPY) $(OBJCOPY_ARGS) \ + --add-section=$1=$(word 2, $^) $< $@ $(images)/miboot.image: $(obj)/dummy.o $(images)/vmlinux.gz - $(OBJCOPY) $(OBJCOPY_ARGS) --add-section=image=$(images)/vmlinux.gz \ - $(obj)/dummy.o $@ + $(call cmd,gen-miboot,image) $(images)/miboot.initrd.image: $(images)/miboot.image $(images)/ramdisk.image.gz - $(OBJCOPY) $(OBJCOPY_ARGS) \ - --add-section=initrd=$(images)/ramdisk.image.gz \ - $(images)/miboot.image $@ - -$(obj)/coffcrt0.o: $(common)/crt0.S - $(CC) $(AFLAGS) -DXCOFF -traditional -c -o $@ $(common)/crt0.S - -$(obj)/crt0.o: $(common)/crt0.S - $(CC) $(AFLAGS) -traditional -c -o $@ $(common)/crt0.S - -$(obj)/coffboot: $(COFFOBJS) $(obj)/image.o $(LIBS) - $(LD) -o $@ $(COFF_LD_ARGS) $^ - $(OBJCOPY) $@ $@ -R .comment -R .ramdisk - -$(obj)/coffboot.initrd: $(COFFOBJS) $(obj)/image-initrd.o $(LIBS) - $(LD) -o $@ $(COFF_LD_ARGS) $^ - $(OBJCOPY) $@ $@ -R .comment - -$(images)/vmlinux.coff: $(obj)/coffboot $(HACKCOFF) - $(OBJCOPY) $(OBJCOPY_ARGS) $(obj)/coffboot $@ - $(HACKCOFF) $@ - ln -sf vmlinux.coff $(images)/zImage.pmac - -$(images)/vmlinux.initrd.coff: $(obj)/coffboot.initrd $(HACKCOFF) - $(OBJCOPY) $(OBJCOPY_ARGS) $(obj)/coffboot.initrd $@ - $(HACKCOFF) $@ - ln -sf vmlinux.initrd.coff $(images)/zImage.initrd.pmac - -$(images)/vmlinux.elf-pmac: $(NEWWORLDOBJS) $(LIBS) $(obj)/image.o $(obj)/note - $(LD) $(NEWWORLD_LD_ARGS) -o $@ $(NEWWORLDOBJS) $(LIBS) $(obj)/image.o - $(OBJCOPY) $@ $@ \ - --add-section=.note=$(obj)/note -R .comment -R .ramdisk - -$(images)/vmlinux.initrd.elf-pmac: $(NEWWORLDOBJS) $(LIBS) \ - $(obj)/image-initrd.o $(obj)/note - $(LD) $(NEWWORLD_LD_ARGS) -o $@ $(NEWWORLDOBJS) $(LIBS) \ - $(obj)/image-initrd.o - $(OBJCOPY) $@ $@ \ - --add-section=.note=$(obj)/note -R .comment + $(call cmd,gen-miboot,initrd) -$(images)/zImage.chrp: $(CHRPOBJS) $(obj)/image.o $(LIBS) - $(LD) $(CHRP_LD_ARGS) -o $@ $^ - $(OBJCOPY) $@ $@ -R .comment -R .ramdisk +# The targets used on the make command-line + +.PHONY: zImage zImage.initrd +zImage: $(images)/vmlinux.coff \ + $(images)/vmlinux.elf-pmac \ + $(images)/zImage.chrp \ + $(images)/zImage.chrp-rs6k \ + $(images)/miboot.image + @echo ' kernel: $@ is ready ($<)' +zImage.initrd: $(images)/vmlinux.initrd.coff \ + $(images)/vmlinux.initrd.elf-pmac \ + $(images)/zImage.initrd.chrp \ + $(images)/zImage.initrd.chrp-rs6k \ + $(images)/miboot.initrd.image + @echo ' kernel: $@ is ready ($<)' + +TFTPIMAGE := /tftpboot/zImage. + +.PHONY: znetboot znetboot.initrd +znetboot: $(images)/vmlinux.coff \ + $(images)/vmlinux.elf-pmac \ + $(images)/zImage.chrp + cp $(images)/vmlinux.coff $(TFTPIMAGE).pmac$(END) + cp $(images)/vmlinux.elf-pmac $(TFTPIMAGE).pmac$(END).elf + cp $(images)/zImage.chrp $(TFTPIMAGE).chrp$(END) + @echo ' kernel: $@ is ready ($<)' +znetboot.initrd:$(images)/vmlinux.initrd.coff \ + $(images)/vmlinux.initrd.elf-pmac \ + $(images)/zImage.initrd.chrp + cp $(images)/vmlinux.initrd.coff $(TFTPIMAGE).pmac$(END) + cp $(images)/vmlinux.initrd.elf-pmac $(TFTPIMAGE).pmac$(END).elf + cp $(images)/zImage.initrd.chrp $(TFTPIMAGE).chrp$(END) + @echo ' kernel: $@ is ready ($<)' -$(images)/zImage.initrd.chrp: $(CHRPOBJS) $(obj)/image-initrd.o $(LIBS) - $(LD) $(CHRP_LD_ARGS) -o $@ $^ - $(OBJCOPY) $@ $@ -R .comment - -$(images)/zImage.chrp-rs6k: $(images)/zImage.chrp $(ADDNOTE) - cp $(images)/zImage.chrp $@ - $(ADDNOTE) $@ - -$(images)/zImage.initrd.chrp-rs6k: $(images)/zImage.initrd.chrp $(ADDNOTE) - cp $(images)/zImage.initrd.chrp $@ - $(ADDNOTE) $@ - -zImage: $(images)/vmlinux.coff $(images)/vmlinux.elf-pmac \ - $(images)/zImage.chrp $(images)/zImage.chrp-rs6k \ - $(images)/miboot.image - -zImage.initrd: $(images)/vmlinux.initrd.coff $(images)/vmlinux.initrd.elf-pmac\ - $(images)/zImage.initrd.chrp $(images)/zImage.initrd.chrp-rs6k\ - $(images)/miboot.initrd.image diff -urN linux-2.5.69-bk17/arch/ppc/boot/openfirmware/dummy.c linux-2.5.69-bk18/arch/ppc/boot/openfirmware/dummy.c --- linux-2.5.69-bk17/arch/ppc/boot/openfirmware/dummy.c 1969-12-31 16:00:00.000000000 -0800 +++ linux-2.5.69-bk18/arch/ppc/boot/openfirmware/dummy.c 2003-05-25 04:38:55.000000000 -0700 @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff -urN linux-2.5.69-bk17/arch/ppc/boot/prep/Makefile linux-2.5.69-bk18/arch/ppc/boot/prep/Makefile --- linux-2.5.69-bk17/arch/ppc/boot/prep/Makefile 2003-05-04 16:53:41.000000000 -0700 +++ linux-2.5.69-bk18/arch/ppc/boot/prep/Makefile 2003-05-25 04:38:55.000000000 -0700 @@ -13,74 +13,96 @@ # modified by Cort (cort@cs.nmt.edu) # -boot: zImage - -TFTPIMAGE = /tftpboot/zImage.prep +TFTPIMAGE := /tftpboot/zImage.prep ifeq ($(CONFIG_SMP),y) -TFTPIMAGE = $(TFTPBOOT).smp +TFTPIMAGE := $(TFTPBOOT).smp endif -LD_ARGS = -T $(boot)/ld.script -Ttext 0x00800000 -Bstatic -OBJCOPY_ARGS = -O elf32-powerpc -LIBS = $(common)/lib.a $(bootlib)/lib.a - boot-y := head.o misc.o boot-$(CONFIG_VGA_CONSOLE) += vreset.o kbd.o -boot := arch/ppc/boot -common := $(boot)/common -utils := $(boot)/utils -bootlib := $(boot)/lib -of1275 := $(boot)/of1275 -images := $(boot)/images -simple := $(boot)/simple +boot := arch/ppc/boot +common := $(boot)/common +utils := $(boot)/utils +bootlib := $(boot)/lib +images := $(boot)/images +simple := $(boot)/simple -EXTRA_TARGETS := $(boot-y) ../simple/legacy.o -OBJS := $(addprefix $(obj)/,$(boot-y)) $(simple)/legacy.o +OBJCOPYFLAGS := -O elf32-powerpc +LIBS := $(common)/lib.a $(bootlib)/lib.a -# Tools -MKPREP := $(utils)/mkprep +targets := $(boot-y) dummy.o ../simple/legacy.o +OBJS := $(addprefix $(obj)/,$(boot-y)) $(simple)/legacy.o # Extra include search dirs CFLAGS_kbd.o += -Idrivers/char +zImage: initrd := zImage: $(images)/zImage.prep -zImage.initrd: $(images)/zImage.initrd.prep + @echo ' kernel: $@ is ready ($<)' -$(obj)/dummy.o: $(common)/dummy.c - $(CC) -c -o $@ $(common)/dummy.c +zImage.initrd: initrd := .initrd +zImage.initrd: $(images)/zImage.initrd.prep + @echo ' kernel: $@ is ready ($<)' -$(images)/zImage.prep: $(OBJS) $(LIBS) $(boot)/ld.script $(images)/vmlinux.gz \ - $(obj)/dummy.o $(MKPREP) - $(OBJCOPY) $(OBJCOPY_ARGS) -R .comment \ - --add-section=.image=$(images)/vmlinux.gz \ - --set-section-flags=.image=contents,alloc,load,readonly,data \ - $(obj)/dummy.o $(obj)/image.o - $(LD) $(LD_ARGS) -o $(obj)/zImage $(OBJS) $(obj)/image.o $(LIBS) - $(OBJCOPY) $(OBJCOPY_ARGS) $(obj)/zImage $(obj)/zImage \ - -R .comment -R .stab -R .stabstr - $(MKPREP) -pbp $(obj)/zImage $@ - rm -f $(obj)/zImage - -$(images)/zImage.initrd.prep: $(OBJS) $(LIBS) $(boot)/ld.script \ - $(images)/vmlinux.gz $(obj)/dummy.o $(MKPREP) - $(OBJCOPY) $(OBJCOPY_ARGS) -R .comment \ - --add-section=.ramdisk=$(images)/ramdisk.image.gz \ - --set-section-flags=.ramdisk=contents,alloc,load,readonly,data \ - --add-section=.image=$(images)/vmlinux.gz \ - --set-section-flags=.image=contents,alloc,load,readonly,data \ - $(obj)/dummy.o $(obj)/image.o - $(LD) $(LD_ARGS) -o $(obj)/zImage.initrd $(OBJS) $(obj)/image.o $(LIBS) - $(OBJCOPY) $(OBJCOPY_ARGS) $(obj)/zImage.initrd $(obj)/zImage.initrd \ - -R .comment -R .stab -R .stabstr - $(MKPREP) -pbp $(obj)/zImage.initrd $@ - rm -f $(obj)/zImage.initrd +$(images)/ramdisk.image.gz: + @echo ' MISSING $@' + @echo ' RAM disk image must be provided separatly' + @/bin/false + +OBJCOPYFLAGS_image.o := \ + --add-section=.image=$(images)/vmlinux.gz \ + --set-section-flags=.image=contents,alloc,load,readonly,data +targets += image.o +$(obj)/image.o: $(obj)/dummy.o $(images)/vmlinux.gz + $(call if_changed,objcopy) + +OBJCOPYFLAGS_image.initrd.o := \ + --add-section=.ramdisk=$(images)/ramdisk.image.gz \ + --set-section-flags=.ramdisk=contents,alloc,load,readonly,data \ + --add-section=.image=$(images)/vmlinux.gz \ + --set-section-flags=.image=contents,alloc,load,readonly,data +targets += image.initrd.o +$(obj)/image.initrd.o: $(obj)/dummy.o $(images)/vmlinux.gz $(images)/ramdisk.image.gz + $(call if_changed,objcopy) + +LDFLAGS_zImage.bin := -Ttext 0x00800000 -Bstatic -T +LDFLAGS_zImage.initrd.bin := -Ttext 0x00800000 -Bstatic -T +targets += zImage.bin +$(obj)/zImage.bin: $(boot)/ld.script $(OBJS) $(obj)/image.o $(LIBS) + $(call if_changed,ld) +targets += zImage.initrd.bin +$(obj)/zImage.initrd.bin: $(boot)/ld.script $(OBJS) $(obj)/image.initrd.o $(LIBS) + $(call if_changed,ld) + +OBJCOPYFLAGS_zImage := -R .comment -R .stab -R .stabstr +OBJCOPYFLAGS_zImage.initrd := -R .comment -R .stab -R .stabstr +targets += zImage +$(obj)/zImage: %: %.bin FORCE + $(call if_changed,objcopy) +targets += zImage.initrd +$(obj)/zImage.initrd: %: %.bin FORCE + $(call if_changed,objcopy) + +quiet_cmd_mkprep = MKPREP $@ + cmd_mkprep = $(utils)/mkprep -pbp $< $@ + +$(images)/zImage.prep: $(obj)/zImage $(utils)/mkprep + $(call cmd,mkprep) +$(images)/zImage.initrd.prep: $(obj)/zImage.initrd $(utils)/mkprep + $(call cmd,mkprep) +# +# Convinient shorthands for various targets +# floppy: zImage dd if=$(images)/zImage.prep of=/dev/fd0H1440 bs=64b znetboot : zImage cp $(images)/zImage.prep $(TFTPIMAGE) + @echo ' kernel: $@ is ready ($<)' znetboot.initrd : zImage.initrd cp $(images)/zImage.initrd.prep $(TFTPIMAGE) + @echo ' kernel: $@ is ready ($<)' + diff -urN linux-2.5.69-bk17/arch/ppc/boot/prep/dummy.c linux-2.5.69-bk18/arch/ppc/boot/prep/dummy.c --- linux-2.5.69-bk17/arch/ppc/boot/prep/dummy.c 1969-12-31 16:00:00.000000000 -0800 +++ linux-2.5.69-bk18/arch/ppc/boot/prep/dummy.c 2003-05-25 04:38:55.000000000 -0700 @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff -urN linux-2.5.69-bk17/arch/ppc/boot/simple/Makefile linux-2.5.69-bk18/arch/ppc/boot/simple/Makefile --- linux-2.5.69-bk17/arch/ppc/boot/simple/Makefile 2003-05-04 16:52:48.000000000 -0700 +++ linux-2.5.69-bk18/arch/ppc/boot/simple/Makefile 2003-05-25 04:38:55.000000000 -0700 @@ -160,8 +160,7 @@ MKPREP := $(utils)/mkprep MKTREE := $(utils)/mktree -$(obj)/dummy.o: $(common)/dummy.c - $(CC) -c -o $@ $(common)/dummy.c +targets := dummy.o $(obj)/zvmlinux: $(OBJS) $(LIBS) $(boot)/ld.script $(images)/vmlinux.gz \ $(obj)/dummy.o diff -urN linux-2.5.69-bk17/arch/ppc/boot/simple/dummy.c linux-2.5.69-bk18/arch/ppc/boot/simple/dummy.c --- linux-2.5.69-bk17/arch/ppc/boot/simple/dummy.c 1969-12-31 16:00:00.000000000 -0800 +++ linux-2.5.69-bk18/arch/ppc/boot/simple/dummy.c 2003-05-25 04:38:55.000000000 -0700 @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff -urN linux-2.5.69-bk17/arch/ppc/boot/utils/Makefile linux-2.5.69-bk18/arch/ppc/boot/utils/Makefile --- linux-2.5.69-bk17/arch/ppc/boot/utils/Makefile 2003-05-04 16:53:40.000000000 -0700 +++ linux-2.5.69-bk18/arch/ppc/boot/utils/Makefile 1969-12-31 16:00:00.000000000 -0800 @@ -1,20 +0,0 @@ -# -# arch/ppc/boot/utils/Makefile -# -# This file is subject to the terms and conditions of the GNU General Public -# License. See the file "COPYING" in the main directory of this archive -# for more details. - -HOSTCFLAGS += -I$(TOPDIR)/arch/$(ARCH)/boot/include - -all: FORCE - -# Simple programs with 1 file and no extra CFLAGS -UTILS = addnote hack-coff mkprep mknote mkbugboot mktree \ - addSystemMap addRamdDisk - -$(UTILS): - $(HOSTCC) $(HOSTCFLAGS) -o $@ $@.c - -clean: - rm -f $(UTILS) diff -urN linux-2.5.69-bk17/arch/ppc/kernel/Makefile linux-2.5.69-bk18/arch/ppc/kernel/Makefile --- linux-2.5.69-bk17/arch/ppc/kernel/Makefile 2003-05-04 16:53:41.000000000 -0700 +++ linux-2.5.69-bk18/arch/ppc/kernel/Makefile 2003-05-25 04:38:55.000000000 -0700 @@ -10,12 +10,10 @@ endif # Start off with 'head.o', change as needed. -HEAD-y := head.o -HEAD-$(CONFIG_40x) := head_4xx.o -HEAD-$(CONFIG_8xx) := head_8xx.o -HEAD-$(CONFIG_6xx) += idle_6xx.o - -extra-y := $(HEAD-y) +extra-y := head.o +extra-$(CONFIG_40x) := head_4xx.o +extra-$(CONFIG_8xx) := head_8xx.o +extra-$(CONFIG_6xx) += idle_6xx.o obj-y := entry.o traps.o irq.o idle.o time.o misc.o \ process.o signal.o ptrace.o align.o \ diff -urN linux-2.5.69-bk17/arch/ppc/kernel/entry.S linux-2.5.69-bk18/arch/ppc/kernel/entry.S --- linux-2.5.69-bk17/arch/ppc/kernel/entry.S 2003-05-04 16:53:41.000000000 -0700 +++ linux-2.5.69-bk18/arch/ppc/kernel/entry.S 2003-05-25 04:38:55.000000000 -0700 @@ -531,12 +531,27 @@ resume_kernel: /* check current_thread_info->preempt_count */ rlwinm r9,r1,0,0,18 - lwz r3,TI_PREEMPT(r9) - cmpwi 0,r3,0 /* if non-zero, just restore regs and return */ + lwz r0,TI_PREEMPT(r9) + cmpwi 0,r0,0 /* if non-zero, just restore regs and return */ bne restore - lwz r9,TI_FLAGS(r9) - andi. r0,r9,_TIF_NEED_RESCHED - bne do_resched + lwz r0,TI_FLAGS(r9) + andi. r0,r0,_TIF_NEED_RESCHED + beq+ restore + andi. r0,r3,MSR_EE /* interrupts off? */ + beq restore /* don't schedule if so */ +1: lis r0,PREEMPT_ACTIVE@h + stw r0,TI_PREEMPT(r9) + ori r10,r10,MSR_EE + SYNC + MTMSRD(r10) /* hard-enable interrupts */ + bl schedule + LOAD_MSR_KERNEL(r10,MSR_KERNEL) + SYNC + MTMSRD(r10) /* disable interrupts */ + rlwinm r9,r1,0,0,18 + lwz r0,TI_FLAGS(r9) + andi. r0,r0,_TIF_NEED_RESCHED + bne- 1b #else resume_kernel: #endif /* CONFIG_PREEMPT */ @@ -740,13 +755,6 @@ lwz r9,TI_FLAGS(r9) andi. r0,r9,_TIF_NEED_RESCHED bne- do_resched - -#ifdef CONFIG_PREEMPT - lwz r0,_MSR(r1) - andi. r0,r0,MSR_PR - beq restore -#endif - andi. r0,r9,_TIF_SIGPENDING beq restore_user do_user_signal: /* r10 contains MSR_KERNEL here */ diff -urN linux-2.5.69-bk17/arch/ppc/kernel/l2cr.S linux-2.5.69-bk18/arch/ppc/kernel/l2cr.S --- linux-2.5.69-bk17/arch/ppc/kernel/l2cr.S 2003-05-04 16:53:32.000000000 -0700 +++ linux-2.5.69-bk18/arch/ppc/kernel/l2cr.S 2003-05-25 04:38:55.000000000 -0700 @@ -272,10 +272,6 @@ blr END_FTR_SECTION_IFCLR(CPU_FTR_L3CR) - /* Stop DST streams */ - DSSALL - sync - /* Turn off interrupts and data relocation. */ mfmsr r7 /* Save MSR in r7 */ rlwinm r4,r7,0,17,15 @@ -284,6 +280,10 @@ mtmsr r4 isync + /* Stop DST streams */ + DSSALL + sync + /* Get the current enable bit of the L3CR into r4 */ mfspr r4,SPRN_L3CR diff -urN linux-2.5.69-bk17/arch/ppc/kernel/misc.S linux-2.5.69-bk18/arch/ppc/kernel/misc.S --- linux-2.5.69-bk17/arch/ppc/kernel/misc.S 2003-05-04 16:53:41.000000000 -0700 +++ linux-2.5.69-bk18/arch/ppc/kernel/misc.S 2003-05-25 04:38:55.000000000 -0700 @@ -534,7 +534,7 @@ isync lis r5, IDC_INVALL@h mtspr IC_CST, r5 -#elif defined(CONFIG_40x) +#elif defined(CONFIG_4xx) #ifdef CONFIG_403GCX li r3, 512 mtctr r3 @@ -1365,13 +1365,13 @@ .long sys_epoll_create .long sys_epoll_ctl .long sys_epoll_wait - .long sys_remap_file_pages - .long sys_timer_create /* 240 */ - .long sys_timer_settime - .long sys_timer_gettime - .long sys_timer_getoverrun - .long sys_timer_delete - .long sys_clock_settime /* 245 */ - .long sys_clock_gettime - .long sys_clock_getres - .long sys_clock_nanosleep + .long sys_remap_file_pages + .long sys_timer_create /* 240 */ + .long sys_timer_settime + .long sys_timer_gettime + .long sys_timer_getoverrun + .long sys_timer_delete + .long sys_clock_settime /* 245 */ + .long sys_clock_gettime + .long sys_clock_getres + .long sys_clock_nanosleep diff -urN linux-2.5.69-bk17/arch/ppc/kernel/pci-dma.c linux-2.5.69-bk18/arch/ppc/kernel/pci-dma.c --- linux-2.5.69-bk17/arch/ppc/kernel/pci-dma.c 2003-05-04 16:53:03.000000000 -0700 +++ linux-2.5.69-bk18/arch/ppc/kernel/pci-dma.c 2003-05-25 04:38:55.000000000 -0700 @@ -22,6 +22,7 @@ if (hwdev == NULL || hwdev->dma_mask != 0xffffffff) gfp |= GFP_DMA; + #ifdef CONFIG_NOT_COHERENT_CACHE ret = consistent_alloc(gfp, size, dma_handle); #else @@ -30,7 +31,9 @@ if (ret != NULL) { memset(ret, 0, size); +#ifndef CONFIG_NOT_COHERENT_CACHE *dma_handle = virt_to_bus(ret); +#endif } return ret; } diff -urN linux-2.5.69-bk17/arch/ppc/kernel/ppc_ksyms.c linux-2.5.69-bk18/arch/ppc/kernel/ppc_ksyms.c --- linux-2.5.69-bk17/arch/ppc/kernel/ppc_ksyms.c 2003-05-04 16:53:41.000000000 -0700 +++ linux-2.5.69-bk18/arch/ppc/kernel/ppc_ksyms.c 2003-05-25 04:38:55.000000000 -0700 @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -156,6 +157,7 @@ EXPORT_SYMBOL(ioremap); EXPORT_SYMBOL(__ioremap); EXPORT_SYMBOL(iounmap); +EXPORT_SYMBOL(ioremap_bot); /* aka VMALLOC_END */ #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) EXPORT_SYMBOL(ppc_ide_md); @@ -197,6 +199,7 @@ EXPORT_SYMBOL(flush_dcache_range); EXPORT_SYMBOL(flush_icache_user_range); EXPORT_SYMBOL(flush_dcache_page); +EXPORT_SYMBOL(flush_tlb_kernel_range); #ifdef CONFIG_ALTIVEC EXPORT_SYMBOL(last_task_used_altivec); EXPORT_SYMBOL(giveup_altivec); diff -urN linux-2.5.69-bk17/arch/ppc/kernel/smp.c linux-2.5.69-bk18/arch/ppc/kernel/smp.c --- linux-2.5.69-bk17/arch/ppc/kernel/smp.c 2003-05-25 04:38:49.000000000 -0700 +++ linux-2.5.69-bk18/arch/ppc/kernel/smp.c 2003-05-25 04:38:55.000000000 -0700 @@ -406,6 +406,7 @@ p = copy_process(CLONE_VM|CLONE_IDLETASK, 0, ®s, 0, NULL, NULL); if (IS_ERR(p)) panic("failed fork for CPU %u: %li", cpu, PTR_ERR(p)); + wake_up_forked_process(p); init_idle(p, cpu); unhash_process(p); diff -urN linux-2.5.69-bk17/arch/ppc/mm/cachemap.c linux-2.5.69-bk18/arch/ppc/mm/cachemap.c --- linux-2.5.69-bk17/arch/ppc/mm/cachemap.c 2003-05-04 16:53:57.000000000 -0700 +++ linux-2.5.69-bk18/arch/ppc/mm/cachemap.c 2003-05-25 04:38:55.000000000 -0700 @@ -2,7 +2,7 @@ * PowerPC version derived from arch/arm/mm/consistent.c * Copyright (C) 2001 Dan Malek (dmalek@jlc.net) * - * arch/arm/mm/consistent.c + * arch/ppc/mm/cachemap.c * * Copyright (C) 2000 Russell King * @@ -59,57 +59,69 @@ */ void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle) { - int order, err, i; - unsigned long page, va, pa, flags; - struct vm_struct *area; - void *ret; + int order, err; + struct page *page, *free, *end; + unsigned long pa, flags, offset; + struct vm_struct *area = NULL; + unsigned long va = 0; - if (in_interrupt()) - BUG(); + BUG_ON(in_interrupt()); - /* Only allocate page size areas. - */ + /* Only allocate page size areas */ size = PAGE_ALIGN(size); order = get_order(size); - page = __get_free_pages(gfp, order); - if (!page) { - BUG(); + free = page = alloc_pages(gfp, order); + if (! page) return NULL; - } + + pa = page_to_phys(page); + *dma_handle = page_to_bus(page); + end = page + (1 << order); /* * we need to ensure that there are no cachelines in use, * or worse dirty in this area. */ - invalidate_dcache_range(page, page + size); + invalidate_dcache_range((unsigned long)page_address(page), + (unsigned long)page_address(page) + size); - /* Allocate some common virtual space to map the new pages. - */ + /* + * alloc_pages() expects the block to be handled as a unit, so + * it only sets the page count on the first page. We set the + * counts on each page so they can be freed individually + */ + for (; page < end; page++) + set_page_count(page, 1); + + + /* Allocate some common virtual space to map the new pages*/ area = get_vm_area(size, VM_ALLOC); - if (area == 0) { - free_pages(page, order); - return NULL; - } - va = VMALLOC_VMADDR(area->addr); - ret = (void *)va; + if (! area) + goto out; - /* This gives us the real physical address of the first page. - */ - *dma_handle = pa = virt_to_bus((void *)page); + va = VMALLOC_VMADDR(area->addr); flags = _PAGE_KERNEL | _PAGE_NO_CACHE; - - err = 0; - for (i = 0; i < size && err == 0; i += PAGE_SIZE) - err = map_page(va+i, pa+i, flags); - if (err) { - vfree((void *)va); - return NULL; + for (offset = 0; offset < size; offset += PAGE_SIZE) { + err = map_page(va+offset, pa+offset, flags); + if (err) { + vfree((void *)va); + va = 0; + goto out; + } + + free++; + } + + out: + /* Free pages which weren't mapped */ + for (; free < end; free++) { + __free_page(free); } - return ret; + return (void *)va; } /* @@ -117,8 +129,7 @@ */ void consistent_free(void *vaddr) { - if (in_interrupt()) - BUG(); + BUG_ON(in_interrupt()); vfree(vaddr); } @@ -155,6 +166,6 @@ { unsigned long start; - start = page_address(page) + offset; + start = (unsigned long)page_address(page) + offset; consistent_sync((void *)start, size, direction); } diff -urN linux-2.5.69-bk17/arch/ppc/ocp/Makefile linux-2.5.69-bk18/arch/ppc/ocp/Makefile --- linux-2.5.69-bk17/arch/ppc/ocp/Makefile 2003-05-04 16:53:09.000000000 -0700 +++ linux-2.5.69-bk18/arch/ppc/ocp/Makefile 2003-05-25 04:38:55.000000000 -0700 @@ -1,13 +1,6 @@ # # Makefile for the linux kernel. # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# -# Note 2! The CFLAGS definitions are now in the main makefile... -# -# NB: cribbed from the drivers/sbus/Makefile -- PMM -obj-y += ocp.o ocp-driver.o ocp-probe.o +obj-y := ocp.o ocp-driver.o ocp-probe.o diff -urN linux-2.5.69-bk17/arch/ppc/syslib/open_pic.c linux-2.5.69-bk18/arch/ppc/syslib/open_pic.c --- linux-2.5.69-bk17/arch/ppc/syslib/open_pic.c 2003-05-04 16:53:32.000000000 -0700 +++ linux-2.5.69-bk18/arch/ppc/syslib/open_pic.c 2003-05-25 04:38:55.000000000 -0700 @@ -55,7 +55,7 @@ #ifdef CONFIG_SMP /* Interprocessor Interrupts */ static void openpic_initipi(u_int ipi, u_int pri, u_int vector); -static void openpic_ipi_action(int cpl, void *dev_id, struct pt_regs *regs); +static irqreturn_t openpic_ipi_action(int cpl, void *dev_id, struct pt_regs *); #endif /* Timer Interrupts */ diff -urN linux-2.5.69-bk17/drivers/block/deadline-iosched.c linux-2.5.69-bk18/drivers/block/deadline-iosched.c --- linux-2.5.69-bk17/drivers/block/deadline-iosched.c 2003-05-25 04:38:50.000000000 -0700 +++ linux-2.5.69-bk18/drivers/block/deadline-iosched.c 2003-05-25 04:38:55.000000000 -0700 @@ -313,11 +313,6 @@ deadline_del_drq_hash(drq); deadline_del_drq_rb(dd, drq); } - - if (q->last_merge == &rq->queuelist) - q->last_merge = NULL; - - list_del_init(&rq->queuelist); } static int diff -urN linux-2.5.69-bk17/drivers/block/elevator.c linux-2.5.69-bk18/drivers/block/elevator.c --- linux-2.5.69-bk17/drivers/block/elevator.c 2003-05-25 04:38:50.000000000 -0700 +++ linux-2.5.69-bk18/drivers/block/elevator.c 2003-05-25 04:38:55.000000000 -0700 @@ -39,63 +39,6 @@ #include /* - * This is a bit tricky. It's given that bio and rq are for the same - * device, but the next request might of course not be. Run through - * the tests below to check if we want to insert here if we can't merge - * bio into an existing request - */ -inline int bio_rq_in_between(struct bio *bio, struct request *rq, - struct list_head *head) -{ - struct list_head *next; - struct request *next_rq; - - /* - * if .next is a valid request - */ - next = rq->queuelist.next; - if (unlikely(next == head)) - return 0; - - next_rq = list_entry(next, struct request, queuelist); - - /* - * not a sector based request - */ - if (!(next_rq->flags & REQ_CMD)) - return 0; - - /* - * if the device is different (not a normal case) just check if - * bio is after rq - */ - if (next_rq->rq_disk != rq->rq_disk) - return bio->bi_sector > rq->sector; - - /* - * ok, rq, next_rq and bio are on the same device. if bio is in between - * the two, this is the sweet spot - */ - if (bio->bi_sector < next_rq->sector && bio->bi_sector > rq->sector) - return 1; - - /* - * next_rq is ordered wrt rq, but bio is not in between the two - */ - if (next_rq->sector > rq->sector) - return 0; - - /* - * next_rq and rq not ordered, if we happen to be either before - * next_rq or after rq insert here anyway - */ - if (bio->bi_sector > rq->sector || bio->bi_sector < next_rq->sector) - return 1; - - return 0; -} - -/* * can we safely merge with this request? */ inline int elv_rq_merge_ok(struct request *rq, struct bio *bio) @@ -138,22 +81,10 @@ inline int elv_try_last_merge(request_queue_t *q, struct bio *bio) { - int ret = ELEVATOR_NO_MERGE; - - /* - * give a one-shot try to merging with the last touched - * request - */ - if (q->last_merge) { - struct request *__rq = list_entry_rq(q->last_merge); + if (q->last_merge) + return elv_try_merge(list_entry_rq(q->last_merge), bio); - if (!rq_mergeable(__rq)) - q->last_merge = NULL; - else - ret = elv_try_merge(__rq, bio); - } - - return ret; + return ELEVATOR_NO_MERGE; } /* @@ -181,7 +112,7 @@ else if (__rq->flags & REQ_STARTED) break; - if (!(__rq->flags & REQ_CMD)) + if (!blk_fs_request(__rq)) continue; if ((ret = elv_try_merge(__rq, bio))) { @@ -276,6 +207,9 @@ { elevator_t *e = &q->elevator; + if (q->last_merge == &next->queuelist) + q->last_merge = NULL; + if (e->elevator_merge_req_fn) e->elevator_merge_req_fn(q, rq, next); } diff -urN linux-2.5.69-bk17/drivers/char/drm/Kconfig linux-2.5.69-bk18/drivers/char/drm/Kconfig --- linux-2.5.69-bk17/drivers/char/drm/Kconfig 2003-05-25 04:38:50.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/drm/Kconfig 2003-05-25 04:38:55.000000000 -0700 @@ -24,10 +24,10 @@ config DRM_GAMMA tristate "3dlabs GMX 2000" - depends on DRM && n + depends on DRM help - This is the old gamma driver, disabled for now unless somebody - tells me it actually might work. + This is the old gamma driver, please tell me if it might actually + work. config DRM_R128 tristate "ATI Rage 128" diff -urN linux-2.5.69-bk17/drivers/char/drm/drmP.h linux-2.5.69-bk18/drivers/char/drm/drmP.h --- linux-2.5.69-bk17/drivers/char/drm/drmP.h 2003-05-25 04:38:50.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/drm/drmP.h 2003-05-25 04:38:55.000000000 -0700 @@ -225,16 +225,16 @@ if (len > DRM_PROC_LIMIT) { ret; *eof = 1; return len - offset; } /* Mapping helper macros */ -#define DRM_IOREMAP(map) \ - (map)->handle = DRM(ioremap)( (map)->offset, (map)->size ) +#define DRM_IOREMAP(map, dev) \ + (map)->handle = DRM(ioremap)( (map)->offset, (map)->size, (dev) ) -#define DRM_IOREMAP_NOCACHE(map) \ - (map)->handle = DRM(ioremap_nocache)((map)->offset, (map)->size) +#define DRM_IOREMAP_NOCACHE(map, dev) \ + (map)->handle = DRM(ioremap_nocache)((map)->offset, (map)->size, (dev)) -#define DRM_IOREMAPFREE(map) \ - do { \ - if ( (map)->handle && (map)->size ) \ - DRM(ioremapfree)( (map)->handle, (map)->size ); \ +#define DRM_IOREMAPFREE(map, dev) \ + do { \ + if ( (map)->handle && (map)->size ) \ + DRM(ioremapfree)( (map)->handle, (map)->size, (dev) ); \ } while (0) #define DRM_FIND_MAP(_map, _o) \ @@ -652,9 +652,9 @@ extern unsigned long DRM(alloc_pages)(int order, int area); extern void DRM(free_pages)(unsigned long address, int order, int area); -extern void *DRM(ioremap)(unsigned long offset, unsigned long size); -extern void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size); -extern void DRM(ioremapfree)(void *pt, unsigned long size); +extern void *DRM(ioremap)(unsigned long offset, unsigned long size, drm_device_t *dev); +extern void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size, drm_device_t *dev); +extern void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev); #if __REALLY_HAVE_AGP extern struct agp_memory *DRM(alloc_agp)(int pages, u32 type); diff -urN linux-2.5.69-bk17/drivers/char/drm/drm_bufs.h linux-2.5.69-bk18/drivers/char/drm/drm_bufs.h --- linux-2.5.69-bk17/drivers/char/drm/drm_bufs.h 2003-05-04 16:53:08.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/drm/drm_bufs.h 2003-05-25 04:38:55.000000000 -0700 @@ -123,7 +123,7 @@ MTRR_TYPE_WRCOMB, 1 ); } #endif - map->handle = DRM(ioremap)( map->offset, map->size ); + map->handle = DRM(ioremap)( map->offset, map->size, dev ); break; case _DRM_SHM: @@ -245,7 +245,7 @@ DRM_DEBUG("mtrr_del = %d\n", retcode); } #endif - DRM(ioremapfree)(map->handle, map->size); + DRM(ioremapfree)(map->handle, map->size, dev); break; case _DRM_SHM: vfree(map->handle); diff -urN linux-2.5.69-bk17/drivers/char/drm/drm_drv.h linux-2.5.69-bk18/drivers/char/drm/drm_drv.h --- linux-2.5.69-bk17/drivers/char/drm/drm_drv.h 2003-05-25 04:38:50.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/drm/drm_drv.h 2003-05-25 04:38:55.000000000 -0700 @@ -453,7 +453,7 @@ DRM_DEBUG( "mtrr_del=%d\n", retcode ); } #endif - DRM(ioremapfree)( map->handle, map->size ); + DRM(ioremapfree)( map->handle, map->size, dev ); break; case _DRM_SHM: vfree(map->handle); @@ -559,7 +559,9 @@ drm_device_t *dev; int i; +#if __HAVE_CTX_BITMAP int retcode; +#endif DRM_DEBUG( "\n" ); #ifdef MODULE diff -urN linux-2.5.69-bk17/drivers/char/drm/drm_lists.h linux-2.5.69-bk18/drivers/char/drm/drm_lists.h --- linux-2.5.69-bk17/drivers/char/drm/drm_lists.h 2003-05-04 16:53:37.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/drm/drm_lists.h 1969-12-31 16:00:00.000000000 -0800 @@ -1,229 +0,0 @@ -/* drm_lists.h -- Buffer list handling routines -*- linux-c -*- - * Created: Mon Apr 19 20:54:22 1999 by faith@valinux.com - * - * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. - * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Rickard E. (Rik) Faith - * Gareth Hughes - */ - -#include "drmP.h" - -#if __HAVE_DMA_WAITLIST - -int DRM(waitlist_create)(drm_waitlist_t *bl, int count) -{ - if (bl->count) return -EINVAL; - - bl->bufs = DRM(alloc)((bl->count + 2) * sizeof(*bl->bufs), - DRM_MEM_BUFLISTS); - - if(!bl->bufs) return -ENOMEM; - memset(bl->bufs, 0, sizeof(*bl->bufs)); - bl->count = count; - bl->rp = bl->bufs; - bl->wp = bl->bufs; - bl->end = &bl->bufs[bl->count+1]; - bl->write_lock = SPIN_LOCK_UNLOCKED; - bl->read_lock = SPIN_LOCK_UNLOCKED; - return 0; -} - -int DRM(waitlist_destroy)(drm_waitlist_t *bl) -{ - if (bl->rp != bl->wp) return -EINVAL; - if (bl->bufs) DRM(free)(bl->bufs, - (bl->count + 2) * sizeof(*bl->bufs), - DRM_MEM_BUFLISTS); - bl->count = 0; - bl->bufs = NULL; - bl->rp = NULL; - bl->wp = NULL; - bl->end = NULL; - return 0; -} - -int DRM(waitlist_put)(drm_waitlist_t *bl, drm_buf_t *buf) -{ - int left; - unsigned long flags; - - left = DRM_LEFTCOUNT(bl); - if (!left) { - DRM_ERROR("Overflow while adding buffer %d from filp %p\n", - buf->idx, buf->filp); - return -EINVAL; - } -#if __HAVE_DMA_HISTOGRAM - buf->time_queued = get_cycles(); -#endif - buf->list = DRM_LIST_WAIT; - - spin_lock_irqsave(&bl->write_lock, flags); - *bl->wp = buf; - if (++bl->wp >= bl->end) bl->wp = bl->bufs; - spin_unlock_irqrestore(&bl->write_lock, flags); - - return 0; -} - -drm_buf_t *DRM(waitlist_get)(drm_waitlist_t *bl) -{ - drm_buf_t *buf; - unsigned long flags; - - spin_lock_irqsave(&bl->read_lock, flags); - buf = *bl->rp; - if (bl->rp == bl->wp) { - spin_unlock_irqrestore(&bl->read_lock, flags); - return NULL; - } - if (++bl->rp >= bl->end) bl->rp = bl->bufs; - spin_unlock_irqrestore(&bl->read_lock, flags); - - return buf; -} - -#endif /* __HAVE_DMA_WAITLIST */ - - -#if __HAVE_DMA_FREELIST - -int DRM(freelist_create)(drm_freelist_t *bl, int count) -{ - atomic_set(&bl->count, 0); - bl->next = NULL; - init_waitqueue_head(&bl->waiting); - bl->low_mark = 0; - bl->high_mark = 0; - atomic_set(&bl->wfh, 0); - bl->lock = SPIN_LOCK_UNLOCKED; - ++bl->initialized; - return 0; -} - -int DRM(freelist_destroy)(drm_freelist_t *bl) -{ - atomic_set(&bl->count, 0); - bl->next = NULL; - return 0; -} - -int DRM(freelist_put)(drm_device_t *dev, drm_freelist_t *bl, drm_buf_t *buf) -{ - drm_device_dma_t *dma = dev->dma; - - if (!dma) { - DRM_ERROR("No DMA support\n"); - return 1; - } - - if (buf->waiting || buf->pending || buf->list == DRM_LIST_FREE) { - DRM_ERROR("Freed buffer %d: w%d, p%d, l%d\n", - buf->idx, buf->waiting, buf->pending, buf->list); - } - if (!bl) return 1; -#if __HAVE_DMA_HISTOGRAM - buf->time_freed = get_cycles(); - DRM(histogram_compute)(dev, buf); -#endif - buf->list = DRM_LIST_FREE; - - spin_lock(&bl->lock); - buf->next = bl->next; - bl->next = buf; - spin_unlock(&bl->lock); - - atomic_inc(&bl->count); - if (atomic_read(&bl->count) > dma->buf_count) { - DRM_ERROR("%d of %d buffers free after addition of %d\n", - atomic_read(&bl->count), dma->buf_count, buf->idx); - return 1; - } - /* Check for high water mark */ - if (atomic_read(&bl->wfh) && atomic_read(&bl->count)>=bl->high_mark) { - atomic_set(&bl->wfh, 0); - wake_up_interruptible(&bl->waiting); - } - return 0; -} - -static drm_buf_t *DRM(freelist_try)(drm_freelist_t *bl) -{ - drm_buf_t *buf; - - if (!bl) return NULL; - - /* Get buffer */ - spin_lock(&bl->lock); - if (!bl->next) { - spin_unlock(&bl->lock); - return NULL; - } - buf = bl->next; - bl->next = bl->next->next; - spin_unlock(&bl->lock); - - atomic_dec(&bl->count); - buf->next = NULL; - buf->list = DRM_LIST_NONE; - if (buf->waiting || buf->pending) { - DRM_ERROR("Free buffer %d: w%d, p%d, l%d\n", - buf->idx, buf->waiting, buf->pending, buf->list); - } - - return buf; -} - -drm_buf_t *DRM(freelist_get)(drm_freelist_t *bl, int block) -{ - drm_buf_t *buf = NULL; - DECLARE_WAITQUEUE(entry, current); - - if (!bl || !bl->initialized) return NULL; - - /* Check for low water mark */ - if (atomic_read(&bl->count) <= bl->low_mark) /* Became low */ - atomic_set(&bl->wfh, 1); - if (atomic_read(&bl->wfh)) { - if (block) { - add_wait_queue(&bl->waiting, &entry); - for (;;) { - current->state = TASK_INTERRUPTIBLE; - if (!atomic_read(&bl->wfh) - && (buf = DRM(freelist_try)(bl))) break; - schedule(); - if (signal_pending(current)) break; - } - current->state = TASK_RUNNING; - remove_wait_queue(&bl->waiting, &entry); - } - return buf; - } - - return DRM(freelist_try)(bl); -} - -#endif /* __HAVE_DMA_FREELIST */ diff -urN linux-2.5.69-bk17/drivers/char/drm/drm_memory.h linux-2.5.69-bk18/drivers/char/drm/drm_memory.h --- linux-2.5.69-bk17/drivers/char/drm/drm_memory.h 2003-05-25 04:38:50.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/drm/drm_memory.h 2003-05-25 04:38:55.000000000 -0700 @@ -38,6 +38,151 @@ */ #define DEBUG_MEMORY 0 +#if __REALLY_HAVE_AGP + +#include + +#ifdef HAVE_PAGE_AGP +#include +#else +# ifdef __powerpc__ +# define PAGE_AGP __pgprot(_PAGE_KERNEL | _PAGE_NO_CACHE) +# else +# define PAGE_AGP PAGE_KERNEL +# endif +#endif + +#include + +/* + * Find the drm_map that covers the range [offset, offset+size). + */ +static inline drm_map_t * +drm_lookup_map (unsigned long offset, unsigned long size, drm_device_t *dev) +{ + struct list_head *list; + drm_map_list_t *r_list; + drm_map_t *map; + + list_for_each(list, &dev->maplist->head) { + r_list = (drm_map_list_t *) list; + map = r_list->map; + if (!map) + continue; + if (map->offset <= offset && (offset + size) <= (map->offset + map->size)) + return map; + } + return NULL; +} + +static inline void * +agp_remap (unsigned long offset, unsigned long size, drm_device_t *dev) +{ + unsigned long *phys_addr_map, i, num_pages = PAGE_ALIGN(size) / PAGE_SIZE; + struct drm_agp_mem *agpmem; + struct page **page_map; + void *addr; + + size = PAGE_ALIGN(size); + +#ifdef __alpha__ + offset -= dev->hose->mem_space->start; +#endif + + for (agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next) + if (agpmem->bound <= offset + && (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >= (offset + size)) + break; + if (!agpmem) + return NULL; + + /* + * OK, we're mapping AGP space on a chipset/platform on which memory accesses by + * the CPU do not get remapped by the GART. We fix this by using the kernel's + * page-table instead (that's probably faster anyhow...). + */ + /* note: use vmalloc() because num_pages could be large... */ + page_map = vmalloc(num_pages * sizeof(struct page *)); + if (!page_map) + return NULL; + + phys_addr_map = agpmem->memory->memory + (offset - agpmem->bound) / PAGE_SIZE; + for (i = 0; i < num_pages; ++i) + page_map[i] = pfn_to_page(phys_addr_map[i] >> PAGE_SHIFT); + addr = vmap(page_map, num_pages, VM_IOREMAP, PAGE_AGP); + vfree(page_map); + if (!addr) + return NULL; + + flush_tlb_kernel_range((unsigned long) addr, (unsigned long) addr + size); + return addr; +} + +static inline unsigned long +drm_follow_page (void *vaddr) +{ + pgd_t *pgd = pgd_offset_k((unsigned long) vaddr); + pmd_t *pmd = pmd_offset(pgd, (unsigned long) vaddr); + pte_t *ptep = pte_offset_kernel(pmd, (unsigned long) vaddr); + return pte_pfn(*ptep) << PAGE_SHIFT; +} + +#endif /* __REALLY_HAVE_AGP */ + +static inline void *drm_ioremap(unsigned long offset, unsigned long size, drm_device_t *dev) +{ +#if __REALLY_HAVE_AGP + if (dev->agp && dev->agp->cant_use_aperture) { + drm_map_t *map = drm_lookup_map(offset, size, dev); + + if (map && map->type == _DRM_AGP) + return agp_remap(offset, size, dev); + } +#endif + + return ioremap(offset, size); +} + +static inline void *drm_ioremap_nocache(unsigned long offset, unsigned long size, + drm_device_t *dev) +{ +#if __REALLY_HAVE_AGP + if (dev->agp && dev->agp->cant_use_aperture) { + drm_map_t *map = drm_lookup_map(offset, size, dev); + + if (map && map->type == _DRM_AGP) + return agp_remap(offset, size, dev); + } +#endif + + return ioremap_nocache(offset, size); +} + +static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *dev) +{ +#if __REALLY_HAVE_AGP + /* + * This is a bit ugly. It would be much cleaner if the DRM API would use separate + * routines for handling mappings in the AGP space. Hopefully this can be done in + * a future revision of the interface... + */ + if (dev->agp && dev->agp->cant_use_aperture + && ((unsigned long) pt >= VMALLOC_START && (unsigned long) pt < VMALLOC_END)) + { + unsigned long offset; + drm_map_t *map; + + offset = drm_follow_page(pt) | ((unsigned long) pt & ~PAGE_MASK); + map = drm_lookup_map(offset, size, dev); + if (map && map->type == _DRM_AGP) { + vunmap(pt); + return; + } + } +#endif + + iounmap(pt); +} #if DEBUG_MEMORY #include "drm_memory_debug.h" @@ -118,19 +263,19 @@ free_pages(address, order); } -void *DRM(ioremap)(unsigned long offset, unsigned long size) +void *DRM(ioremap)(unsigned long offset, unsigned long size, drm_device_t *dev) { - return ioremap(offset, size); + return drm_ioremap(offset, size, dev); } -void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size) +void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size, drm_device_t *dev) { - return ioremap_nocache(offset, size); + return drm_ioremap_nocache(offset, size, dev); } -void DRM(ioremapfree)(void *pt, unsigned long size) +void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev) { - iounmap(pt); + drm_ioremapfree(pt, size, dev); } #if __REALLY_HAVE_AGP diff -urN linux-2.5.69-bk17/drivers/char/drm/drm_memory_debug.h linux-2.5.69-bk18/drivers/char/drm/drm_memory_debug.h --- linux-2.5.69-bk17/drivers/char/drm/drm_memory_debug.h 2003-05-04 16:53:02.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/drm/drm_memory_debug.h 2003-05-25 04:38:55.000000000 -0700 @@ -269,7 +269,7 @@ } } -void *DRM(ioremap)(unsigned long offset, unsigned long size) +void *DRM(ioremap)(unsigned long offset, unsigned long size, drm_device_t *dev) { void *pt; @@ -279,7 +279,7 @@ return NULL; } - if (!(pt = ioremap(offset, size))) { + if (!(pt = drm_ioremap(offset, size, dev))) { spin_lock(&DRM(mem_lock)); ++DRM(mem_stats)[DRM_MEM_MAPPINGS].fail_count; spin_unlock(&DRM(mem_lock)); @@ -292,7 +292,7 @@ return pt; } -void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size) +void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size, drm_device_t *dev) { void *pt; @@ -302,7 +302,7 @@ return NULL; } - if (!(pt = ioremap_nocache(offset, size))) { + if (!(pt = drm_ioremap_nocache(offset, size, dev))) { spin_lock(&DRM(mem_lock)); ++DRM(mem_stats)[DRM_MEM_MAPPINGS].fail_count; spin_unlock(&DRM(mem_lock)); @@ -315,7 +315,7 @@ return pt; } -void DRM(ioremapfree)(void *pt, unsigned long size) +void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev) { int alloc_count; int free_count; @@ -324,7 +324,7 @@ DRM_MEM_ERROR(DRM_MEM_MAPPINGS, "Attempt to free NULL pointer\n"); else - iounmap(pt); + drm_ioremapfree(pt, size, dev); spin_lock(&DRM(mem_lock)); DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_freed += size; diff -urN linux-2.5.69-bk17/drivers/char/drm/drm_proc.h linux-2.5.69-bk18/drivers/char/drm/drm_proc.h --- linux-2.5.69-bk17/drivers/char/drm/drm_proc.h 2003-05-04 16:53:02.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/drm/drm_proc.h 2003-05-25 04:38:55.000000000 -0700 @@ -378,8 +378,6 @@ #if DRM_DEBUG_CODE -#define DRM_VMA_VERBOSE 0 - static int DRM(_vma_info)(char *buf, char **start, off_t offset, int request, int *eof, void *data) { @@ -387,13 +385,6 @@ int len = 0; drm_vma_entry_t *pt; struct vm_area_struct *vma; -#if DRM_VMA_VERBOSE - unsigned long i; - unsigned long address; - pgd_t *pgd; - pmd_t *pmd; - pte_t *pte; -#endif #if defined(__i386__) unsigned int pgprot; #endif diff -urN linux-2.5.69-bk17/drivers/char/drm/drm_vm.h linux-2.5.69-bk18/drivers/char/drm/drm_vm.h --- linux-2.5.69-bk17/drivers/char/drm/drm_vm.h 2003-05-04 16:53:57.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/drm/drm_vm.h 2003-05-25 04:38:55.000000000 -0700 @@ -107,12 +107,12 @@ * Get the page, inc the use count, and return it */ offset = (baddr - agpmem->bound) >> PAGE_SHIFT; - agpmem->memory->memory[offset] &= dev->agp->page_mask; page = virt_to_page(__va(agpmem->memory->memory[offset])); get_page(page); - DRM_DEBUG("baddr = 0x%lx page = 0x%p, offset = 0x%lx\n", - baddr, __va(agpmem->memory->memory[offset]), offset); + DRM_DEBUG("baddr = 0x%lx page = 0x%p, offset = 0x%lx, count=%d\n", + baddr, __va(agpmem->memory->memory[offset]), offset, + atomic_read(&page->count)); return page; } @@ -206,7 +206,7 @@ DRM_DEBUG("mtrr_del = %d\n", retcode); } #endif - DRM(ioremapfree)(map->handle, map->size); + DRM(ioremapfree)(map->handle, map->size, dev); break; case _DRM_SHM: vfree(map->handle); @@ -380,7 +380,16 @@ if ( !priv->authenticated ) return -EACCES; - if (!VM_OFFSET(vma)) return DRM(mmap_dma)(filp, vma); + /* We check for "dma". On Apple's UniNorth, it's valid to have + * the AGP mapped at physical address 0 + * --BenH. + */ + if (!VM_OFFSET(vma) +#if __REALLY_HAVE_AGP + && (!dev->agp || dev->agp->agp_info.device->vendor != PCI_VENDOR_ID_APPLE) +#endif + ) + return DRM(mmap_dma)(filp, vma); /* A sequential search of a linked list is fine here because: 1) there will only be @@ -406,7 +415,7 @@ if (map->size != vma->vm_end - vma->vm_start) return -EINVAL; if (!capable(CAP_SYS_ADMIN) && (map->flags & _DRM_READ_ONLY)) { - vma->vm_flags &= VM_MAYWRITE; + vma->vm_flags &= ~(VM_WRITE | VM_MAYWRITE); #if defined(__i386__) || defined(__x86_64__) pgprot_val(vma->vm_page_prot) &= ~_PAGE_RW; #else @@ -420,15 +429,19 @@ switch (map->type) { case _DRM_AGP: -#if defined(__alpha__) +#if __REALLY_HAVE_AGP + if (dev->agp->cant_use_aperture) { /* - * On Alpha we can't talk to bus dma address from the - * CPU, so for memory of type DRM_AGP, we'll deal with - * sorting out the real physical pages and mappings - * in nopage() + * On some platforms we can't talk to bus dma address from the CPU, so for + * memory of type DRM_AGP, we'll deal with sorting out the real physical + * pages and mappings in nopage() */ +#if defined(__powerpc__) + pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE; +#endif vma->vm_ops = &DRM(vm_ops); break; + } #endif /* fall through to _DRM_FRAME_BUFFER... */ case _DRM_FRAME_BUFFER: @@ -439,15 +452,15 @@ pgprot_val(vma->vm_page_prot) |= _PAGE_PCD; pgprot_val(vma->vm_page_prot) &= ~_PAGE_PWT; } -#elif defined(__ia64__) - if (map->type != _DRM_AGP) - vma->vm_page_prot = - pgprot_writecombine(vma->vm_page_prot); #elif defined(__powerpc__) pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE | _PAGE_GUARDED; #endif vma->vm_flags |= VM_IO; /* not in core dump */ } +#if defined(__ia64__) + if (map->type != _DRM_AGP) + vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); +#endif offset = DRIVER_GET_REG_OFS(); #ifdef __sparc__ if (io_remap_page_range(DRM_RPR_ARG(vma) vma->vm_start, diff -urN linux-2.5.69-bk17/drivers/char/drm/gamma_context.h linux-2.5.69-bk18/drivers/char/drm/gamma_context.h --- linux-2.5.69-bk17/drivers/char/drm/gamma_context.h 1969-12-31 16:00:00.000000000 -0800 +++ linux-2.5.69-bk18/drivers/char/drm/gamma_context.h 2003-05-25 04:38:55.000000000 -0700 @@ -0,0 +1,489 @@ +/* drm_context.h -- IOCTLs for generic contexts -*- linux-c -*- + * Created: Fri Nov 24 18:31:37 2000 by gareth@valinux.com + * + * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: + * Rickard E. (Rik) Faith + * Gareth Hughes + * ChangeLog: + * 2001-11-16 Torsten Duwe + * added context constructor/destructor hooks, + * needed by SiS driver's memory management. + */ + +/* ================================================================ + * Old-style context support -- only used by gamma. + */ + + +/* The drm_read and drm_write_string code (especially that which manages + the circular buffer), is based on Alessandro Rubini's LINUX DEVICE + DRIVERS (Cambridge: O'Reilly, 1998), pages 111-113. */ + +ssize_t DRM(read)(struct file *filp, char *buf, size_t count, loff_t *off) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + int left; + int avail; + int send; + int cur; + + DRM_DEBUG("%p, %p\n", dev->buf_rp, dev->buf_wp); + + while (dev->buf_rp == dev->buf_wp) { + DRM_DEBUG(" sleeping\n"); + if (filp->f_flags & O_NONBLOCK) { + return -EAGAIN; + } + interruptible_sleep_on(&dev->buf_readers); + if (signal_pending(current)) { + DRM_DEBUG(" interrupted\n"); + return -ERESTARTSYS; + } + DRM_DEBUG(" awake\n"); + } + + left = (dev->buf_rp + DRM_BSZ - dev->buf_wp) % DRM_BSZ; + avail = DRM_BSZ - left; + send = DRM_MIN(avail, count); + + while (send) { + if (dev->buf_wp > dev->buf_rp) { + cur = DRM_MIN(send, dev->buf_wp - dev->buf_rp); + } else { + cur = DRM_MIN(send, dev->buf_end - dev->buf_rp); + } + if (copy_to_user(buf, dev->buf_rp, cur)) + return -EFAULT; + dev->buf_rp += cur; + if (dev->buf_rp == dev->buf_end) dev->buf_rp = dev->buf; + send -= cur; + } + + wake_up_interruptible(&dev->buf_writers); + return DRM_MIN(avail, count);; +} + + +/* In an incredibly convoluted setup, the kernel module actually calls + * back into the X server to perform context switches on behalf of the + * 3d clients. + */ +int DRM(write_string)(drm_device_t *dev, const char *s) +{ + int left = (dev->buf_rp + DRM_BSZ - dev->buf_wp) % DRM_BSZ; + int send = strlen(s); + int count; + + DRM_DEBUG("%d left, %d to send (%p, %p)\n", + left, send, dev->buf_rp, dev->buf_wp); + + if (left == 1 || dev->buf_wp != dev->buf_rp) { + DRM_ERROR("Buffer not empty (%d left, wp = %p, rp = %p)\n", + left, + dev->buf_wp, + dev->buf_rp); + } + + while (send) { + if (dev->buf_wp >= dev->buf_rp) { + count = DRM_MIN(send, dev->buf_end - dev->buf_wp); + if (count == left) --count; /* Leave a hole */ + } else { + count = DRM_MIN(send, dev->buf_rp - dev->buf_wp - 1); + } + strncpy(dev->buf_wp, s, count); + dev->buf_wp += count; + if (dev->buf_wp == dev->buf_end) dev->buf_wp = dev->buf; + send -= count; + } + + if (dev->buf_async) kill_fasync(&dev->buf_async, SIGIO, POLL_IN); + + DRM_DEBUG("waking\n"); + wake_up_interruptible(&dev->buf_readers); + return 0; +} + +unsigned int DRM(poll)(struct file *filp, struct poll_table_struct *wait) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + + poll_wait(filp, &dev->buf_readers, wait); + if (dev->buf_wp != dev->buf_rp) return POLLIN | POLLRDNORM; + return 0; +} + +int DRM(context_switch)(drm_device_t *dev, int old, int new) +{ + char buf[64]; + drm_queue_t *q; + + if (test_and_set_bit(0, &dev->context_flag)) { + DRM_ERROR("Reentering -- FIXME\n"); + return -EBUSY; + } + + DRM_DEBUG("Context switch from %d to %d\n", old, new); + + if (new >= dev->queue_count) { + clear_bit(0, &dev->context_flag); + return -EINVAL; + } + + if (new == dev->last_context) { + clear_bit(0, &dev->context_flag); + return 0; + } + + q = dev->queuelist[new]; + atomic_inc(&q->use_count); + if (atomic_read(&q->use_count) == 1) { + atomic_dec(&q->use_count); + clear_bit(0, &dev->context_flag); + return -EINVAL; + } + + /* This causes the X server to wake up & do a bunch of hardware + * interaction to actually effect the context switch. + */ + sprintf(buf, "C %d %d\n", old, new); + DRM(write_string)(dev, buf); + + atomic_dec(&q->use_count); + + return 0; +} + +int DRM(context_switch_complete)(drm_device_t *dev, int new) +{ + drm_device_dma_t *dma = dev->dma; + + dev->last_context = new; /* PRE/POST: This is the _only_ writer. */ + dev->last_switch = jiffies; + + if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { + DRM_ERROR("Lock isn't held after context switch\n"); + } + + if (!dma || !(dma->next_buffer && dma->next_buffer->while_locked)) { + if (DRM(lock_free)(dev, &dev->lock.hw_lock->lock, + DRM_KERNEL_CONTEXT)) { + DRM_ERROR("Cannot free lock\n"); + } + } + + clear_bit(0, &dev->context_flag); + wake_up_interruptible(&dev->context_wait); + + return 0; +} + +static int DRM(init_queue)(drm_device_t *dev, drm_queue_t *q, drm_ctx_t *ctx) +{ + DRM_DEBUG("\n"); + + if (atomic_read(&q->use_count) != 1 + || atomic_read(&q->finalization) + || atomic_read(&q->block_count)) { + DRM_ERROR("New queue is already in use: u%d f%d b%d\n", + atomic_read(&q->use_count), + atomic_read(&q->finalization), + atomic_read(&q->block_count)); + } + + atomic_set(&q->finalization, 0); + atomic_set(&q->block_count, 0); + atomic_set(&q->block_read, 0); + atomic_set(&q->block_write, 0); + atomic_set(&q->total_queued, 0); + atomic_set(&q->total_flushed, 0); + atomic_set(&q->total_locks, 0); + + init_waitqueue_head(&q->write_queue); + init_waitqueue_head(&q->read_queue); + init_waitqueue_head(&q->flush_queue); + + q->flags = ctx->flags; + + DRM(waitlist_create)(&q->waitlist, dev->dma->buf_count); + + return 0; +} + + +/* drm_alloc_queue: +PRE: 1) dev->queuelist[0..dev->queue_count] is allocated and will not + disappear (so all deallocation must be done after IOCTLs are off) + 2) dev->queue_count < dev->queue_slots + 3) dev->queuelist[i].use_count == 0 and + dev->queuelist[i].finalization == 0 if i not in use +POST: 1) dev->queuelist[i].use_count == 1 + 2) dev->queue_count < dev->queue_slots */ + +static int DRM(alloc_queue)(drm_device_t *dev) +{ + int i; + drm_queue_t *queue; + int oldslots; + int newslots; + /* Check for a free queue */ + for (i = 0; i < dev->queue_count; i++) { + atomic_inc(&dev->queuelist[i]->use_count); + if (atomic_read(&dev->queuelist[i]->use_count) == 1 + && !atomic_read(&dev->queuelist[i]->finalization)) { + DRM_DEBUG("%d (free)\n", i); + return i; + } + atomic_dec(&dev->queuelist[i]->use_count); + } + /* Allocate a new queue */ + down(&dev->struct_sem); + + queue = DRM(alloc)(sizeof(*queue), DRM_MEM_QUEUES); + memset(queue, 0, sizeof(*queue)); + atomic_set(&queue->use_count, 1); + + ++dev->queue_count; + if (dev->queue_count >= dev->queue_slots) { + oldslots = dev->queue_slots * sizeof(*dev->queuelist); + if (!dev->queue_slots) dev->queue_slots = 1; + dev->queue_slots *= 2; + newslots = dev->queue_slots * sizeof(*dev->queuelist); + + dev->queuelist = DRM(realloc)(dev->queuelist, + oldslots, + newslots, + DRM_MEM_QUEUES); + if (!dev->queuelist) { + up(&dev->struct_sem); + DRM_DEBUG("out of memory\n"); + return -ENOMEM; + } + } + dev->queuelist[dev->queue_count-1] = queue; + + up(&dev->struct_sem); + DRM_DEBUG("%d (new)\n", dev->queue_count - 1); + return dev->queue_count - 1; +} + +int DRM(resctx)(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_ctx_res_t res; + drm_ctx_t ctx; + int i; + + DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS); + if (copy_from_user(&res, (drm_ctx_res_t *)arg, sizeof(res))) + return -EFAULT; + if (res.count >= DRM_RESERVED_CONTEXTS) { + memset(&ctx, 0, sizeof(ctx)); + for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { + ctx.handle = i; + if (copy_to_user(&res.contexts[i], + &i, + sizeof(i))) + return -EFAULT; + } + } + res.count = DRM_RESERVED_CONTEXTS; + if (copy_to_user((drm_ctx_res_t *)arg, &res, sizeof(res))) + return -EFAULT; + return 0; +} + +int DRM(addctx)(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_ctx_t ctx; + + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; + if ((ctx.handle = DRM(alloc_queue)(dev)) == DRM_KERNEL_CONTEXT) { + /* Init kernel's context and get a new one. */ + DRM(init_queue)(dev, dev->queuelist[ctx.handle], &ctx); + ctx.handle = DRM(alloc_queue)(dev); + } + DRM(init_queue)(dev, dev->queuelist[ctx.handle], &ctx); + DRM_DEBUG("%d\n", ctx.handle); + if (copy_to_user((drm_ctx_t *)arg, &ctx, sizeof(ctx))) + return -EFAULT; + return 0; +} + +int DRM(modctx)(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_ctx_t ctx; + drm_queue_t *q; + + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; + + DRM_DEBUG("%d\n", ctx.handle); + + if (ctx.handle < 0 || ctx.handle >= dev->queue_count) return -EINVAL; + q = dev->queuelist[ctx.handle]; + + atomic_inc(&q->use_count); + if (atomic_read(&q->use_count) == 1) { + /* No longer in use */ + atomic_dec(&q->use_count); + return -EINVAL; + } + + if (DRM_BUFCOUNT(&q->waitlist)) { + atomic_dec(&q->use_count); + return -EBUSY; + } + + q->flags = ctx.flags; + + atomic_dec(&q->use_count); + return 0; +} + +int DRM(getctx)(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_ctx_t ctx; + drm_queue_t *q; + + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; + + DRM_DEBUG("%d\n", ctx.handle); + + if (ctx.handle >= dev->queue_count) return -EINVAL; + q = dev->queuelist[ctx.handle]; + + atomic_inc(&q->use_count); + if (atomic_read(&q->use_count) == 1) { + /* No longer in use */ + atomic_dec(&q->use_count); + return -EINVAL; + } + + ctx.flags = q->flags; + atomic_dec(&q->use_count); + + if (copy_to_user((drm_ctx_t *)arg, &ctx, sizeof(ctx))) + return -EFAULT; + + return 0; +} + +int DRM(switchctx)(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_ctx_t ctx; + + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; + DRM_DEBUG("%d\n", ctx.handle); + return DRM(context_switch)(dev, dev->last_context, ctx.handle); +} + +int DRM(newctx)(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_ctx_t ctx; + + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; + DRM_DEBUG("%d\n", ctx.handle); + DRM(context_switch_complete)(dev, ctx.handle); + + return 0; +} + +int DRM(rmctx)(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_ctx_t ctx; + drm_queue_t *q; + drm_buf_t *buf; + + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; + DRM_DEBUG("%d\n", ctx.handle); + + if (ctx.handle >= dev->queue_count) return -EINVAL; + q = dev->queuelist[ctx.handle]; + + atomic_inc(&q->use_count); + if (atomic_read(&q->use_count) == 1) { + /* No longer in use */ + atomic_dec(&q->use_count); + return -EINVAL; + } + + atomic_inc(&q->finalization); /* Mark queue in finalization state */ + atomic_sub(2, &q->use_count); /* Mark queue as unused (pending + finalization) */ + + while (test_and_set_bit(0, &dev->interrupt_flag)) { + schedule(); + if (signal_pending(current)) { + clear_bit(0, &dev->interrupt_flag); + return -EINTR; + } + } + /* Remove queued buffers */ + while ((buf = DRM(waitlist_get)(&q->waitlist))) { + DRM(free_buffer)(dev, buf); + } + clear_bit(0, &dev->interrupt_flag); + + /* Wakeup blocked processes */ + wake_up_interruptible(&q->read_queue); + wake_up_interruptible(&q->write_queue); + wake_up_interruptible(&q->flush_queue); + + /* Finalization over. Queue is made + available when both use_count and + finalization become 0, which won't + happen until all the waiting processes + stop waiting. */ + atomic_dec(&q->finalization); + return 0; +} + diff -urN linux-2.5.69-bk17/drivers/char/drm/gamma_dma.c linux-2.5.69-bk18/drivers/char/drm/gamma_dma.c --- linux-2.5.69-bk17/drivers/char/drm/gamma_dma.c 2003-05-04 16:53:41.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/drm/gamma_dma.c 2003-05-25 04:38:55.000000000 -0700 @@ -104,7 +104,7 @@ return(!GAMMA_READ(GAMMA_DMACOUNT)); } -void gamma_dma_service(int irq, void *device, struct pt_regs *regs) +irqreturn_t gamma_dma_service(int irq, void *device, struct pt_regs *regs) { drm_device_t *dev = (drm_device_t *)device; drm_device_dma_t *dma = dev->dma; @@ -119,7 +119,8 @@ GAMMA_WRITE(GAMMA_GINTFLAGS, 0x2001); if (gamma_dma_is_ready(dev)) { /* Free previous buffer */ - if (test_and_set_bit(0, &dev->dma_flag)) return; + if (test_and_set_bit(0, &dev->dma_flag)) + return IRQ_HANDLED; if (dma->this_buffer) { gamma_free_buffer(dev, dma->this_buffer); dma->this_buffer = NULL; @@ -127,8 +128,9 @@ clear_bit(0, &dev->dma_flag); /* Dispatch new buffer */ - schedule_work(&dev->tq); + schedule_work(&dev->work); } + return IRQ_HANDLED; } /* Only called by gamma_dma_schedule. */ @@ -612,7 +614,7 @@ } else { DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset ); - DRM_IOREMAP( dev_priv->buffers ); + DRM_IOREMAP( dev_priv->buffers, dev ); buf = dma->buflist[GLINT_DRI_BUF_COUNT]; pgt = buf->address; @@ -651,7 +653,7 @@ drm_gamma_private_t *dev_priv = dev->dev_private; if ( dev_priv->buffers != NULL ) - DRM_IOREMAPFREE( dev_priv->buffers ); + DRM_IOREMAPFREE( dev_priv->buffers, dev ); DRM(free)( dev->dev_private, sizeof(drm_gamma_private_t), DRM_MEM_DRIVER ); diff -urN linux-2.5.69-bk17/drivers/char/drm/gamma_lists.h linux-2.5.69-bk18/drivers/char/drm/gamma_lists.h --- linux-2.5.69-bk17/drivers/char/drm/gamma_lists.h 1969-12-31 16:00:00.000000000 -0800 +++ linux-2.5.69-bk18/drivers/char/drm/gamma_lists.h 2003-05-25 04:38:55.000000000 -0700 @@ -0,0 +1,216 @@ +/* drm_lists.h -- Buffer list handling routines -*- linux-c -*- + * Created: Mon Apr 19 20:54:22 1999 by faith@valinux.com + * + * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: + * Rickard E. (Rik) Faith + * Gareth Hughes + */ + +#define __NO_VERSION__ +#include "drmP.h" + + +int DRM(waitlist_create)(drm_waitlist_t *bl, int count) +{ + if (bl->count) return -EINVAL; + + bl->bufs = DRM(alloc)((bl->count + 2) * sizeof(*bl->bufs), + DRM_MEM_BUFLISTS); + + if(!bl->bufs) return -ENOMEM; + memset(bl->bufs, 0, sizeof(*bl->bufs)); + bl->count = count; + bl->rp = bl->bufs; + bl->wp = bl->bufs; + bl->end = &bl->bufs[bl->count+1]; + bl->write_lock = SPIN_LOCK_UNLOCKED; + bl->read_lock = SPIN_LOCK_UNLOCKED; + return 0; +} + +int DRM(waitlist_destroy)(drm_waitlist_t *bl) +{ + if (bl->rp != bl->wp) return -EINVAL; + if (bl->bufs) DRM(free)(bl->bufs, + (bl->count + 2) * sizeof(*bl->bufs), + DRM_MEM_BUFLISTS); + bl->count = 0; + bl->bufs = NULL; + bl->rp = NULL; + bl->wp = NULL; + bl->end = NULL; + return 0; +} + +int DRM(waitlist_put)(drm_waitlist_t *bl, drm_buf_t *buf) +{ + int left; + unsigned long flags; + + left = DRM_LEFTCOUNT(bl); + if (!left) { + DRM_ERROR("Overflow while adding buffer %d from filp %p\n", + buf->idx, buf->filp); + return -EINVAL; + } + buf->list = DRM_LIST_WAIT; + + spin_lock_irqsave(&bl->write_lock, flags); + *bl->wp = buf; + if (++bl->wp >= bl->end) bl->wp = bl->bufs; + spin_unlock_irqrestore(&bl->write_lock, flags); + + return 0; +} + +drm_buf_t *DRM(waitlist_get)(drm_waitlist_t *bl) +{ + drm_buf_t *buf; + unsigned long flags; + + spin_lock_irqsave(&bl->read_lock, flags); + buf = *bl->rp; + if (bl->rp == bl->wp) { + spin_unlock_irqrestore(&bl->read_lock, flags); + return NULL; + } + if (++bl->rp >= bl->end) bl->rp = bl->bufs; + spin_unlock_irqrestore(&bl->read_lock, flags); + + return buf; +} + +int DRM(freelist_create)(drm_freelist_t *bl, int count) +{ + atomic_set(&bl->count, 0); + bl->next = NULL; + init_waitqueue_head(&bl->waiting); + bl->low_mark = 0; + bl->high_mark = 0; + atomic_set(&bl->wfh, 0); + bl->lock = SPIN_LOCK_UNLOCKED; + ++bl->initialized; + return 0; +} + +int DRM(freelist_destroy)(drm_freelist_t *bl) +{ + atomic_set(&bl->count, 0); + bl->next = NULL; + return 0; +} + +int DRM(freelist_put)(drm_device_t *dev, drm_freelist_t *bl, drm_buf_t *buf) +{ + drm_device_dma_t *dma = dev->dma; + + if (!dma) { + DRM_ERROR("No DMA support\n"); + return 1; + } + + if (buf->waiting || buf->pending || buf->list == DRM_LIST_FREE) { + DRM_ERROR("Freed buffer %d: w%d, p%d, l%d\n", + buf->idx, buf->waiting, buf->pending, buf->list); + } + if (!bl) return 1; + buf->list = DRM_LIST_FREE; + + spin_lock(&bl->lock); + buf->next = bl->next; + bl->next = buf; + spin_unlock(&bl->lock); + + atomic_inc(&bl->count); + if (atomic_read(&bl->count) > dma->buf_count) { + DRM_ERROR("%d of %d buffers free after addition of %d\n", + atomic_read(&bl->count), dma->buf_count, buf->idx); + return 1; + } + /* Check for high water mark */ + if (atomic_read(&bl->wfh) && atomic_read(&bl->count)>=bl->high_mark) { + atomic_set(&bl->wfh, 0); + wake_up_interruptible(&bl->waiting); + } + return 0; +} + +static drm_buf_t *DRM(freelist_try)(drm_freelist_t *bl) +{ + drm_buf_t *buf; + + if (!bl) return NULL; + + /* Get buffer */ + spin_lock(&bl->lock); + if (!bl->next) { + spin_unlock(&bl->lock); + return NULL; + } + buf = bl->next; + bl->next = bl->next->next; + spin_unlock(&bl->lock); + + atomic_dec(&bl->count); + buf->next = NULL; + buf->list = DRM_LIST_NONE; + if (buf->waiting || buf->pending) { + DRM_ERROR("Free buffer %d: w%d, p%d, l%d\n", + buf->idx, buf->waiting, buf->pending, buf->list); + } + + return buf; +} + +drm_buf_t *DRM(freelist_get)(drm_freelist_t *bl, int block) +{ + drm_buf_t *buf = NULL; + DECLARE_WAITQUEUE(entry, current); + + if (!bl || !bl->initialized) return NULL; + + /* Check for low water mark */ + if (atomic_read(&bl->count) <= bl->low_mark) /* Became low */ + atomic_set(&bl->wfh, 1); + if (atomic_read(&bl->wfh)) { + if (block) { + add_wait_queue(&bl->waiting, &entry); + for (;;) { + current->state = TASK_INTERRUPTIBLE; + if (!atomic_read(&bl->wfh) + && (buf = DRM(freelist_try)(bl))) break; + schedule(); + if (signal_pending(current)) break; + } + current->state = TASK_RUNNING; + remove_wait_queue(&bl->waiting, &entry); + } + return buf; + } + + return DRM(freelist_try)(bl); +} + diff -urN linux-2.5.69-bk17/drivers/char/drm/gamma_lock.h linux-2.5.69-bk18/drivers/char/drm/gamma_lock.h --- linux-2.5.69-bk17/drivers/char/drm/gamma_lock.h 1969-12-31 16:00:00.000000000 -0800 +++ linux-2.5.69-bk18/drivers/char/drm/gamma_lock.h 2003-05-25 04:38:55.000000000 -0700 @@ -0,0 +1,140 @@ +/* lock.c -- IOCTLs for locking -*- linux-c -*- + * Created: Tue Feb 2 08:37:54 1999 by faith@valinux.com + * + * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: + * Rickard E. (Rik) Faith + * Gareth Hughes + */ + + +/* Gamma-specific code extracted from drm_lock.h: + */ +static int DRM(flush_queue)(drm_device_t *dev, int context) +{ + DECLARE_WAITQUEUE(entry, current); + int ret = 0; + drm_queue_t *q = dev->queuelist[context]; + + DRM_DEBUG("\n"); + + atomic_inc(&q->use_count); + if (atomic_read(&q->use_count) > 1) { + atomic_inc(&q->block_write); + add_wait_queue(&q->flush_queue, &entry); + atomic_inc(&q->block_count); + for (;;) { + current->state = TASK_INTERRUPTIBLE; + if (!DRM_BUFCOUNT(&q->waitlist)) break; + schedule(); + if (signal_pending(current)) { + ret = -EINTR; /* Can't restart */ + break; + } + } + atomic_dec(&q->block_count); + current->state = TASK_RUNNING; + remove_wait_queue(&q->flush_queue, &entry); + } + atomic_dec(&q->use_count); + + /* NOTE: block_write is still incremented! + Use drm_flush_unlock_queue to decrement. */ + return ret; +} + +static int DRM(flush_unblock_queue)(drm_device_t *dev, int context) +{ + drm_queue_t *q = dev->queuelist[context]; + + DRM_DEBUG("\n"); + + atomic_inc(&q->use_count); + if (atomic_read(&q->use_count) > 1) { + if (atomic_read(&q->block_write)) { + atomic_dec(&q->block_write); + wake_up_interruptible(&q->write_queue); + } + } + atomic_dec(&q->use_count); + return 0; +} + +int DRM(flush_block_and_flush)(drm_device_t *dev, int context, + drm_lock_flags_t flags) +{ + int ret = 0; + int i; + + DRM_DEBUG("\n"); + + if (flags & _DRM_LOCK_FLUSH) { + ret = DRM(flush_queue)(dev, DRM_KERNEL_CONTEXT); + if (!ret) ret = DRM(flush_queue)(dev, context); + } + if (flags & _DRM_LOCK_FLUSH_ALL) { + for (i = 0; !ret && i < dev->queue_count; i++) { + ret = DRM(flush_queue)(dev, i); + } + } + return ret; +} + +int DRM(flush_unblock)(drm_device_t *dev, int context, drm_lock_flags_t flags) +{ + int ret = 0; + int i; + + DRM_DEBUG("\n"); + + if (flags & _DRM_LOCK_FLUSH) { + ret = DRM(flush_unblock_queue)(dev, DRM_KERNEL_CONTEXT); + if (!ret) ret = DRM(flush_unblock_queue)(dev, context); + } + if (flags & _DRM_LOCK_FLUSH_ALL) { + for (i = 0; !ret && i < dev->queue_count; i++) { + ret = DRM(flush_unblock_queue)(dev, i); + } + } + + return ret; +} + +int DRM(finish)(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + int ret = 0; + drm_lock_t lock; + + DRM_DEBUG("\n"); + + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; + ret = DRM(flush_block_and_flush)(dev, lock.context, lock.flags); + DRM(flush_unblock)(dev, lock.context, lock.flags); + return ret; +} diff -urN linux-2.5.69-bk17/drivers/char/drm/gamma_old_dma.h linux-2.5.69-bk18/drivers/char/drm/gamma_old_dma.h --- linux-2.5.69-bk17/drivers/char/drm/gamma_old_dma.h 1969-12-31 16:00:00.000000000 -0800 +++ linux-2.5.69-bk18/drivers/char/drm/gamma_old_dma.h 2003-05-25 04:38:55.000000000 -0700 @@ -0,0 +1,300 @@ +/* drm_dma.c -- DMA IOCTL and function support -*- linux-c -*- + * Created: Fri Mar 19 14:30:16 1999 by faith@valinux.com + * + * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: + * Rickard E. (Rik) Faith + * Gareth Hughes + */ + + +/* Gamma-specific code pulled from drm_dma.h: + */ + +void DRM(clear_next_buffer)(drm_device_t *dev) +{ + drm_device_dma_t *dma = dev->dma; + + dma->next_buffer = NULL; + if (dma->next_queue && !DRM_BUFCOUNT(&dma->next_queue->waitlist)) { + wake_up_interruptible(&dma->next_queue->flush_queue); + } + dma->next_queue = NULL; +} + +int DRM(select_queue)(drm_device_t *dev, void (*wrapper)(unsigned long)) +{ + int i; + int candidate = -1; + int j = jiffies; + + if (!dev) { + DRM_ERROR("No device\n"); + return -1; + } + if (!dev->queuelist || !dev->queuelist[DRM_KERNEL_CONTEXT]) { + /* This only happens between the time the + interrupt is initialized and the time + the queues are initialized. */ + return -1; + } + + /* Doing "while locked" DMA? */ + if (DRM_WAITCOUNT(dev, DRM_KERNEL_CONTEXT)) { + return DRM_KERNEL_CONTEXT; + } + + /* If there are buffers on the last_context + queue, and we have not been executing + this context very long, continue to + execute this context. */ + if (dev->last_switch <= j + && dev->last_switch + DRM_TIME_SLICE > j + && DRM_WAITCOUNT(dev, dev->last_context)) { + return dev->last_context; + } + + /* Otherwise, find a candidate */ + for (i = dev->last_checked + 1; i < dev->queue_count; i++) { + if (DRM_WAITCOUNT(dev, i)) { + candidate = dev->last_checked = i; + break; + } + } + + if (candidate < 0) { + for (i = 0; i < dev->queue_count; i++) { + if (DRM_WAITCOUNT(dev, i)) { + candidate = dev->last_checked = i; + break; + } + } + } + + if (wrapper + && candidate >= 0 + && candidate != dev->last_context + && dev->last_switch <= j + && dev->last_switch + DRM_TIME_SLICE > j) { + if (dev->timer.expires != dev->last_switch + DRM_TIME_SLICE) { + del_timer(&dev->timer); + dev->timer.function = wrapper; + dev->timer.data = (unsigned long)dev; + dev->timer.expires = dev->last_switch+DRM_TIME_SLICE; + add_timer(&dev->timer); + } + return -1; + } + + return candidate; +} + + +int DRM(dma_enqueue)(struct file *filp, drm_dma_t *d) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + int i; + drm_queue_t *q; + drm_buf_t *buf; + int idx; + int while_locked = 0; + drm_device_dma_t *dma = dev->dma; + DECLARE_WAITQUEUE(entry, current); + + DRM_DEBUG("%d\n", d->send_count); + + if (d->flags & _DRM_DMA_WHILE_LOCKED) { + int context = dev->lock.hw_lock->lock; + + if (!_DRM_LOCK_IS_HELD(context)) { + DRM_ERROR("No lock held during \"while locked\"" + " request\n"); + return -EINVAL; + } + if (d->context != _DRM_LOCKING_CONTEXT(context) + && _DRM_LOCKING_CONTEXT(context) != DRM_KERNEL_CONTEXT) { + DRM_ERROR("Lock held by %d while %d makes" + " \"while locked\" request\n", + _DRM_LOCKING_CONTEXT(context), + d->context); + return -EINVAL; + } + q = dev->queuelist[DRM_KERNEL_CONTEXT]; + while_locked = 1; + } else { + q = dev->queuelist[d->context]; + } + + + atomic_inc(&q->use_count); + if (atomic_read(&q->block_write)) { + add_wait_queue(&q->write_queue, &entry); + atomic_inc(&q->block_count); + for (;;) { + current->state = TASK_INTERRUPTIBLE; + if (!atomic_read(&q->block_write)) break; + schedule(); + if (signal_pending(current)) { + atomic_dec(&q->use_count); + remove_wait_queue(&q->write_queue, &entry); + return -EINTR; + } + } + atomic_dec(&q->block_count); + current->state = TASK_RUNNING; + remove_wait_queue(&q->write_queue, &entry); + } + + for (i = 0; i < d->send_count; i++) { + idx = d->send_indices[i]; + if (idx < 0 || idx >= dma->buf_count) { + atomic_dec(&q->use_count); + DRM_ERROR("Index %d (of %d max)\n", + d->send_indices[i], dma->buf_count - 1); + return -EINVAL; + } + buf = dma->buflist[ idx ]; + if (buf->filp != filp) { + atomic_dec(&q->use_count); + DRM_ERROR("Process %d using buffer not owned\n", + current->pid); + return -EINVAL; + } + if (buf->list != DRM_LIST_NONE) { + atomic_dec(&q->use_count); + DRM_ERROR("Process %d using buffer %d on list %d\n", + current->pid, buf->idx, buf->list); + } + buf->used = d->send_sizes[i]; + buf->while_locked = while_locked; + buf->context = d->context; + if (!buf->used) { + DRM_ERROR("Queueing 0 length buffer\n"); + } + if (buf->pending) { + atomic_dec(&q->use_count); + DRM_ERROR("Queueing pending buffer:" + " buffer %d, offset %d\n", + d->send_indices[i], i); + return -EINVAL; + } + if (buf->waiting) { + atomic_dec(&q->use_count); + DRM_ERROR("Queueing waiting buffer:" + " buffer %d, offset %d\n", + d->send_indices[i], i); + return -EINVAL; + } + buf->waiting = 1; + if (atomic_read(&q->use_count) == 1 + || atomic_read(&q->finalization)) { + DRM(free_buffer)(dev, buf); + } else { + DRM(waitlist_put)(&q->waitlist, buf); + atomic_inc(&q->total_queued); + } + } + atomic_dec(&q->use_count); + + return 0; +} + +static int DRM(dma_get_buffers_of_order)(struct file *filp, drm_dma_t *d, + int order) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + int i; + drm_buf_t *buf; + drm_device_dma_t *dma = dev->dma; + + for (i = d->granted_count; i < d->request_count; i++) { + buf = DRM(freelist_get)(&dma->bufs[order].freelist, + d->flags & _DRM_DMA_WAIT); + if (!buf) break; + if (buf->pending || buf->waiting) { + DRM_ERROR("Free buffer %d in use: filp %p (w%d, p%d)\n", + buf->idx, + buf->filp, + buf->waiting, + buf->pending); + } + buf->filp = filp; + if (copy_to_user(&d->request_indices[i], + &buf->idx, + sizeof(buf->idx))) + return -EFAULT; + + if (copy_to_user(&d->request_sizes[i], + &buf->total, + sizeof(buf->total))) + return -EFAULT; + + ++d->granted_count; + } + return 0; +} + + +int DRM(dma_get_buffers)(struct file *filp, drm_dma_t *dma) +{ + int order; + int retcode = 0; + int tmp_order; + + order = DRM(order)(dma->request_size); + + dma->granted_count = 0; + retcode = DRM(dma_get_buffers_of_order)(filp, dma, order); + + if (dma->granted_count < dma->request_count + && (dma->flags & _DRM_DMA_SMALLER_OK)) { + for (tmp_order = order - 1; + !retcode + && dma->granted_count < dma->request_count + && tmp_order >= DRM_MIN_ORDER; + --tmp_order) { + + retcode = DRM(dma_get_buffers_of_order)(filp, dma, + tmp_order); + } + } + + if (dma->granted_count < dma->request_count + && (dma->flags & _DRM_DMA_LARGER_OK)) { + for (tmp_order = order + 1; + !retcode + && dma->granted_count < dma->request_count + && tmp_order <= DRM_MAX_ORDER; + ++tmp_order) { + + retcode = DRM(dma_get_buffers_of_order)(filp, dma, + tmp_order); + } + } + return 0; +} + diff -urN linux-2.5.69-bk17/drivers/char/drm/i810_dma.c linux-2.5.69-bk18/drivers/char/drm/i810_dma.c --- linux-2.5.69-bk17/drivers/char/drm/i810_dma.c 2003-05-04 16:53:09.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/drm/i810_dma.c 2003-05-25 04:38:55.000000000 -0700 @@ -246,7 +246,7 @@ if(dev_priv->ring.virtual_start) { DRM(ioremapfree)((void *) dev_priv->ring.virtual_start, - dev_priv->ring.Size); + dev_priv->ring.Size, dev); } if (dev_priv->hw_status_page) { pci_free_consistent(dev->pdev, PAGE_SIZE, @@ -263,7 +263,7 @@ drm_buf_t *buf = dma->buflist[ i ]; drm_i810_buf_priv_t *buf_priv = buf->dev_private; if ( buf_priv->kernel_virtual && buf->total ) - DRM(ioremapfree)(buf_priv->kernel_virtual, buf->total); + DRM(ioremapfree)(buf_priv->kernel_virtual, buf->total, dev); } } return 0; @@ -333,7 +333,7 @@ *buf_priv->in_use = I810_BUF_FREE; buf_priv->kernel_virtual = DRM(ioremap)(buf->bus_address, - buf->total); + buf->total, dev); } return 0; } @@ -386,7 +386,7 @@ dev_priv->ring.virtual_start = DRM(ioremap)(dev->agp->base + init->ring_start, - init->ring_size); + init->ring_size, dev); if (dev_priv->ring.virtual_start == NULL) { dev->dev_private = (void *) dev_priv; diff -urN linux-2.5.69-bk17/drivers/char/drm/i830_dma.c linux-2.5.69-bk18/drivers/char/drm/i830_dma.c --- linux-2.5.69-bk17/drivers/char/drm/i830_dma.c 2003-05-04 16:53:01.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/drm/i830_dma.c 2003-05-25 04:38:55.000000000 -0700 @@ -246,7 +246,7 @@ if (dev_priv->ring.virtual_start) { DRM(ioremapfree)((void *) dev_priv->ring.virtual_start, - dev_priv->ring.Size); + dev_priv->ring.Size, dev); } if (dev_priv->hw_status_page) { pci_free_consistent(dev->pdev, PAGE_SIZE, @@ -264,7 +264,7 @@ drm_buf_t *buf = dma->buflist[ i ]; drm_i830_buf_priv_t *buf_priv = buf->dev_private; if ( buf_priv->kernel_virtual && buf->total ) - DRM(ioremapfree)(buf_priv->kernel_virtual, buf->total); + DRM(ioremapfree)(buf_priv->kernel_virtual, buf->total, dev); } } return 0; @@ -340,7 +340,7 @@ *buf_priv->in_use = I830_BUF_FREE; buf_priv->kernel_virtual = DRM(ioremap)(buf->bus_address, - buf->total); + buf->total, dev); } return 0; } @@ -394,7 +394,7 @@ dev_priv->ring.virtual_start = DRM(ioremap)(dev->agp->base + init->ring_start, - init->ring_size); + init->ring_size, dev); if (dev_priv->ring.virtual_start == NULL) { dev->dev_private = (void *) dev_priv; diff -urN linux-2.5.69-bk17/drivers/char/drm/mga_dma.c linux-2.5.69-bk18/drivers/char/drm/mga_dma.c --- linux-2.5.69-bk17/drivers/char/drm/mga_dma.c 2003-05-04 16:53:40.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/drm/mga_dma.c 2003-05-25 04:38:55.000000000 -0700 @@ -554,9 +554,9 @@ (drm_mga_sarea_t *)((u8 *)dev_priv->sarea->handle + init->sarea_priv_offset); - DRM_IOREMAP( dev_priv->warp ); - DRM_IOREMAP( dev_priv->primary ); - DRM_IOREMAP( dev_priv->buffers ); + DRM_IOREMAP( dev_priv->warp, dev ); + DRM_IOREMAP( dev_priv->primary, dev ); + DRM_IOREMAP( dev_priv->buffers, dev ); if(!dev_priv->warp->handle || !dev_priv->primary->handle || @@ -651,11 +651,11 @@ drm_mga_private_t *dev_priv = dev->dev_private; if ( dev_priv->warp != NULL ) - DRM_IOREMAPFREE( dev_priv->warp ); + DRM_IOREMAPFREE( dev_priv->warp, dev ); if ( dev_priv->primary != NULL ) - DRM_IOREMAPFREE( dev_priv->primary ); + DRM_IOREMAPFREE( dev_priv->primary, dev ); if ( dev_priv->buffers != NULL ) - DRM_IOREMAPFREE( dev_priv->buffers ); + DRM_IOREMAPFREE( dev_priv->buffers, dev ); if ( dev_priv->head != NULL ) { mga_freelist_cleanup( dev ); diff -urN linux-2.5.69-bk17/drivers/char/drm/mga_drv.h linux-2.5.69-bk18/drivers/char/drm/mga_drv.h --- linux-2.5.69-bk17/drivers/char/drm/mga_drv.h 2003-05-04 16:53:41.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/drm/mga_drv.h 2003-05-25 04:38:55.000000000 -0700 @@ -226,7 +226,7 @@ if ( MGA_VERBOSE ) { \ DRM_INFO( "BEGIN_DMA( %d ) in %s\n", \ (n), __FUNCTION__ ); \ - DRM_INFO( " space=0x%x req=0x%x\n", \ + DRM_INFO( " space=0x%x req=0x%Zx\n", \ dev_priv->prim.space, (n) * DMA_BLOCK_SIZE ); \ } \ prim = dev_priv->prim.start; \ @@ -276,7 +276,7 @@ #define DMA_WRITE( offset, val ) \ do { \ if ( MGA_VERBOSE ) { \ - DRM_INFO( " DMA_WRITE( 0x%08x ) at 0x%04x\n", \ + DRM_INFO( " DMA_WRITE( 0x%08x ) at 0x%04Zx\n", \ (u32)(val), write + (offset) * sizeof(u32) ); \ } \ *(volatile u32 *)(prim + write + (offset) * sizeof(u32)) = val; \ diff -urN linux-2.5.69-bk17/drivers/char/drm/r128_cce.c linux-2.5.69-bk18/drivers/char/drm/r128_cce.c --- linux-2.5.69-bk17/drivers/char/drm/r128_cce.c 2003-05-04 16:53:02.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/drm/r128_cce.c 2003-05-25 04:38:55.000000000 -0700 @@ -350,8 +350,8 @@ R128_WRITE( R128_PM4_BUFFER_DL_RPTR_ADDR, entry->busaddr[page_ofs]); - DRM_DEBUG( "ring rptr: offset=0x%08x handle=0x%08lx\n", - entry->busaddr[page_ofs], + DRM_DEBUG( "ring rptr: offset=0x%08lx handle=0x%08lx\n", + (unsigned long) entry->busaddr[page_ofs], entry->handle + tmp_ofs ); } @@ -539,10 +539,11 @@ (drm_r128_sarea_t *)((u8 *)dev_priv->sarea->handle + init->sarea_priv_offset); +#if __REALLY_HAVE_AGP if ( !dev_priv->is_pci ) { - DRM_IOREMAP( dev_priv->cce_ring ); - DRM_IOREMAP( dev_priv->ring_rptr ); - DRM_IOREMAP( dev_priv->buffers ); + DRM_IOREMAP( dev_priv->cce_ring, dev ); + DRM_IOREMAP( dev_priv->ring_rptr, dev ); + DRM_IOREMAP( dev_priv->buffers, dev ); if(!dev_priv->cce_ring->handle || !dev_priv->ring_rptr->handle || !dev_priv->buffers->handle) { @@ -551,7 +552,9 @@ r128_do_cleanup_cce( dev ); return DRM_ERR(ENOMEM); } - } else { + } else +#endif + { dev_priv->cce_ring->handle = (void *)dev_priv->cce_ring->offset; dev_priv->ring_rptr->handle = @@ -625,23 +628,22 @@ if ( dev->dev_private ) { drm_r128_private_t *dev_priv = dev->dev_private; -#if __REALLY_HAVE_SG +#if __REALLY_HAVE_AGP if ( !dev_priv->is_pci ) { -#endif if ( dev_priv->cce_ring != NULL ) - DRM_IOREMAPFREE( dev_priv->cce_ring ); + DRM_IOREMAPFREE( dev_priv->cce_ring, dev ); if ( dev_priv->ring_rptr != NULL ) - DRM_IOREMAPFREE( dev_priv->ring_rptr ); + DRM_IOREMAPFREE( dev_priv->ring_rptr, dev ); if ( dev_priv->buffers != NULL ) - DRM_IOREMAPFREE( dev_priv->buffers ); -#if __REALLY_HAVE_SG - } else { + DRM_IOREMAPFREE( dev_priv->buffers, dev ); + } else +#endif + { if (!DRM(ati_pcigart_cleanup)( dev, dev_priv->phys_pci_gart, dev_priv->bus_pci_gart )) DRM_ERROR( "failed to cleanup PCI GART!\n" ); } -#endif DRM(free)( dev->dev_private, sizeof(drm_r128_private_t), DRM_MEM_DRIVER ); diff -urN linux-2.5.69-bk17/drivers/char/drm/radeon.h linux-2.5.69-bk18/drivers/char/drm/radeon.h --- linux-2.5.69-bk17/drivers/char/drm/radeon.h 2003-05-04 16:53:41.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/drm/radeon.h 2003-05-25 04:38:55.000000000 -0700 @@ -79,6 +79,7 @@ * R200_EMIT_PP_CUBIC_OFFSETS_[0..5]. (brian) * 1.8 - Remove need to call cleanup ioctls on last client exit (keith) * Add 'GET' queries for starting additional clients on different VT's. + * Add DRM_IOCTL_RADEON_CP_RESUME ioctl. */ #define DRIVER_IOCTLS \ [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { radeon_cp_buffers, 1, 0 }, \ @@ -87,6 +88,7 @@ [DRM_IOCTL_NR(DRM_IOCTL_RADEON_CP_STOP)] = { radeon_cp_stop, 1, 1 }, \ [DRM_IOCTL_NR(DRM_IOCTL_RADEON_CP_RESET)] = { radeon_cp_reset, 1, 1 }, \ [DRM_IOCTL_NR(DRM_IOCTL_RADEON_CP_IDLE)] = { radeon_cp_idle, 1, 0 }, \ + [DRM_IOCTL_NR(DRM_IOCTL_RADEON_CP_RESUME)] = { radeon_cp_resume, 1, 0 }, \ [DRM_IOCTL_NR(DRM_IOCTL_RADEON_RESET)] = { radeon_engine_reset, 1, 0 }, \ [DRM_IOCTL_NR(DRM_IOCTL_RADEON_FULLSCREEN)] = { radeon_fullscreen, 1, 0 }, \ [DRM_IOCTL_NR(DRM_IOCTL_RADEON_SWAP)] = { radeon_cp_swap, 1, 0 }, \ diff -urN linux-2.5.69-bk17/drivers/char/drm/radeon_cp.c linux-2.5.69-bk18/drivers/char/drm/radeon_cp.c --- linux-2.5.69-bk17/drivers/char/drm/radeon_cp.c 2003-05-25 04:38:50.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/drm/radeon_cp.c 2003-05-25 04:38:55.000000000 -0700 @@ -1151,10 +1151,11 @@ (drm_radeon_sarea_t *)((u8 *)dev_priv->sarea->handle + init->sarea_priv_offset); +#if __REALLY_HAVE_AGP if ( !dev_priv->is_pci ) { - DRM_IOREMAP( dev_priv->cp_ring ); - DRM_IOREMAP( dev_priv->ring_rptr ); - DRM_IOREMAP( dev_priv->buffers ); + DRM_IOREMAP( dev_priv->cp_ring, dev ); + DRM_IOREMAP( dev_priv->ring_rptr, dev ); + DRM_IOREMAP( dev_priv->buffers, dev ); if(!dev_priv->cp_ring->handle || !dev_priv->ring_rptr->handle || !dev_priv->buffers->handle) { @@ -1163,7 +1164,9 @@ radeon_do_cleanup_cp(dev); return DRM_ERR(EINVAL); } - } else { + } else +#endif + { dev_priv->cp_ring->handle = (void *)dev_priv->cp_ring->offset; dev_priv->ring_rptr->handle = @@ -1210,7 +1213,6 @@ dev_priv->ring.high_mark = RADEON_RING_HIGH_MARK; -#if __REALLY_HAVE_SG if ( dev_priv->is_pci ) { if (!DRM(ati_pcigart_init)( dev, &dev_priv->phys_pci_gart, &dev_priv->bus_pci_gart)) { @@ -1240,15 +1242,12 @@ RADEON_WRITE( RADEON_MC_AGP_LOCATION, 0xffffffc0 ); /* ?? */ RADEON_WRITE( RADEON_AGP_COMMAND, 0 ); /* clear AGP_COMMAND */ } else { -#endif /* __REALLY_HAVE_SG */ /* Turn off PCI GART */ tmp = RADEON_READ( RADEON_AIC_CNTL ) & ~RADEON_PCIGART_TRANSLATE_EN; RADEON_WRITE( RADEON_AIC_CNTL, tmp ); -#if __REALLY_HAVE_SG } -#endif /* __REALLY_HAVE_SG */ radeon_cp_load_microcode( dev_priv ); radeon_cp_init_ring_buffer( dev, dev_priv ); @@ -1277,20 +1276,21 @@ if ( dev->dev_private ) { drm_radeon_private_t *dev_priv = dev->dev_private; +#if __REALLY_HAVE_AGP if ( !dev_priv->is_pci ) { if ( dev_priv->cp_ring != NULL ) - DRM_IOREMAPFREE( dev_priv->cp_ring ); + DRM_IOREMAPFREE( dev_priv->cp_ring, dev ); if ( dev_priv->ring_rptr != NULL ) - DRM_IOREMAPFREE( dev_priv->ring_rptr ); + DRM_IOREMAPFREE( dev_priv->ring_rptr, dev ); if ( dev_priv->buffers != NULL ) - DRM_IOREMAPFREE( dev_priv->buffers ); - } else { -#if __REALLY_HAVE_SG + DRM_IOREMAPFREE( dev_priv->buffers, dev ); + } else +#endif + { if (!DRM(ati_pcigart_cleanup)( dev, dev_priv->phys_pci_gart, dev_priv->bus_pci_gart )) DRM_ERROR( "failed to cleanup PCI GART!\n" ); -#endif /* __REALLY_HAVE_SG */ } DRM(free)( dev->dev_private, sizeof(drm_radeon_private_t), @@ -1301,6 +1301,176 @@ return 0; } +/* This code will reinit the Radeon CP hardware after a resume from disc. + * AFAIK, it would be very difficult to pickle the state at suspend time, so + * here we make sure that all Radeon hardware initialisation is re-done without + * affecting running applications. This function is called radeon_do_resume_cp() + * as it was derived from radeon_init_cp, where most of the initialisation takes + * place during DRI init. + * + * This patch is NOT to be confused with my and Michel Daenzer's earlier DRI + * reinit work, which de- and re-initialised the complete DRI at every VT + * switch. + * + * Charl P. Botha + */ +static int radeon_do_resume_cp( drm_device_t *dev) +{ + drm_radeon_private_t *dev_priv; + u32 tmp; + DRM_DEBUG( "\n" ); + + DRM_DEBUG("Starting radeon_do_resume_cp()\n"); + + /* get the existing dev_private */ + dev_priv = dev->dev_private; + +#if !defined(PCIGART_ENABLED) + /* PCI support is not 100% working, so we disable it here. + */ + if ( dev_priv->is_pci ) { + DRM_ERROR( "PCI GART not yet supported for Radeon!\n" ); + radeon_do_cleanup_cp(dev); + return DRM_ERR(EINVAL); + } +#endif + + if ( dev_priv->is_pci && !dev->sg ) { + DRM_ERROR( "PCI GART memory not allocated!\n" ); + radeon_do_cleanup_cp(dev); + return DRM_ERR(EINVAL); + } + + if ( dev_priv->usec_timeout < 1 || + dev_priv->usec_timeout > RADEON_MAX_USEC_TIMEOUT ) { + DRM_DEBUG( "TIMEOUT problem!\n" ); + radeon_do_cleanup_cp(dev); + return DRM_ERR(EINVAL); + } + + if ( ( dev_priv->cp_mode != RADEON_CSQ_PRIBM_INDDIS ) && + ( dev_priv->cp_mode != RADEON_CSQ_PRIBM_INDBM ) ) { + DRM_DEBUG( "BAD cp_mode (%x)!\n", dev_priv->cp_mode ); + radeon_do_cleanup_cp(dev); + return DRM_ERR(EINVAL); + } + + if(!dev_priv->sarea) { + DRM_ERROR("could not find sarea!\n"); + radeon_do_cleanup_cp(dev); + return DRM_ERR(EINVAL); + } + + if(!dev_priv->fb) { + DRM_ERROR("could not find framebuffer!\n"); + radeon_do_cleanup_cp(dev); + return DRM_ERR(EINVAL); + } + + if(!dev_priv->mmio) { + DRM_ERROR("could not find mmio region!\n"); + radeon_do_cleanup_cp(dev); + return DRM_ERR(EINVAL); + } + + if(!dev_priv->cp_ring) { + DRM_ERROR("could not find cp ring region!\n"); + radeon_do_cleanup_cp(dev); + return DRM_ERR(EINVAL); + } + + if(!dev_priv->ring_rptr) { + DRM_ERROR("could not find ring read pointer!\n"); + radeon_do_cleanup_cp(dev); + return DRM_ERR(EINVAL); + } + + if(!dev_priv->buffers) { + DRM_ERROR("could not find dma buffer region!\n"); + radeon_do_cleanup_cp(dev); + return DRM_ERR(EINVAL); + } + + if ( !dev_priv->is_pci ) { + if(!dev_priv->agp_textures) { + DRM_ERROR("could not find agp texture region!\n"); + radeon_do_cleanup_cp(dev); + return DRM_ERR(EINVAL); + } + } + + if ( !dev_priv->is_pci ) { + if(!dev_priv->cp_ring->handle || + !dev_priv->ring_rptr->handle || + !dev_priv->buffers->handle) { + DRM_ERROR("could not find ioremap agp regions!\n"); + radeon_do_cleanup_cp(dev); + return DRM_ERR(EINVAL); + } + } else { + DRM_DEBUG( "dev_priv->cp_ring->handle %p\n", + dev_priv->cp_ring->handle ); + DRM_DEBUG( "dev_priv->ring_rptr->handle %p\n", + dev_priv->ring_rptr->handle ); + DRM_DEBUG( "dev_priv->buffers->handle %p\n", + dev_priv->buffers->handle ); + } + + + DRM_DEBUG( "dev_priv->agp_size %d\n", + dev_priv->agp_size ); + DRM_DEBUG( "dev_priv->agp_vm_start 0x%x\n", + dev_priv->agp_vm_start ); + DRM_DEBUG( "dev_priv->agp_buffers_offset 0x%lx\n", + dev_priv->agp_buffers_offset ); + +#if __REALLY_HAVE_AGP + if ( !dev_priv->is_pci ) { + /* Turn off PCI GART + */ + tmp = RADEON_READ( RADEON_AIC_CNTL ) + & ~RADEON_PCIGART_TRANSLATE_EN; + RADEON_WRITE( RADEON_AIC_CNTL, tmp ); + } else +#endif + { + /* I'm not so sure about this ati_picgart_init after at resume-time... */ + if (!DRM(ati_pcigart_init)( dev, &dev_priv->phys_pci_gart, + &dev_priv->bus_pci_gart)) { + DRM_ERROR( "failed to init PCI GART!\n" ); + radeon_do_cleanup_cp(dev); + return DRM_ERR(ENOMEM); + } + + tmp = RADEON_READ( RADEON_AIC_CNTL ) + | RADEON_PCIGART_TRANSLATE_EN; + RADEON_WRITE( RADEON_AIC_CNTL, tmp ); + + /* set PCI GART page-table base address + */ + RADEON_WRITE( RADEON_AIC_PT_BASE, dev_priv->bus_pci_gart ); + + /* set address range for PCI address translate + */ + RADEON_WRITE( RADEON_AIC_LO_ADDR, dev_priv->agp_vm_start ); + RADEON_WRITE( RADEON_AIC_HI_ADDR, dev_priv->agp_vm_start + + dev_priv->agp_size - 1); + + /* Turn off AGP aperture -- is this required for PCIGART? + */ + RADEON_WRITE( RADEON_MC_AGP_LOCATION, 0xffffffc0 ); /* ?? */ + RADEON_WRITE( RADEON_AGP_COMMAND, 0 ); /* clear AGP_COMMAND */ + } + + radeon_cp_load_microcode( dev_priv ); + radeon_cp_init_ring_buffer( dev, dev_priv ); + + radeon_do_engine_reset( dev ); + + return 0; +} + + int radeon_cp_init( DRM_IOCTL_ARGS ) { DRM_DEVICE; @@ -1456,6 +1626,16 @@ return radeon_do_cp_idle( dev_priv ); } +/* Added by Charl P. Botha to call radeon_do_resume_cp(). + */ +int radeon_cp_resume( DRM_IOCTL_ARGS ) +{ + DRM_DEVICE; + + return radeon_do_resume_cp(dev); +} + + int radeon_engine_reset( DRM_IOCTL_ARGS ) { DRM_DEVICE; diff -urN linux-2.5.69-bk17/drivers/char/drm/radeon_drm.h linux-2.5.69-bk18/drivers/char/drm/radeon_drm.h --- linux-2.5.69-bk17/drivers/char/drm/radeon_drm.h 2003-05-04 16:53:33.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/drm/radeon_drm.h 2003-05-25 04:38:55.000000000 -0700 @@ -385,6 +385,8 @@ #define DRM_IOCTL_RADEON_INIT_HEAP DRM_IOW( 0x55, drm_radeon_mem_init_heap_t) #define DRM_IOCTL_RADEON_IRQ_EMIT DRM_IOWR( 0x56, drm_radeon_irq_emit_t) #define DRM_IOCTL_RADEON_IRQ_WAIT DRM_IOW( 0x57, drm_radeon_irq_wait_t) +/* added by Charl P. Botha - see radeon_cp.c for details */ +#define DRM_IOCTL_RADEON_CP_RESUME DRM_IO(0x58) typedef struct drm_radeon_init { enum { diff -urN linux-2.5.69-bk17/drivers/char/drm/radeon_drv.h linux-2.5.69-bk18/drivers/char/drm/radeon_drv.h --- linux-2.5.69-bk17/drivers/char/drm/radeon_drv.h 2003-05-04 16:53:29.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/drm/radeon_drv.h 2003-05-25 04:38:55.000000000 -0700 @@ -159,6 +159,7 @@ extern int radeon_cp_stop( DRM_IOCTL_ARGS ); extern int radeon_cp_reset( DRM_IOCTL_ARGS ); extern int radeon_cp_idle( DRM_IOCTL_ARGS ); +extern int radeon_cp_resume( DRM_IOCTL_ARGS ); extern int radeon_engine_reset( DRM_IOCTL_ARGS ); extern int radeon_fullscreen( DRM_IOCTL_ARGS ); extern int radeon_cp_buffers( DRM_IOCTL_ARGS ); diff -urN linux-2.5.69-bk17/drivers/char/ipmi/ipmi_kcs_intf.c linux-2.5.69-bk18/drivers/char/ipmi/ipmi_kcs_intf.c --- linux-2.5.69-bk17/drivers/char/ipmi/ipmi_kcs_intf.c 2003-05-04 16:52:48.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/ipmi/ipmi_kcs_intf.c 2003-05-25 04:38:55.000000000 -0700 @@ -629,20 +629,6 @@ atomic_set(&kcs_info->req_events, 1); } -#if 0 -static int new_user(void *send_info) -{ - if (!try_module_get(THIS_MODULE)) - return -EBUSY; - return 0; -} - -static void user_left(void *send_info) -{ - module_put(THIS_MODULE); -} -#endif - static int initialized = 0; /* Must be called with interrupts off and with the kcs_lock held. */ diff -urN linux-2.5.69-bk17/drivers/char/ipmi/ipmi_msghandler.c linux-2.5.69-bk18/drivers/char/ipmi/ipmi_msghandler.c --- linux-2.5.69-bk17/drivers/char/ipmi/ipmi_msghandler.c 2003-05-25 04:38:50.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/ipmi/ipmi_msghandler.c 2003-05-25 04:38:55.000000000 -0700 @@ -175,7 +175,7 @@ ipmi_register_all_cmd_rcvr(ipmi_user_t user) { unsigned long flags; - int rv = -EBUSY; + int rv = -EBUSY; write_lock_irqsave(&(user->intf->users_lock), flags); write_lock(&(user->intf->cmd_rcvr_lock)); @@ -194,7 +194,7 @@ ipmi_unregister_all_cmd_rcvr(ipmi_user_t user) { unsigned long flags; - int rv = -EINVAL; + int rv = -EINVAL; write_lock_irqsave(&(user->intf->users_lock), flags); write_lock(&(user->intf->cmd_rcvr_lock)); @@ -431,6 +431,7 @@ { struct seq_table *ent = &(intf->seq_table[seq]); ent->timeout = ent->orig_timeout; + rv = 0; } spin_unlock_irqrestore(&(intf->seq_lock), flags); @@ -1023,7 +1024,7 @@ int rv; ipmi_smi_t new_intf; struct list_head *entry; - unsigned long flags; + unsigned long flags; /* Make sure the driver is actually initialized, this handles diff -urN linux-2.5.69-bk17/drivers/char/ipmi/ipmi_watchdog.c linux-2.5.69-bk18/drivers/char/ipmi/ipmi_watchdog.c --- linux-2.5.69-bk17/drivers/char/ipmi/ipmi_watchdog.c 2003-05-04 16:53:55.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/ipmi/ipmi_watchdog.c 2003-05-25 04:38:55.000000000 -0700 @@ -215,13 +215,13 @@ struct ipmi_recv_msg *recv_msg, int *send_heartbeat_now) { - struct ipmi_msg msg; - unsigned char data[6]; - int rv; + struct ipmi_msg msg; + unsigned char data[6]; + int rv; struct ipmi_system_interface_addr addr; + int hbnow = 0; - *send_heartbeat_now = 0; data[0] = 0; WDOG_SET_TIMER_USE(data[0], WDOG_TIMER_USE_SMS_OS); @@ -233,7 +233,7 @@ } else if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) { /* In ipmi 1.0, setting the timer stops the watchdog, we need to start it back up again. */ - *send_heartbeat_now = 1; + hbnow = 1; } data[1] = 0; @@ -268,10 +268,18 @@ rv); } + if (send_heartbeat_now) + *send_heartbeat_now = hbnow; + return rv; } -static int ipmi_set_timeout(void) +/* Parameters to ipmi_set_timeout */ +#define IPMI_SET_TIMEOUT_NO_HB 0 +#define IPMI_SET_TIMEOUT_HB_IF_NECESSARY 1 +#define IPMI_SET_TIMEOUT_FORCE_HB 2 + +static int ipmi_set_timeout(int do_heartbeat) { int send_heartbeat_now; int rv; @@ -288,8 +296,12 @@ if (rv) { up(&set_timeout_lock); } else { - if (send_heartbeat_now) + if ((do_heartbeat == IPMI_SET_TIMEOUT_FORCE_HB) + || ((send_heartbeat_now) + && (do_heartbeat == IPMI_SET_TIMEOUT_HB_IF_NECESSARY))) + { rv = ipmi_heartbeat(); + } } return rv; @@ -312,7 +324,7 @@ /* Special call, doesn't claim any locks. This is only to be called at panic or halt time, in run-to-completion mode, when the caller - is the only CPU and the only thing that will be going IPMI + is the only CPU and the only thing that will be going is these IPMI calls. */ static void panic_halt_ipmi_set_timeout(void) { @@ -339,7 +351,7 @@ else ipmi_watchdog_state = WDOG_TIMEOUT_RESET; timeout = delay; - ipmi_set_timeout(); + ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY); } /* We use a semaphore to make sure that only one thing can send a @@ -390,16 +402,14 @@ if (ipmi_start_timer_on_heartbeat) { ipmi_start_timer_on_heartbeat = 0; ipmi_watchdog_state = action_val; - return ipmi_set_timeout(); - } - - if (pretimeout_since_last_heartbeat) { + return ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB); + } else if (pretimeout_since_last_heartbeat) { /* A pretimeout occurred, make sure we set the timeout. We don't want to set the action, though, we want to leave that alone (thus it can't be combined with the above operation. */ pretimeout_since_last_heartbeat = 0; - return ipmi_set_timeout(); + return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY); } down(&heartbeat_lock); @@ -501,7 +511,7 @@ if (i) return -EFAULT; timeout = val; - return ipmi_set_timeout(); + return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY); case WDIOC_GETTIMEOUT: i = copy_to_user((void *) arg, @@ -516,7 +526,7 @@ if (i) return -EFAULT; pretimeout = val; - return ipmi_set_timeout(); + return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY); case WDIOC_GET_PRETIMEOUT: i = copy_to_user((void *) arg, @@ -536,14 +546,14 @@ if (val & WDIOS_DISABLECARD) { ipmi_watchdog_state = WDOG_TIMEOUT_NONE; - ipmi_set_timeout(); + ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB); ipmi_start_timer_on_heartbeat = 0; } if (val & WDIOS_ENABLECARD) { ipmi_watchdog_state = action_val; - ipmi_set_timeout(); + ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB); } return 0; @@ -679,7 +689,7 @@ { #ifndef CONFIG_WATCHDOG_NOWAYOUT ipmi_watchdog_state = WDOG_TIMEOUT_NONE; - ipmi_set_timeout(); + ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB); #endif ipmi_wdog_open = 0; } @@ -731,14 +741,14 @@ wake_up_interruptible(&read_q); kill_fasync(&fasync_q, SIGIO, POLL_IN); - /* On some machines, the heartbeat will give - an error and not work unless we re-enable - the timer. So do so. */ - pretimeout_since_last_heartbeat = 1; - spin_unlock(&ipmi_read_lock); } } + + /* On some machines, the heartbeat will give + an error and not work unless we re-enable + the timer. So do so. */ + pretimeout_since_last_heartbeat = 1; } static struct ipmi_user_hndl ipmi_hndlrs = @@ -779,7 +789,7 @@ /* Run from startup, so start the timer now. */ start_now = 0; /* Disable this function after first startup. */ ipmi_watchdog_state = action_val; - ipmi_set_timeout(); + ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB); printk("Starting IPMI Watchdog now!\n"); } } @@ -792,6 +802,12 @@ watchdog. */ if ((!handled) && (preop_val == WDOG_PREOP_PANIC)) panic("IPMI watchdog pre-timeout"); + + /* On some machines, the heartbeat will give + an error and not work unless we re-enable + the timer. So do so. */ + pretimeout_since_last_heartbeat = 1; + return NOTIFY_DONE; } @@ -1009,7 +1025,7 @@ /* Disable the timer. */ ipmi_watchdog_state = WDOG_TIMEOUT_NONE; - ipmi_set_timeout(); + ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB); /* Wait to make sure the message makes it out. The lower layer has pointers to our buffers, we want to make sure they are done before @@ -1096,7 +1112,7 @@ else if (strcmp(option, "preop_panic") == 0) { preop = "preop_panic"; } - else if (strcmp(option, "preop_none") == 0) { + else if (strcmp(option, "preop_give_data") == 0) { preop = "preop_give_data"; } else { printk("Unknown IPMI watchdog option: '%s'\n", option); diff -urN linux-2.5.69-bk17/drivers/char/vt_ioctl.c linux-2.5.69-bk18/drivers/char/vt_ioctl.c --- linux-2.5.69-bk17/drivers/char/vt_ioctl.c 2003-05-25 04:38:50.000000000 -0700 +++ linux-2.5.69-bk18/drivers/char/vt_ioctl.c 2003-05-25 04:38:55.000000000 -0700 @@ -59,7 +59,7 @@ */ unsigned char keyboard_type = KB_101; -#if !defined(__alpha__) && !defined(__ia64__) && !defined(__mips__) && !defined(__arm__) && !defined(__sh__) +#ifdef CONFIG_X86 asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int on); #endif @@ -424,11 +424,13 @@ ucval = keyboard_type; goto setchar; -#if !defined(__alpha__) && !defined(__ia64__) && !defined(__mips__) && !defined(__arm__) && !defined(__sh__) /* * These cannot be implemented on any machine that implements - * ioperm() in user level (such as Alpha PCs). + * ioperm() in user level (such as Alpha PCs) or not at all. + * + * XXX: you should never use these, just call ioperm directly.. */ +#ifdef CONFIG_X86 case KDADDIO: case KDDELIO: /* diff -urN linux-2.5.69-bk17/include/acpi/acpiosxf.h linux-2.5.69-bk18/include/acpi/acpiosxf.h --- linux-2.5.69-bk17/include/acpi/acpiosxf.h 2003-05-25 04:38:52.000000000 -0700 +++ linux-2.5.69-bk18/include/acpi/acpiosxf.h 2003-05-25 04:38:56.000000000 -0700 @@ -287,15 +287,15 @@ * Miscellaneous */ -u8 +BOOLEAN acpi_os_readable ( void *pointer, - acpi_size length); + u32 length); -u8 +BOOLEAN acpi_os_writable ( void *pointer, - acpi_size length); + u32 length); u32 acpi_os_get_timer ( diff -urN linux-2.5.69-bk17/include/asm-ppc/highmem.h linux-2.5.69-bk18/include/asm-ppc/highmem.h --- linux-2.5.69-bk17/include/asm-ppc/highmem.h 2003-05-04 16:53:42.000000000 -0700 +++ linux-2.5.69-bk18/include/asm-ppc/highmem.h 2003-05-25 04:38:56.000000000 -0700 @@ -54,8 +54,7 @@ static inline void *kmap(struct page *page) { - if (in_interrupt()) - BUG(); + might_sleep(); if (page < highmem_start_page) return page_address(page); return kmap_high(page); diff -urN linux-2.5.69-bk17/include/asm-ppc/pci.h linux-2.5.69-bk18/include/asm-ppc/pci.h --- linux-2.5.69-bk17/include/asm-ppc/pci.h 2003-05-04 16:53:36.000000000 -0700 +++ linux-2.5.69-bk18/include/asm-ppc/pci.h 2003-05-25 04:38:56.000000000 -0700 @@ -102,6 +102,9 @@ { if (direction == PCI_DMA_NONE) BUG(); + + consistent_sync(ptr, size, direction); + return virt_to_bus(ptr); } @@ -203,7 +206,8 @@ { if (direction == PCI_DMA_NONE) BUG(); - /* nothing to do */ + + consistent_sync(bus_to_virt(dma_handle), size, direction); } /* Make physical memory consistent for a set of streaming diff -urN linux-2.5.69-bk17/include/asm-ppc/pgtable.h linux-2.5.69-bk18/include/asm-ppc/pgtable.h --- linux-2.5.69-bk17/include/asm-ppc/pgtable.h 2003-05-04 16:53:07.000000000 -0700 +++ linux-2.5.69-bk18/include/asm-ppc/pgtable.h 2003-05-25 04:38:56.000000000 -0700 @@ -299,7 +299,8 @@ #define PAGE_COPY __pgprot(_PAGE_BASE | _PAGE_USER) #define PAGE_COPY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC) -#define PAGE_KERNEL __pgprot(_PAGE_RAM) +#define PAGE_KERNEL __pgprot(_PAGE_RAM) +#define PAGE_KERNEL_NOCACHE __pgprot(_PAGE_IO) /* * The PowerPC can only do execute protection on a segment (256MB) basis, @@ -515,7 +516,7 @@ /* * When flushing the tlb entry for a page, we also need to flush the hash - * table entry. flush_hash_page is assembler (for speed) in hashtable.S. + * table entry. flush_hash_pages is assembler (for speed) in hashtable.S. */ extern int flush_hash_pages(unsigned context, unsigned long va, unsigned long pmdval, int count); diff -urN linux-2.5.69-bk17/include/linux/elevator.h linux-2.5.69-bk18/include/linux/elevator.h --- linux-2.5.69-bk17/include/linux/elevator.h 2003-05-25 04:38:52.000000000 -0700 +++ linux-2.5.69-bk18/include/linux/elevator.h 2003-05-25 04:38:56.000000000 -0700 @@ -83,7 +83,6 @@ extern int elevator_init(request_queue_t *, elevator_t *); extern void elevator_exit(request_queue_t *); -extern inline int bio_rq_in_between(struct bio *, struct request *, struct list_head *); extern inline int elv_rq_merge_ok(struct request *, struct bio *); extern inline int elv_try_merge(struct request *, struct bio *); extern inline int elv_try_last_merge(request_queue_t *, struct bio *); diff -urN linux-2.5.69-bk17/include/linux/kobject.h linux-2.5.69-bk18/include/linux/kobject.h --- linux-2.5.69-bk17/include/linux/kobject.h 2003-05-04 16:52:50.000000000 -0700 +++ linux-2.5.69-bk18/include/linux/kobject.h 2003-05-25 04:38:56.000000000 -0700 @@ -12,7 +12,7 @@ #include #include -#define KOBJ_NAME_LEN 16 +#define KOBJ_NAME_LEN 20 struct kobject { char name[KOBJ_NAME_LEN]; diff -urN linux-2.5.69-bk17/scripts/kconfig/conf.c linux-2.5.69-bk18/scripts/kconfig/conf.c --- linux-2.5.69-bk17/scripts/kconfig/conf.c 2003-05-04 16:53:41.000000000 -0700 +++ linux-2.5.69-bk18/scripts/kconfig/conf.c 2003-05-25 04:38:56.000000000 -0700 @@ -456,29 +456,17 @@ return; sym = menu->sym; - if (!sym) - goto conf_childs; - - if (sym_is_choice(sym)) { - if (!sym_has_value(sym)) { + if (sym) { + if (sym_is_changable(sym) && !sym_has_value(sym)) { if (!conf_cnt++) printf("*\n* Restart config...\n*\n"); rootEntry = menu_get_parent_menu(menu); conf(rootEntry); } - if (sym_get_tristate_value(sym) != mod) + if (sym_is_choice(sym) && sym_get_tristate_value(sym) != mod) return; - goto conf_childs; - } - - if (!sym_has_value(sym)) { - if (!conf_cnt++) - printf("*\n* Restart config...\n*\n"); - rootEntry = menu_get_parent_menu(menu); - conf(rootEntry); } -conf_childs: for (child = menu->list; child; child = child->next) check_conf(child); } diff -urN linux-2.5.69-bk17/scripts/kconfig/menu.c linux-2.5.69-bk18/scripts/kconfig/menu.c --- linux-2.5.69-bk17/scripts/kconfig/menu.c 2003-05-04 16:53:41.000000000 -0700 +++ linux-2.5.69-bk18/scripts/kconfig/menu.c 2003-05-25 04:38:56.000000000 -0700 @@ -283,8 +283,7 @@ { enum prop_type type; - while (menu != &rootmenu) { - menu = menu->parent; + for (; menu != &rootmenu; menu = menu->parent) { type = menu->prompt ? menu->prompt->type : 0; if (type == P_MENU || type == P_ROOTMENU) break;