* [PATCH] mtd: cfi_cmdset_0002: Fix trivial merge conflict
@ 2010-04-29 0:26 Kevin Cernekee
2010-04-29 5:34 ` Artem Bityutskiy
0 siblings, 1 reply; 4+ messages in thread
From: Kevin Cernekee @ 2010-04-29 0:26 UTC (permalink / raw)
To: dwmw2, dedekind1; +Cc: linux-mtd, linux-kernel
Stefani Seibold's patch changed chip->mutex, once a spinlock, into a
mutex. This patch applies the same change to cfi_amdstd_reset(), part
of the new reboot notifier code.
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
---
drivers/mtd/chips/cfi_cmdset_0002.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index d356827..c16b8ce 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -1945,7 +1945,7 @@ static int cfi_amdstd_reset(struct mtd_info *mtd)
chip = &cfi->chips[i];
- spin_lock(chip->mutex);
+ mutex_lock(&chip->mutex);
ret = get_chip(map, chip, chip->start, FL_SHUTDOWN);
if (!ret) {
@@ -1954,7 +1954,7 @@ static int cfi_amdstd_reset(struct mtd_info *mtd)
put_chip(map, chip, chip->start);
}
- spin_unlock(chip->mutex);
+ mutex_unlock(&chip->mutex);
}
return 0;
--
1.6.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mtd: cfi_cmdset_0002: Fix trivial merge conflict
2010-04-29 0:26 [PATCH] mtd: cfi_cmdset_0002: Fix trivial merge conflict Kevin Cernekee
@ 2010-04-29 5:34 ` Artem Bityutskiy
2010-04-29 17:26 ` [PATCHv3] mtd: cfi_cmdset_0002: Add reboot notifier for AMD flashes Kevin Cernekee
0 siblings, 1 reply; 4+ messages in thread
From: Artem Bityutskiy @ 2010-04-29 5:34 UTC (permalink / raw)
To: Kevin Cernekee; +Cc: linux-mtd, dwmw2, linux-kernel
On Wed, 2010-04-28 at 17:26 -0700, Kevin Cernekee wrote:
> Stefani Seibold's patch changed chip->mutex, once a spinlock, into a
> mutex. This patch applies the same change to cfi_amdstd_reset(), part
> of the new reboot notifier code.
>
> Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
> ---
> drivers/mtd/chips/cfi_cmdset_0002.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
> index d356827..c16b8ce 100644
> --- a/drivers/mtd/chips/cfi_cmdset_0002.c
> +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
> @@ -1945,7 +1945,7 @@ static int cfi_amdstd_reset(struct mtd_info *mtd)
>
> chip = &cfi->chips[i];
>
> - spin_lock(chip->mutex);
> + mutex_lock(&chip->mutex);
>
> ret = get_chip(map, chip, chip->start, FL_SHUTDOWN);
> if (!ret) {
> @@ -1954,7 +1954,7 @@ static int cfi_amdstd_reset(struct mtd_info *mtd)
> put_chip(map, chip, chip->start);
> }
>
> - spin_unlock(chip->mutex);
> + mutex_unlock(&chip->mutex);
> }
>
> return 0;
Could you instead resend one patch which is a merge of this one and the
old one, please?
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCHv3] mtd: cfi_cmdset_0002: Add reboot notifier for AMD flashes
2010-04-29 5:34 ` Artem Bityutskiy
@ 2010-04-29 17:26 ` Kevin Cernekee
2010-05-05 5:40 ` Artem Bityutskiy
0 siblings, 1 reply; 4+ messages in thread
From: Kevin Cernekee @ 2010-04-29 17:26 UTC (permalink / raw)
To: dwmw2, dedekind1; +Cc: linux-mtd, linux-kernel
Ensure that the flash device is in a quiescent state before rebooting.
The implementation is closely modeled after the cfi_cmdset_0001 reboot
notifier, commit 963a6fb0a0d336d0513083b7e4b5c3ff9d6d2061 .
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
---
drivers/mtd/chips/cfi_cmdset_0002.c | 56 +++++++++++++++++++++++++++++++++++
1 files changed, 56 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index c93e47d..c16b8ce 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -32,6 +32,7 @@
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
+#include <linux/reboot.h>
#include <linux/mtd/compatmac.h>
#include <linux/mtd/map.h>
#include <linux/mtd/mtd.h>
@@ -56,6 +57,7 @@ static int cfi_amdstd_erase_varsize(struct mtd_info *, struct erase_info *);
static void cfi_amdstd_sync (struct mtd_info *);
static int cfi_amdstd_suspend (struct mtd_info *);
static void cfi_amdstd_resume (struct mtd_info *);
+static int cfi_amdstd_reboot(struct notifier_block *, unsigned long, void *);
static int cfi_amdstd_secsi_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
static void cfi_amdstd_destroy(struct mtd_info *);
@@ -351,6 +353,8 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
mtd->name = map->name;
mtd->writesize = 1;
+ mtd->reboot_notifier.notifier_call = cfi_amdstd_reboot;
+
if (cfi->cfi_mode==CFI_MODE_CFI){
unsigned char bootloc;
/*
@@ -487,6 +491,7 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd)
#endif
__module_get(THIS_MODULE);
+ register_reboot_notifier(&mtd->reboot_notifier);
return mtd;
setup_err:
@@ -628,6 +633,10 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
chip->state = FL_READY;
return 0;
+ case FL_SHUTDOWN:
+ /* The machine is rebooting */
+ return -EIO;
+
case FL_POINT:
/* Only if there's no operation suspended... */
if (mode == FL_READY && chip->oldstate == FL_READY)
@@ -1918,11 +1927,58 @@ static void cfi_amdstd_resume(struct mtd_info *mtd)
}
}
+
+/*
+ * Ensure that the flash device is put back into read array mode before
+ * unloading the driver or rebooting. On some systems, rebooting while
+ * the flash is in query/program/erase mode will prevent the CPU from
+ * fetching the bootloader code, requiring a hard reset or power cycle.
+ */
+static int cfi_amdstd_reset(struct mtd_info *mtd)
+{
+ struct map_info *map = mtd->priv;
+ struct cfi_private *cfi = map->fldrv_priv;
+ int i, ret;
+ struct flchip *chip;
+
+ for (i = 0; i < cfi->numchips; i++) {
+
+ chip = &cfi->chips[i];
+
+ mutex_lock(&chip->mutex);
+
+ ret = get_chip(map, chip, chip->start, FL_SHUTDOWN);
+ if (!ret) {
+ map_write(map, CMD(0xF0), chip->start);
+ chip->state = FL_SHUTDOWN;
+ put_chip(map, chip, chip->start);
+ }
+
+ mutex_unlock(&chip->mutex);
+ }
+
+ return 0;
+}
+
+
+static int cfi_amdstd_reboot(struct notifier_block *nb, unsigned long val,
+ void *v)
+{
+ struct mtd_info *mtd;
+
+ mtd = container_of(nb, struct mtd_info, reboot_notifier);
+ cfi_amdstd_reset(mtd);
+ return NOTIFY_DONE;
+}
+
+
static void cfi_amdstd_destroy(struct mtd_info *mtd)
{
struct map_info *map = mtd->priv;
struct cfi_private *cfi = map->fldrv_priv;
+ cfi_amdstd_reset(mtd);
+ unregister_reboot_notifier(&mtd->reboot_notifier);
kfree(cfi->cmdset_priv);
kfree(cfi->cfiq);
kfree(cfi);
--
1.6.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCHv3] mtd: cfi_cmdset_0002: Add reboot notifier for AMD flashes
2010-04-29 17:26 ` [PATCHv3] mtd: cfi_cmdset_0002: Add reboot notifier for AMD flashes Kevin Cernekee
@ 2010-05-05 5:40 ` Artem Bityutskiy
0 siblings, 0 replies; 4+ messages in thread
From: Artem Bityutskiy @ 2010-05-05 5:40 UTC (permalink / raw)
To: Kevin Cernekee; +Cc: linux-mtd, dwmw2, linux-kernel
On Thu, 2010-04-29 at 10:26 -0700, Kevin Cernekee wrote:
> Ensure that the flash device is in a quiescent state before rebooting.
> The implementation is closely modeled after the cfi_cmdset_0001 reboot
> notifier, commit 963a6fb0a0d336d0513083b7e4b5c3ff9d6d2061 .
>
> Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
> ---
> drivers/mtd/chips/cfi_cmdset_0002.c | 56 +++++++++++++++++++++++++++++++++++
> 1 files changed, 56 insertions(+), 0 deletions(-)
Pushed to l2-mtd-2.6 / master, thanks.
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-05-05 5:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-29 0:26 [PATCH] mtd: cfi_cmdset_0002: Fix trivial merge conflict Kevin Cernekee
2010-04-29 5:34 ` Artem Bityutskiy
2010-04-29 17:26 ` [PATCHv3] mtd: cfi_cmdset_0002: Add reboot notifier for AMD flashes Kevin Cernekee
2010-05-05 5:40 ` Artem Bityutskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).