All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, qemu-devel@nongnu.org
Subject: Re: [PATCH 2/7] mac_via: fix up adb_via_receive() trace events
Date: Wed, 10 Mar 2021 09:51:28 +0100	[thread overview]
Message-ID: <026461af-7084-9bd0-27cd-ab8132bb593f@vivier.eu> (raw)
In-Reply-To: <20210310080908.11861-3-mark.cave-ayland@ilande.co.uk>

Le 10/03/2021 à 09:09, Mark Cave-Ayland a écrit :
> The use of the post-increment operator on adb_data_in_index meant that the
> trace-event was accidentally displaying the next byte in the incoming ADB
> data buffer rather than the current byte.
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>  hw/misc/mac_via.c | 41 ++++++++++++++++++++++++-----------------
>  1 file changed, 24 insertions(+), 17 deletions(-)
> 
> diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c
> index 488d086a17..0f6586e102 100644
> --- a/hw/misc/mac_via.c
> +++ b/hw/misc/mac_via.c
> @@ -816,33 +816,37 @@ static void adb_via_receive(MacVIAState *s, int state, uint8_t *data)
>          switch (s->adb_data_in_index) {
>          case 0:
>              /* First EVEN byte: vADBInt indicates bus timeout */
> -            trace_via1_adb_receive(state == ADB_STATE_EVEN ? "EVEN" : " ODD",
> -                                   *data, (ms->b & VIA1B_vADBInt) ? "+" : "-",
> -                                   adb_bus->status, s->adb_data_in_index,
> -                                   s->adb_data_in_size);
> -
> -            *data = s->adb_data_in[s->adb_data_in_index++];
> +            *data = s->adb_data_in[s->adb_data_in_index];
>              if (adb_bus->status & ADB_STATUS_BUSTIMEOUT) {
>                  ms->b &= ~VIA1B_vADBInt;
>              } else {
>                  ms->b |= VIA1B_vADBInt;
>              }
> -            break;
>  
> -        case 1:
> -            /* First ODD byte: vADBInt indicates SRQ */
>              trace_via1_adb_receive(state == ADB_STATE_EVEN ? "EVEN" : " ODD",
>                                     *data, (ms->b & VIA1B_vADBInt) ? "+" : "-",
>                                     adb_bus->status, s->adb_data_in_index,
>                                     s->adb_data_in_size);
>  
> -            *data = s->adb_data_in[s->adb_data_in_index++];
> +            s->adb_data_in_index++;
> +            break;
> +
> +        case 1:
> +            /* First ODD byte: vADBInt indicates SRQ */
> +            *data = s->adb_data_in[s->adb_data_in_index];
>              pending = adb_bus->pending & ~(1 << (s->adb_autopoll_cmd >> 4));
>              if (pending) {
>                  ms->b &= ~VIA1B_vADBInt;
>              } else {
>                  ms->b |= VIA1B_vADBInt;
>              }
> +
> +            trace_via1_adb_receive(state == ADB_STATE_EVEN ? "EVEN" : " ODD",
> +                                   *data, (ms->b & VIA1B_vADBInt) ? "+" : "-",
> +                                   adb_bus->status, s->adb_data_in_index,
> +                                   s->adb_data_in_size);
> +
> +            s->adb_data_in_index++;
>              break;
>  
>          default:
> @@ -852,14 +856,9 @@ static void adb_via_receive(MacVIAState *s, int state, uint8_t *data)
>               * end of the poll reply, so provide these extra bytes below to
>               * keep it happy
>               */
> -            trace_via1_adb_receive(state == ADB_STATE_EVEN ? "EVEN" : " ODD",
> -                                   *data, (ms->b & VIA1B_vADBInt) ? "+" : "-",
> -                                   adb_bus->status, s->adb_data_in_index,
> -                                   s->adb_data_in_size);
> -
>              if (s->adb_data_in_index < s->adb_data_in_size) {
>                  /* Next data byte */
> -                *data = s->adb_data_in[s->adb_data_in_index++];
> +                *data = s->adb_data_in[s->adb_data_in_index];
>                  ms->b |= VIA1B_vADBInt;
>              } else if (s->adb_data_in_index == s->adb_data_in_size) {
>                  if (adb_bus->status & ADB_STATUS_BUSTIMEOUT) {
> @@ -869,7 +868,6 @@ static void adb_via_receive(MacVIAState *s, int state, uint8_t *data)
>                      /* Return 0x0 after reply */
>                      *data = 0;
>                  }
> -                s->adb_data_in_index++;
>                  ms->b &= ~VIA1B_vADBInt;
>              } else {
>                  /* Bus timeout (no more data) */
> @@ -878,6 +876,15 @@ static void adb_via_receive(MacVIAState *s, int state, uint8_t *data)
>                  adb_bus->status = 0;
>                  adb_autopoll_unblock(adb_bus);
>              }
> +
> +            trace_via1_adb_receive(state == ADB_STATE_EVEN ? "EVEN" : " ODD",
> +                                   *data, (ms->b & VIA1B_vADBInt) ? "+" : "-",
> +                                   adb_bus->status, s->adb_data_in_index,
> +                                   s->adb_data_in_size);
> +
> +            if (s->adb_data_in_index <= s->adb_data_in_size) {
> +                s->adb_data_in_index++;
> +            }
>              break;
>          }
>  
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>


  reply	other threads:[~2021-03-10  8:56 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10  8:09 [PATCH 0/7] mac_via: fixes and improvements Mark Cave-Ayland
2021-03-10  8:09 ` [PATCH 1/7] mac_via: switch rtc pram trace-events to use hex rather than decimal for addresses Mark Cave-Ayland
2021-03-10  8:42   ` Laurent Vivier
2021-03-10  8:09 ` [PATCH 2/7] mac_via: fix up adb_via_receive() trace events Mark Cave-Ayland
2021-03-10  8:51   ` Laurent Vivier [this message]
2021-03-10  8:09 ` [PATCH 3/7] mac_via: allow long accesses to VIA registers Mark Cave-Ayland
2021-03-10  8:57   ` Laurent Vivier
2021-03-10  8:09 ` [PATCH 4/7] mac_via: don't re-inject ADB response when switching to IDLE state Mark Cave-Ayland
2021-03-10  8:09 ` [PATCH 5/7] mac_via: rename VBL timer to 60Hz timer Mark Cave-Ayland
2021-03-10  8:44   ` Laurent Vivier
2021-03-10  8:09 ` [PATCH 6/7] mac_via: fix 60Hz VIA1 timer interval Mark Cave-Ayland
2021-03-10  8:47   ` Laurent Vivier
2021-03-10 12:32   ` BALATON Zoltan
2021-03-10 12:56     ` Laurent Vivier
2021-03-10 13:10       ` Laurent Vivier
2021-03-10 13:24         ` Laurent Vivier
2021-03-10 22:11           ` Mark Cave-Ayland
2021-03-11  0:15             ` BALATON Zoltan
2021-03-11  9:04               ` Mark Cave-Ayland
2021-03-11  9:44                 ` Laurent Vivier
2021-03-11  9:50                   ` Mark Cave-Ayland
2021-03-10 13:27         ` Philippe Mathieu-Daudé
2021-03-10  8:09 ` [PATCH 7/7] mac_via: remove VIA1 timer optimisations Mark Cave-Ayland
2021-03-10  8:50   ` Laurent Vivier

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=026461af-7084-9bd0-27cd-ab8132bb593f@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.