Skip to content

bcm2835-thermal and mailbox property retry #1025

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

Closed
notro opened this issue Jun 15, 2015 · 2 comments
Closed

bcm2835-thermal and mailbox property retry #1025

notro opened this issue Jun 15, 2015 · 2 comments

Comments

@notro
Copy link
Contributor

notro commented Jun 15, 2015

The firmware driver is applied for v4.2, so we can start to use it.
Looking at the thermal driver I wonder if this retry loop is necessary?
I haven't seen any other use of the mailbox where this is done.

static int bcm2835_get_temp_or_max(struct thermal_zone_device *thermal_dev, unsigned long *temp, unsigned tag_id)
{
    int result = -1, retry = 3;
    print_debug("IN");

    *temp = 0;
    while (result != 0 && retry-- > 0) {
        /* wipe all previous message data */
        memset(&bcm2835_data.msg, 0, sizeof bcm2835_data.msg);

        /* prepare message */
        bcm2835_data.msg.msg_size = sizeof bcm2835_data.msg;
        bcm2835_data.msg.tag.buffer_size = 8;
        bcm2835_data.msg.tag.tag_id = tag_id;

        /* send the message */
        result = bcm_mailbox_property(&bcm2835_data.msg, sizeof bcm2835_data.msg);
        print_debug("Got %stemperature as %u (%d,%x)\n", tag_id==VC_TAG_GET_MAX_TEMP ? "max ":"", (uint)bcm2835_data.msg.tag.val, result, bcm2835_data.msg.request_code);
        if (!(bcm2835_data.msg.request_code & 0x80000000))
            result = -1;
    }

    /* check if it was all ok and return the rate in milli degrees C */
    if (result == 0)
        *temp = (uint)bcm2835_data.msg.tag.val;
    else
        print_err("Failed to get temperature! (%x:%d)\n", tag_id, result);
    print_debug("OUT");
    return result;
}
@popcornmix
Copy link
Collaborator

I did add that (over 2 years ago). A github issue reported occasional spurious readings (along with an mailbox error code). At the time retying was a quick fix. Not the right fix.

I've a suspicion this may have been fixed on the firmware side since then. I'm suspecting a latch_try (non-blocking mutex) with error if someone else was calling the function.

See: raspberrypi/firmware#132

So, feel free to remove the retry. I'd be interested if the issue reported still occurs:
raspberrypi/firmware#132 (comment)

@notro
Copy link
Contributor Author

notro commented Jun 15, 2015

Thanks

@notro notro closed this as completed Jun 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants