Package: hdparm
Version: 9.51+ds-1

Part of debian package hdparm is a file /lib/hdparm/hdparm-functions
which is not available in the upstream hdparm project. Therefore this
file is debian specific.

On every startup of my computer I'm seeing following errors in dmesg.

[    9.004058] ata1.00: exception Emask 0x1 SAct 0x0 SErr 0x0 action 0x0
[    9.004127] ata1.00: CPB resp_flags 0x11: , CMD error
[    9.004171] ata1.00: failed command: SET FEATURES
[    9.004219] ata1.00: cmd ef/05:fe:00:00:00/00:00:00:00:00/40 tag 6
[    9.004219]          res 51/04:fe:00:00:00/00:00:00:00:00/40 Emask 0x1 
(device error)
[    9.004333] ata1.00: status: { DRDY ERR }
[    9.004368] ata1.00: error: { ABRT }

I debugged it and this error is triggered by that shell fragment file
/lib/hdparm/hdparm-functions when it calls command:

/sbin/hdparm -B254 $DRIVE

When I call this command manually I'm getting:

$ sudo hdparm -B254 /dev/sda

/dev/sda:
 setting Advanced Power Management level to 0xfe (254)
SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 04 51 40 fe 21 04 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 APM_level      = not supported

(plus above errors in dmesg)

Call -B without APM level issue just get command and it does not trigger
above dmesg error. Moreover output is clear, that APM is not supported:

$ sudo hdparm -B /dev/sda

/dev/sda:
 APM_level      = not supported

Therefore I would propose following change to the hdparm-funcions file
to skip setting APM when it is unsupported.

--- /lib/hdparm/hdparm-functions        2017-01-24 12:20:05.000000000 +0100
+++ /lib/hdparm/hdparm-functions        2018-05-09 14:37:20.795077941 +0200
@@ -56,6 +56,9 @@ hdparm_try_apm()
             return 1
             ;;
     esac
+    if hdparm -B "$1" 2>/dev/null | grep -q 'not supported'; then
+        return 1
+    fi
     return 0
 }
 

With applied this patch I'm no longer getting dmesg errors at computer
startup time. Function hdparm_try_apm() is there to skip setting APM for
some Firewire or USB devices, so it should skip it also when APM is not
supported at all.

Just to note, I'm using SATA controller which is managed by sata_nv.ko
kernel module on nvidia nforce4 motherboard and identified in lspci as:

00:07.0 IDE interface [0101]: NVIDIA Corporation CK804 Serial ATA Controller 
[10de:0054] (rev f3) (prog-if 85 [Master SecO PriO])
00:08.0 IDE interface [0101]: NVIDIA Corporation CK804 Serial ATA Controller 
[10de:0055] (rev f3) (prog-if 85 [Master SecO PriO])

-- 
Pali Rohár
pali.ro...@gmail.com

Attachment: signature.asc
Description: PGP signature

Reply via email to