Re: [PATCH v2 08/12] MIPS: use CKSEG1 instead of KSEG1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, Sam,

On Mon, May 21, 2018 at 05:08:03PM +0200, Sam Ravnborg wrote:
> Hi Peter.
> 
> On Mon, May 21, 2018 at 02:54:34PM +0300, Peter Mamonov wrote:
> > Signed-off-by: Peter Mamonov <pmamonov@xxxxxxxxx>
> > ---
> 
> Can you elaborate a little over this change?
> Earlier IOMEM was fixed to use KSEG1 and not CKSEG1
>
> And now something else moves the other way.

Well, before patch 6 of this patch series IOMEM for MIPS was defined using 
CKSEG1ADDR() macro.  Patch 6 introduced a new definition for MIPS64 using 
PHYS_TO_XKSEG_UNCACHED macro. I can't see any use of KSEG1 in IOMEM definition 
for MIPS...

> > For readers like me that has no clue what KSEG0 and CKSEG0
> is the change looks like noise.
> It may be perfectly fine, but there is no backgrond info to tell why

Anyway, here is the story. MIPS virtual address space is partitioned into 
several segments.  Here is an excerpt from the "See MIPS run (Linux)" book 
which describes KSEG0 and KSEG1:

	kseg0 0x8000.0000 – 9FFF.FFFF (512MB): These addresses are translated
		into physical addresses by merely stripping off the top bit and 
		mapping them contiguously into the low 512 MB of physical 
		memory. [...] Addresses in this region are almost always 
		accessed through the cache, so they may not be used until the 
		caches are properly initialized. They will be used for most 
		programs and data in systems not using the MMU and will be used 
		for the OS kernel for systems that do use the MMU.

	kseg1 0xA000.0000 – BFFF.FFFF (512MB): These addresses are mapped
		into physical addresses by stripping off the leading 3 bits, 
		giving a duplicate mapping of the low 512 MB of physical 
		memory. But this time, access will not use the cache. The kseg1 
		region is the only chunk of the memory map that is guaranteed 
		to behave properly from system reset; that’s why the 		
		after-reset starting point ( 0xBFC0.0000 ) lies within it.

Now, after introduction of MIPS64 these segments were preserved for 
compatibility reasons, and its 64bit equivalents are located at  
0xffffffff80000000 and 0xffffffffa0000000 respectively.

As you can see from the arch/mips/include/asm/addrspace.h KSEG0/1 are defined 
for 32 bits only:

	#ifdef CONFIG_64BIT
	...
	#else
	...
	#define KSEG0                   0x80000000
	#define KSEG1                   0xa0000000
	...
	#endif

While CKSEG0/1 are defined for both 64 and 32 bits:

	#ifdef CONFIG_64BIT
	...
	#define CKSEG0                  _CONST64_(0xffffffff80000000)
	#define CKSEG1                  _CONST64_(0xffffffffa0000000)
	...
	#else
	...
	#define CKSEG0                   0x80000000
	#define CKSEG1                   0xa0000000
	...
	#endif

Linux defines these constants in the same way. I belive the "C" prefix to 
contants names stands for Compatible.

Anyway, if you try to compile 64 bit barebox and use KSEG1 in your code, 
compilation will fail.

Regards,
Peter

> 
> 	Sam

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux