From patchwork Fri Jul 3 06:18:41 2020 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: 1322108 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (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 49ylQ60n6Zz9sR4 for ; Fri, 3 Jul 2020 16:27:58 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com 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=fPPVhUdp; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49ylQ570XLzDrBj for ; Fri, 3 Jul 2020 16:27:57 +1000 (AEST) 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::741; helo=mail-qk1-x741.google.com; envelope-from=leobras.c@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com 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=fPPVhUdp; dkim-atps=neutral Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) (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 49ylF715p1zDr81 for ; Fri, 3 Jul 2020 16:20:10 +1000 (AEST) Received: by mail-qk1-x741.google.com with SMTP id b185so17336324qkg.1 for ; Thu, 02 Jul 2020 23:20:10 -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=AXuvSewgZzGQToJSuOXn5GH8wcApBjTtF70wFJu0qAc=; b=fPPVhUdpY1M9DbysIaIXL23XoeWqWNbUIJJdsAw+dVE2uhOXL6oGxhvObrJYJUaEoU h2XnVBwNwdVM6ZvENmdI7EMo/B91TjXOBK1ypWF6rC0rvFealR2/FIq5bgJ+ioCu1HoN IMABQTarVBT93UKjySO1f8rVjQ2JUWqHxw6OqTlzdSRvpl0dpZczI0PkbsSs6iBnHMD6 JRecBvN+y+wl24G+4heFYchW8GWxEc4McwX+rA1qY0C/aAHrlukUyuLnl2arz+zU6H8u bnHFOg1YrvWl64oyTLH6pKzeFotJt3/9i0kdFRQO4Rn4iC4mJoCA3XG2hejqcCXmhDSr kemg== 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=AXuvSewgZzGQToJSuOXn5GH8wcApBjTtF70wFJu0qAc=; b=hO3dhg4wN/toSlf72kjCT49zBU+r4zZaNCVgL/B2Zka7aD8yGkUzvsh0LN+jl3k4Hr O1qU0ZH4Y6BijDEhmctGQ0nHUCMl2xg41/RkekvD0ECBXKdWy1onmhki1+rlAJY1pBkQ RsmHvRGM+FtklHEz1j8Ec27kJXklbR34VxpJSewUSx6tMr19pZHorS91ehUrHA0PLUDu YgSIKW4Gg4FDMn93KXq5fvBiVqNRQ3me3WXMM5x9CgOjvlfZhbqlP/XzHqbBkms0X6So pUtirkUdOpWMrNQN1CqC6KpfkVV46pwkndfcxFulhbKlKkF8oOgBUVXRNgjE0soTyMTy Kv9A== X-Gm-Message-State: AOAM530cPNO7UdZHPPaQ0II0B/SsgXILMWf6aSaWlYQpTmei+9IbKfDb iuqqtjExpA2rupMLioETuYM= X-Google-Smtp-Source: ABdhPJz9/pHgqjuttvL+DI0gX6GQ9OGCp4TgP29zV7EXLqJaTpdw/wzKHtFVCQI/uJqRgvK4BpPSQA== X-Received: by 2002:ae9:ea13:: with SMTP id f19mr27890229qkg.331.1593757208178; Thu, 02 Jul 2020 23:20:08 -0700 (PDT) Received: from LeoBras.ibmuc.com (200-236-245-17.dynamic.desktop.com.br. [200.236.245.17]) by smtp.gmail.com with ESMTPSA id n28sm11165288qtf.8.2020.07.02.23.20.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jul 2020 23:20:07 -0700 (PDT) From: Leonardo Bras To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alexey Kardashevskiy , Leonardo Bras , Thiago Jung Bauermann , Ram Pai Subject: [PATCH v3 3/6] powerpc/pseries/iommu: Move window-removing part of remove_ddw into remove_dma_window Date: Fri, 3 Jul 2020 03:18:41 -0300 Message-Id: <20200703061844.111865-4-leobras.c@gmail.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200703061844.111865-1-leobras.c@gmail.com> References: <20200703061844.111865-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" Move the window-removing part of remove_ddw into a new function (remove_dma_window), so it can be used to remove other DMA windows. It's useful for removing DMA windows that don't create DIRECT64_PROPNAME property, like the default DMA window from the device, which uses "ibm,dma-window". Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 45 +++++++++++++++----------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 1a933c4e8bba..4e33147825cc 100644 --- a/arch/powerpc/platforms/pseries/iommu.c +++ b/arch/powerpc/platforms/pseries/iommu.c @@ -781,25 +781,14 @@ static int __init disable_ddw_setup(char *str) early_param("disable_ddw", disable_ddw_setup); -static void remove_ddw(struct device_node *np, bool remove_prop) +static void remove_dma_window(struct device_node *np, u32 *ddw_avail, + struct property *win) { struct dynamic_dma_window_prop *dwp; - struct property *win64; - u32 ddw_avail[DDW_APPLICABLE_SIZE]; u64 liobn; - int ret = 0; - - ret = of_property_read_u32_array(np, "ibm,ddw-applicable", - &ddw_avail[0], DDW_APPLICABLE_SIZE); - - win64 = of_find_property(np, DIRECT64_PROPNAME, NULL); - if (!win64) - return; - - if (ret || win64->length < sizeof(*dwp)) - goto delprop; + int ret; - dwp = win64->value; + dwp = win->value; liobn = (u64)be32_to_cpu(dwp->liobn); /* clear the whole window, note the arg is in kernel pages */ @@ -821,10 +810,30 @@ static void remove_ddw(struct device_node *np, bool remove_prop) pr_debug("%pOF: successfully removed direct window: rtas returned " "%d to ibm,remove-pe-dma-window(%x) %llx\n", np, ret, ddw_avail[DDW_REMOVE_PE_DMA_WIN], liobn); +} + +static void remove_ddw(struct device_node *np, bool remove_prop) +{ + struct property *win; + u32 ddw_avail[DDW_APPLICABLE_SIZE]; + int ret = 0; + + ret = of_property_read_u32_array(np, "ibm,ddw-applicable", + &ddw_avail[0], DDW_APPLICABLE_SIZE); + if (ret) + return; + + win = of_find_property(np, DIRECT64_PROPNAME, NULL); + if (!win) + return; + + if (win->length >= sizeof(struct dynamic_dma_window_prop)) + remove_dma_window(np, ddw_avail, win); + + if (!remove_prop) + return; -delprop: - if (remove_prop) - ret = of_remove_property(np, win64); + ret = of_remove_property(np, win); if (ret) pr_warn("%pOF: failed to remove direct window property: %d\n", np, ret);