public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] getting ubifs to run
@ 2016-08-11  9:56 Marco
  2016-08-12  5:05 ` Heiko Schocher
  0 siblings, 1 reply; 11+ messages in thread
From: Marco @ 2016-08-11  9:56 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Marco <marco.hoefle@nanotronic.ch>
---
 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

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 <asm/system.h>
+
+#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
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread
* [U-Boot] [PATCH] getting ubifs to run
@ 2016-09-21 20:05 Travis Waters
  2016-09-26  4:38 ` Heiko Schocher
  0 siblings, 1 reply; 11+ messages in thread
From: Travis Waters @ 2016-09-21 20:05 UTC (permalink / raw)
  To: u-boot

Hello,

I am working to enable UBIFS for use on the sparc platform and I am running
into the same linking trouble flagged in this thread:

uboot/fs/ubifs/lpt_commit.c:1232: undefined reference to
`dbg_chk_lpt_free_spc'
uboot/fs/ubifs/lpt_commit.c:1235: undefined reference to `dbg_check_ltab'
fs/built-in.o: In function `layout_cnodes':
uboot/fs/ubifs/lpt_commit.c:195: undefined reference to `dbg_chk_lpt_sz'
uboot/fs/ubifs/lpt_commit.c:211: undefined reference to `dbg_chk_lpt_sz'
uboot/fs/ubifs/lpt_commit.c:219: undefined reference to `dbg_chk_lpt_sz'
uboot/fs/ubifs/lpt_commit.c:233: undefined reference to `dbg_chk_lpt_sz'
uboot/fs/ubifs/lpt_commit.c:246: undefined reference to `dbg_chk_lpt_sz'
fs/built-in.o:uboot/fs/ubifs/lpt_commit.c:254: more undefined references to
`dbg_chk_lpt_sz' follow
fs/built-in.o: In function `layout_cnodes':
uboot/fs/ubifs/lpt_commit.c:322: undefined reference to
`ubifs_dump_lpt_lebs'
fs/built-in.o: In function `ubifs_add_bud_to_log':
uboot/fs/ubifs/log.c:194: undefined reference to `ubifs_commit_required'
uboot/fs/ubifs/log.c:225: undefined reference to `ubifs_request_bg_commit'
uboot/fs/ubifs/log.c:265: undefined reference to `ubifs_write_node'
fs/built-in.o: In function `ubifs_log_end_commit':
uboot/fs/ubifs/log.c:479: undefined reference to `ubifs_write_master'
fs/built-in.o: In function `do_write_orph_node':
uboot/fs/ubifs/orphan.c:248: undefined reference to `ubifs_write_node'


What is the status of the patch that was addressing this?

Thanks!
-Travis

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-09-26 13:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-11  9:56 [U-Boot] [PATCH] getting ubifs to run Marco
2016-08-12  5:05 ` Heiko Schocher
2016-08-12  7:24   ` Hoefle Marco
2016-08-15 11:55     ` [U-Boot] WG: " Hoefle Marco
2016-09-01 12:45       ` [U-Boot] " Hoefle Marco
2016-09-02  7:57         ` Heiko Schocher
  -- strict thread matches above, loose matches on Subject: below --
2016-09-21 20:05 Travis Waters
2016-09-26  4:38 ` Heiko Schocher
2016-09-26  4:43   ` Travis Waters
2016-09-26  4:52     ` Heiko Schocher
2016-09-26 13:28       ` Hoefle Marco

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox