From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heiko Schocher Date: Fri, 2 Sep 2016 09:57:46 +0200 Subject: [U-Boot] [PATCH] getting ubifs to run In-Reply-To: References: <1470909369-8282-1-git-send-email-marco.hoefle@nanotronic.ch> <57AD5913.8030607@denx.de> <4b2d13745b95427285886fb776dfe445@LysExc01.nanotronic.local> <45b12a96629d426f8b663a78ca13e678@LysExc01.nanotronic.local> Message-ID: <57C930FA.8070100@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello Marco, Am 01.09.2016 um 14:45 schrieb Hoefle Marco: > Hello Heiko and Michal, > Do you agree that the u-boot sources need to be adapted in order to have ubifs on the Microblaze? As you found an error, yes! > It would be good if the changes are somehow in the mainline. Of course ... Hmm I wrote on"12.08.2016 07:05": > Hmm... what exactly do you fix? Can you add a commit message please? > > It seems to me, you get ubifs working on microblaze arch? > > And may you can split this patch into at least two pieces, one for the > arch fixes, and one for the ubifs fixes? > > ubifs read support works for me on some arm based plattforms ... > what exactly do you fix with your fs/ubifs/* changes? May I was unclear ... I am waiting for a v2 ;-) Please split your patch into 2 pieces, write a commit message and resend them as a v2 to the list with Michal and me in CC Thanks! bye, Heiko > BR > Marco > > >> -----Original Message----- >> From: Hoefle Marco >> Sent: Montag, 15. August 2016 13:55 >> To: u-boot at lists.denx.de; hs at denx.de >> Cc: monstr at monstr.eu >> Subject: WG: [U-Boot] [PATCH] getting ubifs to run >> >> Hello Heiko, >> You are right, there are two parts: the Microblaze part and the ubifs stuff. >> To get u-boot compiled I added the following to the Microblaze architecture: >> atomic.h based on the ARM architecture, was missing before. >> Modified bitops.h to get rid of compiler warnings The three ubifs files had >> #defines which didn't work for me. >> With the changes of the patch I sent I can successfully load the Kernel from a >> ubifs partition on a Microblaze. >> >> >> That were the problems: >> >> CC fs/ubifs/ubifs.o >> In file included from /home/hoefle/projects/u- >> boot_patch/fs/ubifs/ubifs.c:17:0: >> /home/hoefle/projects/u-boot_patch/fs/ubifs/ubifs.h:35:24: fatal error: >> asm/atomic.h: No such file or directory #include >> ^ >> compilation terminated. >> >> >> /home/hoefle/projects/u- >> boot_patch/arch/microblaze/include/asm/bitops.h:197:19: note: expected >> 'volatile void *' but argument is of type 'const long unsigned int *' >> static inline int __test_bit(int nr, volatile void *addr) >> ^ >> /home/hoefle/projects/u-boot_patch/fs/ubifs/misc.h: In function >> 'ubifs_zn_obsolete': >> /home/hoefle/projects/u- >> boot_patch/arch/microblaze/include/asm/bitops.h:210:18: warning: passing >> argument 2 of '__test_bit' discards 'const' qualifier from pointer target type >> __test_bit((nr),(addr))) >> ^ >> /home/hoefle/projects/u-boot_patch/fs/ubifs/misc.h:38:11: note: in >> expansion of macro 'test_bit' >> return !!test_bit(OBSOLETE_ZNODE, &znode->flags); >> ^ >> /home/hoefle/projects/u- >> boot_patch/arch/microblaze/include/asm/bitops.h:197:19: note: expected >> 'volatile void *' but argument is of type 'const long unsigned int *' >> static inline int __test_bit(int nr, volatile void *addr) >> ^ >> /home/hoefle/projects/u-boot_patch/fs/ubifs/misc.h: In function >> 'ubifs_zn_cow': >> /home/hoefle/projects/u- >> boot_patch/arch/microblaze/include/asm/bitops.h:210:18: warning: passing >> argument 2 of '__test_bit' discards 'const' qualifier from pointer target type >> __test_bit((nr),(addr))) >> ^ >> /home/hoefle/projects/u-boot_patch/fs/ubifs/misc.h:50:11: note: in >> expansion of macro 'test_bit' >> return !!test_bit(COW_ZNODE, &znode->flags); >> ^ >> /home/hoefle/projects/u- >> boot_patch/arch/microblaze/include/asm/bitops.h:197:19: note: expected >> 'volatile void *' but argument is of type 'const long unsigned int *' >> static inline int __test_bit(int nr, volatile void *addr) >> ^ >> >> >> >> fs/built-in.o: In function `ubifs_lpt_start_commit': >> /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:1232: >> undefined reference to `dbg_chk_lpt_free_spc' >> /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:1235: >> undefined reference to `dbg_check_ltab' >> fs/built-in.o: In function `layout_cnodes': >> /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:195: undefined >> reference to `dbg_chk_lpt_sz' >> /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:211: undefined >> reference to `dbg_chk_lpt_sz' >> /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:219: undefined >> reference to `dbg_chk_lpt_sz' >> /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:233: undefined >> reference to `dbg_chk_lpt_sz' >> /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:246: undefined >> reference to `dbg_chk_lpt_sz' >> fs/built-in.o:/home/hoefle/projects/u- >> boot_patch/fs/ubifs/lpt_commit.c:254: more undefined references to >> `dbg_chk_lpt_sz' follow >> fs/built-in.o: In function `layout_cnodes': >> /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:322: undefined >> reference to `ubifs_dump_lpt_lebs' >> fs/built-in.o: In function `ubifs_add_bud_to_log': >> /home/hoefle/projects/u-boot_patch/fs/ubifs/log.c:194: undefined >> reference to `ubifs_commit_required' >> /home/hoefle/projects/u-boot_patch/fs/ubifs/log.c:225: undefined >> reference to `ubifs_request_bg_commit' >> /home/hoefle/projects/u-boot_patch/fs/ubifs/log.c:265: undefined >> reference to `ubifs_write_node' >> fs/built-in.o: In function `ubifs_log_end_commit': >> /home/hoefle/projects/u-boot_patch/fs/ubifs/log.c:479: undefined >> reference to `ubifs_write_master' >> fs/built-in.o: In function `write_orph_node': >> /home/hoefle/projects/u-boot_patch/fs/ubifs/orphan.c:248: undefined >> reference to `ubifs_write_node' >> >> >> Regards, >> Marco >> >> >> >>> -----Original Message----- >>> From: Heiko Schocher [mailto:hs at denx.de] >>> Sent: Freitag, 12. August 2016 07:05 >>> To: Hoefle Marco >>> Cc: monstr at monstr.eu; u-boot at lists.denx.de >>> Subject: Re: [U-Boot] [PATCH] getting ubifs to run >>> >>> Hello Marco, >>> >>> Am 11.08.2016 um 11:56 schrieb Marco: >>>> Signed-off-by: Marco >>>> --- >>>> arch/microblaze/include/asm/atomic.h | 114 >>> +++++++++++++++++++++++++++++++++++ >>>> arch/microblaze/include/asm/bitops.h | 8 +-- >>>> fs/ubifs/io.c | 2 +- >>>> fs/ubifs/log.c | 99 ++++++++++++++++++++++++++++++ >>>> fs/ubifs/lpt_commit.c | 21 +++++++ >>>> 5 files changed, 239 insertions(+), 5 deletions(-) >>>> create mode 100644 arch/microblaze/include/asm/atomic.h >>> >>> Hmm... what exactly do you fix? Can you add a commit message please? >>> >>> It seems to me, you get ubifs working on microblaze arch? >>> >>> And may you can split this patch into at least two pieces, one for the >>> arch fixes, and one for the ubifs fixes? >>> >>> ubifs read support works for me on some arm based plattforms ... >>> what exactly do you fix with your fs/ubifs/* changes? >>> >>> Thanks! >>> >>> bye, >>> Heiko >>>> diff --git a/arch/microblaze/include/asm/atomic.h >>>> b/arch/microblaze/include/asm/atomic.h >>>> new file mode 100644 >>>> index 0000000..2872149 >>>> --- /dev/null >>>> +++ b/arch/microblaze/include/asm/atomic.h >>>> @@ -0,0 +1,114 @@ >>>> +/* >>>> + * linux/include/asm-arm/atomic.h >>>> + * >>>> + * Copyright (c) 1996 Russell King. >>>> + * >>>> + * This program is free software; you can redistribute it and/or >>>> +modify >>>> + * it under the terms of the GNU General Public License version 2 >>>> +as >>>> + * published by the Free Software Foundation. >>>> + * >>>> + * Changelog: >>>> + * 27-06-1996 RMK Created >>>> + * 13-04-1997 RMK Made functions atomic! >>>> + * 07-12-1997 RMK Upgraded for v2.1. >>>> + * 26-08-1998 PJB Added #ifdef __KERNEL__ >>>> + */ >>>> +#ifndef __ASM_ARM_ATOMIC_H >>>> +#define __ASM_ARM_ATOMIC_H >>>> + >>>> +#ifdef CONFIG_SMP >>>> +#error SMP not supported >>>> +#endif >>>> + >>>> +typedef struct { volatile int counter; } atomic_t; >>>> + >>>> +#define ATOMIC_INIT(i) { (i) } >>>> + >>>> +#ifdef __KERNEL__ >>>> +#include >>>> + >>>> +#define atomic_read(v) ((v)->counter) >>>> +#define atomic_set(v,i) (((v)->counter) = (i)) >>>> + >>>> + >>>> + >>>> + >>>> +static inline void atomic_add(int i, volatile atomic_t *v) { >>>> + unsigned long flags = 0; >>>> + >>>> + local_irq_save(flags); >>>> + v->counter += i; >>>> + local_irq_restore(flags); >>>> +} >>>> + >>>> +static inline void atomic_sub(int i, volatile atomic_t *v) { >>>> + unsigned long flags = 0; >>>> + >>>> + local_irq_save(flags); >>>> + v->counter -= i; >>>> + local_irq_restore(flags); >>>> +} >>>> + >>>> +static inline void atomic_inc(volatile atomic_t *v) { >>>> + unsigned long flags = 0; >>>> + >>>> + local_irq_save(flags); >>>> + v->counter += 1; >>>> + local_irq_restore(flags); >>>> +} >>>> + >>>> +static inline void atomic_dec(volatile atomic_t *v) { >>>> + unsigned long flags = 0; >>>> + >>>> + local_irq_save(flags); >>>> + v->counter -= 1; >>>> + local_irq_restore(flags); >>>> +} >>>> + >>>> +static inline int atomic_dec_and_test(volatile atomic_t *v) { >>>> + unsigned long flags = 0; >>>> + int val; >>>> + >>>> + local_irq_save(flags); >>>> + val = v->counter; >>>> + v->counter = val -= 1; >>>> + local_irq_restore(flags); >>>> + >>>> + return val == 0; >>>> +} >>>> + >>>> +static inline int atomic_add_negative(int i, volatile atomic_t *v) { >>>> + unsigned long flags = 0; >>>> + int val; >>>> + >>>> + local_irq_save(flags); >>>> + val = v->counter; >>>> + v->counter = val += i; >>>> + local_irq_restore(flags); >>>> + >>>> + return val < 0; >>>> +} >>>> + >>>> +static inline void atomic_clear_mask(unsigned long mask, unsigned >>>> +long *addr) { >>>> + unsigned long flags = 0; >>>> + >>>> + local_irq_save(flags); >>>> + *addr &= ~mask; >>>> + local_irq_restore(flags); >>>> +} >>>> + >>>> +/* Atomic operations are already serializing on ARM */ >>>> +#define smp_mb__before_atomic_dec() barrier() >>>> +#define smp_mb__after_atomic_dec() barrier() >>>> +#define smp_mb__before_atomic_inc() barrier() >>>> +#define smp_mb__after_atomic_inc() barrier() >>>> + >>>> +#endif >>>> +#endif >>>> diff --git a/arch/microblaze/include/asm/bitops.h >>>> b/arch/microblaze/include/asm/bitops.h >>>> index 2cab2ac..b3b17b9 100644 >>>> --- a/arch/microblaze/include/asm/bitops.h >>>> +++ b/arch/microblaze/include/asm/bitops.h >>>> @@ -204,10 +204,10 @@ static inline int __test_bit(int nr, volatile >>>> void >>> *addr) >>>> return ((mask & *a) != 0); >>>> } >>>> >>>> -#define test_bit(nr,addr) \ >>>> -(__builtin_constant_p(nr) ? \ >>>> - __constant_test_bit((nr),(addr)) : \ >>>> - __test_bit((nr),(addr))) >>>> +static inline int test_bit(int nr, const void * addr) { >>>> + return ((unsigned char *) addr)[nr >> 3] & (1U << (nr & 7)); } >>>> >>>> #define find_first_zero_bit(addr, size) \ >>>> find_next_zero_bit((addr), (size), 0) diff --git a/fs/ubifs/io.c >>>> b/fs/ubifs/io.c index 51a95bb..685713e 100644 >>>> --- a/fs/ubifs/io.c >>>> +++ b/fs/ubifs/io.c >>>> @@ -847,6 +847,7 @@ out: >>>> ubifs_dump_leb(c, wbuf->lnum); >>>> return err; >>>> } >>>> +#endif >>>> >>>> /** >>>> * ubifs_write_node - write node to the media. >>>> @@ -885,7 +886,6 @@ int ubifs_write_node(struct ubifs_info *c, void >>>> *buf, int len, int lnum, >>>> >>>> return err; >>>> } >>>> -#endif >>>> >>>> /** >>>> * ubifs_read_node_wbuf - read node from the media or write-buffer. >>>> diff --git a/fs/ubifs/log.c b/fs/ubifs/log.c index a07fdef..10302b9 >>>> 100644 >>>> --- a/fs/ubifs/log.c >>>> +++ b/fs/ubifs/log.c >>>> @@ -743,3 +743,102 @@ static int dbg_check_bud_bytes(struct >>>> ubifs_info >>>> *c) >>>> >>>> return err; >>>> } >>>> + >>>> + >>>> +/** >>>> + * ubifs_commit_required - set commit state to "required". >>>> + * @c: UBIFS file-system description object >>>> + * >>>> + * This function is called if a commit is required but cannot be >>>> +done from the >>>> + * calling function, so it is just flagged instead. >>>> + */ >>>> +void ubifs_commit_required(struct ubifs_info *c) { >>>> + spin_lock(&c->cs_lock); >>>> + switch (c->cmt_state) { >>>> + case COMMIT_RESTING: >>>> + case COMMIT_BACKGROUND: >>>> + dbg_cmt("old: %s, new: %s", dbg_cstate(c->cmt_state), >>>> + dbg_cstate(COMMIT_REQUIRED)); >>>> + c->cmt_state = COMMIT_REQUIRED; >>>> + break; >>>> + case COMMIT_RUNNING_BACKGROUND: >>>> + dbg_cmt("old: %s, new: %s", dbg_cstate(c->cmt_state), >>>> + dbg_cstate(COMMIT_RUNNING_REQUIRED)); >>>> + c->cmt_state = COMMIT_RUNNING_REQUIRED; >>>> + break; >>>> + case COMMIT_REQUIRED: >>>> + case COMMIT_RUNNING_REQUIRED: >>>> + case COMMIT_BROKEN: >>>> + break; >>>> + } >>>> + spin_unlock(&c->cs_lock); >>>> +} >>>> + >>>> +/** >>>> + * ubifs_write_master - write master node. >>>> + * @c: UBIFS file-system description object >>>> + * >>>> + * This function writes the master node. Returns zero in case of >>>> +success and a >>>> + * negative error code in case of failure. The master node is >>>> +written twice to >>>> + * enable recovery. >>>> + */ >>>> +int ubifs_write_master(struct ubifs_info *c) { >>>> + int err, lnum, offs, len; >>>> + >>>> + ubifs_assert(!c->ro_media && !c->ro_mount); >>>> + if (c->ro_error) >>>> + return -EROFS; >>>> + >>>> + lnum = UBIFS_MST_LNUM; >>>> + offs = c->mst_offs + c->mst_node_alsz; >>>> + len = UBIFS_MST_NODE_SZ; >>>> + >>>> + if (offs + UBIFS_MST_NODE_SZ > c->leb_size) { >>>> + err = ubifs_leb_unmap(c, lnum); >>>> + if (err) >>>> + return err; >>>> + offs = 0; >>>> + } >>>> + >>>> + c->mst_offs = offs; >>>> + c->mst_node->highest_inum = cpu_to_le64(c->highest_inum); >>>> + >>>> + err = ubifs_write_node(c, c->mst_node, len, lnum, offs); >>>> + if (err) >>>> + return err; >>>> + >>>> + lnum += 1; >>>> + >>>> + if (offs == 0) { >>>> + err = ubifs_leb_unmap(c, lnum); >>>> + if (err) >>>> + return err; >>>> + } >>>> + err = ubifs_write_node(c, c->mst_node, len, lnum, offs); >>>> + >>>> + return err; >>>> +} >>>> + >>>> +/** >>>> + * ubifs_request_bg_commit - notify the background thread to do a >>> commit. >>>> + * @c: UBIFS file-system description object >>>> + * >>>> + * This function is called if the journal is full enough to make a >>>> +commit >>>> + * worthwhile, so background thread is kicked to start it. >>>> + */ >>>> +void ubifs_request_bg_commit(struct ubifs_info *c) { >>>> + spin_lock(&c->cs_lock); >>>> + if (c->cmt_state == COMMIT_RESTING) { >>>> + dbg_cmt("old: %s, new: %s", dbg_cstate(c->cmt_state), >>>> + dbg_cstate(COMMIT_BACKGROUND)); >>>> + c->cmt_state = COMMIT_BACKGROUND; >>>> + spin_unlock(&c->cs_lock); >>>> + ubifs_wake_up_bgt(c); >>>> + } else >>>> + spin_unlock(&c->cs_lock); } >>>> + >>>> + >>>> diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c index >>>> 2df9130..61b2cc8 100644 >>>> --- a/fs/ubifs/lpt_commit.c >>>> +++ b/fs/ubifs/lpt_commit.c >>>> @@ -2039,4 +2039,25 @@ static int dbg_populate_lsave(struct >>>> ubifs_info >>>> *c) >>>> >>>> return 1; >>>> } >>>> +#else >>>> + >>>> +int dbg_chk_lpt_free_spc(struct ubifs_info *c) { >>>> + return 0; >>>> +} >>>> + >>>> +int dbg_check_ltab(struct ubifs_info *c) { >>>> + return 0; >>>> +} >>>> + >>>> +int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len) { >>>> + return 0; >>>> +} >>>> + >>>> +void ubifs_dump_lpt_lebs(const struct ubifs_info *c) { } >>>> + >>>> #endif >>>> >>> >>> -- >>> DENX Software Engineering GmbH, Managing Director: Wolfgang Denk >>> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany >>> > -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany