* [bug report] mmc: sdhci: use WP GPIO in sdhci_check_ro()
@ 2021-12-17 13:33 Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2021-12-17 13:33 UTC (permalink / raw)
To: thomas.petazzoni; +Cc: linux-mmc
Hello Thomas Petazzoni,
The patch 6d5cd068ee59: "mmc: sdhci: use WP GPIO in sdhci_check_ro()"
from Feb 12, 2019, leads to the following Smatch static checker
warning:
drivers/mmc/core/slot-gpio.c:69 mmc_gpio_get_ro()
warn: sleeping in atomic context
drivers/mmc/host/sdhci.c
2459 static int sdhci_check_ro(struct sdhci_host *host)
2460 {
2461 unsigned long flags;
2462 int is_readonly;
2463
2464 spin_lock_irqsave(&host->lock, flags);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Holding a spinlock.
2465
2466 if (host->flags & SDHCI_DEVICE_DEAD)
2467 is_readonly = 0;
2468 else if (host->ops->get_ro)
2469 is_readonly = host->ops->get_ro(host);
2470 else if (mmc_can_gpio_ro(host->mmc))
2471 is_readonly = mmc_gpio_get_ro(host->mmc);
^^^^^^^^^^^^^^^^^^^^^^^^^^
This is a sleeping function. See below.
2472 else
2473 is_readonly = !(sdhci_readl(host, SDHCI_PRESENT_STATE)
2474 & SDHCI_WRITE_PROTECT);
2475
2476 spin_unlock_irqrestore(&host->lock, flags);
2477
2478 /* This quirk needs to be replaced by a callback-function later */
2479 return host->quirks & SDHCI_QUIRK_INVERTED_WRITE_PROTECT ?
2480 !is_readonly : is_readonly;
2481 }
drivers/mmc/core/slot-gpio.c
62 int mmc_gpio_get_ro(struct mmc_host *host)
63 {
64 struct mmc_gpio *ctx = host->slot.handler_priv;
65
66 if (!ctx || !ctx->ro_gpio)
67 return -ENOSYS;
68
--> 69 return gpiod_get_value_cansleep(ctx->ro_gpio);
^^^^^^^^
70 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* [bug report] mmc: sdhci: use WP GPIO in sdhci_check_ro()
@ 2021-07-27 8:50 Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2021-07-27 8:50 UTC (permalink / raw)
To: thomas.petazzoni; +Cc: linux-gpio
Hello Thomas Petazzoni,
The patch 6d5cd068ee59: "mmc: sdhci: use WP GPIO in sdhci_check_ro()"
from Feb 12, 2019, leads to the following static checker warning:
drivers/gpio/gpiolib.c:3287 gpiod_get_value_cansleep()
warn: sleeping in atomic context
drivers/mmc/host/sdhci.c
2424 static int sdhci_check_ro(struct sdhci_host *host)
2425 {
2426 unsigned long flags;
2427 int is_readonly;
2428
2429 spin_lock_irqsave(&host->lock, flags);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
We're holding a spin lock.
2430
2431 if (host->flags & SDHCI_DEVICE_DEAD)
2432 is_readonly = 0;
2433 else if (host->ops->get_ro)
2434 is_readonly = host->ops->get_ro(host);
2435 else if (mmc_can_gpio_ro(host->mmc))
2436 is_readonly = mmc_gpio_get_ro(host->mmc);
^^^^^^^^^^^^^^^^^^^^^^^^^^
The mmc_gpio_get_ro() function calls gpiod_get_value_cansleep() which,
as the name suggests, can sleep.
2437 else
2438 is_readonly = !(sdhci_readl(host, SDHCI_PRESENT_STATE)
2439 & SDHCI_WRITE_PROTECT);
2440
2441 spin_unlock_irqrestore(&host->lock, flags);
2442
2443 /* This quirk needs to be replaced by a callback-function later */
2444 return host->quirks & SDHCI_QUIRK_INVERTED_WRITE_PROTECT ?
2445 !is_readonly : is_readonly;
2446 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-12-17 13:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-17 13:33 [bug report] mmc: sdhci: use WP GPIO in sdhci_check_ro() Dan Carpenter
-- strict thread matches above, loose matches on Subject: below --
2021-07-27 8:50 Dan Carpenter
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.