From: Michael Ellerman <mpe@ellerman.id.au>
To: Nathan Fontenot <nfont@linux.vnet.ibm.com>,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [3/3] powerpc/pseries: Cleanup property cloning in memory dlpar
Date: Wed, 2 Mar 2016 10:02:31 +1100 (AEDT) [thread overview]
Message-ID: <20160301230231.DA2A81402D8@ozlabs.org> (raw)
In-Reply-To: <56BB6FB9.2020701@linux.vnet.ibm.com>
On Wed, 2016-10-02 at 17:13:29 UTC, Nathan Fontenot wrote:
> Now that the DLPAR add/remove flow updates the ibm,dynamic-memory device
> tree property each time we add or remove a LMB the work needed to clone
> this property can be reduced.
>
> Prior to performing any memory DLPAR operation we now clone the device
> tree property once and convert it to cpu format. This copy is then used
> to walk through LMBs as we process them and is thrown away when we
> are finished. There is no longer a need to convert the entire property to
> cpu format and then back to BE every time we update it, we can just parse
> it in its native BE format and update the one LMB we need to modify
> before updating the property.
>
> This patch removes the BE => cpu conversion step in the clone routine and
> creates a drconf_property_to_cpu() routine to make this conversion for the
> one time we need to convert the entire property. This then allows us
> to remove dlpar_update_drconf_property() since we can now do everything
> in dlpar_update_device_tree_lmb().
Hi Nathan,
This sounds like a good cleanup on the face of it.
But even with it applied I still see a boat load of endian errors from sparse
in this file. That worries me, can you please try and fix them.
arch/powerpc/platforms/pseries/hotplug-memory.c:121:20: warning: cast to restricted __be32
arch/powerpc/platforms/pseries/hotplug-memory.c:126:38: warning: cast to restricted __be32
arch/powerpc/platforms/pseries/hotplug-memory.c:129:39: warning: incorrect type in assignment (different base types)
arch/powerpc/platforms/pseries/hotplug-memory.c:129:39: expected unsigned int [unsigned] [usertype] flags
arch/powerpc/platforms/pseries/hotplug-memory.c:129:39: got restricted __be32 [usertype] <noident>
arch/powerpc/platforms/pseries/hotplug-memory.c:130:42: warning: incorrect type in assignment (different base types)
arch/powerpc/platforms/pseries/hotplug-memory.c:130:42: expected unsigned int [unsigned] [usertype] aa_index
arch/powerpc/platforms/pseries/hotplug-memory.c:130:42: got restricted __be32 [usertype] <noident>
arch/powerpc/platforms/pseries/hotplug-memory.c:188:21: warning: cast to restricted __be32
arch/powerpc/platforms/pseries/hotplug-memory.c:189:28: warning: cast to restricted __be32
arch/powerpc/platforms/pseries/hotplug-memory.c:296:16: warning: cast to restricted __be64
arch/powerpc/platforms/pseries/hotplug-memory.c:615:33: warning: cast to restricted __be32
arch/powerpc/platforms/pseries/hotplug-memory.c:675:14: warning: cast to restricted __be32
arch/powerpc/platforms/pseries/hotplug-memory.c:681:37: warning: cast to restricted __be64
arch/powerpc/platforms/pseries/hotplug-memory.c:682:37: warning: cast to restricted __be32
arch/powerpc/platforms/pseries/hotplug-memory.c:683:33: warning: cast to restricted __be32
arch/powerpc/platforms/pseries/hotplug-memory.c:694:15: warning: incorrect type in assignment (different base types)
arch/powerpc/platforms/pseries/hotplug-memory.c:694:15: expected unsigned int [unsigned] [usertype] count
arch/powerpc/platforms/pseries/hotplug-memory.c:694:15: got restricted __be32 [usertype] drc_count
arch/powerpc/platforms/pseries/hotplug-memory.c:695:19: warning: incorrect type in assignment (different base types)
arch/powerpc/platforms/pseries/hotplug-memory.c:695:19: expected unsigned int [unsigned] [usertype] drc_index
arch/powerpc/platforms/pseries/hotplug-memory.c:695:19: got restricted __be32 [usertype] drc_index
arch/powerpc/platforms/pseries/hotplug-memory.c:766:16: warning: cast to restricted __be64
arch/powerpc/platforms/pseries/hotplug-memory.c:808:22: warning: cast to restricted __be32
arch/powerpc/platforms/pseries/hotplug-memory.c:809:24: warning: cast to restricted __be32
arch/powerpc/platforms/pseries/hotplug-memory.c:811:33: warning: cast to restricted __be64
arch/powerpc/platforms/pseries/hotplug-memory.c:814:31: warning: cast to restricted __be32
arch/powerpc/platforms/pseries/hotplug-memory.c:816:30: warning: cast to restricted __be32
arch/powerpc/platforms/pseries/hotplug-memory.c:818:43: warning: cast to restricted __be64
I think the problem is you're using one type, struct of_drconf_cell, to hold
both BE and LE data, but at different times. That may be OK if you do the
conversions exactly right, but it is highly error prone, and also confuses the
checker, so is best avoided.
So we can either say that of_drconf_cell holds the device tree representation,
in which case it should use __be64/__be32, or we say that it holds the cpu
endian representation, in which case it stays as is.
My preference would be the latter, and we create an accessor which does the
conversion in exactly one place, ie. something like:
void of_property_read_drconf_cell(const struct property *p,
struct of_drconf_cell *result)
{
struct {
__be64 base_addr;
__be32 drc_index;
__be32 reserved;
__be32 aa_index;
__be32 flags;
} *s = (void *)p->value;
result->base_addr = be64_to_cpu(s->base_addr);
result->drc_index = be32_to_cpu(s->base_addr);
result->reserved = be32_to_cpu(s->reserved);
result->aa_index = be32_to_cpu(s->aa_index);
result->flags = be32_to_cpu(s->flags);
}
cheers
next prev parent reply other threads:[~2016-03-01 23:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-10 17:08 [PATCH 0/3] powerpc/pseries: Update affinity index during memory dlpar Nathan Fontenot
2016-02-10 17:10 ` [PATCH 1/3] powerpc/pseries: Refactor dlpar_add_lmb() code Nathan Fontenot
2016-04-11 12:35 ` [1/3] " Michael Ellerman
2016-02-10 17:12 ` [PATCH 2/3] powerpc/pseries: Update LMB associativity index during DLPAR add/remove Nathan Fontenot
2016-04-11 12:35 ` [2/3] " Michael Ellerman
2016-02-10 17:13 ` [PATCH 3/3] powerpc/pseries: Cleanup property cloning in memory dlpar Nathan Fontenot
2016-03-01 23:02 ` Michael Ellerman [this message]
2016-03-02 1:47 ` [3/3] " Michael Ellerman
2016-03-04 3:45 ` Nathan Fontenot
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=20160301230231.DA2A81402D8@ozlabs.org \
--to=mpe@ellerman.id.au \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=nfont@linux.vnet.ibm.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;
as well as URLs for NNTP newsgroup(s).