From patchwork Sat Apr 4 10:45:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1266364 X-Patchwork-Delegate: van.freenix@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=FeBSpxyr; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48vYP04Y7Dz9sPF for ; Sat, 4 Apr 2020 21:45:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D8052811F4; Sat, 4 Apr 2020 12:45:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FeBSpxyr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E107A81232; Sat, 4 Apr 2020 12:45:23 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EBF16804EC for ; Sat, 4 Apr 2020 12:45:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut@gmail.com Received: by mail-wm1-x341.google.com with SMTP id a81so10502309wmf.5 for ; Sat, 04 Apr 2020 03:45:18 -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:mime-version :content-transfer-encoding; bh=I4ksgKiMnqkzfz91ltJJJTpP7pbibqMgP43T5Cv20nA=; b=FeBSpxyrYS1p8kWec3yudrum8P/0U0YJWwSEdiAQpsprLDiJYW7VYnq1OLVbQG0cj2 xLR6ewGSmG6bDojntzlykqfFDyl996wQtQk1UXjNsuUfGFTjEuMrtWBgVMkxdco6SHxE euFaKM1mDUrB2yyN1pLxzFTUH7GvacnmN1IYo4wX1xgVM0Yoq3Rz6Z4sJfE3KlV0iEt3 7tNiu8JBbAfr7mRh1MAjWZGYBobCgratGmEZAOX3v/XOPCNenlDLZCK/WtE4qf5RjNQJ 1VcqWrKHPLNsMnwjA+5vtfROMANryheOXBA7+1/+QVtP1tckQ6J8RfHnB7i3/wkPlzjq 2DDw== 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=I4ksgKiMnqkzfz91ltJJJTpP7pbibqMgP43T5Cv20nA=; b=X87pZi/FcO0kCxQzBrP9mVAR1eKlpzonfSmAMmB0f8k97IjwjEK6QYoW7zIp0Ir5Ns oi28ceF3cL3wBz6s92tdYFKrjcrOqDigEpCnbmudKzZSMoSmNLW1ONgH1NSQXbhjG2C0 I7R60w0VH7/Jh2b+lclLiTeVrpnsCXaksRCFN/FtLH8XFsmGbE3nCy4ub7WG/9G66Qw+ W6bCPI6n0F43SULcnbKFlvRbYHTB+w+CgMDwI9KzlFev/mGhg2riPtuUwWAZJ5wzoptS DUvI5FnqH+KpCgbFC5rnnVJZHqxl41wAq1JAUCwWmGB81vNtKyKoj1EPNtMdk9qqdeEv oCKw== X-Gm-Message-State: AGi0PuazXM+IfZvRW33rg3eRXaAc5xeLW+Yz9f+U6iXKvNmGV+EXvRaH KoTE/z7brkQ2TGR2hPsZKm5sS4Bl X-Google-Smtp-Source: APiQypLU550+Kga6bcVWdoYuQ4AHBWnG9nhOVclviReJESXLLmmHRGia1GfAYHZgWvCi/GHby1gsew== X-Received: by 2002:a1c:4d13:: with SMTP id o19mr13768087wmh.82.1585997118126; Sat, 04 Apr 2020 03:45:18 -0700 (PDT) Received: from desktop.lan (ip-86-49-35-8.net.upcbroadband.cz. [86.49.35.8]) by smtp.gmail.com with ESMTPSA id i97sm11454644wri.1.2020.04.04.03.45.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Apr 2020 03:45:17 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Daniel Schwierzeck , Masahiro Yamada , Peng Fan , Simon Glass , Tom Rini Subject: [PATCH V2 1/5] common: bouncebuf: Permit passing custom alignment check function Date: Sat, 4 Apr 2020 12:45:02 +0200 Message-Id: <20200404104506.386314-1-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Add extended version of the bounce_buffer_start(), which permits passing in a custom alignment checker function for the buffer. This is useful e.g. on systems with various DMA restrictions and where the checker function might be more complex than a simple CPU cache alignment check. Signed-off-by: Marek Vasut Cc: Daniel Schwierzeck Cc: Masahiro Yamada Cc: Peng Fan Cc: Simon Glass Cc: Tom Rini --- V2: No change --- common/bouncebuf.c | 20 +++++++++++++++----- include/bouncebuf.h | 15 +++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/common/bouncebuf.c b/common/bouncebuf.c index 614eb36c78..0ace152b98 100644 --- a/common/bouncebuf.c +++ b/common/bouncebuf.c @@ -31,17 +31,19 @@ static int addr_aligned(struct bounce_buffer *state) return 1; } -int bounce_buffer_start(struct bounce_buffer *state, void *data, - size_t len, unsigned int flags) +int bounce_buffer_start_extalign(struct bounce_buffer *state, void *data, + size_t len, unsigned int flags, + size_t alignment, + int (*addr_is_aligned)(struct bounce_buffer *state)) { state->user_buffer = data; state->bounce_buffer = data; state->len = len; - state->len_aligned = roundup(len, ARCH_DMA_MINALIGN); + state->len_aligned = roundup(len, alignment); state->flags = flags; - if (!addr_aligned(state)) { - state->bounce_buffer = memalign(ARCH_DMA_MINALIGN, + if (!addr_is_aligned(state)) { + state->bounce_buffer = memalign(alignment, state->len_aligned); if (!state->bounce_buffer) return -ENOMEM; @@ -62,6 +64,14 @@ int bounce_buffer_start(struct bounce_buffer *state, void *data, return 0; } +int bounce_buffer_start(struct bounce_buffer *state, void *data, + size_t len, unsigned int flags) +{ + return bounce_buffer_start_extalign(state, data, len, flags, + ARCH_DMA_MINALIGN, + addr_aligned); +} + int bounce_buffer_stop(struct bounce_buffer *state) { if (state->flags & GEN_BB_WRITE) { diff --git a/include/bouncebuf.h b/include/bouncebuf.h index fd9b0f3b28..7427bd12e2 100644 --- a/include/bouncebuf.h +++ b/include/bouncebuf.h @@ -62,6 +62,21 @@ struct bounce_buffer { */ int bounce_buffer_start(struct bounce_buffer *state, void *data, size_t len, unsigned int flags); + +/** + * bounce_buffer_start() -- Start the bounce buffer session with external align check function + * state: stores state passed between bounce_buffer_{start,stop} + * data: pointer to buffer to be aligned + * len: length of the buffer + * flags: flags describing the transaction, see above. + * alignment: alignment of the newly allocated bounce buffer + * addr_is_aligned: function for checking the alignment instead of the default one + */ +int bounce_buffer_start_extalign(struct bounce_buffer *state, void *data, + size_t len, unsigned int flags, + size_t alignment, + int (*addr_is_aligned)(struct bounce_buffer *state)); + /** * bounce_buffer_stop() -- Finish the bounce buffer session * state: stores state passed between bounce_buffer_{start,stop} From patchwork Sat Apr 4 10:45:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1266365 X-Patchwork-Delegate: van.freenix@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=gY2zE60K; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48vYP66tjwz9sPF for ; Sat, 4 Apr 2020 21:45:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BFFA3811FB; Sat, 4 Apr 2020 12:45:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gY2zE60K"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 695CD811F9; Sat, 4 Apr 2020 12:45:25 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 45A908116F for ; Sat, 4 Apr 2020 12:45:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut@gmail.com Received: by mail-wm1-x332.google.com with SMTP id e9so10541451wme.4 for ; Sat, 04 Apr 2020 03:45:20 -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=VIQevfFsrP+2ZcvGrE10NatN2VVoLVZ/JbzfelUqP88=; b=gY2zE60KhMQbor+/m/yl4EVidyy1l74BCRUyOogBcLrI7EAUxiEggWewmbFVgzCA42 ki5TMe68S0BQCvhzbmV5RGSnXNfLiwGlm1Ridwin3/lbbt2xYlR8VrY1OEbtDRdSFw7J wNWVaIgmTfirZkUUYhg2VWERiwxuUA1brWr+rR0+It3pbv1pdYgm12DO2jOmK3P3Dekt Z9DgyyGPI9wT52U238g6CN3uHHCKtXD+zLO0Z6Zk7nfGOazhU1XnWpPUEOfmsFP0Zeyp D/Vc6srJZbppDs9VfaiYG1HA7jy5kMe3pIlE1soetiAZ4SWW1P8cTy6QcsHXeBgujeuo 4fTA== 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=VIQevfFsrP+2ZcvGrE10NatN2VVoLVZ/JbzfelUqP88=; b=XBHT0ut4vTPLBKAv2SfHaRtOV5OPbcOuf+TAV6ejybDgjN/ezP59VqA6N3VT+CA8gs mKn9ubJVtZG6lown39BpVPKI068R6gPnUokYtvvwavpL814zqfRuPil6SFoYZEdo65CY NwqxhXNTYzaaisSMlNCqpIusstQ8/+HxHmt2hOsqEsydDV3wLU9snquxuAiwHFHrOTXj ilMQQ/mXnyZzIvSil4toWhsu6VUOwt7gORkAaT4o787EPkxdu2k7yGn+GT8O4k6WbHhL I3AvpPKYgcp2dmKYIFCAZ/+oeSXgSPgciqTKcCe6HXj4khhUUBIIP+Gli6eLoD0cI4g+ Iihw== X-Gm-Message-State: AGi0Puanq0RS+atNld24RK/tDCroUEXI150yHPDznHtZ7S5wKzgAWGFC /I0yWA9f2rlFT1zY4uCUF7ti4dHm X-Google-Smtp-Source: APiQypKIXcfuMOuU4GEFYBKFj0wOu+5itiDSkhE7rJeoejGnRYHZpQhdzyll5k93wPUPxLitioEpIA== X-Received: by 2002:a05:600c:4148:: with SMTP id h8mr13787491wmm.144.1585997119548; Sat, 04 Apr 2020 03:45:19 -0700 (PDT) Received: from desktop.lan (ip-86-49-35-8.net.upcbroadband.cz. [86.49.35.8]) by smtp.gmail.com with ESMTPSA id i97sm11454644wri.1.2020.04.04.03.45.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Apr 2020 03:45:18 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Daniel Schwierzeck , Masahiro Yamada , Peng Fan , Simon Glass , Tom Rini Subject: [PATCH V2 2/5] ARM: rmobile: Increase malloc area size Date: Sat, 4 Apr 2020 12:45:03 +0200 Message-Id: <20200404104506.386314-2-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200404104506.386314-1-marek.vasut+renesas@gmail.com> References: <20200404104506.386314-1-marek.vasut+renesas@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Increase the malloc area size significantly to cater for bounce buffer used by the SDHI driver. Signed-off-by: Marek Vasut Cc: Daniel Schwierzeck Cc: Masahiro Yamada Cc: Peng Fan Cc: Simon Glass Cc: Tom Rini --- V2: No change --- include/configs/rcar-gen3-common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/configs/rcar-gen3-common.h b/include/configs/rcar-gen3-common.h index 6528f1fa62..8f400ba05a 100644 --- a/include/configs/rcar-gen3-common.h +++ b/include/configs/rcar-gen3-common.h @@ -47,7 +47,7 @@ #define CONFIG_SYS_MONITOR_BASE 0x00000000 #define CONFIG_SYS_MONITOR_LEN (1 * 1024 * 1024) -#define CONFIG_SYS_MALLOC_LEN (1 * 1024 * 1024) +#define CONFIG_SYS_MALLOC_LEN (64 * 1024 * 1024) #define CONFIG_SYS_BOOTM_LEN (64 << 20) /* The HF/QSPI layout permits up to 1 MiB large bootloader blob */ From patchwork Sat Apr 4 10:45:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1266366 X-Patchwork-Delegate: van.freenix@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=I3KcBx9h; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48vYPK6kKsz9sPF for ; Sat, 4 Apr 2020 21:45:57 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4A8E481289; Sat, 4 Apr 2020 12:45:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="I3KcBx9h"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 78B00811EF; Sat, 4 Apr 2020 12:45:28 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 81CE1811EF for ; Sat, 4 Apr 2020 12:45:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut@gmail.com Received: by mail-wm1-x343.google.com with SMTP id r16so9706282wmg.5 for ; Sat, 04 Apr 2020 03:45:21 -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=cR0mgEBzCfL45PNu+BetTzVlNzVrOizGrnJCR5u6spo=; b=I3KcBx9hYOJsyV7UQke03pBoex91dir0pBijfV3Ls9bBKDql+lIN0eslxqg6nDPrmp C5BOgXOAzm16DLy+37su3TC0894z9x/nEdDWG0incw4t9rv8uza8xQqqc8pTiuX0OuJh GXm3frmoCMcAgz0Oany5pCGyYoQvcWkgQvdTwZErxFsO6WrPvSVoXVvrdGqyvUzmYvGk gj3Oh7M+cgIRm+OcHOXMneawKgJLwQ9E1dPve/JmtwVWM/KU9pIihL2puTpQpZAAT++V tfruaM2OqKGIO0TWv/hC7hNAMsfM5poQ3vVgQiKofl4r0fT9ZNQvsng8eAVVrFE9PBSv Kyiw== 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=cR0mgEBzCfL45PNu+BetTzVlNzVrOizGrnJCR5u6spo=; b=O0f+zk464p76ATOHiqMk8+bYHIzgiNrKA4Sy7Wp/Vj0B+0p7WzbG+wubWXSB8QNGEp EkF627YALqoR7KpGnlNIZkyzkXyAQ4H/dDFZ/ptYJNd1Epfb3VXHKZ+e/qFVz4ac9lHq H76t4F8zYFV4cxg+ZrAj5e/6/rTD1G86dhtISTnGNigT+1IGDe/IOjhJ79qsq90EjVLR lMkFotN3D2lpeeM2rYyoBwBgOlipBFJT/HYqWFiJV5Yenw370drw+ZT6kq/z4eHlVUoH rxIcJxcW4jzAhEa7yzE1CnF/REHcwu4tPcUYB0/2pP8MnyCAhmi70hBFbNDqLUMiN048 lvBQ== X-Gm-Message-State: AGi0Puat3nWKkn0Eafh6GwQtfnqfrj9AgDUKiFFCNZZySQsXZj1mkgD7 RUuBYdDaB6UyCervIytPk2dL5BIl X-Google-Smtp-Source: APiQypJwIOo81mSPIlGCel5kwVkAlRF1nwbCbxWizgWDoPZJNdIGYRPRsjC/Ypqqg4O1g9UITZuz3w== X-Received: by 2002:a7b:cd0c:: with SMTP id f12mr13486720wmj.4.1585997120789; Sat, 04 Apr 2020 03:45:20 -0700 (PDT) Received: from desktop.lan (ip-86-49-35-8.net.upcbroadband.cz. [86.49.35.8]) by smtp.gmail.com with ESMTPSA id i97sm11454644wri.1.2020.04.04.03.45.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Apr 2020 03:45:20 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Daniel Schwierzeck , Masahiro Yamada , Peng Fan , Simon Glass , Tom Rini Subject: [PATCH V2 3/5] mmc: tmio: sdhi: Use bounce buffer to avoid DMA limitations Date: Sat, 4 Apr 2020 12:45:04 +0200 Message-Id: <20200404104506.386314-3-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200404104506.386314-1-marek.vasut+renesas@gmail.com> References: <20200404104506.386314-1-marek.vasut+renesas@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean The R-Car SDHI DMA controller has various restrictions. To work around those restrictions without falling back to PIO, implement bounce buffer with custom alignment check function which tests for those limitations. Signed-off-by: Marek Vasut Cc: Daniel Schwierzeck Cc: Masahiro Yamada Cc: Peng Fan Cc: Simon Glass Cc: Tom Rini --- V2: Apply 32bit check only on 64bit platforms --- drivers/mmc/Kconfig | 1 + drivers/mmc/renesas-sdhi.c | 77 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig index bb38787eca..8f0df568b9 100644 --- a/drivers/mmc/Kconfig +++ b/drivers/mmc/Kconfig @@ -358,6 +358,7 @@ config RENESAS_SDHI depends on ARCH_RMOBILE depends on BLK && DM_MMC depends on OF_CONTROL + select BOUNCE_BUFFER help This selects support for the Matsushita SD/MMC Host Controller on Renesas R-Car SoCs. diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c index c3b13136f8..231a78178c 100644 --- a/drivers/mmc/renesas-sdhi.c +++ b/drivers/mmc/renesas-sdhi.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -689,12 +690,88 @@ static int renesas_sdhi_wait_dat0(struct udevice *dev, int state, } #endif +#define RENESAS_SDHI_DMA_ALIGNMENT 128 + +static int renesas_sdhi_addr_aligned(struct bounce_buffer *state) +{ + uintptr_t ubuf = (uintptr_t)state->user_buffer; + + /* Check if start is aligned */ + if (!IS_ALIGNED(ubuf, RENESAS_SDHI_DMA_ALIGNMENT)) { + debug("Unaligned buffer address %p\n", state->user_buffer); + return 0; + } + + /* Check if length is aligned */ + if (state->len != state->len_aligned) { + debug("Unaligned buffer length %zu\n", state->len); + return 0; + } + +#ifdef CONFIG_PHYS_64BIT + /* Check if below 32bit boundary */ + if ((ubuf >> 32) || (ubuf + state->len_aligned) >> 32) { + debug("Buffer above 32bit boundary %p-%p\n", + state->user_buffer, + state->user_buffer + state->len_aligned); + return 0; + } +#endif + + /* Aligned */ + return 1; +} + static int renesas_sdhi_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, struct mmc_data *data) { + struct bounce_buffer bbstate; + unsigned int bbflags; + bool bbok = false; + size_t len; + void *buf; int ret; + if (data) { + if (data->flags & MMC_DATA_READ) { + buf = data->dest; + bbflags = GEN_BB_WRITE; + } else { + buf = (void *)data->src; + bbflags = GEN_BB_READ; + } + len = data->blocks * data->blocksize; + + ret = bounce_buffer_start_extalign(&bbstate, buf, len, bbflags, + RENESAS_SDHI_DMA_ALIGNMENT, + renesas_sdhi_addr_aligned); + /* + * If the amount of data to transfer is too large, we can get + * -ENOMEM when starting the bounce buffer. If that happens, + * fall back to PIO as it was before, otherwise use the BB. + */ + if (!ret) { + bbok = true; + if (data->flags & MMC_DATA_READ) + data->dest = bbstate.bounce_buffer; + else + data->src = bbstate.bounce_buffer; + } + } + ret = tmio_sd_send_cmd(dev, cmd, data); + + if (data && bbok) { + buf = bbstate.user_buffer; + + bounce_buffer_stop(&bbstate); + + if (data->flags & MMC_DATA_READ) + data->dest = buf; + else + data->src = buf; + } + if (ret) return ret; From patchwork Sat Apr 4 10:45:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1266367 X-Patchwork-Delegate: van.freenix@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=DYUHpL6R; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48vYPY3bz2z9sPF for ; Sat, 4 Apr 2020 21:46:09 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D1C4C81576; Sat, 4 Apr 2020 12:45:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DYUHpL6R"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 64ED9812DF; Sat, 4 Apr 2020 12:45:29 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D4FCF811FB for ; Sat, 4 Apr 2020 12:45:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut@gmail.com Received: by mail-wm1-x343.google.com with SMTP id t203so1190461wmt.2 for ; Sat, 04 Apr 2020 03:45:22 -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=I0yXmkk0Q95LRG63lMd+8bkPLAmPnBUwt+ZExfhNlOo=; b=DYUHpL6RRz8aqsl2+O+/RDzX3oJ5e1w7R+o5HCOt/hb6vlgSSHgUpd3H9Xu4y+oxNP P4s2CXQ8qJlhWsMEnxHNFFIIsoqchXOAsr3a4IwmFNxg38HhMmRLZtyayuLilojkN6Ed K5MJdWOnqaW1QEa18FGH+1LQExRttHv7Iqk1OboOoJaRMqrCrR86vWB3rCyrcWoaU80v 3fFViHiEevCANZZVCJrZ2568P0C32bOn8x61cPQR5Q6ddYtCoHYbsvNeYQfKiqnMcaof vHV9fYswLmSMfPRMy/vkY/RS82cc60/wNgZv1NvOen2tV0NBqejREKKVuoOIkDnk2DOS T2yw== 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=I0yXmkk0Q95LRG63lMd+8bkPLAmPnBUwt+ZExfhNlOo=; b=cFrgwn9EGMWD1/6IDwKAzTfzT8XLCnC38ECwUeJHoHslB96uK3ZXW+zQMUx2f+sU/2 A0AOudqrrJflofga70OFrX0EVmKeJtwrgwc45LhOf/VXZj7cA0jfCj5IgqopQD+BauD2 OgFKb9YtbkaocNpvU640AGqD/bOlRTPBO4u9Gzqm2IBbIWaJ4NyRFJMbBr7czUHsKapz aL+L9xJ6PpBzoXCUz3g0nQWmFJ0RfnbW5TjZRXEENy0xqZhv7xf70cSuqwXp+O1GZV0I 2tGeuQMkh6XNJ747SNlNBK92/QqrNufnt4dxpqspNZEF6RB89USYIbsszRPpIoX94c43 /LSg== X-Gm-Message-State: AGi0PuYogXT9E9A5I8ank44zyBRMhM90HV1DZe8+OWNI4D4yZCNwg2xr ITvNxBbgYBYpdG/8qz9qvNi5yAmY X-Google-Smtp-Source: APiQypI5t8LELqpkEgoeghixBfXa550Ls52Hl3djdMeuvLMOp8+MDU7DAL9VQ/wkqklajJPOoeMylg== X-Received: by 2002:a7b:c185:: with SMTP id y5mr13552525wmi.90.1585997122094; Sat, 04 Apr 2020 03:45:22 -0700 (PDT) Received: from desktop.lan (ip-86-49-35-8.net.upcbroadband.cz. [86.49.35.8]) by smtp.gmail.com with ESMTPSA id i97sm11454644wri.1.2020.04.04.03.45.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Apr 2020 03:45:21 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Daniel Schwierzeck , Masahiro Yamada , Peng Fan , Simon Glass , Tom Rini Subject: [PATCH V2 4/5] mmc: Add option to adjust b_max before long read Date: Sat, 4 Apr 2020 12:45:05 +0200 Message-Id: <20200404104506.386314-4-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200404104506.386314-1-marek.vasut+renesas@gmail.com> References: <20200404104506.386314-1-marek.vasut+renesas@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Add getter function which permits adjusting the maximum number of blocks that could be read in a single sustained read transfer based on the location of the source/target buffer and length, before such transfer starts. This is mainly useful on systems which have various DMA restrictions for different memory locations, e.g. DMA limited to 32bit addresses, and where a bounce buffer is used to work around such restrictions. Since the U-Boot bounce buffer is mallocated, it's size is limited by the malloc area size, and the read transfer to such a buffer must also be limited. However, as not all areas are limited equally, the b_max should be adjusted accordinly as needed to avoid degrading performance unnecessarily. Signed-off-by: Marek Vasut Cc: Daniel Schwierzeck Cc: Masahiro Yamada Cc: Peng Fan Cc: Simon Glass Cc: Tom Rini --- V2: No change --- drivers/mmc/mmc-uclass.c | 16 ++++++++++++++++ drivers/mmc/mmc.c | 16 ++++++++++++++-- include/mmc.h | 16 ++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index c75892a72c..cb26d841be 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -13,6 +13,22 @@ #include #include "mmc_private.h" +int dm_mmc_get_b_max(struct udevice *dev, void *dst, lbaint_t blkcnt) +{ + struct dm_mmc_ops *ops = mmc_get_ops(dev); + struct mmc *mmc = mmc_get_mmc_dev(dev); + + if (ops->get_b_max) + return ops->get_b_max(dev, dst, blkcnt); + else + return mmc->cfg->b_max; +} + +int mmc_get_b_max(struct mmc *mmc, void *dst, lbaint_t blkcnt) +{ + return dm_mmc_get_b_max(mmc->dev, dst, blkcnt); +} + int dm_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, struct mmc_data *data) { diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 3e36566693..e22834398f 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -409,6 +409,16 @@ static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start, return blkcnt; } +#if !CONFIG_IS_ENABLED(DM_MMC) +static int mmc_get_b_max(struct mmc *mmc, void *dst, lbaint_t blkcnt) +{ + if (mmc->cfg->ops->get_b_max) + return mmc->cfg->ops->get_b_max(mmc, dst, blkcnt); + else + return mmc->cfg->b_max; +} +#endif + #if CONFIG_IS_ENABLED(BLK) ulong mmc_bread(struct udevice *dev, lbaint_t start, lbaint_t blkcnt, void *dst) #else @@ -422,6 +432,7 @@ ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, int dev_num = block_dev->devnum; int err; lbaint_t cur, blocks_todo = blkcnt; + uint b_max; if (blkcnt == 0) return 0; @@ -451,9 +462,10 @@ ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, return 0; } + b_max = mmc_get_b_max(mmc, dst, blkcnt); + do { - cur = (blocks_todo > mmc->cfg->b_max) ? - mmc->cfg->b_max : blocks_todo; + cur = (blocks_todo > b_max) ? b_max : blocks_todo; if (mmc_read_blocks(mmc, dst, start, cur) != cur) { pr_debug("%s: Failed to read blocks\n", __func__); return 0; diff --git a/include/mmc.h b/include/mmc.h index e83c22423b..a24e58b867 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -488,6 +488,19 @@ struct dm_mmc_ops { * @return 0 if not present, 1 if present, -ve on error */ int (*host_power_cycle)(struct udevice *dev); + + /** + * get_b_max - get maximum length of single transfer + * Called before reading blocks from the card, + * useful for system which have e.g. DMA limits + * on various memory ranges. + * + * @dev: Device to check + * @dst: Destination buffer in memory + * @blkcnt: Total number of blocks in this transfer + * @return maximum number of blocks for this transfer + */ + int (*get_b_max)(struct udevice *dev, void *dst, lbaint_t blkcnt); }; #define mmc_get_ops(dev) ((struct dm_mmc_ops *)(dev)->driver->ops) @@ -501,6 +514,7 @@ int dm_mmc_execute_tuning(struct udevice *dev, uint opcode); int dm_mmc_wait_dat0(struct udevice *dev, int state, int timeout_us); int dm_mmc_host_power_cycle(struct udevice *dev); int dm_mmc_deferred_probe(struct udevice *dev); +int dm_mmc_get_b_max(struct udevice *dev, void *dst, lbaint_t blkcnt); /* Transition functions for compatibility */ int mmc_set_ios(struct mmc *mmc); @@ -511,6 +525,7 @@ int mmc_wait_dat0(struct mmc *mmc, int state, int timeout_us); int mmc_set_enhanced_strobe(struct mmc *mmc); int mmc_host_power_cycle(struct mmc *mmc); int mmc_deferred_probe(struct mmc *mmc); +int mmc_get_b_max(struct mmc *mmc, void *dst, lbaint_t blkcnt); #else struct mmc_ops { @@ -521,6 +536,7 @@ struct mmc_ops { int (*getcd)(struct mmc *mmc); int (*getwp)(struct mmc *mmc); int (*host_power_cycle)(struct mmc *mmc); + int (*get_b_max)(struct mmc *mmc, void *dst, lbaint_t blkcnt); }; #endif From patchwork Sat Apr 4 10:45:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1266368 X-Patchwork-Delegate: van.freenix@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=fGEqiY7B; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48vYPp6LhHz9sPF for ; Sat, 4 Apr 2020 21:46:22 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 033D0813D9; Sat, 4 Apr 2020 12:45:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="fGEqiY7B"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4C79581289; Sat, 4 Apr 2020 12:45:30 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3F993804EC for ; Sat, 4 Apr 2020 12:45:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut@gmail.com Received: by mail-wm1-x342.google.com with SMTP id f20so1496775wmh.3 for ; Sat, 04 Apr 2020 03:45:24 -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=8dCJbbZMeqTocpe2cPV5VVJ922MEg5JsR+NuwgFkVcs=; b=fGEqiY7BehylViEWAS7Fo5Tjcn6eCijaaeHfH4YI2e4syyCoXfTZiu/lfvlY6ZRhBZ k4VO7F1dK76lQnl3LKvQk+8e0fw6dwnC5GzmwLLzt2zpD8OFbHZFCZ4PE7NuSuBZjbSi 6WAsxv3qdhy4vyAdRj/yIX3v3YsZmwfwiVdzZqUOtCUOm8U9/Zi7+dfUdZfsBPcjgGFe dHrVKYHF0m9XLSpIF87ro21rAHgiqCTkQttXVLg1b5dHqZ4jqmsEJ1gVlAWNoyHo5YzR WZLH3MPHQfSr0wtqLctLYP8udTEfcHwdJThkmjv3ZdwTCWm36ypc6l7YoC29R6snYUnt +Z5w== 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=8dCJbbZMeqTocpe2cPV5VVJ922MEg5JsR+NuwgFkVcs=; b=e882zzMLb1KDVTX26XY3HKUS83BWPZ2YMtAmKhsSxu5QxdMTXoqDDW5uEGKACw1AAn eI1w+GoR2xYJvzaVxMN3ODEmAYKjpYMXLV6X+V6YjapK/zmVj5Ua7c24KjA2xGdOsBlC p9m3Os2OxNHsKJhJL3+sfYhuwMRm1kBz0CuKwNFKw4uFQfwA7FWxLuXZOpHWYQQr2ZiP XHdAbILH7W/HxLpAlS0WVEwikOQcwbpQ6o/4vIqvfw2wGm86pw0+5MgNGcr0g9ZFV3XU Y/nRzmkni83Jp5MfFLZThEultZFb3KhkWS5rN0E9eNmasMMqCHy71aj5d06RZQtKo8ZZ vEEg== X-Gm-Message-State: AGi0PuauXRtqe367TchKFiTqWlqXYrJThaqH/Nvtd9+Zhfw2+0A5IKDz wCeOZmwtOq8eycs25UbLCmTo59jv X-Google-Smtp-Source: APiQypLJvQYLjBhY46z8ga5II52POTHoq3Bhq2o3H+jCQKKAFNkVUCBuQj94JxWhDq8lzoS/7KQ4Jw== X-Received: by 2002:a05:600c:2115:: with SMTP id u21mr2311030wml.147.1585997123475; Sat, 04 Apr 2020 03:45:23 -0700 (PDT) Received: from desktop.lan (ip-86-49-35-8.net.upcbroadband.cz. [86.49.35.8]) by smtp.gmail.com with ESMTPSA id i97sm11454644wri.1.2020.04.04.03.45.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Apr 2020 03:45:22 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Daniel Schwierzeck , Masahiro Yamada , Peng Fan , Simon Glass , Tom Rini Subject: [PATCH V2 5/5] mmc: tmio: sdhi: Implement get_b_max function Date: Sat, 4 Apr 2020 12:45:06 +0200 Message-Id: <20200404104506.386314-5-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200404104506.386314-1-marek.vasut+renesas@gmail.com> References: <20200404104506.386314-1-marek.vasut+renesas@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Implement get_b_max() for the Renesas R-Car SDHI controller driver, limit the b_max per hardware capabilities such that select Gen2 controllers have 16bit block transfer limit, the rest has 32bit block transfer limit and on Gen3, the block transfer limit on addresses above the 32bit boundary is set to 1/4 of the malloc area. Originally, on Gen3, the block transfers above the 32bit area were limited to PIO only, which resulted in (R8A7795 Salvator-X , HS200 eMMC): => time mmc read 0x0000000700000000 0 0x10000 time: 0.151 seconds => time mmc read 0x0000000700000000 0 0x100000 time: 11.090 seconds with bounce buffer in place and b_max adjustment in place: => time mmc read 0x0000000700000000 0 0x10000 time: 0.156 seconds => time mmc read 0x0000000700000000 0 0x100000 time: 2.349 seconds Note that the bounce buffer does mallocate and free the bounce buffer for every transfer. Experiment which removes this results in further increase of read speed, from 2.349s to 2.156s per 512 MiB of data, which is not such a significant improvement anymore. It might however be interesting to have bounce buffer directly in the MMC core or even block core. Signed-off-by: Marek Vasut Cc: Daniel Schwierzeck Cc: Masahiro Yamada Cc: Peng Fan Cc: Simon Glass Cc: Tom Rini --- V2: Fix printing of ubuf on 32bit systems, use %lx instead --- drivers/mmc/renesas-sdhi.c | 46 +++++++++++++++++++++++++++++--------- drivers/mmc/tmio-common.h | 1 + 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c index 231a78178c..88a7160b0a 100644 --- a/drivers/mmc/renesas-sdhi.c +++ b/drivers/mmc/renesas-sdhi.c @@ -692,28 +692,26 @@ static int renesas_sdhi_wait_dat0(struct udevice *dev, int state, #define RENESAS_SDHI_DMA_ALIGNMENT 128 -static int renesas_sdhi_addr_aligned(struct bounce_buffer *state) +static int renesas_sdhi_addr_aligned_gen(uintptr_t ubuf, + size_t len, size_t len_aligned) { - uintptr_t ubuf = (uintptr_t)state->user_buffer; - /* Check if start is aligned */ if (!IS_ALIGNED(ubuf, RENESAS_SDHI_DMA_ALIGNMENT)) { - debug("Unaligned buffer address %p\n", state->user_buffer); + debug("Unaligned buffer address %lx\n", ubuf); return 0; } /* Check if length is aligned */ - if (state->len != state->len_aligned) { - debug("Unaligned buffer length %zu\n", state->len); + if (len != len_aligned) { + debug("Unaligned buffer length %zu\n", len); return 0; } #ifdef CONFIG_PHYS_64BIT /* Check if below 32bit boundary */ - if ((ubuf >> 32) || (ubuf + state->len_aligned) >> 32) { - debug("Buffer above 32bit boundary %p-%p\n", - state->user_buffer, - state->user_buffer + state->len_aligned); + if ((ubuf >> 32) || (ubuf + len_aligned) >> 32) { + debug("Buffer above 32bit boundary %lx-%lx\n", + ubuf, ubuf + len_aligned); return 0; } #endif @@ -722,6 +720,14 @@ static int renesas_sdhi_addr_aligned(struct bounce_buffer *state) return 1; } +static int renesas_sdhi_addr_aligned(struct bounce_buffer *state) +{ + uintptr_t ubuf = (uintptr_t)state->user_buffer; + + return renesas_sdhi_addr_aligned_gen(ubuf, state->len, + state->len_aligned); +} + static int renesas_sdhi_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, struct mmc_data *data) { @@ -789,6 +795,24 @@ static int renesas_sdhi_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, return 0; } +int renesas_sdhi_get_b_max(struct udevice *dev, void *dst, lbaint_t blkcnt) +{ + struct tmio_sd_priv *priv = dev_get_priv(dev); + struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); + struct mmc *mmc = upriv->mmc; + size_t len = blkcnt * mmc->read_bl_len; + size_t len_align = roundup(len, RENESAS_SDHI_DMA_ALIGNMENT); + + if (renesas_sdhi_addr_aligned_gen((uintptr_t)dst, len, len_align)) { + if (priv->quirks & TMIO_SD_CAP_16BIT) + return U16_MAX; + else + return U32_MAX; + } else { + return (CONFIG_SYS_MALLOC_LEN / 4) / mmc->read_bl_len; + } +} + static const struct dm_mmc_ops renesas_sdhi_ops = { .send_cmd = renesas_sdhi_send_cmd, .set_ios = renesas_sdhi_set_ios, @@ -801,6 +825,7 @@ static const struct dm_mmc_ops renesas_sdhi_ops = { #if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) .wait_dat0 = renesas_sdhi_wait_dat0, #endif + .get_b_max = renesas_sdhi_get_b_max, }; #define RENESAS_GEN2_QUIRKS TMIO_SD_CAP_RCAR_GEN2 @@ -966,6 +991,7 @@ static int renesas_sdhi_probe(struct udevice *dev) return ret; } + priv->quirks = quirks; ret = tmio_sd_probe(dev, quirks); renesas_sdhi_filter_caps(dev); diff --git a/drivers/mmc/tmio-common.h b/drivers/mmc/tmio-common.h index 047458849b..2f671df4bc 100644 --- a/drivers/mmc/tmio-common.h +++ b/drivers/mmc/tmio-common.h @@ -147,6 +147,7 @@ struct tmio_sd_priv { u8 adjust_hs400_calibrate; u8 hs400_bad_tap; const u8 *adjust_hs400_calib_table; + u32 quirks; #endif ulong (*clk_get_rate)(struct tmio_sd_priv *); };