From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.groups.io with SMTP id smtpd.web12.4006.1574723580501323853 for ; Mon, 25 Nov 2019 15:13:00 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=EzmJmH/a; spf=pass (domain: linaro.org, ip: 209.85.221.68, mailfrom: ard.biesheuvel@linaro.org) Received: by mail-wr1-f68.google.com with SMTP id 4so16929829wro.7 for ; Mon, 25 Nov 2019 15:13:00 -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=gDUyfNqG5DgS3AODHiZ5Flqoyi0NfMmpvJeZXhtY6Zs=; b=EzmJmH/aCXyse0mpVqZgCesRZi/wQpEAOo/WWuwU27R5YCOYTDibWcZi3rHLwLLOkO 0tKKeXTwymXQ9EMSd0PJWfcEDsKvN2LCtyXYRyuJ9WXRVMIph27VfmiieI+lNAV0Axkv xHg+uvLf/gZ634VkZCHco/yVay4uYBozrQmyLo/O/XauoQ69JgqlxsAwbQ48G9AzJgl4 +XPwNr3dNfHUwYKku2zyn/HUN8FvVg4w/0iCulFzUZMpckJN6GKaoQa1WGclIGWVBsXZ ovWfAzkj9sCI2t4zvpTET6+0z7VytInYJYdNae0ybw43maw/TqEygX7I1E/1hiXW/kCP Xj9A== 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=gDUyfNqG5DgS3AODHiZ5Flqoyi0NfMmpvJeZXhtY6Zs=; b=mgH6tPO97Efn/ycgmBm5B+o4OCQkqAnntbToxOsLlxi9A2lDhdTVHZxqK9TyL3AWkc VMv3K7F4HgYT79rITjrpVmfYJCsuGkkjTHUzNWc6G4qdn10pMT2vmfNMfc7mZI9RiHa2 ocVkL6swcWTbTk0ySks4DoW9EDDgJi2DHgj+AEyJlO5Vglop1lyy9XuYc1SDFrmrbha5 SgbDk+LI8T26GH8mSPNCmsyTHO9VDyPvteWxuuE4iRAXjnej2+7a3V5FQkt10Fa3S+yO jkNW4hcgrEpp1ZmAFx4MedRBXA1p09UN4RiHAV5pa7XG1Efq1eZgeB3pnjQxuPnpZrCW 0VbQ== X-Gm-Message-State: APjAAAXudGUT6uSeXO3uGRZ59M0SHPUKF0tvA/a7HNmHhGAqwslRlQ1d 6dKz9PazTtACkkLdk+9drpkTvwFEhvNYdmmS X-Google-Smtp-Source: APXvYqw4n9U1V1lS1PqdJLqoRqOh9uho8ctL1H5zEEWzFkBYG40ONaa5QHzC2gHRVT3ZFjzEsawxuA== X-Received: by 2002:a5d:538d:: with SMTP id d13mr35854314wrv.304.1574723578786; Mon, 25 Nov 2019 15:12:58 -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 y6sm12601488wrr.19.2019.11.25.15.12.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2019 15:12:57 -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 v2 0/2] EmbeddedPkg: support for RPi4 PCI and platform DMA Date: Tue, 26 Nov 2019 00:12:40 +0100 Message-Id: <20191125231242.12193-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. Tested on Raspberry Pi 4. Changes since v1: - fix a few major issues in #1 - add Leif's ack to #2 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 | 165 ++++++++++- .../NonCoherentDmaLib/NonCoherentDmaLib.inf | 1 + 6 files changed, 465 insertions(+), 12 deletions(-) create mode 100644 EmbeddedPkg/Drivers/NonCoherentIoMmuDxe/NonCoherentIoMmuDxe.c create mode 100644 EmbeddedPkg/Drivers/NonCoherentIoMmuDxe/NonCoherentIoMmuDxe.inf -- 2.17.1