linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: peng.hao2@zte.com.cn
Cc: andy.shevchenko@gmail.com, robh+dt@kernel.org,
	mark.rutland@arm.com, gregkh@linuxfoundation.org,
	andy@infradead.org, dvhart@infradead.org,
	linux-kernel@vger.kernel.org,
	platform-driver-x86@vger.kernel.org, hutao@cn.fujitsu.com
Subject: Re: Re: [PATCH V2 2/4] misc/pvpanic: add MMIO support
Date: Fri, 26 Oct 2018 09:11:01 +0200	[thread overview]
Message-ID: <CAK8P3a0Y7en4Aa_-ho7fdp17SsG=XnTePhTeqxFmr5PE4LvHeA@mail.gmail.com> (raw)
In-Reply-To: <201810261140543493998@zte.com.cn>

On 10/26/18, peng.hao2@zte.com.cn <peng.hao2@zte.com.cn> wrote:
>>
>> On some architectures (e.g. arm64), it's preferable to use MMIO, since
>> this can be used standalone. Add MMIO support to the pvpanic driver.
>>
>>
>>No global variables, please.

There obviously has to be at least one global variable here, since the
caller of panic() has no context about the device that provides
the MMIO register. But I agree that using ioreadxx() here would
be nice to simplify the code, and it avoids having separate variables
for pio and mmio mode.

>>If your switch to ioreadxx()iowritexx() it would really help you here.
>>
> I can use iowrite8, but here:
>  if (base)
>       iounmap(base);
> I found the nearest API pci_iounmap, but it's a bit strange to see how this
> function is
> used here from the name of the function.
> And I do not confirm that this API is suitable for all architectures.

From reading the driver, I think you either come from a caller that
always uses PIO or from one that always uses MMIO, and they
are paired with probe/remove, so you can assign the global
__iomem pointer using either ioport_map() or ioremap(), and
undo that using ioport_unmap/iounmap respectively, while the
user just uses iowrite8() unconditionally. This is allowed by the
iowritexx() interfaces.

Alternatively, using devm_ioremap_resource() should work for
either pio or mmio, but it requires a device pointer, which in turn
means you have to slightly rewrite the ACPI portion to use a
platform_driver instead.

      Arnd

  parent reply	other threads:[~2018-10-26  7:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-24 17:12 [PATCH V2 1/4] misc/pvpanic: move pvpanic to misc as common driver Peng Hao
2018-10-24 13:08 ` Andy Shevchenko
2018-10-24 17:12 ` [PATCH V2 2/4] misc/pvpanic: add MMIO support Peng Hao
2018-10-24 13:09   ` Andy Shevchenko
     [not found]     ` <201810261140543493998@zte.com.cn>
2018-10-26  7:11       ` Arnd Bergmann [this message]
2018-10-24 17:12 ` [PATCH V2 3/4] misc/pvpanic: add support to pvpanic device information by using FDT Peng Hao
2018-10-24 13:12   ` Andy Shevchenko
2018-10-24 17:12 ` [PATCH V2 4/4] misc/pvpanic : pvpanic: add document for pvpanic-mmio DT Peng Hao
2018-10-24 13:35   ` Rob Herring

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='CAK8P3a0Y7en4Aa_-ho7fdp17SsG=XnTePhTeqxFmr5PE4LvHeA@mail.gmail.com' \
    --to=arnd@arndb.de \
    --cc=andy.shevchenko@gmail.com \
    --cc=andy@infradead.org \
    --cc=dvhart@infradead.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hutao@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=peng.hao2@zte.com.cn \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=robh+dt@kernel.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).