Received: by 10.223.164.202 with SMTP id h10csp2596644wrb; Sun, 12 Nov 2017 13:19:29 -0800 (PST) X-Google-Smtp-Source: AGs4zMaJCJD1vLVeTyBFvzR+jTaxMSo9cSPC1gQnGLUGze5fmvsutQKuPXSiK7fuf8UFQgm95s5C X-Received: by 10.84.244.193 with SMTP id f1mr7079186plt.32.1510521569579; Sun, 12 Nov 2017 13:19:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510521569; cv=none; d=google.com; s=arc-20160816; b=fcxicTskuDsJ1l6kisaS0G82XX5qZXKSaGFOvFG5e944wbYFCm5jB7KHZy398XjNqx AT7Tji3MMvmU1rQ1brGapB71PgvciTUW5hkKNQMB86W8Aik/YqajGvLnILxaw8YzLfBm ZjFvhZe+PsCOZJH1EZda+M1CiwVp35/ttvNapW+f2KRCGi4fxB/ej0Mbx22ySUvKX0Rc qa8tWYtL+yol8vMbymIkiAKPnc+K/5qo0W3kcGgXUMUobbNDqSxDnorS5eR0fvz8wQ/X xRjaq2iC2TM1Dj0fDmkFyr6b9jGdkFhrVL7tQysPE7qlnO6sTNHco8l/y7ZsB0Tr+gUS nPwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=DSqddbLpMz6Pw4LhSxH4uVDz8m+8G5tbXEwVU/7XhMw=; b=u9bj5UW+hE8p1+9l7k8q21g9OJHX61y1Kp5VZu0WzcfmVn75RUS5npne2pRDU32FbF UzP9/qjPLRAssZ7j6Bx+zZgiCle1ZwhlpV+mxSm9ZBvkhobnhQi3sjJVQgbiTjfS3yX9 aYaLDcb0uGmRsA3ZcGnqJ3b7yyF95HYAb7TGGop+AYngpYSYXUaqdmZH9B5Qie1r60y+ DTBDSmf2tZFd3BdoVcthfZPIerP4P+KG+J+MUg2AcZcP+Zx3zG1m3B4vGhu34gvNiUuS 6oSZIEllnlEhNvsic9foZb22Z4UgLEkFGgHjyBkrDoe+hDS2RL65GmESZ/fd4xKQJsYK rt+A== 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 x66si14091828pfa.129.2017.11.12.13.19.17; Sun, 12 Nov 2017 13:19:29 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751274AbdKLVQt (ORCPT + 87 others); Sun, 12 Nov 2017 16:16:49 -0500 Received: from einhorn.in-berlin.de ([192.109.42.8]:60985 "EHLO einhorn-mail.in-berlin.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750960AbdKLVQr (ORCPT ); Sun, 12 Nov 2017 16:16:47 -0500 X-Greylist: delayed 636 seconds by postgrey-1.27 at vger.kernel.org; Sun, 12 Nov 2017 16:16:47 EST X-Envelope-From: stefanr@s5r6.in-berlin.de Received: from kant ([83.221.231.133]) (authenticated bits=0) by einhorn.in-berlin.de (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id vACL5T6O027727 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 12 Nov 2017 22:05:35 +0100 Date: Sun, 12 Nov 2017 22:05:29 +0100 From: Stefan Richter To: Hector Martin , Clemens Ladisch Cc: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH] firewire-ohci: work around oversized DMA reads on JMicron controllers Message-ID: <20171112220529.4cf6c5b5@kant> In-Reply-To: <554bac12-e021-2541-6812-ae9a4e0c96ba@ladisch.de> References: <20171103112857.12426-1-marcan@marcan.st> <554bac12-e021-2541-6812-ae9a4e0c96ba@ladisch.de> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Nov 03 Clemens Ladisch wrote: > Hector Martin wrote: > > At least some JMicron controllers issue buggy oversized DMA reads when > > fetching context descriptors, always fetching 0x20 bytes at once for > > descriptors which are only 0x10 bytes long. This is often harmless, but > > can cause page faults on modern systems with IOMMUs: > > > > DMAR: [DMA Read] Request device [05:00.0] fault addr fff56000 [fault reason 06] PTE Read access is not set > > firewire_ohci 0000:05:00.0: DMA context IT0 has stopped, error code: evt_descriptor_read > > > > This works around the problem by always leaving 0x10 padding bytes at > > the end of descriptor buffer pages, which should be harmless to do > > unconditionally for controllers in case others have the same behavior. > > > > Signed-off-by: Hector Martin > > Reviewed-by: Clemens Ladisch Thanks Hector for the troubleshooting and for the patch. Thanks Clemens for the review. It's been a while since I last reviewed and tested kernel patches, and also my main FireWire equipped PC is currently tied up in work for which reboots aren't desirable. But I am updating a long unused secondary FireWire'd PC right now and give the patch some testing this week. (This one even has a JMicron controller, but not an IOMMU.) > > --- > > drivers/firewire/ohci.c | 8 +++++++- > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c > > index 8bf89267dc25..d731b413cb2c 100644 > > --- a/drivers/firewire/ohci.c > > +++ b/drivers/firewire/ohci.c > > @@ -1130,7 +1130,13 @@ static int context_add_buffer(struct context *ctx) > > return -ENOMEM; > > > > offset = (void *)&desc->buffer - (void *)desc; > > - desc->buffer_size = PAGE_SIZE - offset; > > + /* > > + * Some controllers, like JMicron ones, always issue 0x20-byte DMA reads > > + * for descriptors, even 0x10-byte ones. This can cause page faults when > > + * an IOMMU is in use and the oversized read crosses a page boundary. > > + * Work around this by always leaving at least 0x10 bytes of padding. > > + */ > > + desc->buffer_size = PAGE_SIZE - offset - 0x10; > > desc->buffer_bus = bus_addr + offset; > > desc->used = 0; > > -- Stefan Richter -======----= =-== -==-- http://arcgraph.de/sr/ From 1583055054455622226@xxx Fri Nov 03 14:22:26 +0000 2017 X-GM-THRID: 1583044637121646388 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread