qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jeremy Kerr <jk@codeconstruct.com.au>
To: Joe Komlodi <komlodi@google.com>, qemu-devel@nongnu.org
Cc: venture@google.com, peter.maydell@linaro.org
Subject: Re: [PATCH 10/16] hw/i3c/aspeed_i3c: Add IBI handling
Date: Mon, 03 Apr 2023 11:08:00 +0800	[thread overview]
Message-ID: <55b3164d58dd67954ef99551550dcb5a93673150.camel@codeconstruct.com.au> (raw)
In-Reply-To: <20230331010131.1412571-11-komlodi@google.com>

Hi Joe,

First up, nice work with this series! I haven't yet had a thorough look
at the series, but one item on something that caught me up on the Linux
side:

> +static void aspeed_i3c_device_ibi_queue_push(AspeedI3CDevice *s)
> +{
> +    /* Stored value is in 32-bit chunks, convert it to byte chunks. */
> +    uint8_t ibi_slice_size = aspeed_i3c_device_ibi_slice_size(s);
> +    uint8_t num_slices = fifo8_num_used(&s->ibi_data.ibi_intermediate_queue) /
> +                         ibi_slice_size;
> +    uint8_t ibi_status_count = num_slices;
> +    union {
> +        uint8_t b[sizeof(uint32_t)];
> +        uint32_t val32;
> +    } ibi_data = {
> +        .val32 = 0
> +    };
> +
> +    /* The report was suppressed, do nothing. */
> +    if (s->ibi_data.ibi_nacked && !s->ibi_data.notify_ibi_nack) {
> +        ARRAY_FIELD_DP32(s->regs, PRESENT_STATE, CM_TFR_ST_STATUS,
> +                         ASPEED_I3C_TRANSFER_STATE_IDLE);
> +        ARRAY_FIELD_DP32(s->regs, PRESENT_STATE, CM_TFR_STATUS,
> +                         ASPEED_I3C_TRANSFER_STATUS_IDLE);
> +        return;
> +    }
> +
> +    /* If we don't have any slices to push, just push the status. */
> +    if (num_slices == 0) {
> +        s->ibi_data.ibi_queue_status =
> +             FIELD_DP32(s->ibi_data.ibi_queue_status, IBI_QUEUE_STATUS,
> +                        LAST_STATUS, 1);
> +        fifo32_push(&s->ibi_queue, s->ibi_data.ibi_queue_status);
> +        ibi_status_count = 1;
> +    }
> +
> +    for (uint8_t i = 0; i < num_slices; i++) {
> +        /* If this is the last slice, set LAST_STATUS. */
> +        if (fifo8_num_used(&s->ibi_data.ibi_intermediate_queue) <
> +            ibi_slice_size) {
> +            s->ibi_data.ibi_queue_status =
> +                FIELD_DP32(s->ibi_data.ibi_queue_status, IBI_QUEUE_STATUS,
> +                           IBI_DATA_LEN,
> +                           fifo8_num_used(&s->ibi_data.ibi_intermediate_queue));
> +            s->ibi_data.ibi_queue_status =
> +                FIELD_DP32(s->ibi_data.ibi_queue_status, IBI_QUEUE_STATUS,
> +                           LAST_STATUS, 1);
> +        } else {
> +            s->ibi_data.ibi_queue_status =
> +                FIELD_DP32(s->ibi_data.ibi_queue_status, IBI_QUEUE_STATUS,
> +                           IBI_DATA_LEN, ibi_slice_size);
> +        }
> +
> +        /* Push the IBI status header. */
> +        fifo32_push(&s->ibi_queue, s->ibi_data.ibi_queue_status);
> +        /* Move each IBI byte into a 32-bit word and push it into the queue. */
> +        for (uint8_t j = 0; j < ibi_slice_size; ++j) {
> +            if (fifo8_is_empty(&s->ibi_data.ibi_intermediate_queue)) {
> +                break;
> +            }
> +
> +            ibi_data.b[j & 3] = fifo8_pop(&s->ibi_data.ibi_intermediate_queue);
> +            /* We have 32-bits, push it to the IBI FIFO. */
> +            if ((j & 0x03) == 0x03) {
> +                fifo32_push(&s->ibi_queue, ibi_data.val32);
> +                ibi_data.val32 = 0;
> +            }
> +        }

You'll probably want to handle the IBI_PEC_EN DAT field when pushing the
IBI to the fifo here.

Due to a HW errata, the driver will *always* need to enable PEC_EN. In
cases where the remote isn't actually sending a PEC, this will consume
the last byte of the IBI payload (and probably cause a PEC error, which
the driver needs to ignore).

See here for the driver side, in patches 4/5 and 5/5:

  https://lore.kernel.org/linux-i3c/d5d76a8d2336d2a71886537f42e71d51db184df6.1680161823.git.jk@codeconstruct.com.au/T/#u

Cheers,


Jeremy

  reply	other threads:[~2023-04-03  3:09 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-31  1:01 [PATCH 00/16] i3c: aspeed: Add I3C support Joe Komlodi
2023-03-31  1:01 ` [PATCH 01/16] hw/misc/aspeed_i3c: Move to i3c directory Joe Komlodi
2023-03-31  1:01 ` [PATCH 02/16] hw/i3c: Add bus support Joe Komlodi
2023-03-31  1:01 ` [PATCH 03/16] hw/i3c/aspeed_i3c: Add more register fields Joe Komlodi
2023-03-31  1:01 ` [PATCH 04/16] hw/i3c/aspeed_i3c: Add more reset values Joe Komlodi
2023-03-31  1:01 ` [PATCH 05/16] hw/i3c/aspeed_i3c: Add register RO field masks Joe Komlodi
2023-03-31  1:01 ` [PATCH 06/16] hw/i3c/aspeed_i3c: Treat more registers as read-as-zero Joe Komlodi
2023-03-31  1:01 ` [PATCH 07/16] hw/i3c/aspeed_i3c: Use 32 bits on MMIO writes Joe Komlodi
2023-03-31  1:01 ` [PATCH 08/16] hw/i3c/aspeed_i3c: Add IRQ MMIO behavior Joe Komlodi
2023-03-31  1:01 ` [PATCH 09/16] hw/i3c/aspeed_i3c: Add data TX and RX Joe Komlodi
2023-04-03  8:45   ` Jeremy Kerr
2023-03-31  1:01 ` [PATCH 10/16] hw/i3c/aspeed_i3c: Add IBI handling Joe Komlodi
2023-04-03  3:08   ` Jeremy Kerr [this message]
2023-04-11  9:16   ` Jeremy Kerr
2023-04-12 23:13     ` Joe Komlodi
2023-03-31  1:01 ` [PATCH 11/16] hw/i3c/aspeed_i3c: Add ctrl MMIO handling Joe Komlodi
2023-03-31  1:01 ` [PATCH 12/16] hw/i3c/aspeed_i3c: Add controller resets Joe Komlodi
2023-03-31  1:01 ` [PATCH 13/16] hw/i3c: Add Mock target Joe Komlodi
2023-03-31  1:01 ` [PATCH 14/16] hw/i3c: remote_i3c: Add model Joe Komlodi
2023-04-03  6:13   ` Jeremy Kerr
2023-04-05  2:04     ` Joe Komlodi
2023-04-05  2:44       ` Jeremy Kerr
2023-03-31  1:01 ` [PATCH 15/16] qtest: remote_i3c: Add remote I3C qtest Joe Komlodi
2023-03-31  1:01 ` [PATCH 16/16] hw/i3c: Add hotplug support Joe Komlodi
2023-04-01 17:28 ` [PATCH 00/16] i3c: aspeed: Add I3C support Ben Dooks
2023-04-02  7:33   ` Cédric Le Goater
2023-04-02  8:11     ` Jeremy Kerr
2023-04-05  1:55       ` Joe Komlodi
2023-04-05  2:06         ` Jeremy Kerr
2023-04-05  2:30           ` Joel Stanley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55b3164d58dd67954ef99551550dcb5a93673150.camel@codeconstruct.com.au \
    --to=jk@codeconstruct.com.au \
    --cc=komlodi@google.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=venture@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).