Bug 198336

Summary: sysutils/dvd+rw-tools: Fails to run growisofs: :-( unable to CAMGETPASSTHRU for /dev/cd0: Inappropriate ioctl for device
Product: Base System Reporter: papowell
Component: kernAssignee: Warner Losh <imp>
Status: In Progress ---    
Severity: Affects Only Me CC: andreas.mahling, arved, grahamperrin, imp, mbeis
Priority: --- Flags: linimon: mfc-stable14?
linimon: mfc-stable13?
Version: 15.0-CURRENT   
Hardware: amd64   
OS: Any   

Description papowell 2015-03-06 00:33:26 UTC
This showed up on a FreeBSD 9.3 system when I tried to burn a DVD.  A similar error message historically indicated atapicam module may need to be loaded.  However, this failed.  Please note that the FreeBSD Handbook provides instructions on how to burn a DVD and this procedure does not work.

Does another module need to be loaded or is there some sort of permissions issue?  Note that the cdrecord program seemed to detect the DVD burner,


laptop_93: {39} # grep -r ata_controlcmd /usr/src/sys
/usr/src/sys/dev/ata/ata-all.c: error = ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_SETXFER, 0, mode);
/usr/src/sys/dev/ata/atapi-cd.c:    ata_controlcmd(dev, ATA_DEVICE_RESET, 0, 0, 0);
/usr/src/sys/dev/ata/atapi-cd.c:        ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0);
/usr/src/sys/dev/ata/atapi-fd.c:        ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0);
/usr/src/sys/dev/ata/ata-disk.c:        ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0);
/usr/src/sys/dev/ata/ata-disk.c:            error = ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0);
/usr/src/sys/dev/ata/ata-disk.c:        ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_ENAB_RCACHE, 0, 0);
/usr/src/sys/dev/ata/ata-disk.c:            ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_ENAB_WCACHE, 0, 0);
/usr/src/sys/dev/ata/ata-disk.c:            ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_DIS_WCACHE, 0, 0);
/usr/src/sys/dev/ata/ata-disk.c:        if (!ata_controlcmd(dev, ATA_SET_MULTI, 0, 0, secsperint))
/usr/src/sys/dev/ata/ata-all.h:int ata_controlcmd(device_t dev, u_int8_t command, u_int16_t feature, u_int64_t lba, u_int
16_t count);
/usr/src/sys/dev/ata/atapi-cam.c:       ata_controlcmd(softc->atadev[tid]->dev, ATA_DEVICE_RESET, 0, 0, 0);
/usr/src/sys/dev/ata/ata-queue.c:ata_controlcmd(device_t dev, u_int8_t command, u_int16_t feature,
/usr/src/sys/dev/ata/atapi-tape.c:      ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0);
/usr/src/sys/dev/ata/ata-raid.c:                error |= ata_controlcmd(rdp->disks[disk].dev,
/usr/src/sys/modules/ata/atadevel/ata-devel.c:    error = ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_SETXFER, 0,

 

FreeBSD laptop_93.private 9.3-RELEASE-p10 FreeBSD 9.3-RELEASE-p10 #0: Tue Feb 24 21:28:03 UTC 201
5     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64

laptop_93: {33} # cdrecord -v -scanbus
Cdrecord-ProDVD-ProBD-Clone 3.00 (amd64-unknown-freebsd9.1) Copyright (C) 1995-2010 J\xf6rg Schil
ling
TOC Type: 1 = CD-ROM
Using libscg version 'schily-0.9'.
SCSI buffer size: 65536
scsibus0:
        0,0,0     0) '' '' '' NON CCS Disk
        0,1,0     1) *
        0,2,0     2) *
        0,3,0     3) *
        0,4,0     4) *
        0,5,0     5) *
        0,6,0     6) *
        0,7,0     7) *
scsibus1:
        1,0,0   100) 'HL-DT-ST' 'DVD+-RW GS30N   ' 'A101' Removable CD-ROM
        1,1,0   101) *
        1,2,0   102) *
        1,3,0   103) *
        1,4,0   104) *
        1,5,0   105) *
        1,6,0   106) *
        1,7,0   107) *
scsibus2:
        2,0,0   200) '' '' '' NON CCS Disk
        2,1,0   201) *
        2,2,0   202) *
        2,3,0   203) *
        2,4,0   204) *
        2,5,0   205) *
        2,6,0   206) *
        2,7,0   207) *
