linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Addressing PCI memory
@ 2001-05-15 16:34 Amelia De Vivo
  2001-05-15 16:58 ` Takashi Oe
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Amelia De Vivo @ 2001-05-15 16:34 UTC (permalink / raw)
  To: linuxppc-dev


Hi all, I'm trying to write a driver for a 64 bit PCI device. Something like
this works well under i386 Linux, but it doesn't work at all for Linux
2.2.15 by Yellow Dog:

    struct pci_dev *dev = NULL;
    dev = pci_find_device(vendor, device, dev);
    pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &cards[0].addr0);
    cards[0].vaddr = (void *) ioremap((cards[0].addr0 &
PCI_BASE_ADDRESS_MEM_MASK), cards[0].size);
    writeb('A',(cards[0].vaddr)+0x1000);

I have a kernel panic on writeb. Has someone some suggestion?
Thanks in advance

Amelia


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Addressing PCI memory
  2001-05-15 16:34 Addressing PCI memory Amelia De Vivo
@ 2001-05-15 16:58 ` Takashi Oe
  2001-05-15 17:02 ` Gabriel Paubert
  2001-05-16 16:40 ` ashish anand
  2 siblings, 0 replies; 5+ messages in thread
From: Takashi Oe @ 2001-05-15 16:58 UTC (permalink / raw)
  To: Amelia De Vivo; +Cc: linuxppc-dev


On Tue, 15 May 2001 18:34:50 +0200, Amelia De Vivo wrote:

>
> Hi all, I'm trying to write a driver for a 64 bit PCI device. Something
> like
> this works well under i386 Linux, but it doesn't work at all for Linux
> 2.2.15 by Yellow Dog:
>
>     struct pci_dev *dev = NULL;
>     dev = pci_find_device(vendor, device, dev);
>     pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &cards[0].addr0);
>     cards[0].vaddr = (void *) ioremap((cards[0].addr0 &
> PCI_BASE_ADDRESS_MEM_MASK), cards[0].size);
>     writeb('A',(cards[0].vaddr)+0x1000);
>
> I have a kernel panic on writeb. Has someone some suggestion?

Is PCI_COMMAND_MEMORY enabled on the device?  On Apple machines,
it's usually not enabled by default.  For 2.2.15, you'd need to
manually enable it.  [grep PCI_COMMAND_MEMORY for more info.]


Takashi Oe

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Addressing PCI memory
  2001-05-15 16:34 Addressing PCI memory Amelia De Vivo
  2001-05-15 16:58 ` Takashi Oe
@ 2001-05-15 17:02 ` Gabriel Paubert
  2001-05-15 18:16   ` Jeff Garzik
  2001-05-16 16:40 ` ashish anand
  2 siblings, 1 reply; 5+ messages in thread
From: Gabriel Paubert @ 2001-05-15 17:02 UTC (permalink / raw)
  To: Amelia De Vivo; +Cc: linuxppc-dev


On Tue, 15 May 2001, Amelia De Vivo wrote:

>
> Hi all, I'm trying to write a driver for a 64 bit PCI device. Something like
> this works well under i386 Linux, but it doesn't work at all for Linux
> 2.2.15 by Yellow Dog:
>
>     struct pci_dev *dev = NULL;
>     dev = pci_find_device(vendor, device, dev);
>     pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &cards[0].addr0);

First, use the resource in the dev structure, they do not necessarily
correspond to the value read from the base, even on Intel BTW.

	cards[0].addr0 = dev->resources[0].start

don't even need to mask the address bits...

Report again if the problems  persist.

>     cards[0].vaddr = (void *) ioremap((cards[0].addr0 &
> PCI_BASE_ADDRESS_MEM_MASK), cards[0].size);
>     writeb('A',(cards[0].vaddr)+0x1000);
>
> I have a kernel panic on writeb. Has someone some suggestion?

	Regards,
	Gabriel.


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Addressing PCI memory
  2001-05-15 17:02 ` Gabriel Paubert
@ 2001-05-15 18:16   ` Jeff Garzik
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff Garzik @ 2001-05-15 18:16 UTC (permalink / raw)
  To: Gabriel Paubert; +Cc: Amelia De Vivo, linuxppc-dev


Gabriel Paubert wrote:
>
> On Tue, 15 May 2001, Amelia De Vivo wrote:
>
> >
> > Hi all, I'm trying to write a driver for a 64 bit PCI device. Something like
> > this works well under i386 Linux, but it doesn't work at all for Linux
> > 2.2.15 by Yellow Dog:
> >
> >     struct pci_dev *dev = NULL;
> >     dev = pci_find_device(vendor, device, dev);
> >     pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &cards[0].addr0);
>
> First, use the resource in the dev structure, they do not necessarily
> correspond to the value read from the base, even on Intel BTW.
>
>         cards[0].addr0 = dev->resources[0].start
>
> don't even need to mask the address bits...

correct.

Though note it is highly encouraged to use
pci_resource_{start,end,len,flags} helpers.  That makes it transparent
to port code to earlier kernels, and IMHO makes the code easier to read.

--
Jeff Garzik      | Game called on account of naked chick
Building 1024    |
MandrakeSoft     |

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Addressing PCI memory
  2001-05-15 16:34 Addressing PCI memory Amelia De Vivo
  2001-05-15 16:58 ` Takashi Oe
  2001-05-15 17:02 ` Gabriel Paubert
@ 2001-05-16 16:40 ` ashish anand
  2 siblings, 0 replies; 5+ messages in thread
From: ashish anand @ 2001-05-16 16:40 UTC (permalink / raw)
  To: Amelia De Vivo, linuxppc-dev


Amelia De Vivo wrote:
>
> Hi all, I'm trying to write a driver for a 64 bit PCI device. Something like
> this works well under i386 Linux, but it doesn't work at all for Linux
> 2.2.15 by Yellow Dog:
>
>     struct pci_dev *dev = NULL;
>     dev = pci_find_device(vendor, device, dev);
>     pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &cards[0].addr0);
>     cards[0].vaddr = (void *) ioremap((cards[0].addr0 &
> PCI_BASE_ADDRESS_MEM_MASK), cards[0].size);
>     writeb('A',(cards[0].vaddr)+0x1000);

 READ PCI STATUS REGISTER TO CHECK FOR ANY MASTER/TARGET ABORT.
  LASTLY WHAT IS THE VALUE OF cards[0].size ?

> I have a kernel panic on writeb. Has someone some suggestion?

LET ME KNOW THE PANIC MESSAGE....

> Thanks in advance
>
> Amelia
>

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-05-16 16:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-05-15 16:34 Addressing PCI memory Amelia De Vivo
2001-05-15 16:58 ` Takashi Oe
2001-05-15 17:02 ` Gabriel Paubert
2001-05-15 18:16   ` Jeff Garzik
2001-05-16 16:40 ` ashish anand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).