Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp183395imp; Tue, 19 Feb 2019 21:20:34 -0800 (PST) X-Google-Smtp-Source: AHgI3IZo97DxJkVsL6DIFhjx22MQ9CDJmARcpx2TsrFWLoAaLltV8iqjmTiQMxMqc7oe0zpZLkpJ X-Received: by 2002:a65:568b:: with SMTP id v11mr9277838pgs.23.1550640034390; Tue, 19 Feb 2019 21:20:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550640034; cv=none; d=google.com; s=arc-20160816; b=KJLx1tbPwbE2uxrT8SzwT5bf66AF+uDEMHS9sJIddQ0sRHvRDPbyfPJsFxFAdyZqiu LYnlIEu6TGFdftydlj5E1kHRQoAjg6fMgqZcK2eGHjltlPvuPAH9cxUtQa7K2ZWFz9hI JZXdTzogyqLvFWoucNkaVbw7LMn1bbcJpI5SzLRoIQ262fg5Sa+xc80sXF9q5wdbRSBX NJss/ZvLZ9FpuO+UOkhbvTuBE7Zs0PaRsHjbffjCn5VPMEGgtfgpPamXqQmVv0aSeaAc m05HFlpJPWzCnBh5lvup9Uo5CZrdjmWX872QjLhXYyLeAl3Qb7iNDd1I/08gNzO57Cvf ppfA== 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=Wowct3K4dPgXXojBuflSXWxnwjNKq9pFZQYObBOGVPY=; b=WfOfpC3gc+fg3VlA6vakPjjfwrd/fyie+RbMFe5bIgBrlx3TkIiHbgZMqeDgEUx5oI ou8eDQCgP1BAWVunDjdnmD0a5scTE7PqaRcgaWLiD/GxlR4fR+qCIqYlpJO1qgol4RVv rVkWGKfBnwoX7NrhcQPBZG6RKDmNSXQC7Dp7D1VfxRKkzPUCLGie352TAnyXsitbhNQJ 3rIS9Gut4IJhvSepLE0ORdMUJ1G6K2tFoDUJhPFQIN2Vh9hYAAGFNl6UC5XEauLg0XYl BxO0SqwPGsUV8CPysAdbEH+Qc1oBa4tqqF19Ig5kxNVdFl8cgrAOF5kQfOKB+0/J/pDy Wlrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="ZBziC1/g"; 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 e6si17736024pgp.504.2019.02.19.21.20.19; Tue, 19 Feb 2019 21:20:34 -0800 (PST) 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="ZBziC1/g"; 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 S1726818AbfBTFSR (ORCPT + 99 others); Wed, 20 Feb 2019 00:18:17 -0500 Received: from mail-it1-f196.google.com ([209.85.166.196]:53682 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726687AbfBTFSP (ORCPT ); Wed, 20 Feb 2019 00:18:15 -0500 Received: by mail-it1-f196.google.com with SMTP id x131so12432800itc.3 for ; Tue, 19 Feb 2019 21:18:14 -0800 (PST) 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=Wowct3K4dPgXXojBuflSXWxnwjNKq9pFZQYObBOGVPY=; b=ZBziC1/glnjFoqs0CBX0q8trfAhqGB5rGedmZ0pVBX6kwzp2TW5xwhOEpZrZtABD+Y UDC3UmnhgbwyYJU8xyQGtM94sUx59pvd5eIlOBL/zeNMMEvgfe9+E8fuEK8XR2UH+wjR SwPH0pEVv4TS/t84DlNXBONuj4QXkJaF63ypO1f8+pvMEITHWRDQKRlj2Qnl2tJtF+22 /feVHaorX4yq6+2eGZrIALlWR7fSH9141WnkxOd0QzZcUdD4M9LUSfbmFnKARYnKmiH9 v6jnYXpZMfPt+Oqkb1eTzhGNLqO56Jms1/YM+tXahfxeoWs/JbTR1fHlE+DWTvtZdcEE asQw== 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=Wowct3K4dPgXXojBuflSXWxnwjNKq9pFZQYObBOGVPY=; b=NJvt5lIh4GA+gzuwOmScy7HMPCPxCBJDptVEd58dTID068RZI3rTdowpOi5zLB2MOq WiEyVby0OlhJH/YaZbh1KKZLasK7sEJqDAPDpH90Ob8bQ8yWDAd+yI3LRPWjKbm5LKvh GJHQNJNZv1X7fLdCY7l5Kd8RpYG/6t7WoZIqlUEuapIUocqiT/ZCgsSDzcZrPnAlc9Vi QZkOnt5d1dOQGri3wfiLJq1IpFdCELbQGkJDGQ+RTzEFppVTHyCwAO8fpAjLg5mONY4r 6lw6krG+GqYHg8RS79lIIYQns0nBLikaF+TD2BVZyxz4RxLkiCulfiMXisBi+Ozm2eYT x56Q== X-Gm-Message-State: AHQUAuac8zoGELLcb7uqHqRSB/qxYsOHB24iFN+ZXu+h6GehfNTQ4e3B CJxyVpyYFWyoHhCnoLFSzFM= X-Received: by 2002:a24:a81:: with SMTP id 123mr4379680itw.43.1550639893900; Tue, 19 Feb 2019 21:18:13 -0800 (PST) Received: from localhost.localdomain (c-73-242-244-99.hsd1.nm.comcast.net. [73.242.244.99]) by smtp.gmail.com with ESMTPSA id k64sm2297550itb.7.2019.02.19.21.18.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Feb 2019 21:18:13 -0800 (PST) From: George Hilliard To: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org, Neil Brown , George Hilliard Subject: [PATCH 07/10] staging: mt7621-mmc: Initialize completions a single time during probe Date: Tue, 19 Feb 2019 22:17:51 -0700 Message-Id: <20190220051754.12195-8-thirtythreeforty@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190220051754.12195-1-thirtythreeforty@gmail.com> References: <20190220051754.12195-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. Signed-off-by: George Hilliard --- drivers/staging/mt7621-mmc/sd.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index f12f9d6611c9..942c0d63d710 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -468,7 +468,9 @@ 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 + BUG_ON(completion_done(&host->cmd_done)); sdr_set_bits(host->base + MSDC_INTEN, wints); sdc_send_cmd(rawcmd, cmd->arg); @@ -490,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); @@ -674,7 +675,10 @@ 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 + BUG_ON(completion_done(&host->xfer_done)); /* start the command first*/ if (msdc_command_start(host, cmd, CMD_TIMEOUT) != 0) @@ -693,7 +697,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); @@ -1708,6 +1711,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.20.1