qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Jean-Christophe Dubois <jcd@tribudubois.net>
Cc: "QEMU Developers" <qemu-devel@nongnu.org>,
	"Marcin Krzemiński" <mar.krzeminski@gmail.com>
Subject: Re: [Qemu-devel] [PATCH v4] [i.MX] fix CS handling during SPI access.
Date: Mon, 9 Jan 2017 10:46:27 +0000	[thread overview]
Message-ID: <CAFEAcA8dwhoSZTWS9JJ6-vSUs1Asw8ymktmD+oOqx0DNpCV2XQ@mail.gmail.com> (raw)
In-Reply-To: <20170104220624.26557-1-jcd@tribudubois.net>

On 4 January 2017 at 22:06, Jean-Christophe Dubois <jcd@tribudubois.net> wrote:
> The i.MX SPI device was not de-asserting the CS line at the end of
> memory access.
>
> This triggered a SIGSEGV in Qemu when the sabrelite emulator was acessing
> a SPI flash memory.
>
> Whith this path the CS signal is correctly asserted and deasserted arround
> memory access.
>
> Assertion level is now based on SPI device configuration.
>
> This was tested by:
> * booting linux on Sabrelite Qemu emulator.
> * booting xvisor on Sabrelite Qemu emultor.
>
> Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
> Acked-by: Marcin Krzemiński <mar.krzeminski@gmail.com>

>  static void imx_spi_reset(DeviceState *dev)
>  {
>      IMXSPIState *s = IMX_SPI(dev);
> +    uint32_t i;
>
>      DPRINTF("\n");
>
> @@ -243,6 +263,11 @@ static void imx_spi_reset(DeviceState *dev)
>      imx_spi_update_irq(s);
>
>      s->burst_length = 0;
> +
> +    /* Disable all CS lines */
> +    for (i = 0; i < 4; i++) {
> +        qemu_set_irq(s->cs_lines[i], !imx_spi_channel_pol(s, i));
> +    }

Calling qemu_set_irq() in a device reset function is a bit
tricky, because in a full system reset the device at the other
end might have already reset or might not, and calling into
its handler function for the irq line change might provoke
an unwanted change of its state. We don't really have a coherent
model here but for the moment we just try to avoid calling
set_irq in a reset method.

thanks
-- PMM

  reply	other threads:[~2017-01-09 10:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-04 22:06 [Qemu-devel] [PATCH v4] [i.MX] fix CS handling during SPI access Jean-Christophe Dubois
2017-01-09 10:46 ` Peter Maydell [this message]
2017-01-09 19:04   ` mar.krzeminski
2017-01-09 19:06     ` Peter Maydell
2017-01-09 20:05       ` Jean-Christophe DUBOIS
2017-01-09 21:19         ` Jean-Christophe DUBOIS
2017-01-09 21:45           ` Peter Maydell
2017-01-09 22:27             ` Jean-Christophe DUBOIS
2017-01-09 23:02               ` Peter Maydell
2017-01-11 16:12                 ` Jean-Christophe DUBOIS
2017-01-11 18:08                   ` mar.krzeminski
2017-01-11 18:47                     ` Jean-Christophe DUBOIS

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=CAFEAcA8dwhoSZTWS9JJ6-vSUs1Asw8ymktmD+oOqx0DNpCV2XQ@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=jcd@tribudubois.net \
    --cc=mar.krzeminski@gmail.com \
    --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 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).