All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2][request for stable inclusion] several pstore related bugfixs
@ 2015-01-28  8:06 HuKeping
  2015-01-28  8:06 ` [PATCH v3 1/2] pstore/ram: avoid atomic accesses for ioremapped regions HuKeping
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: HuKeping @ 2015-01-28  8:06 UTC (permalink / raw)
  To: gregkh
  Cc: linux-kernel, matt.fleming, cbouatmailru, ccross, keescook,
	tony.luck, stable, rob.herring, cxie, sdu.liu, wangnan0,
	peifeiyue

Hi greg,
We want to use pstore on linux 3.10. But we found several bugfixs have not
been merged yet. Most of them are obvious and can be cherry-picked cleanly.
Would you please apply them to stable 3.10?

v1 -> v2:
 - remove d4bf205da618bbd0b038e404d646f14e76915718 which has already been merged
 - adjust 0405a5cec3406f19e69da07c8111a6bf1088ac29

v2 -> v3:
 - attach commit to pstore/ram: avoid atomic accesses for ioremapped regions

PART 1: patches that can be cleanly applied:

 bf2883339a33b7544b92ea465b90c3de55082032
 pstore: Fail to unlink if a driver has not defined pstore_erase
 
 c39524e6744284452ef45480d3153bec28960c32
 pstore: d_alloc_name() doesn't return an ERR_PTR
 
 57fd835385a043577457a385f28c08be693991bf
 pstore: clarify clearing of _read_cnt in ramoops_context
 
 aa9a4a1edfbd3d223af01db833da2f07850bc655
 pstore: skip zero size persistent ram buffer in traverse
 
 b0aa931fb84431394d995472d0af2a6c2b61064d
 pstore: Fix NULL pointer fault if get NULL prz in ramoops_get_next_prz
 
PART 2: pathes that should be adjusted:

 Rob Herring (1):
  pstore/ram: avoid atomic accesses for ioremapped regions

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

 Madper Xie (1):
  efi-pstore: Make efi-pstore return a unique id

 drivers/firmware/efi/efi-pstore.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

-- 
1.8.5.5


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

* [PATCH v3 1/2] pstore/ram: avoid atomic accesses for ioremapped regions
  2015-01-28  8:06 [PATCH v3 0/2][request for stable inclusion] several pstore related bugfixs HuKeping
@ 2015-01-28  8:06 ` HuKeping
  2015-01-28  8:06 ` [PATCH v3 2/2] efi-pstore: Make efi-pstore return a unique id HuKeping
  2015-02-03  3:47 ` [PATCH v3 0/2][request for stable inclusion] several pstore related bugfixs Greg KH
  2 siblings, 0 replies; 4+ messages in thread
From: HuKeping @ 2015-01-28  8:06 UTC (permalink / raw)
  To: gregkh
  Cc: linux-kernel, matt.fleming, cbouatmailru, ccross, keescook,
	tony.luck, stable, rob.herring, cxie, sdu.liu, wangnan0,
	peifeiyue

From: Rob Herring <rob.herring@calxeda.com>

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 <rob.herring@calxeda.com>
Acked-by: Anton Vorontsov <anton@enomsg.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>
[hkp: Backported to 3.10: adjust context]
Signed-off-by: HuKeping <hukeping@huawei.com>

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

diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
index 6ff9755..bda61a7 100644
--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -46,7 +46,7 @@ static inline size_t buffer_start(struct persistent_ram_zone *prz)
 }
 
 /* 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(struct persistent_ram_zone *prz, size_t a)
 }
 
 /* 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(struct persistent_ram_zone *prz, size_t a)
 	} 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_addr_t start, size_t size,
 		return NULL;
 	}
 
+	buffer_start_add = buffer_start_add_locked;
+	buffer_size_add = buffer_size_add_locked;
+
 	if (memtype)
 		va = ioremap(start, size);
 	else
-- 
1.8.5.5


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

* [PATCH v3 2/2] efi-pstore: Make efi-pstore return a unique id
  2015-01-28  8:06 [PATCH v3 0/2][request for stable inclusion] several pstore related bugfixs HuKeping
  2015-01-28  8:06 ` [PATCH v3 1/2] pstore/ram: avoid atomic accesses for ioremapped regions HuKeping
@ 2015-01-28  8:06 ` HuKeping
  2015-02-03  3:47 ` [PATCH v3 0/2][request for stable inclusion] several pstore related bugfixs Greg KH
  2 siblings, 0 replies; 4+ messages in thread
From: HuKeping @ 2015-01-28  8:06 UTC (permalink / raw)
  To: gregkh
  Cc: linux-kernel, matt.fleming, cbouatmailru, ccross, keescook,
	tony.luck, stable, rob.herring, cxie, sdu.liu, wangnan0,
	peifeiyue

From: Madper Xie <cxie@redhat.com>

Commit fdeadb43fdf1e7d5698c027b555c389174548e5a upstream.

Pstore fs expects that backends provide a unique id which could avoid
pstore making entries as duplication or denominating entries the same
name. So I combine the timestamp, part and count into id.

Signed-off-by: Madper Xie <cxie@redhat.com>
Cc: Seiji Aguchi <seiji.aguchi@hds.com>
Cc: stable@vger.kernel.org
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
[hkp: Backported to 3.10: adjust context]
Signed-off-by: Hu Keping <hukeping@huawei.com>

---
 drivers/firmware/efi/efi-pstore.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
index 66c0c76..c5163e3 100644
--- a/drivers/firmware/efi/efi-pstore.c
+++ b/drivers/firmware/efi/efi-pstore.c
@@ -38,6 +38,12 @@ struct pstore_read_data {
 	char **buf;
 };
 
+static inline u64 generic_id(unsigned long timestamp,
+			     unsigned int part, int count)
+{
+	return (timestamp * 100 + part) * 1000 + count;
+}
+
 static int efi_pstore_read_func(struct efivar_entry *entry, void *data)
 {
 	efi_guid_t vendor = LINUX_EFI_CRASH_GUID;
@@ -56,7 +62,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data)
 
 	if (sscanf(name, "dump-type%u-%u-%d-%lu",
 		   cb_data->type, &part, &cnt, &time) == 4) {
-		*cb_data->id = part;
+		*cb_data->id = generic_id(time, part, cnt);
 		*cb_data->count = cnt;
 		cb_data->timespec->tv_sec = time;
 		cb_data->timespec->tv_nsec = 0;
@@ -67,7 +73,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data)
 		 * which doesn't support holding
 		 * multiple logs, remains.
 		 */
