Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 25998C433F5 for ; Thu, 2 Dec 2021 15:36:33 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CCE38811A7; Thu, 2 Dec 2021 16:36:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1638459391; bh=QGKfOsWN6wqLSYKpGmYrSDqy4OOHQDTvYHpARiE0dds=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=cgASpRDEd+DHknF7VX8PYSHAJrUimxP71oWKXhV5OJn3r3mnZ+BEIE7wDvW/Td/85 oM0vqxG9h9vPsSTp+gtPthuV8ajmomVerNERZPDfF+Jvxjfn7XaODi+sX5Fem82JE1 JjroW+AGvwN8LEJKO33NNL4/U0iLc0BtVyQCT+XbJ22OMSPgUhN+D9SLPqbRJAAfv2 BL5/I1TIJxThebJx03yFLUIyM64XfUZtQWWj/8Rc6tigyhaYM+0TnkzNJb+icdZCRz BCopsz/pclHA0EjR3mAzN625RjOPN7s5xRBBgdUpj0zjGcwlC1oGVVE7E1KQq3lWCX ml3vq8p/8BLVg== Received: by phobos.denx.de (Postfix, from userid 109) id D905682F63; Thu, 2 Dec 2021 16:36:27 +0100 (CET) Received: from mout-u-107.mailbox.org (mout-u-107.mailbox.org [91.198.250.252]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6C4F8811B3 for ; Thu, 2 Dec 2021 16:36:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp1.mailbox.org (unknown [91.198.250.123]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4J4g6B29p1zQl4Z; Thu, 2 Dec 2021 16:36:18 +0100 (CET) Message-ID: <21e97c08-dd7f-e952-4397-18dd26de52d6@denx.de> Date: Thu, 2 Dec 2021 16:36:14 +0100 MIME-Version: 1.0 Subject: Re: [PATCH] pci: Disable I/O forwarding during autoconfiguration if unsupported Content-Language: en-US To: =?UTF-8?Q?Pali_Roh=c3=a1r?= Cc: Simon Glass , Bin Meng , u-boot@lists.denx.de References: <20211125103243.23826-1-pali@kernel.org> <19e2644f-5498-8cc9-f0ae-2343ee688102@denx.de> <20211201230833.x3ci626twcmjepky@pali> From: Stefan Roese In-Reply-To: <20211201230833.x3ci626twcmjepky@pali> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On 12/2/21 00:08, Pali Rohár wrote: > On Tuesday 30 November 2021 07:09:36 Stefan Roese wrote: >> On 11/25/21 11:32, Pali Rohár wrote: >>> If U-Boot does not have any I/O resource for assignment then disable I/O >>> forwarding in PCI bridge autoconfiguration code. Default initial state of >>> PCI bridge IO registers is unspecified, therefore they can be in enabled if >>> U-Boot does not touch them. >>> >>> Signed-off-by: Pali Rohár >>> >>> --- >>> drivers/pci/pci_auto.c | 8 ++++++++ >>> 1 file changed, 8 insertions(+) >>> >>> diff --git a/drivers/pci/pci_auto.c b/drivers/pci/pci_auto.c >>> index 7e6ee54be087..6e5ed194f247 100644 >>> --- a/drivers/pci/pci_auto.c >>> +++ b/drivers/pci/pci_auto.c >>> @@ -265,6 +265,14 @@ void dm_pciauto_prescan_setup_bridge(struct udevice *dev, int sub_bus) >>> (pci_io->bus_lower & 0xffff0000) >> 16); >>> cmdstat |= PCI_COMMAND_IO; >>> + } else { >>> + /* Disable I/O if unsupported */ >>> + dm_pci_write_config8(dev, PCI_IO_BASE, 0xf0 | io_32); >>> + dm_pci_write_config8(dev, PCI_IO_LIMIT, 0x0 | io_32); >> >> Does it perhaps make sense to add / use a macro for this 0xf0 above? > > For setting range bits we already have macro PCI_IO_RANGE_MASK. > > So for setting all base range bits to one (which is this patch is > suppose to do) I can write something like this: (~0 & PCI_IO_RANGE_MASK) > or (0xff & PCI_IO_RANGE_MASK). (write_config8 denotes that we use 8bit > numbers...) > > I/O forwarding is disabled when base address is higher than limit > address and it is common to choose base address as the highest possible > (hence all ones) and limit address to lowest possible (hence all zeros). > > So question is, do we need macro which evaluates to number with all > zeros and another macro which evaluates to number with all ones? > > I'm not sure. For me is "0xf0 | io_32" more readable as "the verbose > usage with macro" "(0xff & PCI_IO_RANGE_MASK) | io_32". I have no hard feeling here to really change this - was just checking here. > But this is all just about "naming conventions" and "coding style". If > you think that for consistency is better to create macro or use another > construction, please let me know other ideas. I would follow any style > which is expected here... You already have my RB tag, so all is fine IMHO. Thanks, Stefan > >> Other than this: >> >> Reviewed-by: Stefan Roese >> >> Thanks, >> Stefan >> >> >>> + if (io_32 == PCI_IO_RANGE_TYPE_32) { >>> + dm_pci_write_config16(dev, PCI_IO_BASE_UPPER16, 0x0); >>> + dm_pci_write_config16(dev, PCI_IO_LIMIT_UPPER16, 0x0); >>> + } >>> } >>> /* Enable memory and I/O accesses, enable bus master */ >>> >> >> Viele Grüße, >> Stefan Roese >> >> -- >> DENX Software Engineering GmbH, Managing Director: Wolfgang Denk >> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany >> Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de Viele Grüße, Stefan Roese -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de