mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
e31cf2f4ca
Patch series "mm: consolidate definitions of page table accessors", v2. The low level page table accessors (pXY_index(), pXY_offset()) are duplicated across all architectures and sometimes more than once. For instance, we have 31 definition of pgd_offset() for 25 supported architectures. Most of these definitions are actually identical and typically it boils down to, e.g. static inline unsigned long pmd_index(unsigned long address) { return (address >> PMD_SHIFT) & (PTRS_PER_PMD - 1); } static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address) { return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(address); } These definitions can be shared among 90% of the arches provided XYZ_SHIFT, PTRS_PER_XYZ and xyz_page_vaddr() are defined. For architectures that really need a custom version there is always possibility to override the generic version with the usual ifdefs magic. These patches introduce include/linux/pgtable.h that replaces include/asm-generic/pgtable.h and add the definitions of the page table accessors to the new header. This patch (of 12): The linux/mm.h header includes <asm/pgtable.h> to allow inlining of the functions involving page table manipulations, e.g. pte_alloc() and pmd_alloc(). So, there is no point to explicitly include <asm/pgtable.h> in the files that include <linux/mm.h>. The include statements in such cases are remove with a simple loop: for f in $(git grep -l "include <linux/mm.h>") ; do sed -i -e '/include <asm\/pgtable.h>/ d' $f done Signed-off-by: Mike Rapoport <rppt@linux.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Cain <bcain@codeaurora.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Chris Zankel <chris@zankel.net> Cc: "David S. Miller" <davem@davemloft.net> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Greentime Hu <green.hu@gmail.com> Cc: Greg Ungerer <gerg@linux-m68k.org> Cc: Guan Xuetao <gxt@pku.edu.cn> Cc: Guo Ren <guoren@kernel.org> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Helge Deller <deller@gmx.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Ley Foon Tan <ley.foon.tan@intel.com> Cc: Mark Salter <msalter@redhat.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Matt Turner <mattst88@gmail.com> Cc: Max Filippov <jcmvbkbc@gmail.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Michal Simek <monstr@monstr.eu> Cc: Mike Rapoport <rppt@kernel.org> Cc: Nick Hu <nickhu@andestech.com> Cc: Paul Walmsley <paul.walmsley@sifive.com> Cc: Richard Weinberger <richard@nod.at> Cc: Rich Felker <dalias@libc.org> Cc: Russell King <linux@armlinux.org.uk> Cc: Stafford Horne <shorne@gmail.com> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Tony Luck <tony.luck@intel.com> Cc: Vincent Chen <deanbo422@gmail.com> Cc: Vineet Gupta <vgupta@synopsys.com> Cc: Will Deacon <will@kernel.org> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Link: http://lkml.kernel.org/r/20200514170327.31389-1-rppt@kernel.org Link: http://lkml.kernel.org/r/20200514170327.31389-2-rppt@kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
137 lines
3.4 KiB
C
137 lines
3.4 KiB
C
/***************************************************************************/
|
|
|
|
/*
|
|
* timers.c - Generic hardware timer support.
|
|
*
|
|
* Copyright (C) 1993 Hamish Macdonald
|
|
* Copyright (C) 1999 D. Jeff Dionne
|
|
* Copyright (C) 2001 Georges Menie, Ken Desmet
|
|
*
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
* License. See the file COPYING in the main directory of this archive
|
|
* for more details.
|
|
*/
|
|
|
|
/***************************************************************************/
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/irq.h>
|
|
#include <linux/clocksource.h>
|
|
#include <linux/rtc.h>
|
|
#include <asm/setup.h>
|
|
#include <asm/machdep.h>
|
|
#include <asm/MC68VZ328.h>
|
|
|
|
/***************************************************************************/
|
|
|
|
#if defined(CONFIG_DRAGEN2)
|
|
/* with a 33.16 MHz clock, this will give usec resolution to the time functions */
|
|
#define CLOCK_SOURCE TCTL_CLKSOURCE_SYSCLK
|
|
#define CLOCK_PRE 7
|
|
#define TICKS_PER_JIFFY 41450
|
|
|
|
#elif defined(CONFIG_XCOPILOT_BUGS)
|
|
/*
|
|
* The only thing I know is that CLK32 is not available on Xcopilot
|
|
* I have little idea about what frequency SYSCLK has on Xcopilot.
|
|
* The values for prescaler and compare registers were simply
|
|
* taken from the original source
|
|
*/
|
|
#define CLOCK_SOURCE TCTL_CLKSOURCE_SYSCLK
|
|
#define CLOCK_PRE 2
|
|
#define TICKS_PER_JIFFY 0xd7e4
|
|
|
|
#else
|
|
/* default to using the 32Khz clock */
|
|
#define CLOCK_SOURCE TCTL_CLKSOURCE_32KHZ
|
|
#define CLOCK_PRE 31
|
|
#define TICKS_PER_JIFFY 10
|
|
#endif
|
|
|
|
static u32 m68328_tick_cnt;
|
|
static irq_handler_t timer_interrupt;
|
|
|
|
/***************************************************************************/
|
|
|
|
static irqreturn_t hw_tick(int irq, void *dummy)
|
|
{
|
|
/* Reset Timer1 */
|
|
TSTAT &= 0;
|
|
|
|
m68328_tick_cnt += TICKS_PER_JIFFY;
|
|
return timer_interrupt(irq, dummy);
|
|
}
|
|
|
|
/***************************************************************************/
|
|
|
|
static u64 m68328_read_clk(struct clocksource *cs)
|
|
{
|
|
unsigned long flags;
|
|
u32 cycles;
|
|
|
|
local_irq_save(flags);
|
|
cycles = m68328_tick_cnt + TCN;
|
|
local_irq_restore(flags);
|
|
|
|
return cycles;
|
|
}
|
|
|
|
/***************************************************************************/
|
|
|
|
static struct clocksource m68328_clk = {
|
|
.name = "timer",
|
|
.rating = 250,
|
|
.read = m68328_read_clk,
|
|
.mask = CLOCKSOURCE_MASK(32),
|
|
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
|
|
};
|
|
|
|
/***************************************************************************/
|
|
|
|
void hw_timer_init(irq_handler_t handler)
|
|
{
|
|
int ret;
|
|
|
|
/* disable timer 1 */
|
|
TCTL = 0;
|
|
|
|
/* set ISR */
|
|
ret = request_irq(TMR_IRQ_NUM, hw_tick, IRQF_TIMER, "timer", NULL);
|
|
if (ret) {
|
|
pr_err("Failed to request irq %d (timer): %pe\n", TMR_IRQ_NUM,
|
|
ERR_PTR(ret));
|
|
}
|
|
|
|
/* Restart mode, Enable int, Set clock source */
|
|
TCTL = TCTL_OM | TCTL_IRQEN | CLOCK_SOURCE;
|
|
TPRER = CLOCK_PRE;
|
|
TCMP = TICKS_PER_JIFFY;
|
|
|
|
/* Enable timer 1 */
|
|
TCTL |= TCTL_TEN;
|
|
clocksource_register_hz(&m68328_clk, TICKS_PER_JIFFY*HZ);
|
|
timer_interrupt = handler;
|
|
}
|
|
|
|
/***************************************************************************/
|
|
|
|
int m68328_hwclk(int set, struct rtc_time *t)
|
|
{
|
|
if (!set) {
|
|
long now = RTCTIME;
|
|
t->tm_year = 1;
|
|
t->tm_mon = 0;
|
|
t->tm_mday = 1;
|
|
t->tm_hour = (now >> 24) % 24;
|
|
t->tm_min = (now >> 16) % 60;
|
|
t->tm_sec = now % 60;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/***************************************************************************/
|