Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3979797imu; Fri, 18 Jan 2019 23:18:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN5VuaohnmttGqSpgMuovfcWYx18uWwxjOric5sAw0/8AnyLqxIqM4eKHUHXht0837X+yqDl X-Received: by 2002:a63:7e1a:: with SMTP id z26mr20250007pgc.216.1547882300371; Fri, 18 Jan 2019 23:18:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547882300; cv=none; d=google.com; s=arc-20160816; b=FWfbPo2dtIWXpPwPUF7ds6k7HNDoGAsWhgseualrlkFcKbz3G5hGo5OQpAOLBgU8uq znT2BAbjS+8FRqBz1avGOaAwolYzBHuxKSVIworlK17HfwtyKcu+zQf4C7KiFZYtB3XM 4OQDkrH/KcYCzB7iwLxa9cHgO2TdE7rUT8U1qeBTJSbkqKTURh+q14UudaDcjkI2s0nw jiwWxhSLfZuB1lmaIkVfxOn4LDBirpG5RAIJ9LMmCj8DoxMkii6hsDZEOyYa3fUGKcuk dNo5yu2DmsirWyNBiCt+41bwRuM0eDIJkXYiJfNEr81QWeDeoMRgT0B+R7WCJYLb5CTf FPGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:mail-followup-to:reply-to:message-id:subject:to:from :date; bh=K7muGxWLC+as0Ps/LPlVCpjx56rRCs1E9OCFoQtoAG0=; b=m3M4uMWCgmcROu8m5RTDkFyYgu5tVeq7lJSKBq/zrjDUDDSBFCbW6yK5f+05fH3B++ N7EA/eOoEsY1wLTDUp3e8FIY5FUag31Kwx8IGtDqAljtnNUA+rNbppfMCBqUYSwaqILy 0lsWybPfa6HeoDsLN7jDC0uuS0p7MpfNmq0ITIC3NL+CHbxgvKxC/oexSOU7CZQ6oGOe MJNKICrvdrncr3mpiB66US+JQnB8J79gTcMZc2hPJK30ZZ4m3v9KRERTWshTjm+VWwiU +X7LWxYQ09as/tcqABMEoLJDKJtZVq3iCd/qryqJIFkeRd287Q78fTXf5ljMcWn+hCHC Ak3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m75si4921495pga.432.2019.01.18.23.18.01; Fri, 18 Jan 2019 23:18:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727567AbfASHQY (ORCPT + 99 others); Sat, 19 Jan 2019 02:16:24 -0500 Received: from mail-qt1-f181.google.com ([209.85.160.181]:44424 "EHLO mail-qt1-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727472AbfASHQX (ORCPT ); Sat, 19 Jan 2019 02:16:23 -0500 Received: by mail-qt1-f181.google.com with SMTP id n32so17764742qte.11 for ; Fri, 18 Jan 2019 23:16:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:reply-to :mail-followup-to:mime-version:content-disposition:user-agent; bh=K7muGxWLC+as0Ps/LPlVCpjx56rRCs1E9OCFoQtoAG0=; b=FwBIzyV5hodMmtubNsDy8dBwN5K22koD58Ve1EDdd+H978BF2eNWTYkZso7RSfoo9P ytzsuhTa8Ol1u+ZCvRWSsMUpRqalaPCSBuwsCuALCPKS5KZc0Pbt/JDydqWT4XHO3phK 4ZSYXa8Hk+K9xZiedkR61ayQvo7NuPWU/hXr0qvnVUnJnh3L8pXoAVgo8330lUA8XRO1 WmSu0BHhY0eM5GYCy09gXLfZH7ALDlhX1bWBqXatzyWqsA0NgmnCp5/tbXugsVeZpFs5 xNKV/7yVcRhvIRre5kqvkC2wXHaKj8SFOJbdjH8s9gH/L0d92OycyjzIouv56yxtq0ar UoyQ== X-Gm-Message-State: AJcUukc3w8RCBAEWRbavRdbnG+I3bN8DpgPIdIcuHBiyeKNwHPgTzXOy rnXQqVyL4yt0k2k4cgNaH3S5oeUSHTY= X-Received: by 2002:a0c:d992:: with SMTP id y18mr19075551qvj.161.1547882182936; Fri, 18 Jan 2019 23:16:22 -0800 (PST) Received: from localhost (ip72-223-3-97.ph.ph.cox.net. [72.223.3.97]) by smtp.gmail.com with ESMTPSA id 20sm66975101qtp.54.2019.01.18.23.16.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jan 2019 23:16:22 -0800 (PST) Date: Sat, 19 Jan 2019 00:16:21 -0700 From: Jerry Snitselaar To: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Joerg Roedel Subject: Question about out_unmap section of map_sg in amd_iommu.c Message-ID: <20190119071621.xh5s3rkqiabgjwo4@cantor> Reply-To: Jerry Snitselaar Mail-Followup-To: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Joerg Roedel MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org out_unmap: pr_err("%s: IOMMU mapping error in map_sg (io-pages: %d)\n", dev_name(dev), npages); for_each_sg(sglist, s, nelems, i) { int j, pages = iommu_num_pages(sg_phys(s), s->length, PAGE_SIZE); for (j = 0; j < pages; ++j) { unsigned long bus_addr; bus_addr = address + s->dma_address + (j << PAGE_SHIFT); iommu_unmap_page(domain, bus_addr, PAGE_SIZE); if (--mapped_pages) goto out_free_iova; Is this condition correct? My thought is this was meant to break out of the loop early if all the mapped pages have been unmapped. So if (--mapped == 0) instead? } }