diff options
author | Wolfram Sang <wsa+renesas@sang-engineering.com> | 2019-02-19 11:39:46 -0500 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2019-02-23 04:34:08 -0500 |
commit | bb6bdd51c838e8d046a84502f12619de4fd58d69 (patch) | |
tree | 45616a63ec1871c1ec0f7e22e9abd3c489a86ade /drivers/i2c | |
parent | 63e57b6f191db99ffdd0dc6c7b9ee6b2cf7abb04 (diff) |
i2c: gpio: fault-injector: add 'inject_panic' injector
Add a fault injector simulating a Kernel panic happening after starting
a transfer. Read the docs for its usage.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-gpio.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c index 76e43783f50f..bba5c4627de3 100644 --- a/drivers/i2c/busses/i2c-gpio.c +++ b/drivers/i2c/busses/i2c-gpio.c | |||
@@ -231,6 +231,32 @@ static int fops_lose_arbitration_set(void *data, u64 duration) | |||
231 | } | 231 | } |
232 | DEFINE_DEBUGFS_ATTRIBUTE(fops_lose_arbitration, NULL, fops_lose_arbitration_set, "%llu\n"); | 232 | DEFINE_DEBUGFS_ATTRIBUTE(fops_lose_arbitration, NULL, fops_lose_arbitration_set, "%llu\n"); |
233 | 233 | ||
234 | static irqreturn_t inject_panic_irq(int irq, void *dev_id) | ||
235 | { | ||
236 | struct i2c_gpio_private_data *priv = dev_id; | ||
237 | |||
238 | udelay(priv->scl_irq_data); | ||
239 | panic("I2C fault injector induced panic"); | ||
240 | |||
241 | return IRQ_HANDLED; | ||
242 | } | ||
243 | |||
244 | static int fops_inject_panic_set(void *data, u64 duration) | ||
245 | { | ||
246 | struct i2c_gpio_private_data *priv = data; | ||
247 | |||
248 | if (duration > 100 * 1000) | ||
249 | return -EINVAL; | ||
250 | |||
251 | priv->scl_irq_data = duration; | ||
252 | /* | ||
253 | * Interrupt on falling SCL. This ensures that the master under test has | ||
254 | * really started the transfer. | ||
255 | */ | ||
256 | return i2c_gpio_fi_act_on_scl_irq(priv, inject_panic_irq); | ||
257 | } | ||
258 | DEFINE_DEBUGFS_ATTRIBUTE(fops_inject_panic, NULL, fops_inject_panic_set, "%llu\n"); | ||
259 | |||
234 | static void i2c_gpio_fault_injector_init(struct platform_device *pdev) | 260 | static void i2c_gpio_fault_injector_init(struct platform_device *pdev) |
235 | { | 261 | { |
236 | struct i2c_gpio_private_data *priv = platform_get_drvdata(pdev); | 262 | struct i2c_gpio_private_data *priv = platform_get_drvdata(pdev); |
@@ -256,9 +282,12 @@ static void i2c_gpio_fault_injector_init(struct platform_device *pdev) | |||
256 | priv, &fops_incomplete_addr_phase); | 282 | priv, &fops_incomplete_addr_phase); |
257 | debugfs_create_file_unsafe("incomplete_write_byte", 0200, priv->debug_dir, | 283 | debugfs_create_file_unsafe("incomplete_write_byte", 0200, priv->debug_dir, |
258 | priv, &fops_incomplete_write_byte); | 284 | priv, &fops_incomplete_write_byte); |
259 | if (priv->bit_data.getscl) | 285 | if (priv->bit_data.getscl) { |
286 | debugfs_create_file_unsafe("inject_panic", 0200, priv->debug_dir, | ||
287 | priv, &fops_inject_panic); | ||
260 | debugfs_create_file_unsafe("lose_arbitration", 0200, priv->debug_dir, | 288 | debugfs_create_file_unsafe("lose_arbitration", 0200, priv->debug_dir, |
261 | priv, &fops_lose_arbitration); | 289 | priv, &fops_lose_arbitration); |
290 | } | ||
262 | debugfs_create_file_unsafe("scl", 0600, priv->debug_dir, priv, &fops_scl); | 291 | debugfs_create_file_unsafe("scl", 0600, priv->debug_dir, priv, &fops_scl); |
263 | debugfs_create_file_unsafe("sda", 0600, priv->debug_dir, priv, &fops_sda); | 292 | debugfs_create_file_unsafe("sda", 0600, priv->debug_dir, priv, &fops_sda); |
264 | } | 293 | } |