Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp696254rdh; Wed, 14 Feb 2024 08:44:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXuxAVQJvd13V+RZ768+LaOt1OXu0BW8PTs3+Vjtu7Tsx4ZS1wnK9rA3vHXpQ1KkyCtvgyVOwNR2efx8J4FhzkEQ9lcDlzWPpm+7CLEfA== X-Google-Smtp-Source: AGHT+IFY2UuUsCo+2ubDlc872Kt+S8Th7rGAnizrPoFb6wxOVoUJKqFpZn8QqSk+xa7Dx0B/SuRA X-Received: by 2002:a17:902:ab8f:b0:1db:2ad9:9393 with SMTP id f15-20020a170902ab8f00b001db2ad99393mr2664524plr.48.1707929048059; Wed, 14 Feb 2024 08:44:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707929048; cv=pass; d=google.com; s=arc-20160816; b=hhl8UF4BvE3yEK8wcacFWN22CoSlo0XBTWBFM051TMhYwtHAFhpYQ6ovtB42dGo+bS szqcnEq/oWdKZbUusr6vYhcu50lg3UOaNYGK++5eZ1oRUxd63cTS4PzydzvNv13Hxl7A 24R+JH8QnbYAwl+YA+jnRmUtD9dBDPDnT1LmcH92X0WMIwkZqXLmSxMQxRrJqqCeYJOS xRkpxsC2S6P9cc40Nwa7D001vfxz40qYxRaPZKvhmauRAM3vakd2gLXRecBOO/ruQwG3 Y3cYE3qCxVLWMcuy1bt5sB73LMRpJCkMvOUKJoR4E/G1btWAjBkCiS/bB5gkRDqETiHV 6cHQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=R0ADXAcnx55rHzVKxCSUweqUJ0IxcRwiblhtNC8mXI8=; fh=qms/Rte41LB2ctAw008VsDfvOW3LbDTLcCNKEUBcNYY=; b=jH1tkR7vQ0mE8c6+BAK20AQ50f3yHi9urBkzigh1Ju6KxR/YHR06LFO2p0oyx6WlhX XOx+Y0LdX5AuW2ObELuHlopxKYGsIBGNv5nwpi9NZj/WFpkfqKEnOXMk6wPu5ndcya3a vZs+r6rfxVEetVu5jP3HmlSJXuxIfZw58Ew30/Mknn5HuwN3na5tFnAYq+/Pin2YamVr vsG/9xq0MLrsaOsj+JPLxnwP+0gaoqicAunW7t+oizwQkbU6MjsNc17rrbm9dcopVkJa 3siW8DON00YVsq5T1YGGPhNNkqp972M/G8qv1ySxR9pBAiKe6g8SmQTtFX6Qq1izo1gw sLvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="oP/9iHXz"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-65569-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65569-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCWUt0FDTvbD4YlU5RnWnt0LuC8ViWSzrxPLBqYwiVOmXupmcotwboNkRs54bcUXAhB+c6+M0oq5WCK0mH5NPLDn/yRtdRP7csqvgSHKoA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z6-20020a170902ccc600b001db546820d4si1671506ple.8.2024.02.14.08.44.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 08:44:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65569-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="oP/9iHXz"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-65569-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65569-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E1E53283743 for ; Wed, 14 Feb 2024 16:42:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DAEE422612; Wed, 14 Feb 2024 16:41:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oP/9iHXz" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C07E5D49C; Wed, 14 Feb 2024 16:41:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707928905; cv=none; b=MGvp0+/UjriwVqs+LwEpkwIYBAayqOUMLBgKQDhuWQreCA50H1udcSNgfOY+GqDOtk0vs8gjuTfMWR/O1XcVU5KE/rlEkfs5ovZtAYKga6s5d6Dnkqaw6dv9b74BXVZ+hHWUpsQREtK9vG/pBV64BedqcRFpWOb+k7LbpWs6RIU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707928905; c=relaxed/simple; bh=rtzaQewjWyFqgXvX8Cpq/QwLjOpb1280iFp5zLTTWx8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZvngrQ0FvQ97ZLUoDE3506VHDXeinLbxC0HZniH1IEC65CLr1BOWXLbowHWdXopZJj08GW3aDdf94WFaiFC7SmL9scwwvOK0NPnhgQg3IeeO1Iey3XB2iTKPvLxC86HCmWijKsl915NjpcTMVJjr4JQfhzcGSjRsIvE0Gs3iK8k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oP/9iHXz; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14B19C433F1; Wed, 14 Feb 2024 16:41:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707928904; bh=rtzaQewjWyFqgXvX8Cpq/QwLjOpb1280iFp5zLTTWx8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oP/9iHXzZ4W3ZkEIKY9irpzbod0eFARuDjHbe93lj1nSEHbUYvXg3uHTnMtH9Jkmt SuqEPiKzPsRKrc5m74cY32AfDw/qAVaFGETVY32JqsFWgRSR5RvlcF0t1HdI+GtK3f x7Ye1fDwGN5Zfei+HU++QCasgmImmcKpwQHy6MC660hAUJZxnILvlV4RFM0QLgt23B 7/MSUOriFsS4NiTahlVGWkpfjqfgxTAnimulbm1unYOY2l/Zum4l+1qVgQG/9qVV6w y1Iu8twIAaK4onCIbUsBWRJCER2TwLsWCJSJCFsh8Bk0OtJHI7HhALtsWjs3Dx7xQN XKys4GJgd5Tmw== Date: Wed, 14 Feb 2024 16:41:38 +0000 From: Will Deacon To: Nicolin Chen Cc: sagi@grimberg.me, hch@lst.de, axboe@kernel.dk, kbusch@kernel.org, joro@8bytes.org, robin.murphy@arm.com, jgg@nvidia.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, murphyt7@tcd.ie, baolu.lu@linux.intel.com Subject: Re: [PATCH v1 0/2] nvme-pci: Fix dma-iommu mapping failures when PAGE_SIZE=64KB Message-ID: <20240214164138.GA31927@willie-the-truck> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Hi Nicolin, On Tue, Feb 13, 2024 at 01:53:55PM -0800, Nicolin Chen wrote: > It's observed that an NVME device is causing timeouts when Ubuntu boots > with a kernel configured with PAGE_SIZE=64KB due to failures in swiotlb: > systemd[1]: Started Journal Service. > => nvme 0000:00:01.0: swiotlb buffer is full (sz: 327680 bytes), total 32768 (slots), used 32 (slots) > note: journal-offline[392] exited with irqs disabled > note: journal-offline[392] exited with preempt_count 1 > > An NVME device under a PCIe bus can be behind an IOMMU, so dma mappings > going through dma-iommu might be also redirected to swiotlb allocations. > Similar to dma_direct_max_mapping_size(), dma-iommu should implement its > dma_map_ops->max_mapping_size to return swiotlb_max_mapping_size() too. > > Though an iommu_dma_max_mapping_size() is a must, it alone can't fix the > issue. The swiotlb_max_mapping_size() returns 252KB, calculated from the > default pool 256KB subtracted by min_align_mask NVME_CTRL_PAGE_SIZE=4KB, > while dma-iommu can roundup a 252KB mapping to 256KB at its "alloc_size" > when PAGE_SIZE=64KB via iova->granule that is often set to PAGE_SIZE. So > this mismatch between NVME_CTRL_PAGE_SIZE=4KB and PAGE_SIZE=64KB results > in a similar failure, though its signature has a fixed size "256KB": > systemd[1]: Started Journal Service. > => nvme 0000:00:01.0: swiotlb buffer is full (sz: 262144 bytes), total 32768 (slots), used 128 (slots) > note: journal-offline[392] exited with irqs disabled > note: journal-offline[392] exited with preempt_count 1 > > Both failures above occur to NVME behind IOMMU when PAGE_SIZE=64KB. They > were likely introduced for the security feature by: > commit 82612d66d51d ("iommu: Allow the dma-iommu api to use bounce buffers"), > > So, this series bundles two fixes together against that. They should be > taken at the same time to entirely fix the mapping failures. It's a bit of a shot in the dark, but I've got a pending fix to some of the alignment handling in swiotlb. It would be interesting to know if patch 1 has any impact at all on your NVME allocations: https://lore.kernel.org/r/20240205190127.20685-1-will@kernel.org Cheers, Will