From patchwork Wed Aug 21 10:58:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 820973 Delivered-To: patch@linaro.org Received: by 2002:adf:e98a:0:b0:367:895a:4699 with SMTP id h10csp640987wrm; Wed, 21 Aug 2024 04:03:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUsuScs1mska67xvMChM9gu6874lEaawGhVCaONygTzr5w5onz9c86wUCZabz3KP5aKzI5D5A==@linaro.org X-Google-Smtp-Source: AGHT+IGCDJq5aihx1vDgeEqsgffC0bWE8MtKjQh1Qii7uCDwa+YUh5/xLiCtJkmCHVqV4nrOgj23 X-Received: by 2002:a2e:be09:0:b0:2ec:1810:e50a with SMTP id 38308e7fff4ca-2f3f893cc00mr11933981fa.32.1724238180121; Wed, 21 Aug 2024 04:03:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724238180; cv=none; d=google.com; s=arc-20160816; b=PRg3ft/8tu/WiRGbts0NuhCBSYhkI+zA6GP2vTWjvgcqJU27gVPcA3lm9HqVopmjsm nAMvQFyg7dNFea9Vi8umRERFrolwGw3uL5aOU/W9xiim23ftRsTSBFXtNdQo4ExGdGk4 nizDTsQKCpfpXcF6k/RVlVsgRMtkhI17LF9NC2heeWIyLC7z6L5YtoIt5e/rEHGAZoM2 Az9SnE5uxCCgVXNxGNz7+LkfzPmDf3E/cllfv9NEq5hBy1dih5S1n9v3560EzHR6U936 y3MTPacvPuSvKYzIuv2oNhOzBMxgH/52HUESoqDEofGH6iIUNceFPS6A3F/2eySgdmWM dGeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=IfK5Jx72o8oBnxtse+yS1qWQO/LCuBFLFoE7Y8R/Y4I=; fh=pnMZGD6unUPoMrkOwzXlkuYg+kVwGnSNRCTlQoWqjVc=; b=o4Q+yU2j08Ws3KJFcbBUGrxNqPLi+4vokPeKVohZT+zZDD3BeCSUIE8MFHBpQRVf7s WtXgg/2MSS65RHLk5cht57xlGi7EVGk8/QQA06LiZOzKii8P6H254GPcvMco0+ItWhDF G1Xbl5sRTfmhwEexbQ8oRgysF3Bu8tQilXfn+h1Snrjg+4N4rGkiO851feLNr7jZx4MA ycnrfG06tzYm3mYxcARwALJ63dmY5XsdA6oh62zeGCaQSpebhArdE4a+cZGM661usIKH DKv87h8yGfeR60yfi8BfX3n7UVIUhszaWDgKneBC59M2G+eqQYFrvzuSleQF+My/CEE7 LAdg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5bebbdefa77si8280974a12.167.2024.08.21.04.02.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 04:03:00 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 2EB0088C04; Wed, 21 Aug 2024 13:00:31 +0200 (CEST) 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 5079588113; Wed, 21 Aug 2024 13:00: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=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE 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 8038D88DDE for ; Wed, 21 Aug 2024 13:00:27 +0200 (CEST) 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 03780DA7; Wed, 21 Aug 2024 04:00:53 -0700 (PDT) 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 96AE93F73B; Wed, 21 Aug 2024 04:00:23 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Simon Glass , Tom Rini , Ilias Apalodimas , Heinrich Schuchardt , Marek Vasut , Mark Kettenis , Michal Simek , Patrick DELAUNAY , Patrice CHOTARD , Sughosh Ganu Subject: [PATCH v3 23/27] sandbox: iommu: remove lmb allocation in the driver Date: Wed, 21 Aug 2024 16:28:35 +0530 Message-Id: <20240821105839.2870293-24-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821105839.2870293-1-sughosh.ganu@linaro.org> References: <20240821105839.2870293-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 sandbox iommu driver uses the LMB module to allocate a particular range of memory for the device virtual address(DVA). This used to work earlier since the LMB memory map was caller specific and not global. But with the change to make the LMB allocations global and persistent, adding this memory range has other side effects. On the other hand, the sandbox iommu test expects to see this particular value of the DVA. Use the DVA address directly, instead of mapping it in the LMB memory map, and then have it allocated. Signed-off-by: Sughosh Ganu Reviewed-by: Simon Glass --- Changes since V2: None arch/sandbox/include/asm/test.h | 4 ++++ drivers/iommu/sandbox_iommu.c | 25 ++++++------------------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h index 17159f8d67..0e8d19ce23 100644 --- a/arch/sandbox/include/asm/test.h +++ b/arch/sandbox/include/asm/test.h @@ -49,6 +49,10 @@ struct unit_test_state; #define PCI_EA_BAR2_MAGIC 0x72727272 #define PCI_EA_BAR4_MAGIC 0x74747474 +/* Used by the sandbox iommu driver */ +#define SANDBOX_IOMMU_DVA_ADDR 0x89abc000 +#define SANDBOX_IOMMU_PAGE_SIZE SZ_4K + enum { SANDBOX_IRQN_PEND = 1, /* Interrupt number for 'pending' test */ }; diff --git a/drivers/iommu/sandbox_iommu.c b/drivers/iommu/sandbox_iommu.c index 5b4a6a8982..c5eefec218 100644 --- a/drivers/iommu/sandbox_iommu.c +++ b/drivers/iommu/sandbox_iommu.c @@ -5,23 +5,20 @@ #include #include -#include #include +#include #include -#define IOMMU_PAGE_SIZE SZ_4K - static dma_addr_t sandbox_iommu_map(struct udevice *dev, void *addr, size_t size) { phys_addr_t paddr, dva; phys_size_t psize, off; - paddr = ALIGN_DOWN(virt_to_phys(addr), IOMMU_PAGE_SIZE); + paddr = ALIGN_DOWN(virt_to_phys(addr), SANDBOX_IOMMU_PAGE_SIZE); off = virt_to_phys(addr) - paddr; - psize = ALIGN(size + off, IOMMU_PAGE_SIZE); - - dva = lmb_alloc(psize, IOMMU_PAGE_SIZE); + psize = ALIGN(size + off, SANDBOX_IOMMU_PAGE_SIZE); + dva = (phys_addr_t)SANDBOX_IOMMU_DVA_ADDR; return dva + off; } @@ -32,11 +29,9 @@ static void sandbox_iommu_unmap(struct udevice *dev, dma_addr_t addr, phys_addr_t dva; phys_size_t psize; - dva = ALIGN_DOWN(addr, IOMMU_PAGE_SIZE); + dva = ALIGN_DOWN(addr, SANDBOX_IOMMU_PAGE_SIZE); psize = size + (addr - dva); - psize = ALIGN(psize, IOMMU_PAGE_SIZE); - - lmb_free(dva, psize); + psize = ALIGN(psize, SANDBOX_IOMMU_PAGE_SIZE); } static struct iommu_ops sandbox_iommu_ops = { @@ -44,13 +39,6 @@ static struct iommu_ops sandbox_iommu_ops = { .unmap = sandbox_iommu_unmap, }; -static int sandbox_iommu_probe(struct udevice *dev) -{ - lmb_add(0x89abc000, SZ_16K); - - return 0; -} - static const struct udevice_id sandbox_iommu_ids[] = { { .compatible = "sandbox,iommu" }, { /* sentinel */ } @@ -61,5 +49,4 @@ U_BOOT_DRIVER(sandbox_iommu) = { .id = UCLASS_IOMMU, .of_match = sandbox_iommu_ids, .ops = &sandbox_iommu_ops, - .probe = sandbox_iommu_probe, };