From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 419A6C63793 for ; Thu, 22 Jul 2021 07:33:47 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E727760551 for ; Thu, 22 Jul 2021 07:33:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E727760551 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=etri.re.kr Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94.2) (envelope-from ) id 1m6TCu-0006Ri-SQ; Thu, 22 Jul 2021 03:33:24 -0400 Received: from mscreen.etri.re.kr ([129.254.9.16]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (Exim 4.94.2) (envelope-from ) id 1m6TCq-0006Q3-FT for kernelnewbies@kernelnewbies.org; Thu, 22 Jul 2021 03:33:21 -0400 Received: from unknown (HELO send002-relay.gov-dooray.com) (211.180.235.153) by 129.254.9.16 with ESMTP; 22 Jul 2021 16:33:14 +0900 X-Original-SENDERIP: 211.180.235.153 X-Original-MAILFROM: ckim@etri.re.kr X-Original-RCPTTO: kernelnewbies@kernelnewbies.org Received: from [10.162.225.112] (HELO smtp002-imp.gov-dooray.com) ([10.162.225.112]) by send002-relay.gov-dooray.com with SMTP id 4309e31960f91f3a; Thu, 22 Jul 2021 16:33:14 +0900 DKIM-Signature: a=rsa-sha256; b=wyKFaQZ2iDASVvCAPxPvvgn0V67GbPnVtvoNXkLwnOxdfVGPHbH4UxYvkgA74wRRe0ISZhbF5A 7+wI0bee/XjoUsp6EiuQogq2J6iDzqlOrfPRajPNbbmABvyusas6z8zOpym1Jvc9szkr5KYoWdGc 0fPUEghXMBR2PwBJDLG1bP7prgyY0YYx+WEpLVwdFptx1HqShu2ToB03VSEbKcRDuJz6H7qJQcK2 DfIbbyRLn5LycGpX/xiQock9vs5HFMvrsBcc76o1NQAiQKkRzuKGpqZd0wWpSLk/LYOVu8ZQNPqB ITT67VTlAdX6LbXcgoLEBl1kOmcQ3juLFMY7Ht8A==; c=relaxed/relaxed; s=selector; d=dooray.com; v=1; bh=F+bEbMVoUv0S1oBKjOPN44G3Ry1vvHOR0DgUoklzax4=; h=From:To:Subject:Message-ID; Received: from [129.254.132.39] (HELO CHANKIMPC) ([129.254.132.39]) by smtp002-imp.gov-dooray.com with SMTP id d55b6c9d60f91f39; Thu, 22 Jul 2021 16:33:14 +0900 From: To: Subject: a question about dma_set_mask function Date: Thu, 22 Jul 2021 16:33:13 +0900 Message-ID: <00a201d77ecb$d4339490$7c9abdb0$@etri.re.kr> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 thread-index: Add+y8CaBXPr/v0SQaeHjoYesXdmsQ== Content-Language: ko X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============5942361156257592478==" Errors-To: kernelnewbies-bounces@kernelnewbies.org This is a multipart message in MIME format. --===============5942361156257592478== Content-Type: multipart/alternative; boundary="----=_NextPart_000_00A3_01D77F17.441C26F0" Content-Language: ko This is a multipart message in MIME format. ------=_NextPart_000_00A3_01D77F17.441C26F0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello, I have a question about DNA (I was reading DMA-API-HOWTO.txt ). You know regarding DMA, there is cpu virtual address, cpu physical address and bus address for the device. Bus address is converted to cpu physical address using bridge or bus controller to which the device is attached. And for platform device, bus address is equal to the cpu physical address. The DMA-API-HOWTO.txt says > When dma_set_mask() or dma_set_mask_and_coherent() is successful, and > returns zero, the kernel saves away this mask you have provided. The > kernel will use this information later when you make DMA mappings. So I guess when the driver later requests memory for dma using dma_map_..(ex. dma_map_single, or dma_map_sg) function, the kernel allocates memory and sets up page table and it sets the bus address in the ranges supported by the dma_mask. The virtual address is returned by the function, but where is this 'bus address' kept? I see a pointer to the struct page in the function argument, Is it kept in this struct array? Or is the bus address just the physical address(pfn) in the page table?(I guess so) And when the device has a separate iommu(like arm64's SMMU), I guess the DMA virtual address (assigned for dma by the kernel) for the device is first converted to the bus address by iommu and then the bus address is converted to physical address by bus bridge. Is my understanding correct? It's so confusing.. Any explanation or comment will be deeply appreciated. Thanks! Chan Kim ------=_NextPart_000_00A3_01D77F17.441C26F0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hello,

 

I have a question about DNA (I was = reading DMA-A= PI-HOWTO.txt ).

You know regarding DMA, there is cpu virtual address, cpu = physical address and bus address for the device. =

Bus = address is converted to cpu physical address using bridge or bus = controller to which the device is attached.

And for platform device, bus = address is equal to the cpu physical address.

 

The DMA-A= PI-HOWTO.txt says

 

> When dma_set_mask() or dma_set_mask_and_coherent() is = successful, and

> returns zero, the kernel saves away this mask you have = provided.  The

> kernel will use this information later when you make = DMA mappings.

 

So I guess when the driver later requests memory for dma = using dma_map_..(ex. dma_map_single, or dma_map_sg) function, =

the kernel = allocates memory and sets up page table and it sets the bus address in = the ranges supported by the dma_mask.

The virtual address is returned by = the function, but where is this ‘bus address’ kept? I see a = pointer to the struct page in the function argument, Is it kept in this = struct array? Or is the bus address just the physical address(pfn) in = the page table?(I guess so)

And when the device has a separate = iommu(like arm64’s SMMU), I guess the DMA virtual address = (assigned for dma by the kernel) for the device is first converted to = the bus address by iommu and then the bus address is converted to = physical address by bus bridge. Is my understanding = correct?

It’s so confusing.. Any explanation or comment will = be deeply appreciated.

Thanks!

 

Chan Kim

 

 

 

------=_NextPart_000_00A3_01D77F17.441C26F0-- --===============5942361156257592478== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies --===============5942361156257592478==--