From patchwork Sun Feb 15 14:46:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Kaneko X-Patchwork-Id: 5830161 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 779D1BF440 for ; Sun, 15 Feb 2015 14:47:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D1DBB200DB for ; Sun, 15 Feb 2015 14:47:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 259DA20219 for ; Sun, 15 Feb 2015 14:47:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755137AbbBOOrN (ORCPT ); Sun, 15 Feb 2015 09:47:13 -0500 Received: from mail-pd0-f169.google.com ([209.85.192.169]:33803 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754998AbbBOOrN (ORCPT ); Sun, 15 Feb 2015 09:47:13 -0500 Received: by pdjg10 with SMTP id g10so29742594pdj.1; Sun, 15 Feb 2015 06:47:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=WjEzfoBvsBbSlyDSUFAKNS8Ji8Cv8S9pWgbyyhyeaTo=; b=sydL4bH6yAqvxDTMJ+Ch15VdodLYd0eUFv7kpsvcqHJh0EhewiDh0a8DWWs3WKvxww HR1IJLwJSS0cQkX3QxahiE8GvyEXlh2pxkiEQ2U0Y1tZCvl4VD6u6iKkjSSXFpaq8U3T cdKWio6iX5Al5ZB9+cEHXwlj7GrgDtpmt1f/74AMMHRojeCEjtBeBgz0olAJ0DR4DxD+ c7Q+DQVjvIOnzmezWGK2oJENUCHv+SIY2MMfeup8qbVs5yi9JsQaeYO25KUS3Wjyjx1e CjEFVJOlEC5CQ7DTjKFpPL1fNDhBOaI6h7bjJr7qo3Tsmkx+c/4NYqasWB7htbZ1Bshs 7sQQ== X-Received: by 10.66.65.195 with SMTP id z3mr31657585pas.10.1424011632645; Sun, 15 Feb 2015 06:47:12 -0800 (PST) Received: from localhost.localdomain (KD118152108246.ppp-bb.dion.ne.jp. [118.152.108.246]) by mx.google.com with ESMTPSA id d11sm12061752pdk.26.2015.02.15.06.47.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 15 Feb 2015 06:47:11 -0800 (PST) From: Yoshihiro Kaneko To: linux-mmc@vger.kernel.org Cc: Chris Ball , Ulf Hansson , Simon Horman , Magnus Damm , Kuninori Morimoto , linux-sh@vger.kernel.org Subject: [PATCH/RFC] mmc: sh_mmcif: Add exclusion between cmd and interrupt Date: Sun, 15 Feb 2015 23:46:46 +0900 Message-Id: <1424011607-3682-1-git-send-email-ykaneko0929@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kouichi Tomita A command end interrupt should not be processed between command issue and setting of wait_for flag. It expects already the flag to be set. Therefore the exclusive control was added. Signed-off-by: Kouichi Tomita Signed-off-by: Yoshihiro Kaneko --- This patch is based on next branch of Chris Ball's mmc tree. drivers/mmc/host/sh_mmcif.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c index 7d9d6a3..e5d0b42 100644 --- a/drivers/mmc/host/sh_mmcif.c +++ b/drivers/mmc/host/sh_mmcif.c @@ -875,6 +875,7 @@ static void sh_mmcif_start_cmd(struct sh_mmcif_host *host, struct mmc_command *cmd = mrq->cmd; u32 opc = cmd->opcode; u32 mask; + unsigned long flags; switch (opc) { /* response busy check */ @@ -909,10 +910,12 @@ static void sh_mmcif_start_cmd(struct sh_mmcif_host *host, /* set arg */ sh_mmcif_writel(host->addr, MMCIF_CE_ARG, cmd->arg); /* set cmd */ + spin_lock_irqsave(&host->lock, flags); sh_mmcif_writel(host->addr, MMCIF_CE_CMD_SET, opc); host->wait_for = MMCIF_WAIT_FOR_CMD; schedule_delayed_work(&host->timeout_work, host->timeout); + spin_unlock_irqrestore(&host->lock, flags); } static void sh_mmcif_stop_cmd(struct sh_mmcif_host *host, @@ -1171,6 +1174,12 @@ static irqreturn_t sh_mmcif_irqt(int irq, void *dev_id) struct sh_mmcif_host *host = dev_id; struct mmc_request *mrq; bool wait = false; + unsigned long flags; + int wait_work; + + spin_lock_irqsave(&host->lock, flags); + wait_work = host->wait_for; + spin_unlock_irqrestore(&host->lock, flags); cancel_delayed_work_sync(&host->timeout_work); @@ -1188,7 +1197,7 @@ static irqreturn_t sh_mmcif_irqt(int irq, void *dev_id) * All handlers return true, if processing continues, and false, if the * request has to be completed - successfully or not */ - switch (host->wait_for) { + switch (wait_work) { case MMCIF_WAIT_FOR_REQUEST: /* We're too late, the timeout has already kicked in */ mutex_unlock(&host->thread_lock);