openbmc.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Peter Delevoryas <pdel@fb.com>
Cc: Billy Tsai <billy_tsai@aspeedtech.com>,
	OpenBMC List <openbmc@lists.ozlabs.org>
Subject: Re: aspeed-adc driver kpanic
Date: Mon, 4 Oct 2021 19:26:04 +0000	[thread overview]
Message-ID: <24AC6FDD-323D-4F37-818F-C965164544BF@fb.com> (raw)
In-Reply-To: <YVtNypUnYfp/kztP@heinlein>



> On Oct 4, 2021, at 11:54 AM, Patrick Williams <patrick@stwcx.xyz> wrote:
> 
> On Mon, Oct 04, 2021 at 01:34:54PM -0500, Patrick Williams wrote:
>> Hi Billy,
>> 
>> When I run the latest linux-5.14 on QEMU with the Witherspoon config, I end up
>> with a kernel panic[1].  I think there is an ordering problem in the aspeed_adc
>> driver.  
>> 
>> See [2,3].  The code registers with devm a pointer to the prescaler object which
>> is not yet created.  I think it is possible that the struct value contains
>> uninitialized data as well.  Can you please take a look at this?
>> 
>> 1. https://gist.github.com/williamspatrick/4a0f0d1e0ca6f54816461a8df09e6cb8
>> 2. https://github.com/openbmc/linux/blob/dev-5.14/drivers/iio/adc/aspeed_adc.c#L513
>> 3. https://github.com/openbmc/linux/blob/dev-5.14/drivers/iio/adc/aspeed_adc.c#L527
>> 
>> -- 
>> Patrick Williams
> 
> Also, Peter D. has been working on getting the QEMU code for the ADC working
> and I cherry-picked his commits[1] and the code gets farther but crashes with
> what seems like a memory alignment issue in a read at [2].  New gist of kernel panic
> at [3].

Oh yeah, this is probably not the driver’s fault, this is the fault of my QEMU
patches. I only allowed 32-bit aligned reads. I bet if you apply this additional
diff, it won’t crash, but it’ll probably return the channel 0 values when you’re
trying to read channel 1 values, channel 2 instead of channel 3, etc. I think only
the data registers require the 16-bit read access, because 2 channels are packed
in each 32-bit data register, but the bounds and hysteresis registers are
1 channel per register.

diff --git a/hw/adc/aspeed_adc.c b/hw/adc/aspeed_adc.c
index fcd93d6853..58e3f18c6c 100644
--- a/hw/adc/aspeed_adc.c
+++ b/hw/adc/aspeed_adc.c
@@ -234,9 +234,9 @@ static const MemoryRegionOps aspeed_adc_engine_ops = {
     .write = aspeed_adc_engine_write,
     .endianness = DEVICE_LITTLE_ENDIAN,
     .valid = {
-        .min_access_size = 4,
+        .min_access_size = 1,
         .max_access_size = 4,
-        .unaligned = false,
+        .unaligned = true,
     },
 };

I intend to resolve this by resubmitting Andrew Jeffery’s patch for supporting
16-bit and 8-bit reads transparently to the QEMU model, but maybe I’ll also
revise my patch to support the 16-bit reads (even without Andrew’s special
memory patch).

https://lore.kernel.org/qemu-devel/20170630030058.28943-1-andrew@aj.id.au/

Cedric just approved what I had, but it hasn’t been pulled yet: if you want,
feel free to comment, I’ll probably comment about it myself too.

https://lore.kernel.org/qemu-devel/4d7c55d4-25fd-520c-97aa-98036fe6fd1a@kaod.org/

Thanks!
Peter

> 
> 1. https://github.com/peterdelevoryas/qemu/tree/adc-support-v2
> 2. https://github.com/openbmc/linux/blob/dev-5.14/drivers/iio/adc/aspeed_adc.c#L248
> 3. https://gist.github.com/williamspatrick/76827c99e2db8fce385b9a87f7526d33
> 
> -- 
> Patrick Williams


  reply	other threads:[~2021-10-04 23:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-04 18:34 aspeed-adc driver kpanic Patrick Williams
2021-10-04 18:54 ` Patrick Williams
2021-10-04 19:26   ` Peter Delevoryas [this message]
2021-10-04 22:25     ` Patrick Williams
2021-10-05  0:00 ` 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=24AC6FDD-323D-4F37-818F-C965164544BF@fb.com \
    --to=pdel@fb.com \
    --cc=billy_tsai@aspeedtech.com \
    --cc=openbmc@lists.ozlabs.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).