dri-devel Archive on lore.kernel.org
 help / color / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Saheed Bolarinwa <refactormyself@gmail.com>
Cc: Vignesh Raghavendra <vigneshr@ti.com>,
	trix@redhat.com, linux-fpga@vger.kernel.org,
	dri-devel@lists.freedesktop.org, linux-ide@vger.kernel.org,
	linux-mtd@lists.infradead.org, linux-i2c@vger.kernel.org,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	linux-rdma@vger.kernel.org, Richard Weinberger <richard@nod.at>,
	Joerg Roedel <joro@8bytes.org>,
	linux-atm-general@lists.sourceforge.net, helgaas@kernel.org,
	linux-pci@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
	Wolfgang Grandegger <wg@grandegger.com>,
	intel-gfx@lists.freedesktop.org, linux-gpio@vger.kernel.org,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	skhan@linuxfoundation.org, bjorn@helgaas.com,
	Kalle Valo <kvalo@codeaurora.org>,
	linux-edac@vger.kernel.org, linux-hwmon@vger.kernel.org,
	netdev@vger.kernel.org, linux-wireless@vger.kernel.org,
	linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
	linux-crypto@vger.kernel.org, dmaengine@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [RFC PATCH 00/17] Drop uses of pci_read_config_*() return value
Date: Sun, 2 Aug 2020 20:46:48 +0200
Message-ID: <20200802184648.GA23190@nazgul.tnic> (raw)
In-Reply-To: <b720aa44-895a-203b-e220-ecdb3acd9278@gmail.com>

On Sun, Aug 02, 2020 at 07:28:00PM +0200, Saheed Bolarinwa wrote:
> Because the value ~0 has a meaning to some drivers and only

No, ~0 means that the PCI read failed. For *every* PCI device I know.

Here's me reading from 0xf0 offset of my hostbridge:

# setpci -s 00:00.0 0xf0.l

That device doesn't have extended config space, so the last valid byte
is 0xff. Let's read beyond that:

# setpci -s 00:00.0 0x100.l

> Again, only the drivers can determine if ~0 is a valid value. This
> information is not available inside pci_config_read*().

Of course it is.

*every* change you've done in 6/17 - this is the only patch I have
received - checks for == ~0. So that check can just as well be moved
inside pci_config_read_*().

Here's how one could do it:

#define PCI_OP_READ(size, type, len) \
int noinline pci_bus_read_config_##size \
	(struct pci_bus *bus, unsigned int devfn, int pos, type *value)	\
{									\
	int res;							\
	unsigned long flags;						\
	u32 data = 0;							\
	if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER;	\
	pci_lock_config(flags);						\
	res = bus->ops->read(bus, devfn, pos, len, &data);		\

	/* Check we actually read something which is not all 1s.*/
	if (data == ~0)

	*value = (type)data;						\
	pci_unlock_config(flags);					\
	return res;							\

Also, I'd prefer a function to *not* return void but return either
an error or success. In the success case, the @value argument can be
consumed by the caller and otherwise not.

In any case, that change is a step in the wrong direction and I don't
like it, sorry.


dri-devel mailing list

  reply index

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-01 11:24 Saheed O. Bolarinwa
2020-08-01 11:24 ` [RFC PATCH 09/17] drm/i915/vga: " Saheed O. Bolarinwa
2020-08-01 12:56 ` [RFC PATCH 00/17] " Borislav Petkov
2020-08-02 14:53   ` Tom Rix
2020-08-02 17:28   ` Saheed Bolarinwa
2020-08-02 18:46     ` Borislav Petkov [this message]
2020-08-02 19:14       ` Bjorn Helgaas
2020-08-02 20:18         ` Borislav Petkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200802184648.GA23190@nazgul.tnic \
    --to=bp@alien8.de \
    --cc=bjorn@helgaas.com \
    --cc=davem@davemloft.net \
    --cc=dmaengine@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=helgaas@kernel.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=kuba@kernel.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-atm-general@lists.sourceforge.net \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-fpga@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=refactormyself@gmail.com \
    --cc=richard@nod.at \
    --cc=skhan@linuxfoundation.org \
    --cc=trix@redhat.com \
    --cc=vigneshr@ti.com \
    --cc=wg@grandegger.com \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

dri-devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/dri-devel/0 dri-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dri-devel dri-devel/ https://lore.kernel.org/dri-devel \
	public-inbox-index dri-devel

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git