Enable PCI busmaster feature

Hello, All!

In <hw/pci.h> I’ve found the next defines (flags to pci_attach_device)

#define PCI_MASTER_ENABLE 0x001000000
#define PCI_FASTB2B 0x002000000
#define PCI_MGR_ATTACH 0x004000000

flag PCI_INIT_ALL doesn’t includes the above flags, so is that defines for
future use or worked but undocumented ?

Can I enable PCI Bus Master using flag PCI_MASTER_ENABLE ?

Thanks !

With best regards, Mike Gorchak.

Previously, Mike Gorchak wrote in qdn.public.qnxrtp.os:

Hello, All!

In <hw/pci.h> I’ve found the next defines (flags to pci_attach_device)

#define PCI_MASTER_ENABLE 0x001000000
#define PCI_FASTB2B 0x002000000
#define PCI_MGR_ATTACH 0x004000000

flag PCI_INIT_ALL doesn’t includes the above flags, so is that defines for
future use or worked but undocumented ?

No, it is not defined for future use. You can or in the flag when you do
your pci_attach_device() and it will enable bus mastering.

Can I enable PCI Bus Master using flag PCI_MASTER_ENABLE ?

Thanks !

With best regards, Mike Gorchak.

Hello, Hugh!
You wrote on Tue, 6 Aug 2002 09:46:11 -0400:

??>> flag PCI_INIT_ALL doesn’t includes the above flags, so is that defines
??>> for future use or worked but undocumented ?

HB> No, it is not defined for future use. You can or in the flag when you
HB> do your pci_attach_device() and it will enable bus mastering.

Thank You !!! But I have another question (more complexity) I wrote question
in the qdn.public.ddk.audio about enabling bus master feature for audio
device, but no got answer till this time. ado_* function set in the Audio
DDK doesn’t allow to pass flags while attaching to PCI audio device. So I
can’t enable bus master …

I wrote the next source but it is doesn’t work for me: if you know, please
help me ! :slight_smile:

P.S. In FreeBSD kernel they do read COMMAND register after set MASTER flag,
but I don’t … maybe this is my problem ? (The below source from linux
kernel, adopted for QNX)

#define PCI_COMMAND_REG 0x04 /* offset in pci config space
/
#define PCI_COMMAND_REG_SIZE 0x02 /
register size in bytes
/
#define PCI_COMMAND_REG_TYPE uint16_t /
register in C type
/
#define PCI_LATENCYTIMER_REG 0x0D /
offset in pci config space
/
#define PCI_LATENCYTIMER_REG_SIZE 0x01 /
register size in bytes
/
#define PCI_LATENCYTIMER_REG_TYPE uint8_t /
register in C type
/
#define PCI_LATENCYTIMER_MAX 255 /
maximum value for latency
timer /


/
Setup Bus Master to device */

ado_debug(DB_LVL_DRIVER, “ctrl_init(): VT8233: Setting up BusMaster to
device …\n”);
pci_read_config(vt8233->pci->handle, PCI_COMMAND_REG, 0x01,
PCI_COMMAND_REG_SIZE, &PCICommandReg);
if (PCICommandReg & PCI_COMMAND_MASTER_ENABLE == 0)
{
PCI_LATENCYTIMER_REG_TYPE PCILatencyTimerReg;
uint8_t needupdate=1;

/* if BM flag isn’t already setted, we set it up manually. */
PCICommandReg|=PCI_COMMAND_MASTER_ENABLE;
pci_write_config(vt8233->pci->handle, PCI_COMMAND_REG, 0x01,
PCI_COMMAND_REG_SIZE, &PCICommandReg);

/* initializing PCI latency timer for this device manually. */
ado_debug(DB_LVL_DRIVER, “ctrl_init(): VT8233: initalizing PCI device
latency timer …\n”);
pci_read_config(vt8233->pci->handle, PCI_LATENCYTIMER_REG, 0x01,
PCI_LATENCYTIMER_REG, &PCILatencyTimerReg);
if (PCILatencyTimerReg < 16)
{
PCILatencyTimerReg = (64 <= PCI_LATENCYTIMER_MAX) ? 64 :
PCI_LATENCYTIMER_MAX;
}
else
{
if (PCILatencyTimerReg > PCI_LATENCYTIMER_MAX)
{
PCILatencyTimerReg = PCI_LATENCYTIMER_MAX;
}
else
{
needupdate=0;
}
}
if (needupdate)
{
pci_write_config(vt8233->pci->handle, PCI_LATENCYTIMER_REG, 0x01,
PCI_LATENCYTIMER_REG, &PCILatencyTimerReg);
}
}


