Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3216519imw; Mon, 11 Jul 2022 04:31:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tE1NtsjrSvcQwOZxPUnNgaZ69GDVB7TqATDeDiooaQAZbqVGUCLnMy5lm6nmuohPxvt8KN X-Received: by 2002:a17:907:6e05:b0:72a:a141:962 with SMTP id sd5-20020a1709076e0500b0072aa1410962mr18058389ejc.545.1657539061729; Mon, 11 Jul 2022 04:31:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657539061; cv=none; d=google.com; s=arc-20160816; b=FC91OFsWLPO+l4ZjQmHYo6TrTYrw1xDyWF3CchJTwxx4bAxgywWyaMfExnn5kwNBTV dAZciIkncsHz5o29zmxqG7RQHZgIFvW3K1gSYrCCPMLpymg4c2V6oNf50QxsshXdIUZD FF4OpWeGgOCyCwDgl4yv+/rE6K3cBHbXGzlEdphLF5U/H6d43wyAfXXU6mMMe82twBLR ahidlHlpX6lqWrCgFnzwUa11I5ALpladhb31QsX4VXxonbTyIjwNmKOCUjiqrkLbvoZ0 Xk32sLDa8jhSeWidRvLd4JPkR1WHK6jT+HZGtyl+WJZwzZLHgA2yC6Iw6QozxPytHlUi jfbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=fvDha30EjIYFTyOjulIlalbEfYYBWRIUA6JTsEntNUw=; b=Ra5VLtJuYT/eavppZZx+rlEzqhHLnlliph9MJPXbiSPMAsosvPLHmyn/tdxbwiwn9x ZT9I1D3fAyUAGxwX2TEfiFD0hng3Eu73PHZcFLLFW//+jb5iWvT1JvuQUbp+wU2kaTbi 7DzC6ALiCjBEtmOhNrfagX71T88fcf/8cnQe58XlmOhBsaTlfJkS78L0B2QirGiSZF3Q gTz4Cr1zqfdkvJkQCPkmQdTJkVDZirXUcpQuvgGscJLY7wswWUGWoTL0bcqakugLWy0e E7i4I94Hka4vm/KWlv44cSmtJMzPh2U6sX/IuQJnAkbBVZsRzB0QdXzu029B+yzcB1i8 Htvw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id he19-20020a1709073d9300b0072b6a00914fsi1220180ejc.242.2022.07.11.04.30.37; Mon, 11 Jul 2022 04:31:01 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231417AbiGKL0b (ORCPT + 99 others); Mon, 11 Jul 2022 07:26:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229930AbiGKLZ7 (ORCPT ); Mon, 11 Jul 2022 07:25:59 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3C9C111A22 for ; Mon, 11 Jul 2022 04:01:06 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6BD6516A3; Mon, 11 Jul 2022 04:01:06 -0700 (PDT) Received: from [10.57.85.194] (unknown [10.57.85.194]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C23353F792; Mon, 11 Jul 2022 04:01:04 -0700 (PDT) Message-ID: Date: Mon, 11 Jul 2022 12:01:00 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] swiotlb: ensure io_tlb_default_mem spinlock always initialised Content-Language: en-GB To: Ben Dooks , Christoph Hellwig Cc: linux-kernel@vger.kernel.org, iommu@lists.linux.dev, iommu@lists.linux-foundation.org, Sudip Mukherjee , Jude Onyenegecha , Marek Szyprowski References: <20220708170811.270589-1-ben.dooks@sifive.com> <683344bd-dc9b-0bb5-9377-b3e9ab410a74@sifive.com> <20220711102134.GB4639@lst.de> <4fa8b709-c883-54dc-c302-20c9e55ae93a@sifive.com> <20220711103921.GA6542@lst.de> <43426798-44df-c2c7-1f46-0b79201cb620@sifive.com> From: Robin Murphy In-Reply-To: <43426798-44df-c2c7-1f46-0b79201cb620@sifive.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,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 On 2022-07-11 11:42, Ben Dooks wrote: > On 11/07/2022 11:39, Christoph Hellwig wrote: >> On Mon, Jul 11, 2022 at 11:24:51AM +0100, Ben Dooks wrote: >>> On 11/07/2022 11:21, Christoph Hellwig wrote: >>>> On Mon, Jul 11, 2022 at 11:07:17AM +0100, Robin Murphy wrote: >>>>> If none of your peripherals should need SWIOTLB, then the fact that >>>>> you're ending up in swiotlb_map() at all is a clear sign that >>>>> something's wrong. Most likely someone's forgotten to set their DMA >>>>> masks correctly. >>>> >>>> Yes. >>> >>> Possibly, we had at least one driver which attempted to set a 32 bit >>> DMA mask which had to be removed as the DMA layer accepts this but >>> since there is no DMA32 memory the allocator then just fails. >>> >>> I expect the above may need to be a separate discussion(s) of how to >>> default the DMA mask and how to stop the implicit acceptance of setting >>> a 32-bit DMA mask. >> >> No.  Linux simply assumes you can do 32-bit DMA and this won't >> change.  So we'll need to fix your platform to support swiotlb >> eventually. > > Ok, is there any examples currently in the kernel that have no memory > in the DMA32 zone that do use swiotlb? The arm64 code originally made an assumption that a system with that kind of memory layout would use a DMA offset in the interconnect, and so placed ZONE_DMA32 in the first 4GB of available RAM rather than actual physical address space. The only relatively mainstream platform we subsequently saw with all RAM above 32 bits was AMD Seattle, which also *didn't* use a DMA offset, so it "worked" by virtue of this bodge in the sense that allocations didn't fail, but DMA transactions would then disappear off into nowhere when the device truncated the MSBs of whatever too-big DMA address it was given. I think that stuff's long gone by now, and if any of handful of remaining Seattle users plug in a 32-bit PCIe device and try to use it with the IOMMU disabled, they'll probably see the fireworks as intended. Much as we'd like to make DMA an explicit opt-in for all drivers, that's something which can only really be solved 30 years ago. Robin.