-		*cb_data->id = part;
+		*cb_data->id = generic_id(time, part, 0);
 		*cb_data->count = 0;
 		cb_data->timespec->tv_sec = time;
 		cb_data->timespec->tv_nsec = 0;
@@ -185,14 +191,16 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count,
 	char name[DUMP_NAME_LEN];
 	efi_char16_t efi_name[DUMP_NAME_LEN];
 	int found, i;
+	unsigned int part;
 
-	sprintf(name, "dump-type%u-%u-%d-%lu", type, (unsigned int)id, count,
-		time.tv_sec);
+	do_div(id, 1000);
+	part = do_div(id, 100);
+	sprintf(name, "dump-type%u-%u-%d-%lu", type, part, count, time.tv_sec);
 
 	for (i = 0; i < DUMP_NAME_LEN; i++)
 		efi_name[i] = name[i];
 
-	edata.id = id;
+	edata.id = part;
 	edata.type = type;
 	edata.count = count;
 	edata.time = time;
-- 
1.8.5.5


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

* Re: [PATCH v3 0/2][request for stable inclusion] several pstore related bugfixs
  2015-01-28  8:06 [PATCH v3 0/2][request for stable inclusion] several pstore related bugfixs HuKeping
  2015-01-28  8:06 ` [PATCH v3 1/2] pstore/ram: avoid atomic accesses for ioremapped regions HuKeping
  2015-01-28  8:06 ` [PATCH v3 2/2] efi-pstore: Make efi-pstore return a unique id HuKeping
@ 2015-02-03  3:47 ` Greg KH
  2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2015-02-03  3:47 UTC (permalink / raw)
  To: HuKeping
  Cc: linux-kernel, matt.fleming, cbouatmailru, ccross, keescook,
	tony.luck, stable, rob.herring, cxie, sdu.liu, wangnan0,
	peifeiyue

On Wed, Jan 28, 2015 at 04:06:24PM +0800, HuKeping wrote:
> Hi greg,
> We want to use pstore on linux 3.10. But we found several bugfixs have not
> been merged yet. Most of them are obvious and can be cherry-picked cleanly.
> Would you please apply them to stable 3.10?
> 
> v1 -> v2:
>  - remove d4bf205da618bbd0b038e404d646f14e76915718 which has already been merged
>  - adjust 0405a5cec3406f19e69da07c8111a6bf1088ac29
> 
> v2 -> v3:
>  - attach commit to pstore/ram: avoid atomic accesses for ioremapped regions
> 
> PART 1: patches that can be cleanly applied:
> 
>  bf2883339a33b7544b92ea465b90c3de55082032
>  pstore: Fail to unlink if a driver has not defined pstore_erase
>  
>  c39524e6744284452ef45480d3153bec28960c32
>  pstore: d_alloc_name() doesn't return an ERR_PTR
>  
>  57fd835385a043577457a385f28c08be693991bf
>  pstore: clarify clearing of _read_cnt in ramoops_context
>  
>  aa9a4a1edfbd3d223af01db833da2f07850bc655
>  pstore: skip zero size persistent ram buffer in traverse
>  
>  b0aa931fb84431394d995472d0af2a6c2b61064d
>  pstore: Fix NULL pointer fault if get NULL prz in ramoops_get_next_prz
>  
> PART 2: pathes that should be adjusted:
> 
>  Rob Herring (1):
>   pstore/ram: avoid atomic accesses for ioremapped regions
> 
>  fs/pstore/ram_core.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 52 insertions(+), 2 deletions(-)
> 
>  Madper Xie (1):
>   efi-pstore: Make efi-pstore return a unique id
> 
>  drivers/firmware/efi/efi-pstore.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)

All now applied, along with some of these for 3.14, thanks.

greg k-h

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

end of thread, other threads:[~2015-02-03  3:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-28  8:06 [PATCH v3 0/2][request for stable inclusion] several pstore related bugfixs HuKeping
2015-01-28  8:06 ` [PATCH v3 1/2] pstore/ram: avoid atomic accesses for ioremapped regions HuKeping
2015-01-28  8:06 ` [PATCH v3 2/2] efi-pstore: Make efi-pstore return a unique id HuKeping
2015-02-03  3:47 ` [PATCH v3 0/2][request for stable inclusion] several pstore related bugfixs Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.