From patchwork Wed Nov 27 07:12:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 845746 Delivered-To: patch@linaro.org Received: by 2002:a5d:6989:0:b0:382:43a8:7b94 with SMTP id g9csp643381wru; Tue, 26 Nov 2024 23:13:15 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVesJFv6exQJLQrQZUultfT53oP8fSEMBZ+YOptxpO7Co8o+VXMnSnICJIaJlxVvkcwXr21gA==@linaro.org X-Google-Smtp-Source: AGHT+IE2bIAknFqR0GZ8wlhkQNmgOWOx2GAAZCQ4AJhlzph6EMGMjq6CD0t3hlAOsMpmtEV/j+0Z X-Received: by 2002:a17:906:cc56:b0:aa5:451c:ce20 with SMTP id a640c23a62f3a-aa58105980dmr113862166b.40.1732691594898; Tue, 26 Nov 2024 23:13:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732691594; cv=none; d=google.com; s=arc-20240605; b=B0ojq+UDB6Nw+e3JeJ4VCbHRzvLLJID1BIIBbNuWw7t3/pAF/ZqHbEb5vhiK51ePzv sRDzX++7gFsCBG+M8L+sZ+q/pmoxYIqJ4ywWLt6fpvHGHdCdK8M7KfLLCiS6NYW8jtHb tck0Mf0mPGhnD0bHiwHzVpoCojjNTxUMGlejVv3BM+RTIz10TXqAUBjhFYllOAN4LztL CTXUllpmsA+z9BSOWqam5aKOkLiYTV/MMkKbBE+u+hMivMEvWYkehbAYNQBYkJjQtR6O 8dTN8QKZ80dugfKz6uW3/ZxPNdgGyHj/Ng/poPH8CVEFnABgWuhU/Z4SW0d/bFaRnWmo s/Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=d2aF8E67n0YRJu+iNUN94nkCZZqiuGDagRDdnbmymyM=; fh=XQqClP2JY+Zsz5EjxBnUTa/Vp9x50nQR/jVjZleIhn4=; b=kvBdhvkmRyp1SiOXepqrEXnU3GpQq5pPqalrAlr/x7VsthK4c8Lp5pAUiSELA6UjOe YhEvZf7gBOpExRk3N0i80n49SiRlIAgh/NLCJLknq6YWgE4eJ9tGNO5CQcvMEd1F7DAi D3vjPZJiWp+Yz6flY/KQvENLHNvm3kJYxtgvfMCpySyGPg1nE5j8iG//2YU+AZWiF98D zgx5nYHX5Srw/VlTLcy1ZG7rHUM9s2zGA4RQLwaryZAfZbAmIyS8MVS1JdtKxc78m9U9 pkfNztsfYKgFyf45ppkheZyHUddURI9yGoUaQySkScu+Y5WKT7txzOA77ECqVGZas13s pOHg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-aa57a87fc91si127050266b.64.2024.11.26.23.13.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2024 23:13:14 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BDA2D89CD6; Wed, 27 Nov 2024 08:13:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id E3D1E89794; Wed, 27 Nov 2024 08:13:07 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id E09B9896FF for ; Wed, 27 Nov 2024 08:13:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 33F012444; Tue, 26 Nov 2024 23:13:35 -0800 (PST) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5A1593F58B; Tue, 26 Nov 2024 23:13:02 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , E Shattow , Simon Glass , Tom Rini , Minda Chen , Hal Feng , Sughosh Ganu Subject: [PATCH 1/2] bouncebuf: allow for allocating bounce buffer frome heap Date: Wed, 27 Nov 2024 12:42:49 +0530 Message-Id: <20241127071250.736762-2-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241127071250.736762-1-sughosh.ganu@linaro.org> References: <20241127071250.736762-1-sughosh.ganu@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean The current bounce buffer logic checks if the user passed buffer is DMA aligned, and if so, the same buffer is used. This can be an issue on platforms which have certain IP's that are unable to access memory addresses above a certain point. Introduce a config symbol that can be used by such platforms which forces the bounce buffer logic to allocate the buffer from the heap which is part of the U-Boot image area. Signed-off-by: Sughosh Ganu --- common/bouncebuf.c | 2 +- drivers/core/Kconfig | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/common/bouncebuf.c b/common/bouncebuf.c index b2f87e4d93..f827378e5f 100644 --- a/common/bouncebuf.c +++ b/common/bouncebuf.c @@ -44,7 +44,7 @@ int bounce_buffer_start_extalign(struct bounce_buffer *state, void *data, state->len_aligned = roundup(len, alignment); state->flags = flags; - if (!addr_is_aligned(state)) { + if (CONFIG_IS_ENABLED(BOUNCE_BUFFER_ALLOC) || !addr_is_aligned(state)) { state->bounce_buffer = memalign(alignment, state->len_aligned); if (!state->bounce_buffer) diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig index 6b4330fe4e..94258e8761 100644 --- a/drivers/core/Kconfig +++ b/drivers/core/Kconfig @@ -476,4 +476,11 @@ config BOUNCE_BUFFER A second possible use of bounce buffers is their ability to provide aligned buffers for DMA operations. +config BOUNCE_BUFFER_ALLOC + bool "Allocate memory for bounce buffer" + depends on BOUNCE_BUFFER + help + Certain platforms have IP's which are unable to access addresses above + a certain value. This symbol forces the bounce buffer to be allocated + from within the U-Boot image area for such platforms. endmenu