Linux Remote Processor Subsystem development
 help / color / mirror / Atom feed
From: Tim Blechmann <tim@klingt.org>
To: Arnaud POULIQUEN <arnaud.pouliquen@foss.st.com>,
	Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Tim Blechmann <tim.blechmann@gmail.com>,
	linux-remoteproc@vger.kernel.org,
	agostino.carballeira@native-instruments.de
Subject: Re: [PATCH 1/1] rpmsg: virtio_rpmsg_bus - prevent possible race condition
Date: Wed, 13 Sep 2023 09:07:06 +0800	[thread overview]
Message-ID: <b3374cec-946b-db27-d849-0a4ec0068b1b@klingt.org> (raw)
In-Reply-To: <0ec7f251-36de-f8b6-cfbe-96632519c851@foss.st.com>


[-- Attachment #1.1: Type: text/plain, Size: 3510 bytes --]

>> virtio emits a few times:
>> [  404.XXXXXX] No more buffers in queue
>> and then
>> [  404.588722] remoteproc remoteproc0: vq index 1 is interrupted
>> [  404.597249] virtqueue interrupt with no work for 6d53f13a
> 
> Difficult to understand the scheduling with your trace. Could you enable ftrace to
> observe it (mailbox interrupts,rpmsg and virtio functions)

does this help (it's a trace that a coworker did a few days ago)?

```
root:.../kernel/tracing# cat trace | head -50
# tracer: function_graph
#
# CPU  DURATION                  FUNCTION CALLS
# |     |   |                     |   |   |   |
  0) + 10.250 us   |        rpmsg_sg_init();
  0) + 42.375 us   |      } /* rpmsg_send_offchannel_raw */
  0) + 51.125 us   |    } /* virtio_rpmsg_send */
  0) + 59.625 us   |  } /* rpmsg_send */
  ------------------------------------------
  0)  stm32mp-414   =>  kworker-365
  ------------------------------------------

  0)               |  rpmsg_recv_done() {
  0)               |    rpmsg_recv_single() {
  0)   5.542 us    |      rpmsg_sg_init();
  0) + 36.542 us   |    }
  0) + 48.250 us   |  }
  ------------------------------------------
  0)  kworker-365   =>  stm32mp-414
  ------------------------------------------

  0)   7.000 us    |  rpmsg_get_buffer_size();
  0)               |  rpmsg_send() {
  0)               |    virtio_rpmsg_send() {
  0)               |      rpmsg_send_offchannel_raw() {
  0)   5.625 us    |        rpmsg_sg_init();
  0) + 37.333 us   |      }
  0) + 45.916 us   |    }
  0) + 54.250 us   |  }
  ------------------------------------------
  0)  stm32mp-414   =>  kworker-365
  ------------------------------------------

  0)               |  rpmsg_recv_done() {
  0)               |    rpmsg_recv_single() {
  0)   6.041 us    |      rpmsg_sg_init();
  0) + 37.292 us   |    }
  0) + 49.542 us   |  }
  ------------------------------------------
  0)  kworker-365   =>  stm32mp-414
  ------------------------------------------

  0)   6.500 us    |  rpmsg_get_buffer_size();
  0)               |  rpmsg_send() {
  0)               |    virtio_rpmsg_send() {
  0)               |      rpmsg_send_offchannel_raw() {
  0)   5.417 us    |        rpmsg_sg_init();
  0) + 36.583 us   |      }
  0) + 45.167 us   |    }
  0) + 53.583 us   |  }
```

apparently this is where it gets stuck (not sure if it's enough context, 
though).

>>
>>> If yes what is not clear to me is that wait_event_interruptible_timeout() seems
>>> to test the condition (so call get_a_tx_buf()) before entering in sleep[1]. A
>>> free TX buffer should be found at this step.
>>>
>>> [1]https://elixir.bootlin.com/linux/latest/source/include/linux/wait.h#L534
>>
>> hmm, interesting. but that would imply a timing issue where calling get_a_tx_buf
>> twice somehow makes a difference as opposed to calling it only once.
>>
>> would the "interrupt with no work" point to a different cause for the issue that
>> we are seeing?
> 
> Look like you have not released the buffer on remote side so no buffer in vring
> used list.
> 
> Do you use the zero copy (rpmsg_hold_rx_buffer) on remote processor?
> If yes, please check that you have following fix:
> https://github.com/OpenAMP/open-amp/commit/2b6a38a9c6890869960ed41d6a1dc9930c079e0d

yes, we use rpmsg_hold_rx_buffer, however the fix from 
2b6a38a9c6890869960ed41d6a1dc9930c079e0d apparently did not change the 
behaviour.

many thanks,
tim

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

  reply	other threads:[~2023-09-13  1:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04  8:36 [PATCH 1/1] rpmsg: virtio_rpmsg_bus - prevent possible race condition Tim Blechmann
2023-09-04 13:52 ` Arnaud POULIQUEN
2023-09-04 20:43   ` Mathieu Poirier
2023-09-05  1:33     ` Tim Blechmann
2023-09-05 16:02       ` Mathieu Poirier
2023-09-08 15:04       ` Arnaud POULIQUEN
2023-09-09  6:28         ` Tim Blechmann
2023-09-11 17:20           ` Arnaud POULIQUEN
2023-09-13  1:07             ` Tim Blechmann [this message]
2023-09-13  1:11               ` Tim Blechmann
2023-09-13  7:44                 ` Arnaud POULIQUEN
2023-09-13  8:47                   ` Tim Blechmann
2023-09-13 10:02                     ` Arnaud POULIQUEN
     [not found]                     ` <CAG2LOc42AG5H56=tzz8_2WrrBiy9d74qYmgPQaEVGrzWTNqodg@mail.gmail.com>
2023-09-14 17:25                       ` Arnaud POULIQUEN
2023-09-16  1:38                         ` Tim Blechmann
2023-09-13 10:10     ` Arnaud POULIQUEN
2023-09-13 14:46       ` Mathieu Poirier
  -- strict thread matches above, loose matches on Subject: below --
2023-09-07  4:51 Tim Blechmann

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=b3374cec-946b-db27-d849-0a4ec0068b1b@klingt.org \
    --to=tim@klingt.org \
    --cc=agostino.carballeira@native-instruments.de \
    --cc=arnaud.pouliquen@foss.st.com \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=tim.blechmann@gmail.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