Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp722715iog; Fri, 17 Jun 2022 12:06:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vvlPa24S0hgqXSM39hc60Ufcw/uMFCCV6h8dszykuFSbhEdJbycmuFu0Ysp98ucjfGfhMC X-Received: by 2002:a17:90a:430a:b0:1ea:e7f4:9f59 with SMTP id q10-20020a17090a430a00b001eae7f49f59mr11496105pjg.75.1655492816723; Fri, 17 Jun 2022 12:06:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655492816; cv=none; d=google.com; s=arc-20160816; b=RE/PdfQvrHVTA9oHJiq5qL1DOuy2KAhZheDReWLu/qNX++IntCycn3Kdukmk/e35cj 2P9563EUD9zPhX80hN/HlVJhVpTaw+tAHW8of9Pb30v6e6B2Zk2f13lESnW2+JLeAvEk CesET1khtmblgJ/nSXHkxsbRKBokRdYNISDxRgGg+hiSoSr8o/nkBP6iQmi1MQJwH7L5 Ge3oR5myHxQDvPyY9vgCTiWloopko8u3CgSi2guzzFh26FTWvYJhW7i74AhzhucbZjPf qvS6lK99UD+iGZ6uH6m4N99gEDfiwSZPxr5kUZsUFS+GsZOKDMv5+s9AqSjYmih4f9TO 5a0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:references:in-reply-to :sensitivity:importance:date:subject:cc:to:from:message-id :mime-version:dkim-signature; bh=5vgmbhFpQ6A9bkTaYfYOzcd1/69qFhx1POEBzucmZU4=; b=zNZiHh55v9RbdLPdodYXxh1MQerQ1lUk/bSABC5DGU4G7umH4rtwWED6M+mtPQLBAc k5k4WFGg0iRdWoNnKhit8ZPSSFVMDRM2ZxakQm7G8krnGLP0+aYy5ChRSaHLKRrx9ABM fIZK6dQZO68gLm0GTPE9tRw6XvEM68OpTrnLw2nOyO+/qcPWjl8c7ol5pQr0LxsCUx4Z KuwOuSYFpOFHsLpdYd35y7Q54ci40Cq4/ianGiklKghQKiwsoWqSSoZng0A4rSi7Yfan 9x1PMm7BDqBCBHF/mi8XNR721s3Px5GbOpiCf1nhu6xm2DSxGUaQ2dfsWftJBE+F71Bo EYGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=i+a+pQW8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o6-20020a63fb06000000b003fa34f038afsi6308414pgh.159.2022.06.17.12.06.44; Fri, 17 Jun 2022 12:06:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=i+a+pQW8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233252AbiFQSzJ (ORCPT + 99 others); Fri, 17 Jun 2022 14:55:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229693AbiFQSzI (ORCPT ); Fri, 17 Jun 2022 14:55:08 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B01D13EA83 for ; Fri, 17 Jun 2022 11:55:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1655492096; bh=5TERitrWUvvUfTI5MhjoAnMJtaxI+oi4yMzwuHPSIUs=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=i+a+pQW8GlxSWj07fLslQTwc24Fe6QepDIgw4YDFU5CRqlZtOLguwhOt5xQLqK59r aIyVp69kLQ950G7iYgrKcM08OyMGZ2dm7qX++OTpFYtscahIzIA/+WkZ3fVeG14gbR r+yzaXE0SuGkW7fl6rWgl5KPY9tLoyYjLVkYH8wM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [217.61.144.127] ([217.61.144.127]) by web-mail.gmx.net (3c-app-gmx-bap03.server.lan [172.19.172.73]) (via HTTP); Fri, 17 Jun 2022 20:54:56 +0200 MIME-Version: 1.0 Message-ID: From: Frank Wunderlich To: Robin Murphy Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Marek Szyprowski Subject: Aw: Re: helping with remapping vmem for dma Content-Type: text/plain; charset=UTF-8 Date: Fri, 17 Jun 2022 20:54:56 +0200 Importance: normal Sensitivity: Normal In-Reply-To: <88080559-0c96-ec91-6f72-df05a2d0c5af@arm.com> References: <88080559-0c96-ec91-6f72-df05a2d0c5af@arm.com> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:NEHWw+yzysQMeV3UCczydEq2+A+cbQ0zKtwmSr3mWWJSVTqpr/npypc8nYI/Lj586NJZ8 ZQdk6Dll3i+7Lt+GdW3tkpTctzcCH647OJopRuFd5KBEKImQ3T3735UbZYfuB43hER8UQerSWrUE DbDyN0V0fTc5aHyWuJqK/4wKy4HtVDvAw8vyBBkX8DJ64lzl6JLDdnK76o0FImdtly1cyKCBvFbf aHkEJ1+1wMyZ/rMzXfyUjiOu5C+cH489uun/J0whgoyHbhM9Hvhxk1y2JPHcvZmDl3ZIXxYI4Q63 pc= X-UI-Out-Filterresults: notjunk:1;V03:K0:UxGlKHXmd08=:mO4sRPmbDS3nNfb4UPq1zD QL/3on00tn85Gwlp9cHm+SHcY07rN4H00WATjI9vgWy0erTIvxApS5KQybYJVc1iqw1afw6oJ CDWsjaq0bp89rnTXVq0uosv6bG2cHQZ2p8ztoqAR6G1Z4onmoB0cefui3tD2HbWQfA51Ge9ZA AelTe/1RhVQUd1dr9YkVfsmKnHWFioxWBxFmjfarcZB1Fi99zFybB+scNvLNN2w4v3TW8jaHI oB/XCJB4quMOlwF2K8dJFLp3rMaw50/AmUHui7Aani5rt5ipI7T3VST67f43qbvr6AWMyfRq+ 0C53RM+dqlCChFCe9RdxrlUi5saXtMzyHcNWl6NAj7/+hyWMBTgURsOa4DNoCe0erudLa3VV5 Pm5keMe0gQTEMZoVlPoFiE7mnHVwSNNcGCOrZ2+LqgKJWRyhuz4KfORDOeouj3tB/FAPYPVnR cu0pSxyaM/Z3aZRur0rL90NVJCMX3obV0dkplYept+pMUGozKi3MQqwx7oyXHfce5PeAKB4FC CwzsElTEiAqpY0KyMnzoXsTpWWAXpf1QO3S4LcwygeAB5MPEpkZBhvnTQjKeQNwIc8OxIcPMw ukmTOi9KdfnYPaYF9tdOiwROHm5zpMY/b2hdCEhdZVLG0XLiLEPyokardiyfrgW4iKenlR3c6 oOrRDGagOv/Uy3Dx3igqd1D6GCGqUVc+o74IDc5QCfsmhHZnVFg0dABjg0h1x/gCeC5ABmpIM fUlhN48hzoXGiq2/1xZ3kjyDy20I3ZUbAl3Z5LsNIy852vxNHLAmHDSQlkW96b0GwAyXggMAr S0BdvkF Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Gesendet: Freitag, 17. Juni 2022 um 19:22 Uhr > Von: "Robin Murphy" > An: "Frank Wunderlich" , "Christoph Hellwig" > Cc: linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, "Mar= ek Szyprowski" > Betreff: Re: helping with remapping vmem for dma > > On 2022-06-17 17:17, Frank Wunderlich wrote: > > Am 15. Juni 2022 15:17:00 MESZ schrieb Christoph Hellwig : > >> On Wed, Jun 15, 2022 at 02:15:33PM +0100, Robin Murphy wrote: > >>> Put simply, if you want to call dma_map_single() on a buffer, then t= hat > >>> buffer needs to be allocated with kmalloc() (or technically alloc_pa= ges(), > >>> but then dma_map_page() would make more sense when dealing with enti= re > >>> pages. > >> > >> Yes. It sounds like the memory here comes from the dma coherent > >> allocator, in which case the code need to use the address returned > >> by that and not create another mapping. > > > > Hi > > > > traced it to buffer allocated as simple uint8-array [1]: > > > > UINT_8 aucBuffer[sizeof(INIT_HIF_RX_HEADER_T) + sizeof(INIT_EVENT_CMD_= RESULT)]; > > Ah, so it's trying to do DMA with a stack variable? CONFIG_DMA_API_DEBUG > is your friend; it should have screamed about that specifically. > Allocate this buffer properly to begin with, and free it again on the > way out of the function (it's surely not worth having to make a > temporary copy further down the callchain). The kmalloc flags can > probably be regular GFP_KERNEL, unless this can be called from more > restrictive contexts like an IRQ handler - the fact that it might be > mapped for DMA later is essentially irrelevant in that respect. Hi, simply replaced the stack-vars to uint_8-pointers and using kmalloc/kfree = for memory handling (needed to replace some returns to goto to always free mem= ory). Thanks very much for support, driver is now working again :) https://github.com/frank-w/BPI-R2-4.14/commit/7f3a721d5b0d8ca44935c23d5513= a19cc57786c0 > Thanks, > Robin.