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 7F056C4829A for ; Tue, 13 Feb 2024 17:01:09 +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=O0jI9coRW6V4RqS0UNQXNjZsc84r0Iptm5hVcBWI22A=; b=2FYSl7TGKne6F3 IMokCork/uCROKgl9CaqYOQ9VduogR0f8JpwZp5wECHzY9ROQmDtISW4IMaTBp/KXdhVWiuc6Y51y X6QGPhIIsNfWNxLoj7KwRlx7bTrcvNEu7ywEFaJVwBPlfUnU5l5+6tTCEURNepkS4daBSeITGZz3T f0RdKjy9CKrY4u//TYgW+V9lMA3j5UKKfbJZ170Bhi/IEvC63HvpWrt9mcCCGKCH2iFa9uQjmMi7A WumTWLjUMfhARB5RsPZjRr4L5V/fPtxiZRhVr5QfYT1k7H/jZ014M8IWdJCpFQ/ORdxdMo1uXeJlr LBZYGYZOPahDPLOWo35Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZw9N-0000000A4VU-30kO; Tue, 13 Feb 2024 17:00:53 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZw9K-0000000A4Ux-35RE for linux-arm-kernel@lists.infradead.org; Tue, 13 Feb 2024 17:00:52 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-410acf9e776so65325e9.1 for ; Tue, 13 Feb 2024 09:00:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707843649; x=1708448449; 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=5cWBvmXxi6UMr28DCjOQCiv1KG2CcDRbLU6dcLN76xU=; b=StVfKteGeIbZwp6bQgAoOLRWFfyVqKgiRcQPxaM2UOv+VjTxr0akq2Dx2YC4QYCH8M ssFEAqWUb27jQ8OskHy4IH6X7uv47bEYm2+DdT5IbHvXx9R9OKOl/GZXExuaog/OEY3b DfudrcG+JMUzx6yzjhxNmmJ9s7Ef6QeeFgB0SaaRPX2jrfmmZoHPHlXhumsOhQBOuj5X 9v/2X1JUQKkW+QoRqxzeG5maCocXhryFpYhkqrDhE2wJDDvIGE16cerKU3iMtGKse2Io chPesf1FLY0FqRGRruFkw0c51N9D0VcfTr47jo+HmV+CSsD9WJRFB33LizxDB1xIDN/z wkcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707843649; x=1708448449; 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=5cWBvmXxi6UMr28DCjOQCiv1KG2CcDRbLU6dcLN76xU=; b=BVDjfmaxT8B5LOqwqd2pWllriY9cYE82NHNBGGOpR3+ExqX9yTkV7xOY2Yv5KhS6j8 kuVHvoOr3EtQab3n9QB7dfpy+e6wT+ZoT3R0XpLIpUYgscukMZhZynzchTph6BzRTL3K tH6KpEOvtTv3dEUnORKOPMp50HO2oGg34/Ec4bxc9J2z8Y1eDC+smSpmCjeJNhS/e4+U yrzadzWZQQNHSw9z4pEuHaa2nvzReE3oNlAjXi61DJpt32Aj29qNLq6JlRmq2QB5uDQo GxHTcrgISXE1dUYn31aBWh02onPGLSGEe+zW7hy2PFD2zxfT01lNR3wqyBdQcHz9MdkR GOSQ== X-Forwarded-Encrypted: i=1; AJvYcCXEAPhBH8VIc19u4kLQay6y5XiSjIe4Ca0ILJz15Z0cdyQZ3lU1zokVsjnShLLynN2aC490ExECyCa8+4yWB/QD5x4GVamrCEK7fIKn59wStjytfH0= X-Gm-Message-State: AOJu0YxXxVQuWX94QI4/VahkZ8tB5U2wLFv/9oYXXzPghy9ylaypQM77 S63r48g3Lv43JZ9lIjzQGqYcQ1u3az23Uy10WBzecrTRs3SPMOoHtDjx3c5DBQ== X-Google-Smtp-Source: AGHT+IFsllimKT4Ae5wbJyvmEQy4xvKDG1jTB+aQNSR/IivggyXAlwFr7LJHQ/dE4OA58cgEGjlCng== X-Received: by 2002:a05:600c:a008:b0:410:d18a:290b with SMTP id jg8-20020a05600ca00800b00410d18a290bmr18394wmb.7.1707843649317; Tue, 13 Feb 2024 09:00:49 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUm9zGe7yYjtudtYm2xecBgJCDyzWuo7aNldtekCrdZCF7haqHhbsTc43FrJDj0WVsuns4uctGcMcBrOLYwlIGD9L9p8arT0OtOzePAaFQeJkPdRyIAzR/xgKSGDBNpMMJhd/9LvkGaiB56GgKtAFOM9HZNPKArstCw1HOBGMW9ElSfjRJpYNvMlbj59vQ2cF46fBzz2HNaJ7xTUeeDqdnPEpCIoR3a8Nh8vGGYWK+nj0tRKGbagfXWcsE6J+RAik4aTeYGNeaiZ4QPdOZJRlAbroH36nuISSKvJeahoD4YwWd/tGwxZOx0oPLFS/EADd3QM/HmQ14owgpu5g6OrfyQTjyzkNrAAKN08ql5Ahx/TgRuhZYOPNfer/VYCugwylcMteT0tivNUcVhyAI8xST7DIFzKOOf+7GaRo73lBCfm/LUPUWb5vIf0C2UuiFuThrKZPpWufHVsfBPF8gDDjMhf2x+EIntz3whBMP0mOHPlFsrWvcSqw== Received: from google.com (185.83.140.34.bc.googleusercontent.com. [34.140.83.185]) by smtp.gmail.com with ESMTPSA id n16-20020a5d67d0000000b0033af26545c8sm9977041wrw.50.2024.02.13.09.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 09:00:48 -0800 (PST) Date: Tue, 13 Feb 2024 17:00:44 +0000 From: Mostafa Saleh To: Jason Gunthorpe Cc: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Will Deacon , Lu Baolu , Jean-Philippe Brucker , Joerg Roedel , Moritz Fischer , Moritz Fischer , Michael Shavit , Nicolin Chen , patches@lists.linux.dev, Shameer Kolothum , Zhangfei Gao Subject: Re: [PATCH v5 11/17] iommu/arm-smmu-v3: Remove arm_smmu_master->domain Message-ID: References: <0-v5-cd1be8dd9c71+3fa-smmuv3_newapi_p1_jgg@nvidia.com> <11-v5-cd1be8dd9c71+3fa-smmuv3_newapi_p1_jgg@nvidia.com> <20240213163739.GE1088888@nvidia.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240213163739.GE1088888@nvidia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240213_090050_813376_66E4ACFD X-CRM114-Status: GOOD ( 28.75 ) 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 Tue, Feb 13, 2024 at 12:37:39PM -0400, Jason Gunthorpe wrote: > On Tue, Feb 13, 2024 at 03:45:34PM +0000, Mostafa Saleh wrote: > > Hi Jason, > > > > On Tue, Feb 06, 2024 at 11:12:48AM -0400, Jason Gunthorpe wrote: > > > Introducing global statics which are of type struct iommu_domain, not > > > struct arm_smmu_domain makes it difficult to retain > > > arm_smmu_master->domain, as it can no longer point to an IDENTITY or > > > BLOCKED domain. > > > > > > The only place that uses the value is arm_smmu_detach_dev(). Change things > > > to work like other drivers and call iommu_get_domain_for_dev() to obtain > > > the current domain. > > > > > > The master->domain is subtly protecting the domain_head against being > > > unused, change the domain_head to be INIT'd when the master is not > > > attached to a domain instead of garbage/zero. > > > > I don't this the problem here, neither the reason for initialising the > > domain_head, can you please clarify the issue? > > I didn't notice it either. Eric found it: > > https://lore.kernel.org/linux-iommu/6fff20dd-46d5-4974-a4a5-fb4e7a59ce44@redhat.com/ > > > > @@ -2560,19 +2560,20 @@ static void arm_smmu_disable_pasid(struct arm_smmu_master *master) > > > > > > static void arm_smmu_detach_dev(struct arm_smmu_master *master) > > > { > > > + struct iommu_domain *domain = iommu_get_domain_for_dev(master->dev); > > > + struct arm_smmu_domain *smmu_domain; > > > unsigned long flags; > > > - struct arm_smmu_domain *smmu_domain = master->domain; > > master->domain is NULL here which happens in cases where the current > RID domain is not a PAGING domain. > > > > - if (!smmu_domain) > > > + if (!domain) > > > return; > > Which used to early exit > > > > > > > + smmu_domain = to_smmu_domain(domain); > > > arm_smmu_disable_ats(master, smmu_domain); > > > > > > spin_lock_irqsave(&smmu_domain->devices_lock, flags); > > > - list_del(&master->domain_head); > > > + list_del_init(&master->domain_head); > > > spin_unlock_irqrestore(&smmu_domain->devices_lock, flags); > > But now would cause the list_del() to hit a non-inited list_head and > explode. > > Instead we keep the list head init'd and the list_del is a NOP. > > Tricky right?? > > I changed the comment like this: > > The master->domain is subtly protecting the master->domain_head against > being unused as only PAGING domains will set master->domain and only > paging domains use the master->domain_head. To make it simple keep the > master->domain_head initialized so that the list_del() logic just does > nothing for non-PAGING domains. > > OK? Ahh, I see, as iommu_get_domain_for_dev() now returns a valid domain. Thanks for the explanation, that makes sense. Reviewed-by: Mostafa Saleh Thanks, Mostafa _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel