From patchwork Thu Apr 22 07:07:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Leonardo_Br=C3=A1s?= X-Patchwork-Id: 1469023 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=aA9nvDxy; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FQpXS5VzQz9sSC for ; Thu, 22 Apr 2021 17:12:40 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4FQpXS4n2Hz3bxl for ; Thu, 22 Apr 2021 17:12:40 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=aA9nvDxy; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::f2e; helo=mail-qv1-xf2e.google.com; envelope-from=leobras.c@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=aA9nvDxy; dkim-atps=neutral Received: from mail-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [IPv6:2607:f8b0:4864:20::f2e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4FQpRt6GGYz3bsm for ; Thu, 22 Apr 2021 17:08:42 +1000 (AEST) Received: by mail-qv1-xf2e.google.com with SMTP id ei1so3488894qvb.9 for ; Thu, 22 Apr 2021 00:08:42 -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=AoZXrUkv0udXNoT8w/Ft93InRMYUvDvZ87CDQIYBZaw=; b=aA9nvDxyuCeSQ4HVCXeg+DEtYFyCJb130yUW3vJxks1Y+9wAkgy9KIjudn4gNT0CZk LcooEzOH0tis4RXDQsge4LnwQyVnSYH+VlAiPDCRT39WSuXFXs9NEnJms2pkPdYahjyo 1/k/WwBntOHmHaiLILClZiNy5zuGAvOY1Sksgkslcu61V7196+ygBeoqGuMJLbXdVgP2 5j/RUTaFd3H5dD0NvEBQSdWG8jSP71Jc9oUPaeHrH1+f7gQ6+xt3RrtsUrcB6FvvcI1s 5aWDlWho+uG+LMNRxdfQiaAilqCI595MRuZEGl+9wwiETDP7BJFvualpZFtBcE1BLPsW ojwg== 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=AoZXrUkv0udXNoT8w/Ft93InRMYUvDvZ87CDQIYBZaw=; b=m57JAYis810U0XInFZ8TqLBH6uLHb2M/fHQbMhMpwcmQs1zzAtRswnQGin/QqGHOd+ UI++XBk8BOhBMpIhwXPODb0YI0KvGFgP3K0B81L8yFkPMJezeTD0Jhqd/z79q3AUK2+R O87scRV0Wrir8b6+5H0s00n5Fx/EcXksGMSEDX3GEeSkHBR9OuY1d7DQxvyqyMa6TUDL VHea7RWgJNHUSb7/MQDyAEg8QvQyqtVjc3ZCjZbeC1eaUpFjF0rW7riiihx70b149QGh G0utBYhjqVxXKoKEeyepJKV+wBm/6MW/aTQFSLb8rdqnv68BK8P5MjKqWBEgirFyjq5E +LIg== X-Gm-Message-State: AOAM533vVlhCMiOfgpFLOwpINbN1uCVB5LzwpHTbtsnkLZJEnXVpRpQ6 4qhct0PJIPcseHhrizh+F40= X-Google-Smtp-Source: ABdhPJz819j68z8ZrvwHt6aGkXaKBd8CmPhMQ5J9o9pbkP4mCfkCbf5mVa15tlwx3Dy0Fv2AjoVLTA== X-Received: by 2002:a0c:f9c5:: with SMTP id j5mr1877385qvo.36.1619075320201; Thu, 22 Apr 2021 00:08:40 -0700 (PDT) Received: from li-908e0a4c-2250-11b2-a85c-f027e903211b.ibm.com.com ([177.35.200.187]) by smtp.gmail.com with ESMTPSA id w67sm1658329qkc.79.2021.04.22.00.08.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 00:08:39 -0700 (PDT) From: Leonardo Bras To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Leonardo Bras , Joel Stanley , Christophe Leroy , Alexey Kardashevskiy , Nicolin Chen , Niklas Schnelle Subject: [PATCH v3 09/11] powerpc/pseries/iommu: Find existing DDW with given property name Date: Thu, 22 Apr 2021 04:07:21 -0300 Message-Id: <20210422070721.463912-10-leobras.c@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210422070721.463912-1-leobras.c@gmail.com> References: <20210422070721.463912-1-leobras.c@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" At the moment pseries stores information about created directly mapped DDW window in DIRECT64_PROPNAME. With the objective of implementing indirect DMA mapping with DDW, it's necessary to have another propriety name to make sure kexec'ing into older kernels does not break, as it would if we reuse DIRECT64_PROPNAME. In order to have this, find_existing_ddw_windows() needs to be able to look for different property names. Extract find_existing_ddw_windows() into find_existing_ddw_windows_named() and calls it with current property name. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 075c6e08f012..3367233a5535 100644 --- a/arch/powerpc/platforms/pseries/iommu.c +++ b/arch/powerpc/platforms/pseries/iommu.c @@ -888,24 +888,21 @@ static struct direct_window *ddw_list_new_entry(struct device_node *pdn, return window; } -static int find_existing_ddw_windows(void) +static void find_existing_ddw_windows_named(const char *name) { int len; struct device_node *pdn; struct direct_window *window; - const struct dynamic_dma_window_prop *direct64; - - if (!firmware_has_feature(FW_FEATURE_LPAR)) - return 0; + const struct dynamic_dma_window_prop *dma64; - for_each_node_with_property(pdn, DIRECT64_PROPNAME) { - direct64 = of_get_property(pdn, DIRECT64_PROPNAME, &len); - if (!direct64 || len < sizeof(*direct64)) { - remove_ddw(pdn, true, DIRECT64_PROPNAME); + for_each_node_with_property(pdn, name) { + dma64 = of_get_property(pdn, name, &len); + if (!dma64 || len < sizeof(*dma64)) { + remove_ddw(pdn, true, name); continue; } - window = ddw_list_new_entry(pdn, direct64); + window = ddw_list_new_entry(pdn, dma64); if (!window) break; @@ -913,6 +910,14 @@ static int find_existing_ddw_windows(void) list_add(&window->list, &direct_window_list); spin_unlock(&direct_window_list_lock); } +} + +static int find_existing_ddw_windows(void) +{ + if (!firmware_has_feature(FW_FEATURE_LPAR)) + return 0; + + find_existing_ddw_windows_named(DIRECT64_PROPNAME); return 0; }