Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5298611ybi; Tue, 11 Jun 2019 23:44:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqzx3dth0AanIhgyFaEtcHuQnvGpTZEVm7JzyvugeBKUVhaJC2hAfuwCJ6pJDjwTg+wlIO76 X-Received: by 2002:a63:4104:: with SMTP id o4mr24562388pga.345.1560321871342; Tue, 11 Jun 2019 23:44:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560321871; cv=none; d=google.com; s=arc-20160816; b=VJksXZyQYbyFKLecMZXzYPv/d9bABCl8Zlvt/kKjnbgJCaLedrsvvp8vWQLubCS5sN JcH+DwyLrX5aTq3yOvwY4rF1ctgM2HvmexVJihbkh98I6Jlz7cDkKWsqVNHGp9iFn9QZ gcocRzN1kFmFZbIPWgrpwP9sJRKMobJ8oyBA2Vo3h9TuI/cuS69jRPFzbxmsTLvzgIIf vxIVe+2Nst8HcOtw434FpZfT5udxvlpv1GBBe7yVjWFr5pkWQolwPFROADG225HZz8T0 dHZM7i78SUb8I+6PccXXZx3YKlCBjoR66GHB98898/kXyuwx0lG8+eTM/TVsTa5JlcdE qTpg== 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:date:cc:to:from:subject:message-id; bh=2GAORxYUwheknrduVsiCadK9MmaPI9XAQcvYot571Xs=; b=UKpxkZ9qwq4UPxnB8OX7uG28cWlqAN1GC+IdS0z21u92DCCXATL8yGkxt9CVcAdcV5 3cgB/nm+4rQ1H+9in8SyqvlFXBaA00NrxKXV1dMLATSeuvCgeEUk0MRV3X7nYj4iZIx3 3c3993pPtVIXnaS7GJLN1iMAkYwY25FrvFHIG49lpYVmM4IfxyPW6u/e1cJu+V2Gimus h7fBhSm3QevtnhVdOgKzAFY5bKe/IUmKBQPgBIyF2fpSrr1gfExaU6vd/3wR7Z22NEAD O5VSMSVp5ESZYOgVKQ8TndI5w7iVekp9h+XYQwMrlxDSWPhmg2hmKzRWFegm7LS+00Uy piwQ== 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 23si4872945pjx.87.2019.06.11.23.43.47; Tue, 11 Jun 2019 23:44:31 -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 S2407353AbfFKWx0 (ORCPT + 99 others); Tue, 11 Jun 2019 18:53:26 -0400 Received: from gate.crashing.org ([63.228.1.57]:33554 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404048AbfFKWx0 (ORCPT ); Tue, 11 Jun 2019 18:53:26 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id x5BMr72S021573; Tue, 11 Jun 2019 17:53:08 -0500 Message-ID: Subject: Re: [PATCH v2 8/8] habanalabs: enable 64-bit DMA mask in POWER9 From: Benjamin Herrenschmidt To: Oded Gabbay , Greg KH , linuxppc-dev@ozlabs.org, Christoph Hellwig Cc: "Linux-Kernel@Vger. Kernel. Org" , Oliver OHalloran , Russell Currey Date: Wed, 12 Jun 2019 08:53:07 +1000 In-Reply-To: References: <20190611092144.11194-1-oded.gabbay@gmail.com> <20190611095857.GB24058@kroah.com> <20190611151753.GA11404@infradead.org> <20190611152655.GA3972@kroah.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2019-06-11 at 20:22 +0300, Oded Gabbay wrote: > > > So, to summarize: > > If I call pci_set_dma_mask with 48, then it fails on POWER9. However, > > in runtime, I don't know if its POWER9 or not, so upon failure I will > > call it again with 32, which makes our device pretty much unusable. > > If I call pci_set_dma_mask with 64, and do the dedicated configuration > > in Goya's PCIe controller, then it won't work on x86-64, because bit > > 59 will be set and the host won't like it (I checked it). In addition, > > I might get addresses above 50 bits, which my device can't generate. > > > > I hope this makes things more clear. Now, please explain to me how I > > can call pci_set_dma_mask without any regard to whether I run on > > x86-64 or POWER9, considering what I wrote above ? > > > > Thanks, > > Oded > > Adding ppc mailing list. You can't. Your device is broken. Devices that don't support DMAing to the full 64-bit deserve to be added to the trash pile. As a result, getting it to work will require hacks. Some GPUs have similar issues and require similar hacks, it's unfortunate. Added a couple of guys on CC who might be able to help get those hacks right. It's still very fishy .. the idea is to detect the case where setting a 64-bit mask will give your system memory mapped at a fixed high address (1 << 59 in our case) and program that in your chip in the "Fixed high bits" register that you seem to have (also make sure it doesn't affect MSIs or it will break them). This will only work as long as all of the system memory can be addressed at an offset from that fixed address that itself fits your device addressing capabilities (50 bits in this case). It may or may not be the case but there's no way to check since the DMA mask logic won't really apply. You might want to consider fixing your HW in the next iteration... This is going to bite you when x86 increases the max physical memory for example, or on other architectures. Cheers, Ben.