TRYING /dev/cd0
laptop_93: {35} # growisofs -dvd-compat -Z /dev/cd0=FreeBSD-9.3-RELEASE-amd64-dvd1.iso
:-( unable to CAMGETPASSTHRU for /dev/cd0: Inappropriate ioctl for device

laptop_93: {37} # kldload atapicam.ko
kldload: an error occurred while loading the module. Please check dmesg(8) for more details.
laptop_93: {18} # dmesg
link_elf_obj: symbol ata_controlcmd undefined
linker_load_file: Unsupported file type


laptop_93: {39} # grep -r ata_controlcmd /usr/src/sys
/usr/src/sys/dev/ata/ata-all.c: error = ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_SETXFER, 0, mode);
/usr/src/sys/dev/ata/atapi-cd.c:    ata_controlcmd(dev, ATA_DEVICE_RESET, 0, 0, 0);
/usr/src/sys/dev/ata/atapi-cd.c:        ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0);
/usr/src/sys/dev/ata/atapi-fd.c:        ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0);
/usr/src/sys/dev/ata/ata-disk.c:        ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0);
/usr/src/sys/dev/ata/ata-disk.c:            error = ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0);
/usr/src/sys/dev/ata/ata-disk.c:        ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_ENAB_RCACHE, 0, 0);
/usr/src/sys/dev/ata/ata-disk.c:            ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_ENAB_WCACHE, 0, 0);
/usr/src/sys/dev/ata/ata-disk.c:            ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_DIS_WCACHE, 0, 0);
/usr/src/sys/dev/ata/ata-disk.c:        if (!ata_controlcmd(dev, ATA_SET_MULTI, 0, 0, secsperint))
/usr/src/sys/dev/ata/ata-all.h:int ata_controlcmd(device_t dev, u_int8_t command, u_int16_t feature, u_int64_t lba, u_int
16_t count);
/usr/src/sys/dev/ata/atapi-cam.c:       ata_controlcmd(softc->atadev[tid]->dev, ATA_DEVICE_RESET, 0, 0, 0);
/usr/src/sys/dev/ata/ata-queue.c:ata_controlcmd(device_t dev, u_int8_t command, u_int16_t feature,
/usr/src/sys/dev/ata/atapi-tape.c:      ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0);
/usr/src/sys/dev/ata/ata-raid.c:                error |= ata_controlcmd(rdp->disks[disk].dev,
/usr/src/sys/modules/ata/atadevel/ata-devel.c:    error = ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_SETXFER, 0,
Comment 1 papowell 2015-03-06 15:03:48 UTC
I forgot to indicate that I have:

/boot/loader.conf:

atapicam_load="YES"

But when I do kldstat it does not show up in the installed modules list.
Comment 2 Graham Perrin freebsd_committer freebsd_triage 2022-05-23 19:13:51 UTC
Cross-reference: <https://forums.freebsd.org/threads/85282/>
Comment 3 Kubilay Kocak freebsd_committer freebsd_triage 2022-05-24 03:18:13 UTC
Re-classify (ports issue) until any (potential) base issue can be identified.

We'll need reproduction against a supported FreeBSD version too.
Comment 4 amahling 2022-06-09 19:04:15 UTC
I have a similar issue with CD ripping tool audio/freac v1.1.5

It runs flawlessly under 13.0, after upgrading base system to 13.1 it fails to connect to /dev/cd0 with error 

++ WARN: ioctl(fd, CDIOCALLOW) failed: Invalid argument

++ WARN: open: Inappropriate ioctl for device

It doesn't matter whether I use the freac package or compile it from the ports tree

uname -a 
FreeBSD NomadBSD 13.1-RELEASE FreeBSD 13.1-RELEASE releng/13.1-n250148-fc952ac2212 GENERIC amd64

I've added the comment, because I suppose it is a problem with the base system. Please let me know, if I would better open a bug report for the freac port. Thank you.
Comment 5 Warner Losh freebsd_committer freebsd_triage 2024-07-25 04:30:22 UTC
I have a fix. I'll commit and merge to 14 and 13.
Comment 6 commit-hook freebsd_committer freebsd_triage 2024-07-25 04:49:39 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=028b16e2088a682c1abfb74fa5eb7ff64405ffff

commit 028b16e2088a682c1abfb74fa5eb7ff64405ffff
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-07-25 04:47:45 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-07-25 04:47:45 +0000

    cam: better ioctl compatibility for cd

    Unlike xpt and pass driver, there's no test for ENOTTY in cdioctl to try
    the compatbility ioctls. Add one.

    However, this is a disk ioctl, not a cdev ioctl. To get around this, we
    cast the struct disk * to a struct cdev * to pass through. We cast it
    back in a simple wrapper function.

    PR:                     198336
    Sponsored by:           Netflix
    MFC after:              2 weeks
    Differential Revision:  https://reviews.freebsd.org/D42666
    Differential Revision:  https://reviews.freebsd.org/D35312

 sys/cam/cam_compat.c |  6 ++++++
 sys/cam/cam_periph.c | 22 +++++++++++++++++++++-
 2 files changed, 27 insertions(+), 1 deletion(-)
Comment 7 Mark Linimon freebsd_committer freebsd_triage 2024-11-23 23:50:38 UTC
^Triage: patch committed but into src tree.  Reclassify a bit.