With best regards, Mike Gorchak.

Previously, Mike Gorchak wrote in qdn.public.qnxrtp.os:

Hello, Hugh!
You wrote on Tue, 6 Aug 2002 09:46:11 -0400:

??>> flag PCI_INIT_ALL doesn’t includes the above flags, so is that defines
??>> for future use or worked but undocumented ?

HB> No, it is not defined for future use. You can or in the flag when you
HB> do your pci_attach_device() and it will enable bus mastering.

Thank You !!! But I have another question (more complexity) I wrote question
in the qdn.public.ddk.audio about enabling bus master feature for audio
device, but no got answer till this time. ado_* function set in the Audio
DDK doesn’t allow to pass flags while attaching to PCI audio device. So I
can’t enable bus master …

I wrote the next source but it is doesn’t work for me: if you know, please
help me ! > :slight_smile:

Your code looks fine. If you do a read_config of the command register after
this code, is the master enable bit set in the register?

P.S. In FreeBSD kernel they do read COMMAND register after set MASTER flag,
but I don’t … maybe this is my problem ? (The below source from linux
kernel, adopted for QNX)

#define PCI_COMMAND_REG 0x04 /* offset in pci config space
/
#define PCI_COMMAND_REG_SIZE 0x02 /
register size in bytes
/
#define PCI_COMMAND_REG_TYPE uint16_t /
register in C type
/
#define PCI_LATENCYTIMER_REG 0x0D /
offset in pci config space
/
#define PCI_LATENCYTIMER_REG_SIZE 0x01 /
register size in bytes
/
#define PCI_LATENCYTIMER_REG_TYPE uint8_t /
register in C type
/
#define PCI_LATENCYTIMER_MAX 255 /
maximum value for latency
timer /


/
Setup Bus Master to device */

ado_debug(DB_LVL_DRIVER, “ctrl_init(): VT8233: Setting up BusMaster to
device …\n”);
pci_read_config(vt8233->pci->handle, PCI_COMMAND_REG, 0x01,
PCI_COMMAND_REG_SIZE, &PCICommandReg);
if (PCICommandReg & PCI_COMMAND_MASTER_ENABLE == 0)
{
PCI_LATENCYTIMER_REG_TYPE PCILatencyTimerReg;
uint8_t needupdate=1;

/* if BM flag isn’t already setted, we set it up manually. */
PCICommandReg|=PCI_COMMAND_MASTER_ENABLE;
pci_write_config(vt8233->pci->handle, PCI_COMMAND_REG, 0x01,
PCI_COMMAND_REG_SIZE, &PCICommandReg);

/* initializing PCI latency timer for this device manually. */
ado_debug(DB_LVL_DRIVER, “ctrl_init(): VT8233: initalizing PCI device
latency timer …\n”);
pci_read_config(vt8233->pci->handle, PCI_LATENCYTIMER_REG, 0x01,
PCI_LATENCYTIMER_REG, &PCILatencyTimerReg);
if (PCILatencyTimerReg < 16)
{
PCILatencyTimerReg = (64 <= PCI_LATENCYTIMER_MAX) ? 64 :
PCI_LATENCYTIMER_MAX;
}
else
{
if (PCILatencyTimerReg > PCI_LATENCYTIMER_MAX)
{
PCILatencyTimerReg = PCI_LATENCYTIMER_MAX;
}
else
{
needupdate=0;
}
}
if (needupdate)
{
pci_write_config(vt8233->pci->handle, PCI_LATENCYTIMER_REG, 0x01,
PCI_LATENCYTIMER_REG, &PCILatencyTimerReg);
}
}


With best regards, Mike Gorchak.
\

Hello !

