Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4227074imj; Tue, 12 Feb 2019 12:02:41 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ42zJU5PtkbhPlUfkRGRndsrdvN1sEmZM/DOEqGIQsm6y7JsC1t4D6Db1cAcEPevTcEzcq X-Received: by 2002:a62:a1a:: with SMTP id s26mr5616983pfi.31.1550001761303; Tue, 12 Feb 2019 12:02:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550001761; cv=none; d=google.com; s=arc-20160816; b=BPi3Pn6w9P9HmfDzQ1Ojh02xkvO2raqrAiQT71Sq3giOLHM+3MZo7Si6Mwl8Nyl0a0 1NxTN8W5lgNBWndBnHyNGzNLUCB1BlZM9fB4alUAKl1WxbPv2FvaF4MZwf7Jlxsj4vou GAEzd53VWuU8YVI9FFKwWQ9Uykvq2h3IF54ROLDCSJNtRU0TwYoU3Tk0XrVP1PjG4Gv7 RersG78bXlyvP66wqb7FhymXTZwe1JPwyDLH1hykIDViWgy1ndm5D8Ks4QgHIQDW9d11 cHyx/eNONot7GRFUMFvbeoS084nFn8gdlu9AgTHags6bJatKFBoQyxJZF3E+8MFBORdb 8STA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=RlWBYt/s+9V0QpZCLG+zjbxSYF/nR3fEJEG7YnknZbM=; b=I9W3e/XCzg44G6Jr0JLdhHK+1r+OkY78SvsKOx89GNA3b36LgvYQUEwiHHsTfHAy9x fCjx32UcXkmr3edJqWHRVEV+GHy8IrHOmpUTJTcDOGDInj4/qrAFsijIiiaW4SUjJlrY 19otBWeH2zn0DDvukVtJ8aD7TCMnxJ0QWiDDcl1PrkIY8OmEv/Rq1NWN9RDfaoqb7Z3k YUAQgdFruCFG51hHm6zgHH5VG2EplZk9/Ik0X3ewDOv4qGrFuQt/Z+hXEXkBL+QmPnPI HBpEVVLKW1dNeY83yFy9qungYoRrvtd48p+aJ1HlFA/oNMODddhIrmgC5R5jFZ4PvWky NUnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=FujlZtKy; 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 s186si13092483pgb.557.2019.02.12.12.02.25; Tue, 12 Feb 2019 12:02:41 -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; dkim=pass header.i=@agner.ch header.s=dkim header.b=FujlZtKy; 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 S1729645AbfBLTHg (ORCPT + 99 others); Tue, 12 Feb 2019 14:07:36 -0500 Received: from mail.kmu-office.ch ([178.209.48.109]:42944 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727677AbfBLTHf (ORCPT ); Tue, 12 Feb 2019 14:07:35 -0500 Received: from webmail.kmu-office.ch (unknown [IPv6:2a02:418:6a02::a3]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 07A055C026A; Tue, 12 Feb 2019 20:07:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1549998453; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RlWBYt/s+9V0QpZCLG+zjbxSYF/nR3fEJEG7YnknZbM=; b=FujlZtKyTZDcZACzadu4K+pY0YMakG2X562sMstwC4cxxzImEWOwuccvhkuLLwRGV4FN7g uuC7kCbjAifkBaCmd7uExCJFHyFKA0q+/FQ6mokXWADZAU7Bj3JBgPzAqL+YfEYjUyDqB9 ClqLMHr6eP3Y3aXUC0ct07xzVP47CUs= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: Tue, 12 Feb 2019 20:07:32 +0100 From: Stefan Agner To: Lorenzo Pieralisi Cc: Lucas Stach , Bjorn Helgaas , jingoohan1@gmail.com, gustavo.pimentel@synopsys.com, tpiepho@impinj.com, leonard.crestez@nxp.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] PCI: imx6: limit DBI register length In-Reply-To: <20190212113257.GA23658@red-moon> References: <14fafdf52d19feb9c926c312f4e3ba7ff8a4bad9.1549446867.git.stefan@agner.ch> <119211b4f2e9ada55b86041d009656e49c2b5281.1549446867.git.stefan@agner.ch> <20190211213900.GA247873@google.com> <1549961694.2546.18.camel@pengutronix.de> <20190212113257.GA23658@red-moon> Message-ID: X-Sender: stefan@agner.ch User-Agent: Roundcube Webmail/1.3.7 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12.02.2019 12:33, Lorenzo Pieralisi wrote: > On Tue, Feb 12, 2019 at 09:54:54AM +0100, Lucas Stach wrote: >> Hi Bjorn, >> >> Am Montag, den 11.02.2019, 15:39 -0600 schrieb Bjorn Helgaas: >> > On Wed, Feb 06, 2019 at 10:57:32AM +0100, Stefan Agner wrote: >> > > Define the length of the DBI registers. This makes sure that >> > > the kernel does not access registers beyond that point, avoiding >> > > the following abort on a i.MX 6Quad: >> > >   # cat /sys/devices/soc0/soc/1ffc000.pcie/pci0000\:00/0000\:00\:00.0/config >> > >   [  100.021433] Unhandled fault: imprecise external abort (0x1406) at 0xb6ea7000 >> > >   ... >> > >   [  100.056423] PC is at dw_pcie_read+0x50/0x84 >> > >   [  100.060790] LR is at dw_pcie_rd_own_conf+0x44/0x48 >> > >   ... >> > >> > I assume this problem happens when using the pci_read_config() path or >> > something similar? >> > >> > Could this be solved using pci_dev.cfg_size instead of building a new >> > dwc-specific mechanism?  There are some quirks that set dev->cfg_size >> > to keep from reading past certain points in config space, e.g., >> > quirk_citrine(), quirk_nfp6000(). >> > >> > I'm not necessarily opposed to doing it in dwc, but maybe there's some >> > advantage in reducing the number of ways of doing the same thing. >> >> This actually started out as a quirk changing the cfg size. But the >> valid config space size seems to be different between root ports that >> share the same (broken) device ID (Synopsys abcd), so I doubt that this >> would be easier and/or any cleaner to implement as a quirk. For reference, this was the initial patch using DECLARE_PCI_FIXUP_HEADER: https://lore.kernel.org/lkml/20181019111350.6170-1-stefan@agner.ch/T/#u > > There are two things here: matching the root port and setting > the cfg size limit. > > I agree with Bjorn that the cfg size limit, given that it is > implemented in core code should be leveraged instead of reinventing > the wheel to solve the same problem in driver specific code. Seems sensible yes. > > In the quirk code I do not think it is that complicated to retrieve > the IMX variant to apply the quirk accordingly on the pci_dev. It seems that drivers/pci/controller/pcie-iproc.c uses FIXUP functions which access driver specific structs. I think we can get from (struct pci_host_bridge *)->sysdata to struct pcie_port * and from there to struct dw_pci. I will give this a try next week. > > Please let me know if that's feasible so that I can drop the > patches from the branch and update it with a new version. > Fine for me. -- Stefan