Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp309796imu; Fri, 11 Jan 2019 00:23:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN6BK4ijWemmuzojnE3dxGAn8MK1g4pB5Vn8pfAmnv0mVjKNP2yMek3ZDsY1FX+uU0bsUoj0 X-Received: by 2002:a65:63d3:: with SMTP id n19mr12648220pgv.179.1547195039038; Fri, 11 Jan 2019 00:23:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547195039; cv=none; d=google.com; s=arc-20160816; b=CopeJmO+Qj7iFhE7svKdEVa7totOGxt7ZRFCtpLJHrHCAJGmtdGUK5WU2r3T+atyi0 8xpr1S0JNU+m1f1kwCjlUbYBlBFIyyiRzLCyrlU+KzAKmyGt40zUyVLZk5spHawVHI6T jf9rfJoGI3jV4xWYl1dm1lFgG71RKAgyuIeIsmgIRLKQ4oLz2fQkXkeXMImjUaVV2Hgr BUjW3qN92xfS99AWxEK7Ti6x7eO20zvUW9ffMfSyLZtEbkp2Tg/BY64EWOtb/CR+Eayc s8VA6w1mIPdBKvQIfkVCo7e6Q4htP8dE6Q6Cb49GYgoJjUZ+tTpG6HrYLMW0kzIwaHht qo3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=qx6KoER5FBJX5tpE0WeAv2OhXTt+AKSUd702iLtQv9E=; b=ykOdgkvm9b7Q6FrV76zUgVsL8oBhMDJFqoyjkUAuV+oARXyEr+HWC5fkEr3KiyioEk sT1p+hfWjlAWpTdxEkdTUi1D1H1LPy814MPQOqwesIvxcSz5zDxYExKjYzNddVbZmcuO JavMornm4eelIf1GLgC8Lq+5Zz78bPjF5jUH4npY7ZYAIhr2wUvW6OpQyzFrjWbYSsZ6 INdx5l0CdD+vdC5ZEkGUh3w9iRDCH87bY36+1SXehoLBkc5qVZLXs7Z88Z6YETlq7ums x/8Z9kJg7+8+Y3aX+la6TNth/eEAitv4u39K968EbLyNDWUT+ulpe5X6csYzH10x7FKL bVig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i198si60831681pfe.289.2019.01.11.00.23.43; Fri, 11 Jan 2019 00:23:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729792AbfAKGJ0 (ORCPT + 99 others); Fri, 11 Jan 2019 01:09:26 -0500 Received: from icp-osb-irony-out2.external.iinet.net.au ([203.59.1.155]:32885 "EHLO icp-osb-irony-out2.external.iinet.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728042AbfAKGJZ (ORCPT ); Fri, 11 Jan 2019 01:09:25 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2AEAADaMThc/zXSMGcNVxkBAQEBAQE?= =?us-ascii?q?BAQEBAQEHAQEBAQEBgVQBAQEBAQELAYJpgSmEAYN7khuZdTKERwKCRzcGDQE?= =?us-ascii?q?DAQEBAQEBAoEJhVYBAQEBAgEjFUEQCw0BCgICJgICVwYNCAEBgx4BgWgBEBe?= =?us-ascii?q?sS3GBLxqEFAGBE4RtgQuBc4lYgUA/gREngmuDBYFVgzCCVwKLUoRukTsJgQS?= =?us-ascii?q?BKoRsimMeiiwDh04tjlGILIUVgXgzGh+DQQiLFIVRYQmIAIJNAQE?= X-IPAS-Result: =?us-ascii?q?A2AEAADaMThc/zXSMGcNVxkBAQEBAQEBAQEBAQEHAQEBA?= =?us-ascii?q?QEBgVQBAQEBAQELAYJpgSmEAYN7khuZdTKERwKCRzcGDQEDAQEBAQEBAoEJh?= =?us-ascii?q?VYBAQEBAgEjFUEQCw0BCgICJgICVwYNCAEBgx4BgWgBEBesS3GBLxqEFAGBE?= =?us-ascii?q?4RtgQuBc4lYgUA/gREngmuDBYFVgzCCVwKLUoRukTsJgQSBKoRsimMeiiwDh?= =?us-ascii?q?04tjlGILIUVgXgzGh+DQQiLFIVRYQmIAIJNAQE?= X-IronPort-AV: E=Sophos;i="5.56,464,1539619200"; d="scan'208";a="178029546" Received: from unknown (HELO [10.44.0.22]) ([103.48.210.53]) by icp-osb-irony-out2.iinet.net.au with ESMTP; 11 Jan 2019 14:09:19 +0800 Subject: Re: [PATCH 1/2] dma-mapping: zero memory returned from dma_alloc_* To: Christoph Hellwig Cc: Geert Uytterhoeven , Linux IOMMU , Michal Simek , ashutosh.dixit@intel.com, linux-m68k , Linux Kernel Mailing List References: <20181214082515.14835-1-hch@lst.de> <20181214082515.14835-2-hch@lst.de> <20181214114719.GA3316@lst.de> <5ae55118-6858-9121-6b3e-9b19b41550ef@westnet.com.au> <20181217115931.GA6853@lst.de> From: Greg Ungerer Message-ID: Date: Fri, 11 Jan 2019 16:09:19 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181217115931.GA6853@lst.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Christoph, On 17/12/18 9:59 pm, Christoph Hellwig wrote: > On Sat, Dec 15, 2018 at 12:14:29AM +1000, Greg Ungerer wrote: >> Yep, that is right. Certainly the MMU case is broken. Some noMMU cases work >> by virtue of the SoC only having an instruction cache (the older V2 cores). > > Is there a good an easy case to detect if a core has a cache? Either > runtime or in Kconfig? > >> The MMU case is fixable, but I think it will mean changing away from >> the fall-back virtual:physical 1:1 mapping it uses for the kernel address >> space. So not completely trivial. Either that or a dedicated area of RAM >> for coherent allocations that we can mark as non-cachable via the really >> course grained and limited ACR registers - not really very appealing. > > What about CF_PAGE_NOCACHE? Reading arch/m68k/include/asm/mcf_pgtable.h > suggest this would cause an uncached mapping, in which case something > like this should work: > > http://git.infradead.org/users/hch/misc.git/commitdiff/4b8711d436e8d56edbc5ca19aa2be639705bbfef No, that won't work. The current MMU setup for ColdFire relies on a quirk of the cache control subsystem to map kernel mapping (actually all of RAM when accessed in supervisor mode). The effective address calculation by the CPU/MMU firstly checks the RAMBAR access, then From the ColdFire 5475 Reference Manual (section 5.5.1): If virtual mode is enabled, any normal mode access that does not hit in the MMUBAR, RAMBARs, ROMBARs, or ACRs is considered a normal mode virtual address request and generates its access attributes from the MMU. For this case, the default CACR address attributes are not used. The MMUBAR is the MMU control registers, the RAMBAR/ROMBAR are the internal static RAM/ROM regions and the ACR are the cache control registers. The code in arch/m68k/coldfire/head.S sets up the ACR registers so that all of RAM is accessible and cached when in supervisor mode. So kernel code and data accesses will hit this and use the address for access. User pages won't hit this and will go through to hit the MMU mappings. The net out is we don't need page mappings or use TLB entries for kernel code/data. The problem is we also can't map individual regions as not cached for coherent allocations... The ACR mapping means all-or-nothing. This leads back to what I mentioned earlier about changing the VM mapping to not use the ACR mapping method and actually page mapping the kernel space. Not completely trivial and I expect there will be a performance hit with the extra TLB pressure and their setup/remapping overhead. >> The noMMU case in general is probably limited to something like that same >> type of dedicated RAM/ACR register mechamism. >> >> The most commonly used periperal with DMA is the FEC ethernet module, >> and it has some "special" (used very loosely) cache flushing for >> parts like the 532x family which probably makes it mostly work right. >> There is a PCI bus on the 54xx family of parts, and I know general >> ethernet cards on it (like e1000's) have problems I am sure are >> related to the fact that coherent memory allocations aren't. > > If we really just care about FEC we can just switch it do use > DMA_ATTR_NON_CONSISTENT and do explicit cache flushing. But as far > as I can tell FEC only uses DMA coherent allocations for the TSO > headers anyway, is TSO even used on this SOC? The FEC is the most commonly used, but not the only. I test generic PCI NICs on the PCI bus on the ColdFire 5475 - and a lot of those drivers rely on coherent allocations. Regards Greg