LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 09-17-2017, 04:09 AM   #1
vivek thullimalli
LQ Newbie
 
Registered: Aug 2017
Posts: 5

Rep: Reputation: Disabled
initializing clocks in linux kernel


Hi,

I am trying to port clocks for custom Made SoC into linux kernel (4.9), by setting up a lookup table. My code was given below.

structures used for clocks:
struct clk
{
struct list_head node;
const char *name;
struct clk *parent;
unsigned long rate;
int users;
int sw_locked;
void __iomem *enable_reg;
u32 enable_mask;
// struct clk_core *core;

unsigned long (*get_rate)(struct clk *clk);
int (*set_rate)(struct clk *clk, unsigned long rate);
};

static struct clk ref_clk =
{
.name = "ref",
.rate = CRYSTAL_OSC_CLK_RATE,
};

static struct clk pll1_clk =
{
.parent = &ref_clk,
};

static struct clk apb_clk =
{
.parent = &pll1_clk,
};

static struct clk spi_clk =
{
.parent = &apb_clk,
.rate = 102400, /*100KHz*/
};


My code for lookup table:

static struct clk_lookup clocks[] =
{
CLKDEV_INIT(NULL, "ref", &ref_clk),
CLKDEV_INIT(NULL, "pll1", &pll1_clk),
CLKDEV_INIT(NULL, "apb_pclk", &apb_clk),
CLKDEV_INIT("spi0", NULL, &spi_clk),
};

Init call from board file:

int __init clocks_init(void)
{
clkdev_add_table(clocks, ARRAY_SIZE(clocks));
return 0;
}
postcore_initcall(bbsoc_clocks_init);

I am facing error below:
Unable to handle kernel NULL pointer dereference at virtual address 00000008
[ 0.000000] pgd = c0004000
[ 0.000000] [00000008] *pgd=00000000
[ 0.000000] Internal error: Oops: 5 [#1] ARM
[ 0.000000] Modules linked in:
[ 0.000000] CPU: 0 PID: 1 Comm: swapper Not tainted 4.9.22+ #22
[ 0.000000] Hardware name: BCM2835
[ 0.000000] task: c6898000 task.stack: c688e000
[ 0.000000] PC is at __clk_get_hw+0x1c/0x24
[ 0.000000] LR is at clkdev_add_table+0x40/0x78
[ 0.000000] pc : [<c025ce40>] lr : [<c025cda8>] psr: a0000053
[ 0.000000] sp : c688fe58 ip : c688fe68 fp : c688fe64
[ 0.000000] r10: 00000000 r9 : 0000003d r8 : c04867f0
[ 0.000000] r7 : c04ea720 r6 : c04ea714 r5 : 00000004 r4 : c04cbf50
[ 0.000000] r3 : 00000000 r2 : 00000000 r1 : 00000004 r0 : c04cbf98
[ 0.000000] Flags: NzCv IRQs on FIQs off Mode SVC_32 ISA ARM Segment user
[ 0.000000] Control: 00c5387d Table: c0004008 DAC: 00000055
[ 0.000000] Process swapper (pid: 1, stack limit = 0xc688e188)
[ 0.000000] Stack: (0xc688fe58 to 0xc6890000)
[ 0.000000] fe40: c688fe84 c688fe68
[ 0.000000] fe60: c025cda8 c025ce30 00000000 c8905000 c0501020 c04ae820 c688fea4 c688fe88
[ 0.000000] fe80: c048a6d8 c025cd74 00000000 c03004d4 c04ca798 c04cd718 c688febc c688fea8
[ 0.000000] fea0: c048a4a8 c048a62c c04c27f8 00000003 c688fecc c688fec0 c0486814 c048a49c
[ 0.000000] fec0: c688ff4c c688fed0 c0009a6c c04867fc c0483614 c02268b8 00000000 c0434e84
[ 0.000000] fee0: c6fffe00 c032ca2c c688ff4c c688fef8 c003e5f4 c0483604 c0050050 c00bb438
[ 0.000000] ff00: 00000000 c030f938 00000003 00000003 00000000 c04349c0 c03d2654 00000000
[ 0.000000] ff20: c688ff4c c04c27f8 00000003 c0501020 c04ae820 00000000 0000003d c04ae838
[ 0.000000] ff40: c688ff94 c688ff50 c0483ec0 c0009a2c 00000003 00000003 00000000 c04835f8
[ 0.000000] ff60: 9d322010 62802229 20a41903 00000000 c030cc94 00000000 00000000 00000000
[ 0.000000] ff80: 00000000 00000000 c688ffac c688ff98 c030ccac c0483d48 ffffffff 00000000
[ 0.000000] ffa0: 00000000 c688ffb0 c00107c8 c030cca0 00000000 00000000 00000000 00000000
[ 0.000000] ffc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 0.000000] ffe0: 00000000 00000000 00000000 00000000 00000013 00000000 0114212a 8dce8aa8
[ 0.000000] [<c025ce40>] (__clk_get_hw) from [<c025cda8>] (clkdev_add_table+0x40/0x78)
[ 0.000000] [<c025cda8>] (clkdev_add_table) from [<c048a6d8>] (bbsoc_clocks_init+0xb8/0xec)
[ 0.000000] [<c048a6d8>] (clocks_init) from [<c048a4a8>] (bcm2835_init+0x18/0x74)
[ 0.000000] [<c048a4a8>] (bcm2835_init) from [<c0486814>] (customize_machine+0x24/0x30)
[ 0.000000] [<c0486814>] (customize_machine) from [<c0009a6c>] (do_one_initcall+0x4c/0x180)
[ 0.000000] [<c0009a6c>] (do_one_initcall) from [<c0483ec0>] (kernel_init_freeable+0x184/0x254)
[ 0.000000] [<c0483ec0>] (kernel_init_freeable) from [<c030ccac>] (kernel_init+0x18/0x114)
[ 0.000000] [<c030ccac>] (kernel_init) from [<c00107c8>] (ret_from_fork+0x14/0x2c)
[ 0.000000] Code: e52de004 e8bd4000 e3500000 15903000 (15930008)
[ 0.000000] ---[ end trace 671b49261be9dc6a ]---
[ 0.000000] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b

