Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1095507pxv; Thu, 22 Jul 2021 22:37:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzo6ufydRHYRj8l/3AsDoqVmbLqXHRYb3yhi9XkXlqnhjaGJUGP5RH+WUZRgzUX6wUX/3qO X-Received: by 2002:a05:6402:278e:: with SMTP id b14mr3584377ede.277.1627018643111; Thu, 22 Jul 2021 22:37:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627018643; cv=none; d=google.com; s=arc-20160816; b=ekNZJV2+JLbMa8f8jrTtrBdgc96ogxdRAxUCiMQF8vezVz0i2Zef/E4Gi0ZGadRICy 9csuEBCJiIL4udTgdG1dlXKtCKxLehPXe+0BTZ1fM3Ofw8qHvwYoreWGytwYUFJtM7fV DgGeYfDx2h4FMcoeDnmnFLbGvK7XxfvXluUvw+B2SR89u1/S5kA6qCbZwDfmit+9YNqm MtPuRBDEvwRmP90IkWKJnyyVNERto6zMFgqHL3iq4v8mUG2YjFMWRD9tPSQm0KWs2g7H QevyHRxGx/1HACgHRPwOMFrWN9uNsCfFlXb6Yr6rDq65BRn8VfYSX9h4vysuNsPv8cjo Gjpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=R31IBsRAfuuPKWQktgrPBsM8qqZTNdn0VUlW4YQ6CmU=; b=N5xlRZNx7Qphw+T7+0fudxURDVWjPuxVHhl9Rqd0Tt/4mikIo8Z+TryqHq6wwi4TmE Pp4k/RBRY5gIf8sDL/8aTpODPTh6TNxAqwg1kTONO/Mjh3asnF7RYbNEtB08b+yzZmQx 791CAy6LlacT+HgbAE818DGo2v8HgXVKmC01aMHc1TMiRBOqasBi/bTWXabXDIz9Jy3d XbIyV84APW2iNSfsCMDW53OGAf/vF8CemdQr9pGOAphReKVrkLQCZomt7TpqIYw5JpiX Ald7pP9ekAtmjKRCzi+v6M7f4tf4nQLM92BQbYHBzw2tzlpCW/ZXWMoXD65z9B9yk6KN gPtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ozlabs-ru.20150623.gappssmtp.com header.s=20150623 header.b=shYdbYpK; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nd17si34933798ejc.732.2021.07.22.22.36.59; Thu, 22 Jul 2021 22:37:23 -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=@ozlabs-ru.20150623.gappssmtp.com header.s=20150623 header.b=shYdbYpK; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231807AbhGWEyW (ORCPT + 99 others); Fri, 23 Jul 2021 00:54:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229904AbhGWEx7 (ORCPT ); Fri, 23 Jul 2021 00:53:59 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAEF1C061575 for ; Thu, 22 Jul 2021 22:34:32 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id m2-20020a17090a71c2b0290175cf22899cso2342312pjs.2 for ; Thu, 22 Jul 2021 22:34:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ozlabs-ru.20150623.gappssmtp.com; s=20150623; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=R31IBsRAfuuPKWQktgrPBsM8qqZTNdn0VUlW4YQ6CmU=; b=shYdbYpKnnZqm3nw+0kpBihqH8f7KJROTlNmKF6YN4j4mx9oxE9amV1mosmOA6XqFB MVjyzhtn+B+ahOWqplFIYkLSU+nMzE6N0JSo+x9HY2zsO60MQfzTIzwgg3AhDYqimSRh 6eu3wJ5bfyiCjKf6iRfpZ6d4Jg5azuCRs9nxkVvmhtu2Rd8yMNQb1ekVMChSypNwNlXs 6g9SbsBaiRoWq4MfOTVh7QP4eU0iNr9hbYlLRSY3nVX5f/8wWbNux4QWD8B5f7XDPD0m WUsIdOtdX1g8NK05c0UHfuBF42+/UItgWfFng0ZZJ0q/BRt1URVN1jPQzVX26cA+NuqH X8Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=R31IBsRAfuuPKWQktgrPBsM8qqZTNdn0VUlW4YQ6CmU=; b=XkfVhPA9b8hOIVcL4jEqD9yIoW19wch84BeZKwEFioSf4Mqxp9OsWTQ4URrsBieMs9 DbdrRwSKmH7A0G8sLhx/S3C4zgOJdEgBXhuTRYb3rhd0/J2X9dIQLgzHc246KlDpoLgr tFOkBsguYs+FFmsoOTqXAAWj0ogrJmBVDNTg8I28WJGg9s1E2cBz4WQApsubndqFeLiv RZVooSwvdeJHzsP5zi9f4/G4Lk2WKCcCg9W8j84H/CnZ678swGSXoEgYwnDk9zGLYAQs UIEfFLmTJ6hTQY+7FrdRQstooS8pSgnCvwh2qr+DuWEbK+8+tHOs94g7SmIJc36TtHgT zqMQ== X-Gm-Message-State: AOAM531UBhVgzxgB41lp3CP86hBSbnJ0kb+PxneV8pllZesOBsETIgBy 5XZDLSQ1WEqfRebhq4r6doY41Q== X-Received: by 2002:a17:90a:420c:: with SMTP id o12mr3076303pjg.101.1627018472138; Thu, 22 Jul 2021 22:34:32 -0700 (PDT) Received: from [192.168.10.23] (219-90-184-65.ip.adam.com.au. [219.90.184.65]) by smtp.gmail.com with UTF8SMTPSA id n22sm31926155pfo.125.2021.07.22.22.34.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Jul 2021 22:34:31 -0700 (PDT) Message-ID: <75c84c0b-46b3-2600-c186-257aec05c645@ozlabs.ru> Date: Fri, 23 Jul 2021 15:34:25 +1000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.0 Subject: Re: [PATCH v5 10/11] powerpc/pseries/iommu: Make use of DDW for indirect mapping Content-Language: en-US To: Frederic Barrat , Leonardo Bras , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , David Gibson , kernel test robot , Nicolin Chen Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <20210716082755.428187-1-leobras.c@gmail.com> <20210716082755.428187-11-leobras.c@gmail.com> <8dfb28d5-b654-746c-03d8-aeee3d438240@ozlabs.ru> <994051df-73b3-4dad-76aa-1a03d9afaf6d@linux.ibm.com> From: Alexey Kardashevskiy In-Reply-To: <994051df-73b3-4dad-76aa-1a03d9afaf6d@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22/07/2021 01:04, Frederic Barrat wrote: > > > On 21/07/2021 05:32, Alexey Kardashevskiy wrote: >>>> +        struct iommu_table *newtbl; >>>> +        int i; >>>> + >>>> +        for (i = 0; i < ARRAY_SIZE(pci->phb->mem_resources); i++) { >>>> +            const unsigned long mask = IORESOURCE_MEM_64 | >>>> IORESOURCE_MEM; >>>> + >>>> +            /* Look for MMIO32 */ >>>> +            if ((pci->phb->mem_resources[i].flags & mask) == >>>> IORESOURCE_MEM) >>>> +                break; >>>> +        } >>>> + >>>> +        if (i == ARRAY_SIZE(pci->phb->mem_resources)) >>>> +            goto out_del_list; >>> >>> >>> So we exit and do nothing if there's no MMIO32 bar? >>> Isn't the intent just to figure out the MMIO32 area to reserve it >>> when init'ing the table? In which case we could default to 0,0 >>> >>> I'm actually not clear why we are reserving this area on pseries. >> >> >> >> If we do not reserve it, then the iommu code will allocate DMA pages >> from there and these addresses are MMIO32 from the kernel pov at >> least. I saw crashes when (I think) a device tried DMAing to the top >> 2GB of the bus space which happened to be a some other device's BAR. > > > hmmm... then figuring out the correct range needs more work. We could > have more than one MMIO32 bar. And they don't have to be adjacent. They all have to be within the MMIO32 window of a PHB and we reserve the entire window here. > I > don't see that we are reserving any range on the initial table though > (on pseries). True, we did not need to, as the hypervisor always took care of DMA and MMIO32 regions to not overlap. And in this series we do not (strictly speaking) need this either as phyp never allocates more than one window dynamically and that only window is always the second one starting from 0x800.0000.0000.0000. It is probably my mistake that KVM allows a new window to start from 0 - PAPR did not prohibit this explicitly. And for the KVM case, we do not need to remove the default window as KVM can pretty much always allocate as many TCE as the VM wants. But we still allow removing the default window and creating a huge one instead at 0x0 as this way we can allow 1:1 for every single PCI device even if it only allows 48 (or similar but less than 64bit) DMA. Hope this makes sense. Thanks, -- Alexey