From: "Guan Xuetao" <gxt@mprc.pku.edu.cn>
To: "'Arnd Bergmann'" <arnd@arndb.de>
Cc: <linux-kernel@vger.kernel.org>, <linux-arch@vger.kernel.org>,
"'Greg KH'" <greg@kroah.com>
Subject: RE: [PATCH 09/12] unicore32 machine related files: hardware registers
Date: Sun, 27 Feb 2011 11:35:05 +0800 [thread overview]
Message-ID: <017d01cbd62f$53af8590$fb0e90b0$@mprc.pku.edu.cn> (raw)
In-Reply-To: <201102261416.10050.arnd@arndb.de>
> -----Original Message-----
> From: Arnd Bergmann [mailto:arnd@arndb.de]
> Sent: Saturday, February 26, 2011 9:16 PM
> To: Guan Xuetao
> Cc: linux-kernel@vger.kernel.org; linux-arch@vger.kernel.org; 'Greg KH'
> Subject: Re: [PATCH 09/12] unicore32 machine related files: hardware registers
>
> On Saturday 26 February 2011, Guan Xuetao wrote:
> > > > #ifndef __ASSEMBLY__
> > > >
> > > > -# define __REG(x) (*((volatile unsigned long *)io_p2v(x)))
> > > > -# define __PREG(x) (io_v2p((unsigned long)&(x)))
> > > > +# define __REG(x) (void __iomem *)io_p2v(x)
> > >
> > > The patch looks correct, but if you make the the definition for
> > > PKUNITY_MMIO_BASE contain the cast to (void __iomem *), you no
> > > longer need another cast.
> >
> > Because the io_p2v(x) calculate x and PKUNITY_IOSPACE_BASE,
> > all registers should be added with (void __iomem *).
> > So I prefer to remain the previous patch.
>
> The problem with the definition of io_p2v is that it gives you
> an type that is impossible to use correctly, except in assembly
> code. Linux assumes that MMIO registers in virtual space
> are __iomem pointers, and we like that to be consistent.
>
> If you have a function that returns a virtual address, it should
> really have the same type as any other function that uses a virtual
> address.
Ok, I see.
Please see following patch, __REG removed and __iomem added to io_p2v:
diff --git a/arch/unicore32/include/mach/hardware.h b/arch/unicore32/include/mach/hardware.h
index b71405a..b197b0b 100644
--- a/arch/unicore32/include/mach/hardware.h
+++ b/arch/unicore32/include/mach/hardware.h
@@ -17,13 +17,10 @@
#include "PKUnity.h"
-#define io_p2v(x) ((x) - PKUNITY_MMIO_BASE)
-#define io_v2p(x) ((x) + PKUNITY_MMIO_BASE)
-
#ifndef __ASSEMBLY__
-
-# define __REG(x) (void __iomem *)io_p2v(x)
-
+#define io_p2v(x) (void __iomem *)((x) - PKUNITY_MMIO_BASE)
+#else
+#define io_p2v(x) ((x) - PKUNITY_MMIO_BASE)
#endif
#define PCIBIOS_MIN_IO 0x4000 /* should lower than 64KB */
>
> Arnd
Thanks & Regards.
Guan Xuetao
next prev parent reply other threads:[~2011-02-27 3:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-16 7:51 Guan Xuetao
2011-02-17 16:59 ` Arnd Bergmann
2011-02-18 9:52 ` Guan Xuetao
2011-02-18 10:42 ` Arnd Bergmann
2011-02-22 14:09 ` Guan Xuetao
2011-02-22 14:19 ` Arnd Bergmann
2011-02-26 12:23 ` Guan Xuetao
2011-02-26 13:16 ` Arnd Bergmann
2011-02-27 3:35 ` Guan Xuetao [this message]
2011-02-27 17:15 ` Arnd Bergmann
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='017d01cbd62f$53af8590$fb0e90b0$@mprc.pku.edu.cn' \
--to=gxt@mprc.pku.edu.cn \
--cc=arnd@arndb.de \
--cc=greg@kroah.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.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
all inboxes | Powered by JetHome®