linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: "Bjorn Helgaas" <bhelgaas@google.com>,
	linux-pci@vger.kernel.org, pali@kernel.org,
	"Marek Behún" <kabel@kernel.org>,
	"Russell King" <rmk+kernel@armlinux.org.uk>
Subject: [PATCH 01/14] PCI: pci-bridge-emul: Fix emulation of W1C bits
Date: Tue, 12 Oct 2021 18:41:32 +0200	[thread overview]
Message-ID: <20211012164145.14126-2-kabel@kernel.org> (raw)
In-Reply-To: <20211012164145.14126-1-kabel@kernel.org>

The pci_bridge_emul_conf_write() function correctly clears W1C bits in
cfgspace cache, but it does not inform the underlying implementation
about the clear request: the .write_op() method is given the value with
these bits cleared.

This is wrong if the .write_op() needs to know which bits were requested
to be cleared.

Fix the value to be passed into the .write_op() method to have requested
W1C bits set, so that it can clear them.

Both pci-bridge-emul users (mvebu and aardvark) are compatible with this
change.

Fixes: 23a5fba4d941 ("PCI: Introduce PCI bridge emulated config space common logic")
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <kabel@kernel.org>
Cc: stable@vger.kernel.org
Cc: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/pci/pci-bridge-emul.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/pci/pci-bridge-emul.c b/drivers/pci/pci-bridge-emul.c
index fdaf86a888b7..db97cddfc85e 100644
--- a/drivers/pci/pci-bridge-emul.c
+++ b/drivers/pci/pci-bridge-emul.c
@@ -431,8 +431,21 @@ int pci_bridge_emul_conf_write(struct pci_bridge_emul *bridge, int where,
 	/* Clear the W1C bits */
 	new &= ~((value << shift) & (behavior[reg / 4].w1c & mask));
 
+	/* Save the new value with the cleared W1C bits into the cfgspace */
 	cfgspace[reg / 4] = cpu_to_le32(new);
 
+	/*
+	 * Clear the W1C bits not specified by the write mask, so that the
+	 * write_op() does not clear them.
+	 */
+	new &= ~(behavior[reg / 4].w1c & ~mask);
+
+	/*
+	 * Set the W1C bits specified by the write mask, so that write_op()
+	 * knows about that they are to be cleared.
+	 */
+	new |= (value << shift) & (behavior[reg / 4].w1c & mask);
+
 	if (write_op)
 		write_op(bridge, reg, old, new, mask);
 
-- 
2.32.0


  reply	other threads:[~2021-10-12 16:41 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-12 16:41 [PATCH 00/14] PCI: aardvark controller fixes BATCH 2 Marek Behún
2021-10-12 16:41 ` Marek Behún [this message]
2021-10-12 16:41 ` [PATCH 02/14] PCI: aardvark: Fix return value of MSI domain .alloc() method Marek Behún
2021-10-27 11:26   ` Lorenzo Pieralisi
2021-10-27 11:31     ` Pali Rohár
2021-10-12 16:41 ` [PATCH 03/14] PCI: aardvark: Read all 16-bits from PCIE_MSI_PAYLOAD_REG Marek Behún
2021-10-12 16:41 ` [PATCH 04/14] PCI: aardvark: Fix support for MSI interrupts Marek Behún
2021-10-12 16:41 ` [PATCH 05/14] PCI: aardvark: Fix reading MSI interrupt number Marek Behún
2021-10-12 16:41 ` [PATCH 06/14] PCI: aardvark: Clear all MSIs at setup Marek Behún
2021-10-12 16:41 ` [PATCH 07/14] PCI: aardvark: Refactor unmasking summary MSI interrupt Marek Behún
2021-10-12 16:41 ` [PATCH 08/14] PCI: aardvark: Fix masking MSI interrupts Marek Behún
2021-10-12 16:41 ` [PATCH 09/14] PCI: aardvark: Fix setting MSI address Marek Behún
2021-10-12 16:41 ` [PATCH 10/14] PCI: aardvark: Enable MSI-X support Marek Behún
2021-10-27 14:12   ` Lorenzo Pieralisi
2021-10-27 14:23     ` Pali Rohár
2021-10-28 11:08       ` Lorenzo Pieralisi
2021-10-28 11:13         ` Pali Rohár
2021-10-28 11:30           ` Lorenzo Pieralisi
2021-10-28 11:37             ` Pali Rohár
2021-10-28 15:24               ` Marc Zyngier
2021-10-28 15:29                 ` Pali Rohár
2021-10-28 15:51                 ` Marek Behún
2021-10-28 16:22                   ` Marc Zyngier
2021-10-28 16:25                   ` Marek Behún
2021-10-28 17:00                     ` Marc Zyngier
2021-10-28 17:47                       ` Lorenzo Pieralisi
2021-10-28 18:24                         ` Marek Behún
2021-10-12 16:41 ` [PATCH 11/14] PCI: aardvark: Fix support for bus mastering and PCI_COMMAND on emulated bridge Marek Behún
2021-10-12 16:41 ` [PATCH 12/14] PCI: aardvark: Set PCI Bridge Class Code to PCI Bridge Marek Behún
2021-10-28 18:30   ` Lorenzo Pieralisi
2021-10-28 18:45     ` Pali Rohár
2021-10-28 20:43       ` Bjorn Helgaas
2021-10-12 16:41 ` [PATCH 13/14] PCI: aardvark: Fix support for PCI_BRIDGE_CTL_BUS_RESET on emulated bridge Marek Behún
2021-10-12 16:41 ` [PATCH 14/14] PCI: aardvark: Fix support for PCI_ROM_ADDRESS1 " Marek Behún
2021-10-19 18:36 ` [PATCH 00/14] PCI: aardvark controller fixes BATCH 2 Pali Rohár
2021-10-28 18:33 ` Lorenzo Pieralisi

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=20211012164145.14126-2-kabel@kernel.org \
    --to=kabel@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=pali@kernel.org \
    --cc=rmk+kernel@armlinux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).