CC: [email protected]
CC: [email protected]
TO: "Chunyan, Zhang," <[email protected]>
CC: Ulf Hansson <[email protected]>
CC: Faiz Abbas <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f6aee505c71bbb035dde146caf5a6abbf3ccbe47
commit: 18e762e3b7a7be764c50957edd2fa0879cb9c67e mmc: sdhci: add support for 
using external DMA devices
date:   5 months ago
:::::: branch date: 2 hours ago
:::::: commit date: 5 months ago
config: i386-randconfig-m021-20200603 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>

New smatch warnings:
drivers/mmc/host/sdhci.c:2922 sdhci_request_done() error: double unlocked 
'host->lock' (orig line 2860)

Old smatch warnings:
drivers/mmc/host/sdhci.c:2941 sdhci_request_done() error: double unlocked 
'host->lock' (orig line 2860)
drivers/mmc/host/sdhci.c:3552 sdhci_runtime_suspend_host() error: double 
unlocked 'host->lock' (orig line 3546)
drivers/mmc/host/sdhci.c:3602 sdhci_runtime_resume_host() error: double 
unlocked 'host->lock' (orig line 3583)

# 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=18e762e3b7a7be764c50957edd2fa0879cb9c67e
git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git remote update linus
git checkout 18e762e3b7a7be764c50957edd2fa0879cb9c67e
vim +2922 drivers/mmc/host/sdhci.c

71e69211eac889 drivers/mmc/host/sdhci.c Guennadi Liakhovetski 2012-12-04  2827  
4e9f8fe5f25f0e drivers/mmc/host/sdhci.c Adrian Hunter         2016-06-29  2828  
static bool sdhci_request_done(struct sdhci_host *host)
d129bceb1d44ed drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  2829  
{
d129bceb1d44ed drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  2830  
        unsigned long flags;
d129bceb1d44ed drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  2831  
        struct mmc_request *mrq;
4e9f8fe5f25f0e drivers/mmc/host/sdhci.c Adrian Hunter         2016-06-29  2832  
        int i;
d129bceb1d44ed drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  2833  
66fd8ad5100b50 drivers/mmc/host/sdhci.c Adrian Hunter         2011-10-03  2834  
        spin_lock_irqsave(&host->lock, flags);
66fd8ad5100b50 drivers/mmc/host/sdhci.c Adrian Hunter         2011-10-03  2835  
4e9f8fe5f25f0e drivers/mmc/host/sdhci.c Adrian Hunter         2016-06-29  2836  
        for (i = 0; i < SDHCI_MAX_MRQS; i++) {
4e9f8fe5f25f0e drivers/mmc/host/sdhci.c Adrian Hunter         2016-06-29  2837  
                mrq = host->mrqs_done[i];
6ebebeab5185f5 drivers/mmc/host/sdhci.c Adrian Hunter         2016-11-02  2838  
                if (mrq)
4e9f8fe5f25f0e drivers/mmc/host/sdhci.c Adrian Hunter         2016-06-29  2839  
                        break;
4e9f8fe5f25f0e drivers/mmc/host/sdhci.c Adrian Hunter         2016-06-29  2840  
        }
d129bceb1d44ed drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  2841  
4e9f8fe5f25f0e drivers/mmc/host/sdhci.c Adrian Hunter         2016-06-29  2842  
        if (!mrq) {
4e9f8fe5f25f0e drivers/mmc/host/sdhci.c Adrian Hunter         2016-06-29  2843  
                spin_unlock_irqrestore(&host->lock, flags);
4e9f8fe5f25f0e drivers/mmc/host/sdhci.c Adrian Hunter         2016-06-29  2844  
                return true;
4e9f8fe5f25f0e drivers/mmc/host/sdhci.c Adrian Hunter         2016-06-29  2845  
        }
d129bceb1d44ed drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  2846  
054cedff5e025a drivers/mmc/host/sdhci.c Russell King          2016-01-26  2847  
        /*
054cedff5e025a drivers/mmc/host/sdhci.c Russell King          2016-01-26  2848  
         * Always unmap the data buffers if they were mapped by
054cedff5e025a drivers/mmc/host/sdhci.c Russell King          2016-01-26  2849  
         * sdhci_prepare_data() whenever we finish with a request.
054cedff5e025a drivers/mmc/host/sdhci.c Russell King          2016-01-26  2850  
         * This avoids leaking DMA mappings on error.
054cedff5e025a drivers/mmc/host/sdhci.c Russell King          2016-01-26  2851  
         */
054cedff5e025a drivers/mmc/host/sdhci.c Russell King          2016-01-26  2852  
        if (host->flags & SDHCI_REQ_USE_DMA) {
054cedff5e025a drivers/mmc/host/sdhci.c Russell King          2016-01-26  2853  
                struct mmc_data *data = mrq->data;
054cedff5e025a drivers/mmc/host/sdhci.c Russell King          2016-01-26  2854  
18e762e3b7a7be drivers/mmc/host/sdhci.c Chunyan Zhang         2020-01-16  2855  
                if (host->use_external_dma && data &&
18e762e3b7a7be drivers/mmc/host/sdhci.c Chunyan Zhang         2020-01-16  2856  
                    (mrq->cmd->error || data->error)) {
18e762e3b7a7be drivers/mmc/host/sdhci.c Chunyan Zhang         2020-01-16  2857  
                        struct dma_chan *chan = 
sdhci_external_dma_channel(host, data);
18e762e3b7a7be drivers/mmc/host/sdhci.c Chunyan Zhang         2020-01-16  2858  
18e762e3b7a7be drivers/mmc/host/sdhci.c Chunyan Zhang         2020-01-16  2859  
                        host->mrqs_done[i] = NULL;
18e762e3b7a7be drivers/mmc/host/sdhci.c Chunyan Zhang         2020-01-16 @2860  
                        spin_unlock_irqrestore(&host->lock, flags);
18e762e3b7a7be drivers/mmc/host/sdhci.c Chunyan Zhang         2020-01-16  2861  
                        dmaengine_terminate_sync(chan);
18e762e3b7a7be drivers/mmc/host/sdhci.c Chunyan Zhang         2020-01-16  2862  
                        spin_lock_irqsave(&host->lock, flags);
18e762e3b7a7be drivers/mmc/host/sdhci.c Chunyan Zhang         2020-01-16  2863  
                        sdhci_set_mrq_done(host, mrq);
18e762e3b7a7be drivers/mmc/host/sdhci.c Chunyan Zhang         2020-01-16  2864  
                }
18e762e3b7a7be drivers/mmc/host/sdhci.c Chunyan Zhang         2020-01-16  2865  
054cedff5e025a drivers/mmc/host/sdhci.c Russell King          2016-01-26  2866  
                if (data && data->host_cookie == COOKIE_MAPPED) {
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2867  
                        if (host->bounce_buffer) {
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2868  
                                /*
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2869  
                                 * On reads, copy the bounced data into the
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2870  
                                 * sglist
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2871  
                                 */
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2872  
                                if (mmc_get_dma_dir(data) == DMA_FROM_DEVICE) {
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2873  
                                        unsigned int length = 
data->bytes_xfered;
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2874  
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2875  
                                        if (length > host->bounce_buffer_size) {
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2876  
                                                pr_err("%s: bounce buffer is %u 
bytes but DMA claims to have transferred %u bytes\n",
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2877  
                                                       mmc_hostname(host->mmc),
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2878  
                                                       host->bounce_buffer_size,
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2879  
                                                       data->bytes_xfered);
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2880  
                                                /* Cap it down and continue */
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2881  
                                                length = 
host->bounce_buffer_size;
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2882  
                                        }
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2883  
                                        dma_sync_single_for_cpu(
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2884  
                                                host->mmc->parent,
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2885  
                                                host->bounce_addr,
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2886  
                                                host->bounce_buffer_size,
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2887  
                                                DMA_FROM_DEVICE);
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2888  
                                        sg_copy_from_buffer(data->sg,
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2889  
                                                data->sg_len,
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2890  
                                                host->bounce_buffer,
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2891  
                                                length);
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2892  
                                } else {
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2893  
                                        /* No copying, just switch ownership */
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2894  
                                        dma_sync_single_for_cpu(
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2895  
                                                host->mmc->parent,
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2896  
                                                host->bounce_addr,
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2897  
                                                host->bounce_buffer_size,
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2898  
                                                mmc_get_dma_dir(data));
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2899  
                                }
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2900  
                        } else {
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2901  
                                /* Unmap the raw data */
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2902  
                                dma_unmap_sg(mmc_dev(host->mmc), data->sg,
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2903  
                                             data->sg_len,
feeef096a770d2 drivers/mmc/host/sdhci.c Heiner Kallweit       2017-03-26  2904  
                                             mmc_get_dma_dir(data));
bd9b902798ab14 drivers/mmc/host/sdhci.c Linus Walleij         2018-01-29  2905  
                        }
054cedff5e025a drivers/mmc/host/sdhci.c Russell King          2016-01-26  2906  
                        data->host_cookie = COOKIE_UNMAPPED;
054cedff5e025a drivers/mmc/host/sdhci.c Russell King          2016-01-26  2907  
                }
054cedff5e025a drivers/mmc/host/sdhci.c Russell King          2016-01-26  2908  
        }
054cedff5e025a drivers/mmc/host/sdhci.c Russell King          2016-01-26  2909  
d129bceb1d44ed drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  2910  
        /*
d129bceb1d44ed drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  2911  
         * The controller needs a reset of internal state machines
d129bceb1d44ed drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  2912  
         * upon error conditions.
d129bceb1d44ed drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  2913  
         */
0cc563ce5436dc drivers/mmc/host/sdhci.c Adrian Hunter         2016-06-29  2914  
        if (sdhci_needs_reset(host, mrq)) {
6ebebeab5185f5 drivers/mmc/host/sdhci.c Adrian Hunter         2016-11-02  2915  
                /*
6ebebeab5185f5 drivers/mmc/host/sdhci.c Adrian Hunter         2016-11-02  2916  
                 * Do not finish until command and data lines are available for
6ebebeab5185f5 drivers/mmc/host/sdhci.c Adrian Hunter         2016-11-02  2917  
                 * reset. Note there can only be one other mrq, so it cannot
6ebebeab5185f5 drivers/mmc/host/sdhci.c Adrian Hunter         2016-11-02  2918  
                 * also be in mrqs_done, otherwise host->cmd and host->data_cmd
6ebebeab5185f5 drivers/mmc/host/sdhci.c Adrian Hunter         2016-11-02  2919  
                 * would both be null.
6ebebeab5185f5 drivers/mmc/host/sdhci.c Adrian Hunter         2016-11-02  2920  
                 */
6ebebeab5185f5 drivers/mmc/host/sdhci.c Adrian Hunter         2016-11-02  2921  
                if (host->cmd || host->data_cmd) {
6ebebeab5185f5 drivers/mmc/host/sdhci.c Adrian Hunter         2016-11-02 @2922  
                        spin_unlock_irqrestore(&host->lock, flags);
6ebebeab5185f5 drivers/mmc/host/sdhci.c Adrian Hunter         2016-11-02  2923  
                        return true;
6ebebeab5185f5 drivers/mmc/host/sdhci.c Adrian Hunter         2016-11-02  2924  
                }
6ebebeab5185f5 drivers/mmc/host/sdhci.c Adrian Hunter         2016-11-02  2925  
645289dca50212 drivers/mmc/sdhci.c      Pierre Ossman         2006-06-30  2926  
                /* Some controllers need this kick or reset won't work here */
8213af3b7a4059 drivers/mmc/host/sdhci.c Andy Shevchenko       2013-01-07  2927  
                if (host->quirks & SDHCI_QUIRK_CLOCK_BEFORE_RESET)
645289dca50212 drivers/mmc/sdhci.c      Pierre Ossman         2006-06-30  2928  
                        /* This is to force an update */
1771059cf5f9c0 drivers/mmc/host/sdhci.c Russell King          2014-04-25  2929  
                        host->ops->set_clock(host, host->clock);
645289dca50212 drivers/mmc/sdhci.c      Pierre Ossman         2006-06-30  2930  
645289dca50212 drivers/mmc/sdhci.c      Pierre Ossman         2006-06-30  2931  
                /* Spec says we should do both at the same time, but Ricoh
645289dca50212 drivers/mmc/sdhci.c      Pierre Ossman         2006-06-30  2932  
                   controllers do not like that. */
03231f9b781f24 drivers/mmc/host/sdhci.c Russell King          2014-04-25  2933  
                sdhci_do_reset(host, SDHCI_RESET_CMD);
03231f9b781f24 drivers/mmc/host/sdhci.c Russell King          2014-04-25  2934  
                sdhci_do_reset(host, SDHCI_RESET_DATA);
ed1563de0bc90e drivers/mmc/host/sdhci.c Adrian Hunter         2016-06-29  2935  
ed1563de0bc90e drivers/mmc/host/sdhci.c Adrian Hunter         2016-06-29  2936  
                host->pending_reset = false;
d129bceb1d44ed drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  2937  
        }
d129bceb1d44ed drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  2938  
6ebebeab5185f5 drivers/mmc/host/sdhci.c Adrian Hunter         2016-11-02  2939  
        host->mrqs_done[i] = NULL;
6ebebeab5185f5 drivers/mmc/host/sdhci.c Adrian Hunter         2016-11-02  2940  
d129bceb1d44ed drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  2941  
        spin_unlock_irqrestore(&host->lock, flags);
d129bceb1d44ed drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  2942  
d129bceb1d44ed drivers/mmc/sdhci.c      Pierre Ossman         2006-03-24  2943  
        mmc_request_done(host->mmc, mrq);
4e9f8fe5f25f0e drivers/mmc/host/sdhci.c Adrian Hunter         2016-06-29  2944  
4e9f8fe5f25f0e drivers/mmc/host/sdhci.c Adrian Hunter         2016-06-29  2945  
        return false;
4e9f8fe5f25f0e drivers/mmc/host/sdhci.c Adrian Hunter         2016-06-29  2946  
}
4e9f8fe5f25f0e drivers/mmc/host/sdhci.c Adrian Hunter         2016-06-29  2947  

:::::: The code at line 2922 was first introduced by commit
:::::: 6ebebeab5185f50d55c6a24d0abe47e5dac1b191 mmc: sdhci: Fix CMD line reset 
interfering with ongoing data transfer

:::::: TO: Adrian Hunter <[email protected]>
:::::: CC: Ulf Hansson <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to