Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2312440pxv; Sat, 3 Jul 2021 05:15:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyu0GIZ5qyCnYypeDMvYZ+yGHEmL4YiiuVQ4K3T+/JSnAo94cKsEQCx4Q03EnwF3wAMpvXh X-Received: by 2002:a6b:b882:: with SMTP id i124mr3961886iof.80.1625314517964; Sat, 03 Jul 2021 05:15:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625314517; cv=none; d=google.com; s=arc-20160816; b=PlpzcrLXm9Yk2QlTB+xeCK0YrI2xjgwUZQSJWAfsS5nboJAC4OLKhGHtjjAutCAt0z R+u2s+AV60od+6ZeHocV5b4wOVVpcN6otN+7HR9ppSmuDGtFeDTUtiqH2PcO2D3VfYHR ha+eGhzR6PBrwYGAmZvfBIlcy6mhzBFb9sTELgOnrM8eN52IfXRqln0xUY82u8Qt20S2 I8dzr8QJx324RWVUlxtcmAMPqHa1AqjU0mCti1TNTCTH3VWbWeBu5s8WAh2hOKs3YFTt obaAI5VDo5hPI0JxjX8UaH2xt3vaeGwcaq4mm44XNIWck/RSSxyZgyId+7dF5db1UJVo LrBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=xTFCNuHEAPBMz882Nfyun06XuBQ3jJNbxgwSUneaAfU=; b=ShN1hGarKiG8C+j1T2QpS2PMsr5UKlD80bl+a+tyxM4si1IYtJcbgfOBjVZhjFZOrU eMtq65bzQJPoPegvwidXs4hm8CLNBtWQWFqMsKs0cn029RaKhdfqr8T+IBP5ctOa/oPW PKHY4dHiWXKM6xdGRgGcI4pnMxlzWNbyPszmZZTzR8gHkKJil2/SbcgF2F1+xGAHgseB 6zgI+4v9dLtwSIy2At5kmjV7xrU0SYCIw87AHb/O2B/A7qjqSoVIFiMV0MRLz2tSD8ih Baj14M0Y8PktN+wezqVxHGVhAQY9fd9mvTrKUOVKxlDUAjNloSob83B1TMFU5uFjffOI 2R9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oFAhw8N4; 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 n6si7051712ilj.66.2021.07.03.05.15.03; Sat, 03 Jul 2021 05:15:17 -0700 (PDT) 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=k20201202 header.b=oFAhw8N4; 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 S230239AbhGCMPS (ORCPT + 99 others); Sat, 3 Jul 2021 08:15:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:59394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230209AbhGCMPR (ORCPT ); Sat, 3 Jul 2021 08:15:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 092FA61934; Sat, 3 Jul 2021 12:12:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625314364; bh=1mLMGaBe3T8PNBo9Ly3kN5L7hm+00YAjMpTfySrZV6c=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=oFAhw8N4IyGvi+9Wdqp1rBC20SM5p55/NOmWMbKMhsxdFEaI2fUVVfmLo0tUtEokC 20R3S9EpwD2vZRpPjVDTkargqOVbOe33P3EhxOwhuNMZZY45WVmUpYiGuqDDDndg8i 6sFCbeJFaM0C7BePLbRhJqwkO1KmQECBYOvUO0zmW28SuHzZ9qoSRyN2fq1j5IUKBx ICTlU80cr/+o2MJmaEjD4ad8nU8RYE303v4dnliAZSxnk5pEJOiFzIylay/7/dQNb8 2Y3EZgjS4sHhhvXr/guu9l1MWIG2/7QUUP6YOJIdqkpdStR1z7DBYCEtFySPkSO3bq OyDFkHDIQhwaw== Received: by mail-wr1-f51.google.com with SMTP id m18so15902732wrv.2; Sat, 03 Jul 2021 05:12:43 -0700 (PDT) X-Gm-Message-State: AOAM53177Q7+34ieDTtHC6Hhe+qNGCWwV+r58LD2qdeh6gwrG/gCIi6W +iZewo6JIXHanKXruX05Wh4RhphtQWU2eWq9qpw= X-Received: by 2002:a5d:6485:: with SMTP id o5mr5183612wri.286.1625314362622; Sat, 03 Jul 2021 05:12:42 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Arnd Bergmann Date: Sat, 3 Jul 2021 14:12:26 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [GIT PULL 1/2] asm-generic: rework PCI I/O space access To: Linus Torvalds Cc: linux-arch , linux-pci , Linux Kernel Mailing List , Niklas Schnelle Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 2, 2021 at 9:42 PM Linus Torvalds wrote: > > On Fri, Jul 2, 2021 at 6:48 AM Arnd Bergmann wrote: > > > > A rework for PCI I/O space access from Niklas Schnelle: > > I pulled this, but then I ended up unpulling. > > I don't absolutely _hate_ the concept, but I really find this to be > very unpalatable: > > #if !defined(inb) && !defined(_inb) > #define _inb _inb > static inline u8 _inb(unsigned long addr) > { > #ifdef PCI_IOBASE > u8 val; > > __io_pbr(); > val = __raw_readb(PCI_IOBASE + addr); > __io_par(val); > return val; > #else > WARN_ONCE(1, "No I/O port support\n"); > return ~0; > #endif > } > #endif > > because honestly, the notion of a run-time warning for a compile-time > "this cannot work" is just wrong. Ok, fair enough, back to the drawing board then. > If the platform doesn't have inb/outb, and you compile some driver > that uses them, you don't want a run-time warning. Particularly since > in many cases nobody will ever run it, and the main use case was to do > compile-testing across a wide number of platforms. > > So if the platform doesn't have inb/outb, they simply should not be > declared, and there should be a *compile-time* error. That is > literally a lot more useful, and it avoids this extra code. I tried adding a Kconfig option over a decade ago, but at the time gave up when I couldn't still get drivers/ide and the 8250 uart driver to build in a sensible way that would still allow the MMIO based variants to work, but leave out the PIO accessors. With drivers/ide gone, and the drivers/tty/serial/ having gone through many changes, it's probably easier now. I could imagine adding a CONFIG_LEGACY_PCI that controls whether we have any pre-PCIe devices or those PCIe drivers that need PIO accessors other than ioport_map()/pci_iomap(). This can then select a CONFIG_IOPORT, which controls whether inb/outb etc are provided. x86 and anything that uses inb/outb for non-PCI devices would select it as well. > Extra code that not only doesn't add value, but that actually > *subtracts* value is not code I really want to pull. What happened here specifically is that the asm-generic version is definitely broken and can cause a NULL pointer dereference on platforms that used to fall back to NULL PCI_IOBASE. The latest clang does complain about those drivers with a correct warning (not an error) that shows up in s390 allmodconfig builds. Niklas' original version of the patch tried to shut up the warning but did not address the dangerous behavior, which I did not find sufficient either. The version we got here makes it no longer crash the kernel, but I see your point that the runtime warning is still wrong. I'll have a look at what it would take to guard all inb/outb callers with a Kconfig conditional, and will report back after that. Arnd