Xilinx: hwicap driver comments
Subsystems (2)
Hi,
first of all, I think that the driver should go through lkml before upstream merge or at least be in -mm for a while (I think this used to be a rule some time ago), correct me if I'm wrong, but none of it happened.
Few comments I have:
- release f_op retval is silently ignored, I guess you will get your device into undefined state when the first function fails (esp. when you interrupt the sem)
- semaphores are deprecated
- class_device_create is deprecated
- module_init/exit functions should be __init, not __devinit/exit (not a bug, it's subset)
- this piece:
drvdata = kmalloc(sizeof(struct hwicap_drvdata), GFP_KERNEL);
if (!drvdata) {
dev_err(dev, "Couldn't allocate device private record\n");
return -ENOMEM;
} memset((void *)drvdata, 0, sizeof(struct hwicap_drvdata));
kmalloc + memset = kzalloc
null probed_devices[id] on that fail path and on failed1 label
- from/to (void *) casts are useless
- io resources are at least ulong
- don't understand this:
memcpy(kbuf, drvdata->read_buffer, bytes_remaining);
drvdata->read_buffer_in_use = bytes_remaining;
free_page((unsigned long)kbuf);
- can this overlap (=>memmove)?
memcpy(drvdata->read_buffer + bytes_to_read,
drvdata->read_buffer, 4 - bytes_to_read);- is platform probing function race-proof (like pci)?
- run sparse on it, you mix __user with non-__user at least
Quoted 5 lines · Jiri Slaby
Hi,
first of all, I think that the driver should go through lkml before upstream merge or at least be in -mm for a while (I think this used to be a rule some time ago), correct me if I'm wrong, but none of it happened.
Hmmm, if that's the rule then I apologize. I had thought that arch specific drivers were okay (assuming not part of a common subsystem like USB, Eth, etc). The driver went through a number of review cycles on the linuxppc mailing list and the comments had settled down.
I didn't see any problem in merging it as it is a platform specific
driver only used by the Xilinx Virtex chips. It is only used by arch/powerpc and only when CONFIG_XILINX_VIRTEX is selected.
Linus has already pulled Paul's tree so the patch is already merged upstream. Does it need to come back out?
Stephen, can you please repost you patch to the LKML? Even if the driver is allowed to stay in for the time being you can at least get feedback on what needs to be changed.
Cheers,
g.
Quoted 31 lines
Few comments I have:
- releasef_opretval is silently ignored, I guess you will get your device into undefined state when the first function fails (esp. when you interrupt the sem)
- semaphores are deprecated
-class_device_createis deprecated
- module_init/exit functions should be__init, not __devinit/exit (not a bug, it's subset)
- this piece:drvdata = kmalloc(sizeof(struct hwicap_drvdata), GFP_KERNEL); if (!drvdata) { dev_err(dev, "Couldn't allocate device private record\n"); return -ENOMEM; }
memset((void *)drvdata, 0, sizeof(struct hwicap_drvdata));kmalloc + memset = kzalloc
null probed_devices[id] on that fail path and on failed1 label- from/to (void *) casts are useless
- io resources are at least ulong
- don't understand this:memcpy(kbuf, drvdata->read_buffer, bytes_remaining); drvdata->read_buffer_in_use = bytes_remaining; free_page((unsigned long)kbuf); - can this overlap (=>memmove)? memcpy(drvdata->read_buffer + bytes_to_read, drvdata->read_buffer, 4 - bytes_to_read);- is platform probing function race-proof (like pci)?
- run sparse on it, you mix__userwith non-__user at least
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.
Quoted 4 lines
Stephen, can you please repost you patch to the LKML? Even if the driver is allowed to stay in for the time being you can at least get feedback on what needs to be changed.
Certainly... I'll try to address some of Jiri's issues first.
Steve
Quoted 3 lines · On Thu, 07 Feb 2008 21:08:50 +0100 Jiri Slaby <[email protected]> wrote:
first of all, I think that the driver should go through lkml before upstream merge or at least be in -mm for a while (I think this used to be a rule some time ago), correct me if I'm wrong, but none of it happened.
Never seen it before in my life. Can't find any references to it in any of the mailing lists. I ended up googling the changelog text for a whopping three hits and it appears that this change went into the powerpc patch system (http://patchwork.ozlabs.org/linuxppc/patch?id=16712)
How it got from there into Linux is also a mystery. I see a batch of powerpc updates just went into mainline but I don't know whose tree was pulled - I wasn't copied on any pull request and I can't find one on the kernel mailing list.
Perhaps Paul has just done a stealth merge, but the patch to which you refer doesn't have his signoff. Very confused.
Guys, can we all play too?
Quoted 8 lines · Andrew Morton
On Thu, 07 Feb 2008 21:08:50 +0100
How it got from there into Linux is also a mystery. I see a batch of powerpc updates just went into mainline but I don't know whose tree was pulled - I wasn't copied on any pull request and I can't find one on the kernel mailing list.Perhaps Paul has just done a stealth merge, but the patch to which you refer doesn't have his signoff. Very confused.
It went through my tree. Paul pulls from Josh Boyer's tree for powerpc-4xx patches, and Josh pulls from mine for xilinx virtex powerpc 405 patches.
My screw up, sorry I broke the rules. What is the best way to resolve this?
g.
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.
Quoted 7 lines · On Thu, 7 Feb 2008 13:54:06 -0700 "Grant Likely" <[email protected]>…
Quoted 6 lines · Andrew Morton
On Thu, 07 Feb 2008 21:08:50 +0100
How it got from there into Linux is also a mystery. I see a batch of powerpc updates just went into mainline but I don't know whose tree was pulled - I wasn't copied on any pull request and I can't find one on the kernel mailing list.
Quoted 9 lines
Quoted 2 lines
Perhaps Paul has just done a stealth merge, but the patch to which you refer doesn't have his signoff. Very confused.
It went through my tree. Paul pulls from Josh Boyer's tree for powerpc-4xx patches, and Josh pulls from mine for xilinx virtex powerpc 405 patches.
My screw up, sorry I broke the rules. What is the best way to resolve this?
Well I think we'd like to see the patches appear in Paul's tree well before the merge window if poss - that way they'll get a little bit of tyre-kicking and perhaps review via -mm. Kamalesh and I (at least) do perform build- and runtime testing of powerpc.
I would request that Paul copy myself and the main mailing list on pull requests.
It seems wrong that the signoff trail for that patch didn't actually reflect reality - it should have had both Josh's and Paul's signoffs. That would require that the changelog be altered during git->git transfers which I expect is just incompatible with the way git works (as far as I dimly understand it).
It never hurts to send a patch to lkml even if you believe it isn't of general interest. People will pass an idle eye across it, and things might get picked up, yielding improvements. Plus more people know about its existence. Probably this is more the case for something which resides under drivers/char/ than with something which resides in arch/powerpc/...
Quoted 7 lines · Andrew Morton
Quoted 5 lines · On Thu, 7 Feb 2008 13:54:06 -0700 "Grant Likely" <[email protected]>…
It went through my tree. Paul pulls from Josh Boyer's tree for powerpc-4xx patches, and Josh pulls from mine for xilinx virtex powerpc 405 patches.
Quoted 7 lines
Quoted 2 lines
My screw up, sorry I broke the rules. What is the best way to resolve this?
Well I think we'd like to see the patches appear in Paul's tree well before the merge window if poss - that way they'll get a little bit of tyre-kicking and perhaps review via -mm. Kamalesh and I (at least) do perform build- and runtime testing of powerpc.
Fair enough. I can do so in the future.
Quoted 9 lines
I would request that Paul copy myself and the main mailing list on pull requests.
It seems wrong that the signoff trail for that patch didn't actually reflect reality - it should have had both Josh's and Paul's signoffs. That would require that the changelog be altered during
git->gittransfers which I expect is just incompatible with the way git works (as far as I dimly understand it).
Quoted 5 lines
It never hurts to send a patch to lkml even if you believe it isn't of general interest. People will pass an idle eye across it, and things might get picked up, yielding improvements. Plus more people know about its existence. Probably this is more the case for something which resides under
drivers/char/than with something which resides inarch/powerpc/...
ok
Cheers,
g.
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.
Quoted 2 lines
Quoted 2 lines
It seems wrong that the signoff trail for that patch didn't actually reflect reality - it should have had both Josh's and Paul's
signoffs. That
Quoted 1 line
Quoted 1 line
would require that the changelog be altered during
git->git
transfers which
Quoted 1 line
Quoted 1 line
I expect is just incompatible with the way git works (as far as I
dimly
Quoted 1 line
Quoted 1 line
understand it).
I'm rather new to all this and still (to some extent) trying to figure out what is expected.
Maybe what is needed is git pull --ack?
Steve
Quoted 11 lines · On Thu, 7 Feb 2008 13:35:09 -0800 "Stephen Neuendorffer"…
Quoted 2 lines
Quoted 2 lines
It seems wrong that the signoff trail for that patch didn't actually reflect reality - it should have had both Josh's and Paul's
signoffs. That
Quoted 1 line
Quoted 1 line
would require that the changelog be altered during
git->gittransfers which
Quoted 1 line
Quoted 1 line
I expect is just incompatible with the way git works (as far as I
dimly
Quoted 1 line
Quoted 1 line
understand it).
I'm rather new to all this and still (to some extent) trying to figure out what is expected.
We're all still trying to figure it out, really. We've gone and made it awfully easy to get code into the kernel nowadays. Perhaps too easy. I'm presently having a little campaign of watching what's going on a bit more closely, and ecouraging people to make it easier for others to see what's going on, should they choose to do so.
I'm hoping that by the time we're developing 2.6.26 there will be a unified git tree (aka linux-next) (basically all the git and quilt trees from -mm) for people to look at and play with. That'll improve our pre-merge test coverage, but won't do much to improve review. And it won't do anything to improve our post-merge bugfixing.
Quoted 1 line
Maybe what is needed is git pull --ack?
I'm also hoping/expecting/planning that if someone tries to merge a patch into mainline, and that patch hasn't been in linux-next for "long enough", flags will wave and lights will flash and we can get to take a closer look at why it was so late and whether it's OK.
Quoted 2 lines
Quoted 2 lines
I'm rather new to all this and still (to some extent) trying to
figure
Quoted 3 lines
Quoted 1 line
out what is expected.
We're all still trying to figure it out, really. We've gone and made
it
Quoted 1 line
awfully easy to get code into the kernel nowadays. Perhaps too easy.
I'm
Quoted 1 line
presently having a little campaign of watching what's going on a bit
more
Quoted 1 line
closely, and ecouraging people to make it easier for others to see
what's
Quoted 3 lines
going on, should they choose to do so.
I'm hoping that by the time we're developing 2.6.26 there will be a
unified
Quoted 1 line
git tree (aka linux-next) (basically all the git and quilt trees from
-mm)
Quoted 1 line
for people to look at and play with. That'll improve our pre-merge
test
Quoted 1 line
coverage, but won't do much to improve review. And it won't do
anything to
Quoted 1 line
improve our post-merge bugfixing.
All of them are good, but I trust testing and sparse more than review.. :)
Quoted 3 lines
Quoted 1 line
Maybe what is needed is git pull --ack?
I'm also hoping/expecting/planning that if someone tries to merge a
patch
Quoted 1 line
into mainline, and that patch hasn't been in linux-next for "long
enough",
Quoted 1 line
flags will wave and lights will flash and we can get to take a closer
look
Quoted 1 line
at why it was so late and whether it's OK.
Hmm... what if git told you what time the original git commit happened? That can't be that hard to add (if it's not already there!)
Steve
Quoted 3 lines · Andrew Morton
It seems wrong that the signoff trail for that patch didn't actually reflect reality - it should have had both Josh's and Paul's signoffs.
No, it's correct.
If you look deeper, you'll see (in gitk, or using "--pretty=fuller") that it has:
Author: Stephen Neuendorffer <[email protected]>
Commit: Grant Likely <[email protected]>
which means that the sign-off chain is complete and matches:
ie it was written by Stephen, and then committed by Grant, and that's the whole sequence.
Then, of course, that commit was merged into another tree entirely (by Josh) in 256ae6a720618cbbfacc5e62ea1fe7c129d1b644, and by Paul in 5ab3e84f66321579ca36b63a13bf78decba65121 and then finally by me in 37969581301e50872a1ae84dc73962b5f7ee6b76, but those merge commits only show up because there was other development too (ie those things would not have showed up at all if the merges had been just fast-forwards).
So in general, the rule is that the sign-off chain should take you from the author to the committer.
You can't really go any further: we could have some "forced sign-off on merge between trees", but that would not just be inconvenient, it is fundamentally questionable in a git environment: who is "upstream" is really just a matter of opinion (ie I may be "obviously upstream", but if I have merge problems I'll actually ask the downstream person to do the merge, because he's the one who has the knowledge about that particular merge!)
Linus
Quoted 7 lines · Grant Likely
Quoted 6 lines · Andrew Morton
On Thu, 07 Feb 2008 21:08:50 +0100
How it got from there into Linux is also a mystery. I see a batch of powerpc updates just went into mainline but I don't know whose tree was pulled - I wasn't copied on any pull request and I can't find one on the kernel mailing list.
Quoted 8 lines
Quoted 2 lines
Perhaps Paul has just done a stealth merge, but the patch to which you refer doesn't have his signoff. Very confused.
It went through my tree. Paul pulls from Josh Boyer's tree for powerpc-4xx patches, and Josh pulls from mine for xilinx virtex powerpc 405 patches.
My screw up, sorry I broke the rules. What is the best way to resolve this?
It's unclear to me whether you did anything wrong here.
This driver is totally platform specific (it's not like it was a wireless driver or something like that) and has been reviewed on the platform mailing list (even if, apprently, not enough).
If those problems haven't been spotted, then too bad, and thanks Jiri for picking them up later on, that's much welcome, but I don't think we should start having all of the platform bits go through lkml, it wouldn't be practical at all.
As far as -mm is concerned, that depends how long this has been in paulus tree before the merge window I suppose. I suspect that while paulus for-2.6.25 has been around getting ready for merge for some time now (we've been good citizen in that regard, getting everything together way before the actual merge window), we haven't necessarily yet totally sorted out the timing with out own sub-maintainer and sub-sub-maintainer trees (powerpc is a complicated architecture !).
So while I would have expected this to show up at least for a little while in -mm via paulus for-2.6.25, it's possible that it didn't happen, or that paulus didn't include for-2.6.25 in powerpc.git or something like that....
So we can try to improve in this area, but I don't think Grant himself did anything wrong including that driver in his tree and having paul merge it, except maybe for a bit more in depth review (but we all do miss things sometimes).
Cheers,
Ben.
Quoted 12 lines · On Thu, 7 Feb 2008 12:42:03 -0800 Andrew Morton <[email protected]>…
Quoted 3 lines · On Thu, 07 Feb 2008 21:08:50 +0100 Jiri Slaby <[email protected]> wrote:
first of all, I think that the driver should go through lkml before upstream merge or at least be in -mm for a while (I think this used to be a rule some time ago), correct me if I'm wrong, but none of it happened.
Never seen it before in my life. Can't find any references to it in any of the mailing lists. I ended up googling the changelog text for a whopping three hits and it appears that this change went into the powerpc patch system (http://patchwork.ozlabs.org/linuxppc/patch?id=16712)
Quoted 7 lines
How it got from there into Linux is also a mystery. I see a batch of powerpc updates just went into mainline but I don't know whose tree was pulled - I wasn't copied on any pull request and I can't find one on the kernel mailing list.
Perhaps Paul has just done a stealth merge, but the patch to which you refer doesn't have his signoff. Very confused.
Gah, no. Don't blame Paul. It wasn't actually stealth either as it got posted a few times to the powerpc list.
You can blame me and/or Grant if you'd like. It's a Virtex specific driver and I didn't see any problem with it going in through the powerpc tree. I'll/we'll do better next time.
Quoted 1 line
Guys, can we all play too?
Sure. You could add my tree to -mm if you want. Though I'd really rather if we all sync up with Paul sooner so you don't have to track 5 or 6 "powerpc" trees.
josh
Quoted 5 lines · On Thu, 7 Feb 2008 15:35:45 -0600 Josh Boyer <[email protected]> wrote:
Quoted 1 line
Guys, can we all play too?
Sure. You could add my tree to -mm if you want. Though I'd really rather if we all sync up with Paul sooner so you don't have to track 5 or 6 "powerpc" trees.
Yes, I was trying to pull Kumar's tree for a while. I still am doing so, but it's presently 6.5MB of conflicts, so I'll give up on that ;)
In theory, your 2.6.x+1 material shold be ready to go well in advance of the 2.6.x release day (hah), so it'd be good if it could be in Paul's tree during 2.6.x's late -rc's.
Quoted 11 lines · On Thu, 7 Feb 2008 14:11:43 -0800 Andrew Morton <[email protected]>…
Quoted 5 lines · On Thu, 7 Feb 2008 15:35:45 -0600 Josh Boyer <[email protected]> wrote:
Quoted 1 line
Guys, can we all play too?
Sure. You could add my tree to -mm if you want. Though I'd really rather if we all sync up with Paul sooner so you don't have to track 5 or 6 "powerpc" trees.
Yes, I was trying to pull Kumar's tree for a while. I still am doing so, but it's presently 6.5MB of conflicts, so I'll give up on that ;)
Kumar's tree is speshul ;). I'm entirely too nice and my tree tends to just be a fast-forward to Paul's most of the time.
Quoted 3 lines
In theory, your 2.6.x+1 material shold be ready to go well in advance of the 2.6.x release day (hah), so it'd be good if it could be in Paul's tree during 2.6.x's late -rc's.
Actually, 90% of it was. The recent stuff from my tree was all bug fixes and/or patches that were waiting on some other subsystem maintainer to get merged (the ehci usb bits, etc). I think I'm still waiting on Jeff for a netdev patch even. Anyway, the exception to that was the Virtex stuff so my bad there.
So I really am trying to play nice and mostly have stuff in by the -rc's already. I'll take heed to your warning though and watch the late commits from now on.
josh
Quoted 1 line · Jiri Slaby
- io resources are at least ulong
They should actually be resource_size_t :-)
Ben.
Quoted 4 lines · Benjamin Herrenschmidt
Quoted 1 line · Jiri Slaby
- io resources are at least ulong
They should actually be
resource_size_t:-)
Yup, should... [I don't know how ofter people have 64bit resources on 32 bit this becomes a problem.]
Quoted 8 lines · Jiri Slaby
Quoted 4 lines · Benjamin Herrenschmidt
Quoted 1 line · Jiri Slaby
- io resources are at least ulong
They should actually be
resource_size_t:-)Yup, should... [I don't know how ofter people have 64bit resources on 32 bit this becomes a problem.]
For MMIO it's becoming more and more common actually in the embedded space. Xilinx uses 405 cores which I think still only have a 32 bits physical bus though, but if they ever extend it or switch to 440 they'll have a 36 bits bus.
Ben.
Quoted 9 lines · Benjamin Herrenschmidt
Quoted 2 lines · Jiri Slaby
Yup, should... [I don't know how ofter people have 64bit resources on 32 bit this becomes a problem.]
For MMIO it's becoming more and more common actually in the embedded space. Xilinx uses 405 cores which I think still only have a 32 bits physical bus though, but if they ever extend it or switch to 440 they'll have a 36 bits bus.
The Virtex5 has a 440. It's going to be released "real soon now"
g.
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.
Quoted 9 lines
-----Original Message-----
From: Jiri Slaby [mailto:[email protected]]
Sent: Thursday, February 07, 2008 12:09 PM
To: Stephen Neuendorffer; Grant Likely
Cc: Linux Kernel Mailing List; Andrew Morton
Subject: Xilinx: hwicap driver comments
Quoted 3 lines
Hi,
first of all, I think that the driver should go through lkml before
upstream
Quoted 1 line
merge or at least be in -mm for a while (I think this used to be a
rule some
Quoted 4 lines
time ago), correct me if I'm wrong, but none of it happened.
Few comments I have:
- releasef_opretval is silently ignored, I guess you will get your
device into
Quoted 1 line
undefined state when the first function fails (esp. when you interrupt
the sem)
Hmm.. hadn't realized that. I'm open to suggestions on how to do this better. The real reason why the synchronization is there is to make sure that only one client is using the device at a time, using the is_open flag.
Quoted 2 lines
- semaphores are deprecated
-class_device_createis deprecated
What is preferred?
Quoted 1 line
- module_init/exit functions should be
__init, not __devinit/exit (not
a bug,
Quoted 5 lines
it's subset)
- this piece:drvdata = kmalloc(sizeof(struct hwicap_drvdata), GFP_KERNEL); if (!drvdata) { dev_err(dev, "Couldn't allocate device private
record\n");
Quoted 9 lines
return -ENOMEM; }
memset((void *)drvdata, 0, sizeof(struct hwicap_drvdata));kmalloc + memset = kzalloc
null probed_devices[id] on that fail path and on failed1 label- from/to (void *) casts are useless
- io resources are at least ulong
easily fixed.
Quoted 4 lines
- don't understand this:
memcpy(kbuf, drvdata->read_buffer, bytes_remaining); drvdata->read_buffer_in_use = bytes_remaining; free_page((unsigned long)kbuf);
The physical device only generates/accepts complete words, the intention is to account for the possibility that a read does not read complete words, and to fulfill the read whenever possible.
It's arguable that read() and write() should not accept or return partial words, I suppose
Quoted 3 lines
- can this overlap (=>memmove)?
memcpy(drvdata->read_buffer + bytes_to_read, drvdata->read_buffer, 4 -
bytes_to_read);
Quoted 1 line
- is platform probing function race-proof (like pci)?
no idea. even if it is, it's unlikely that the of_driver probing is protected by the same lock as the platform_driver probing.
Quoted 1 line
- run sparse on it, you mix
__userwith non-__user at least
I thought I had been.... hmm... looks like a few other things to fix there, too.
Steve
Quoted 10 lines · Stephen Neuendorffer
Quoted 2 lines
Few comments I have:
- releasef_opretval is silently ignored, I guess you will get yourdevice into
Quoted 1 line
undefined state when the first function fails (esp. when you interrupt
the sem)
Hmm.. hadn't realized that. I'm open to suggestions on how to do this better. The real reason why the synchronization is there is to make sure that only one client is using the device at a time, using the
is_openflag.
just mutex_lock(); that need not be interrupted.
Quoted 4 lines
Quoted 2 lines
- semaphores are deprecated
-class_device_createis deprecatedWhat is preferred?
device_create(); and pass the struct device as a parent when you are at it. Otherwise it will be in /sys/*/virtual/* I suppose.
Quoted 10 lines
Quoted 4 lines
- don't understand this:
memcpy(kbuf, drvdata->read_buffer, bytes_remaining); drvdata->read_buffer_in_use = bytes_remaining; free_page((unsigned long)kbuf);The physical device only generates/accepts complete words, the intention is to account for the possibility that a read does not read complete words, and to fulfill the read whenever possible.
It's arguable thatread()andwrite()should not accept or return partial words, I suppose
OK, but why are you copying anything to buffer which you free 2 lines below?
PATCH 1/1 Xilinx: hwicap driver
In reply to Jiri SlabyThis includes code for new fifo-based xps_hwicap in addition to the older opb_hwicap, which has a significantly different interface. The common code between the two drivers is largely shared.
Significant differences exists between this driver and what is supported in the EDK drivers. In particular, most of the architecture-specific code for reconfiguring individual FPGA resources has been removed. This functionality is likely better provided in a user-space support library. In addition, read and write access is supported. In addition, although the xps_hwicap cores support interrupt-driver mode, this driver only supports polled operation, in order to make the code simpler, and since the interrupt processing overhead is likely to slow down the throughput under Linux.
Fixed to add mutexes, and a few style issues.
The final update to xilinx_hwicap.h was missing.
fix some missing __user tags and incorrect section tags. convert semaphores to mutexes.
make probed_devices re-entrancy and error condition safe. fix some backwards memcpys.
some other minor cleanups.
--- drivers/char/Kconfig | 7 + drivers/char/Makefile | 1 + drivers/char/xilinx_hwicap/Makefile | 7 + drivers/char/xilinx_hwicap/buffer_icap.c | 380 ++++++++++++ drivers/char/xilinx_hwicap/buffer_icap.h | 57 ++ drivers/char/xilinx_hwicap/fifo_icap.c | 381 ++++++++++++ drivers/char/xilinx_hwicap/fifo_icap.h | 62 ++ drivers/char/xilinx_hwicap/xilinx_hwicap.c | 923 ++++++++++++++++++++++++++++ drivers/char/xilinx_hwicap/xilinx_hwicap.h | 193 ++++++ 9 files changed, 2011 insertions(+), 0 deletions(-) create mode 100644 drivers/char/xilinx_hwicap/Makefile create mode 100644 drivers/char/xilinx_hwicap/buffer_icap.c create mode 100644 drivers/char/xilinx_hwicap/buffer_icap.h create mode 100644 drivers/char/xilinx_hwicap/fifo_icap.c create mode 100644 drivers/char/xilinx_hwicap/fifo_icap.h create mode 100644 drivers/char/xilinx_hwicap/xilinx_hwicap.c create mode 100644 drivers/char/xilinx_hwicap/xilinx_hwicap.h
drivers/char/Kconfig +7 -0
@@ -831,6 +831,13 @@ config DTLK To compile this driver as a module, choose M here: the module will be called dtlk. +config XILINX_HWICAP + tristate "Xilinx HWICAP Support" + depends on XILINX_VIRTEX + help + This option enables support for Xilinx Internal Configuration + Access Port (ICAP) driver. + config R3964 tristate "Siemens R3964 line discipline" ---help---
drivers/char/Makefile +1 -0
@@ -76,6 +76,7 @@ obj-$(CONFIG_EFI_RTC) += efirtc.o obj-$(CONFIG_SGI_DS1286) += ds1286.o obj-$(CONFIG_SGI_IP27_RTC) += ip27-rtc.o obj-$(CONFIG_DS1302) += ds1302.o +obj-$(CONFIG_XILINX_HWICAP) += xilinx_hwicap/ ifeq ($(CONFIG_GENERIC_NVRAM),y) obj-$(CONFIG_NVRAM) += generic_nvram.o else
drivers/char/xilinx_hwicap/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# +# Makefile for the Xilinx OPB hwicap driver +# + +obj-$(CONFIG_XILINX_HWICAP) += xilinx_hwicap_m.o + +xilinx_hwicap_m-y := xilinx_hwicap.o fifo_icap.o buffer_icap.o
drivers/char/xilinx_hwicap/buffer_icap.c new file +380 -0
380 lines not on this page · raw message
drivers/char/xilinx_hwicap/buffer_icap.h new file +57 -0
57 lines not on this page · raw message
drivers/char/xilinx_hwicap/fifo_icap.c new file +381 -0
381 lines not on this page · raw message
drivers/char/xilinx_hwicap/fifo_icap.h new file +62 -0
62 lines not on this page · raw message
drivers/char/xilinx_hwicap/xilinx_hwicap.c new file +923 -0
923 lines not on this page · raw message
drivers/char/xilinx_hwicap/xilinx_hwicap.h new file +193 -0
193 lines not on this page · raw message
Signature · 1 line
1.5.3.4-dirty
Re: [PATCH] [POWERPC] Xilinx: hwicap driver
Quoted 20 lines · Stephen Neuendorffer
This includes code for new fifo-based
xps_hwicapin addition to the olderopb_hwicap, which has a significantly different interface. The common code between the two drivers is largely shared.Significant differences exists between this driver and what is supported in the EDK drivers. In particular, most of the architecture-specific code for reconfiguring individual FPGA resources has been removed. This functionality is likely better provided in a user-space support library. In addition, read and write access is supported. In addition, although the
xps_hwicapcores support interrupt-driver mode, this driver only supports polled operation, in order to make the code simpler, and since the interrupt processing overhead is likely to slow down the throughput under Linux.Signed-off-by Stephen Neuendorffer <[email protected]>Fixed to add mutexes, and a few style issues.
Acked-by Grant Likely <[email protected]>
Quoted 7 lines
The final update to
xilinx_hwicap.hwas missing.fix some missing
__usertags and incorrect section tags. convert semaphores to mutexes.
makeprobed_devicesre-entrancy and error condition safe. fix some backwards memcpys.
some other minor cleanups.
Looks good to me.
Quoted 2 lines
Signed-off-by Stephen Neuendorffer <[email protected]>---
[...]
Quoted 6 lines
drivers/char/xilinx_hwicap/xilinx_hwicap.c new file +0
-0@@ -0,0 +1,923 @@
[...]
drivers/char/xilinx_hwicap/xilinx_hwicap.c line 122
Quoted 6 lines
drivers/char/xilinx_hwicap/xilinx_hwicap.c new file +6
-0+module_param (xhwicap_major, int,S_IRUGO ); +module_param (xhwicap_minor, int,S_IRUGO ); + +/* An array, which is set to true when the device is registered. */ +static bool probed_devices[HWICAP_DEVICES ]; +static struct mutex icap_sem;
Just a sideway note, static DEFINE_MUTEX(icap_sem); and you don't need to runtime init it then.
Re: [PATCH] [POWERPC] Xilinx: hwicap driver
In reply to Stephen NeuendorfferQuoted 24 lines · On Thu, 7 Feb 2008 18:17:41 -0800 Stephen Neuendorffer wrote:
drivers/char/Kconfig | 7 + drivers/char/Makefile | 1 + drivers/char/xilinx_hwicap/Makefile | 7 + drivers/char/xilinx_hwicap/buffer_icap.c | 380 ++++++++++++ drivers/char/xilinx_hwicap/buffer_icap.h | 57 ++ drivers/char/xilinx_hwicap/fifo_icap.c | 381 ++++++++++++ drivers/char/xilinx_hwicap/fifo_icap.h | 62 ++ drivers/char/xilinx_hwicap/xilinx_hwicap.c | 923 ++++++++++++++++++++++++++++ drivers/char/xilinx_hwicap/xilinx_hwicap.h | 193 ++++++ 9 files changed, 2011 insertions(+), 0 deletions(-) create mode 100644 drivers/char/xilinx_hwicap/Makefile create mode 100644 drivers/char/xilinx_hwicap/buffer_icap.c create mode 100644 drivers/char/xilinx_hwicap/buffer_icap.h create mode 100644 drivers/char/xilinx_hwicap/fifo_icap.c create mode 100644 drivers/char/xilinx_hwicap/fifo_icap.h create mode 100644 drivers/char/xilinx_hwicap/xilinx_hwicap.c create mode 100644 drivers/char/xilinx_hwicap/xilinx_hwicap.hdrivers/char/xilinx_hwicap/buffer_icap.c new file +0
-0
drivers/char/xilinx_hwicap/buffer_icap.c line 78
Quoted 5 lines
drivers/char/xilinx_hwicap/buffer_icap.c new file +4
-0@@ -0,0 +1,380 @@ +/** +* buffer_icap_get_status: Get the contents of the status register. +* @parameter base_address: is the base address of the device +*
Hi,
For this function and many others in these source files:
Please see Documentation/kernel-doc-nano-HOWTO.txt for the correct kernel-doc notation format.
If you have questions or need help, please ask.
Hints:
a. function name & short description: separate name & description with '-' b. parameters are listed as: @base_address: (without "parameter")
Quoted 26 lines
+ * The status register contains the ICAP status and the done bit.
+ *
+ * D8 - cfgerr
+ * D7 - dalign
+ * D6 - rip
+ * D5 -in_abort_l
+ * D4 - Always 1
+ * D3 - Always 1
+ * D2 - Always 1
+ * D1 - Always 1
+ * D0 - Done bit
+ **/drivers/char/xilinx_hwicap/buffer_icap.c new file +4
-0+static inline u32 buffer_icap_get_status (void __iomem *base_address) +{ +return in_be32 (base_address +XHI_STATUS_REG_OFFSET ); +}drivers/char/xilinx_hwicap/xilinx_hwicap.h new file +1
-0@@ -0,0 +1,193 @@ +#ifndef XILINX_HWICAP_H_ /* prevent circular inclusions */
drivers/char/xilinx_hwicap/xilinx_hwicap.h line 46
Quoted 10 lines
drivers/char/xilinx_hwicap/xilinx_hwicap.h new file +10
-0+#define XILINX_HWICAP_H_ /* by using protection macros */ + +#include <linux/types.h> +#include <linux/cdev.h> +#include <linux/version.h> +#include <linux/platform_device.h> + +#include <asm/io.h> + +struct hwicap_drvdata {
BTW, you can also use kernel-doc for structs, unions, & enums.
Quoted 20 lines
drivers/char/xilinx_hwicap/xilinx_hwicap.h new file +20
-0+u32 write_buffer_in_use;/* Always in [0,3] */ +u8 write_buffer[4 ]; +u32 read_buffer_in_use;/* Always in [0,3] */ +u8 read_buffer[4 ]; +resource_size_t mem_start;/* phys. address of the control registers */ +resource_size_t mem_end;/* phys. address of the control registers */ +resource_size_t mem_size; +void __iomem *base_address;/* virt. address of the control registers */ + +struct device *dev; +struct cdev cdev;/* Char device structure */ +dev_t devt; + +const struct hwicap_driver_config *config; +const struct config_registers *config_regs; +void *private_data; +bool is_open; +struct mutex sem; +}; +
drivers/char/xilinx_hwicap/xilinx_hwicap.h line 76
Quoted 10 lines
drivers/char/xilinx_hwicap/xilinx_hwicap.h new file +10
-0+struct hwicap_driver_config { +int (*get_configuration)(struct hwicap_drvdata *drvdata,u32 *data, +u32 size); +int (*set_configuration)(struct hwicap_drvdata *drvdata,u32 *data, +u32 size); +void (*reset)(struct hwicap_drvdata *drvdata); +}; + +/* Number of times to poll the done regsiter */ +#define XHI_MAX_RETRIES 10
---
~Randy
Missed the 'send' button on this last night.
Quoted 10 lines
-----Original Message-----
From: Jiri Slaby [mailto:[email protected]]
Sent: Thursday, February 07, 2008 12:09 PM
To: Stephen Neuendorffer; Grant Likely
Cc: Linux Kernel Mailing List; Andrew Morton
Subject: Xilinx: hwicap driver commentsHi,
first of all, I think that the driver should go through lkml before
upstream
Quoted 1 line
merge or at least be in -mm for a while (I think this used to be a
rule some
Quoted 4 lines
time ago), correct me if I'm wrong, but none of it happened.
Few comments I have:
- releasef_opretval is silently ignored, I guess you will get your
device into
Quoted 1 line
undefined state when the first function fails (esp. when you interrupt
the sem)
Fixed.
Quoted 1 line
- semaphores are deprecated
converted to mutexes.
Quoted 1 line
-
class_device_createis deprecated
Fixed.
Quoted 1 line
- module_init/exit functions should be
__init, not __devinit/exit (not
a bug,
Quoted 1 line
it's subset)
Fixed.
Quoted 4 lines
- this piece:
drvdata = kmalloc(sizeof(struct hwicap_drvdata), GFP_KERNEL); if (!drvdata) { dev_err(dev, "Couldn't allocate device private
record\n");
Quoted 5 lines
return -ENOMEM; }
memset((void *)drvdata, 0, sizeof(struct hwicap_drvdata));kmalloc + memset = kzalloc
Fixed.
Quoted 1 line
null probed_devices[id] on that fail path and on failed1 label
Fixed.
Quoted 2 lines
- from/to (void *) casts are useless
- io resources are at least ulong
Fixed to be resource_size_t.
Quoted 4 lines
- don't understand this:
memcpy(kbuf, drvdata->read_buffer, bytes_remaining); drvdata->read_buffer_in_use = bytes_remaining; free_page((unsigned long)kbuf);
Yeow. Fixed so the sense of the memcpy correct.
Quoted 3 lines
- can this overlap (=>memmove)?
memcpy(drvdata->read_buffer + bytes_to_read, drvdata->read_buffer, 4 -
bytes_to_read);
Yes, it can! fixed.
Given the length of time that these errors have been there, I'm really wondering if the added complexity of this buffer is worth it.
Quoted 1 line
- is platform probing function race-proof (like pci)?
Added another mutex around access to probed_devices
Quoted 1 line
- run sparse on it, you mix
__userwith non-__user at least
Fixed. There is one warning (related to a function that is not called), but I'd like to leave this in, as it should get bound to an ioctl, most likely.
Thanks alot for the comments!
Steve