Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp954361pxb; Mon, 16 Aug 2021 23:41:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYULR07pBiMtKaa9zDUmxCQOX3R8HaAxZjE1WwMRha5kleqQYl5fpWcmJbdqqV5hDwNYPS X-Received: by 2002:a5e:8812:: with SMTP id l18mr1832759ioj.157.1629182491444; Mon, 16 Aug 2021 23:41:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629182491; cv=none; d=google.com; s=arc-20160816; b=mFerfoegYn4AMdj29QwAaRYhBSOBCvIlg1EOmtIUZRJnUrlomEVk1Hm6PHgKlsWWJq 8vzjNuV0Lu43ttqY7LAEYSr6tWHhhtVAuraQk+h23rCTc/wIOq0TgvduEFaRRoLoutjd iBOn3C+QlHgbKtj1cyylnRvLvJ6BpbgXrD76PFiN7899B5zNzJIFS9WW4OpTJicTLsNK x/eLUrVWf6GdaaCibeE3I0QS+m/h4Cu0F83NeWfHw5uyHTz2S36OoY6rNLR7/GzZugRz tjBCQVEidFhLVNKZhuU44Hdk7/vios4V7FscYguDR6BSOcLtAfQKHNTjslqX4Yd9d5ST WLBg== 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=HyJt6PU8F2AZ27Os2Gh9HToURd99LY2BIrsmeAWc9n0=; b=pL7gOBusfp/T0SK7k7OcH2YGq5UF1Hz9zdF/F9Nq2Gq60kHa77ooFTn4eCyrdCYy+K I83yT8c9CjdlQeEg/ss8iRst4QwBZsdMM9x6rhwuNdyjKfaQSg09TWq8Q52JTcow6gtb 4NSq3vR447ErXUUKxMAHcLZvTlxDSnLwjD8YHmQWQRYX8W9sZco5UMzceSVrb6fMPa+e IVQ+iMnq0/XdfR4CvtNHCJzk9B1NCjpFUphW1ziExo0sKzXRp6uVweRCDD7pu6ijb5d/ zIYcM25FfUijnX9N/adh+K9e/3JiFrZmn+WPuIprlqC/xAgZBsEFNOKbOjRSSUz4AxEy u23Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TgSGn5ik; 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 p15si1526381jan.86.2021.08.16.23.41.20; Mon, 16 Aug 2021 23:41:31 -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=TgSGn5ik; 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 S238401AbhHQGlC (ORCPT + 99 others); Tue, 17 Aug 2021 02:41:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233118AbhHQGkz (ORCPT ); Tue, 17 Aug 2021 02:40:55 -0400 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9663AC061796 for ; Mon, 16 Aug 2021 23:40:22 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id y144so8909691qkb.6 for ; Mon, 16 Aug 2021 23:40:22 -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=HyJt6PU8F2AZ27Os2Gh9HToURd99LY2BIrsmeAWc9n0=; b=TgSGn5ikHZPvrwUAhmwCeQuflxe6hE3G+KqV+lxzLwtbvh4HUm+5puCcWGjI6Ubwik WCRK6pHIgiVdMMbNywWhgoOYdMzV1pyLmACPOBcaV5F8WND/tUItXQRjgLbD8/KD68HQ yqEzDaYqg/mw9VjTM8uPUJvSnk0GsVsv/B5SeL9q5ybKPtGvD4fElUoBXvAglx+eV9Wg rp6kT9VfZKDul6B6Ju/le7xkoPqVRYqEErjpt2iUZFjyBBEzdTHH6Sc4Vv4uKAjUN2gh 56r0rRFeSl0ZOsacn+/zTs9GyyfMc4Yy4tfNzm9znGBaB4PMaIx/vWOkhtQbYnkmuuvG gMGA== 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=HyJt6PU8F2AZ27Os2Gh9HToURd99LY2BIrsmeAWc9n0=; b=o4dMc6I+trN+BC7wb778RvHN7BIR6rkvhMCspPso9K7OLLZgNEnKXUhqhfFyd3lDbm uCJcmK3OOqmrVzTw9IX9YgmkJaKsGtjrvQ7wjresJhcqddnDlHstfDMcjl3VH1qM1/jJ UBi47ASaqzd8lrWUDFDo4/B1Mo6EBDpEkjbzDyc/0M38nPb2CjtxRoBRh0KaEb4b8DN4 1FHNetbuIF94CcIZ1CwlerbgzcQ3TZEmG5LX3PC8R4rYbXai8vFtRaGtX1tjaKncmt4a sSlOjkywFEGOTlfg4KeL7MLfb7e04VBz8UOs/awuPYQdVPjk0Fim01Yz8yYV+9p+RRC8 TH/A== X-Gm-Message-State: AOAM530krxCt5t0Dl8H4yCnWYXz55WoQnJPr0TRRAd8FfkCKomBmYIji ndKrLqdMrTlTHrHbg/+PzSs= X-Received: by 2002:ae9:dc82:: with SMTP id q124mr2230762qkf.288.1629182421814; Mon, 16 Aug 2021 23:40:21 -0700 (PDT) Received: from LeoBras.redhat.com ([2804:431:c7f0:30b2:5c9e:50:88f3:269a]) by smtp.gmail.com with ESMTPSA id c11sm526938qth.29.2021.08.16.23.40.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Aug 2021 23:40:21 -0700 (PDT) From: Leonardo Bras To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Leonardo Bras , Alexey Kardashevskiy , Frederic Barrat , David Gibson , Nicolin Chen , kernel test robot Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 03/11] powerpc/pseries/iommu: Add iommu_pseries_alloc_table() helper Date: Tue, 17 Aug 2021 03:39:21 -0300 Message-Id: <20210817063929.38701-4-leobras.c@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210817063929.38701-1-leobras.c@gmail.com> References: <20210817063929.38701-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 Reviewed-by: Frederic Barrat --- 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 b1b8d12bab39..33d82865d6e6 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.32.0