From pb@ludd.ltu.se  Mon Mar  1 22:25:04 2004
Return-Path: <pb@ludd.ltu.se>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id B2E9916A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  1 Mar 2004 22:25:04 -0800 (PST)
Received: from mother.ludd.ltu.se (mother.ludd.ltu.se [130.240.16.3])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 5472F43D49
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  1 Mar 2004 22:25:03 -0800 (PST)
	(envelope-from pb@ludd.ltu.se)
Received: from brother.ludd.ltu.se (daemon@brother.ludd.ltu.se [130.240.16.78])
	by mother.ludd.ltu.se (8.12.10+Sun/8.12.10) with ESMTP id i226P1Ar003263
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 2 Mar 2004 07:25:01 +0100 (MET)
Received: (from pb@localhost)
	by brother.ludd.ltu.se (8.11.6+Sun/8.9.3) id i226P1Y10576
	for FreeBSD-gnats-submit@freebsd.org; Tue, 2 Mar 2004 07:25:01 +0100 (MET)
Message-Id: <200403020625.i226P1Y10576@brother.ludd.ltu.se>
Date: Tue, 2 Mar 2004 07:25:01 +0100 (MET)
From: Peter B <pb@ludd.ltu.se>
To: FreeBSD-gnats-submit@freebsd.org
Subject: mounting atapicam volume through cd0c cause data corruption

