public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jes Sorensen <Jes.Sorensen@cern.ch>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: Klaus Nielsen <jimbo@zorland.dk>,
	Linux Kernel list <linux-kernel@vger.rutgers.edu>
Subject: Re: Unable to read memory mapped PCI memory the second time == freezeup..
Date: 11 Jul 1999 14:03:51 +0200	[thread overview]
Message-ID: <d3emifs89k.fsf@dxplus05.cern.ch> (raw)
In-Reply-To: Jeff Garzik's message of "Sat, 10 Jul 1999 10:44:15 -0400 (EDT)"

>>>>> "Jeff" == Jeff Garzik <jgarzik@pobox.com> writes:

Jeff> Read linux/Documentation/IO-mapping.txt, and then use read?()
Jeff> and write?() for MMIO.  For example:

Jeff> 	byArgh = readb(global_vmemaddr); if(byArgh==0)
Jeff> printk(KERN_DEBUG "byArgh\n"); writeb (0x5a, global_vmemaddr);
Jeff> byArgh = readb(global_vmemaddr);

There is a number of memory barrier instructions missing in that
example, you need to put an mb() in after the writeb to make sure the
compiler doesn't cache the value written to the register. On
architectures which do not guarantee write ordering this shows up even
more since the CPU may decide to issue the instructions in a different
order (though this is mainly of interest if you are accessing several
different registers in the mapped area). Anyway the correct way to do
things is this way:

	byArgh = readb(global_vmemaddr);
	if(byArgh==0) printk(KERN_DEBUG "byArgh\n");
	writeb (0x5a, global_vmemaddr);
	mb();
	byArgh = readb(global_vmemaddr);

You are absolutely right about the use of readb/writeb though, one
should _never_ access PCI shared memory directly.

Jes

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

           reply	other threads:[~1999-07-11 12:06 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <Pine.GSO.3.96.990710104147.7017A-100000@ext1>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d3emifs89k.fsf@dxplus05.cern.ch \
    --to=jes.sorensen@cern.ch \
    --cc=jgarzik@pobox.com \
    --cc=jimbo@zorland.dk \
    --cc=linux-kernel@vger.rutgers.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox