From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400d:c0d::235; helo=mail-qt0-x235.google.com; envelope-from=rafaelrodrigues.machado@gmail.com; receiver=edk2-devel@lists.01.org Received: from mail-qt0-x235.google.com (mail-qt0-x235.google.com [IPv6:2607:f8b0:400d:c0d::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9B59521E256AB for ; Thu, 25 Jan 2018 10:47:48 -0800 (PST) Received: by mail-qt0-x235.google.com with SMTP id i1so21797286qtj.8 for ; Thu, 25 Jan 2018 10:53:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=6QDAcm8MXsHudxOwbTQ4gRoD2dFaaNiQtfBeLch+L8c=; b=LZcirMQKKHYDrWtpok0vAvKEM6/4HqkGnzcHP4JnMPnJSkaJWk9Uk6GrwetezIcVc0 Bdy8RM1xsQ1JxKWU9cX+/kKi4kP4wp4pxiykSlBhhKHMIO9Yvbg+MhxoEjz0rIlwg7rz yS5H69P72WhJDpM3o8G2RtGuqdkCVCm+78C5C5JEYi1sqSIErG1eBBrkqdBmfCMQLEYc gH1ACxrFBup0ZAOf4j+7NbtxmeNXNwBr744pRiKmPoetEOLMU1Zke26kNRz0yWCVHz52 0ofjRFEtOU9iJd5MUyz5bBxvu3tDE+hN92EK8QYRFZQWRHpYeqM0ez9IgXreScraMGx6 0hYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=6QDAcm8MXsHudxOwbTQ4gRoD2dFaaNiQtfBeLch+L8c=; b=n0PvSzDDH+XmPjv298OYm/UUM+OAedrqLbYBkipHFA2D+Y49MitPtDqKqt1aubsGHN bx1xgAFQST+nJpQnuYRnNG7b5HIWtpUUYIt4Pmx2SXBIG8TfJr5Yw/TR3h1qPJAjVTIB ICwvQ9E0tjTa91z8lidSMc70LpApkDuHujo89/TtxX8C7Bff8pLfZg6ARjahkoJjhnFH bNtzKR5TY/Clpc1vps5u4ZTzleSDYvb/rjnRPT5Jeh0Y9NfJ1ErSyDjaHuXXSo6Hz5b9 r9p92hNQnCvuWjKFyNsodQnUfG6DSCGEn70pTM1HIfnpGNhJjguwZ13JLzd315GSwkXe PcUA== X-Gm-Message-State: AKwxytepceEIjj7ManT7g94aBX9SxO9TFviRMpJxZdlnmj8LP9JXmCCv gvc4/MgInk7cmhvonML1cFwhs7+AHgJBHv9buqs= X-Google-Smtp-Source: AH8x227petNbIQVtG2OeF6SBoiGN3HZF6ETs1KaSsaKEsqEvuobaJZvFHTlMZvmHecHakr6mOdTdcSMIYntEKKNnhDM= X-Received: by 10.55.110.193 with SMTP id j184mr16048513qkc.70.1516906396995; Thu, 25 Jan 2018 10:53:16 -0800 (PST) MIME-Version: 1.0 From: Rafael Machado Date: Thu, 25 Jan 2018 18:53:06 +0000 Message-ID: To: "edk2-devel@lists.01.org" X-Content-Filtered-By: Mailman/MimeDel 2.1.23 Subject: DMA Buffer write operation not persisted X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Jan 2018 18:47:49 -0000 Content-Type: text/plain; charset="UTF-8" Hi everyone. I'm currently work on a task, and I need to write some data at a DMA buffer. At the UEFI Driver Writer's guide, at page 359 there is a sample code of how to do that. Considering that code and adapting to my scenario I got the following function (some debug prints are present for clarification): EFI_STATUS EFIAPI DoBusMasterWrite ( IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciIo, IN UINT8 *HostAddress, IN UINTN *Length, IN UINT32 Value ) { EFI_STATUS Status; UINTN NumberOfBytes; EFI_PHYSICAL_ADDRESS DeviceAddress; VOID *Mapping; UINT64 ReadValue; // // Call Map() to retrieve the DeviceAddress to use for the bus // master write operation. The Map() function may not support // performing a DMA operation for the entire length, so it may // be broken up into smaller DMA operations. // NumberOfBytes = *Length; Status = PciIo->Map (PciIo, // This EfiPciIoOperationBusMasterCommonBuffer, // Operation (VOID *)HostAddress, // HostAddress &NumberOfBytes, // NumberOfBytes &DeviceAddress, //DeviceAddress &Mapping //Mapping); if (EFI_ERROR (Status)) { return Status; } // // Write the data to the desired address // This write operation also starts the DMA transaction // Status = PciIo->Mem.Write (PciIo, // This EfiPciIoWidthUint32, // Width *HostAddress, 1, // Count &Value // Buffer ); Print(L"NumberOfBytes: %d\r\n", NumberOfBytes); Print(L"address: 0x%x\r\n", HostAddress); Print(L"Value: 0x%x\r\n", Value); Print(L"Status: %r\r\n", Status); if (EFI_ERROR (Status)) { return Status; } // // The operations performed by PollMem() also flush all posted // writes from the PCI bus master and through PCI-to-PCI bridges. // Status = PciIo->PollMem (PciIo, // This EfiPciIoWidthUint32, // Width *HostAddress, // Offset 0xFFFFFFFF,// Mask Value,// Value EFI_TIMER_PERIOD_SECONDS (1), // Timeout &ReadValue // Result ); Print(L"Status2: %r\r\n", Status); if (EFI_ERROR (Status)) { return Status; } // // Call Flush() to flush all write transactions to system memory // Status = PciIo->Flush (PciIo); Print(L"Status3: %r\r\n", Status); if (EFI_ERROR (Status)) { return Status; } // // Call Unmap() to complete the bus master write operation // Status = PciIo->Unmap (PciIo, Mapping); Print(L"Status4: %r\r\n", Status); if (EFI_ERROR (Status)) { return Status; } return Status; } The output of this function is this: NumberOfBytes: 4 address: 0xCCCAC000 Value: 0xAAAAA Status: Success Status2: Success Status3: Success Status4: Success The problem is that when I try to read this memory content using the dmem command at the efiShell the value 0xAAAAA cannot be found. Seems something is locking the DMA trasaction. Can someone give me some light? Thanks and Regard Rafael R. Machado