From: Scott Wood <scottwood@freescale.com>
To: Kim Phillips <kim.phillips@freescale.com>
Cc: "J. German Rivera" <German.Rivera@freescale.com>,
<gregkh@linuxfoundation.org>, <arnd@arndb.de>,
<linux-kernel@vger.kernel.org>, <stuart.yoder@freescale.com>,
<agraf@suse.de>, <linuxppc-release@linux.freescale.net>
Subject: Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Date: Mon, 15 Sep 2014 23:31:21 -0500 [thread overview]
Message-ID: <1410841881.24184.499.camel@snotra.buserror.net> (raw)
In-Reply-To: <20140915184451.962a3a19c4940792d182f10a@freescale.com>
On Mon, 2014-09-15 at 18:44 -0500, Kim Phillips wrote:
> On Thu, 11 Sep 2014 12:34:21 -0500
> "J. German Rivera" <German.Rivera@freescale.com> wrote:
>
> > +int mc_get_version(struct fsl_mc_io *mc_io, struct mc_version *mc_ver_info)
> > +{
> > + struct mc_command cmd = { 0 };
>
> we can save some cycles if this initialization is not absolutely
> necessary: is it? i.e., does the h/w actually look at the params
> section when doing a get_version? not sure to what other commands
> this comment would apply to...at least get_container_id, but maybe
> more - all of them?
Do you really want to open that can of worms, much less to speed up
something that doesn't look performance critical? Have fun debugging it
if it turns out the hardware does look at something you didn't
initialize.
> > diff --git a/drivers/bus/fsl-mc/fsl_mc_sys.c b/drivers/bus/fsl-mc/fsl_mc_sys.c
>
> > +/**
> > + * Map an MC portal in the kernel virtual address space
> > + */
> > +static int map_mc_portal(phys_addr_t mc_portal_phys_addr,
> > + uint32_t mc_portal_size,
> > + void __iomem **new_mc_portal_virt_addr)
> > +{
> > + void __iomem *mc_portal_virt_addr = NULL;
> > + struct resource *res = NULL;
> > + int error = -EINVAL;
> > +
> > + res =
> > + request_mem_region(mc_portal_phys_addr, mc_portal_size,
> > + "mc_portal");
> > + if (res == NULL) {
> > + pr_err("request_mem_region() failed for MC portal %#llx\n",
> > + mc_portal_phys_addr);
> > + error = -EBUSY;
> > + goto error;
> > + }
> > +
> > + mc_portal_virt_addr = ioremap_nocache(mc_portal_phys_addr,
> > + mc_portal_size);
> > + if (mc_portal_virt_addr == NULL) {
> > + pr_err("ioremap_nocache() failed for MC portal %#llx\n",
> > + mc_portal_phys_addr);
> > + error = -EFAULT;
> > + goto error;
> > + }
> > +
> > + *new_mc_portal_virt_addr = mc_portal_virt_addr;
> > + return 0;
> > +error:
> > + if (mc_portal_virt_addr != NULL)
> > + iounmap(mc_portal_virt_addr);
> > +
> > + if (res != NULL)
> > + release_mem_region(mc_portal_phys_addr, mc_portal_size);
> > +
> > + return error;
> > +}
>
> unnecessary initializations, bad error codes (both should be
> -ENOMEM),
Why should the first one be -ENOMEM? It's not allocating memory, but
rather reserving I/O space.
> unnecessarily complicated error path, plus a simpler
> implementation can be made if fn can return the mapped address, like
> so:
>
> static void __iomem *map_mc_portal(phys_addr_t mc_portal_phys_addr,
> uint32_t mc_portal_size)
> {
> struct resource *res;
> void __iomem *mapped_addr;
>
> res = request_mem_region(mc_portal_phys_addr, mc_portal_size,
> "mc_portal");
> if (!res)
> return NULL;
>
> mapped_addr = ioremap_nocache(mc_portal_phys_addr,
> mc_portal_size);
> if (!mapped_addr)
> release_mem_region(mc_portal_phys_addr, mc_portal_size);
>
> return mapped_addr;
> }
>
> the callsite can return -ENOMEM to its caller if returned NULL.
-ENOMEM would only be appropriate for one of these errors.
> > +#define ioread64(_p) readq(_p)
> > +#define iowrite64(_v, _p) writeq(_v, _p)
>
> these definitions have names that are too generic to belong in a FSL
> h/w header: conflicts will be introduced once the existing
> io{read,write}32 functions get promoted. Either use readq/writeq
> directly, or, if you can justify it, patch a more generic io.h.
>
> Also, is there a reason the 'relaxed' versions of the i/o accessors
> aren't being used?
Raw accessors should only be used in performance critical sections where
it's worth the effort to implement and verify manual synchronization.
My understanding is that the entire management complex is related to
setup, not on the I/O fast path.
-Scott
next prev parent reply other threads:[~2014-09-16 4:46 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-11 17:34 [PATCH 0/4] drivers/bus: Freescale Management Complex bus driver patch series J. German Rivera
2014-09-11 17:34 ` [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs J. German Rivera
2014-09-11 18:45 ` Joe Perches
2014-09-17 16:35 ` German Rivera
2014-09-15 23:44 ` Kim Phillips
2014-09-16 4:31 ` Scott Wood [this message]
2014-09-16 19:28 ` Kim Phillips
2014-09-16 19:58 ` Scott Wood
2014-09-18 4:17 ` German Rivera
2014-09-18 13:14 ` Alexander Graf
2014-09-18 20:22 ` Kim Phillips
2014-09-18 23:03 ` Scott Wood
2014-09-18 23:13 ` Stuart Yoder
2014-09-18 23:29 ` Scott Wood
2014-09-18 23:46 ` Stuart Yoder
2014-09-19 3:05 ` German Rivera
2014-09-19 17:19 ` Kim Phillips
2014-09-19 19:06 ` Stuart Yoder
2014-09-19 20:24 ` Kim Phillips
2014-09-19 20:32 ` Alexander Graf
2014-09-19 20:41 ` Scott Wood
2014-09-19 21:46 ` Alexander Graf
2014-09-20 15:36 ` Stuart Yoder
2014-09-19 21:37 ` Stuart Yoder
2014-09-19 21:30 ` Stuart Yoder
2014-09-19 0:18 ` Stuart Yoder
2014-09-19 2:34 ` German Rivera
2014-09-19 18:25 ` Stuart Yoder
2014-09-19 20:58 ` Kim Phillips
2014-09-22 14:42 ` Stuart Yoder
2014-09-22 14:57 ` <gregkh@linuxfoundation.org>
2014-09-22 15:01 ` Stuart Yoder
2014-09-18 23:39 ` Stuart Yoder
2014-09-18 23:53 ` Scott Wood
2014-09-11 17:34 ` [PATCH 2/4] drivers/bus: Freescale Management Complex (fsl-mc) bus driver J. German Rivera
2014-09-11 18:49 ` Joe Perches
2014-09-17 23:50 ` German Rivera
2014-09-11 17:34 ` [PATCH 3/4] drivers/bus: Device driver for FSL-MC DPRC devices J. German Rivera
2014-09-11 17:34 ` [PATCH 4/4] Update MAINTAINERS file J. German Rivera
2014-09-15 23:44 ` [PATCH 0/4] drivers/bus: Freescale Management Complex bus driver patch series Kim Phillips
2014-09-18 0:20 ` German Rivera
2014-09-18 12:58 ` Alexander Graf
2014-09-19 0:31 ` German Rivera
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=1410841881.24184.499.camel@snotra.buserror.net \
--to=scottwood@freescale.com \
--cc=German.Rivera@freescale.com \
--cc=agraf@suse.de \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=kim.phillips@freescale.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-release@linux.freescale.net \
--cc=stuart.yoder@freescale.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
all inboxes | Powered by JetHome®