Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1349652rdb; Fri, 1 Dec 2023 13:56:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IHuYB90kAK/jAbGSpF4lVGMKGoC/BaTHPiaF2EhzPZh8acWOoHZX/3P6R+QqI5r6gSyF/Tr X-Received: by 2002:a05:6870:678a:b0:1fb:75a:de61 with SMTP id gc10-20020a056870678a00b001fb075ade61mr270655oab.79.1701467783530; Fri, 01 Dec 2023 13:56:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701467783; cv=none; d=google.com; s=arc-20160816; b=F2Ejr7Fg4Ka6QCQMefskvXkLkbNbrxVA4Xtq/xvKtzTfh5Jcw0tau/jKjpC01vyVf7 63l4U3Ug3KaPQUsY+O+KHVX/kIQ4iXsi+7D4G8F6iAXp99U6W8SJ60WisvEmOHDqWUnM 4uOrN1n30aU0mMmTabubYDyhge+zqRryc7kAEyyxSGunl6f5stASzOBb0f+GtNKvT9rp XT2ePHAM5qgmUErMnIz7kXW5e98RJFRGkdtDhEsl1eJnCs9IU5BBDIATtz3I9FQrvUSE a4/I/Utg9hR9oZwKq5DTNdWHUCEi5QYHyolq3rOmNfzdNjCp6RUgxj5jQOyuOyjFNC6d RSQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=qzB8UGnzvCMXlHDXHp/lNMLMscLApc7r9rtEsoGucVw=; fh=H9yeA4nRdbsBgiXuKEeeBSeY1NkHkQ+xB31x1XNAlY8=; b=HmJuuOFsfnkjnPtfEfBfPxoOGOXosL3EndNIR1yD/uL8XnAtA7x9PuEeOD6EXCOq1U +ZGAuV4iknEAcOW9hKKXre1a2rx48zKTUPc/A58JB+1FeKLGVSb9TedeYqDyyqP0PdiY 7zVKTr1AJJGjPVU9F2EfH7c26fnNEKnSCn9S6xWWOygev8lYEbUtvqESZMk4QyKSIHzs uXFkA+/iAgUuA2GSpibdGDTZn8IhIzKXd2gnj8zBaA9uhL0OwYTiFYs+SaWez1+pSxvQ GH4bKYmcZDTsIY4wl3Ks+j5S7tTCuQyHkdBGpyfBCv5n5bOWgeLAWw2Y3VxyQ8Vzj0XM CUIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=evkrK01I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id y191-20020a638ac8000000b005b9b68add9asi3845686pgd.255.2023.12.01.13.56.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 13:56:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=evkrK01I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B974880DEA6C; Fri, 1 Dec 2023 13:56:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229547AbjLAV4M (ORCPT + 99 others); Fri, 1 Dec 2023 16:56:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbjLAV4L (ORCPT ); Fri, 1 Dec 2023 16:56:11 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60C86F4 for ; Fri, 1 Dec 2023 13:56:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701467776; 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=qzB8UGnzvCMXlHDXHp/lNMLMscLApc7r9rtEsoGucVw=; b=evkrK01IIt5dCqEEb2bENQNDK2db72a6He9rWs7e6bA2SqlZmixuWSvlW1JzNEBEg6rxgH 1wDVAU9D/cnMAJRfjqhjg5arQS0R5RHGDJKSL3TPXmffPVYpNvmxjPWJR4NxhFomI95bYg oYKnozYxjtMPbqfv3zaNu3InhhCApl4= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-445-hKKyC5uBO-WB9t8Oh4HIoQ-1; Fri, 01 Dec 2023 16:56:10 -0500 X-MC-Unique: hKKyC5uBO-WB9t8Oh4HIoQ-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3333298eaabso157789f8f.0 for ; Fri, 01 Dec 2023 13:56:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701467769; x=1702072569; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=qzB8UGnzvCMXlHDXHp/lNMLMscLApc7r9rtEsoGucVw=; b=EWqhb5wkCmDnXPpLs98K1kJgxtfQTuxYbyxGqkeVoFT+AE9Sw9aBSb4f60y4H9xHl+ 8SlsdZEKEV1LiGrDhzyknkpfOlX7daWci6HQDrdIr5VX8Ik3oUoYubM4tZCkeQF4035j FXQFWXctHeCgeVyh74BE4xTwEPRLLdZZqtZRquvbedM7Lj0gnZ0Gr5uHIXj16iMly0K1 7Iz5z2dxQtcqSdP5WS+0QOMlB0RNPceVO4tKJn8mTeYCyolOb2oX7tMOz3wI9TIG6h5W 8XOoebmRqBoH2Ob17XiiztB7hUv8EqBS2/7SbiAsh4sjeyXyvrMQ1eMuXB/Fkf+Yutxt pL6Q== X-Gm-Message-State: AOJu0YyCPFFF3WdFIEjqVZAiu6cyHzKlqgCW9ywTeROI1Qh7i+s5L1Gh ICjR0zV7HDjUPneSrUJ51K/P4ssru/ZaWEwg93Y67eeHNwaXHCnV7wJtNAClXomBvssJ06BMHWb Jjeiq/VzBXEjRzFhZAtfB1eD2 X-Received: by 2002:a05:600c:2102:b0:40b:516a:3856 with SMTP id u2-20020a05600c210200b0040b516a3856mr4459048wml.1.1701467768938; Fri, 01 Dec 2023 13:56:08 -0800 (PST) X-Received: by 2002:a05:600c:2102:b0:40b:516a:3856 with SMTP id u2-20020a05600c210200b0040b516a3856mr4459027wml.1.1701467768604; Fri, 01 Dec 2023 13:56:08 -0800 (PST) Received: from pstanner-thinkpadt14sgen1.remote.csb ([2001:9e8:32e2:4e00:227b:d2ff:fe26:2a7a]) by smtp.gmail.com with ESMTPSA id fk14-20020a05600c0cce00b0040b2a52ecaasm10410926wmb.2.2023.12.01.13.56.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 13:56:08 -0800 (PST) Message-ID: Subject: Re: [PATCH v2 4/4] lib, pci: unify generic pci_iounmap() From: Philipp Stanner To: Arnd Bergmann , Bjorn Helgaas , Andrew Morton , Dan Williams , Jonathan Cameron , Jakub Kicinski , Dave Jiang , Uladzislau Koshchanka , Neil Brown , Niklas Schnelle , John Sanpe , Kent Overstreet , Masami Hiramatsu , Kees Cook , David Gow , Yury Norov , "wuqiang.matt" , Jason Baron , Kefeng Wang , Ben Dooks , Danilo Krummrich Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Linux-Arch , Arnd Bergmann , pstanner@redhat.com Date: Fri, 01 Dec 2023 22:56:05 +0100 In-Reply-To: <330df2f8-3796-4f74-8856-06ae1e46ec9b@app.fastmail.com> References: <20231201121622.16343-1-pstanner@redhat.com> <20231201121622.16343-5-pstanner@redhat.com> <619ea619-29e4-42fb-9b27-1d1a32e0ee66@app.fastmail.com> <330df2f8-3796-4f74-8856-06ae1e46ec9b@app.fastmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,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 lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Fri, 01 Dec 2023 13:56:21 -0800 (PST) On Fri, 2023-12-01 at 22:32 +0100, Arnd Bergmann wrote: > On Fri, Dec 1, 2023, at 20:37, Philipp Stanner wrote: > > On Fri, 2023-12-01 at 16:26 +0100, Arnd Bergmann wrote: > > >=20 > > > static inline bool struct iomem_is_ioport(void __iomem *p) > > > { > > > #ifdef CONFIG_HAS_IOPORT > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uintptr_t start =3D (uintp= tr_t) PCI_IOBASE; > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uintptr_t addr =3D (uintpt= r_t) p; > > >=20 > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (addr >=3D start && add= r < start + IO_SPACE_LIMIT) > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 return true; > > > #endif > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return false; > > > } > > >=20 > > > > +#else /* CONFIG_GENERIC_IOMAP. Version from lib/iomap.c will > > > > be > > > > used.=20 > > > > */ > > > > +bool iomem_is_ioport(void __iomem *addr); > > > > +#define ARCH_WANTS_GENERIC_IOMEM_IS_IOPORT > > >=20 > > > I'm not sure what this macro is for, since it appears to > > > do the opposite of what its name suggests: rather than > > > provide the generic version of iomem_is_ioport(), it > > > skips that and provides a custom one to go with lib/iomap.c > >=20 > > Hmmm well now it's getting tricky. > >=20 > > This else-branch is the one where CONFIG_GENERIC_IOMAP is actually > > set. > >=20 > > I think we're running into the "generic not being generic now that > > IA64 > > has died" problem you were hinting at. > >=20 > > If we build for x86 and have CONFIG_GENERIC set, only then do we > > want > > iomem_is_ioport() from lib/iomap.c. So the macro serves avoiding a > > collision between symbols. Because lib/iomap.c might be compiled > > even > > if someone else already has defined iomem_is_ioport(). > > I also don't like it, but it was the least bad solution I could > > come up > > with > > Suggestions? >=20 > The best I can think of is to move the lib/iomap.c version > of iomem_is_ioport() to include/asm-generic/iomap.h with > an #ifndef iomem_is_ioport / #define iomem_is_ioport > check around it. This file is only included on parisc, alpha, > sh and when CONFIG_GENERIC_IOMAP is set. My implementation from lib/iomap.c basically just throws away the IO_COND macro and does the checks manually: #if defined(ARCH_WANTS_GENERIC_IOMEM_IS_IOPORT) bool iomem_is_ioport(void __iomem *addr) { unsigned long port =3D (unsigned long __force)addr; if (port > PIO_OFFSET && port < PIO_RESERVED) return true; return false; } #endif /* ARCH_WANTS_GENERIC_IOMEM_IS_IOPORT */ So we'd also need PIO_OFFSET and PIO_RESERVED, which are not present in asm-generic/iomap.h. Sure, we could move them there or into a common header. But I'm not sure if that is wise, meaning: is it really better than the ugly WANTS_GENERIC_IOMEM... macro? Our entire goal in this series is, after all, to simplify the implementation. P. >=20 > The default version in asm-generic/io.h then just needs > one more #ifdef iomem_is_ioport check around it. >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Arnd >=20