-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers: sensors: akm09918: make submit function more unblocking #74389
drivers: sensors: akm09918: make submit function more unblocking #74389
Conversation
6a81cca
to
c444d1c
Compare
c444d1c
to
44dafbe
Compare
44dafbe
to
b1d3672
Compare
Hi @FlorianWeber1018, may you check if #74435 already addresses your needs? |
b1d3672
to
e9e01de
Compare
Hi @ubieda I have tested before 10 minutes but your PR does not solve my problem. (debugged with logic analyzer) But i am with you that your approach (using a dedicated workqueue instead of the system workqueue) is the more elegant way. After your PR is merged i will rebase and adopt my changes. |
CI is failing because the system workqueue has the same priority (-1) than the test in sensors.generic_test. |
Thanks for the details! I agree that one way to handle these delays during the execution (e.g: not because of a bus transfer, but because the sensor needs it) is by scheduling work item to execute when the delay is over. I'd be happy to provide this feature expansion by following-up on a separate PR after #74435 it's merged. EDIT: It seems the approach would not be as straightforward as I had suggested. However, seems like it should still fit naturally within what the RTIO Workqueue service would cover. |
e9e01de
to
b7706cb
Compare
@ubieda could you please extend the RTIO Workqueue service so that it is possible to start delayed work as you have already mentioned? |
b7706cb
to
fdb6ee0
Compare
I'll take a look soon and let you know. Thanks! |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
fdb6ee0
to
40174cc
Compare
627b0ad
to
db9938a
Compare
@ubieda at the moment it looks like that delayed work in the rtio workq (#77100) will not be available in the near future. As you have mentioned in the issue, it is not as straight forward as you have thought at the beginning. |
@FlorianWeber1018 yeah - let's move forward without relying on it and refactor once the feature lands. Feel free to mark this PR as ready for review when it's finalized to get the process going. |
*x = sys_le16_to_cpu(buf[1] | (buf[2] << 8)); | ||
*y = sys_le16_to_cpu(buf[3] | (buf[4] << 8)); | ||
*z = sys_le16_to_cpu(buf[5] | (buf[6] << 8)); | ||
*x = buf[1] | (buf[2] << 8); | ||
*y = buf[3] | (buf[4] << 8); | ||
*z = buf[5] | (buf[6] << 8); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required for Big Endian arch's. Please discard change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my Perspective doing the conversion this way (buf[1] | (buf[2] << 8)) should already taken care about endianness because the shift operator works at the level of the logical value, not how it is ordered in memory.
<< shifts always to the the MSB (even across byte boarders) disregarding the endianness. << is also an arithmetic operation.
Endianness only affects how values are stored in memory (the order of bytes), but it doesn’t affect how the CPU performs bitwise operations on the value itself.
The CPU’s shift operation takes place on the entire bit pattern, treating it as a single number, not as a collection of bytes in memory.
Do you have a BE SoC to test it?
In fact that this change is not related to this PR I should revert it anyway and reach out a dedicated PR for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my Perspective doing the conversion this way (buf[1] | (buf[2] << 8)) should already taken care about endianness because the shift operator works at the level of the logical value, not how it is ordered in memory.
<< shifts always to the the MSB (even across byte boarders) disregarding the endianness. << is also an arithmetic operation.Endianness only affects how values are stored in memory (the order of bytes), but it doesn’t affect how the CPU performs bitwise operations on the value itself.
The CPU’s shift operation takes place on the entire bit pattern, treating it as a single number, not as a collection of bytes in memory.Do you have a BE SoC to test it?
Not sure I understand: the code is mapping an array of bytes to an int16_t
based on your CPU endianness. Doing the same bit-shifting on Little-endian and Big-endian will give you different results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: I went and looked an old test-code I had for this use-case and ran it on BE and LE. Here's the results:
Source code:
#include <stdio.h>
#include <stdint.h>
int main(void)
{
printf("Exercise: Converting little-endian value in big-endian system!\n");
{
uint8_t array[] = {0x12, 0x34};
uint16_t *val = (uint16_t *)array;
uint16_t num = array[0] | (array[1] << 8);
printf("Array interpreted as integer: 0x%04X = %d\n", *val, *val);
printf("Integer after conversion: 0x%04X = %d\n", num, num);
}
return 0;
}
Console output:
ubieda@ubieda-ubuntu:~/programming/c_programming/endianness/src$ mips-linux-gnu-gcc-10 main.c -o main_be.o && qemu-mips -L /usr/mips-linux-gnu/ ./main_be.o
Exercise: Converting little-endian value in big-endian system!
Array interpreted as integer: 0x1234 = 4660
Integer after conversion: 0x3412 = 13330
ubieda@ubieda-ubuntu:~/programming/c_programming/endianness/src$ gcc main.c -o main.o && ./main.o
Exercise: Converting little-endian value in big-endian system!
Array interpreted as integer: 0x3412 = 13330
Integer after conversion: 0x3412 = 13330
It appears this is indeed needed. I suggest putting it on a separate patch or creating another PR with proper description.
The driver now does not wait for the completion of a measurement in the submit function. Instead it schedule the fetch and the completion of the submission queue entry as delayed work to the system work queue. Signed-off-by: Florian Weber <[email protected]>
db9938a
to
4786896
Compare
The driver now does not wait for the completion of a measurement in the submit function.
Instead it schedule the fetch and the completion of the submission queue entry as delayed work to the system work queue.