Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp833367rdb; Wed, 6 Dec 2023 00:50:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEkW+BARBdEHRynnbg63oMK0/eQ+38sWsH4jLotCIFRk9nUJUAhtOp8nXOhIqtachVf0/Hp X-Received: by 2002:a17:902:bc84:b0:1cf:b964:5e36 with SMTP id bb4-20020a170902bc8400b001cfb9645e36mr495689plb.44.1701852626580; Wed, 06 Dec 2023 00:50:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701852626; cv=none; d=google.com; s=arc-20160816; b=amBTeLxWUnUeXY6/Xl3gDzsHgIyUrRmv5ip7ESbYiA8yvj3m7aupHVAjjERFqd34wc SQHsNBqvtAyK4yJYlsvgyTnh+zn/OUilWW/Ro+bun8tlXzeKmWg8m1j5r1uGccgmDCiw tqLfoQkyWZ/LVQ4+f3j2Z6xFA6YAK3z2jCbWR95arSFdmZ5FL2w7ElwUy3J6ikjnSJLI ZUVpP7d1aGlsyoqpgti+v4lX4VLUBi462l5ttCjtnkwntPEaNNmJAZToJexks6gyP4ui rHFyp2fXCBqPttLiET8dU4yBL645UBYrFZQaBUPQz3hzzhRyvZyQQthY1QPA9RsPCAKU 9HeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:feedback-id:dkim-signature :dkim-signature; bh=W3qjdlXCrGJYdFNLku/WKxa0Yd1q1gu7loL3v5KHYRM=; fh=GlOc0jJ0cz9fUjQAtDU7dum+S0EV9I7ODU8I9+JjwkA=; b=0/V7dyuC+9T3iMFliLQQiG4XGi16T8EcO4w6Tx39D3rgUWj6Saoyk2wnRlTQ8KQxJX QDcyz8UKS1pCxGSBkS2QKsQBMONf3P7asORjNAm2BDoXWoMfmFopZo30vDs0dbjDyqlF cb4KAjdw4UK4KlpnUkpqTzQc0HIsD3PyK3b5Zdz/kFlrFwuIxJnaclz00qDHO3RR8Oxo scRjatxVhKWYV8qtNUFC/r2ZeOw1mcSk2Yi97SkBfEGaP2DoXSZkO9YN95PooHSiynr/ N30HikgxZGsX4AC5Zy5yVlUXXXSf6rclEesechJ0DobztQpencuhAYYtQ7ZV5ti4QfqH GqJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm3 header.b=bLrkhj0k; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=d4gOIy6q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arndb.de Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id j12-20020a170902c3cc00b001d0c1ce3095si3005854plj.151.2023.12.06.00.50.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 00:50:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@arndb.de header.s=fm3 header.b=bLrkhj0k; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=d4gOIy6q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arndb.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id A47A2805061C; Tue, 5 Dec 2023 05:26:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235216AbjLEN0b (ORCPT + 99 others); Tue, 5 Dec 2023 08:26:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235232AbjLEN03 (ORCPT ); Tue, 5 Dec 2023 08:26:29 -0500 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 305031B6; Tue, 5 Dec 2023 05:26:35 -0800 (PST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 7C1375C02B6; Tue, 5 Dec 2023 08:26:34 -0500 (EST) Received: from imap51 ([10.202.2.101]) by compute5.internal (MEProxy); Tue, 05 Dec 2023 08:26:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1701782794; x=1701869194; bh=W3 qjdlXCrGJYdFNLku/WKxa0Yd1q1gu7loL3v5KHYRM=; b=bLrkhj0kwVDlhhm0+R pQOLQFBz3kV22n0WjqMPaeVJUuBarW8pHH0nK37J/5f8lyTuxsz2iWa8ZqFmKkvC bjX8ZUvMEM99/GWgx/ImY4aW2B57xjYC7/4m+Dym3fOqkaAUClDVHUysbFmA4/+f g0JG0o8FYgwLMFnPUTyVGmFLBD6DNdJtY1XaHdWWii/IZIvzbjKUGI6OaxpYXP6Z yZRpeA+UMpBUnu7aWcUsxpkYmwwSrbJn+s4gTCc6wXq9dlUUPeCkKdlld4bHJXo3 Ww6yrjXgSQc3NvsAH7/Mg32qSWdf7+l7p0V5xYztDOfDopVj1g7QejZd/AjfsI7U vUFw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1701782794; x=1701869194; bh=W3qjdlXCrGJYd FNLku/WKxa0Yd1q1gu7loL3v5KHYRM=; b=d4gOIy6qFdfd4X8LITm6s20dSvrO3 aP93Rin/2ZeuMjOa7bvPlovch3EgW5aTuq97NwuYM580SBPIeKLfKfWWLPIY2Zqu s8WF+rnjnMldz+/cS//YOStmVRB73mjLgxqySiQLavRbCMjDBJF1dMx9lLYAofmI /+ydkW25kJ7+a5+Bsb7TxEieR6l4x2X0sfXzscZycM+TGUhHXExj4kKU2PTy6e52 UmWDBdh2eXtqipjevJgcwI5ux44TvC2fK8Pc3DCbjd0261VPdxUk/VcNq+0kF9VZ pxiKtzUo4Jcz9yyCOlmZkjLQvz0PsF70LMMLU9IT+0En9R60z3S16ajzQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudejkedghedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsehttdertderredtnecuhfhrohhmpedftehr nhguuceuvghrghhmrghnnhdfuceorghrnhgusegrrhhnuggsrdguvgeqnecuggftrfgrth htvghrnhepffehueegteeihfegtefhjefgtdeugfegjeelheejueethfefgeeghfektdek teffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hrnhgusegrrhhnuggsrdguvg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 7D795B6008D; Tue, 5 Dec 2023 08:26:33 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-1178-geeaf0069a7-fm-20231114.001-geeaf0069 MIME-Version: 1.0 Message-Id: <2ef81211-9525-4f96-a6b2-3fcfbed0c6e5@app.fastmail.com> In-Reply-To: <602e1ba4f02489fcbc47e8f9904f3c1db1c9f14a.1701768028.git.ysato@users.sourceforge.jp> References: <602e1ba4f02489fcbc47e8f9904f3c1db1c9f14a.1701768028.git.ysato@users.sourceforge.jp> Date: Tue, 05 Dec 2023 14:26:13 +0100 From: "Arnd Bergmann" To: "Yoshinori Sato" , linux-sh@vger.kernel.org Cc: "Damien Le Moal" , "Rob Herring" , "Krzysztof Kozlowski" , "Conor Dooley" , "Geert Uytterhoeven" , "Michael Turquette" , "Stephen Boyd" , "Dave Airlie" , "Daniel Vetter" , "Maarten Lankhorst" , "Maxime Ripard" , "Thomas Zimmermann" , "Thomas Gleixner" , "Lorenzo Pieralisi" , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , "Bjorn Helgaas" , "Greg Kroah-Hartman" , "Jiri Slaby" , "Magnus Damm" , "Daniel Lezcano" , "Rich Felker" , "John Paul Adrian Glaubitz" , "Lee Jones" , "Helge Deller" , =?UTF-8?Q?Heiko_St=C3=BCbner?= , "Jernej Skrabec" , "Chris Morgan" , "Linus Walleij" , "Randy Dunlap" , "Hyeonggon Yoo" <42.hyeyoo@gmail.com>, "David Rientjes" , "Vlastimil Babka" , "Baoquan He" , "Andrew Morton" , "Guenter Roeck" , "Stephen Rothwell" , guoren , "Javier Martinez Canillas" , "Azeem Shaikh" , "Palmer Dabbelt" , "Bin Meng" , "Max Filippov" , "Tom Rix" , "Herve Codina" , "Jacky Huang" , "Lukas Bulwahn" , "Jonathan Corbet" , "Biju Das" , =?UTF-8?Q?Uwe_Kleine-K=C3=B6nig?= , "Sam Ravnborg" , "Michael Karcher" , "Sergey Shtylyov" , "Laurent Pinchart" , linux-ide@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Linux-Renesas , linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org, linux-serial@vger.kernel.org, linux-fbdev@vger.kernel.org Subject: Re: [DO NOT MERGE v5 11/37] pci: pci-sh7751: Add SH7751 PCI driver Content-Type: text/plain X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 05 Dec 2023 05:26:46 -0800 (PST) On Tue, Dec 5, 2023, at 10:45, Yoshinori Sato wrote: > +#include > +#include "pci-sh7751.h" > + > +#define pcic_writel(val, base, reg) __raw_writel(val, base + (reg)) > +#define pcic_readl(base, reg) __raw_readl(base + (reg)) __raw_writel()/__raw_readl() has a number of problems with atomicity (the compiler may split or merge pointer dereferences), barriers and endianess. You should normally always use readl()/writel() instead. > + memset(pci_config, 0, sizeof(pci_config)); > + if (of_property_read_u32_array(np, "renesas,config", > + pci_config, SH7751_NUM_CONFIG) == 0) { > + for (i = 0; i < SH7751_NUM_CONFIG; i++) { > + r = pci_config[i * 2]; > + /* CONFIG0 is read-only, so make it a sentinel. */ > + if (r == 0) > + break; > + pcic_writel(pci_config[i * 2 + 1], pcic, r * 4); > + } > + } the config property seems a little too specific to this implementation of the driver. Instead of encoding register values in DT, I think these should either be described in named properties where needed, or hardcoded in the driver if there is only one sensible value. > +/* > + * We need to avoid collisions with `mirrored' VGA ports > + * and other strange ISA hardware, so we always want the > + * addresses to be allocated in the 0x000-0x0ff region > + * modulo 0x400. > + */ > +#define IO_REGION_BASE 0x1000 > +resource_size_t pcibios_align_resource(void *data, const struct > resource *res, > + resource_size_t size, resource_size_t align) > +{ You can't have these generic functions in a driver, as that prevents you from building more than one such driver. The logic you have here is neither architecture nor driver specific. > +static int sh7751_pci_probe(struct platform_device *pdev) > +{ > + struct resource *res, *bscres; > + void __iomem *pcic; > + void __iomem *bsc; > + u32 memory[2]; > + u16 vid, did; > + u32 word; > + > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > + if (IS_ERR(res)) > + return PTR_ERR(res); > + pcic = (void __iomem *)res->start; This cast is invalid, as res->start is a physical address that you would need to ioremap() to turn into an __iomem pointer. > + bscres = platform_get_resource(pdev, IORESOURCE_MEM, 1); > + bsc = devm_ioremap_resource(&pdev->dev, bscres); > + if (IS_ERR(bsc)) > + return PTR_ERR(bsc); > + > + if (of_property_read_u32_array(pdev->dev.of_node, > + "renesas,memory", memory, 2) < 0) { > + /* > + * If no memory range is specified, > + * the entire main memory will be targeted for DMA. > + */ > + memory[0] = memory_start; > + memory[1] = memory_end - memory_start; > + } There is a generic "dma-ranges" proerty for describing which memory is visible by a bus. > diff --git a/drivers/pci/controller/pci-sh7751.h > b/drivers/pci/controller/pci-sh7751.h > new file mode 100644 > index 000000000000..540cee7095c6 > --- /dev/null > +++ b/drivers/pci/controller/pci-sh7751.h > @@ -0,0 +1,76 @@ If the header is only included from one file, just removed it and add the register definitions to the driver directly. Arnd