From: Marc Leeman <marc.leeman@barco•com>
To: linuxppc-dev list <linuxppc-dev@lists•linuxppc.org>
Subject: Re: PCI Memory mapping
Date: Wed, 24 Mar 2004 15:25:24 +0100 [thread overview]
Message-ID: <20040324142524.GA22701@smtp.barco.com> (raw)
In-Reply-To: <20040324122652.GA22171@smtp.barco.com>
This is getting weird, I found a solution to the problem, well kind of.
Let's introduce the major players in this drama:
/* communication struct between user and kernel space , in driver.h
* kernel include */
typedef struct SStreamPci {
unsigned int pciaddress;
unsigned int useraddress;
unsigned char stream;
}TSStreamPci;
/* user space program */
/* as long as not all data is transferred */
while(userptr < (userbuffer + (TRANSFER_SIZE>>2))){
/* currentstream is a struct that is passed to the kernel of
* type TSStreamPci */
currentstream.useraddress = (unsigned)userptr;
/* copy our buffer to the kernel (PCI_TRANSFER_SIZE), 4k */
ioctl(dsphandle,PPC2DSP_CONSISTENT_COPY_TO_KERNEL,¤tstream);
/* Interrupt the DSP */
WriteToDSP(PacketReady,0x1);
ioctl(dsphandle,PPC2DSP_SET_HDCR,&interrupt);
/* Wait until the DSP acknowledges transfer */
while(ReadFromDSP(PacketReady)){}
/* Read kernel buffer back */
ioctl(dsphandle,PPC2DSP_CONSISTENT_COPY_FROM_KERNEL,¤tstream);
/* increment pointer */
userptr += (BLOCK_TRANSFER_SIZE >> 2);
}
The strange thing is that this works only and only if I do a transfer
back from kernel space into the userbuffer AFTER the DSP has
acknowledged transferring the data. Note that this data is never used
again. Doing this copy_to_user before DSP acknowledgement still results
in the afore mentioned data corruption.
The associated ioctls are:
case PPC2DSP_CONSISTENT_COPY_TO_KERNEL:
{
TSStreamPci currentstream;
if(copy_from_user(¤tstream,(TSStreamPci*) arg,sizeof(TSStreamPci))){
return -EFAULT;
}
if(copy_from_user(driver_data.device[currentstream.stream]->kern_addr,(char*)currentstream.useraddress, PCI_TRANSFER_SIZE)){
return -EFAULT;
}
break;
}
case PPC2DSP_CONSISTENT_COPY_FROM_KERNEL:
{
TSStreamPci currentstream;
if(copy_from_user(¤tstream,(TSStreamPci*) arg, sizeof(TSStreamPci))){
return -EFAULT;
}
if(copy_to_user((char*)currentstream.useraddress,driver_data.device[currentstream.stream]->kern_addr, PCI_TRANSFER_SIZE)){
return -EFAULT;
}
break;
}
There is about a 10% bandwith reduction (due to PPC utilisation I would
assume) over the PCI, so I can live with that; but what bothers me is
not knowing _why_, ... Especially since I want my first module not to
contain too large beginners mistakes :)
marc.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
next prev parent reply other threads:[~2004-03-24 14:25 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-16 11:40 PCI Memory mapping Marc Leeman
2004-03-16 16:39 ` Jeff Angielski
2004-03-22 7:48 ` Marc Leeman
2004-03-22 11:02 ` Marc Leeman
2004-03-23 11:17 ` Marc Leeman
2004-03-23 16:01 ` Marc Leeman
2004-03-24 2:04 ` Michael R. Zucca
2004-03-24 0:04 ` Benjamin Herrenschmidt
2004-03-24 12:26 ` Marc Leeman
2004-03-24 14:25 ` Marc Leeman [this message]
2004-03-24 17:08 ` linas
2004-03-25 15:48 ` Marc Leeman
2004-03-25 16:34 ` linas
2004-03-25 16:45 ` linas
2004-03-26 8:00 ` Marc Leeman
2004-03-30 19:49 ` Jeff Angielski
2004-03-31 15:56 ` Marc Leeman
2004-03-31 16:02 ` Marc Leeman
2004-04-01 12:33 ` Marc Leeman
2004-04-04 22:53 ` Benjamin Herrenschmidt
2004-04-05 8:46 ` Adrian Cox
[not found] ` <20040402140130.GG22365@smtp.barco.com>
[not found] ` <1081175362.20952.30.camel@localhost.localdomain>
2004-04-06 6:21 ` Marc Leeman
-- strict thread matches above, loose matches on Subject: below --
2004-04-07 7:15 Marc Leeman
2011-04-15 5:44 koteswararaom
2011-04-15 6:32 ` David Hawkins
2011-04-15 6:48 ` Michael Neuling
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=20040324142524.GA22701@smtp.barco.com \
--to=marc.leeman@barco$(echo .)com \
--cc=linuxppc-dev@lists$(echo .)linuxppc.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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