>Number:         63629
>Category:       kern
>Synopsis:       [atapicam] mounting atapicam volume through cd0c cause data corruption
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    linimon
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 01 22:30:15 PST 2004
>Closed-Date:    Tue Feb 23 15:01:44 UTC 2010
>Last-Modified:  Tue Feb 23 15:01:44 UTC 2010
>Originator:     Charlie &
>Release:        FreeBSD 4.9-RELEASE i386
>Organization:
>Environment:
 
 System: FreeBSD 4.9-RELEASE #0: Fri Feb 13 16:09:18 CET 2004 pb@host:/usr/src/sys/compile/ASUSP166 i386
 	CPU:		Intel P166
 	Memory:		32 MB
 	Motherboard:	ASUS TX97-X
 	PCI:		S3 Trio64V+
 	PCI:		Intel Pro 10/100  (fxp0)
 	ata0-master:	Seagate ST3491A		(40 pin ribbon, pio3)
 	ata1-master:	Lite-On LDW-451S	(80 pin ribbon, udma33)
 	Floppy:		1.44 MB
 
 Kernel configuration file: /usr/src/sys/i386/conf/ASUSP166
   
   machine		i386
   cpu			I586_CPU
   
   options		CPU_ENABLE_SSE		# enables SSE/MMX2 instructions support.
   options		CPU_FASTER_5X86_FPU	# enables faster FPU exception handler.
   
   ident		GENERIC
   maxusers	0
   
   options 	INET			#InterNETworking
   options 	FFS			#Berkeley Fast Filesystem
   options 	FFS_ROOT		#FFS usable as root device [keep this!]
   options 	SOFTUPDATES		#Enable FFS soft updates support
   options 	UFS_DIRHASH		#Improve performance on big directories
   options 	MFS			#Memory Filesystem
   options 	MD_ROOT			#MD is a potential root device
   options 	NFS			#Network Filesystem
   options 	NFS_ROOT		#NFS usable as root device, NFS required
   options 	MSDOSFS			#MSDOS Filesystem
   options 	CD9660			#ISO 9660 Filesystem
   options 	CD9660_ROOT		#CD-ROM usable as root, CD9660 required
   options 	PROCFS			#Process filesystem
   options 	COMPAT_43		#Compatible with BSD 4.3 [KEEP THIS!]
   options 	SCSI_DELAY=15000	#Delay (in ms) before probing SCSI
   options 	UCONSOLE		#Allow users to grab the console
   options 	USERCONFIG		#boot -c editor
   options 	VISUAL_USERCONFIG	#visual boot -c editor
   options 	KTRACE			#ktrace(1) support
   options 	SYSVSHM			#SYSV-style shared memory
   options 	SYSVMSG			#SYSV-style message queues
   options 	SYSVSEM			#SYSV-style semaphores
   options 	P1003_1B		#Posix P1003_1B real-time extensions
   options 	_KPOSIX_PRIORITY_SCHEDULING
   options 	ICMP_BANDLIM		#Rate limit bad replies
   options 	KBD_INSTALL_CDEV	# install a CDEV entry in /dev
   options 	AHC_REG_PRETTY_PRINT	# Print register bitfields in debug
   					# output.  Adds ~128k to driver.
   options 	AHD_REG_PRETTY_PRINT	# Print register bitfields in debug 
   					# output.  Adds ~215k to driver.
   
   device		isa
   options		AUTO_EOI_1
   options		AUTO_EOI_2 # works for some clones and some integrated versions.
   
   device		pci
   options         PCI_ENABLE_IO_MODES
   
   device		fdc0	at isa? port IO_FD1 irq 6 drq 2
   device		fd0	at fdc0 drive 0
   device		fd1	at fdc0 drive 1
   
   device		ata0	at isa? port IO_WD1 irq 14
   device		ata
   device		atadisk			# ATA disk drives
   device		atapicd			# ATAPI CDROM drives
   device		atapifd			# ATAPI floppy drives
   device		atapist			# ATAPI tape drives
   device          atapicam		# emulate ATAPI devices as SCSI ditto via CAM
   					# needs CAM to be present (scbus & pass)
   options 	ATA_STATIC_ID		#Static device numbering
   
   device		ahc		# AHA2940 and onboard AIC7xxx devices
   device		ncr		# NCR/Symbios Logic
   device		sym		# NCR/Symbios Logic (newer chipsets)
   options 	SYM_SETUP_LP_PROBE_MAP=0x40
   				# Allow ncr to attach legacy NCR devices when 
   				# both sym and ncr are configured
   
   device		aha0	at isa?
   
   device		scbus		# SCSI bus (required)
   device		da		# Direct Access (disks)
   device		sa		# Sequential Access (tape etc)
   device		cd		# CD
   device		pass		# Passthrough device (direct SCSI access)
   
   device		atkbdc0	at isa? port IO_KBD		# AT keyboard
   device		atkbd0	at atkbdc? irq 1 flags 0x1
   device		psm0	at atkbdc? irq 12		# PS/2 mouse
   
   device		vga0	at isa?				# VGA console
   
   pseudo-device	splash
   
   device		sc0	at isa? flags 0x100
   
   device		agp		# support several AGP chipsets
   
   device		npx0	at nexus? port IO_NPX irq 13
   
   device		apm0	at nexus? disable flags 0x20 # Advanced Power Management
   
   device		sio0	at isa? port IO_COM1 flags 0x10 irq 4
   device		sio1	at isa? port IO_COM2 irq 3
   
   device		ppc0	at isa? irq 7
   device		ppbus		# Parallel port bus (required)
   device		lpt		# Printer
   device		plip		# TCP/IP over parallel
   device		ppi		# Parallel port interface device
   
   device		miibus		# MII bus support
   device		fxp		# Intel EtherExpress PRO/100B (82557, 82558)
   device		rl		# RealTek 8129/8139
   
   device          smbus           # Bus support, required for smb below.
   device          intpm		# Intel PIIX4 (82371AB, 82443MX) Power Management Unit
   device          smb
   
   device		ed0	at isa? disable port 0x280 irq 10 iomem 0xd8000
   
   device          pca0 at isa? port IO_TIMER1
   
   device          joy0    at isa? port IO_GAME  # joystick
   
   pseudo-device	loop		# Network loopback
   pseudo-device	ether		# Ethernet support
   pseudo-device	sl	1	# Kernel SLIP
   pseudo-device	ppp	1	# Kernel PPP
   pseudo-device	tun		# Packet tunnel.
   pseudo-device	pty		# Pseudo-ttys (telnet etc)
   pseudo-device   speaker         #Play IBM BASIC-style noises out your speaker
   pseudo-device   vn              #Vnode driver (turns a file into a device)
   pseudo-device	md		# Memory "disks"
   
   options         IPFIREWALL              #firewall
   options         IPFIREWALL_VERBOSE      #enable logging to syslogd(8)
   options         IPFIREWALL_VERBOSE_LIMIT=100    #limit verbosity
   
   pseudo-device	bpf		#Berkeley packet filter
   
   device		uhci		# UHCI PCI->USB interface
   device		ohci		# OHCI PCI->USB interface
   device		usb		# USB Bus (required)
   device		ugen		# Generic
   device		uhid		# "Human Interface Devices"
   device		ukbd		# Keyboard
   device		ulpt		# Printer
   device		umass		# Disks/Mass storage - Requires scbus and da
   device		ums		# Mouse
   device		uscanner	# Scanners  
 
 Dmesg:
   Copyright (c) 1992-2003 The FreeBSD Project.
   Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
   	The Regents of the University of California. All rights reserved.
   FreeBSD 4.9-RELEASE #0: Fri Feb 13 16:09:18 CET 2004
       pb@xray.campus.luth.se:/usr/src/sys/compile/ASUSP166
   Timecounter "i8254"  frequency 1193182 Hz
   CPU: Pentium/P55C (167.05-MHz 586-class CPU)
     Origin = "GenuineIntel"  Id = 0x542  Stepping = 2
     Features=0x8001bf<FPU,VME,DE,PSE,TSC,MSR,MCE,CX8,MMX>
   real memory  = 33554432 (32768K bytes)
   config> en psm0
   config> #di ppc0
   Invalid command or syntax.  Type `?' for help.
   config> #di sio0
   Invalid command or syntax.  Type `?' for help.
   config> #di sio1
   Invalid command or syntax.  Type `?' for help.
   config> di ata1
   No such device: ata1
   Invalid command or syntax.  Type `?' for help.
   config> en apm
   config> #
   Invalid command or syntax.  Type `?' for help.
   config> di pcic0
   No such device: pcic0
   Invalid command or syntax.  Type `?' for help.
   config> di bt0
   No such device: bt0
   Invalid command or syntax.  Type `?' for help.
   config> di aic0
   No such device: aic0
   Invalid command or syntax.  Type `?' for help.
   config> di aha0
   config> di adv0
   No such device: adv0
   Invalid command or syntax.  Type `?' for help.
   config> q
   avail memory = 28819456 (28144K bytes)
   Preloaded elf kernel "kernel" at 0xc03e7000.
   Preloaded userconfig_script "/boot/kernel.conf" at 0xc03e709c.
   Intel Pentium detected, installing workaround for F00F bug
   md0: Malloc disk
       ACPI-0159: *** Error: AcpiLoadTables: Could not get RSDP, AE_NO_ACPI_TABLES
       ACPI-0213: *** Error: AcpiLoadTables: Could not load tables: AE_NO_ACPI_TABLES
   ACPI: table load failed: AE_NO_ACPI_TABLES
   Using $PIR table, 7 entries at 0xc00f0a90
   apm0: <APM BIOS> on motherboard
   apm0: found APM BIOS v1.2, connected at v1.2
   npx0: <math processor> on motherboard
   npx0: INT 16 interface
   pcib0: <Host to PCI bridge> on motherboard
   pci0: <PCI bus> on pcib0
   isab0: <Intel 82371AB PCI to ISA bridge> at device 1.0 on pci0
   isa0: <ISA bus> on isab0
   atapci0: <Intel PIIX4 ATA33 controller> port 0xe000-0xe00f at device 1.1 on pci0
   ata0: at 0x1f0 irq 14 on atapci0
   ata1: at 0x170 irq 15 on atapci0
   uhci0: <Intel 82371AB/EB (PIIX4) USB controller> port 0xd800-0xd81f irq 9 at device 1.2 on pci0
   usb0: <Intel 82371AB/EB (PIIX4) USB controller> on uhci0
   usb0: USB revision 1.0
   uhub0: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
   uhub0: 2 ports with 2 removable, self powered
   intpm0: <Intel 82371AB Power management controller> port 0xe800-0xe80f irq 9 at device 1.3 on pci0
   intpm0: I/O mapped e800
   intpm0: intr IRQ 9 enabled revision 0
   smbus0: <System Management Bus> on intsmb0
   smb0: <SMBus general purpose I/O> on smbus0
   intpm0: PM I/O mapped e400 
   fxp0: <Intel 82558 Pro/100 Ethernet> port 0xd400-0xd41f mem 0xe6800000-0xe68fffff,0xe7800000-0xe7800fff irq 10 at device 10.0 on pci0
   fxp0: Ethernet address 00:a0:c9:e7:37:0b
   inphy0: <i82555 10/100 media interface> on miibus0
   inphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
   pci0: <S3 Trio graphics accelerator> at 12.0 irq 11
   orm0: <Option ROM> at iomem 0xc0000-0xc7fff on isa0
   pmtimer0 on isa0
   fdc0: <NEC 72065B or clone> at port 0x3f0-0x3f5,0x3f7 irq 6 drq 2 on isa0
   fdc0: FIFO enabled, 8 bytes threshold
   atkbdc0: <Keyboard controller (i8042)> at port 0x60,0x64 on isa0
   atkbd0: <AT Keyboard> flags 0x1 irq 1 on atkbdc0
   kbd0 at atkbd0
   vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
   sc0: <System console> at flags 0x100 on isa0
   sc0: VGA <16 virtual consoles, flags=0x300>
   sio0 at port 0x3f8-0x3ff irq 4 flags 0x10 on isa0
   sio0: type 16550A
   sio1 at port 0x2f8-0x2ff irq 3 on isa0
   sio1: type 16550A
   ppc0: <Parallel port> at port 0x378-0x37f irq 7 on isa0
   ppc0: SMC-like chipset (ECP/EPP/PS2/NIBBLE) in COMPATIBLE mode
   ppc0: FIFO with 16/16/16 bytes threshold
   plip0: <PLIP network interface> on ppbus0
   lpt0: <Printer> on ppbus0
   lpt0: Interrupt-driven port
   ppi0: <Parallel I/O> on ppbus0
   pca0 at port 0x40 on isa0
   joy0 at port 0x201 on isa0
   IP packet filtering initialized, divert disabled, rule-based forwarding enabled, default to deny, logging limited to 100 packets/entry by default
   ad0: 408MB <ST3491A D> [899/15/62] at ata0-master PIO3
   acd0: CD-RW <LITE-ON DVDRW LDW-451S> at ata1-master UDMA33
   Mounting root from ufs:/dev/ad0s1a
   cd0 at ata1 bus 0 target 0 lun 0
   cd0: <LITE-ON DVDRW LDW-451S GSB4> Removable CD-ROM SCSI-0 device 
   cd0: 33.000MB/s transfers
   cd0: cd present [2258544 x 2048 byte records]
 
>Description:
 	Mounting the dvd-writer as scsi device cause files to appear corrupt.
 	AND causes system instability with all kinds of processes dieying from
 	signal 10 SIGBUS. Like there is some kind of ram problem..
 
 	PR http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/62507 seems to
 	be related to this issue.
 	
 	I have now tested to mount the drive as atapi unit instead. And it
 	seems to work flawlessly on repeated file comparisions.
 
 	It can't be good that the 4.x has this issue as it considered
 	production use..
 	Burning dvd discs with cd0c seems to work ok. (luckily :)
 	Also the 'psm0' device seems to not be detected on this machine
 	aswell.. (same problem present on a friends AMDXP2400 laptop).
 
>How-To-Repeat:
 	* Connect an DVD-Writer (cd?) to your computer.
 	* Compile kernel with atapicam, scbus, pass.
         * mount_cd9660 /dev/cd0c /cd
         * Read any file.. In particular verify them with cmp or md5.
 
>Fix:
 	mount_cd9660 /dev/acd0c /cd
 	And NEVER use cd0c unless you have to.
 
 	Bad allocation/use of datatransfer setup or buffers?
 
>Release-Note:
>Audit-Trail:

From: Peter B <pb@ludd.ltu.se>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: pending/63629: mounting atapicam volume through cd0c cause data corruption
Date: Fri, 12 Mar 2004 09:17:11 +0100 (MET)

 What doesn't work with direct ata works over usb->ata.. I attached an external
 usb-ata box with drive and THEN "mount_cd9660 /dev/cd0c /mnt/cd0" DOES work
 without data corruption (what I have noticed).
 
 Hardware:
   Asus TX97-X builtin USB1 port (Motherboard)
   uKnight External Aluminium closure (ATA->USB2)
   Lite-On LDW-451S  (ATA-DVD burner)
 
 Software:
   Previously PR'd kernel config and version.
 
 After booting machine I connect the powered up box:
   umass0: Genesyslogic USB Mass Storage Device, rev 2.00/0.02, addr 2
 
   cd0 at umass-sim0 bus 0 target 0 lun 0
   cd0: <LITE-ON DVDRW LDW-451S GSB4> Removable CD-ROM SCSI-0 device 
   cd0: 650KB/s transfers
   cd0: Attempt to query device size failed: NOT READY, Medium not present
 
 And then type "mount_cd9660 /dev/cd0c /mnt/cd0" as root. Which produces:
   umass0: Unsupported ATAPI command 0x43
   last message repeated 4 times
 
   cd9660: RockRidge Extension
 
 The disc is accessable and md5 checksums match this time.
 
 I hope this can help to pinpoint the cause of the problem.
 
Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Thu Apr 1 10:23:22 PST 2004 
Responsible-Changed-Why:  
Try to rescue this badly misformatted PR from the 'pending' category. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=63629 
Responsible-Changed-From-To: freebsd-bugs->thomas 
Responsible-Changed-By: arved 
Responsible-Changed-When: Sat Aug 28 18:53:26 GMT 2004 
Responsible-Changed-Why:  
Over to atapicam Maintainer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=63629 

From: Thomas Quinot <thomas@FreeBSD.ORG>
To: pb@ludd.ltu.se
Cc: bug-followup@FreeBSD.org
Subject: Re: kern/63629: mounting atapicam volume through cd0c cause data corruption
Date: Sun, 29 Aug 2004 18:52:11 +0200

 * Tilman Linneweh, 2004-08-28 :
 
 > Subject: Re: kern/63629: mounting atapicam volume through cd0c cause data corruption
 
 Does this problem occur with an up-to-date system (RELENG_4, RELENG_5
 or HEAD)?
 
 Thomas.
 
 -- 
     Thomas.Quinot@Cuivre.FR.EU.ORG

From: Thomas Quinot <thomas@FreeBSD.ORG>
To: Peter B <pb@ludd.ltu.se>
Cc: bug-followup@freebsd.org
Subject: Re: kern/63629: mounting atapicam volume through cd0c cause data corruption
Date: Sun, 29 Aug 2004 19:09:37 +0200

 * Peter B, 2004-08-29 :
 
 > You can provoke the system by mounting a ufs1 filesystem on a umass device. Or
 > using scsi-atapi to mount a ata drive as a scsi drive.
 
 Ah, this is an interesting datapoint. If the problem show up with umass
 or with plain ATA disks, then it rules out an ATAPI/CAM issue, since
 neither umass nor ATA use ATAPI/CAM.
 
 Thomas.
 
 -- 
     Thomas.Quinot@Cuivre.FR.EU.ORG

From: Thomas Quinot <thomas@FreeBSD.ORG>
To: Peter B <pb@ludd.ltu.se>
Cc: bug-followup@freebsd.org
Subject: Re: kern/63629: mounting atapicam volume through cd0c cause data corruption
Date: Sun, 29 Aug 2004 19:23:19 +0200

 [ Please do not remove bug-followup@freebsd.org from the Cc: list, it is
   necessary to ensure proper tracking of this exchange. ]
 
 * Peter B, 2004-08-29 :
 
 > Well I have corrupt dvd-burns and the dvd burner is used as scsi device. And
 > the drive is p-ata type. To make use of it you have to enable atapi/cam.
 > This is kind ot tough, because dvd-r is by its very nature.. hard to fix ;)
 
 There seems to be some confusion here. Are you using an ATA drive or an
 ATAPI drive? What about the umass drive you were mentioning in your
 initial report?
 
 -- 
     Thomas.Quinot@Cuivre.FR.EU.ORG

From: Peter B <pb@ludd.ltu.se>
To: thomas@FreeBSD.ORG (Thomas Quinot)
Cc: bug-followup@FreeBSD.ORG
Subject: Re: kern/63629: mounting atapicam volume through cd0c cause data corruption
Date: Sun, 29 Aug 2004 19:43:49 +0200 (MEST)

 Thomas Quinot wrote:
 >
 >[ Please do not remove bug-followup@freebsd.org from the Cc: list, it is
 >  necessary to ensure proper tracking of this exchange. ]
 MUA fault.. fixed by hand ;)
 
 >There seems to be some confusion here. Are you using an ATA drive or an
 >ATAPI drive? What about the umass drive you were mentioning in your
 >initial report?
 
 There is a problem in the following situations (i386):
   4.9:  P-Ata dvd-writer(device) + atapi/cam(kernopt) + dvd+rw-tools(port)
         Burning & Reading is corrupted.
         4.9 is a pentium machine as mentioned in the PR.
 
   5.2:  Connecting an P-Ata device in a umass "chassi" and mounting it as
         scsi device cause mysterious empty files when copying and misc
         "stalled" messages in syslog. Which will not occour for msdos type fs.
         5.2 is on a acer laptop t-220.
 
          /P
 

From: Thomas Quinot <thomas@FreeBSD.ORG>
To: Peter B <pb@ludd.ltu.se>
Cc: bug-followup@FreeBSD.ORG
Subject: Re: kern/63629: mounting atapicam volume through cd0c cause data corruption
Date: Tue, 14 Sep 2004 14:17:38 +0200

 * Peter B, 2004-08-29 :
 
 > There is a problem in the following situations (i386):
 >   4.9:  P-Ata dvd-writer(device) + atapi/cam(kernopt) + dvd+rw-tools(port)
 >         Burning & Reading is corrupted.
 >         4.9 is a pentium machine as mentioned in the PR.
 
 4.9 is an old release from the RELENG_4 branch, this may have been fixed
 in 4.10.
 
 >   5.2:  Connecting an P-Ata device in a umass "chassi" and mounting it as
 >         scsi device cause mysterious empty files when copying and misc
 >         "stalled" messages in syslog. Which will not occour for msdos type fs.
 >         5.2 is on a acer laptop t-220.
 
 Then the problem under 5.2 is not in ATAPI/CAM.
 
 Thomas.
 
 -- 
     Thomas.Quinot@Cuivre.FR.EU.ORG
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Tue Feb 23 15:00:01 UTC 2010 
State-Changed-Why:  
PR applies to versions of FreeBSD that are no longer supported.  The 
code has been rewritten since this PR was filed. 


Responsible-Changed-From-To: thomas->linimon 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue Feb 23 15:00:01 UTC 2010 
Responsible-Changed-Why:  
thomas' commit bit has been taken for safeskeeping per his request. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=63629 
>Unformatted:
