From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 591FB42ABB for ; Sun, 17 Dec 2023 13:06:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="MfPHfxSX" Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-77f552d4179so172978685a.1 for ; Sun, 17 Dec 2023 05:06:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1702818413; x=1703423213; darn=vger.kernel.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=KImPZocudnA0Xid9bPae7bvgNXTlGpXerlYRqfFZmS0=; b=MfPHfxSXkor6ksyXCZguDaP3qwObFWL6B7+wc6rlY1NZWv0fWhwi1atdEEPevaQr10 EFq3D5aJYsnu1kqQ+SDxYhJN5lUtpSMeXffTI5KTgDacoxKi6KXhI+FSLB6zum9BiWwg RU+XRgwEyIgzGp5xz6MbBYaLq//fa/AFCfRn2nnwCvFvFvont9210vGskSXLTFcgwcul fuCzyz9ZnT0fE37m2zlEzswqlvXJt+GngC9O7H5GrxK+f1UHcbokfSwb04fy7AYRXmGx mWsVqWU1eM/Gg+ECLTAjaW/wcQ7V8GJYJ9qOyCSVyUUuEWJFARyXfGBCPIoYcXzaQ+qI GB6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702818413; x=1703423213; 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=KImPZocudnA0Xid9bPae7bvgNXTlGpXerlYRqfFZmS0=; b=LXN7zXp2XM19h2amz6zGyN7w/L+8CGxKMTU6jKi8fHWn1Kvu8HdFZjgkd5+yFuuaGH 73KbH5WTUwOy6GIHmZ7qIjvhqIIGy+4HOMKRl51/lBfW3HxPWhvDYPekhH3hIYJ2X6J5 yihYLzfe+ElViJrKUNh9KYWvParMOjkkBxdtzpVvM6K/LF0PdiNGlugWXQqepmHeGFWh gB2GW9KbkZV1XI7IKhZ210fAgM2Ds5wUPrgRS3s/sOo187CFfY1xdAyQwmixhRhjUzgt KsfdDmiiBhsrl2au4xCBVUKfj79xHtkFI7Z9LOtgMYZnVRs8K4MVVDQ1LBAnr/t3RWIT ihhg== X-Gm-Message-State: AOJu0YxlH8Ef9uyfccHK/5BO8UIQs5GEiZK9vHptDS2llbryXLNajMu0 fg6CFQftRmbWa1qP4IZmpgQCUQ== X-Google-Smtp-Source: AGHT+IHTVjfMN59xpIf4XTLv2Tg1BapJF9ANCTlx2a8wYFY7k8a4DvzAyzksTBDM70stjssrCc4n+g== X-Received: by 2002:a05:620a:24c2:b0:77f:849f:72a5 with SMTP id m2-20020a05620a24c200b0077f849f72a5mr12897578qkn.94.1702818413199; Sun, 17 Dec 2023 05:06:53 -0800 (PST) Received: from ziepe.ca ([208.169.72.58]) by smtp.gmail.com with ESMTPSA id a26-20020a05620a439a00b007788bb0ab8esm7536493qkp.19.2023.12.17.05.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 05:06:52 -0800 (PST) Received: from jgg by jggl with local (Exim 4.95) (envelope-from ) id 1rEqr5-00013m-DC; Sun, 17 Dec 2023 09:06:51 -0400 Date: Sun, 17 Dec 2023 09:06:51 -0400 From: Jason Gunthorpe To: Robin Murphy Cc: Jean-Philippe Brucker , 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 , 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: References: <5d89190b35720bf5b66621f46b6d3c85323d8eab.1702486837.git.robin.murphy@arm.com> <20231214165126.GA3726750@myrica> <2d87c1dc-cc95-4d92-968c-9d6e6e6439ff@arm.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2d87c1dc-cc95-4d92-968c-9d6e6e6439ff@arm.com> On Thu, Dec 14, 2023 at 06:22:49PM +0000, Robin Murphy wrote: > Taking yet another look, there's not actually one single place we can do > this right now which will work in a manageable way for all cases. The dma ops should be set after changing the translation and there is only one place that attachs the domain? What prevents putting it there? > @@ -3217,18 +3220,9 @@ static ssize_t iommu_group_store_type(struct iommu_group *group, > if (ret) > goto out_unlock; > - /* > - * Release the mutex here because ops->probe_finalize() call-back of > - * some vendor IOMMU drivers calls arm_iommu_attach_device() which > - * in-turn might call back into IOMMU core code, where it tries to take > - * group->mutex, resulting in a deadlock. > - */ > - mutex_unlock(&group->mutex); > - > /* Make sure dma_ops is appropriatley set */ > for_each_group_device(group, gdev) > - iommu_group_do_probe_finalize(gdev->dev); > - return count; If we are turning this into something that only works for the ARM DMA then the remaining caller should be guarded by an IS_ENABLED Jason 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 5DFB8C3DA6E for ; Sun, 17 Dec 2023 13:07:29 +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=Cnbi2p6Kie1yKQjGdviLNJoX4Rn9Acr/helen89WEr4=; b=y+pUwbP9lC3mys H3PVPppfFz+YJc/GbsC3GC0H5RDKllihn1Kltmxnefe244nkTC7/7psFFCaPDsacrcYIYJviNn4J6 n8AQRs5EP0BiIz86CGT235IHQfvlSw7LuVzhjv+qWCgHQg2E6iXqI/IGJ53b6wRHU9PA8ZPEZD/vn xdTCV57KrLjtlkFzb/sqRTvf/lIBrKuEYTVojpSPBJ74dqPJ0IA3kl4X6A4X0/dv+DP8SZpn+OPCv BGEY5DMNOTQ0VsDcipUkSTJHtBSdiNlx7sT7DqgJqEdt0c2YhTh9NbxU1JHepyNVeWPdhYQGkXgpQ sQUb5Y89+l8Uks69zLcg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rEqrG-007q8i-3B; Sun, 17 Dec 2023 13:07:02 +0000 Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rEqrA-007q7k-2h for linux-arm-kernel@lists.infradead.org; Sun, 17 Dec 2023 13:07:00 +0000 Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-77f3183f012so173557785a.0 for ; Sun, 17 Dec 2023 05:06:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1702818413; x=1703423213; 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=KImPZocudnA0Xid9bPae7bvgNXTlGpXerlYRqfFZmS0=; b=H25zbM/4xrBRBfoacyVKMWDWDMlepqRj2bss7TpXtiWV/hTTIhQA/z/14CAriNQxId LXp5z0mWMy3aqum7ZcDYEhztWmNyk/xM8mxaNrPGuuJVGHvKyL+9mZ9oi3+McIOmlKPd d6Kuh1ZjcQgWgN9Y1PRl9RpykiA39Q/aYtkXfGFozLTM5OLdWGlH7wenBjdkBD6kMk0Z KIYaL+H7Hn61FDNtuRXQZoZ5fX5Qrt6OfjUdaIr/E7azIK2v6nLbGwLKyRCMKLdJu62C tfvT64ZnHVzMmHaL2GOqNEGgP9UGdEghHMP+H/jP9sJ/AmV8HhpyDXv1zC3ILjMTCC+S exDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702818413; x=1703423213; 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=KImPZocudnA0Xid9bPae7bvgNXTlGpXerlYRqfFZmS0=; b=goEhyrZS7M80EC1Gt3J2LuZ74/eYvJ+b4Quq6BiyPNdAtN2VKKABk4QawFmEZGSk74 fB39wi/vfwyGj4GjoP0+xTBlvG9IbdvX68TYzDBKW87B0ma9M7pjeAoEqN6ne9FWoBCH DgVPOTbIyEO9X9/c/f2oY9cOXpc0pqYbaUwzsflOulmY7w13EhPQwPAyXfwPk7g4Zu0S isHfg9FyIB54pqI+WkqaUdSlejBl0wKOLDXJb/0riMnRyey1b7z5t5B+Mu8GEgHWdGAg qp6OnpqLB1H9e6uTR5crH6zhmuoBpOfuqXRIb1L+DEIyuN5BoatBzvmb7Jwwy4tnFl/p fdnA== X-Gm-Message-State: AOJu0YyRaQcMvBrLEqoTZayVKKCF/5wfGJyKyBZ/Q80GKplrYyI1qwZZ zxsTa6CaNkfvB12wvGmVXKN5Vg== X-Google-Smtp-Source: AGHT+IHTVjfMN59xpIf4XTLv2Tg1BapJF9ANCTlx2a8wYFY7k8a4DvzAyzksTBDM70stjssrCc4n+g== X-Received: by 2002:a05:620a:24c2:b0:77f:849f:72a5 with SMTP id m2-20020a05620a24c200b0077f849f72a5mr12897578qkn.94.1702818413199; Sun, 17 Dec 2023 05:06:53 -0800 (PST) Received: from ziepe.ca ([208.169.72.58]) by smtp.gmail.com with ESMTPSA id a26-20020a05620a439a00b007788bb0ab8esm7536493qkp.19.2023.12.17.05.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 05:06:52 -0800 (PST) Received: from jgg by jggl with local (Exim 4.95) (envelope-from ) id 1rEqr5-00013m-DC; Sun, 17 Dec 2023 09:06:51 -0400 Date: Sun, 17 Dec 2023 09:06:51 -0400 From: Jason Gunthorpe To: Robin Murphy Cc: Jean-Philippe Brucker , 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 , 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: References: <5d89190b35720bf5b66621f46b6d3c85323d8eab.1702486837.git.robin.murphy@arm.com> <20231214165126.GA3726750@myrica> <2d87c1dc-cc95-4d92-968c-9d6e6e6439ff@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2d87c1dc-cc95-4d92-968c-9d6e6e6439ff@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231217_050657_017384_ED25D80E X-CRM114-Status: GOOD ( 15.39 ) 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 Thu, Dec 14, 2023 at 06:22:49PM +0000, Robin Murphy wrote: > Taking yet another look, there's not actually one single place we can do > this right now which will work in a manageable way for all cases. The dma ops should be set after changing the translation and there is only one place that attachs the domain? What prevents putting it there? > @@ -3217,18 +3220,9 @@ static ssize_t iommu_group_store_type(struct iommu_group *group, > if (ret) > goto out_unlock; > - /* > - * Release the mutex here because ops->probe_finalize() call-back of > - * some vendor IOMMU drivers calls arm_iommu_attach_device() which > - * in-turn might call back into IOMMU core code, where it tries to take > - * group->mutex, resulting in a deadlock. > - */ > - mutex_unlock(&group->mutex); > - > /* Make sure dma_ops is appropriatley set */ > for_each_group_device(group, gdev) > - iommu_group_do_probe_finalize(gdev->dev); > - return count; If we are turning this into something that only works for the ARM DMA then the remaining caller should be guarded by an IS_ENABLED Jason _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel