Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1813744rdb; Wed, 31 Jan 2024 09:46:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IHraKOsxYWruqFSL13ShF6R3Xgc/ob/S3EpzopCSC1p8vmVWwjejSa/MDviY1UpuQ+bLcyQ X-Received: by 2002:a05:6359:100d:b0:176:71c3:80db with SMTP id ib13-20020a056359100d00b0017671c380dbmr2554594rwb.16.1706723178312; Wed, 31 Jan 2024 09:46:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706723178; cv=pass; d=google.com; s=arc-20160816; b=sWOrWFZL+XN4J/OLD1EpzxVM9wrAmrd9dBRSd5kTnpSdbynjD//f5DIXCJrHHNU6/1 r2o6y+al3Zwmhmq+HXNlEXYDgYVyaive8zcLSBvHn0JcFDG2UQWkZt7l34DH6L5SK7Tq KUzKSCz2xBqw0HqxapWPAy42CtTWd+rVZMSfqAnc0Xok1NgHaPS03mlKlTjiT8HAIFvN bPXbNf5wjV2evF7T8NulZH0mAI+R1dtmJ7SAQTbPh72Qdo81x72UHaZBFx8M0W+YgEzT kPyTtccd5iAru1tYDTa48YrzZhLeWOVlQ34t9Vejhwbqln7mof61ocby4jSPVw5aYvaX 5mjQ== 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=7DpgAkCvpe1xe0jkYm/SNIrdLeuAoxNEQGmV54R5akQ=; fh=rCgqJMNKJPUyIqTLZq5Iy/Dmnd2IGuj9IMeoO/xJXt4=; b=cUlkTQCggsqlK68qM1/UBbd9PcQ0Co/b5czy8+YYNrfBVpVZfSWXeRlLolphYk2DUG 6KqkV3X7RH7RLyaXVFl3kMjnG0O6SZAs1Ng1ekD8//cjl6dp2dmeaJ8exwRChtt5farO bSjSENEVsyKDj/UbShItX4WCSvYMP4B7kPdUMmv8+vKdThBGxEM2e79gy6GgeIMxEnlO t8WY0W9sVGG1vYHcw06VIt0lGAnZ/5o7ajsGb+dgjdQsPi+7LTicOtep5ovnJX2z+adR 8JNmJeGWHNgmXSsaRPgnd/gE9XMQghEx1It2b71JTA3iRHN3PT9WeqGXjVeYzHdNlgFA lt/g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BUOCBvaB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-46927-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46927-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCVnZh8N2AYhPjd2ei7Lp3CDC8OI6yyRpMQOAb2j4qLde+uWEBLtnL/AVm9T+o26aFVMcEwTXenkznq9EuAGjcs9UjvtzQNNL1cazPAl4w== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p23-20020aa78617000000b006ddcdca29d0si9994486pfn.256.2024.01.31.09.46.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 09:46:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46927-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BUOCBvaB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-46927-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46927-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 E1A7A28A462 for ; Wed, 31 Jan 2024 17:46:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87E1812DDB9; Wed, 31 Jan 2024 17:45:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BUOCBvaB" 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 AAB2512DDB0; Wed, 31 Jan 2024 17:45:22 +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=1706723122; cv=none; b=LQw/V/clVa5sHOvSn71+y8UaI9EfkHscZPkuqI0ibIPUbjrPP6W3ZfD2CVtDN9ipV5Pveo8yYMAsevW90n3JiAKgFmxCKsrtSgeH3mCJi7jJ1CGD/CfyszolR4+UWdvw79ngbsBZAn2IPtvsoWtpCC3/05io5p+RqpsgRduz2Nk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706723122; c=relaxed/simple; bh=nUArffftpYnAZbiHt8Ob1hqxWBT6f6uIQHVJHvysZIU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Qo9HJJU9UQt+7WtlShOCgSFLJabOcL0Z6AcDX2dmzbWGbRmOTXHJ8mNVfLYhfuZ6kPFwR0LbHZIZqranZtI3eFmxYtcuI/gIYKRLuPJ37aOCxqbRELPUureCAG5sAQBvizSX3ggFOnlrwt4ltUjKKZcUUTubIV39e4d7QkNQxlc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BUOCBvaB; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9217BC433C7; Wed, 31 Jan 2024 17:45:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706723122; bh=nUArffftpYnAZbiHt8Ob1hqxWBT6f6uIQHVJHvysZIU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BUOCBvaBD27KfHv4ciq855lq28+zJV4LoJW8XZ3mtqz19L6eGtrWN3r6HSNOhYWdv 5IzVpSVokqn8erbCNinc8v8n1HjHpIVvGkK3lSd+193zpXRwMydajVBfUqfI/RLIvz T3urWj2C8oqdcXd7kUMyMqxf7Cc7jqD5q+ANHCYcsQUTI55yfKPdeEoSsaXwiI2TuI jXeII+l+cK33jMFO7mpLuZKDpRIKGYYweFAjViuoeGWshMeOkcckMgYdKgVqAiM52x OaNcvEdT7JCFy72JbDN/wwJlxKz+nsRJvuT1f1JS20ms6DiTAs9VNGIaAOUCWcHwGv 31o6TLZ5w0oiw== Date: Wed, 31 Jan 2024 17:45:17 +0000 From: Will Deacon To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, iommu@lists.linux.dev, Christoph Hellwig , Marek Szyprowski , Robin Murphy , Petr Tesarik , Dexuan Cui Subject: Re: [PATCH v2 1/3] swiotlb: Fix allocation alignment requirement when searching slots Message-ID: <20240131174516.GA14943@willie-the-truck> References: <20240131122543.14791-1-will@kernel.org> <20240131122543.14791-2-will@kernel.org> 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: <20240131122543.14791-2-will@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) On Wed, Jan 31, 2024 at 12:25:41PM +0000, Will Deacon wrote: > @@ -1015,14 +1014,16 @@ static int swiotlb_search_pool_area(struct device *dev, struct io_tlb_pool *pool > index = area->index; > > for (slots_checked = 0; slots_checked < pool->area_nslabs; ) { > - slot_index = slot_base + index; > + phys_addr_t tlb_addr; > > - if (orig_addr && > - (slot_addr(tbl_dma_addr, slot_index) & > - iotlb_align_mask) != (orig_addr & iotlb_align_mask)) { > + slot_index = slot_base + index; > + tlb_addr = slot_addr(tbl_dma_addr, slot_index); > + > + if ((tlb_addr & alloc_align_mask) || > + (orig_addr && (tlb_addr & iotlb_align_mask) != > + (orig_addr & iotlb_align_mask))) { > index = wrap_area_index(pool, index + 1); > slots_checked++; > - continue; Bah, I accidentally dropped this 'continue' when addressing the review comments, so I'll add it back in v3. Will