Your code looks fine. If you do a read_config of the command register
after
this code, is the master enable bit set in the register?

Yes, the master bit is enabled after reading COMMAND register, but
pci -vvv still show that master bit not enabled … maybe pci server for
QNX6 uses some cache ?

Your code looks fine. If you do a read_config of the command register
after
this code, is the master enable bit set in the register?

Yes, the master bit is enabled after reading COMMAND register, but
pci -vvv still show that master bit not enabled … maybe pci server for
QNX6 uses some cache ?

Oops, sorry ! the master bit still zero !!! after read. It is my mistake, I
looked at the i/o enable bit, so master bit is still zero as before write

Previously, Mike Gorchak wrote in qdn.public.qnxrtp.os:

Your code looks fine. If you do a read_config of the command register
after
this code, is the master enable bit set in the register?

Yes, the master bit is enabled after reading COMMAND register, but
pci -vvv still show that master bit not enabled … maybe pci server for
QNX6 uses some cache ?

Oops, sorry ! the master bit still zero !!! after read. It is my mistake, I
looked at the i/o enable bit, so master bit is still zero as before write

Then it appears that your adapter does not support bus mastering. The audio
driver does enable bus mastering, BTW.

Hello, Hugh!

HB> Then it appears that your adapter does not support bus mastering.

This is VT8233 VIA south bridge.

HB> The audio driver does enable bus mastering, BTW.

Is it means, the ado_attach_device try to enable the Bus Master internally ?
So what about Latency timer reg, when I try to wrote to it, I have error
PCI_DEVICE_NOT_FOUND, why ? But write to other registers works fine !

I have a big headache with this VT8233 southbridge :slight_smile: Ported driver from
ALSA seems worked, but no sound to hear, with full volume I hear only
scratch + noise over music background in deep end … :slight_smile:

With best regards, Mike Gorchak.

Previously, Mike Gorchak wrote in qdn.public.qnxrtp.os:

Hello, Hugh!

HB> Then it appears that your adapter does not support bus mastering.

This is VT8233 VIA south bridge.

HB> The audio driver does enable bus mastering, BTW.

Is it means, the ado_attach_device try to enable the Bus Master internally ?

I believe so, yes.

So what about Latency timer reg, when I try to wrote to it, I have error
PCI_DEVICE_NOT_FOUND, why ? But write to other registers works fine !

The pci_write_config functions do not return PCI_DEVICE_NOT_FOUND!

I have a big headache with this VT8233 southbridge > :slight_smile: > Ported driver from
ALSA seems worked, but no sound to hear, with full volume I hear only
scratch + noise over music background in deep end … > :slight_smile:

With best regards, Mike Gorchak.

Hello, Hugh!

??>> So what about Latency timer reg, when I try to wrote to it, I have
??>> error PCI_DEVICE_NOT_FOUND, why ? But write to other registers works
??>> fine !

HB> The pci_write_config functions do not return PCI_DEVICE_NOT_FOUND!

This is not first occurance of this behavior, on self-made boards on PLX
chipsets we have the same behavior. If you have somewhere motherboard with
VT8233 south bridge I can send you unfinished sources of audio driver for
it. If I work with devfunc with the pci_write_configXX(…) function set,
the behavior differ. I think somewhere problem with “void* handle”
functions.

Thanks !

With best regards, Mike Gorchak.

Previously, Mike Gorchak wrote in qdn.public.qnxrtp.os:

Hello, Hugh!

??>> So what about Latency timer reg, when I try to wrote to it, I have
??>> error PCI_DEVICE_NOT_FOUND, why ? But write to other registers works
??>> fine !

HB> The pci_write_config functions do not return PCI_DEVICE_NOT_FOUND!

This is not first occurance of this behavior, on self-made boards on PLX
chipsets we have the same behavior. If you have somewhere motherboard with
VT8233 south bridge I can send you unfinished sources of audio driver for
it. If I work with devfunc with the pci_write_configXX(…) function set,
the behavior differ. I think somewhere problem with “void* handle”
functions.

Sorry, we don’t have any hardware like that here and I also don’t know
anything about audio drivers.

Thanks !

With best regards, Mike Gorchak.
\