From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.groups.io with SMTP id smtpd.web10.21116.1574325143913469342 for ; Thu, 21 Nov 2019 00:32:24 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=xidDaHch; spf=pass (domain: linaro.org, ip: 209.85.221.65, mailfrom: ard.biesheuvel@linaro.org) Received: by mail-wr1-f65.google.com with SMTP id a15so3234362wrf.9 for ; Thu, 21 Nov 2019 00:32:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=O9EkHFSprbmkQBXsWT8iC6Ze1pB45tgiuaTKChLwuNk=; b=xidDaHchI8EFzaUVI+6Gd3Cd2FHwmWjpSjrju/nxzo9+iN44FIeVinIyEKZVIZLJDI 87XROBR1FK7bcry7QLq4jnJjoVefFi+2SnZRpl3BVrKgakM/gU8XjqUWZgBs7z+s9BRp 1uljU4HS3mhCwvT+P2TUGYzfed7SZ4PCctfLBPq5q+4F0T1FD43cq9flAGV5xF4T0/Vf f4WV2i8oMf4u+37IvfOBoIEUEk+jIpOBkdpuuwj7T671puLCoiIzKc9uddmToqfrkPQK CYdKhgTT6RiFHSh6Fclb6ddzESz0SFNlhJeqgYgmMW8YP00uCVZVCJ64fc+FudCC4quh x9dQ== 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; bh=O9EkHFSprbmkQBXsWT8iC6Ze1pB45tgiuaTKChLwuNk=; b=UM5k+lKLP9mW/1bwtbfzeJyOlc/MbiY3Tq6Np+Ufa3OnduYLbBkdRhXBiX2Gi6gBJA TgEfGFziOJlJsoLmImE3frtqaT0n4MVpwivW+7DZDitYDwG7eUrIZHA2eE+bUKQcVB3s 6vDOTjV+r9LvGov7ms8mQOVFiYM/NPX+g915wGmPl2Cn/zdrPZxGTwBKZVhP+oXX/RcK st51Fd5Hg7Ho9qApBKxu9a6r+qqIa1HzYDcrHwOzEpIr5WACDDBxghezz60j2sXdG90l +lrcpa+25xslQNnlT8Vq9HniYCtGOHdkzIYRrSMJbiul6dasmKkUHWTqR2tEsuH/cF8b Bkhg== X-Gm-Message-State: APjAAAUZLg7tw4U5ztKWeSOYaI9SyMBwWchi+WI8IYaSLBTEhkFu6kdb V3A24xmTB78VlK+iR7twhbScbRYGrPEMk7W8 X-Google-Smtp-Source: APXvYqwb1dr9Zd6lvdLRcJUdw9HcW3ldRCm/gYCncNLjQkm1LGG5VOByo0FJOw7MDFxbBYFGb2c4ow== X-Received: by 2002:a5d:5224:: with SMTP id i4mr8982331wra.303.1574325142223; Thu, 21 Nov 2019 00:32:22 -0800 (PST) Return-Path: Received: from e123331-lin.home (lfbn-mar-1-643-104.w90-118.abo.wanadoo.fr. [90.118.215.104]) by smtp.gmail.com with ESMTPSA id u18sm2435667wrp.14.2019.11.21.00.32.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2019 00:32:21 -0800 (PST) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif.lindholm@linaro.org, Ard Biesheuvel , awarkentin@vmware.com, jeremy.linton@arm.com, pete@akeo.ie, samer.el-haj-mahmoud@arm.com Subject: [PATCH 0/2] EmbeddedPkg: support for RPi4 PCI and platform DMA Date: Thu, 21 Nov 2019 09:32:25 +0100 Message-Id: <20191121083227.2850-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 This set implements two changes to the support we have in EmbeddedPkg for non-coherent DMA, which together should allow the Raspberry Pi4 to use both the platform and PCI based DMA devices. Patch #1 implements support for limiting DMA to a certain memory region. This is necessary given that the RPi4 ships with more than 1 GB of memory in some configurations, but uses DMA translation for the platform devices in a way that puts that memory out of reach for 32-bit DMA (i.e., the DMA translation is +3 GB). By setting the device DMA limit to MAX_UINT32, the library will infer a host address limit of 1 GB, and use bounce buffering if any buffers are mapped outside that region. Patch #2 implements a trivial wrapper around DmaLib that exposes the EDK2 IoMmu protocol. This is used by the generic PCI infrastructure instead of the builtin DMA routines when the protocol exists, so it is a natural place to implement the non-cache coherent DMA handling we need for the RPi4. Patch #1 is build tested only. Patch #2 was tested on actual h/w. Cc: awarkentin@vmware.com Cc: jeremy.linton@arm.com Cc: pete@akeo.ie Cc: samer.el-haj-mahmoud@arm.com Ard Biesheuvel (2): EmbeddedPkg/NonCoherentDmaLib: implement support for DMA range limits EmbeddedPkg: implement EDK2 IoMmu protocol wrapping DmaLib .../NonCoherentIoMmuDxe/NonCoherentIoMmuDxe.c | 257 ++++++++++++++++++ .../NonCoherentIoMmuDxe.inf | 43 +++ EmbeddedPkg/EmbeddedPkg.dec | 6 + EmbeddedPkg/EmbeddedPkg.dsc | 5 + .../NonCoherentDmaLib/NonCoherentDmaLib.c | 176 ++++++++++-- .../NonCoherentDmaLib/NonCoherentDmaLib.inf | 1 + 6 files changed, 463 insertions(+), 25 deletions(-) create mode 100644 EmbeddedPkg/Drivers/NonCoherentIoMmuDxe/NonCoherentIoMmuDxe.c create mode 100644 EmbeddedPkg/Drivers/NonCoherentIoMmuDxe/NonCoherentIoMmuDxe.inf -- 2.17.1