Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3318643pxx; Mon, 2 Nov 2020 06:01:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0YAvBWy11pRLpNeEjQFNzvjcylYzedOGjEShj5i6BYuzUXicNt00A1RkXglPsaKggcOoW X-Received: by 2002:a17:906:1614:: with SMTP id m20mr15233029ejd.258.1604325717027; Mon, 02 Nov 2020 06:01:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604325717; cv=none; d=google.com; s=arc-20160816; b=QujSGNJkCMF//PlCDH6xlyoVmcvEHuzdmDL89FHii+9YsfOVUd3lW32sipjsZnAOk9 jmK3m8mFs6thRggFt7rcYOhrzauOeIzTJ1m/W5Y3yChYd5TpSgv5YtSPbmSICOFyvvi5 9EUaPDBnLQY0vXrFholULBARq1PsnhwA8wE+S1PU4v4vq43fA2nB4uJtkttVhJ153zbK EmZZjZcPl1B7H34iaZFhcS8h2iksbOoN/OPbAhA54Pbs9MmJy+awtm4NM/3Jk9lEOYpF ua6dXczY+dlONDtyFgRRcbTG4J2+wKbKY2/cIXtAwVgVXPhgzCP2tejnsthFDcs9sdW9 NxEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=woEbHM4yQdeldeA36P/XuWeJvsFtFh65/XH9ZS+5bMk=; b=lTRQUa+GjBEYYPqZ+Iu9kQeN5XbP9NFbZtp7wyh5mxGu6Sn7UMsx4mO35HaXfd89cm rxqcVfZ9uJJdKpmth/nGeOzMWb1GQWSmgV8Y+hSnkNksalvvvEbcVyz/Iqh3lajOwfkr dM/gdmhXyLBirSIBBdmERI59Fk+0w5j3rmxguQ8Wq21V1/ZvZIkZDASMq9TuJ38nGN3J jYcx+26balKR1VxRbEavJXG+0jLV0inPB646GnOcOYybbrMly+MkuwOnFYNXMBjdQsAq mMGT9h8nNwJmLEALRkeKNezglcAYKKyaCkPcFAHMw0ONOuHbWGaPMZxLviLWaTyGfvbN ZIMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b+8i5rz2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y10si6619805ejf.165.2020.11.02.06.01.29; Mon, 02 Nov 2020 06:01:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b+8i5rz2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725967AbgKBN6t (ORCPT + 99 others); Mon, 2 Nov 2020 08:58:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:51336 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725960AbgKBN6Q (ORCPT ); Mon, 2 Nov 2020 08:58:16 -0500 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D96092227F; Mon, 2 Nov 2020 13:58:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604325495; bh=4vBetSmkaAnipo22H++gE1vnC0urlGdr/4l9rZltXFE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=b+8i5rz2fNvGL/J6h4wEUkI4ox8rsUkM8bbbQBOG71JqSsWi1gVwTT0Mo82faN1td /KMhiFuGwK7cRt0J4BfT9L7nWYKypu8/fdn/U0HtQBjKJFeAB9BDprMjxJv47a4iue 6vtU7qZPCSdHWVnb29WtdnR5uM/nDL8Xv0AplhW0= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1kZaLc-006g2w-Bj; Mon, 02 Nov 2020 13:58:12 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 02 Nov 2020 13:58:12 +0000 From: Marc Zyngier To: Frank Wunderlich Cc: Thomas Gleixner , Ryder Lee , linux-mediatek@lists.infradead.org, Frank Wunderlich , linux-kernel@vger.kernel.org, Matthias Brugger , linux-pci@vger.kernel.org, Bjorn Helgaas Subject: Re: Aw: Re: Re: [PATCH] pci: mediatek: fix warning in msi.h In-Reply-To: References: <20201031140330.83768-1-linux@fw-web.de> <878sbm9icl.fsf@nanos.tec.linutronix.de> <87lfflti8q.wl-maz@kernel.org> <1604253261.22363.0.camel@mtkswgap22> <87k0v4u4uq.wl-maz@kernel.org> <87pn4w90hm.fsf@nanos.tec.linutronix.de> User-Agent: Roundcube Webmail/1.4.9 Message-ID: <336d6588567949029c52ecfbb87660c1@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: frank-w@public-files.de, tglx@linutronix.de, ryder.lee@mediatek.com, linux-mediatek@lists.infradead.org, linux@fw-web.de, linux-kernel@vger.kernel.org, matthias.bgg@gmail.com, linux-pci@vger.kernel.org, bhelgaas@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-11-02 11:56, Frank Wunderlich wrote: > looks good on bananapi-r2, no warning, pcie-card and hdd recognized Thanks for giving it a shot. Still needs a bit of tweaking, as I expect it to break configurations that select CONFIG_PCI_MSI_ARCH_FALLBACKS (we have to assume that MSIs can be handled until we hit the arch-specific stuff). There is also a small nit in the way we allow userspace to mess with this flag via sysfs, and similar restrictions should probably apply. Updated patch below. M. diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index d15c881e2e7e..5bb1306162c7 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -387,10 +387,20 @@ static ssize_t msi_bus_store(struct device *dev, struct device_attribute *attr, return count; } - if (val) + if (val) { + /* + * If there is no possibility for this bus to deal with + * MSIs, then allowing them to be requested would lead to + * the kernel complaining loudly. In this situation, don't + * let userspace mess things up. + */ + if (!pci_bus_is_msi_capable(subordinate)) + return -EINVAL; + subordinate->bus_flags &= ~PCI_BUS_FLAGS_NO_MSI; - else + } else { subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; + } dev_info(&subordinate->dev, "MSI/MSI-X %s for future drivers of devices on this bus\n", val ? "allowed" : "disallowed"); diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 4289030b0fff..28861cc6435a 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -871,6 +871,8 @@ static void pci_set_bus_msi_domain(struct pci_bus *bus) d = pci_host_bridge_msi_domain(b); dev_set_msi_domain(&bus->dev, d); + if (!pci_bus_is_msi_capable(bus)) + bus->bus_flags |= PCI_BUS_FLAGS_NO_MSI; } static int pci_register_host_bridge(struct pci_host_bridge *bridge) diff --git a/include/linux/pci.h b/include/linux/pci.h index 22207a79762c..6aadb863dff4 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -2333,6 +2333,12 @@ pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) { return NULL; } static inline bool pci_pr3_present(struct pci_dev *pdev) { return false; } #endif +static inline bool pci_bus_is_msi_capable(struct pci_bus *bus) +{ + return (IS_ENABLED(CONFIG_PCI_MSI_ARCH_FALLBACKS) || + dev_get_msi_domain(&bus->dev)); +} + #ifdef CONFIG_EEH static inline struct eeh_dev *pci_dev_to_eeh_dev(struct pci_dev *pdev) { -- Jazz is not dead. It just smells funny...