Skip to contentSkip to conversation

Can't unbind PCI sound card

DISCUSSION Tech Writer 2 participants 4 messages Sep 27, 2007

lore
Share & tools
lore
#0 lore raw

This is my first post, so I am hoping this is the right place to ask my question... I have been asked to test some training materials that we received, and provide sample solutions. I've been unable to get one of the exercises to work properly, even though it follows the same steps that are available both in the documentation, and throughout the web.

The task is to unbind the PCI sound card from Domain0 and then assign it to a new VM, as shown below.

===================
(1) Load the pciback module by typing -> modprobe pciback

(2) Get the PCI ID for the hardware you will be using by typing > lspci

(3) Unbind the desired device intended for pciback. Go to /sys/bus/drivers and look for the folder with your driver. Go in the folder and you will see the sym link for the device starting with your pci_id. Next ->

echo -n [pci-slot-id] > /sys/bus/pci/drivers/e100/unbind

Now that sym link you just checked out should be gone.

(4) Now bind the device to pciback.

echo -n [pci-slot-id] > /sys/bus/pci/drivers/pciback/new_slot echo -n [pci-slot-id] > /sys/bus/pci/drivers/pciback/bind

Go to the pciback directory and you should see a new sym link created.

Now configure your Virtual Machine (DomU) to use the device.
===================

Every time I get to the command:

    echo -n 0000:00:0b.0 >  /sys/bus/pci/drivers/e100/unbind

my terminal window locks up. Although I have no other processes running, it appears the sound card is being used. I have tried this several different ways, and can't seem to get past the unbind command. It's an ensoniq card, so I tried to search for other dependencies and found:

# lsmod | grep ens
snd_ens1371            30880  1
gameport               19464  1 snd_ens1371
snd_rawmidi            30848  2 snd_seq_midi,snd_ens1371
snd_ac97_codec         98592  1 snd_ens1371
snd_pcm               101124  3 snd_pcm_oss,snd_ens1371,snd_ac97_codec
snd                    63492  12 snd_pcm_oss,snd_mixer_oss,snd_seq_midi,snd_seq,snd_ens1371,snd_rawmidi,snd_seq_device,snd_ac97_codec,snd_pcm,snd_timer
#

I can make the sound card available if I edit /etc/modprobe.conf.local with:

    options pciback hide=(0000:00:0b.0) 

and then reboot. However, I would like to find some way to get the example that is so widely documented to work. Does anyone know how I can ensure that the sound card is free and available so that the unbind works correctly?

Peg

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 1 line · Tech Writer
    echo -n 0000:00:0b.0 >  /sys/bus/pci/drivers/e100/unbind

e100 is a network driver not a sound driver, are you sure you aren't disconnecting the Ethernet interface you are logged in over or something? You probably want /sys/bus/pci/drivers/snd_ens1371/unbind, I would actually follow the symlink
at /sys/bus/pci/devices/0000:00:0b.0/driver instead of going vi /sys/bus/pci/drivers to be sure of getting the right device.

Below is the script I use to attach a device to pciback, it takes a list of pci devices as its parameter.

Ian.

#!/bin/sh

if [ $# -eq 0 ] ; then
echo "Require a PCI device as parameter"
exit 1
fi

for pcidev in $@ ; do
if [ -h /sys/bus/pci/devices/"$pcidev"/driver ] ; then

echo "Unbinding $pcidev from" $(basename $(readlink /sys/bus/pci/devices/"$pcidev"/driver)) echo -n "$pcidev" > /sys/bus/pci/devices/"$pcidev"/driver/unbind
fi
echo "Binding $pcidev to pciback"
echo -n "$pcidev" > /sys/bus/pci/drivers/pciback/new_slot
echo -n "$pcidev" > /sys/bus/pci/drivers/pciback/bind
done

#2 lore raw

I am definitely trying to unbind the PCI sound card. The "example" I included was one that I pulled off the web. I just re-read my initial note, and realized i just edited the web example. My exact command is this:

       echo -n 0000:00:0b.0 > /sys/bus/pci/drivers/ENS1371/unbind

... and this command just hangs.

As I mentioned in my original post, I can find a way to use the sound card by editing /etc/modprobe.conf.local with:

    options pciback hide=(0000:00:0b.0) 

However, my goal is to get the documented example to work. If a new user of Xen tries to follow the documentation or the web examples, they will be given the steps listed in my original post, which are:

# # Unbind a PCI network card from its network driver

# echo -n <pci-slot-nbr> > /sys/bus/pci/drivers/<device>/unbind 
# # And now bind it to the PCI Backend 
# echo -n <pci-slot-nbr> > /sys/bus/pci/drivers/pciback/new_slot 
# echo -n <pci-slot-nbr> > /sys/bus/pci/drivers/pciback/bind

I haven't found any indication in any of the web examples, or in the documentation, following this sequence of commands, which indicates what to do if the unbind hangs. So, I'm trying to figure out why it is hanging, and if there is a workaround that can be included in the training materials.

Peg

----- Original Message -----
From: "Ian Campbell" <[email protected]>
To: "Tech Writer" <[email protected]>
Cc: <[email protected]>
Sent: Thursday, September 27, 2007 8:55 AM
Subject: Re: [Xen-devel] Can't unbind PCI sound card

Quoted 36 lines · Tech Writer
Quoted 1 line
    echo -n 0000:00:0b.0 >  /sys/bus/pci/drivers/e100/unbind

e100 is a network driver not a sound driver, are you sure you aren't disconnecting the Ethernet interface you are logged in over or something? You probably want /sys/bus/pci/drivers/snd_ens1371/unbind, I would actually follow the symlink
at /sys/bus/pci/devices/0000:00:0b.0/driver instead of going vi /sys/bus/pci/drivers to be sure of getting the right device.

Below is the script I use to attach a device to pciback, it takes a list of pci devices as its parameter.

Ian.

#!/bin/sh

if [ $# -eq 0 ] ; then
echo "Require a PCI device as parameter"
exit 1
fi

for pcidev in $@ ; do
if [ -h /sys/bus/pci/devices/"$pcidev"/driver ] ; then

echo "Unbinding $pcidev from" $(basename $(readlink /sys/bus/pci/devices/"$pcidev"/driver)) echo -n "$pcidev" > /sys/bus/pci/devices/"$pcidev"/driver/unbind
fi
echo "Binding $pcidev to pciback"
echo -n "$pcidev" > /sys/bus/pci/drivers/pciback/new_slot
echo -n "$pcidev" > /sys/bus/pci/drivers/pciback/bind
done

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
Quoted 8 lines · Tech Writer

I am definitely trying to unbind the PCI sound card. The "example" I included was one that I pulled off the web. I just re-read my initial note, and realized i just edited the web example. My exact command is this:

       echo -n 0000:00:0b.0 > /sys/bus/pci/drivers/ENS1371/unbind

... and this command just hangs.

My best guess would be that the device in in use and therefore it is hanging waiting for the devices reference count to drop to zero before it can unbind.

You probably need to find which process has the sound-device open, the lsof tool might help here.

Ian.