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=-6.7 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 220C5C43461 for ; Thu, 17 Sep 2020 14:40:28 +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 B00312223C for ; Thu, 17 Sep 2020 14:40:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gak9GtDO"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="GFTFOf9K" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B00312223C 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=OkBuo3RokTZO80ZOnRQbn3G59dY2z3bU94FRe0J3N8w=; b=gak9GtDOlCu13XSoFWBoyGuFz Y/gTAFLIK2DEgaD7g/n3aDwI9lTYiaqPiPOuLqQOSv2EtBdGoIBQJdu+9ENOwpXICISMvBfn+8Jur XVfDnzSKa/MwhsercTtQd5PbOFCoPGgphOE1GZFKM0Fd40C7E6+KYkHbXDS+Dk0q47rxSBMVcwvB6 6R2WGvnTE6d+fPeAhSPdXOPYn9Dv/dPO8w2gaQNFa+ZPWPkTRq77FjG3aB0vw58P+R7zd/6zjAMnC rJ/wFms4MvETBKwxhJBsNmb0i0VfNM4fzraQmb7kKyZad7di7lFbCI9+rUiz8Iehygu0Z0YQPymrl dU2GRc4NA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIv42-0004WG-CA; Thu, 17 Sep 2020 14:39:10 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIv3y-0004Ut-Oa for linux-arm-kernel@lists.infradead.org; Thu, 17 Sep 2020 14:39:07 +0000 Received: by mail-wr1-x442.google.com with SMTP id g4so2354044wrs.5 for ; Thu, 17 Sep 2020 07:39:06 -0700 (PDT) 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=blq2eWz1TJY2NfaOXXK0EtWvwOCukS98JLYvKkk93sM=; b=GFTFOf9KQo9OYFZDXVIhEsIqyfD0L+/FflZiDJdF9RcHJ5dOvFWQzNepjcs7Ivc/ma QWd66lW5nQX7igMeeWoP1qZ61ZaEvQuOkN5I/O8d8sP+nemrwyPJETg9H7nPSP5rRuf0 e5JebqaoNMJe8Uy9S/AutgpgQOycEmMXKtwlJX+xi7JV8+igu0AY+sAmYUNhi8hN36ui H1WDDLMZP1vYQSjlYBEuWqXwOHjA4+I4Dt7fueOmsgmQgq3AgKAA6nOinN/7Frj0gPfr sG5RYsh7UJEHIx/Y+JtEkzG/HmRUtBA2mp8PUlAJNxRN23FixjhML1gh1Fg5/Af1sAVs coTw== 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=blq2eWz1TJY2NfaOXXK0EtWvwOCukS98JLYvKkk93sM=; b=k+7lpiOPyXRc+GOaPf5pl7vRAkgMJ5cGsKyyGEcQ1rYE7lfwOOMewmi2z7M2kdL+ut rK1WHLWU95WswY45XF1XI7uAlZ/jE4/mw7TvSEcR5RL7CvfyQKvRoUcIZxUKq7TvcmF+ xrNc1B696+nfYHGiTuK8nasNrA30MoyegMZZ9/jS/eKsSMwaXrvpsMV8coaiSCA8ZhnV ouhkVjQn82VJyTu0qmTaOA0D+BXT9inG++Z54VJkOSqts0ZxrxaqCIPRV7qbOId8O9xZ KKr1lZhp9n/RmUFtSqnfHPnWiyncM8yJZqB+g2soWGdxCJEGhLbaKEaHcy8EO50EAf5R f6eQ== X-Gm-Message-State: AOAM533HopVuVJhKOv8PHT6cXstoA5XIBBplqZJXmSNTN8oE3/FLJBaV nSpq9UsrHkmAUrt/Nhv7iHjAAQ== X-Google-Smtp-Source: ABdhPJwT7jNG6KNnNsiF2CoCm68Ve7JQv1AJXwjyTV/nuEqz1zbskGeAhcfQ5nK/wfDSAhXGLzRoww== X-Received: by 2002:a5d:470f:: with SMTP id y15mr32317774wrq.420.1600353545804; Thu, 17 Sep 2020 07:39:05 -0700 (PDT) Received: from myrica ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id m10sm11033383wmi.9.2020.09.17.07.39.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 07:39:05 -0700 (PDT) Date: Thu, 17 Sep 2020 16:38:46 +0200 From: Jean-Philippe Brucker To: Auger Eric Subject: Re: [PATCH RESEND v9 09/13] iommu/arm-smmu-v3: Seize private ASID Message-ID: <20200917143846.GD134903@myrica> References: <20200817171558.325917-1-jean-philippe@linaro.org> <20200817171558.325917-10-jean-philippe@linaro.org> <7a67022c-a33a-5ea1-1bfb-4154d83ca009@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <7a67022c-a33a-5ea1-1bfb-4154d83ca009@redhat.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200917_103906_813180_04F6513B X-CRM114-Status: GOOD ( 16.13 ) 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, will@kernel.org, catalin.marinas@arm.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, zhangfei.gao@linaro.org, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org 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 Mon, Sep 07, 2020 at 06:41:11PM +0200, Auger Eric wrote: > > +/* > > + * Try to reserve this ASID in the SMMU. If it is in use, try to steal it from > > + * the private entry. Careful here, we may be modifying the context tables of > > + * another SMMU! > Not sure I got what you meant by this comment. That comment does need refreshing: /* * Check if the CPU ASID is available on the SMMU side. If a private context * descriptor is using it, try to replace it. */ > > + */ > > static struct arm_smmu_ctx_desc * > > arm_smmu_share_asid(struct mm_struct *mm, u16 asid) > > { > > + int ret; > > + u32 new_asid; > > struct arm_smmu_ctx_desc *cd; > > + struct arm_smmu_device *smmu; > > + struct arm_smmu_domain *smmu_domain; > > > > cd = xa_load(&arm_smmu_asid_xa, asid); > > if (!cd) > > @@ -27,8 +36,31 @@ arm_smmu_share_asid(struct mm_struct *mm, u16 asid) > > return cd; > > } > > > > - /* Ouch, ASID is already in use for a private cd. */ > > - return ERR_PTR(-EBUSY); > > + smmu_domain = container_of(cd, struct arm_smmu_domain, s1_cfg.cd); > > + smmu = smmu_domain->smmu; > > + > > + ret = xa_alloc(&arm_smmu_asid_xa, &new_asid, cd, > > + XA_LIMIT(1, 1 << smmu->asid_bits), GFP_KERNEL); > XA_LIMIT(1, (1 << smmu->asid_bits) - 1), GFP_KERNEL) Good catch Thanks, Jean _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel