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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6DBC3C4167B for ; Thu, 14 Dec 2023 16:51:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YNgaCoWQlSshlLvWVzYSTKq41ebHF3st541ev5NR/mw=; b=wNZJ//2HnR1KVf RrvSz6fQysY4NeLYgNvLNXxq4pgr6E/Wdf0ct88sIPceU6KThqUvlMt1Cko5XJoBd9CkffBSKm9E7 eJRH90RSx6a0VlKkpVWDNXCXRPVwx+mPThNGeMVpjWmI6kS8bC7tQWr7uixYbNPSo4hBQDKBoqNin EnJr2TlqdZP+BzrBmHpvou4FoM3LKRHSeIOvTdARXUuO9/OLs8olTFCN4VLhZIHxsHTUTe3Gc/Ov7 cdq0GjtiUZl6sLqGLydIeB9RsGZttrnbFAK7UZ7Dzwlgs3Qj680+UsyUqjZsNs8LTeTA013RchZfO laVRcWFvUE4u9ucmdQ0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDovj-000qqe-2A; Thu, 14 Dec 2023 16:51:23 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDovg-000qp3-0v for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2023 16:51:21 +0000 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-3363eba94ebso1522482f8f.3 for ; Thu, 14 Dec 2023 08:51:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702572678; x=1703177478; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Usgg76jsYIefadLxnuqF6rdoT8QTltStQ3cD7RxnFLY=; b=MsgnmLYvm4B/PFWxeeLNPst3dX8ICDI8sF6lcy4Qk2EHWKkhE8u5iOBaYgMts7y52v zCG1uzG8r1MxPArPPA7U/Bw0pTb0W+yb8197wW/XmQmnHKLp1saNOZZFwjnWuoZFn+uK p/+DRqXTwiAdJl+JNFU8tUAmPG/zcO0q4p7Iv2oD5fSAh4OGNp1bVZ8C9x5psAF0wYFe k4GogLDchjULeyBZ0kMYMez1h3Hf0dul85usXpbaYV8REN4TOGU1uT+XuuBUZ04kKRa0 CnM2J8YAcinlLIBFEjEhnlfpb6MXcvQIpiEgWqo/fWB+weN/5dqSipfWX4G3htFobMP1 PSsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702572678; x=1703177478; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Usgg76jsYIefadLxnuqF6rdoT8QTltStQ3cD7RxnFLY=; b=B9CTMh+WUFAuJjh3Km8xrOlSeESNE9hmgjbl66C03wa7fU/VFYUXmfW8TOqxEeft3/ ReHZljPNIDuMMZuq4597sHYjRPaSYvCd2HUl0lBZV9izFMalz7cuvaB/a5ms9PDmoGWK Mvhq0+q2dc+h7fWBtZo/yaJrgmPB61GO0us9qIHpLCyDajjZrfZ0IWuYrqB2m+r+EeMk gJCAI5f1repxE0RevkdKZYPaD2DBSG2cmqk2HZW6ppcnif2z/vxR7f+S3XZoCJFrbcwB UrhbIPIm/vg7RmLp1PnJVYmLcUCeXdFnsWufJrqGKNcfg0AFbaNxdLjDYjkE8XomoFFX /GSg== X-Gm-Message-State: AOJu0YxGnkiS387zpnQkewBRCCamN0U7zNgiDiC/X9tLSjR4BB2yNlcE oCvALaedsIg3a8+8QP4slYEURw== X-Google-Smtp-Source: AGHT+IFBMhJj6OgBJFoBT/wwSuMBs9mGXlacijvXWzHs6AsF1SDBWLDmS4Y/dcB+WWbQ8eP+CZ35gg== X-Received: by 2002:a05:6000:1e8e:b0:336:4256:c7d7 with SMTP id dd14-20020a0560001e8e00b003364256c7d7mr632414wrb.111.1702572678542; Thu, 14 Dec 2023 08:51:18 -0800 (PST) Received: from myrica ([2.221.137.100]) by smtp.gmail.com with ESMTPSA id q18-20020adff952000000b0033609b71825sm16076369wrr.35.2023.12.14.08.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 08:51:18 -0800 (PST) Date: Thu, 14 Dec 2023 16:51:26 +0000 From: Jean-Philippe Brucker To: Robin Murphy Cc: Joerg Roedel , Christoph Hellwig , Vineet Gupta , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Thomas Bogendoerfer , Paul Walmsley , Palmer Dabbelt , Albert Ou , Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Suravee Suthikulpanit , David Woodhouse , Lu Baolu , Niklas Schnelle , Matthew Rosato , Gerald Schaefer , Rob Herring , Frank Rowand , Marek Szyprowski , Jason Gunthorpe , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, iommu@lists.linux.dev, devicetree@vger.kernel.org Subject: Re: [PATCH v2 6/7] iommu/dma: Centralise iommu_setup_dma_ops() Message-ID: <20231214165126.GA3726750@myrica> References: <5d89190b35720bf5b66621f46b6d3c85323d8eab.1702486837.git.robin.murphy@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5d89190b35720bf5b66621f46b6d3c85323d8eab.1702486837.git.robin.murphy@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231214_085120_333458_40A297D8 X-CRM114-Status: GOOD ( 19.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Dec 13, 2023 at 05:17:59PM +0000, Robin Murphy wrote: > diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c > index 27a167f4cd3e..d808c8dcf5cb 100644 > --- a/drivers/iommu/dma-iommu.c > +++ b/drivers/iommu/dma-iommu.c > @@ -1724,25 +1724,20 @@ static const struct dma_map_ops iommu_dma_ops = { > .opt_mapping_size = iommu_dma_opt_mapping_size, > }; > > -/* > - * The IOMMU core code allocates the default DMA domain, which the underlying > - * IOMMU driver needs to support via the dma-iommu layer. > - */ > -void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 dma_limit) > +void iommu_setup_dma_ops(struct device *dev) > { > struct iommu_domain *domain = iommu_get_domain_for_dev(dev); > > - if (!domain) > - goto out_err; > + if (dev_is_pci(dev)) > + dev->iommu->pci_32bit_workaround = !iommu_dma_forcedac; > > - /* > - * The IOMMU core code allocates the default DMA domain, which the > - * underlying IOMMU driver needs to support via the dma-iommu layer. > - */ > if (iommu_is_dma_domain(domain)) { ... > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index 824989874dee..43f630d0530e 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -560,10 +560,10 @@ static int __iommu_probe_device(struct device *dev, struct list_head *group_list > if (list_empty(&group->entry)) > list_add_tail(&group->entry, group_list); > } > - mutex_unlock(&group->mutex); > > - if (dev_is_pci(dev)) > - iommu_dma_set_pci_32bit_workaround(dev); > + iommu_setup_dma_ops(dev); With Intel VT-d (QEMU emulation) I get a crash in iommu_setup_dma_ops() because at this point group->domain and group->default_domain are still NULL, group_list is non-NULL. No problem with x86 virtio-iommu, it goes through iommu_setup_default_domain() earlier in the function. Arm virtio-iommu is fine too. Thanks, Jean _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel