On Thu, May 19, 2022 at 10:12:38AM +0200, David Jander wrote: > Mark Brown <broonie@xxxxxxxxxx> wrote: > > On Tue, May 17, 2022 at 05:16:26PM +0200, David Jander wrote: > > > Mark Brown <broonie@xxxxxxxxxx> wrote: > > > Nice! I like that idea. Do you want to somehow extend spi_async() to do this > > > transparently? So we just need to introduce a second function > > > ("spi_async_await()" ?) which would wait for completion and collect the RX > > > buffer? > > We shouldn't need a new API to wait for the async operation to complete, > > hopefully the existing one is fine. > Maybe there is something I am not seeing then. The client needs to make two > function calls. One to fill the FIFO and start the transfer, and a second one > to poll the FIFO and read out the RX data. With the existing API, I can only > think of these options: The client just submits a message using spi_async() and can use the complete() callback like spi_sync() does to find out when the transfer is done. The core is responsible for actually interacting with the device. > 2. Use a completion or callback. But I don't see how that will work without a > context switch to some code that completes the completion or calls the > callback, which is what we are trying to avoid having in the first place. If the core doesn't need to context switch then the core should just be able to complete without context switching hopefully. At most we'd need a mechanism to say that the completion is OK to call from atomic context. > > Or otherwise make it unobtrusive (eg, with similar techniques to those > > used by the networking API). > I just tried this out by re-writing the statistics code using u64_stats_sync > and per-cpu statistics, which get totaled on sysfs read access as Andrew Lunn > suggested. > The results are truly amazing! > The overhead caused by statistics in my test dropped from 43us to just 1-2us. Ah, cool. I look forward to the patches. > This was tested on a 64-bit machine though, so I don't know how it will affect > 32-bit systems. Nor do I have an easy means of testing this. Any ideas? Hopefully someone with a 32 bit system who's concerned about performance can test. > Also, I have converted all the struct spi_statistics members to u64_stats_t. > It was easier to test this way. Some of the original types were unsigned long, > which can have different sizes on 64bit or 32bit systems... is that > intentional? I don't think so.
Attachment:
signature.asc
Description: PGP signature