From: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>, linuxppc-dev@ozlabs.org
Cc: imunsie@au1.ibm.com, dja@axtens.net, Michael Neuling <mikey@neuling.org>
Subject: Re: [PATCH] cxl: sparse: add __iomem annotations in vphb.c
Date: Wed, 04 Nov 2015 17:17:43 +1100 [thread overview]
Message-ID: <5639A307.7060503@au1.ibm.com> (raw)
In-Reply-To: <1446541751.23081.1.camel@ellerman.id.au>
On 03/11/15 20:09, Michael Ellerman wrote:
> Part of your problem is you're storing afu->crs_len which is not __iomem in
> cfg_data which is, and so that's leading to some of your casts.
>
> I don't really see why you're using cfg_data like that, you have the afu in
> phb->private_data. But maybe cfg_data needs to hold that value for some other
> code I'm not seeing.
I can't see any obvious reason why we need to use cfg_data either.
> Regardless, in cxl_pcie_config_info() you have the afu pointer, so you can just
> look at afu->crs_len directly can't you?
>
> That means you can drop one cast of cfg_data to unsigned long in there.
>
> Then I see that cxl_pcie_cfg_addr() is only used in cxl_pcie_config_info(), and
> doesn't abstract much. So I'd drop it and inline the logic. That leads to the
> realisation that we're calling cxl_pcie_cfg_record() twice, so we can save the
> value and only call it once.
> You're then left with:
>
> addr = phb->cfg_addr + (afu->crs_len * record) + offset;
> *ioaddr = (void *)(addr & ~0x3ULL);
> *shift = ((addr & 0x3) * 8);
Will do, that's nicer.
> Ideally we'd be able to say that cfg_addr is always aligned, and so it doesn't
> need to be part of the calculation. I suspect that is true but you'll have to
> check. If it is you can then leave cfg_addr out of the logic and you have:
>
> addr = (afu->crs_len * record) + offset;
>
> *ioaddr = phb->cfg_addr + (addr & ~0x3ull);
> *shift = (addr & 0x3) * 8;
>
> Which hopefully still gives you the right result! :)
Will check.
Andrew
--
Andrew Donnellan Software Engineer, OzLabs
andrew.donnellan@au1.ibm.com Australia Development Lab, Canberra
+61 2 6201 8874 (work) IBM Australia Limited
next prev parent reply other threads:[~2015-11-04 6:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-28 3:29 [PATCH] cxl: sparse: add __iomem annotations in vphb.c Andrew Donnellan
2015-10-28 3:49 ` Ian Munsie
2015-10-30 13:07 ` Arnd Bergmann
2015-11-02 4:57 ` Andrew Donnellan
2015-11-03 9:09 ` Michael Ellerman
2015-11-04 6:17 ` Andrew Donnellan [this message]
2015-12-08 6:30 ` Andrew Donnellan
2015-12-09 1:00 ` Michael Neuling
2015-12-09 1:06 ` Michael Ellerman
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=5639A307.7060503@au1.ibm.com \
--to=andrew.donnellan@au1.ibm.com \
--cc=dja@axtens.net \
--cc=imunsie@au1.ibm.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=mikey@neuling.org \
--cc=mpe@ellerman.id.au \
/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).