Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4845658img; Tue, 26 Mar 2019 18:52:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQzpakpdwL57YqYF5LIAwQ58+D7sVqxcQwEjZVUY2AvumbquYGh04M/c3H9z5HIaQGC6Vm X-Received: by 2002:a62:469a:: with SMTP id o26mr33762221pfi.251.1553651525867; Tue, 26 Mar 2019 18:52:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553651525; cv=none; d=google.com; s=arc-20160816; b=sBl589IzM73bcjT9hcuzEH+M+p2K1dXt1YZ51jOJozi/vo4M09gjWKzvCWcFIy5R5o dlxruiXgVzumDqkQ9o6noqSSdnoIgsAPZim+En8FGiVzx9TU+vMfTDJ7pI5l7JkfJxt7 L1QDMVhBCIvZ1vpiMxg4tlR9qD5fl6GDZa3oASgFL0zyz4N9GdVhvPFb0dp97Cia1RyG kg+HJOQN47K+uhKz/Cbt2HrNJ+hPyx6fGZ28F+5y3pPt0J/6uZmux1//VxX8E4sHK4Ks X5VAb/hs51bnMHPYIxnOFToAwuZjZQ/TM/ZDMWVQ3Ay7GRxAFEPsVBfSpWsQjMpMykfk qTTw== 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=gmSbYUaITpcXSdME+U0+kal7ZNf0Gfb6hH7q8/011WE=; b=UPwgCG1TCM9jI/uZsPEt+CQhVFudCVqmsjA9ar8Vjc7G/krxxyo6P9EgaxBOqkgAd5 ymOWqiZtf0WVXUa9hq4Ts3lR3E2Ny0W+AeVyS2fq25Nz/6qp5Swu//hKV+yaovGPmqHv LE418TCmKLG+maRuh59fJ00+o9TqCzcQtwldOZIqK77PJYNzFSXgtgtlTunwZCnZLH5Q sJjJfvxyPXS9IEECUhoTwOooDDJbj4HNbJfKg3FAlnQpQ9U3l3hW9IKr3LbDhSWyv1Ke eVS8dlcZj2X+9XGdrPMxe7A2XtWdShOgdQKUYdmaocZbMUT8UzOC9GTz5dyvQXx98qF5 pi8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Nqu6cu7o; 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 o35si14790141pgb.551.2019.03.26.18.51.50; Tue, 26 Mar 2019 18:52:05 -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=Nqu6cu7o; 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 S1732617AbfC0BvJ (ORCPT + 99 others); Tue, 26 Mar 2019 21:51:09 -0400 Received: from mail-it1-f196.google.com ([209.85.166.196]:40151 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726922AbfC0BvG (ORCPT ); Tue, 26 Mar 2019 21:51:06 -0400 Received: by mail-it1-f196.google.com with SMTP id y63so11894488itb.5; Tue, 26 Mar 2019 18:51:06 -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=gmSbYUaITpcXSdME+U0+kal7ZNf0Gfb6hH7q8/011WE=; b=Nqu6cu7os2lFdqNtWLjjfqRWrdkEveSAjBmYSF4f6lE1STeKnk6bHJPWqMH6ZVIcKC hHsaCu+zSpg8Z49Pu7GD0dr09Pdr+2j3MQugkisGAUgHqhh+M6NXzbK0tT+M/2yjan7j NImC5b8MFxMUD65h2cStTmk0Q9/Fr/l4YExe4YfhfFyKgs4vD/AkFwrw0s7kQeCrQlDC 44+oobfIx5Frp/dNZnLF4VeYC2SiTwsC+zaJnsAbCydQ8LcqG+tl5uhEu2y9+PzeuTuh pvhfQ7uLuclKj8eGaS0oy0r0Crt7lw1ROP7MtYSGJJrREzlXNxMdvFA4rp4lHc26W4Ae OsOw== 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=gmSbYUaITpcXSdME+U0+kal7ZNf0Gfb6hH7q8/011WE=; b=ASgIyl4bX5SyuSWaZn8j+KbW0oLn7gv3rosp7ijxRiIyij/85EzoO+Imb5MJJqTL5X z75I8J+XuWzEZkrjYZVKzztdr+KlEktNcWx2NPFvgrRT4YHLrg9neKZSQn2+28Lr3/cH rP7dn6tJYgrF5oxjv3f6r8ijsOsekjvcpTWqDra5RRyvfQpERZE75iIKXFTDUKgd2epf WZhMZyZpJ7+J7QqX1tiX3+GVyrusP0wrydNQ9pRzN4QTPpPrFJ2ll5A7YFGfUj5d2uAa PqZkq0wcpmldOvnBNO7gt+ubUBTjzm8UYio9qNSju5Np2KPX63SuAgtUWYvwhjTEoLaR +fkQ== X-Gm-Message-State: APjAAAXuSgcEGmfZ4AtfNzU7YVGONRpiTiEDJVXg18R3UgPuWI+yatud mQqZN2pULkmHqXp1E7abvVU= X-Received: by 2002:a24:f68a:: with SMTP id u132mr1691036ith.45.1553651465975; Tue, 26 Mar 2019 18:51:05 -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 e27sm4550040ioc.14.2019.03.26.18.51.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Mar 2019 18:51:05 -0700 (PDT) From: George Hilliard To: Greg Kroah-Hartman Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, George Hilliard Subject: [PATCH v5 2/2] staging: mt7621-mmc: Initialize completions a single time during probe Date: Tue, 26 Mar 2019 19:50:57 -0600 Message-Id: <20190327015057.9568-3-thirtythreeforty@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190327015057.9568-1-thirtythreeforty@gmail.com> References: <20190327015057.9568-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 v5: *Correct* whitespace 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..9a4b27562cd0 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