This is a note to let you know that I've just added the patch titled

    pstore/ram: avoid atomic accesses for ioremapped regions

to the 3.10-stable tree which can be found at:
    
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     pstore-ram-avoid-atomic-accesses-for-ioremapped-regions.patch
and it can be found in the queue-3.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.


>From 0405a5cec3406f19e69da07c8111a6bf1088ac29 Mon Sep 17 00:00:00 2001
From: Rob Herring <[email protected]>
Date: Mon, 8 Apr 2013 20:23:33 -0500
Subject: pstore/ram: avoid atomic accesses for ioremapped regions

From: Rob Herring <[email protected]>

commit 0405a5cec3406f19e69da07c8111a6bf1088ac29 upstream.

For persistent RAM outside of main memory, the memory may have limitations
on supported accesses. For internal RAM on highbank platform exclusive
accesses are not supported and will hang the system. So atomic_cmpxchg
cannot be used. This commit uses spinlock protection for buffer size and
start updates on ioremapped regions instead.

Signed-off-by: Rob Herring <[email protected]>
Acked-by: Anton Vorontsov <[email protected]>
Signed-off-by: Tony Luck <[email protected]>
[hkp: Backported to 3.10: adjust context]
Signed-off-by: HuKeping <[email protected]>

---
 fs/pstore/ram_core.c |   54 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 52 insertions(+), 2 deletions(-)

--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -46,7 +46,7 @@ static inline size_t buffer_start(struct
 }
 
 /* increase and wrap the start pointer, returning the old value */
-static inline size_t buffer_start_add(struct persistent_ram_zone *prz, size_t 
a)
+static size_t buffer_start_add_atomic(struct persistent_ram_zone *prz, size_t 
a)
 {
        int old;
        int new;
@@ -62,7 +62,7 @@ static inline size_t buffer_start_add(st
 }
 
 /* increase the size counter until it hits the max size */
-static inline void buffer_size_add(struct persistent_ram_zone *prz, size_t a)
+static void buffer_size_add_atomic(struct persistent_ram_zone *prz, size_t a)
 {
        size_t old;
        size_t new;
@@ -78,6 +78,53 @@ static inline void buffer_size_add(struc
        } while (atomic_cmpxchg(&prz->buffer->size, old, new) != old);
 }
 
+static DEFINE_RAW_SPINLOCK(buffer_lock);
+
+/* increase and wrap the start pointer, returning the old value */
+static size_t buffer_start_add_locked(struct persistent_ram_zone *prz, size_t 
a)
+{
+       int old;
+       int new;
+       unsigned long flags;
+
+       raw_spin_lock_irqsave(&buffer_lock, flags);
+
+       old = atomic_read(&prz->buffer->start);
+       new = old + a;
+       while (unlikely(new > prz->buffer_size))
+               new -= prz->buffer_size;
+       atomic_set(&prz->buffer->start, new);
+
+       raw_spin_unlock_irqrestore(&buffer_lock, flags);
+
+       return old;
+}
+
+/* increase the size counter until it hits the max size */
+static void buffer_size_add_locked(struct persistent_ram_zone *prz, size_t a)
+{
+       size_t old;
+       size_t new;
+       unsigned long flags;
+
+       raw_spin_lock_irqsave(&buffer_lock, flags);
+
+       old = atomic_read(&prz->buffer->size);
+       if (old == prz->buffer_size)
+               goto exit;
+
+       new = old + a;
+       if (new > prz->buffer_size)
+               new = prz->buffer_size;
+       atomic_set(&prz->buffer->size, new);
+
+exit:
+       raw_spin_unlock_irqrestore(&buffer_lock, flags);
+}
+
+static size_t (*buffer_start_add)(struct persistent_ram_zone *, size_t) = 
buffer_start_add_atomic;
+static void (*buffer_size_add)(struct persistent_ram_zone *, size_t) = 
buffer_size_add_atomic;
+
 static void notrace persistent_ram_encode_rs8(struct persistent_ram_zone *prz,
        uint8_t *data, size_t len, uint8_t *ecc)
 {
@@ -379,6 +426,9 @@ static void *persistent_ram_iomap(phys_a
                return NULL;
        }
 
+       buffer_start_add = buffer_start_add_locked;
+       buffer_size_add = buffer_size_add_locked;
+
        if (memtype)
                va = ioremap(start, size);
        else


Patches currently in stable-queue which might be from [email protected] 
are

queue-3.10/pstore-ram-avoid-atomic-accesses-for-ioremapped-regions.patch
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to