Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2154347lqt; Mon, 22 Apr 2024 03:07:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW89A7t7J5fxBrVMZnCIKXrCLXOaprgc/Vy4GuelTIgFIyiasmjmzw/O2APAgTMryljhFKFa8daM/t5EuSiA/CglBVCamWMmlSsjxXTDQ== X-Google-Smtp-Source: AGHT+IFf6FzH/aRi/1pW4AwcQE3vJQavbvCCR39XQPsZiqQZulGHRYhiZIx/oIbGP0OSGb8SbHA6 X-Received: by 2002:a17:90a:d393:b0:2a6:664a:9c51 with SMTP id q19-20020a17090ad39300b002a6664a9c51mr7962607pju.17.1713780436292; Mon, 22 Apr 2024 03:07:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713780436; cv=pass; d=google.com; s=arc-20160816; b=ss6C0Il20JAY9UJk50A3xasZYTngq0l9WJyXeztxM/XTZDplToopt/wT9EEKxUq4pF WAQawejL+/WJcHWabT6rc53Dob37962hIkHs9r2bEJzohFtOCi4SYvJHy+WTN3iKPKZG gAb3b6rcHHlo9mcFbrfFq5TDZ30+Ph5U0urwNnd7Q7kOL3RD5QWJUTfJIfg2Cb73SxMv +koPmHHdgytwZGL9IO+0jSWh8jgfNiwrfoCgusUfuQWNH62YbmxLj8+im3Gr8VafKNTE dxqEFCnBqBBbHSqU/Me/IO9uXoI/LT7OsImoWkKRkMf47tMRLJhr49sJ7O1+PvQbxG2W 6M+A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:cc:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=ZVFarcRq6fU4kSoxnU2jUP9H/1PaoH5omO2biePdtsw=; fh=G3pJYHdWpxeW3C5ySFcdHS0N9OVcUZL5ooy87Ibh41k=; b=f9r7GBfnOutH0nmM19vAIrVp7ftqLjL2IEbjWFfNjIpsdHd3HweFGv0SgcWss3zC/1 q1IyqEAkA0/RyFn+VdC1+iP6fGCD8SbwUrWqf4/LFND3QJrSMd0LmpdM8Etz/NdSQehu C9NtwYPk0hvls3e3HPVswdsD+/OGqEorwQc3MTRb4JDI63toKKU3hpXidRNoSKSoeOfD GcIxOA6ixZvQx6pqyBWzWWHlH/QBX4OEIVrhQ5Zhdn2uQ27qtwOL/8RbbjWiC94tFiUY g/0CM8v7WGFf0CBAkqe+3o/NEND/cOjZzT4mpm26DdASf8d9z5AFWCHeL2VyYQAMKced lmFg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=S0qklbmS; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-152885-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152885-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s24-20020a17090aad9800b002ad561f3126si2860879pjq.24.2024.04.22.03.07.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 03:07:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152885-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=S0qklbmS; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-152885-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152885-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 38B73283B79 for ; Mon, 22 Apr 2024 07:41:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1AED04CDEC; Mon, 22 Apr 2024 07:41:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="S0qklbmS" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD9424AEFE; Mon, 22 Apr 2024 07:40:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713771661; cv=none; b=b5NOrs7Hqae6Sbd3nghzBy/f6Dj5RiESMZaFLKs6hwNmwVvPrWj/Z1xB6lqCMiBRGAqKkCY/VQkGJ/GvFk/5U8uEE5H38RQQHVObH2m/hvk3TwMLaLg2ojRX27CKQ8hFUK8iJM0xCjVS3HpCFLJjorLTxpGEKCkNTo9DvykXhZM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713771661; c=relaxed/simple; bh=USR3bFEd40WckrOHmGi8VAlZeJ/vjjPTOFMN/FwP1iw=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=EftwOw/71Y1LoVh3tHlx9VM5luiTqG96RktmsfDERqjhQ2qTC0oUjg3yYM1KuLDxfunetcp3UnZQO+QEwJwywW8d+LDbNksBfq7QBGlFESRw7VKJpIoRmjP0FGEextKpyvaLSu6Pk+/cY95P3wVLl8jWBwYoxEuLqEmYv1DKuU4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=S0qklbmS; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713771660; x=1745307660; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=USR3bFEd40WckrOHmGi8VAlZeJ/vjjPTOFMN/FwP1iw=; b=S0qklbmSM8d0bIkXWJ5FAudZDbh55r1v7Q4NUooJh+XBKGrfPWHacSye u1KZ4gDKgXUu5Vt9Slor/EAjyJLTKfw4jQMxCCenVHhM3x9qIJOBp5bRP r5ysrWGFTEvQkrM9tOYZLdD2zH/b3eGjdCH6c3dl4FXoBmBWu3Q4pBldO 2JGsOrDfnlxExNmfZs82RgL1XldRpcwfbl5xUai2pA9R4aKGxWDG3lEKN jrmu7b9lIWOtTFflfzDiuHhcUot9nFb90gDmJOI3t0+FqNupLlwqOrwET 1GL7eh/8oDN5VvcqLwCj50G2YNZAmP3t8XcYAqjQZxrf2LdYyeTcyZdX4 w==; X-CSE-ConnectionGUID: NYkUW69STGq2tfXR+ozkRg== X-CSE-MsgGUID: C/1kWFZYSqOBJhOMEI+UyQ== X-IronPort-AV: E=McAfee;i="6600,9927,11051"; a="20436786" X-IronPort-AV: E=Sophos;i="6.07,220,1708416000"; d="scan'208";a="20436786" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2024 00:40:59 -0700 X-CSE-ConnectionGUID: Bhjbqn5PRx+ExxI/+DpaQg== X-CSE-MsgGUID: I0j9NBpPT8OLzM2aqsevpQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,220,1708416000"; d="scan'208";a="24012803" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.124.225.176]) ([10.124.225.176]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2024 00:40:54 -0700 Message-ID: <23ef7fbd-7498-4fb0-895b-81c618acedc1@linux.intel.com> Date: Mon, 22 Apr 2024 15:40:51 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: baolu.lu@linux.intel.com, Joerg Roedel , Will Deacon , Robin Murphy , Paul Walmsley , Palmer Dabbelt , Albert Ou , Anup Patel , Sunil V L , Nick Kossifidis , Sebastien Boeuf , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, iommu@lists.linux.dev, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux@rivosinc.com Subject: Re: [PATCH v2 7/7] iommu/riscv: Paging domain support To: Jason Gunthorpe , Tomasz Jeznach References: <301244bc3ff5da484b46d3fecc931cdad7d2806f.1713456598.git.tjeznach@rivosinc.com> <20240419125627.GD223006@ziepe.ca> Content-Language: en-US From: Baolu Lu In-Reply-To: <20240419125627.GD223006@ziepe.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024/4/19 20:56, Jason Gunthorpe wrote: >> + riscv_iommu_cmd_inval_vma(&cmd); >> + riscv_iommu_cmd_inval_set_pscid(&cmd, domain->pscid); >> + if (len > 0 && len < RISCV_IOMMU_IOTLB_INVAL_LIMIT) { >> + for (iova = start; iova < end; iova += PAGE_SIZE) { >> + riscv_iommu_cmd_inval_set_addr(&cmd, iova); >> + riscv_iommu_cmd_send(iommu, &cmd, 0); >> + } >> + } else { >> + riscv_iommu_cmd_send(iommu, &cmd, 0); >> + } >> + } > This seems suboptimal, you probably want to copy the new design that > Intel is doing where you allocate "bonds" that are already > de-duplicated. Ie if I have 10 devices on the same iommu sharing the > domain the above will invalidate the PSCID 10 times. It should only be > done once. > > ie add a "bond" for the (iommu,pscid) and refcount that based on how > many devices are used. Then another "bond" for the ATS stuff eventually. The latest version is under discussion here. https://lore.kernel.org/linux-iommu/20240416080656.60968-1-baolu.lu@linux.intel.com/ Supposedly, you can make such optimization after the base code is landed in the mainline tree if the change is big. Best regards, baolu