We're preparing the AT86RF230 driver for the 231 boards we've made
in the qi-hardware project (*). One the the boards (atben) connects
directly to the GPIOs of the Ben NanoNote and can be driven by the
spi_gpio driver.
(*) You can see them at the bottom of
http://en.qi-hardware.com/wiki/Ben_WPAN
However, the other (atusb) uses a higher-level protocol that has
things like "read register" and "write data block". For this one, I
plan to split the driver into an upper part for the AT86RF230 logic
and a lower part for the transport. Further on, I may also replace
spi_gpio with something a little more streamlined for the Ben.
Does this sound good to far ?
I'm now cleaning up the driver in preparation of the split and I've
come across a number of puzzles:
- the irq_disabled flag doesn't seem to accomplish anything the
logic of the rest of the code wouldn't already do. I.e., when you
reach the point where you _may_ disable the interrupt, you will
in fact always do so. Likewise for enabling. I'll send a tentative
patch in my next posting.
- the supposed atomicity of is_tx is an even greater mystery to me.
Most of the real synchronization with regard to transmitting seems
to happen already in mac802154_xmit_worker.
With regard to receiving, I don't see the atomicity (enforced via
the spinlock) prevent races. In fact, the following sequence should
confuse the stack:
- at86rf230_xmit gets called
- lp->is_tx is set
- at86rf230_state(dev, STATE_FORCE_TX_ON, STATE_TX_ON) begins
running, sleeps
- meanwhile, an RX interrupt arrives, triggers at86rf230_isr,
schedules work
- while we're still asleep in at86rf230_state, at86rf230_irqwork
runs
- checks lp->is_tx, "thinks" the transmission is done, then
happily calls complete()
So I'd just remove the whole spinlock along with writing is_tx
in at86rf230_irqwork (so it doesn't even have to be atomic), then
go after the above race. What I wonder is if I've overlooked
something ?
Thanks,
- Werner
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Linux-zigbee-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel