Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp429862img; Tue, 26 Feb 2019 02:37:17 -0800 (PST) X-Google-Smtp-Source: AHgI3IaxJhGWR89dXLBmhkMM1VAY6Kg4tlZrTpckSLFH9iGbk2mbcrEgUpl3HPnnKsjZGCU2ocMp X-Received: by 2002:a17:902:b709:: with SMTP id d9mr25569246pls.83.1551177437564; Tue, 26 Feb 2019 02:37:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551177437; cv=none; d=google.com; s=arc-20160816; b=qZOwYDQv2ojoVl4CVke2Y8/gFEk/6OEtE7juEvdvg6MO4ng2Xucgr3yC7NaX2ttJ1o atFv8d1rbxeLOyZUiYeJHQquB8/kW9Uu9/00eImNcmRRGfvM1Rbd6v+Vp2lcotj32lsI 06IBr1Buktnv1y0ZguV6bU7a5ISK3Vy47jHcFLjfVxDqzqiL81P1dNKQKLLQJpUiMOk2 A825uGtaCm+mLp1MfE289pngoYp+exmP2WmIqis6MCmQjJQWaPuIBS3vdNSwXzr0v83R 5S7Gf1CHlQu8Jldbm34EXajp4y0tJIqxyWAVRjpQwqRjy2AeUkC/KGk+vsVbeB4guuI+ yDEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=cOTW8aT+Bj/W+hTXEANTEqmQIrEjzR7jCMd6mx3Gir8=; b=xJU/IHe+bOHd8hWf9s9IhSNFzCm7PoFsYNJMtcC8KN9Eupl6P8AZ+n5EmcLcJ3G7gw 5CVOXdyKFNyrQMWoKKJUFNaPijAqNnQgH948WoDNfdzKhakvYkMSe6JQ0dDiIqE117Il bf3s/Tl9xh8V8B3KCTF0lVdpWdpEUpSnL8aF4WoMNJzlIZa+vjB13pnztJFNCTdz0enT t0B27t1k24FAT31VB4Rrvj9YhExXy642SNEiZfhciJHGg1NCmT4w7d14HT/WzA/TJNAM GKn4fgVDli/uHg31wKR4vT5ZmG/G6Nw3Oa7eoY9qej6pFOdOapVmV587OqPD2RDYMlpK 3ERw== 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 a1si183110pgl.266.2019.02.26.02.37.02; Tue, 26 Feb 2019 02:37:17 -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 S1727588AbfBZKe4 (ORCPT + 99 others); Tue, 26 Feb 2019 05:34:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51962 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725908AbfBZKe4 (ORCPT ); Tue, 26 Feb 2019 05:34:56 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E9E8670D6C; Tue, 26 Feb 2019 10:34:55 +0000 (UTC) Received: from localhost (unknown [10.40.205.183]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E5125D6AA; Tue, 26 Feb 2019 10:34:52 +0000 (UTC) Date: Tue, 26 Feb 2019 11:34:51 +0100 From: Stanislaw Gruszka To: Joerg Roedel Cc: Lorenzo Bianconi , Rosen Penev , linux-wireless , Samuel Sieb , Alexander Duyck , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: MT76x2U crashes XHCI driver on AMD Ryzen system Message-ID: <20190226103450.GA2989@redhat.com> References: <83A1D243-9073-48D1-9F26-5A2581DCB829@gmail.com> <1547404075.1582.0@smtp.gmail.com> <20190114091841.GA23045@localhost.localdomain> <20190115090400.GA2267@localhost.localdomain> <20190218143742.GA11872@redhat.com> <20190226100535.GA20740@8bytes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190226100535.GA20740@8bytes.org> User-Agent: Mutt/1.8.3 (2017-05-23) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 26 Feb 2019 10:34:56 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 26, 2019 at 11:05:36AM +0100, Joerg Roedel wrote: > On Mon, Feb 18, 2019 at 03:37:48PM +0100, Stanislaw Gruszka wrote: > > 0001-mt76x02u-use-usb_bulk_msg-to-upload-firmware.patch > > 0002-mt76usb-do-not-use-compound-head-page-for-SG-I-O.patch > > > > Or problem can be solved by just one of it (either first or second). > > > > Additionally I'm not 100% sure if > > > > 0002-mt76usb-do-not-use-compound-head-page-for-SG-I-O.patch > > > > is correct. So perhaps some IOMMU maintainer could look at it. > > The patch looks good, but I don't understand why it is needed. The AMD > IOMMU driver should handle sg->offset > PAGE_SIZE just fine. Can you > verify that this is the problem? I will look into that again if it turns > out there is bug in the IOMMU driver. I'm try to get that information from bug reporter, but I can't get it so far. If sg->offset > PAGE_SIZE is fine then most likely we have problem with alignment. We use page_frag_alloc() in mt76usb for buffer allocation in scheme like this page_frag_alloc(max_payload); // something like 14434 page_frag_alloc(1024); page_frag_alloc(2048) page_frag_alloc(2048) page_frag_alloc(2048) ... page_frag_alloc works smart and fast way internally by allocating fragments just but changing internal offset: offset = nc->offset - fragsz; if (unlikely(offset < 0)) { page = virt_to_page(nc->va); . . . } nc->offset = offset; return nc->va + offset; but unlike other allocators like kmalloc that make effort to provide ARCH_DMA_MINALIGN buffers, it does not care about alignment. Above scheme of allocation in mt76usb breaks it. Note hat issue is with dma_map_sg(), switching to dma_map_single() by using urb->transfer_buffer instead of urb->sg make things work on AMD IOMMU. Stanislaw