upon investigation func: __clk_get_hw(cl->clk); is trying to access clk->core->hw (This is where exactly it is failing!)(below function)
struct clk_hw *__clk_get_hw(struct clk *clk)
{
return !clk ? NULL : clk->core->hw;
}
EXPORT_SYMBOL_GPL(__clk_get_hw);

the above function is from file: ./drivers/clk/clk.c

Any suggestions on this?

Thanks,
Vivek

Last edited by vivek thullimalli; 09-18-2017 at 12:31 AM.
 
Old 09-17-2017, 06:52 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,863

Rep: Reputation: 2905Reputation: 2905Reputation: 2905Reputation: 2905Reputation: 2905Reputation: 2905Reputation: 2905Reputation: 2905Reputation: 2905Reputation: 2905Reputation: 2905
http://catb.org/~esr/faqs/smart-ques...html#beprecise
 
Old 09-17-2017, 02:58 PM   #3
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 4,515
Blog Entries: 6

Rep: Reputation: 2426Reputation: 2426Reputation: 2426Reputation: 2426Reputation: 2426Reputation: 2426Reputation: 2426Reputation: 2426Reputation: 2426Reputation: 2426Reputation: 2426
Please place your code and kernel message snippets inside [CODE]...[/CODE] tags for better readability. You may type those yourself or click the "#" button in the edit controls.

As you are doing this with custom hardware it would be difficult for others to understand the context of the question.

As a kernel question it might have more meaning to someone intimately familiar with kernel code. As a programming question there is not enough relevant information given for anyone to provide any help.

Please see the Site FAQ for help in asking a complete question, in particular the link at bottom of that page, How to Ask Questions the Smart Way.
 
Old 09-18-2017, 01:15 AM   #4
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 4,515
Blog Entries: 6

Rep: Reputation: 2426Reputation: 2426Reputation: 2426Reputation: 2426Reputation: 2426Reputation: 2426Reputation: 2426Reputation: 2426Reputation: 2426Reputation: 2426Reputation: 2426
Moved: This thread is more suitable in Kernel forum and has been moved accordingly to help your thread/question get the exposure it deserves.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: 5 of the Best Free Linux Clocks LXer Syndicated Linux News 0 09-02-2013 08:21 PM
Kernel Module with multiple source files not initializing mbschenkel Linux - Kernel 2 06-20-2011 03:45 PM
LXer: Benchmark clocks TI's OMAP2420 graphics on Linux LXer Syndicated Linux News 0 02-03-2006 10:46 AM
Kernel Freeze Initializing Network Xyem Linux - Newbie 15 10-11-2005 07:54 PM
Kernel panic when Redhat 9.0 cdrom is initializing for installation armes Linux - Software 0 06-01-2004 03:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 08:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration