pstore, mmc: add mmc as backend for pstore
Subsystems (7)
PATCH 1/26 pstore: allow for big files
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
pstore reads all files into memory at mount time. To allow for back ends that will store arbitrarily large files, enhance pstore also to be able to read from the back end as needed.
--- drivers/acpi/apei/erst.c | 16 +++++++++------- fs/pstore/inode.c | 26 ++++++++++++++++++++------ fs/pstore/internal.h | 5 +++-- fs/pstore/platform.c | 11 +++++++---- fs/pstore/ram.c | 15 +++++++-------- include/linux/pstore.h | 7 +++++-- 6 files changed, 51 insertions(+), 29 deletions(-)
drivers/acpi/apei/erst.c +9 -7
@@ -931,9 +931,9 @@ static int erst_check_table(struct acpi_table_erst *erst_tab)static int erst_open_pstore (struct pstore_info *psi);static int erst_close_pstore (struct pstore_info *psi); -static ssize_t erst_reader (u64 *id,enum pstore_type_id *type, -struct timespec *time,char **buf, -struct pstore_info *psi); +static int erst_reader (u64 *id,enum pstore_type_id *type, +struct timespec *time,char **buf,loff_t *size, +struct pstore_info *psi);static int erst_writer (enum pstore_type_id type,enum kmsg_dump_reason reason,u64 *id,unsigned int part,size_t size,struct pstore_info *psi);
@@ -987,9 +987,9 @@ static int erst_close_pstore(struct pstore_info *psi)return 0 ; } -static ssize_t erst_reader (u64 *id,enum pstore_type_id *type, -struct timespec *time,char **buf, -struct pstore_info *psi) +static int erst_reader (u64 *id,enum pstore_type_id *type, +struct timespec *time,char **buf,loff_t *size, +struct pstore_info *psi) {int rc;ssize_t len =0 ;
@@ -1051,7 +1051,9 @@ skip: out:kfree (rcd); -return (rc <0 ) ? rc : (len -sizeof (*rcd)); +if (!rc) + *size = len -sizeof (*rcd); +return rc; } static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason,
fs/pstore/inode.c +20 -6
@@ -49,7 +49,8 @@ struct pstore_private {struct pstore_info *psi;enum pstore_type_id type;u64 id; -ssize_t size; +loff_t size; +bool big;char data[]; };
@@ -65,12 +66,13 @@ static void *pstore_ftrace_seq_start(struct seq_file *s, loff_t *pos) {struct pstore_private *ps = s->private;struct pstore_ftrace_seq_data *data; +loff_t size = ps->size; data =kzalloc (sizeof (*data),GFP_KERNEL );if (!data)return NULL ; - data->off = ps->size %REC_SIZE ; + data->off =do_div (size,REC_SIZE ); data->off += *pos *REC_SIZE ;if (data->off +REC_SIZE > ps->size) {kfree (data);
@@ -127,6 +129,12 @@ static ssize_t pstore_file_read(struct file *file, char __user *userbuf,if (ps->type ==PSTORE_TYPE_FTRACE )return seq_read (file, userbuf, count, ppos); +if (ps->big) { +if (ps->psi->file_read) +return ps->psi->file_read (ps->id, ps->type, userbuf, + count, ppos, ps->psi); +return -EFBIG ; + }return simple_read_from_buffer (userbuf, count, ppos, ps->data, ps->size); }
@@ -271,8 +279,8 @@ int pstore_is_mounted(void)* Set the mtime & ctime to the date that this record was originally stored. */ int pstore_mkfile (enum pstore_type_id type,char *psname,u64 id, -char *data,size_t size,struct timespec time, -struct pstore_info *psi) +char *data,loff_t size,struct timespec time, +struct pstore_info *psi,bool big) {struct dentry *root = pstore_sb->s_root;struct dentry *dentry;
@@ -281,6 +289,7 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id,char name[PSTORE_NAMELEN ];struct pstore_private *private, *pos;unsigned long flags; +size_t inline_size;spin_lock_irqsave (&allpstore_lock, flags);list_for_each_entry (pos, &allpstore, list) {
@@ -301,12 +310,17 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, goto fail; inode->i_mode =S_IFREG |0444 ; inode->i_fop = &pstore_file_operations; - private =kmalloc (sizeof *private + size,GFP_KERNEL ); +if (big) + inline_size =0 ; +else + inline_size = size; + private =kmalloc (sizeof (*private) + inline_size,GFP_KERNEL );if (!private) goto fail_alloc; private->type = type; private->id = id; private->psi = psi; + private->big = big;switch (type) {case PSTORE_TYPE_DMESG :
@@ -336,7 +350,7 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id,if (IS_ERR (dentry)) goto fail_lockedalloc; -memcpy (private->data, data, size); +memcpy (private->data, data, inline_size); inode->i_size = private->size = size; inode->i_private = private;
fs/pstore/internal.h +3 -2
@@ -50,8 +50,9 @@ extern struct pstore_info *psinfo;extern void pstore_set_kmsg_bytes (int );extern void pstore_get_records (int );extern int pstore_mkfile (enum pstore_type_id ,char *psname,u64 id, -char *data,size_t size, -struct timespec time,struct pstore_info *psi); +char *data,loff_t size, +struct timespec time,struct pstore_info *psi, +bool big);extern int pstore_is_mounted (void );#endif
fs/pstore/platform.c +7 -4
@@ -264,7 +264,7 @@ void pstore_get_records(int quiet) {struct pstore_info *psi = psinfo;char *buf =NULL ; -ssize_t size; +loff_t size;u64 id;enum pstore_type_id type;struct timespec time;
@@ -277,9 +277,12 @@ void pstore_get_records(int quiet)if (psi->open && psi->open (psi)) goto out; -while ((size = psi->read (&id, &type, &time, &buf, psi)) >0 ) { - rc =pstore_mkfile (type, psi->name, id, buf, (size_t )size, - time, psi); +while (1 ) { + rc = psi->read (&id, &type, &time, &buf, &size, psi); +if (rc && rc != -EFBIG ) +break ; + rc =pstore_mkfile (type, psi->name, id, buf, size, + time, psi, rc == -EFBIG );kfree (buf); buf =NULL ;if (rc && (rc != -EEXIST || !quiet))
fs/pstore/ram.c +7 -8
@@ -131,12 +131,11 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max,return prz; } -static ssize_t ramoops_pstore_read (u64 *id,enum pstore_type_id *type, +static int ramoops_pstore_read (u64 *id,enum pstore_type_id *type,struct timespec *time, -char **buf, +char **buf,loff_t *size,struct pstore_info *psi) { -ssize_t size;struct ramoops_context *cxt = psi->data;struct persistent_ram_zone *prz;
@@ -150,19 +149,19 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type, prz =ramoops_get_next_prz (&cxt->fprz, &cxt->ftrace_read_cnt,1 , id, type,PSTORE_TYPE_FTRACE ,0 );if (!prz) -return 0 ; +return -EINVAL ;/* TODO(kees): Bogus time for the moment. */ time->tv_sec =0 ; time->tv_nsec =0 ; - size =persistent_ram_old_size (prz); - *buf =kmalloc (size,GFP_KERNEL ); + *size =persistent_ram_old_size (prz); + *buf =kmalloc (*size,GFP_KERNEL );if (*buf ==NULL )return -ENOMEM ; -memcpy (*buf,persistent_ram_old (prz), size); +memcpy (*buf,persistent_ram_old (prz), *size); -return size; +return 0 ; }static size_t ramoops_write_kmsg_hdr (struct persistent_ram_zone *prz)
include/linux/pstore.h +5 -2
@@ -49,8 +49,11 @@ struct pstore_info {struct mutex read_mutex;/* serialize open/read/close */ int (*open)(struct pstore_info *psi);int (*close)(struct pstore_info *psi); -ssize_t (*read)(u64 *id,enum pstore_type_id *type, -struct timespec *time,char **buf, +int (*read)(u64 *id,enum pstore_type_id *type, +struct timespec *time,char **buf,loff_t *size, +struct pstore_info *psi); +ssize_t (*file_read)(u64 id,enum pstore_type_id type, +char __user *userbuf,size_t count,loff_t *ppos,struct pstore_info *psi); int (*write)(enum pstore_type_id type, enum kmsg_dump_reason reason, u64 *id,
Signature · 1 line
1.7.9.5
PATCH 2/26 pstore: add flags
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
Let the back end tweak pstore behaviour. Flags added are:
PSTORE_NO_HEADINGS
Omit pstore heading lines from dumped data
PSTORE_MAX_KMSG_BYTES
Default kmsg_bytes to ULONG_MAX
--- fs/pstore/platform.c | 9 ++++++++- include/linux/pstore.h | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-)
fs/pstore/platform.c +8 -1
@@ -128,7 +128,11 @@ static void pstore_dump(struct kmsg_dumper *dumper,size_t len; dst = psinfo->buf; - hsize =sprintf (dst,"%s#%d Part%d\n" , why, oopscount, part); +if (psinfo->flags &PSTORE_NO_HEADINGS ) + hsize =0 ; +else + hsize =sprintf (dst,"%s#%d Part%d\n" , why, oopscount, + part); size = psinfo->bufsize - hsize; dst += hsize;
@@ -237,6 +241,9 @@ int pstore_register(struct pstore_info *psi)return -EINVAL ; } +if (psinfo->flags &PSTORE_MAX_KMSG_BYTES ) + kmsg_bytes =ULONG_MAX ; +if (pstore_is_mounted ())pstore_get_records (0 );
include/linux/pstore.h +4 -0
@@ -40,9 +40,13 @@ enum pstore_type_id {struct module ; +#define PSTORE_NO_HEADINGS BIT(0) +#define PSTORE_MAX_KMSG_BYTES BIT(1) +struct pstore_info {struct module *owner;char *name; +unsigned int flags;spinlock_t buf_lock;/* serialize access to 'buf' */ char *buf;size_t bufsize;
Signature · 1 line
1.7.9.5
PATCH 5/26 block: add panic write
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
Add a small interface to allow block devices to attempt to write during an oops or panic.
--- drivers/block/Kconfig | 3 ++ include/linux/blkdev.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/genhd.h | 3 ++ 3 files changed, 83 insertions(+)
drivers/block/Kconfig +3 -0
@@ -553,4 +553,7 @@ config BLK_DEV_OOPS See <file:Documentation/blockdev/blkoops.txt> for more information. +config BLK_DEV_PANIC_WRITE + bool + endif # BLK_DEV
include/linux/blkdev.h +77 -0
83 lines not on this page · raw message
include/linux/genhd.h +3 -0
@@ -195,6 +195,9 @@ struct gendisk {#ifdef CONFIG_BLK_DEV_INTEGRITY struct blk_integrity *integrity;#endif +#ifdef CONFIG_BLK_DEV_PANIC_WRITE +const struct panic_write_operations *pwops; +#endif int node_id; };
Signature · 1 line
1.7.9.5
PATCH 6/26 mmc: block: add panic write support
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/card/Kconfig | 11 ++ drivers/mmc/card/block.c | 257 +++++++++++++++++++++++++++++++++++++++++++++- include/linux/mmc/host.h | 92 +++++++++++++++++ 3 files changed, 359 insertions(+), 1 deletion(-)
drivers/mmc/card/Kconfig +11 -0
@@ -50,6 +50,17 @@ config MMC_BLOCK_BOUNCE If unsure, say Y here. +config MMC_BLOCK_PANIC_WRITE + bool "Panic write support" + depends on MMC_BLOCK + select BLK_DEV_PANIC_WRITE + default n + help + Say Y here to support panic write. Panic write enables upper + layers to write to MMC/SD cards during an oops or panic. + However a host controller driver that supports panic writes + is also needed. + config SDIO_UART tristate "SDIO UART/GPS class support" help
drivers/mmc/card/block.c +256 -1
281 lines not on this page · raw message
include/linux/mmc/host.h +92 -0
120 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 7/26 mmc: panic write: bypass host claiming
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/core/core.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/mmc/core/core.c +9 -0
@@ -767,6 +767,9 @@ int __mmc_claim_host(struct mmc_host *host, atomic_t *abort)unsigned long flags;int stop; +if (mmc_am_panic_task (host)) +return 0 ; +might_sleep ();add_wait_queue (&host->wq, &wait);
@@ -807,6 +810,9 @@ int mmc_try_claim_host(struct mmc_host *host)int claimed_host =0 ;unsigned long flags; +if (mmc_am_panic_task (host)) +return 1 ; +spin_lock_irqsave (&host->lock, flags);if (!host->claimed || host->claimer == current) { host->claimed =1 ;
@@ -837,6 +843,9 @@ void mmc_release_host(struct mmc_host *host)if (host->ops->disable && host->claim_cnt ==1 ) host->ops->disable (host); +if (mmc_am_panic_task (host)) +return ; +spin_lock_irqsave (&host->lock, flags);if (--host->claim_cnt) {/* Release for nested claim */
Signature · 1 line
1.7.9.5
PATCH 11/26 mmc: panic write: bypass clock gating
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/core/core.c | 5 +++++ drivers/mmc/core/host.c | 9 +++++++++ 2 files changed, 14 insertions(+)
drivers/mmc/core/core.c +5 -0
@@ -956,6 +956,11 @@ void mmc_set_ungated(struct mmc_host *host) {unsigned long flags; +if (mmc_am_panic_task (host)) { + host->clk_gated = false; +return ; + } +/* * We've been given a new frequency while the clock is gated, * so make sure we regard this as ungating it.
drivers/mmc/core/host.c +9 -0
@@ -153,6 +153,12 @@ void mmc_host_clk_hold(struct mmc_host *host) {unsigned long flags; +if (mmc_am_panic_task (host)) { +if (host->clk_gated) +mmc_ungate_clock (host); +return ; + } +/* cancel any clock gating work scheduled by mmc_host_clk_release() */ cancel_delayed_work_sync (&host->clk_gate_work);mutex_lock (&host->clk_gate_mutex);
@@ -200,6 +206,9 @@ void mmc_host_clk_release(struct mmc_host *host) {unsigned long flags; +if (mmc_am_panic_task (host)) +return ; +spin_lock_irqsave (&host->clk_lock, flags); host->clk_requests--; if (mmc_host_may_gate_card(host->card) &&
Signature · 1 line
1.7.9.5
PATCH 12/26 mmc: panic write: bypass regulators
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/core/core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mmc/core/core.c +3 -0
@@ -1128,6 +1128,9 @@ int mmc_regulator_set_ocr(struct mmc_host *mmc,int result =0 ;int min_uV, max_uV; +if (mmc_am_panic_task (mmc)) +return 0 ; +if (vdd_bit) {int tmp;int voltage;
Signature · 1 line
1.7.9.5
PATCH 10/26 mmc: panic write: do not msleep
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/core/core.c | 6 +++--- drivers/mmc/core/core.h | 6 ++++-- drivers/mmc/core/mmc_ops.c | 10 +++++----- drivers/mmc/core/sd_ops.c | 2 +- drivers/mmc/core/sdio_ops.c | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-)
drivers/mmc/core/core.c +3 -3
@@ -1331,7 +1331,7 @@ static void mmc_power_up(struct mmc_host *host)* This delay should be sufficient to allow the power supply * to reach the minimum voltage. */ -mmc_delay (10 ); +mmc_delay (host,10 ); host->ios.clock = host->f_init;
@@ -1342,7 +1342,7 @@ static void mmc_power_up(struct mmc_host *host)* This delay must be at least 74 clock sizes, or 1 ms, or the * time required to reach a stable voltage. */ -mmc_delay (10 ); +mmc_delay (host,10 );mmc_host_clk_release (host); }
@@ -1378,7 +1378,7 @@ void mmc_power_off(struct mmc_host *host)* XO-1.5, require a short delay after poweroff before the card * can be successfully turned on again. */ -mmc_delay (1 ); +mmc_delay (host,1 );mmc_host_clk_release (host); }
drivers/mmc/core/core.h +4 -2
@@ -46,9 +46,11 @@ void mmc_set_timing(struct mmc_host *host, unsigned int timing);void mmc_set_driver_type (struct mmc_host *host,unsigned int drv_type);void mmc_power_off (struct mmc_host *host); -static inline void mmc_delay (unsigned int ms) +static inline void mmc_delay (struct mmc_host *host,unsigned int ms) { -if (ms <1000 /HZ ) { +if (mmc_am_panic_task (host)) { +mdelay (ms); + }else if (ms <1000 /HZ ) {cond_resched ();mdelay (ms); }else {
drivers/mmc/core/mmc_ops.c +5 -5
@@ -83,7 +83,7 @@ int mmc_card_sleepawake(struct mmc_host *host, int sleep)* others) is invalid while the card sleeps. */ if (!(host->caps &MMC_CAP_WAIT_WHILE_BUSY )) -mmc_delay (DIV_ROUND_UP (card->ext_csd.sa_timeout,10000 )); +mmc_delay (host,DIV_ROUND_UP (card->ext_csd.sa_timeout,10000 ));if (!sleep) err =mmc_select_card (card);
@@ -107,7 +107,7 @@ int mmc_go_idle(struct mmc_host *host)*/ if (!mmc_host_is_spi (host)) {mmc_set_chip_select (host,MMC_CS_HIGH ); -mmc_delay (1 ); +mmc_delay (host,1 ); } cmd.opcode =MMC_GO_IDLE_STATE ;
@@ -116,11 +116,11 @@ int mmc_go_idle(struct mmc_host *host) err =mmc_wait_for_cmd (host, &cmd,0 ); -mmc_delay (1 ); +mmc_delay (host,1 );if (!mmc_host_is_spi (host)) {mmc_set_chip_select (host,MMC_CS_DONTCARE ); -mmc_delay (1 ); +mmc_delay (host,1 ); } host->use_spi_crc =0 ;
@@ -159,7 +159,7 @@ int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) err = -ETIMEDOUT ; -mmc_delay (10 ); +mmc_delay (host,10 ); }if (rocr && !mmc_host_is_spi (host))
drivers/mmc/core/sd_ops.c +1 -1
@@ -181,7 +181,7 @@ int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) err = -ETIMEDOUT ; -mmc_delay (10 ); +mmc_delay (host,10 ); }if (rocr && !mmc_host_is_spi (host))
drivers/mmc/core/sdio_ops.c +1 -1
@@ -56,7 +56,7 @@ int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) err = -ETIMEDOUT ; -mmc_delay (10 ); +mmc_delay (host,10 ); }if (rocr)
Signature · 1 line
1.7.9.5
PATCH 15/26 mmc: sdhci: panic write: bypass spin lock
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/host/sdhci.c | 119 ++++++++++++++++++++++++++++++---------------- drivers/mmc/host/sdhci.h | 24 ++++++++++ 2 files changed, 101 insertions(+), 42 deletions(-)
drivers/mmc/host/sdhci.c +77 -42
@@ -287,7 +287,7 @@ static void sdhci_led_control(struct led_classdev *led, struct sdhci_host *host = container_of(led, struct sdhci_host, led);unsigned long flags; -spin_lock_irqsave (&host->lock, flags); +sdhci_lock_irqsave (host, flags);if (host->runtime_suspended) goto out;
@@ -297,7 +297,7 @@ static void sdhci_led_control(struct led_classdev *led, elsesdhci_activate_led (host ); out: - spin_unlock_irqrestore(&host->lock, flags); + sdhci_unlock_irqrestore(host, flags); }#endif
@@ -1266,7 +1266,7 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)sdhci_runtime_pm_get (host); -spin_lock_irqsave (&host->lock, flags); +sdhci_lock_irqsave (host, flags);WARN_ON (host->mrq !=NULL );
@@ -1319,9 +1319,9 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) tuning_opcode = mmc->card->type ==MMC_TYPE_MMC ?MMC_SEND_TUNING_BLOCK_HS200 :MMC_SEND_TUNING_BLOCK ; -spin_unlock_irqrestore (&host->lock, flags); +sdhci_unlock_irqrestore (host, flags);sdhci_execute_tuning (mmc, tuning_opcode); -spin_lock_irqsave (&host->lock, flags); +sdhci_lock_irqsave (host, flags);/* Restore original mmc_request structure */ host->mrq = mrq;
@@ -1334,7 +1334,7 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) }mmiowb (); -spin_unlock_irqrestore (&host->lock, flags); +sdhci_unlock_irqrestore (host, flags); }static void sdhci_do_set_ios (struct sdhci_host *host,struct mmc_ios *ios)
@@ -1343,10 +1343,10 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios)int vdd_bit =-1 ;u8 ctrl; -spin_lock_irqsave (&host->lock, flags); +sdhci_lock_irqsave (host, flags);if (host->flags &SDHCI_DEVICE_DEAD ) { -spin_unlock_irqrestore (&host->lock, flags); +sdhci_unlock_irqrestore (host, flags);if (host->vmmc && ios->power_mode ==MMC_POWER_OFF )mmc_regulator_set_ocr (host->mmc, host->vmmc,0 );return ;
@@ -1369,9 +1369,9 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) vdd_bit =sdhci_set_power (host, ios->vdd);if (host->vmmc && vdd_bit !=-1 ) { -spin_unlock_irqrestore (&host->lock, flags); +sdhci_unlock_irqrestore (host, flags);mmc_regulator_set_ocr (host->mmc, host->vmmc, vdd_bit); -spin_lock_irqsave (&host->lock, flags); +sdhci_lock_irqsave (host, flags); }if (host->ops->platform_send_init_74_clocks)
@@ -1500,7 +1500,7 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios)sdhci_reset (host,SDHCI_RESET_CMD |SDHCI_RESET_DATA );mmiowb (); -spin_unlock_irqrestore (&host->lock, flags); +sdhci_unlock_irqrestore (host, flags); }static void sdhci_set_ios (struct mmc_host *mmc,struct mmc_ios *ios)
@@ -1517,7 +1517,7 @@ static int sdhci_check_ro(struct sdhci_host *host)unsigned long flags;int is_readonly; -spin_lock_irqsave (&host->lock, flags); +sdhci_lock_irqsave (host, flags);if (host->flags &SDHCI_DEVICE_DEAD ) is_readonly =0 ;
@@ -1527,7 +1527,7 @@ static int sdhci_check_ro(struct sdhci_host *host) is_readonly = !(sdhci_readl (host,SDHCI_PRESENT_STATE ) &SDHCI_WRITE_PROTECT ); -spin_unlock_irqrestore (&host->lock, flags); +sdhci_unlock_irqrestore (host, flags);/* This quirk needs to be replaced by a callback-function later */ return host->quirks & SDHCI_QUIRK_INVERTED_WRITE_PROTECT ?
@@ -1600,9 +1600,9 @@ static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable)struct sdhci_host *host =mmc_priv (mmc);unsigned long flags; -spin_lock_irqsave (&host->lock, flags); +sdhci_lock_irqsave (host, flags);sdhci_enable_sdio_irq_nolock (host, enable); -spin_unlock_irqrestore (&host->lock, flags); +sdhci_unlock_irqrestore (host, flags); } static int sdhci_do_3_3v_signal_voltage_switch(struct sdhci_host *host,
@@ -1770,7 +1770,7 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)sdhci_runtime_pm_get (host);disable_irq (host->irq); -spin_lock (&host->lock); +sdhci_lock (host); ctrl =sdhci_readw (host,SDHCI_HOST_CONTROL2 );
@@ -1790,7 +1790,7 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) requires_tuning_nonuhs) ctrl |= SDHCI_CTRL_EXEC_TUNING; else { -spin_unlock (&host->lock); +sdhci_unlock (host);enable_irq (host->irq);sdhci_runtime_pm_put (host);return 0 ;
@@ -1863,7 +1863,7 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) host->cmd =NULL ; host->mrq =NULL ; -spin_unlock (&host->lock); +sdhci_unlock (host);enable_irq (host->irq);/* Wait for Buffer Read Ready interrupt */
@@ -1871,7 +1871,7 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) (host->tuning_done ==1 ), msecs_to_jiffies(50));disable_irq (host->irq); -spin_lock (&host->lock); +sdhci_lock (host);if (!host->tuning_done) { pr_info(DRIVER_NAME ": Timeout waiting for "
@@ -1945,7 +1945,7 @@ out: err =0 ;sdhci_clear_set_irqs (host,SDHCI_INT_DATA_AVAIL , ier); -spin_unlock (&host->lock); +sdhci_unlock (host);enable_irq (host->irq);sdhci_runtime_pm_put (host);
@@ -1961,7 +1961,7 @@ static void sdhci_do_enable_preset_value(struct sdhci_host *host, bool enable)if (host->version <SDHCI_SPEC_300 )return ; -spin_lock_irqsave (&host->lock, flags); +sdhci_lock_irqsave (host, flags); ctrl =sdhci_readw (host,SDHCI_HOST_CONTROL2 );
@@ -1979,7 +1979,7 @@ static void sdhci_do_enable_preset_value(struct sdhci_host *host, bool enable) host->flags &= ~SDHCI_PV_ENABLED ; } -spin_unlock_irqrestore (&host->lock, flags); +sdhci_unlock_irqrestore (host, flags); }static void sdhci_enable_preset_value (struct mmc_host *mmc,bool enable)
@@ -2002,6 +2002,40 @@ static const struct mmc_host_ops sdhci_ops = { .enable_preset_value = sdhci_enable_preset_value, }; +#ifdef CONFIG_MMC_BLOCK_PANIC_WRITE + +void sdhci_lock (struct sdhci_host *host) +{ +if (mmc_am_panic_task (host->mmc)) +return ; +spin_lock (&host->lock); +} + +void sdhci_unlock (struct sdhci_host *host) +{ +if (!mmc_am_panic_task (host->mmc)) +spin_unlock (&host->lock); +} + +void _sdhci_lock_irqsave (struct sdhci_host *host,unsigned long *flags_ptr) +{ +unsigned long flags; + +if (mmc_am_panic_task (host->mmc)) +return ; + +spin_lock_irqsave (&host->lock, flags); + *flags_ptr = flags; +} + +void sdhci_unlock_irqrestore (struct sdhci_host *host,unsigned long flags) +{ +if (!mmc_am_panic_task (host->mmc)) +spin_unlock_irqrestore (&host->lock, flags); +} + +#endif +/*****************************************************************************\ * * * Tasklets *
@@ -2015,7 +2049,7 @@ static void sdhci_tasklet_card(unsigned long param) host = (struct sdhci_host *)param; -spin_lock_irqsave (&host->lock, flags); +sdhci_lock_irqsave (host, flags);/* Check host->mrq first in case we are runtime suspended */ if (host->mrq &&
@@ -2032,7 +2066,7 @@ static void sdhci_tasklet_card(unsigned long param)tasklet_schedule (&host->finish_tasklet); } -spin_unlock_irqrestore (&host->lock, flags); +sdhci_unlock_irqrestore (host, flags);mmc_detect_change (host->mmc,msecs_to_jiffies (200 )); }
@@ -2045,14 +2079,14 @@ static void sdhci_tasklet_finish(unsigned long param) host = (struct sdhci_host *)param; -spin_lock_irqsave (&host->lock, flags); +sdhci_lock_irqsave (host, flags);/* * If this tasklet gets rescheduled while running, it will * be run again afterwards but without any active request. */ if (!host->mrq) { -spin_unlock_irqrestore (&host->lock, flags); +sdhci_unlock_irqrestore (host, flags);return ; }
@@ -2095,7 +2129,7 @@ static void sdhci_tasklet_finish(unsigned long param)#endif mmiowb (); -spin_unlock_irqrestore (&host->lock, flags); +sdhci_unlock_irqrestore (host, flags);mmc_request_done (host->mmc, mrq);sdhci_runtime_pm_put (host);
@@ -2108,7 +2142,7 @@ static void sdhci_timeout_timer(unsigned long data) host = (struct sdhci_host *)data; -spin_lock_irqsave (&host->lock, flags); +sdhci_lock_irqsave (host, flags);if (host->mrq) { pr_err("%s: Timeout waiting for hardware "
@@ -2129,7 +2163,7 @@ static void sdhci_timeout_timer(unsigned long data) }mmiowb (); -spin_unlock_irqrestore (&host->lock, flags); +sdhci_unlock_irqrestore (host, flags); }static void sdhci_tuning_timer (unsigned long data)
@@ -2139,11 +2173,11 @@ static void sdhci_tuning_timer(unsigned long data) host = (struct sdhci_host *)data; -spin_lock_irqsave (&host->lock, flags); +sdhci_lock_irqsave (host, flags); host->flags |=SDHCI_NEEDS_RETUNING ; -spin_unlock_irqrestore (&host->lock, flags); +sdhci_unlock_irqrestore (host, flags); }/*****************************************************************************\
@@ -2336,10 +2370,11 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)u32 intmask, unexpected =0 ;int cardint =0 , max_loops =16 ; -spin_lock (&host->lock); +sdhci_lock (host); +if (host->runtime_suspended) { -spin_unlock (&host->lock); +sdhci_unlock (host);pr_warning ("%s: got irq while runtime suspended\n" ,mmc_hostname (host->mmc));return IRQ_HANDLED ;
@@ -2421,7 +2456,7 @@ again:if (intmask && --max_loops) goto again; out: -spin_unlock (&host->lock); +sdhci_unlock (host);if (unexpected) { pr_err("%s: Unexpected interrupt 0x%08x.\n",
@@ -2557,15 +2592,15 @@ int sdhci_runtime_suspend_host(struct sdhci_host *host) host->flags &= ~SDHCI_NEEDS_RETUNING ; } -spin_lock_irqsave (&host->lock, flags); +sdhci_lock_irqsave (host, flags);sdhci_mask_irqs (host,SDHCI_INT_ALL_MASK ); -spin_unlock_irqrestore (&host->lock, flags); +sdhci_unlock_irqrestore (host, flags);synchronize_irq (host->irq); -spin_lock_irqsave (&host->lock, flags); +sdhci_lock_irqsave (host, flags); host->runtime_suspended = true; -spin_unlock_irqrestore (&host->lock, flags); +sdhci_unlock_irqrestore (host, flags);return ret; }
@@ -2596,7 +2631,7 @@ int sdhci_runtime_resume_host(struct sdhci_host *host)if (host->flags &SDHCI_USING_RETUNING_TIMER ) host->flags |=SDHCI_NEEDS_RETUNING ; -spin_lock_irqsave (&host->lock, flags); +sdhci_lock_irqsave (host, flags); host->runtime_suspended = false;
@@ -2607,7 +2642,7 @@ int sdhci_runtime_resume_host(struct sdhci_host *host)/* Enable Card Detection */ sdhci_enable_card_detection (host); -spin_unlock_irqrestore (&host->lock, flags); +sdhci_unlock_irqrestore (host, flags);return ret; }
@@ -3132,7 +3167,7 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)unsigned long flags;if (dead) { -spin_lock_irqsave (&host->lock, flags); +sdhci_lock_irqsave (host, flags); host->flags |=SDHCI_DEVICE_DEAD ;
@@ -3144,7 +3179,7 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)tasklet_schedule (&host->finish_tasklet); } -spin_unlock_irqrestore (&host->lock, flags); +sdhci_unlock_irqrestore (host, flags); }sdhci_disable_card_detection (host);
drivers/mmc/host/sdhci.h +24 -0
@@ -388,4 +388,28 @@ extern int sdhci_runtime_suspend_host(struct sdhci_host *host);extern int sdhci_runtime_resume_host (struct sdhci_host *host);#endif +#ifdef CONFIG_MMC_BLOCK_PANIC_WRITE + +extern void sdhci_lock (struct sdhci_host *host); +extern void sdhci_unlock (struct sdhci_host *host); + +extern void _sdhci_lock_irqsave (struct sdhci_host *host, +unsigned long *flags_ptr); +extern void sdhci_unlock_irqrestore (struct sdhci_host *host, +unsigned long flags); + +#define sdhci_lock_irqsave (host, flags) _sdhci_lock_irqsave(host, &(flags)) + +#else + +#define sdhci_lock (host) spin_lock(&(host)->lock) +#define sdhci_unlock (host) spin_unlock(&(host)->lock) + +#define sdhci_lock_irqsave (host, flags) \ + spin_lock_irqsave(&(host)->lock, flags) +#define sdhci_unlock_irqrestore (host, flags) \ + spin_unlock_irqrestore(&(host)->lock, flags) + +#endif +#endif /* __SDHCI_HW_H */
Signature · 1 line
1.7.9.5
PATCH 18/26 mmc: sdhci: panic write: no timeout timer
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/host/sdhci.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci.c +4 -2
@@ -1012,7 +1012,8 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)mdelay (1 ); } -mod_timer (&host->timer, jiffies +10 *HZ ); +if (!mmc_am_panic_task (host->mmc)) +mod_timer (&host->timer, jiffies +10 *HZ ); host->cmd = cmd;
@@ -2117,7 +2118,8 @@ static void sdhci_tasklet_finish(unsigned long param)return ; } -del_timer (&host->timer); +if (!mmc_am_panic_task (host->mmc)) +del_timer (&host->timer); mrq = host->mrq;
Signature · 1 line
1.7.9.5
PATCH 13/26 mmc: panic write: trap non panic tasks
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/core/core.c | 10 +++++++++- drivers/mmc/core/host.c | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-)
drivers/mmc/core/core.c +9 -1
@@ -252,6 +252,7 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) }mmc_host_clk_hold (host);led_trigger_event (host->led,LED_FULL ); +mmc_trap_nonpanic_tasks (host); host->ops->request (host, mrq); }
@@ -344,8 +345,10 @@ static void mmc_wait_for_req_done(struct mmc_host *host,while (1 ) {/* Panic task requests must be completed in ->request() */ -if (!mmc_am_panic_task (host)) +if (!mmc_am_panic_task (host)) {wait_for_completion (&mrq->completion); +mmc_trap_nonpanic_tasks (host); + } cmd = mrq->cmd; if (!cmd->error || !cmd->retries ||
@@ -774,6 +777,8 @@ int __mmc_claim_host(struct mmc_host *host, atomic_t *abort)if (mmc_am_panic_task (host))return 0 ; +else +mmc_trap_nonpanic_tasks (host);might_sleep ();
@@ -817,6 +822,8 @@ int mmc_try_claim_host(struct mmc_host *host)if (mmc_am_panic_task (host))return 1 ; +else +mmc_trap_nonpanic_tasks (host);spin_lock_irqsave (&host->lock, flags);if (!host->claimed || host->claimer == current) {
@@ -880,6 +887,7 @@ static inline void mmc_set_ios(struct mmc_host *host)if (ios->clock >0 )mmc_set_ungated (host); +mmc_trap_nonpanic_tasks (host); host->ops->set_ios (host, ios); }
drivers/mmc/core/host.c +2 -0
@@ -90,6 +90,8 @@ static void mmc_host_clk_gate_delayed(struct mmc_host *host)unsigned long freq = host->ios.clock;unsigned long flags; +mmc_trap_nonpanic_tasks (host); +if (!freq) { pr_debug("%s: frequency set to 0 in disable function, " "this means the clock is already disabled.\n",
Signature · 1 line
1.7.9.5
PATCH 19/26 mmc: sdhci: panic write: no runtime pm
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/host/sdhci.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/mmc/host/sdhci.c +6 -0
@@ -2601,11 +2601,17 @@ EXPORT_SYMBOL_GPL(sdhci_enable_irq_wakeups);static int sdhci_runtime_pm_get (struct sdhci_host *host) { +if (mmc_am_panic_task (host->mmc)) +return 0 ; +return pm_runtime_get_sync (host->mmc->parent); }static int sdhci_runtime_pm_put (struct sdhci_host *host) { +if (mmc_am_panic_task (host->mmc)) +return 0 ; +pm_runtime_mark_last_busy (host->mmc->parent);return pm_runtime_put_autosuspend (host->mmc->parent); }
Signature · 1 line
1.7.9.5
PATCH 26/26 mmc: sdhci-pci: add panic write support
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/host/sdhci-pci.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/mmc/host/sdhci-pci.c +5 -0
@@ -966,6 +966,8 @@ static void sdhci_pci_hw_reset(struct sdhci_host *host)if (!gpio_is_valid (rst_n_gpio))return ; +if (mmc_panic_task_active (host->mmc)) +return ;gpio_set_value_cansleep (rst_n_gpio,0 );/* For eMMC, minimum is 1us but give it 10us for good measure */ udelay (10 );
@@ -1278,6 +1280,9 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot( } host->mmc->pm_caps =MMC_PM_KEEP_POWER |MMC_PM_WAKE_SDIO_IRQ ; +#ifdef CONFIG_MMC_BLOCK_PANIC_WRITE + slot->host->mmc->caps2 =MMC_CAP_PANIC_WRITE ; +#endif ret =sdhci_add_host (host);if (ret)
Signature · 1 line
1.7.9.5
PATCH 25/26 mmc: sdhci: panic write: trap nonpanic tasks
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/host/sdhci.c | 47 +++++++++++++++++++++++++++++++++++++++++---- include/linux/mmc/sdhci.h | 1 + 2 files changed, 44 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci.c +43 -4
@@ -2204,8 +2204,12 @@ static void sdhci_panic_cleanup(struct mmc_host *mmc)void sdhci_lock (struct sdhci_host *host) { -if (mmc_am_panic_task (host->mmc)) -return ; +if (mmc_panic_task_active (host->mmc)) { +if (mmc_am_panic_task (host->mmc)) +return ; +while (mmc_am_nonpanic_task (host->mmc)) +cpu_relax (); + }spin_lock (&host->lock); }
@@ -2219,8 +2223,12 @@ void _sdhci_lock_irqsave(struct sdhci_host *host, unsigned long *flags_ptr) {unsigned long flags; -if (mmc_am_panic_task (host->mmc)) -return ; +if (mmc_panic_task_active (host->mmc)) { +if (mmc_am_panic_task (host->mmc)) +return ; +while (mmc_am_nonpanic_task (host->mmc)) +cpu_relax (); + }spin_lock_irqsave (&host->lock, flags); *flags_ptr = flags;
@@ -2235,6 +2243,16 @@ void sdhci_unlock_irqrestore(struct sdhci_host *host, unsigned long flags)static void sdhci_panic_begin (struct mmc_host *mmc) {struct sdhci_host *host =mmc_priv (mmc); +int i; + +/* Wait a bit for other users to go away */ +for (i =0 ; i <10000 ; i++) { +if (spin_trylock (&host->lock)) { + host->locked =1 ; +break ; + } +udelay (1 ); + }if (host->runtime_suspended)sdhci_runtime_resume_host (host);
@@ -2250,6 +2268,10 @@ static void sdhci_panic_end(struct mmc_host *mmc) ier =sdhci_readl (host,SDHCI_INT_ENABLE );sdhci_writel (host, ier,SDHCI_SIGNAL_ENABLE ); +if (host->locked) { + host->locked =0 ; +spin_unlock (&host->lock); + } }static const struct mmc_panic_ops sdhci_pops = {
@@ -2368,6 +2390,9 @@ static void sdhci_timeout_timer(unsigned long data) host = (struct sdhci_host *)data; +if (mmc_am_nonpanic_task (host->mmc)) +return ; +sdhci_lock_irqsave (host, flags);if (host->mrq) {
@@ -2399,6 +2424,9 @@ static void sdhci_tuning_timer(unsigned long data) host = (struct sdhci_host *)data; +if (mmc_am_nonpanic_task (host->mmc)) +return ; +sdhci_lock_irqsave (host, flags); host->flags |=SDHCI_NEEDS_RETUNING ;
@@ -2596,6 +2624,9 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)u32 intmask, unexpected =0 ;int cardint =0 , max_loops =16 ; +if (mmc_am_nonpanic_task (host->mmc)) +return IRQ_HANDLED ; +sdhci_lock (host);
@@ -2713,6 +2744,8 @@ int sdhci_suspend_host(struct sdhci_host *host)if (host->ops->platform_suspend) host->ops->platform_suspend (host); +mmc_trap_nonpanic_tasks (host->mmc); +sdhci_disable_card_detection (host);/* Disable tuning since we are suspending */
@@ -2745,6 +2778,8 @@ int sdhci_resume_host(struct sdhci_host *host) {int ret; +mmc_trap_nonpanic_tasks (host->mmc); +if (host->flags & (SDHCI_USE_SDMA |SDHCI_USE_ADMA )) {if (host->ops->enable_dma) host->ops->enable_dma (host);
@@ -2820,6 +2855,8 @@ int sdhci_runtime_suspend_host(struct sdhci_host *host)unsigned long flags;int ret =0 ; +mmc_trap_nonpanic_tasks (host->mmc); +/* Disable tuning since we are suspending */ if (host->flags &SDHCI_USING_RETUNING_TIMER ) {del_timer_sync (&host->tuning_timer);
@@ -2845,6 +2882,8 @@ int sdhci_runtime_resume_host(struct sdhci_host *host)unsigned long flags;int ret =0 , host_flags = host->flags; +mmc_trap_nonpanic_tasks (host->mmc); +if (host_flags & (SDHCI_USE_SDMA |SDHCI_USE_ADMA )) {if (host->ops->enable_dma) host->ops->enable_dma (host);
include/linux/mmc/sdhci.h +1 -0
@@ -173,6 +173,7 @@ struct sdhci_host {struct timer_list tuning_timer;/* Timer for tuning */ #ifdef CONFIG_MMC_BLOCK_PANIC_WRITE +int locked;/* panic task has the lock */ void *panic_buf;/* buffer for panic requests */ size_t panic_bufsize;/* panic buffer size */ dma_addr_t panic_dma_addr;/* panic buffer dma address */
Signature · 1 line
1.7.9.5
PATCH 22/26 mmc: sdhci: panic write: no dma mapping
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/host/sdhci.c | 158 ++++++++++++++++++++++++++++++++++++++++++++- include/linux/mmc/sdhci.h | 8 +++ 2 files changed, 164 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci.c +156 -2
@@ -649,6 +649,69 @@ static void sdhci_adma_table_post(struct sdhci_host *host, data->sg_len, direction); } +#ifdef CONFIG_MMC_BLOCK_PANIC_WRITE + +static void sdhci_panic_dma_pre (struct sdhci_host *host,struct mmc_data *data) +{ +struct scatterlist *sg; +int i, len; +dma_addr_t addr; +u8 *desc; + +if (host->flags &SDHCI_USE_ADMA ) { +if (data->sg_len !=1 ) { +WARN_ON (1 ); + host->flags &= ~SDHCI_REQ_USE_DMA ; +return ; + } + desc = host->panic_adma_desc; +for_each_sg (data->sg, sg,1 , i) { + addr = host->panic_dma_addr; + len = sg->length; +sdhci_set_adma_desc (desc, addr, len,0x21 ); + desc +=8 ; + } +if (host->quirks &SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC ) { +if (desc != host->panic_adma_desc) { + desc -=8 ; + desc[0 ] |=0x2 ; + } + }else { +sdhci_set_adma_desc (desc,0 ,0 ,0x3 ); + } +sdhci_writel (host, host->panic_adma_addr,SDHCI_ADMA_ADDRESS ); + }else { +sdhci_writel (host, host->panic_dma_addr,SDHCI_DMA_ADDRESS ); + } + +if (data->flags &MMC_DATA_WRITE ) { +sg_copy_to_buffer (data->sg, data->sg_len, host->panic_buf, + host->panic_bufsize); + } +} + +static void sdhci_panic_dma_post (struct sdhci_host *host,struct mmc_data *data) +{ +if (data->flags &MMC_DATA_READ ) { +sg_copy_from_buffer (data->sg, data->sg_len, host->panic_buf, + host->panic_bufsize); + } +} + +#else + +static inline void sdhci_panic_dma_pre (struct sdhci_host *host, +struct mmc_data *data) +{ +} + +static inline void sdhci_panic_dma_post (struct sdhci_host *host, +struct mmc_data *data) +{ +} + +#endif +static u8 sdhci_calc_timeout (struct sdhci_host *host,struct mmc_command *cmd) {u8 count;
@@ -810,7 +873,9 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd) }if (host->flags &SDHCI_REQ_USE_DMA ) { -if (host->flags &SDHCI_USE_ADMA ) { +if (mmc_am_panic_task (host->mmc)) { +sdhci_panic_dma_pre (host, data); + }else if (host->flags &SDHCI_USE_ADMA ) { ret =sdhci_adma_table_pre (host, data);if (ret) {/*
@@ -937,7 +1002,9 @@ static void sdhci_finish_data(struct sdhci_host *host) host->data =NULL ;if (host->flags &SDHCI_REQ_USE_DMA ) { -if (host->flags &SDHCI_USE_ADMA ) +if (mmc_am_panic_task (host->mmc)) +sdhci_panic_dma_post (host, data); +else if (host->flags &SDHCI_USE_ADMA )sdhci_adma_table_post (host, data);else { dma_unmap_sg(mmc_dev(host->mmc), data->sg,
@@ -2045,6 +2112,91 @@ static const struct mmc_host_ops sdhci_ops = {#ifdef CONFIG_MMC_BLOCK_PANIC_WRITE +/* +* Arbitrary maximum DMA buffer size and hence maximum request size when using +* DMA. +*/ +#define SDHCI_PANIC_DMA_BUFSIZE (32 * 1024) + +/* +* We DMA at most one segment which is aligned. Plus we need an end descriptor. +* We allow for a 8 byte (32-bit address) descriptor size. +*/ +#define SDHCI_PANIC_ADMA_DESC_SZ ((1 + 1) * 12) + +static void sdhci_panic_dma_cleanup (struct sdhci_host *host) +{ +if (host->panic_adma_desc) { +dma_free_coherent (mmc_dev (host->mmc),SDHCI_PANIC_ADMA_DESC_SZ , + host->panic_adma_desc, host->panic_adma_addr); + host->panic_adma_desc =NULL ; + } + +if (host->panic_buf) { +dma_free_coherent (mmc_dev (host->mmc), host->panic_bufsize, + host->panic_buf, host->panic_dma_addr); + host->panic_buf =NULL ; + } +} + +static int sdhci_panic_dma_init (struct sdhci_host *host) +{ +size_t size; + + size =min_t (size_t,SDHCI_PANIC_DMA_BUFSIZE , host->mmc->max_seg_size); +while (size >PAGE_SIZE ) { + host->panic_buf =dma_alloc_coherent (mmc_dev (host->mmc), size, + &host->panic_dma_addr, +GFP_KERNEL | __GFP_NOWARN); +if (host->panic_buf) +break ; + size >>=1 ; + } +if (!host->panic_buf) { + host->panic_buf =dma_alloc_coherent (mmc_dev (host->mmc), size, + &host->panic_dma_addr, +GFP_KERNEL ); + } +if (!host->panic_buf) +return -ENOMEM ; + + host->panic_bufsize = size; + host->mmc->panic_max_size = size; + +if (host->flags &SDHCI_USE_ADMA ) { + size =SDHCI_PANIC_ADMA_DESC_SZ ; + host->panic_adma_desc =dma_alloc_coherent (mmc_dev (host->mmc), + size, + &host->panic_adma_addr, +GFP_KERNEL ); +if (!host->panic_adma_desc) { +sdhci_panic_dma_cleanup (host); +return -ENOMEM ; + } + } + +return 0 ; +} + +static int sdhci_panic_init (struct mmc_host *mmc) +{ +struct sdhci_host *host =mmc_priv (mmc); + + mmc->panic_max_size = mmc->max_seg_size; + +if (host->flags & (SDHCI_USE_SDMA |SDHCI_USE_ADMA )) +return sdhci_panic_dma_init (host); + +return 0 ; +} + +static void sdhci_panic_cleanup (struct mmc_host *mmc) +{ +struct sdhci_host *host =mmc_priv (mmc); + +sdhci_panic_dma_cleanup (host); +} +void sdhci_lock (struct sdhci_host *host) {if (mmc_am_panic_task (host->mmc))
@@ -2092,6 +2244,8 @@ static void sdhci_panic_end(struct mmc_host *mmc) }static const struct mmc_panic_ops sdhci_pops = { + .init = sdhci_panic_init, + .cleanup = sdhci_panic_cleanup, .begin = sdhci_panic_begin, .end = sdhci_panic_end, };
include/linux/mmc/sdhci.h +8 -0
@@ -172,6 +172,14 @@ struct sdhci_host {#define SDHCI_TUNING_MODE_1 0struct timer_list tuning_timer;/* Timer for tuning */ +#ifdef CONFIG_MMC_BLOCK_PANIC_WRITE +void *panic_buf;/* buffer for panic requests */ +size_t panic_bufsize;/* panic buffer size */ +dma_addr_t panic_dma_addr;/* panic buffer dma address */ +u8 *panic_adma_desc;/* adma desc buffer */ +dma_addr_t panic_adma_addr;/* adma desc address */ +#endif + unsigned long private[0] ____cacheline_aligned; };#endif /* LINUX_MMC_SDHCI_H */
Signature · 1 line
1.7.9.5
PATCH 24/26 mmc: sdhci: panic write: abort request in progress
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/host/sdhci.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/mmc/host/sdhci.c +5 -0
@@ -1351,6 +1351,11 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)sdhci_lock_irqsave (host, flags); +if (mmc_am_panic_task (mmc) && host->mrq) { + host->mrq->cmd->error = -EILSEQ ; +sdhci_sched_tasklet (host, finish); + } +WARN_ON (host->mrq !=NULL );#ifndef SDHCI_USE_LEDS_CLASS
Signature · 1 line
1.7.9.5
PATCH 23/26 mmc: sdhci: panic write: resume suspended host
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/host/sdhci.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci.c +10 -4
@@ -2231,6 +2231,10 @@ static void sdhci_panic_begin(struct mmc_host *mmc) {struct sdhci_host *host =mmc_priv (mmc); +if (host->runtime_suspended) +sdhci_runtime_resume_host (host); +else if (mmc->ios.vdd ==0 ) +sdhci_resume_host (host);sdhci_writel (host,0 ,SDHCI_SIGNAL_ENABLE ); }
@@ -2741,10 +2745,12 @@ int sdhci_resume_host(struct sdhci_host *host) host->ops->enable_dma (host); } - ret =request_irq (host->irq, sdhci_irq,IRQF_SHARED , -mmc_hostname (host->mmc), host); -if (ret) -return ret; +if (!mmc_am_panic_task (host->mmc)) { + ret =request_irq (host->irq, sdhci_irq,IRQF_SHARED , +mmc_hostname (host->mmc), host); +if (ret) +return ret; + }if ((host->mmc->pm_flags &MMC_PM_KEEP_POWER ) && (host->quirks2 &SDHCI_QUIRK2_HOST_OFF_CARD_ON )) {
Signature · 1 line
1.7.9.5
PATCH 21/26 mmc: sdhci: panic write: poll interrupts
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/host/sdhci.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
drivers/mmc/host/sdhci.c +33 -0
@@ -131,6 +131,8 @@ static void sdhci_clear_set_irqs(struct sdhci_host *host, u32 clear, u32 set) ier &= ~clear; ier |= set;sdhci_writel (host, ier,SDHCI_INT_ENABLE ); +if (mmc_panic_task_active (host->mmc)) + ier =0 ;sdhci_writel (host, ier,SDHCI_SIGNAL_ENABLE ); }
@@ -1267,6 +1269,8 @@ static int sdhci_set_power(struct sdhci_host *host, unsigned short power)* * \*****************************************************************************/ +static irqreturn_t sdhci_irq (int irq,void *dev_id); +static void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq) {struct sdhci_host *host;
@@ -1347,6 +1351,11 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)mmiowb ();sdhci_unlock_irqrestore (host, flags); + +if (mmc_am_panic_task (host->mmc)) { +while (host->mrq) +sdhci_irq (0 , host); + } }static void sdhci_do_set_ios (struct sdhci_host *host,struct mmc_ios *ios)
@@ -2066,6 +2075,27 @@ void sdhci_unlock_irqrestore(struct sdhci_host *host, unsigned long flags) spin_unlock_irqrestore(&host->lock, flags); } +static void sdhci_panic_begin (struct mmc_host *mmc) +{ +struct sdhci_host *host =mmc_priv (mmc); + +sdhci_writel (host,0 ,SDHCI_SIGNAL_ENABLE ); +} + +static void sdhci_panic_end (struct mmc_host *mmc) +{ +struct sdhci_host *host =mmc_priv (mmc); +u32 ier; + + ier =sdhci_readl (host,SDHCI_INT_ENABLE ); +sdhci_writel (host, ier,SDHCI_SIGNAL_ENABLE ); +} + +static const struct mmc_panic_ops sdhci_pops = { + .begin = sdhci_panic_begin, + .end = sdhci_panic_end, +}; +#endif /*****************************************************************************\
@@ -2854,6 +2884,9 @@ int sdhci_add_host(struct sdhci_host *host)* Set host parameters. */ mmc->ops = &sdhci_ops; +#ifdef CONFIG_MMC_BLOCK_PANIC_WRITE + mmc->pops = &sdhci_pops; +#endif mmc->f_max = host->max_clk;if (host->ops->get_min_clock) mmc->f_min = host->ops->get_min_clock (host);
Signature · 1 line
1.7.9.5
PATCH 20/26 mmc: sdhci: panic write: no tuning
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/host/sdhci.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mmc/host/sdhci.c +4 -0
@@ -1794,6 +1794,10 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)int err =0 ;bool requires_tuning_nonuhs = false; +/* Tuning may need a timer so it is not supported by the panic task */ +if (mmc_am_panic_task (mmc)) +return -EINVAL ; + host =mmc_priv (mmc);sdhci_runtime_pm_get (host);
Signature · 1 line
1.7.9.5
PATCH 9/26 mmc: panic write: suppress host not claimed warnings
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/core/core.c | 13 +++++++------ drivers/mmc/core/mmc.c | 4 ++-- drivers/mmc/core/sd.c | 4 ++-- drivers/mmc/core/sdio.c | 4 ++-- drivers/mmc/core/sdio_irq.c | 4 ++-- 5 files changed, 15 insertions(+), 14 deletions(-)
drivers/mmc/core/core.c +7 -6
@@ -224,7 +224,7 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) mrq->stop->arg, mrq->stop->flags); } -WARN_ON (!host->claimed); +WARN_ON (!host->claimed && !mmc_am_panic_task (host)); mrq->cmd->error =0 ; mrq->cmd->mrq = mrq;
@@ -558,7 +558,7 @@ int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int retries {struct mmc_request mrq = {NULL }; -WARN_ON (!host->claimed); +WARN_ON (!host->claimed && !mmc_am_panic_task (host));memset (cmd->resp,0 ,sizeof (cmd->resp)); cmd->retries = retries;
@@ -843,7 +843,7 @@ void mmc_release_host(struct mmc_host *host) {unsigned long flags; -WARN_ON (!host->claimed); +WARN_ON (!host->claimed && !mmc_am_panic_task (host));if (host->ops->disable && host->claim_cnt ==1 ) host->ops->disable (host);
@@ -1433,7 +1433,7 @@ void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops)BUG_ON (!host);BUG_ON (!ops); -WARN_ON (!host->claimed); +WARN_ON (!host->claimed && !mmc_am_panic_task (host));spin_lock_irqsave (&host->lock, flags);
@@ -1456,7 +1456,7 @@ void mmc_detach_bus(struct mmc_host *host)BUG_ON (!host); -WARN_ON (!host->claimed); +WARN_ON (!host->claimed && !mmc_am_panic_task (host));WARN_ON (!host->bus_ops);spin_lock_irqsave (&host->lock, flags);
@@ -2106,7 +2106,8 @@ int mmc_detect_card_removed(struct mmc_host *host)struct mmc_card *card = host->card;int ret; -WARN_ON (!host->claimed); +WARN_ON (!host->claimed && !mmc_am_panic_task (host)); +if (!card)return 1 ;
drivers/mmc/core/mmc.c +2 -2
@@ -823,7 +823,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,u8 *ext_csd =NULL ;BUG_ON (!host); -WARN_ON (!host->claimed); +WARN_ON (!host->claimed && !mmc_am_panic_task (host));/* Set correct bus mode for MMC before attempting init */ if (!mmc_host_is_spi (host))
@@ -1478,7 +1478,7 @@ int mmc_attach_mmc(struct mmc_host *host)u32 ocr;BUG_ON (!host); -WARN_ON (!host->claimed); +WARN_ON (!host->claimed && !mmc_am_panic_task (host));/* Set correct bus mode for MMC before attempting attach */ if (!mmc_host_is_spi (host))
drivers/mmc/core/sd.c +2 -2
@@ -899,7 +899,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,u32 rocr =0 ;BUG_ON (!host); -WARN_ON (!host->claimed); +WARN_ON (!host->claimed && !mmc_am_panic_task (host)); err =mmc_sd_get_cid (host, ocr, cid, &rocr);if (err)
@@ -1146,7 +1146,7 @@ int mmc_attach_sd(struct mmc_host *host)u32 ocr;BUG_ON (!host); -WARN_ON (!host->claimed); +WARN_ON (!host->claimed && !mmc_am_panic_task (host));/* Disable preset value enable if already set since last time */ if (host->ops->enable_preset_value) {
drivers/mmc/core/sdio.c +2 -2
@@ -585,7 +585,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,int err;BUG_ON (!host); -WARN_ON (!host->claimed); +WARN_ON (!host->claimed && !mmc_am_panic_task (host));/* * Inform the card of the voltage
@@ -1051,7 +1051,7 @@ int mmc_attach_sdio(struct mmc_host *host)struct mmc_card *card;BUG_ON (!host); -WARN_ON (!host->claimed); +WARN_ON (!host->claimed && !mmc_am_panic_task (host)); err =mmc_send_io_op_cond (host,0 , &ocr);if (err)
drivers/mmc/core/sdio_irq.c +2 -2
@@ -175,7 +175,7 @@ static int sdio_card_irq_get(struct mmc_card *card) {struct mmc_host *host = card->host; -WARN_ON (!host->claimed); +WARN_ON (!host->claimed && !mmc_am_panic_task (host));if (!host->sdio_irqs++) {atomic_set (&host->sdio_irq_thread_abort,0 );
@@ -196,7 +196,7 @@ static int sdio_card_irq_put(struct mmc_card *card) {struct mmc_host *host = card->host; -WARN_ON (!host->claimed); +WARN_ON (!host->claimed && !mmc_am_panic_task (host));BUG_ON (host->sdio_irqs <1 );if (!--host->sdio_irqs) {
Signature · 1 line
1.7.9.5
PATCH 8/26 mmc: panic write: bypass request completion
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/core/core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/mmc/core/core.c +6 -1
@@ -148,6 +148,9 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq) cmd->retries =0 ; } +if (mmc_am_panic_task (host)) +return ; +if (err && cmd->retries && !mmc_card_removed (host->card)) {/* * Request starter must handle retries - see
@@ -340,7 +343,9 @@ static void mmc_wait_for_req_done(struct mmc_host *host,struct mmc_command *cmd;while (1 ) { -wait_for_completion (&mrq->completion); +/* Panic task requests must be completed in ->request() */ +if (!mmc_am_panic_task (host)) +wait_for_completion (&mrq->completion); cmd = mrq->cmd; if (!cmd->error || !cmd->retries ||
Signature · 1 line
1.7.9.5
PATCH 3/26 pstore: add flush
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
Let the back end know when writing has finished by adding a flush method.
--- fs/pstore/platform.c | 3 +++ include/linux/pstore.h | 1 + 2 files changed, 4 insertions(+)
fs/pstore/platform.c +3 -0
@@ -114,6 +114,9 @@ static void pstore_dump(struct kmsg_dumper *dumper, why =get_reason_str (reason); +if (psinfo->flush) + psinfo->flush (psinfo); +if (in_nmi ()) { is_locked =spin_trylock (&psinfo->buf_lock);if (!is_locked)
include/linux/pstore.h +1 -0
@@ -68,6 +68,7 @@ struct pstore_info { struct pstore_info *psi);int (*erase)(enum pstore_type_id type,u64 id,struct pstore_info *psi); +int (*flush)(struct pstore_info *psi);void *data; };
Signature · 1 line
1.7.9.5
PATCH 4/26 blkoops: add a block device oops / panic logger
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
blkoops is a pstore back end to write panic / oops logs to a block device. It is initially intended for use with eMMC as an alternative to using a crash kernel.
--- Documentation/blockdev/00-INDEX | 2 + Documentation/blockdev/blkoops.txt | 104 +++ drivers/block/Kconfig | 10 + drivers/block/Makefile | 1 + drivers/block/blkoops.c | 1569 ++++++++++++++++++++++++++++++++++++ 5 files changed, 1686 insertions(+) create mode 100644 Documentation/blockdev/blkoops.txt create mode 100644 drivers/block/blkoops.c
Documentation/blockdev/00-INDEX +2 -0
@@ -2,6 +2,8 @@ - this file README.DAC960 - info on Mylex DAC960/DAC1100 PCI RAID Controller Driver for Linux. +blkoops.txt + - info on block device oops / panic logger cciss.txt - info, major/minor #'s for Compaq's SMART Array Controllers. cpqarray.txt
Documentation/blockdev/blkoops.txt new file +104 -0
104 lines not on this page · raw message
drivers/block/Kconfig +10 -0
@@ -543,4 +543,14 @@ config BLK_DEV_RBD If unsure, say N. +config BLK_DEV_OOPS + bool "Block Oops / Panic Logger" + select BLK_DEV_PANIC_WRITE + select PSTORE + default n + help + This enables panic and oops messages to be logged to a block device. + + See <file:Documentation/blockdev/blkoops.txt> for more information. + endif # BLK_DEV
drivers/block/Makefile +1 -0
@@ -25,6 +25,7 @@ obj-$(CONFIG_MG_DISK) += mg_disk.o obj-$(CONFIG_SUNVDC) += sunvdc.o obj-$(CONFIG_BLK_DEV_NVME) += nvme.o obj-$(CONFIG_BLK_DEV_OSD) += osdblk.o +obj-$(CONFIG_BLK_DEV_OOPS) += blkoops.o obj-$(CONFIG_BLK_DEV_UMEM) += umem.o obj-$(CONFIG_BLK_DEV_NBD) += nbd.o
drivers/block/blkoops.c new file +1569 -0
1,569 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 16/26 mmc: sdhci: panic write: no sleeping
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/host/sdhci.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
drivers/mmc/host/sdhci.c +21 -5
@@ -1536,6 +1536,14 @@ static int sdhci_check_ro(struct sdhci_host *host)#define SAMPLE_COUNT 5 +static void sdhci_msleep (struct sdhci_host *host,unsigned int ms) +{ +if (mmc_am_panic_task (host->mmc)) +mdelay (ms); +else +msleep (ms); +} +static int sdhci_do_get_ro (struct sdhci_host *host) {int i, ro_count;
@@ -1549,7 +1557,7 @@ static int sdhci_do_get_ro(struct sdhci_host *host)if (++ro_count >SAMPLE_COUNT /2 )return 1 ; } -msleep (30 ); +sdhci_msleep (host,30 ); }return 0 ; }
@@ -1605,6 +1613,14 @@ static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable)sdhci_unlock_irqrestore (host, flags); } +#define sdhci_usleep_range (host, min, max) \ +do { \ + if (mmc_am_panic_task((host)->mmc)) \ + mdelay(DIV_ROUND_UP(min, 1000)); \ + else \ + usleep_range(min, max); \ +} while (0) +static int sdhci_do_3_3v_signal_voltage_switch (struct sdhci_host *host,u16 ctrl) {
@@ -1623,7 +1639,7 @@ static int sdhci_do_3_3v_signal_voltage_switch(struct sdhci_host *host, } }/* Wait for 5ms */ -usleep_range (5000 ,5500 ); +sdhci_usleep_range (host,5000 ,5500 );/* 3.3V regulator output should be stable within 5 ms */ ctrl =sdhci_readw (host,SDHCI_HOST_CONTROL2 );
@@ -1668,7 +1684,7 @@ static int sdhci_do_1_8v_signal_voltage_switch(struct sdhci_host *host,sdhci_writew (host, ctrl,SDHCI_HOST_CONTROL2 );/* Wait for 5ms */ -usleep_range (5000 ,5500 ); +sdhci_usleep_range (host,5000 ,5500 ); ctrl =sdhci_readw (host,SDHCI_HOST_CONTROL2 );if (ctrl &SDHCI_CTRL_VDD_180 ) {
@@ -1676,7 +1692,7 @@ static int sdhci_do_1_8v_signal_voltage_switch(struct sdhci_host *host, clk =sdhci_readw (host,SDHCI_CLOCK_CONTROL ); clk |=SDHCI_CLOCK_CARD_EN ;sdhci_writew (host, clk,SDHCI_CLOCK_CONTROL ); -usleep_range (1000 ,1500 ); +sdhci_usleep_range (host,1000 ,1500 );/* * If DAT[3:0] level is 1111b, then the card
@@ -1703,7 +1719,7 @@ static int sdhci_do_1_8v_signal_voltage_switch(struct sdhci_host *host,regulator_disable (host->vmmc);/* Wait for 1ms as per the spec */ -usleep_range (1000 ,1500 ); +sdhci_usleep_range (host,1000 ,1500 ); pwr |=SDHCI_POWER_ON ;sdhci_writeb (host, pwr,SDHCI_POWER_CONTROL );if (host->vmmc)
Signature · 1 line
1.7.9.5
PATCH 17/26 mmc: sdhci: panic write: call tasklets inline
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/host/sdhci.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)
drivers/mmc/host/sdhci.c +21 -10
@@ -914,6 +914,17 @@ static void sdhci_set_transfer_mode(struct sdhci_host *host,sdhci_writew (host, mode,SDHCI_TRANSFER_MODE ); } +static void sdhci_tasklet_card (unsigned long param); +static void sdhci_tasklet_finish (unsigned long param); + +#define sdhci_sched_tasklet (host, name) \ +{ \ + if (mmc_am_panic_task(host->mmc)) \ + sdhci_tasklet_##name((unsigned long)host); \ + else \ + tasklet_schedule(&host->name##_tasklet); \ +} +static void sdhci_finish_data (struct sdhci_host *host) {struct mmc_data *data;
@@ -965,7 +976,7 @@ static void sdhci_finish_data(struct sdhci_host *host)sdhci_send_command (host, data->stop); }else -tasklet_schedule (&host->finish_tasklet); +sdhci_sched_tasklet (host, finish); }static void sdhci_send_command (struct sdhci_host *host,struct mmc_command *cmd)
@@ -994,7 +1005,7 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) "inhibit bit(s).\n", mmc_hostname(host->mmc));sdhci_dumpregs (host); cmd->error = -EIO ; -tasklet_schedule (&host->finish_tasklet); +sdhci_sched_tasklet (host, finish);return ; } timeout--;
@@ -1015,7 +1026,7 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)pr_err ("%s: Unsupported response type!\n" ,mmc_hostname (host->mmc)); cmd->error = -EINVAL ; -tasklet_schedule (&host->finish_tasklet); +sdhci_sched_tasklet (host, finish);return ; }
@@ -1076,7 +1087,7 @@ static void sdhci_finish_command(struct sdhci_host *host)sdhci_finish_data (host);if (!host->cmd->data) -tasklet_schedule (&host->finish_tasklet); +sdhci_sched_tasklet (host, finish); host->cmd =NULL ; }
@@ -1303,7 +1314,7 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)if (!present || host->flags &SDHCI_DEVICE_DEAD ) { host->mrq->cmd->error = -ENOMEDIUM ; -tasklet_schedule (&host->finish_tasklet); +sdhci_sched_tasklet (host, finish); }else {u32 present_state;
@@ -2079,7 +2090,7 @@ static void sdhci_tasklet_card(unsigned long param)sdhci_reset (host,SDHCI_RESET_DATA ); host->mrq->cmd->error = -ENOMEDIUM ; -tasklet_schedule (&host->finish_tasklet); +sdhci_sched_tasklet (host, finish); }sdhci_unlock_irqrestore (host, flags);
@@ -2174,7 +2185,7 @@ static void sdhci_timeout_timer(unsigned long data)else host->mrq->cmd->error = -ETIMEDOUT ; -tasklet_schedule (&host->finish_tasklet); +sdhci_sched_tasklet (host, finish); } }
@@ -2221,7 +2232,7 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask) host->cmd->error = -EILSEQ ;if (host->cmd->error) { -tasklet_schedule (&host->finish_tasklet); +sdhci_sched_tasklet (host, finish);return ; }
@@ -2429,7 +2440,7 @@ again:sdhci_writel (host, intmask & (SDHCI_INT_CARD_INSERT |SDHCI_INT_CARD_REMOVE ),SDHCI_INT_STATUS ); intmask &= ~(SDHCI_INT_CARD_INSERT |SDHCI_INT_CARD_REMOVE ); -tasklet_schedule (&host->card_tasklet); +sdhci_sched_tasklet (host, card); }if (intmask &SDHCI_INT_CMD_MASK ) {
@@ -3192,7 +3203,7 @@ void sdhci_remove_host(struct sdhci_host *host, int dead) " transfer!\n", mmc_hostname(host->mmc)); host->mrq->cmd->error = -ENOMEDIUM ; -tasklet_schedule (&host->finish_tasklet); +sdhci_sched_tasklet (host, finish); }sdhci_unlock_irqrestore (host, flags);
Signature · 1 line
1.7.9.5
PATCH 14/26 mmc: panic write: bypass bus ref locking
In reply to Irina TirdeaFrom: Adrian Hunter <[email protected]>
--- drivers/mmc/core/core.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/mmc/core/core.c +10 -0
@@ -1418,6 +1418,11 @@ static inline void mmc_bus_get(struct mmc_host *host) {unsigned long flags; +if (mmc_am_panic_task (host)) { + host->bus_refs++; +return ; + } +spin_lock_irqsave (&host->lock, flags); host->bus_refs++;spin_unlock_irqrestore (&host->lock, flags);
@@ -1431,6 +1436,11 @@ static inline void mmc_bus_put(struct mmc_host *host) {unsigned long flags; +if (mmc_am_panic_task (host)) { + host->bus_refs--; +return ; + } +spin_lock_irqsave (&host->lock, flags); host->bus_refs--;if ((host->bus_refs ==0 ) && host->bus_ops)
Signature · 1 line
1.7.9.5
cover pstore, mmc: add mmc as backend for pstore
These patches enable using the mmc card to store panic information.
They include changes for pstore and mmc:
- add block device backend for pstore
- add logic in mmc for writing in panic mode
Thanks,
Irina
Adrian Hunter (26):
pstore: allow for big files
pstore: add flags
pstore: add flush
blkoops: add a block device oops / panic logger
block: add panic write
mmc: block: add panic write support
mmc: panic write: bypass host claiming
mmc: panic write: bypass request completion
mmc: panic write: suppress host not claimed warnings
mmc: panic write: do not msleep
mmc: panic write: bypass clock gating
mmc: panic write: bypass regulators
mmc: panic write: trap non panic tasks
mmc: panic write: bypass bus ref locking
mmc: sdhci: panic write: bypass spin lock
mmc: sdhci: panic write: no sleeping
mmc: sdhci: panic write: call tasklets inline
mmc: sdhci: panic write: no timeout timer
mmc: sdhci: panic write: no runtime pm
mmc: sdhci: panic write: no tuning
mmc: sdhci: panic write: poll interrupts
mmc: sdhci: panic write: no dma mapping
mmc: sdhci: panic write: resume suspended host
mmc: sdhci: panic write: abort request in progress
mmc: sdhci: panic write: trap nonpanic tasks
mmc: sdhci-pci: add panic write support
Documentation/blockdev/00-INDEX | 2 + Documentation/blockdev/blkoops.txt | 104 +++ drivers/acpi/apei/erst.c | 16 +- drivers/block/Kconfig | 13 + drivers/block/Makefile | 1 + drivers/block/blkoops.c | 1569 ++++++++++++++++++++++++++++++++++++ drivers/mmc/card/Kconfig | 11 + drivers/mmc/card/block.c | 257 +++++- drivers/mmc/core/core.c | 61 +- drivers/mmc/core/core.h | 6 +- drivers/mmc/core/host.c | 11 + drivers/mmc/core/mmc.c | 4 +- drivers/mmc/core/mmc_ops.c | 10 +- drivers/mmc/core/sd.c | 4 +- drivers/mmc/core/sd_ops.c | 2 +- drivers/mmc/core/sdio.c | 4 +- drivers/mmc/core/sdio_irq.c | 4 +- drivers/mmc/core/sdio_ops.c | 2 +- drivers/mmc/host/sdhci-pci.c | 5 + drivers/mmc/host/sdhci.c | 441 ++++++++-- drivers/mmc/host/sdhci.h | 24 + fs/pstore/inode.c | 26 +- fs/pstore/internal.h | 5 +- fs/pstore/platform.c | 23 +- fs/pstore/ram.c | 15 +- include/linux/blkdev.h | 77 ++ include/linux/genhd.h | 3 + include/linux/mmc/host.h | 92 +++ include/linux/mmc/sdhci.h | 9 + include/linux/pstore.h | 12 +- 30 files changed, 2690 insertions(+), 123 deletions(-) create mode 100644 Documentation/blockdev/blkoops.txt create mode 100644 drivers/block/blkoops.c
Signature · 1 line
1.7.9.5
Re: [PATCH 01/26] pstore: allow for big files
In reply to Irina TirdeaQuoted 74 lines · Irina Tirdea
From: Adrian Hunter <[email protected]>
pstore reads all files into memory at mount time. To allow for back ends that will store arbitrarily large files, enhance pstore also to be able to read from the back end as needed.
Signed-off-by Adrian Hunter <[email protected]>Signed-off-by Irina Tirdea <[email protected]>--- drivers/acpi/apei/erst.c | 16 +++++++++------- fs/pstore/inode.c | 26 ++++++++++++++++++++------ fs/pstore/internal.h | 5 +++-- fs/pstore/platform.c | 11 +++++++---- fs/pstore/ram.c | 15 +++++++-------- include/linux/pstore.h | 7 +++++-- 6 files changed, 51 insertions(+), 29 deletions(-)drivers/acpi/apei/erst.c +9
-7@@ -931,9 +931,9 @@ static int erst_check_table(struct acpi_table_erst *erst_tab)static int erst_open_pstore (struct pstore_info *psi);static int erst_close_pstore (struct pstore_info *psi); -static ssize_t erst_reader (u64 *id,enum pstore_type_id *type, -struct timespec *time,char **buf, -struct pstore_info *psi); +static int erst_reader (u64 *id,enum pstore_type_id *type, +struct timespec *time,char **buf,loff_t *size, +struct pstore_info *psi);static int erst_writer (enum pstore_type_id type,enum kmsg_dump_reason reason,u64 *id,unsigned int part,size_t size,struct pstore_info *psi);@@ -987,9 +987,9 @@ static int erst_close_pstore(struct pstore_info *psi)return 0 ; } -static ssize_t erst_reader (u64 *id,enum pstore_type_id *type, -struct timespec *time,char **buf, -struct pstore_info *psi) +static int erst_reader (u64 *id,enum pstore_type_id *type, +struct timespec *time,char **buf,loff_t *size, +struct pstore_info *psi) {int rc;ssize_t len =0 ;@@ -1051,7 +1051,9 @@ skip: out:kfree (rcd); -return (rc <0 ) ? rc : (len -sizeof (*rcd)); +if (!rc) + *size = len -sizeof (*rcd); +return rc; } static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason,fs/pstore/inode.c +2
-1@@ -49,7 +49,8 @@ struct pstore_private {struct pstore_info *psi;enum pstore_type_id type;u64 id; -ssize_t size; +loff_t size; +bool big;char data[]; };@@ -65,12 +66,13 @@ static void *pstore_ftrace_seq_start(struct seq_file *s, loff_t *pos) {
fs/pstore/inode.c static void *pstore_ftrace_seq_start(struct seq_file *s, loff_t *pos) · line 75
Quoted 10 lines
fs/pstore/inode.c +2
-1struct pstore_private *ps = s->private;struct pstore_ftrace_seq_data *data; +loff_t size = ps->size; data =kzalloc (sizeof (*data),GFP_KERNEL );if (!data)return NULL ; - data->off = ps->size %REC_SIZE ; + data->off =do_div (size,REC_SIZE );
This modifies ps->size. I don't think you want that?
-Kees
Quoted 173 lines
fs/pstore/inode.c +16
-4data->off += *pos *REC_SIZE ;if (data->off +REC_SIZE > ps->size) {kfree (data);@@ -127,6 +129,12 @@ static ssize_t pstore_file_read(struct file *file, char __user *userbuf,if (ps->type ==PSTORE_TYPE_FTRACE )return seq_read (file, userbuf, count, ppos); +if (ps->big) { +if (ps->psi->file_read) +return ps->psi->file_read (ps->id, ps->type, userbuf, + count, ppos, ps->psi); +return -EFBIG ; + }return simple_read_from_buffer (userbuf, count, ppos, ps->data, ps->size); }@@ -271,8 +279,8 @@ int pstore_is_mounted(void)* Set the mtime & ctime to the date that this record was originally stored. */ int pstore_mkfile (enum pstore_type_id type,char *psname,u64 id, -char *data,size_t size,struct timespec time, -struct pstore_info *psi) +char *data,loff_t size,struct timespec time, +struct pstore_info *psi,bool big) {struct dentry *root = pstore_sb->s_root;struct dentry *dentry;@@ -281,6 +289,7 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id,char name[PSTORE_NAMELEN ];struct pstore_private *private, *pos;unsigned long flags; +size_t inline_size;spin_lock_irqsave (&allpstore_lock, flags);list_for_each_entry (pos, &allpstore, list) {@@ -301,12 +310,17 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, goto fail; inode->i_mode =S_IFREG |0444 ; inode->i_fop = &pstore_file_operations; - private =kmalloc (sizeof *private + size,GFP_KERNEL ); +if (big) + inline_size =0 ; +else + inline_size = size; + private =kmalloc (sizeof (*private) + inline_size,GFP_KERNEL );if (!private) goto fail_alloc; private->type = type; private->id = id; private->psi = psi; + private->big = big;switch (type) {case PSTORE_TYPE_DMESG :@@ -336,7 +350,7 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id,if (IS_ERR (dentry)) goto fail_lockedalloc; -memcpy (private->data, data, size); +memcpy (private->data, data, inline_size); inode->i_size = private->size = size; inode->i_private = private;fs/pstore/internal.h +3
-2@@ -50,8 +50,9 @@ extern struct pstore_info *psinfo;extern void pstore_set_kmsg_bytes (int );extern void pstore_get_records (int );extern int pstore_mkfile (enum pstore_type_id ,char *psname,u64 id, -char *data,size_t size, -struct timespec time,struct pstore_info *psi); +char *data,loff_t size, +struct timespec time,struct pstore_info *psi, +bool big);extern int pstore_is_mounted (void );#endif fs/pstore/platform.c +7
-4@@ -264,7 +264,7 @@ void pstore_get_records(int quiet) {struct pstore_info *psi = psinfo;char *buf =NULL ; -ssize_t size; +loff_t size;u64 id;enum pstore_type_id type;struct timespec time;@@ -277,9 +277,12 @@ void pstore_get_records(int quiet)if (psi->open && psi->open (psi)) goto out; -while ((size = psi->read (&id, &type, &time, &buf, psi)) >0 ) { - rc =pstore_mkfile (type, psi->name, id, buf, (size_t )size, - time, psi); +while (1 ) { + rc = psi->read (&id, &type, &time, &buf, &size, psi); +if (rc && rc != -EFBIG ) +break ; + rc =pstore_mkfile (type, psi->name, id, buf, size, + time, psi, rc == -EFBIG );kfree (buf); buf =NULL ;if (rc && (rc != -EEXIST || !quiet))fs/pstore/ram.c +7
-8@@ -131,12 +131,11 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max,return prz; } -static ssize_t ramoops_pstore_read (u64 *id,enum pstore_type_id *type, +static int ramoops_pstore_read (u64 *id,enum pstore_type_id *type,struct timespec *time, -char **buf, +char **buf,loff_t *size,struct pstore_info *psi) { -ssize_t size;struct ramoops_context *cxt = psi->data;struct persistent_ram_zone *prz;@@ -150,19 +149,19 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type, prz =ramoops_get_next_prz (&cxt->fprz, &cxt->ftrace_read_cnt,1 , id, type,PSTORE_TYPE_FTRACE ,0 );if (!prz) -return 0 ; +return -EINVAL ;/* TODO(kees): Bogus time for the moment. */ time->tv_sec =0 ; time->tv_nsec =0 ; - size =persistent_ram_old_size (prz); - *buf =kmalloc (size,GFP_KERNEL ); + *size =persistent_ram_old_size (prz); + *buf =kmalloc (*size,GFP_KERNEL );if (*buf ==NULL )return -ENOMEM ; -memcpy (*buf,persistent_ram_old (prz), size); +memcpy (*buf,persistent_ram_old (prz), *size); -return size; +return 0 ; }static size_t ramoops_write_kmsg_hdr (struct persistent_ram_zone *prz)include/linux/pstore.h +5
-3@@ -49,8 +49,11 @@ struct pstore_info {struct mutex read_mutex;/* serialize open/read/close */ int (*open)(struct pstore_info *psi);int (*close)(struct pstore_info *psi); -ssize_t (*read)(u64 *id,enum pstore_type_id *type, -struct timespec *time,char **buf, +int (*read)(u64 *id,enum pstore_type_id *type, +struct timespec *time,char **buf,loff_t *size, +struct pstore_info *psi); +ssize_t (*file_read)(u64 id,enum pstore_type_id type, +char __user *userbuf,size_t count,loff_t *ppos,struct pstore_info *psi); int (*write)(enum pstore_type_id type, enum kmsg_dump_reason reason, u64 *id, --1.7.9.5
Signature · 2 lines
Kees Cook Chrome OS Security
Re: [PATCH 03/26] pstore: add flush
In reply to Irina TirdeaQuoted 6 lines · Irina Tirdea
From: Adrian Hunter <[email protected]>
Let the back end know when writing has finished by adding a flush method.
Signed-off-by Adrian Hunter <[email protected]>Signed-off-by Irina Tirdea <[email protected]>
-Kees
Signature · 2 lines
Kees Cook Chrome OS Security
Re: [PATCH 02/26] pstore: add flags
In reply to Irina TirdeaQuoted 7 lines · Irina Tirdea
From: Adrian Hunter <[email protected]>
Let the back end tweak pstore behaviour. Flags added are:
PSTORE_NO_HEADINGSOmit pstore heading lines from dumped data
I wonder if the default should be to not show headers, and to add this flag to the backends that want the pstore-added header. I think the more common case going forward will to be without headers since backends should arguably storing metadata themselves.
Thoughts?
Quoted 6 lines
PSTORE_MAX_KMSG_BYTESDefault
kmsg_bytestoULONG_MAXSigned-off-by Adrian Hunter <[email protected]>Signed-off-by Irina Tirdea <[email protected]>
Either way, this patch looks logically fine to me.
-Kees
Signature · 2 lines
Kees Cook Chrome OS Security
Luck, Tony
reviewerRE: [PATCH 02/26] pstore: add flags
Quoted 4 lines
I wonder if the default should be to not show headers, and to add this flag to the backends that want the pstore-added header. I think the more common case going forward will to be without headers since backends should arguably storing metadata themselves.
Perhaps just add the headings when pstore breaks a dump into pieces because of a back-end size limitation. I.e. if there is only one piece, then no headings. If there are two or more, include a heading to aid with putting the pieces together later.
-Tony
Re: [PATCH 01/26] pstore: allow for big files
In reply to Kees CookQuoted 80 lines · Kees Cook
Quoted 78 lines · Irina Tirdea
From: Adrian Hunter <[email protected]>
pstore reads all files into memory at mount time. To allow for back ends that will store arbitrarily large files, enhance pstore also to be able to read from the back end as needed.
Signed-off-by Adrian Hunter <[email protected]>Signed-off-by Irina Tirdea <[email protected]>--- drivers/acpi/apei/erst.c | 16 +++++++++------- fs/pstore/inode.c | 26 ++++++++++++++++++++------ fs/pstore/internal.h | 5 +++-- fs/pstore/platform.c | 11 +++++++---- fs/pstore/ram.c | 15 +++++++-------- include/linux/pstore.h | 7 +++++-- 6 files changed, 51 insertions(+), 29 deletions(-)drivers/acpi/apei/erst.c +9
-7@@ -931,9 +931,9 @@ static int erst_check_table(struct acpi_table_erst *erst_tab)static int erst_open_pstore (struct pstore_info *psi);static int erst_close_pstore (struct pstore_info *psi); -static ssize_t erst_reader (u64 *id,enum pstore_type_id *type, -struct timespec *time,char **buf, -struct pstore_info *psi); +static int erst_reader (u64 *id,enum pstore_type_id *type, +struct timespec *time,char **buf,loff_t *size, +struct pstore_info *psi);static int erst_writer (enum pstore_type_id type,enum kmsg_dump_reason reason,u64 *id,unsigned int part,size_t size,struct pstore_info *psi);@@ -987,9 +987,9 @@ static int erst_close_pstore(struct pstore_info *psi)return 0 ; } -static ssize_t erst_reader (u64 *id,enum pstore_type_id *type, -struct timespec *time,char **buf, -struct pstore_info *psi) +static int erst_reader (u64 *id,enum pstore_type_id *type, +struct timespec *time,char **buf,loff_t *size, +struct pstore_info *psi) {int rc;ssize_t len =0 ;@@ -1051,7 +1051,9 @@ skip: out:kfree (rcd); -return (rc <0 ) ? rc : (len -sizeof (*rcd)); +if (!rc) + *size = len -sizeof (*rcd); +return rc; } static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason,fs/pstore/inode.c +3
-1@@ -49,7 +49,8 @@ struct pstore_private {struct pstore_info *psi;enum pstore_type_id type;u64 id; -ssize_t size; +loff_t size; +bool big;char data[]; };@@ -65,12 +66,13 @@ static void *pstore_ftrace_seq_start(struct seq_file *s, loff_t *pos) {struct pstore_private *ps = s->private;struct pstore_ftrace_seq_data *data; +loff_t size = ps->size;
Quoted 9 lines
fs/pstore/inode.c static void *pstore_ftrace_seq_start(struct seq_file *s, loff_t *pos) · line 75
Quoted 6 lines
fs/pstore/inode.c +1
-1data =kzalloc (sizeof (*data),GFP_KERNEL );if (!data)return NULL ; - data->off = ps->size %REC_SIZE ; + data->off =do_div (size,REC_SIZE );This modifies
ps->size. I don't think you want that?
ps->size is not modified. The locally stored "size" variable is used to avoid modifying ps->size.
Thanks,
Dragos
Re: [PATCH 02/26] pstore: add flags
In reply to Luck, TonyQuoted 10 lines · Tony
Quoted 4 lines
I wonder if the default should be to not show headers, and to add this flag to the backends that want the pstore-added header. I think the more common case going forward will to be without headers since backends should arguably storing metadata themselves.
Perhaps just add the headings when pstore breaks a dump into pieces because of a back-end size limitation. I.e. if there is only one piece, then no headings. If there are two or more, include a heading to aid with putting the pieces together later.
But how do you determine the kmsg data size without doing a kmsg_dump_get_buffer beforehand?
Thanks,
Dragos
Quoted 5 lines · Irina Tirdea
These patches enable using the mmc card to store panic information.
They include changes for pstore and mmc:
- add block device backend for pstore
- add logic in mmc for writing in panic mode
Chris, any feedback on mmc/sdhci part?
Signature · 1 line
Kirill A. Shutemov
Hi,
Quoted 8 lines · Kirill A. Shutemov
Quoted 5 lines · Irina Tirdea
These patches enable using the mmc card to store panic information.
They include changes for pstore and mmc:
- add block device backend for pstore
- add logic in mmc for writing in panic modeChris, any feedback on mmc/sdhci part?
Looks like the patchset hasn't been sent to [email protected] yet -- could you send a v2 with that address included, please?
It would also be great to see descriptive commit messages, rather than just patch subject lines.
Documentation-wise, the patchset mentions that host controller support is required for this to work, but doesn't explain what kind of support that is, and the sdhci-pci support seems unconditional on type of host controller -- why wouldn't every controller work? Is it (just) because other controller drivers use msleep?
Thanks,
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child