From patchwork Thu Jan 17 17:06:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabien Parent X-Patchwork-Id: 1026825 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="nrRy8OMB"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gVq04K3hz9sBn for ; Fri, 18 Jan 2019 04:06:36 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 428EBC22088; Thu, 17 Jan 2019 17:06:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 14E62C21D8A; Thu, 17 Jan 2019 17:06:30 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 81966C21D8A; Thu, 17 Jan 2019 17:06:28 +0000 (UTC) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by lists.denx.de (Postfix) with ESMTPS id 4BC01C21C4A for ; Thu, 17 Jan 2019 17:06:27 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id v13so11864378wrw.5 for ; Thu, 17 Jan 2019 09:06:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Q1tP1YAzZ6D0y8V6k03rUlPxOZoTpI+faGUFGVeES34=; b=nrRy8OMB+k2R/2gQXAcljYZjCEbjjlMuTDz+eCsdgZBEut9QQIkLWjPBAQfX3Nbjni wBQUAxbCaWQH8/LqqnzVk32zAOW+Iwwn9ek0M2abFeLsssY/GT3B96D/hEt6BycVfYZi ynAhslakJWoyO/Rt5L09M2mCOxAbsk+08xeGBZ262Nr7ar+XZKdVpOyv9MJzJO0Q7722 +htMCmTAxSfasaLrH9OYuDJkpp+xh5yHh2+t2+Zp+z2T/HEbpLKgPCtFSm+RJQD19phg BZAhj5OAUDd/PKvLFnXWGtSerw801GONxSiqxgelm+Gsmtv3Mly9ARGLplCDKrIaeS69 DN2Q== 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=Q1tP1YAzZ6D0y8V6k03rUlPxOZoTpI+faGUFGVeES34=; b=DIaI4oKpJGdTPtqe3Cp2St3r28ZDZRDXk/iE1ootCMjp8EGDC6hBg/lDxjV8zKKQyY OSXbpbIbT/t79ohjzmQ8uGKnqT4wLK4UGZopnYp8Yft5lvuCqY75n9dF85B/fveAJ586 z56wD9zMZXB8mm+xP6ReiqJMlW1S4Jo7rOXKjYxQz0KSwwzYsEuR5XcIl5uVWzQZrpt+ 5BrLs0syhxPIlyMe6YE2TpNHK+Z8EtaZ5iBI2aO1jhu9Pq3JNF/0HT4s4N9dKW1HkJcJ 4Mv/eyKPd+7A3afaLFCTITTJ1jDkrgTZW+P7zUJqg5vbAkxpzOk4r3ogzl42Kjla2WiC Qqfg== X-Gm-Message-State: AJcUukddtP8J/EKrvyJhZN4iYhhqiKWUbTaN1tLDap94qwKxGLNgCux7 6ykodb6C2BLGzeu0Bu1OKhKHHypNDq1FvQ== X-Google-Smtp-Source: ALg8bN6MixKgi8P6eL3DRog1o6pSO0yj1snLI2mjpdroLr1GDB8RaMm9PvpKfVUuDY5jP2nEaXfIEQ== X-Received: by 2002:adf:8143:: with SMTP id 61mr12429837wrm.47.1547744786386; Thu, 17 Jan 2019 09:06:26 -0800 (PST) Received: from localhost.localdomain (cag06-8-78-203-165-84.fbx.proxad.net. [78.203.165.84]) by smtp.gmail.com with ESMTPSA id w6sm39316219wme.46.2019.01.17.09.06.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Jan 2019 09:06:25 -0800 (PST) From: Fabien Parent To: u-boot@lists.denx.de, panto@antoniou-consulting.com Date: Thu, 17 Jan 2019 18:06:00 +0100 Message-Id: <20190117170601.20676-1-fparent@baylibre.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Cc: trini@konsulko.com, GSS_MTK_Uboot_upstream@mediatek.com, stephane.leprovost@mediatek.com Subject: [U-Boot] [PATCH 1/2] mmc: mtk-sd: fix possible incomplete read ops X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The code is checking for incomplete read when it see the INT_XFER_COMPL flag, but it forget to first check whether there is anything left in the FIFO to copy to the RX buffer. This means that sometimes we will get errors because of erroneous incomplete read operation. This commit fixes the driver re-ordering the code so that we first check for data inside the RX fifo and only after check the status of the INT_XFER_COMPL flag. Signed-off-by: Fabien Parent --- drivers/mmc/mtk-sd.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/mtk-sd.c b/drivers/mmc/mtk-sd.c index 0741a525c0..e668df7017 100644 --- a/drivers/mmc/mtk-sd.c +++ b/drivers/mmc/mtk-sd.c @@ -554,6 +554,14 @@ static int msdc_pio_read(struct msdc_host *host, u8 *ptr, u32 size) break; } + chksz = min(size, (u32)MSDC_FIFO_SIZE); + + if (msdc_fifo_rx_bytes(host) >= chksz) { + msdc_fifo_read(host, ptr, chksz); + ptr += chksz; + size -= chksz; + } + if (status & MSDC_INT_XFER_COMPL) { if (size) { pr_err("data not fully read\n"); @@ -562,15 +570,7 @@ static int msdc_pio_read(struct msdc_host *host, u8 *ptr, u32 size) break; } - - chksz = min(size, (u32)MSDC_FIFO_SIZE); - - if (msdc_fifo_rx_bytes(host) >= chksz) { - msdc_fifo_read(host, ptr, chksz); - ptr += chksz; - size -= chksz; - } - } +} return ret; } From patchwork Thu Jan 17 17:06:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabien Parent X-Patchwork-Id: 1026826 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="dibU4flK"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43gVqR5MHjz9sBn for ; Fri, 18 Jan 2019 04:06:59 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 611CAC220AE; Thu, 17 Jan 2019 17:06:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id BAC62C21E77; Thu, 17 Jan 2019 17:06:54 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 713C0C220A6; Thu, 17 Jan 2019 17:06:47 +0000 (UTC) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by lists.denx.de (Postfix) with ESMTPS id 8D2DBC2207B for ; Thu, 17 Jan 2019 17:06:47 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id g67so1852305wmd.2 for ; Thu, 17 Jan 2019 09:06:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Rg6FVNBXyTJCDb6fKkd0SYjPyLFVc9ODn3AEjFB86bo=; b=dibU4flKj5waJvl9RRySrOMAz+8BXQOUWSpHOAI1LOkfRQ/NPmNdM6sbaloxmslKUh SHKsBGkTZqNayWNSHQd+qDAxPDVuEoFYYw0OPwlm5HY/WVhgWpCRewtMG+SYYQgZFoEU m5yVjfG732+Gc8xQ+lgQEtkZ21/0snOkdNOi4fIoqrMId8Oco2mUTzo0tWTP2vdQhpjj lT0r7e12L1obFu75LU0Z8wV6tDIAdOdnO+of9syxhyK/aenGJRI1seFvkNzI1Da6G0lt mZEMyenqmUJwwD4ffHKxFLb0zlSR32aCApby+RCdW3lNUKK0UylBpQKbz/XfyQXdRqHi V/aw== 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=Rg6FVNBXyTJCDb6fKkd0SYjPyLFVc9ODn3AEjFB86bo=; b=l1ZIs6qKgeu0psIptr8H6X46m2gbCVcLEihkRUz6sJUVZfUz0iKrE7A1wD7A1Ny3Ka lZjKJUTejySAJ3T8rQd10rJw6G1tfY3XBqU2NAdI1aB07BExsTkWs3OEpZW4KL7c7Bxc Z4l/Te+ph+Mp+wExhrwH6UxXNfWxulHG11/ujGSORQS8WgKJNfgjU3+5kUMIut0aOfS7 /zWiAPaQg1KUAaO0RdTPWcUkwju2zcZFfGY2ofdnb9BOXj27Zh2QNVMQdeZpR1B3Nkyu kdPtbB9Jtkn+mUTSvDGKMYjgJN0cKxPQ6ThJuTQMWzLV52f+pfGFHgdSXMZkRQVAhQl6 RcgA== X-Gm-Message-State: AJcUukclyLLFpOgA3yMqchOneVggBByD4i0xh8mEuYghnUwJBqZvx1Q0 mYrVaQZLW1HWAFiHr/AyxfWdAqaYl/ZsIg== X-Google-Smtp-Source: ALg8bN7COzz9qcJtkLq3h0/jqsFrtrxJEnLiTncI/M6IbLZXH1ItqXY1VvjjXDDScGsZnnmqbW4amA== X-Received: by 2002:a1c:ab87:: with SMTP id u129mr12615361wme.104.1547744806873; Thu, 17 Jan 2019 09:06:46 -0800 (PST) Received: from localhost.localdomain (cag06-8-78-203-165-84.fbx.proxad.net. [78.203.165.84]) by smtp.gmail.com with ESMTPSA id w6sm39316219wme.46.2019.01.17.09.06.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Jan 2019 09:06:46 -0800 (PST) From: Fabien Parent To: u-boot@lists.denx.de, panto@antoniou-consulting.com Date: Thu, 17 Jan 2019 18:06:01 +0100 Message-Id: <20190117170601.20676-2-fparent@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190117170601.20676-1-fparent@baylibre.com> References: <20190117170601.20676-1-fparent@baylibre.com> MIME-Version: 1.0 Cc: trini@konsulko.com, GSS_MTK_Uboot_upstream@mediatek.com, stephane.leprovost@mediatek.com Subject: [U-Boot] [PATCH 2/2] mmc: mtk-sd: fix SPL compilation when GPIO=y and SPL_GPIO=n X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" It is not possible to link the SPL image when CONFIG_GPIO is enabled but CONFIG_SPL_GPIO is not. Use the IS_ENABLED macro instead to correctly check whether CONFIG_{SPL_}GPIO is enabled. This commit fixes the following errors: * undefined reference to `dm_gpio_get_value * undefined reference to `gpio_request_by_name' Signed-off-by: Fabien Parent --- drivers/mmc/mtk-sd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/mtk-sd.c b/drivers/mmc/mtk-sd.c index e668df7017..4c997977d7 100644 --- a/drivers/mmc/mtk-sd.c +++ b/drivers/mmc/mtk-sd.c @@ -269,7 +269,7 @@ struct msdc_host { bool builtin_cd; /* card detection / write protection GPIOs */ -#ifdef CONFIG_DM_GPIO +#if IS_ENABLED(DM_GPIO) struct gpio_desc gpio_wp; struct gpio_desc gpio_cd; #endif @@ -849,7 +849,7 @@ static int msdc_ops_get_cd(struct udevice *dev) return !(val & MSDC_PS_CDSTS); } -#ifdef CONFIG_DM_GPIO +#if IS_ENABLED(DM_GPIO) if (!host->gpio_cd.dev) return 1; @@ -863,7 +863,7 @@ static int msdc_ops_get_wp(struct udevice *dev) { struct msdc_host *host = dev_get_priv(dev); -#ifdef CONFIG_DM_GPIO +#if IS_ENABLED(DM_GPIO) if (!host->gpio_wp.dev) return 0; @@ -1332,7 +1332,7 @@ static int msdc_ofdata_to_platdata(struct udevice *dev) if (ret < 0) return ret; -#ifdef CONFIG_DM_GPIO +#if IS_ENABLED(DM_GPIO) gpio_request_by_name(dev, "wp-gpios", 0, &host->gpio_wp, GPIOD_IS_IN); gpio_request_by_name(dev, "cd-gpios", 0, &host->gpio_cd, GPIOD_IS_IN); #endif