From patchwork Wed Feb 28 13:39:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 207874 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3360920dyb; Wed, 28 Feb 2024 05:59:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWQXOJmRKrN1+O2Bfi0EnCGF4wy8RiuLUvA8Ibw84qwKY1rQBPeRsPiB5eKiofngm4Q2crXWUkdLCwQ8F4L2Lz99iNFeQ== X-Google-Smtp-Source: AGHT+IEsKGnyJcyVSYAazxWCFaUHQJEQ0LO29JGFAQx8/WwrnGFLv9RaFE0sDc8aSAj7+goB0bFy X-Received: by 2002:a05:6a21:3511:b0:1a0:fea5:8405 with SMTP id zc17-20020a056a21351100b001a0fea58405mr5359637pzb.41.1709128794189; Wed, 28 Feb 2024 05:59:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709128794; cv=pass; d=google.com; s=arc-20160816; b=yAtHcQ9GaPXVAxJVRYaKLRMUx7NmoU2Y3FyhE3XeISDkiNGX/qPxQHmzjp40L81Tb0 0JlDW1bk2JZ2o6uxiWbKoiqNQZ2Aur/SO+l5uH+aOXVr5CyDSEZ3/lfQ5NGvZ9PHfDNp sH2l1m1GcX66OgYB7ZF0LNdqRcqdVsWZrLGJOE96La4rEp1y2FBR2W6zeQsdcB3jNrgw 7sAfNwdf3d/ZwwAlketyvVQkn0pcLt+Q0GajrXPwdFoYkHUG2KDCHDIw/TrH2CALmazH W8Ro+Jvmk/dLW5PrGw/xym2UDo9rRBcS67g18X3eMBZY03TP0HYtAs7cUmquUFfO3x0n 1lxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=yKJtWXMUUZDiSXU7ORRKFKfyXQXAcRzYJs0Ixf4Gg2s=; fh=E8F5/vp/nAcPVJWJwVt5RE8c2HME7kVqVeSMFxe8huE=; b=vadzZl2ZOWNxYi0Jf5C43YZ+SzSViE9sC0/bLBMmYfCvUYw0LQkZ+hy7j6lWm8ahPD GkE7F1xjfjVL3DuAx2eYaf/0V19Ahqfda1b+22n4byRWZevB6Wafky63NEfAdxpX2fsc I7KRelSSxG//fa/e+AiTkBuaXWYc6FHB/bTfvSlIBBoJp+R/9IMSso6b52pgo1ZHjZ+1 T5lFVoD7rFKzXJQESNAlPIqgeQPQKaebaE+gjGDVuAaJwBna6m+MPJLjbaBqWtZ3CF7E RUFP486517aKKS+sBIik9LfRk1rrzBtcKknZY2g3ka7/aimUfgX6DqZh55t+UjHHoATl jnxQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZHQNrkmE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85115-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85115-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e5-20020a656885000000b005d8c55d9669si7430035pgt.366.2024.02.28.05.59.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 05:59:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85115-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZHQNrkmE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85115-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85115-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id F0EE2B27A4C for ; Wed, 28 Feb 2024 13:41:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 76CF9159580; Wed, 28 Feb 2024 13:39:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZHQNrkmE" 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 BA2AF158D83; Wed, 28 Feb 2024 13:39:52 +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=1709127592; cv=none; b=CWtVK5q5VSgRtIiypKjQwA/UYgbBrKEFYF/4eRiuSxYNkjDqmpzUXHQrVdQsAi/BvehnYecJKXgNFkSfUFaukmEa2ZsYJ6Qe5s5HbHBj4aWIUPyKxq22Jf6q9l9agcsxk8jMqp5VB5JyU+ekSa2y3zFgM7wfMtmbDuy3rhpst6U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709127592; c=relaxed/simple; bh=aD3tZMex9G2YUndtdrq37+tQDE+4+Pl1DCirhnA679E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jTA7KXf2yOI5fF1qjcRs65BuzpXmMpJHT0EAtlB1vci3rlaoQdswlacdQScfCeU0FTUEJOPqwzcsJgFTPPAmv5JJ9WIakXQcMFh4DQJpifhNNZ6k8VhtvRtpovD7ypn69WsJO6G84xYwQGYJDJbKQ94n5E3DPQjFSWqLb2KCKZ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZHQNrkmE; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2895CC433A6; Wed, 28 Feb 2024 13:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709127592; bh=aD3tZMex9G2YUndtdrq37+tQDE+4+Pl1DCirhnA679E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZHQNrkmEgy12WEFe8Jv/6qBhkOgpWG2e1degZiyvn0LRnsKBkD8hP4JCuu/CpirRZ E5WF8pyyGcE2r60DIS5WmAChmo8/4oGap1B0RpdsQBkyekKbiqQXkgZisyOndf5F1I CslGRSqiwlNv/3k8HP/jQ3oEozzZ9SRJVXLmjraro47W5uHsqGvgl5iwzEv+p8g86Y SuAOP/Yv0HD5yJun+tFlSvNzuxnwf9mQzayPmRpn9BwYrwTDEu+aLsLwpQoYNHbO3W VugD2V8V/AXwfyavEVwlfOy6PrZtVkypRCqeIldUmtlJVwuBTG8baksKhrDOgEV83W grPbgFR7fX4bQ== From: Will Deacon To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, Will Deacon , iommu@lists.linux.dev, Christoph Hellwig , Marek Szyprowski , Robin Murphy , Petr Tesarik , Dexuan Cui , Nicolin Chen , Michael Kelley Subject: [PATCH v5 6/6] swiotlb: Remove pointless stride adjustment for allocations >= PAGE_SIZE Date: Wed, 28 Feb 2024 13:39:30 +0000 Message-Id: <20240228133930.15400-7-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240228133930.15400-1-will@kernel.org> References: <20240228133930.15400-1-will@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792151434552043947 X-GMAIL-MSGID: 1792151434552043947 For swiotlb allocations >= PAGE_SIZE, the slab search historically adjusted the stride to avoid checking unaligned slots. However, this is no longer needed now that the code around it has evolved and the stride is calculated from the required alignment. Either 'alloc_align_mask' is used to specify the allocation alignment or the DMA 'min_align_mask' is used to align the allocation with 'orig_addr'. At least one of these masks is always non-zero. In light of that, remove the redundant (and slightly confusing) check. Link: https://lore.kernel.org/r/SN6PR02MB4157089980E6FC58D5557BCED4572@SN6PR02MB4157.namprd02.prod.outlook.com Reported-by: Michael Kelley Signed-off-by: Will Deacon --- kernel/dma/swiotlb.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index c381a7ed718f..0d8805569f5e 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -1006,13 +1006,6 @@ static int swiotlb_search_pool_area(struct device *dev, struct io_tlb_pool *pool */ stride = get_max_slots(max(alloc_align_mask, iotlb_align_mask)); - /* - * For allocations of PAGE_SIZE or larger only look for page aligned - * allocations. - */ - if (alloc_size >= PAGE_SIZE) - stride = umax(stride, PAGE_SHIFT - IO_TLB_SHIFT + 1); - spin_lock_irqsave(&area->lock, flags); if (unlikely(nslots > pool->area_nslabs - area->used)) goto not_found;