Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp162767pxa; Tue, 4 Aug 2020 20:05:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwUiQkcrQD0odnOgBsGmL6jsr/tZAVhSR8xpkKgmWxzQlQUd4OiGgNRyFErtnVyxzkKbuH X-Received: by 2002:a17:906:743:: with SMTP id z3mr1165937ejb.216.1596596746395; Tue, 04 Aug 2020 20:05:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596596746; cv=none; d=google.com; s=arc-20160816; b=FkdHZIjq3ASrO6XCFd5fz/8F9o4d+XJgP1y2XseCZ8dJKDHDqKDpqhfXBS8yH71UQW kKNR+5lYkT4eC8voAeracIaK8hDN1yHAAfluJIL9w3oxpHuHVSHYY1ZgaNOWBNnZG75b c1cJPSnDxiyynn4cNqO1B4PAVAp7kIcXH35jUHKb41jnn+rfzwAYsp5GgN342C7HOtbk YTXzm5Mavb8AEPTtCszH/bvPR10h/+CIspy9zfFn2SJGEF+m4eR2UeRqIe73CRubiNiP oPgKAkPF5xeWfF3N70y02rbuqejUZMnQ+vVrtKF0GlMKzrulGJsBIh5NF9Wj3m8d9T3U 2YQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=WtXwfpDFreDLwGVsqvsaCTe1LWZg8pmE0dEw2EJKlf0=; b=eIr9JbjcxwDlkgAXC7wwyUQNk1nQB3Zrguf8CPnhn5DuMPwauh08n3CfKQPblhQJub uzNVWggi5nXJRKK7klbAetKsmmuiiWNBBoc07mXdSl6ztF8Pg4tscjVKCMQB6GKbynuA 6h5b7b0t0jpQ6+T1Qphf02ad2b23EqnDVmVz6UG3AhdHluqdOwQeMWHZd900Za/zhM9Q VocFhYyeVEswQ1wDpRrcK1OimD+3Y0mUFk/NC60M2gba+TrOuVMRDdH+d0K3y0kMlh99 HsttsQlXq4pWrWr6F2jZPSRPjZZw9F407JrTWug4IRhcUuBwLqlZqPWOy34Fz8nLy2ab RVHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Sks840nK; 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 j3si462562edt.444.2020.08.04.20.05.23; Tue, 04 Aug 2020 20:05:46 -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=Sks840nK; 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 S1727118AbgHEDFG (ORCPT + 99 others); Tue, 4 Aug 2020 23:05:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725950AbgHEDFG (ORCPT ); Tue, 4 Aug 2020 23:05:06 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E0E7C06174A for ; Tue, 4 Aug 2020 20:05:06 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id h7so40444913qkk.7 for ; Tue, 04 Aug 2020 20:05:06 -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:mime-version :content-transfer-encoding; bh=WtXwfpDFreDLwGVsqvsaCTe1LWZg8pmE0dEw2EJKlf0=; b=Sks840nKMOrcyH24HC/3BAqdEuA0rkgkLlLBy5HCVvWfWag5qxd5TGH/DvTp+PFCjw TDBw61DiWcwU+p836z/cGcL9YceKYcS4k1CTd53ub09Z/GoAK5EVqi9k3OhwazvppyF9 J4DARGGWfSBmMO3XEe9ksbYWt1v54qBzzTpHj6Rr/GneGlr+eBJxs3m80oXTkHuxorF2 1jIfhcAIz/87HGHJ4trc7lrQ628DxOziEZ6DAlyGHqEMo4AqMyS36fCkUqg46nyxava1 Aa8WDFVGb0n0RA3v/jt5/kZ3vWFIPHEzT7Ysw7rgeR4fB3ZtL2OrI3/zhm3wWNqpeb2w gy9w== 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:mime-version :content-transfer-encoding; bh=WtXwfpDFreDLwGVsqvsaCTe1LWZg8pmE0dEw2EJKlf0=; b=N74fQ3bQ0MMuf+KOFQQ/k/L087CojQq/kOrra9Mw4i4t8J2WUrbZckMZ7RX6NbYM/1 GtB/cy4E7jhM2UbYDMNg5JO8Y7D2lZb3Jjoie/2omWxHr7ShjB6hjYEtgGNf2iPw7T01 TQHHyZ5jbICoZhWI9wEH+Wt0y88qE3m+89jNno0DT0dIsPL9HKqJ5nRpWPTH+B4/jvp3 jjWMmXE21J2DrIv32ibqxf1+8SjuqJ1hYtQkC+NRA0p6/jZLoY1fhknpOm/beoLxUV4I BoCQ4wsgEq1b90zQVHFdAtsa2pQqWEt6O8WmJgYeA2gzQstPA8fKRaN1Jcu6CIg5JCIJ cmzg== X-Gm-Message-State: AOAM531H66yQgyrtfsO+BwvPWTYxRCmKOeFHAG+2/pEwInyUc9Cn2MDn 6EHmjjwIjaOueebggNVpU7E= X-Received: by 2002:a05:620a:1436:: with SMTP id k22mr1333392qkj.308.1596596705317; Tue, 04 Aug 2020 20:05:05 -0700 (PDT) Received: from LeoBras.ibmuc.com (179-125-154-168.dynamic.desktop.com.br. [179.125.154.168]) by smtp.gmail.com with ESMTPSA id n4sm869946qtr.73.2020.08.04.20.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2020 20:05:04 -0700 (PDT) From: Leonardo Bras To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Leonardo Bras , Alexey Kardashevskiy , Thiago Jung Bauermann , Ram Pai , Brian King , Murilo Fossa Vicentini , David Dai Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 0/4] Allow bigger 64bit window by removing default DMA window Date: Wed, 5 Aug 2020 00:04:51 -0300 Message-Id: <20200805030455.123024-1-leobras.c@gmail.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are some devices in which a hypervisor may only allow 1 DMA window to exist at a time, and in those cases, a DDW is never created to them, since the default DMA window keeps using this resource. LoPAR recommends this procedure: 1. Remove the default DMA window, 2. Query for which configs the DDW can be created, 3. Create a DDW. Patch #1: Create defines for outputs of ibm,ddw-applicable, so it's easier to identify them. Patch #2: - After LoPAR level 2.8, there is an extension that can make ibm,query-pe-dma-windows to have 6 outputs instead of 5. This changes the order of the outputs, and that can cause some trouble. - query_ddw() was updated to check how many outputs the ibm,query-pe-dma-windows is supposed to have, update the rtas_call() and deal correctly with the outputs in both cases. - This patch looks somehow unrelated to the series, but it can avoid future problems on DDW creation. Patch #3 moves the window-removing code from remove_ddw() to remove_dma_window(), creating a way to delete any DMA window, so it can be used to delete the default DMA window. Patch #4 makes use of the remove_dma_window() from patch #3 to remove the default DMA window before query_ddw(). It also implements a new rtas call to recover the default DMA window, in case anything fails after it was removed, and a DDW couldn't be created. --- Changes since v4: - Removed patches 5+ in order to deal with a feature at a time - Remove unnecessary parentesis in patch #4 - Changed patch #4 title from "Remove default DMA window before creating DDW" - Included David Dai tested-by - v4 link: http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=190051&state=%2A&archive=both Changes since v3: - Introduces new patch #5, to prepare for an important change in #6 - struct iommu_table was not being updated, so include a way to do this in patch #6. - Improved patch #4 based in a suggestion from Alexey, to make code more easily understandable - v3 link: http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=187348&state=%2A&archive=both Changes since v2: - Change the way ibm,ddw-extensions is accessed, using a proper function instead of doing this inline everytime it's used. - Remove previous patch #6, as it doesn't look like it would be useful. - Add new patch, for changing names from direct* to dma*, as indirect mapping can be used from now on. - Fix some typos, corrects some define usage. - v2 link: http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=185433&state=%2A&archive=both Changes since v1: - Add defines for ibm,ddw-applicable and ibm,ddw-extensions outputs - Merge aux function query_ddw_out_sz() into query_ddw() - Merge reset_dma_window() patch (prev. #2) into remove default DMA window patch (#4). - Keep device_node *np name instead of using pdn in remove_*() - Rename 'device_node *pdn' into 'parent' in new functions - Rename dfl_win to default_win - Only remove the default DMA window if there is no window available in first query. - Check if default DMA window can be restored before removing it. - Fix 'unitialized use' (found by travis mpe:ci-test) - New patches #5 and #6 - v1 link: http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=184420&state=%2A&archive=both Special thanks for Alexey Kardashevskiy, Brian King and Oliver O'Halloran for the feedback provided! Leonardo Bras (4): powerpc/pseries/iommu: Create defines for operations in ibm,ddw-applicable powerpc/pseries/iommu: Update call to ibm,query-pe-dma-windows powerpc/pseries/iommu: Move window-removing part of remove_ddw into remove_dma_window powerpc/pseries/iommu: Allow bigger 64bit window by removing default DMA window arch/powerpc/platforms/pseries/iommu.c | 242 ++++++++++++++++++++----- 1 file changed, 195 insertions(+), 47 deletions(-) -- 2.25.4