Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2260613ybk; Sun, 17 May 2020 15:35:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLqRy5n1ahzyBAl3Yf5uxMdRadV7/mLbEzACjFgZBWEgyk3aHmTTo2/c5s1Ri4P4B6Z2xO X-Received: by 2002:a50:cdd8:: with SMTP id h24mr11042871edj.260.1589754901739; Sun, 17 May 2020 15:35:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589754901; cv=none; d=google.com; s=arc-20160816; b=CcNB7nbWMX2xpSWxHT/i4UZIkFwQu94mVjRhFaONkiEKbEK2NmPEKKGjMhIzCph5Mo +gab3X46rjUzS6AGQ1+tkJHjhguh+FkG1fzT7EEYYvTvie2GbgvLiJMC2zue1zveha9W /CJEkyWjFEse9SZMxomIBYsdYxoM3j8zms7QSf6CbyzHQ/PEHQiiyngsP9l+fncwPR/O 1PVkPM3NQT2BCujCalQpUTswp5zYPzH4spAfKRnHotmbyPVdMnPjSFUJDSUFlisnROqR N/6VuI/edM8uiS2qDRq0mBdM5BMKXL8nGduxVUgUZsHnei2nGYT7vSP+5RCcIuD9C3a1 Lq0w== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=3zBbpyoelvZMQi2sOj6TWYdOKOApt3dyMAzoTjYhpAc=; b=WlHLwGxPZ118U+NrKLb1GDwHFmnJsWUeDY279e7HeXzGH4cS6wCXZFiyJS/+qv3jSe SVeBNIeWhlRNizXawkZUTulptHRHyoVcwVIiYWN/K0ILxpaul0ILCmtdnrklocN4dW7a pqhsyBkGDXUBt/FSIrIF5uM7h+cwtlKkn/uhWCrV71XR5sRwfl4X/Asd75XKHpgbuR1L WJrHEOdRaREf4zP4xwFudJUcWumMfnf2uH4sddJXEbcewB8keWwqxVWEQ16di4AUBbGs kGwcJX6lTSPWWBpNvqbDth+tPAwXMpxaseTRjVA6e4OnV71AnqVv5c4qK6X5UqS/39Zi BW7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@googlemail.com header.s=20161025 header.b=my4ubcsy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a34si3448772edf.315.2020.05.17.15.34.22; Sun, 17 May 2020 15:35:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@googlemail.com header.s=20161025 header.b=my4ubcsy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726601AbgEQW3f (ORCPT + 99 others); Sun, 17 May 2020 18:29:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726444AbgEQW3f (ORCPT ); Sun, 17 May 2020 18:29:35 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A18A9C061A0C; Sun, 17 May 2020 15:29:34 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id m12so7440388wmc.0; Sun, 17 May 2020 15:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3zBbpyoelvZMQi2sOj6TWYdOKOApt3dyMAzoTjYhpAc=; b=my4ubcsyz+v4QpyWlb/muucdIIfwEzKHPRDj65Ud1hff5Sw5+RL6mtJJ0tg7ZXtjaK eXo0Brwj/Yy+L+TQFkLy9eYTRBoFsPP9KlmatvE/StbtXirjWl591t5qIcPlJkCkXiFo qeTMbSv8ou2Y45QB7rOKtwrYCVaQPvhSJxs8xhlHThodFsT9SiVZ8eiYKOo3w6OeuEmk jb3K6S5ieYl8cvL24CcQmU3bjyzuHa+4rAVRHYg5viauNa6XwTNnk7g+1/SOdtJuQ6HN ZO3aoPP1UekJUSm62JwmAf3Y1icer6CxzCAmfLBclIWZG4uv+ybf4wjj9uUvket80ljP 4g/w== 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:mime-version :content-transfer-encoding; bh=3zBbpyoelvZMQi2sOj6TWYdOKOApt3dyMAzoTjYhpAc=; b=S4pu3B1obrjKuWv9UybaRKO0tYhYggirPz2uqzyp3TFIslChFA4IDhB1X8eSlL+JIH jghjGjDZzyW0j7Z/3pWsctGz1ApXgBgpZ8bmr7O9bzsINM83e1xHoAKTDBBdHGvVjsFA yI2OftDusU7NncRHVvbaMwBsCiwstYRZbZ9iNu74CXUw9kbzv6NS1PMumWfQ0MSWVRjq RaEj2a6jGkoRq26/CAISAw51ZHht3Tkzejixo9g8rQDO4vNkNAJJKejs+Ps3TrONZXq0 YG9X6lNSuJdWMqh3YIOkt6bYxPg25LI8pOG6weFyM8HHYzwkvqDqVdnTcLPXhCxtuEtF 0dUQ== X-Gm-Message-State: AOAM533JgI4TqFIfpGUTeYX8RTqV1eOI98pudwf8kb9wx2t7uX2bbvDG lI15+9jgEa5e3s0WHEOK8Jw= X-Received: by 2002:a7b:cd04:: with SMTP id f4mr15304085wmj.3.1589754573183; Sun, 17 May 2020 15:29:33 -0700 (PDT) Received: from localhost.localdomain (p200300f137132e00428d5cfffeb99db8.dip0.t-ipconnect.de. [2003:f1:3713:2e00:428d:5cff:feb9:9db8]) by smtp.googlemail.com with ESMTPSA id b65sm14624702wmc.30.2020.05.17.15.29.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 May 2020 15:29:32 -0700 (PDT) From: Martin Blumenstingl To: ulf.hansson@linaro.org, linux-mmc@vger.kernel.org, linux-amlogic@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Martin Blumenstingl , Thomas Graichen Subject: [PATCH 1/2] mmc: host: meson-mx-sdhc: fix manual RX FIFO flushing Date: Mon, 18 May 2020 00:29:06 +0200 Message-Id: <20200517222907.1277787-1-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.26.2 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 For Meson8 and Meson8b SoCs the vendor driver follows the following pattern: - for eMMC and SD cards in .set_pdma it sets: pdma->rxfifo_manual_flush = 1; - for SDIO cards in .set_pdma it sets: pdma->rxfifo_manual_flush = 0; - before syncing the DMA read buffer is sets: pdma->rxfifo_manual_flush |= 0x02; Set the second bit of MESON_SDHC_PDMA_RXFIFO_MANUAL_FLUSH without clearing the first bit before syncing the DMA read buffer. This fixes a problem where Meson8 and Meson8b SoCs would read random garbage from SD cards. It is not clear why it worked for eMMC cards. This manifested in the following errors when plugging in an SD card: unrecognised SCR structure version Fixes: 53ded1b676d199 ("mmc: host: meson-mx-sdhc: new driver for the Amlogic Meson SDHC host") Cc: Thomas Graichen Signed-off-by: Martin Blumenstingl --- drivers/mmc/host/meson-mx-sdhc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/meson-mx-sdhc.c b/drivers/mmc/host/meson-mx-sdhc.c index 5c00958d7754..53e3f6a4245a 100644 --- a/drivers/mmc/host/meson-mx-sdhc.c +++ b/drivers/mmc/host/meson-mx-sdhc.c @@ -586,10 +586,17 @@ static irqreturn_t meson_mx_sdhc_irq_thread(int irq, void *irq_data) cmd->data->flags & MMC_DATA_READ) { meson_mx_sdhc_wait_cmd_ready(host->mmc); + /* + * If MESON_SDHC_PDMA_RXFIFO_MANUAL_FLUSH was + * previously 0x1 then it has to be set to 0x3. If it + * was 0x0 before then it has to be set to 0x2. Without + * this reading SD cards sometimes transfers garbage, + * which results in cards not being detected due to: + * unrecognised SCR structure version + */ val = FIELD_PREP(MESON_SDHC_PDMA_RXFIFO_MANUAL_FLUSH, 2); - regmap_update_bits(host->regmap, MESON_SDHC_PDMA, - MESON_SDHC_PDMA_RXFIFO_MANUAL_FLUSH, + regmap_update_bits(host->regmap, MESON_SDHC_PDMA, val, val); } -- 2.26.2