rtirq, kernels >= 3.2 and udev

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all (and Rui),

As noted in another thread I found out that the naming of the irq processes of pci soundcards has changed with kernels >= 3.2 to be uniform and predictable. That made it possible to change rtirq so that (at least for pci cards) only the irq process that corresponds to the soundcard gets an elevated priority - this was not completely reliable before.

Another nice (very nice I'd say) side effect of this change is that now udev can be trivially used to change the priorities of soundcards dynamically. I tested this while running 3.2.16-rt27 on a Fedora 14 system. I removed "snd" and "usb" of the rtirq sysconfig file so that it would not touch those and rebooted. My hda_intel got the priority I wanted, inserting (or removing) a usb or a pci-express card with a Multiface II worked as well. Right now my simple script does not try to order priorities, it just sets them to a fixed one. But well, it is a start... Code attached (the udev rule goes into /etc/udev/rules.d/ in my system)...

This simple script also returns the priority of the usb irq for the soundcard to 50 (the default) when the card is unplugged, but it does not check for multiple cards (ie: even if another soundcard is still using the same irq process it downgrades its priority), this should be fixed.

Feedback appreciated.
-- Fernando

PS: Another rtirq script in /etc/pm/sleep.d/ could save the current priorities before a suspend and restore them after a resume - that does not happen currently.
# Change irq priority for soundcards
SUBSYSTEM=="sound", ATTRS{irq}=="[0-9]*", DRIVERS=="*", RUN+="/usr/bin/rtirq_udev $attr{irq} $driver"
#!/bin/bash
#
# rtirq_usb: change irq priority for soundcards detected by udev
#
# This script is called from a udev rule that detects the insertion
# or removal of a soundcard. It works when the name of the irq process
# coincides with the name of the kernel module for the card. For pci cards
# that is the case for kernels > 3.2.x. It also works for usb soundcards.
#
# arguments
#  $1: irq of soundcard
#  $2: name of kernel module
#
# An example udev rule:
#
# SUBSYSTEM=="sound", ATTRS{irq}=="[0-9]*", DRIVERS=="*", RUN+="/usr/bin/rtirq_udev $attr{irq} $driver"
#
# Copyright (c) 2012 Fernando Lopez-Lezcano
#
#   This program is free software; you can redistribute it and/or
#   modify it under the terms of the GNU General Public License
#   as published by the Free Software Foundation; either version 2
#   of the License, or (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License along
#   with this program; if not, write to the Free Software Foundation, Inc.,
#   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

IRQ=${1}
DRIVER=${2}

if [ -n "${IRQ}" -a -n "${DRIVER}" ] ; then
    IRQPID=`/bin/ps -e -o pid,comm | /bin/egrep "irq.${IRQ}.${DRIVER:0:8}" | /usr/bin/awk '{print $1}'`
    if [ -n "${IRQPID}" ] ; then
	if [ "${ACTION}" == "remove" ] ; then
	    IRQPRIO=50
	else
	    IRQPRIO=70
	fi
	PRIO=`/bin/ps -p ${IRQPID} -o rtprio=`
	if [ ${PRIO} -ne ${IRQPRIO} ] ; then
	    /usr/bin/chrt -f -p ${IRQPRIO} ${IRQPID}
	fi
    fi
fi
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@xxxxxxxxxxxxxxxxxxxx
http://lists.linuxaudio.org/listinfo/linux-audio-user

[Index of Archives]     [Linux Sound]     [ALSA Users]     [Pulse Audio]     [ALSA Devel]     [Sox Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux