Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4383590img; Tue, 26 Mar 2019 08:22:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqyM+9YvYPqlUkK2yKRHmerj9rOcAyinQqowSDXQheLiuZZ1HGz+kOXq/wJvsL4XCaDVV62U X-Received: by 2002:a62:a509:: with SMTP id v9mr31173892pfm.64.1553613775912; Tue, 26 Mar 2019 08:22:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553613775; cv=none; d=google.com; s=arc-20160816; b=S287pndptlhATdlblRj8Sn8xaAKa8eao3PG/HidhCUXQktmfcTtoLBBEitH7mAk7XJ tAqmlOwr0K0eWVnvdiBrEUKbpY7m7XkXj9S7tbBycAXRwm4YFYvk4DS/qE2le7ZXdSpW xJxMjakyGJfWsPzORwp5eHrVLHIckRJvmiIpWaIW3B4Ug9q2An8ecfEWGAP0+TYcOhw6 vEuT80kM1jGjlZerQJGjWu5ZdEivyW+6sowaAxcGAIBnjMN/T8CG6iFCfeOwLEjAUolz KRtIx8KKcuSBunJPwgH0vKC92+ROB2NkD0Ss9sFlT0uxwrcaP05+2NQXDAQT3JumAvAQ HK2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zNDW/JmLRYmJUskWsM7sYQ9RMDYDxyLGR5SNcEkiM2c=; b=UYiNBIMSotmOMhtCeuhHK8/75SgH8KQguZiF/cFVNcEOstbGeuPp9HwKGLuBAhYdrj PHttaYwgiUe3dxqGKA4GQHV+41Kajad24Xq+jvmP5DgYz4Qw65//f/ySMxbc58sh/4Op W/d7wH/AQeT45zQ42PPPX4SNabp5r8HA9ZttKbMaMRK1g2vGddvq3txffK/tObheeLPI PyNUaEL/uAtdiVc1/SfnkQC+1eUtbYqZvrhZnjehNqCFrCGRJJBxKeyBnwX8WCol7+Fj m02qjIQ637KRaUwIsBY0DT08z5fnKj8orJN1IwLQCnU95WXUDhv/cKwIX9al9aqz/5c+ p9jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qPUhDFW0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si17799638plg.3.2019.03.26.08.22.40; Tue, 26 Mar 2019 08:22:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qPUhDFW0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732138AbfCZPVy (ORCPT + 99 others); Tue, 26 Mar 2019 11:21:54 -0400 Received: from mail-it1-f196.google.com ([209.85.166.196]:39738 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732128AbfCZPVv (ORCPT ); Tue, 26 Mar 2019 11:21:51 -0400 Received: by mail-it1-f196.google.com with SMTP id 139so20617550ita.4; Tue, 26 Mar 2019 08:21:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zNDW/JmLRYmJUskWsM7sYQ9RMDYDxyLGR5SNcEkiM2c=; b=qPUhDFW0YWT2mMdOecOhI21kFtySIqtkIBHaIoP8KWwDixZPVv8MJNC7trbNDOvadr 4kButM8JLmArS934E+vTO6e9MIBO5W7FuvMj763tnoz0MlE4fz097zlupCE8t02wnJds Fo8CJeeH8U1zMjhFpMcmpdqPRhmharIwW0J044O2JLrDnmgjEwzAjK/0NL6diRmObjNt 9/wWubkKMCryYstz3Bej9XVRI71ilhOv4HcmhPtEk1p/T2+iEm4f72N6fEOqETA8V3kX 4w3MSlq0E2cFDSfAE90SoyFE2fKWxDgZzXRcVu42M53EOU2oIfZ+M6kJBpqWqUqkHv2W L1Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zNDW/JmLRYmJUskWsM7sYQ9RMDYDxyLGR5SNcEkiM2c=; b=fAfD2+21SwyU14+d07/uumw1ZjN8mPTd0fpbscPz9RhjnwDzHx9Q9UAaGMczzwL8Iy CyaZ6ADyQTrKcoFCNxGoYyyGd1lBG2d1PUVAmdUKZfFntdiU5/qk0O1X3jqnCsjHqEXA T3bUhT6+FyrSEvWJohiC5Po/V/Weybm5mgdBgtcyW+IfYrMHP3tzc/p9PVZAFJplgHLQ JzvUScwhyWfJ2Gt5bKK/fqgMEYslU7cV7jj+f0yRr3x2mjK6RSYJcfziPpqH1wrLYQXw 0BGSNS3WCos7qWr8dDNH7DRkONTBjhPIM5akRiECgxGC6j7zpDyvP9XoCUzwWJ/fWvh1 ERCg== X-Gm-Message-State: APjAAAUrJZP5ZNqmnIMzSK1sxNS8dtGoyppaObCel9iGKb4SVjtaWHst fo91GLqZNSaPcnpa47dkUZukozSgszo= X-Received: by 2002:a24:287:: with SMTP id 129mr667516itu.114.1553613710753; Tue, 26 Mar 2019 08:21:50 -0700 (PDT) Received: from localhost.localdomain (c-73-242-244-99.hsd1.nm.comcast.net. [73.242.244.99]) by smtp.gmail.com with ESMTPSA id w14sm6861045iol.32.2019.03.26.08.21.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Mar 2019 08:21:50 -0700 (PDT) From: George Hilliard To: Greg Kroah-Hartman Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, George Hilliard Subject: [PATCH v4 2/2] staging: mt7621-mmc: Initialize completions a single time during probe Date: Tue, 26 Mar 2019 09:21:39 -0600 Message-Id: <20190326152139.18609-3-thirtythreeforty@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190326152139.18609-1-thirtythreeforty@gmail.com> References: <20190326152139.18609-1-thirtythreeforty@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The module was initializing completions whenever it was going to wait on them, and not when the completion was allocated. This is incorrect according to the completion docs: Calling init_completion() on the same completion object twice is most likely a bug [...] Re-initialization is also unnecessary because the module never uses complete_all(). Fix this by only ever initializing the completion a single time, and log if the completions are not consumed as intended (this is not a fatal problem, but should not go unnoticed). Signed-off-by: George Hilliard --- v2: rewrite of v1 v3: Remove BUG_ON() calls v4: Indent style fixup drivers/staging/mt7621-mmc/sd.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index e346167754bd..ed63bd3ba6cc 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -466,7 +466,11 @@ static unsigned int msdc_command_start(struct msdc_host *host, host->cmd = cmd; host->cmd_rsp = resp; - init_completion(&host->cmd_done); + // The completion should have been consumed by the previous command + // response handler, because the mmc requests should be serialized + if(completion_done(&host->cmd_done)) + dev_err(mmc_dev(host->mmc), + "previous command was not handled\n"); sdr_set_bits(host->base + MSDC_INTEN, wints); sdc_send_cmd(rawcmd, cmd->arg); @@ -488,7 +492,6 @@ static unsigned int msdc_command_resp(struct msdc_host *host, MSDC_INT_ACMD19_DONE; BUG_ON(in_interrupt()); - //init_completion(&host->cmd_done); //sdr_set_bits(host->base + MSDC_INTEN, wints); spin_unlock(&host->lock); @@ -670,7 +673,13 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) //msdc_clr_fifo(host); /* no need */ msdc_dma_on(); /* enable DMA mode first!! */ - init_completion(&host->xfer_done); + + // The completion should have been consumed by the previous + // xfer response handler, because the mmc requests should be + // serialized + if(completion_done(&host->cmd_done)) + dev_err(mmc_dev(host->mmc), + "previous transfer was not handled\n"); /* start the command first*/ if (msdc_command_start(host, cmd, CMD_TIMEOUT) != 0) @@ -696,7 +705,6 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) /* for read, the data coming too fast, then CRC error * start DMA no business with CRC. */ - //init_completion(&host->xfer_done); msdc_dma_start(host); spin_unlock(&host->lock); @@ -1687,6 +1695,8 @@ static int msdc_drv_probe(struct platform_device *pdev) } msdc_init_gpd_bd(host, &host->dma); + init_completion(&host->cmd_done); + init_completion(&host->xfer_done); INIT_DELAYED_WORK(&host->card_delaywork, msdc_tasklet_card); spin_lock_init(&host->lock); msdc_init_hw(host); -- 2.21.0