Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp491244pxy; Fri, 30 Apr 2021 09:33:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzac/UMw+jdkm1nN418+T4KxT62WUR2Xd7cpE6VjML9/u8gfc9V1+9ogB67DxepGFJafcU7 X-Received: by 2002:a62:86c5:0:b029:25f:4e63:223b with SMTP id x188-20020a6286c50000b029025f4e63223bmr5567531pfd.19.1619800402077; Fri, 30 Apr 2021 09:33:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619800402; cv=none; d=google.com; s=arc-20160816; b=ReQXcqIrV/Het8oHDBsL2r9OCXnpCxNtc4N0EsHlXJ79hgE2jE4ueVgT5+2xKvYsIp 9g9XcbExW758cWgsuYViS+LG4KI3L9NoII2d+8RhpRSBGhahk3avdOKqKMJst01F0uy3 JUcqyk6qAAOZ1xu9hsMpkX0USIv317lYDCV+nXBeU7VOOSxtUxkILhKRUIIElq05Ac5C vBq7qRuZDVtZqi2rnr6Ik27UiEczxay/EaTz/40O2vFVdGYDZRMeWWiyBqrdtSiKdhxG iIbVrncEUvhVEi2Zm55vR6xZb8W96pRIOFs2ioWudVJYt7u6HEqKbmWFRDCu5aIT4yac RoRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VYO/WSrJUAQuhWN9PmepPjluMGVj7vrr4kT01MiVYuU=; b=rC0NOVpZLt5gY+blECefo8J2wmqF4RgtzkSVvy9oVofWECxbBFLZKcJZXTciCpfg2m z4dI6sMnhggIitRHBSqgvDmdHpGQurPO9uT5+X5nHO9BD0GUOppy2DKNG0Psllv1tWVy i4YY8Nlb7UduVdv+SitTxIuUaz68Svl5x5KQz+4F+S6m9pgYku+F1IPRFpDT8BiUgC/h 4pDuiJY15JDrYhlCOt0nlP0AzuuB9raviUpBgef5rtzZOkdvkfCpZ1Zm6+ZIYl1dqLQN QBGiERIbYdD4ryTL1TO6e3OeMY97bPN+zh/Ta08VoF+BKAJ95tY6RFzjlOPWvHMWwSuQ 1E6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=r5wG4ZIp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h15si2743936pfv.27.2021.04.30.09.33.09; Fri, 30 Apr 2021 09:33:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=r5wG4ZIp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231178AbhD3QdN (ORCPT + 99 others); Fri, 30 Apr 2021 12:33:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230421AbhD3QdD (ORCPT ); Fri, 30 Apr 2021 12:33:03 -0400 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B8F7C06138E for ; Fri, 30 Apr 2021 09:32:15 -0700 (PDT) Received: by mail-qk1-x72a.google.com with SMTP id k127so15668325qkc.6 for ; Fri, 30 Apr 2021 09:32:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VYO/WSrJUAQuhWN9PmepPjluMGVj7vrr4kT01MiVYuU=; b=r5wG4ZIp0DghweYrb7BhTEg3Kw1src5C+ZZBqCXlTWE1bZV7bFSh/xbKn1I6HnSmVZ Y6BRnXi613ZhHJDDVj96/JeNtkFJb6utsFpxhCCGvpQB2vOXfWEwzrD6UkyBqb6aqTqC Z539mxM8+agShzuMop5DKz1Jh+KRUvJrvvBNomfNzxooHM/5rknJd6Rh7PIgvlxf1NYV 9iP82LDonuG4dacJwqh4Vya58EnUDAjYUIS/y8r+52Ed5Ra2B/7GXC2vberWnLGvzhTS 81Cp+Ymq20OoFZR+XRfi/zqTpiZshA8PMnbqT/CMp6oLfN7AwCBQ6K0qLSo9FPrSb4XD 4COQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VYO/WSrJUAQuhWN9PmepPjluMGVj7vrr4kT01MiVYuU=; b=jICNOIC1Jwqc1eckhM2KkfB65sih4xV54Gvn1+SXB3WOdBz+DBH6f06HBF9IjXrPZN QchwIUFTj513KXnw19memMPh2DoIW/CoJ8ab/ZF6qNcxAiyFeLJRuktA5NiQjlgDjmJk Z8M9hdKnJkfXb1PrFUFPyZx27AVfGWkf0Z9ZPMNZ8FYdwrzBh+2YgsJpcsCfRMFiK8Jh piHNX26FFPPHHPAU84danxUXvV3VG/kl5H029FPuph03pUIsaAz1htCjL0MN4KNmJwuc k9ZWH0O8Ye64zY9ggx2ldDm3O2fybxVqSR2Yz2K2NHMj2DE8FWJnkjnbGKpRNZFWZ6Af QM5Q== X-Gm-Message-State: AOAM533KnQXXN+vVcIQNEi5hxBCd1/Fk9moj0A7Lc4M3n1nCwgtjE4+L EM7MSthSxgFugEbo3TUu84TvzoiBlHs= X-Received: by 2002:a37:492:: with SMTP id 140mr6290975qke.161.1619800334473; Fri, 30 Apr 2021 09:32:14 -0700 (PDT) Received: from li-908e0a4c-2250-11b2-a85c-f027e903211b.ibm.com.com ([2804:14c:482:7b04::1001]) by smtp.gmail.com with ESMTPSA id p1sm2624334qtu.89.2021.04.30.09.32.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Apr 2021 09:32:14 -0700 (PDT) From: Leonardo Bras To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Joel Stanley , Christophe Leroy , Leonardo Bras , Alexey Kardashevskiy , Nicolin Chen , Niklas Schnelle Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 03/11] powerpc/pseries/iommu: Add iommu_pseries_alloc_table() helper Date: Fri, 30 Apr 2021 13:31:38 -0300 Message-Id: <20210430163145.146984-4-leobras.c@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210430163145.146984-1-leobras.c@gmail.com> References: <20210430163145.146984-1-leobras.c@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Creates a helper to allow allocating a new iommu_table without the need to reallocate the iommu_group. This will be helpful for replacing the iommu_table for the new DMA window, after we remove the old one with iommu_tce_table_put(). Signed-off-by: Leonardo Bras Reviewed-by: Alexey Kardashevskiy --- arch/powerpc/platforms/pseries/iommu.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 796ab356341c..d02359ca1f9f 100644 --- a/arch/powerpc/platforms/pseries/iommu.c +++ b/arch/powerpc/platforms/pseries/iommu.c @@ -53,28 +53,31 @@ enum { DDW_EXT_QUERY_OUT_SIZE = 2 }; -static struct iommu_table_group *iommu_pseries_alloc_group(int node) +static struct iommu_table *iommu_pseries_alloc_table(int node) { - struct iommu_table_group *table_group; struct iommu_table *tbl; - table_group = kzalloc_node(sizeof(struct iommu_table_group), GFP_KERNEL, - node); - if (!table_group) - return NULL; - tbl = kzalloc_node(sizeof(struct iommu_table), GFP_KERNEL, node); if (!tbl) - goto free_group; + return NULL; INIT_LIST_HEAD_RCU(&tbl->it_group_list); kref_init(&tbl->it_kref); + return tbl; +} - table_group->tables[0] = tbl; +static struct iommu_table_group *iommu_pseries_alloc_group(int node) +{ + struct iommu_table_group *table_group; + + table_group = kzalloc_node(sizeof(*table_group), GFP_KERNEL, node); + if (!table_group) + return NULL; - return table_group; + table_group->tables[0] = iommu_pseries_alloc_table(node); + if (table_group->tables[0]) + return table_group; -free_group: kfree(table_group); return NULL; } -- 2.30.2