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 X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70FC4C5519F for ; Wed, 25 Nov 2020 09:29:39 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DFAC3208CA for ; Wed, 25 Nov 2020 09:29:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="1S6WXyEa"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="J2TU+ZzT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DFAC3208CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject: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=3Bomsg33m/fC+Hxi2QdyyNHPJ/Gmd+1gyvHBzTv0CWs=; b=1S6WXyEaqFg8TqwifK/QfpuI9 ApWOJo5V5kNlICvJOvqAQWYascJxWK7twDnWzvYw9UAwJ2Y09Vrpu9XygPLRQdvm169l8c1IqLMj6 MAgcRi26OOVxyACJtxkoaQVXbkBpzc3ZscBZlm32i3jfELZtEXCGvmwdn+sSRhByfWEm32aJBUvAf ha3NEdNUbEvDMJ6olHvoWZ7a2iuCpEuyVNZhm6BkWIttUvk8DAnePWSXRWU8FrvsOJUjM1++kMI+e 7cQd5+hjPcsjZry6K+U5JgbnAsBnF2HsGBXwlSjWlsO9r65tftP1XHlZc1WvxR/GpDY+EMe2LuDNX XcvKrdEvg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1khr60-0002Zu-Np; Wed, 25 Nov 2020 09:28:16 +0000 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1khr5v-0002XA-RM for linux-arm-kernel@lists.infradead.org; Wed, 25 Nov 2020 09:28:14 +0000 Received: by mail-ed1-x541.google.com with SMTP id d17so1037243edq.2 for ; Wed, 25 Nov 2020 01:28:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=V6jfPwZkNeh5oW/xhyxIAPCS+jYbX5BnmAGa7tqS/UM=; b=J2TU+ZzTtpXOeRpQEU95Ot5rlO5r6/XqvYl5hbbxifRwxuudgrBEX+kHKxWKrh0yR+ d57ZC0VghJ3JrkXqCZ5vuegixijbxUTkoHcoDeEg11SJPHlRp+2GvFW63hpArzENjq4U OlF4db7JcfP3J6yAqr1EhhDw3oaiUx2sAcSA0NzoqPQAALKchRAM7bJGV1FEyU/u8Zew 714LCXKYumJNKQVlpjCTYX+Z7UJsT797AMbwG/YZfFX4eQ60bh81Lj92i3gDvaNhbTY/ 5f3jFSNHbCDkr9eiCZyarUEoxZFkkIlKVBkr3onMOxe0WoWtw4M6SyzvBKX/R+450e6r RKQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=V6jfPwZkNeh5oW/xhyxIAPCS+jYbX5BnmAGa7tqS/UM=; b=PDsY6ypku9XEDkKZATb5blF108ca/bmGOEJIrerh1PMD0Nz8pKZW1ZBOODVRldFs86 W4OjLCQycqfmSuMZ7Sw1KQEx4r4HcM+RUtEH7l1BRm6A+UuvmlAqeKREjOqzzSssOBB2 KopEHxVpmBnvasMZnCq0aXv0FY/29VvCw0JEV8HVbCsOwayRZxwwXq8DuWRIzVOqk2sN k+LMwPb3/xWUjqbi4un+UFd4e+R6NtYFdjD/bV4nkP2VLbFkTFlyD2QOh3oEgDMfP43Q SZbrPBqPFpbqx8Bvtm+6kJV7CMqY/F52bvHdreM9GRuVUhLf61leB/ffLWFvN8LvQuqc 2slg== X-Gm-Message-State: AOAM533qqHLXLtCE/ZQQXxIw56fL2DnjTbm++TRS8nTIsC7DFBgpJXw9 GdMlSmXYp8N2ZCe3gvVH/kQMJQ== X-Google-Smtp-Source: ABdhPJzvewHbh7Ug/phOO580pv1zq0+bZCsdfkc81eifmIcHg0fFb/d7vHs0RNWy2PR74Xir911t3A== X-Received: by 2002:aa7:c716:: with SMTP id i22mr2632276edq.94.1606296489038; Wed, 25 Nov 2020 01:28:09 -0800 (PST) Received: from myrica ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id p14sm867798edq.6.2020.11.25.01.28.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 01:28:08 -0800 (PST) Date: Wed, 25 Nov 2020 10:27:49 +0100 From: Jean-Philippe Brucker To: Jason Gunthorpe Subject: Re: [PATCH v10 12/13] iommu/arm-smmu-v3: Implement iommu_sva_bind/unbind() Message-ID: <20201125092749.GA2445658@myrica> References: <20200918101852.582559-1-jean-philippe@linaro.org> <20200918101852.582559-13-jean-philippe@linaro.org> <20201124235800.GA242277@nvidia.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201124235800.GA242277@nvidia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201125_042812_136915_B297B4F8 X-CRM114-Status: GOOD ( 18.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fenghua.yu@intel.com, jacob.jun.pan@linux.intel.com, eric.auger@redhat.com, catalin.marinas@arm.com, joro@8bytes.org, robin.murphy@arm.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Jonathan.Cameron@huawei.com, zhangfei.gao@linaro.org, will@kernel.org, xuzaibo@huawei.com, linux-arm-kernel@lists.infradead.org, baolu.lu@linux.intel.com 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, Nov 24, 2020 at 07:58:00PM -0400, Jason Gunthorpe wrote: > On Fri, Sep 18, 2020 at 12:18:52PM +0200, Jean-Philippe Brucker wrote: > > > +/* Allocate or get existing MMU notifier for this {domain, mm} pair */ > > +static struct arm_smmu_mmu_notifier * > > +arm_smmu_mmu_notifier_get(struct arm_smmu_domain *smmu_domain, > > + struct mm_struct *mm) > > +{ > > + int ret; > > + struct arm_smmu_ctx_desc *cd; > > + struct arm_smmu_mmu_notifier *smmu_mn; > > + > > + list_for_each_entry(smmu_mn, &smmu_domain->mmu_notifiers, list) { > > + if (smmu_mn->mn.mm == mm) { > > + refcount_inc(&smmu_mn->refs); > > + return smmu_mn; > > + } > > + } > > + > > + cd = arm_smmu_alloc_shared_cd(mm); > > + if (IS_ERR(cd)) > > + return ERR_CAST(cd); > > + > > + smmu_mn = kzalloc(sizeof(*smmu_mn), GFP_KERNEL); > > + if (!smmu_mn) { > > + ret = -ENOMEM; > > + goto err_free_cd; > > + } > > + > > + refcount_set(&smmu_mn->refs, 1); > > + smmu_mn->cd = cd; > > + smmu_mn->domain = smmu_domain; > > + smmu_mn->mn.ops = &arm_smmu_mmu_notifier_ops; > > + > > + ret = mmu_notifier_register(&smmu_mn->mn, mm); > > + if (ret) { > > + kfree(smmu_mn); > > + goto err_free_cd; > > + } > > I suppose this hasn't been applied yet, but someone asked me to look > at this series.. It's queued for v5.11, but I could submit improvements for 5.12 > Why did you drop the change to mmu_notifier_get here? Dropped at v6 when I got rid of the io_mm cruft: https://lore.kernel.org/linux-iommu/20200430143424.2787566-1-jean-philippe@linaro.org/ > I'm strongly > trying to discourage static lists matching mm's like smmu_mn is > doing. This is handled by the core code, don't open code it.. We discussed this at v6, which wonkily stored the mn ops in the domain to obtain a unique notifier per {mm, domain}. A clean solution requires changing mm_notifier_get() to use an opaque token. Rather than testing {mm, ops} uniqueness it would compare {mm, ops, token}. I figured it wasn't worth the effort for a single driver, especially since the SMMU driver would still have one list matching because it needs to deal with both {mm, domain} and {mm, device} uniqueness. https://lore.kernel.org/linux-iommu/20200501121552.GA6012@infradead.org/ Thanks, Jean _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel