From patchwork Tue Sep 14 18:19:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Fazio X-Patchwork-Id: 1528190 X-Patchwork-Delegate: pbrobinson@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=xes-inc.com header.i=@xes-inc.com header.a=rsa-sha256 header.s=mail header.b=t7jGBErD; dkim-atps=neutral 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=) 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 4H8NRR3H13z9t0Z for ; Wed, 15 Sep 2021 11:48:51 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3FB6B81BC0; Wed, 15 Sep 2021 03:48:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=xes-inc.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=xes-inc.com header.i=@xes-inc.com header.b="t7jGBErD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 028C280612; Tue, 14 Sep 2021 20:19:43 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.xes-mad.com (mail.xes-mad.com [162.248.234.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AE2DC82A15 for ; Tue, 14 Sep 2021 20:19:37 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=xes-inc.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=vfazio@xes-inc.com Received: from vfazio2.xes-mad.com (vfazio2.xes-mad.com [10.52.16.113]) by mail.xes-mad.com (Postfix) with ESMTP id 22DED22384; Tue, 14 Sep 2021 13:19:36 -0500 (CDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xes-inc.com; s=mail; t=1631643576; bh=ZRvwT48saaTJqHZRVrKzh+HGBpKo1Q4DTbW/qyLN9Cg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t7jGBErDEZW3B0vG/TLGYMWsLnP8fvosV1wot40SkUDVXwOyeyEizwcYLZkt68sCJ 44nK5R2tB+m2PtmYG7Ba6IA8xa5xdTiQMhvE7oX+Dif7NnhMrB7vXWvVNJAusA+A3z ZQsqRc5xV/LyCJvuA5G7Rdx8Ikb6Z2kChNtMZvH0= From: Vincent Fazio To: u-boot@lists.denx.de Cc: Matthias Brugger , Jaehoon Chung , Peng Fan , Vincent Fazio Subject: [PATCH 1/2] arm: rpi: fallback to max clock rate for MMC clock Date: Tue, 14 Sep 2021 13:19:18 -0500 Message-Id: <20210914181919.584951-2-vfazio@xes-inc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210914181919.584951-1-vfazio@xes-inc.com> References: <20210914181919.584951-1-vfazio@xes-inc.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 15 Sep 2021 03:48:23 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.103.2 at phobos.denx.de X-Virus-Status: Clean In rpi-firmware 25e2b597ebfb2495eab4816a276758dcc6ea21f1, the GET_CLOCK_RATE mailbox property was changed to return the last value set by SET_CLOCK_RATE. https://github.com/raspberrypi/firmware/issues/1619#issuecomment-917025502 Due to this change in firmware behavior, bcm2835_get_mmc_clock now returns a clock rate of zero since we do not issue SET_CLOCK_RATE. This results in degraded MMC performance. SET_CLOCK_RATE fixes the clock to a specific value and disables scaling so is not an ideal solution. Instead, fallback to GET_MAX_CLOCK_RATE in bcm2835_get_mmc_clock if GET_CLOCK_RATE returns zero. Signed-off-by: Vincent Fazio --- arch/arm/mach-bcm283x/include/mach/mbox.h | 2 ++ arch/arm/mach-bcm283x/msg.c | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-bcm283x/include/mach/mbox.h b/arch/arm/mach-bcm283x/include/mach/mbox.h index 2ae2d3d97c..7dcac583cc 100644 --- a/arch/arm/mach-bcm283x/include/mach/mbox.h +++ b/arch/arm/mach-bcm283x/include/mach/mbox.h @@ -224,6 +224,8 @@ struct bcm2835_mbox_tag_set_power_state { }; #define BCM2835_MBOX_TAG_GET_CLOCK_RATE 0x00030002 +#define BCM2835_MBOX_TAG_GET_MAX_CLOCK_RATE 0x00030004 +#define BCM2835_MBOX_TAG_GET_MIN_CLOCK_RATE 0x00030007 #define BCM2835_MBOX_CLOCK_ID_EMMC 1 #define BCM2835_MBOX_CLOCK_ID_UART 2 diff --git a/arch/arm/mach-bcm283x/msg.c b/arch/arm/mach-bcm283x/msg.c index 347aece3cd..ae85e9159e 100644 --- a/arch/arm/mach-bcm283x/msg.c +++ b/arch/arm/mach-bcm283x/msg.c @@ -75,6 +75,7 @@ int bcm2835_get_mmc_clock(u32 clock_id) { ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_clock_rate, msg_clk, 1); int ret; + u32 clock_rate = 0; ret = bcm2835_power_on_module(BCM2835_MBOX_POWER_DEVID_SDHCI); if (ret) @@ -90,7 +91,23 @@ int bcm2835_get_mmc_clock(u32 clock_id) return -EIO; } - return msg_clk->get_clock_rate.body.resp.rate_hz; + clock_rate = msg_clk->get_clock_rate.body.resp.rate_hz; + + if (clock_rate == 0) { + BCM2835_MBOX_INIT_HDR(msg_clk); + BCM2835_MBOX_INIT_TAG(&msg_clk->get_clock_rate, GET_MAX_CLOCK_RATE); + msg_clk->get_clock_rate.body.req.clock_id = clock_id; + + ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_clk->hdr); + if (ret) { + printf("bcm2835: Could not query max eMMC clock rate\n"); + return -EIO; + } + + clock_rate = msg_clk->get_clock_rate.body.resp.rate_hz; + } + + return clock_rate; } int bcm2835_get_video_size(int *widthp, int *heightp)