Received: by 10.192.165.148 with SMTP id m20csp2539931imm; Sun, 22 Apr 2018 09:09:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/POOXU9A4+akxCd5EqO3Ebq8kHcUHxcUaFTewM7RfgFGw7/W9HYiLRSXHPZ3j49uUe4x4T X-Received: by 10.99.124.1 with SMTP id x1mr13944558pgc.286.1524413347971; Sun, 22 Apr 2018 09:09:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524413347; cv=none; d=google.com; s=arc-20160816; b=u20WBIwndvHiXp3mbnITcAHx9KeOda6R55XUZfscApCCKQ7S3rdq+wH9Y8n2ypRaON kI69hCSKhqfT93w40SWYNZV+6uj3G6UXBAejvKM4EVhRQerJknuEYkrVsKbXDE4c1lsR QmI2QYqDu8r6NAV5zPJ8lYZGMNAbjUsBr8AqIMUXG36eCBhtsqDrCrJ3o+bUQDE+m2Xg 11muK+2LWgXGaY+6wMtQfpy0viZeSw/RCZFJRf8eUqJqGhTyLg/dgvC4DQ6EYqM5zm2k /jaC+UW2CDuUtsbirMcKF9bBPKo9lhtZt+b7E7STDW1mJ85x20GfdO6bjATD7eHj1y28 lOZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=/61b+6Y52gSAIDyrFrh/xs5F5Zef5NOIaJkRbdoXHf4=; b=S7aS51Qk81pD3F4rOMcHMGkFCJl5rwzbxLKbtFXa2DUro9csJO6gyEUrhPc18+cjQc VfFyCAywOoQMlLtVf9snzSr8pNb+MNoEICYpPozRAMwl2l23Rr1AChi190ybgFMthFmQ pRA7dIN9t/Q7cNPF/3YMxrTAdXXpdE9UMM9tkPYH+QeMNXOvIz9ZSDeopWGUkdmX7mUY HqFlKFT5Gi3xC/2Fa4gXyFH0WFha9u4d/Op2WQ3Yy5Z5kHZaz18ofxM2Ka5JW1vBlBBf lRCqtT5cvV9osaaSwnT66dVd7ovEAEXhfsuNFZLh1/V3uElgNnDhvAI6suAPpRV/bkQL YVBA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si7419423pfm.226.2018.04.22.09.08.53; Sun, 22 Apr 2018 09:09:07 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753971AbeDVQH6 (ORCPT + 99 others); Sun, 22 Apr 2018 12:07:58 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45424 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753794AbeDVN4y (ORCPT ); Sun, 22 Apr 2018 09:56:54 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 02B35C64; Sun, 22 Apr 2018 13:56:52 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai , Christoph Hellwig , Jean Delvare Subject: [PATCH 4.16 058/196] swiotlb: fix unexpected swiotlb_alloc_coherent failures Date: Sun, 22 Apr 2018 15:51:18 +0200 Message-Id: <20180422135107.210672134@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Takashi Iwai commit 9e7f06c8beee304ee21b791653fefcd713f48b9a upstream. The code refactoring by commit 0176adb00406 ("swiotlb: refactor coherent buffer allocation") made swiotlb_alloc_buffer almost always failing due to a thinko: namely, the function evaluates the dma_coherent_ok call incorrectly and dealing as if it's invalid. This ends up with weird errors like iwlwifi probe failure or amdgpu screen flickering. This patch corrects the logic error. Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1088658 Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1088902 Fixes: 0176adb00406 ("swiotlb: refactor coherent buffer allocation") Cc: # v4.16+ Signed-off-by: Takashi Iwai Signed-off-by: Christoph Hellwig Cc: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- lib/swiotlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/lib/swiotlb.c +++ b/lib/swiotlb.c @@ -732,7 +732,7 @@ swiotlb_alloc_buffer(struct device *dev, goto out_warn; *dma_handle = swiotlb_phys_to_dma(dev, phys_addr); - if (dma_coherent_ok(dev, *dma_handle, size)) + if (!dma_coherent_ok(dev, *dma_handle, size)) goto out_unmap; memset(phys_to_virt(phys_addr), 0, size);