From: Bjorn Helgaas <helgaas@kernel.org>
To: Thippeswamy Havalige <thippeswamy.havalige@amd.com>
Cc: bhelgaas@google.com, lpieralisi@kernel.org, kw@linux.com,
manivannan.sadhasivam@linaro.org, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org,
linux-pci@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, michal.simek@amd.com,
bharat.kumar.gogada@amd.com, jingoohan1@gmail.com
Subject: Re: [PATCH v13 3/3] PCI: amd-mdb: Add AMD MDB Root Port driver
Date: Wed, 19 Feb 2025 12:19:52 -0600 [thread overview]
Message-ID: <20250219181952.GA225098@bhelgaas> (raw)
In-Reply-To: <20250219102124.725344-4-thippeswamy.havalige@amd.com>
On Wed, Feb 19, 2025 at 03:51:24PM +0530, Thippeswamy Havalige wrote:
> Add support for AMD MDB (Multimedia DMA Bridge) IP core as Root Port.
> +#define AMD_MDB_TLP_IR_STATUS_MISC 0x4C0
> +#define AMD_MDB_TLP_IR_MASK_MISC 0x4C4
> +#define AMD_MDB_TLP_IR_ENABLE_MISC 0x4C8
> +#define AMD_MDB_TLP_IR_DISABLE_MISC 0x4CC
> +
> +#define AMD_MDB_TLP_PCIE_INTX_MASK GENMASK(23, 16)
> +
> +#define AMD_MDB_PCIE_INTR_INTX_ASSERT(x) BIT((x) * 2)
> +#define AMD_MDB_PCIE_INTX_BIT(x) (1U << (2 * (x) + AMD_MDB_PCIE_INTR_INTX))
I don't think you need both AMD_MDB_PCIE_INTR_INTX_ASSERT() and
AMD_MDB_PCIE_INTX_BIT().
AMD_MDB_PCIE_INTX_BIT() is essentially the same as
FIELD_PREP(AMD_MDB_TLP_PCIE_INTX_MASK, AMD_MDB_PCIE_INTR_INTX_ASSERT).
I would just do this:
#define AMD_MDB_PCIE_INTR_INTX(x) BIT((x) * 2)
and in amd_mdb_intx_irq_mask() and amd_mdb_intx_irq_unmask(), do this:
val = FIELD_PREP(AMD_MDB_TLP_PCIE_INTX_MASK,
AMD_MDB_PCIE_INTR_INTX(data->hwirq));
Then all the users do FIELD_PREP() or FIELD_GET() at the point of use.
It's a little confusing for dw_pcie_rp_intx_flow() to do the
FIELD_GET() there, but amd_mdb_intx_irq_mask() and
amd_mdb_intx_irq_unmask() have the equivalent of FIELD_PREP() hidden
inside AMD_MDB_PCIE_INTX_BIT().
> +static void amd_mdb_intx_irq_mask(struct irq_data *data)
> +{
> + struct amd_mdb_pcie *pcie = irq_data_get_irq_chip_data(data);
> + struct dw_pcie *pci = &pcie->pci;
> + struct dw_pcie_rp *port = &pci->pp;
> + unsigned long flags;
> + u32 val;
> +
> + raw_spin_lock_irqsave(&port->lock, flags);
> + val = AMD_MDB_PCIE_INTX_BIT(data->hwirq);
> + pcie_write(pcie, val, AMD_MDB_TLP_IR_DISABLE_MISC);
I guess AMD_MDB_TLP_IR_DISABLE_MISC and AMD_MDB_TLP_IR_ENABLE_MISC are
set up so writing zero bits does nothing, and writing a one bit only
masks or unmasks that single interrupt? It's somewhat unusual, so a
comment to that effect might be useful.
> + raw_spin_unlock_irqrestore(&port->lock, flags);
> +}
> +
> +static void amd_mdb_intx_irq_unmask(struct irq_data *data)
> +{
> + struct amd_mdb_pcie *pcie = irq_data_get_irq_chip_data(data);
> + struct dw_pcie *pci = &pcie->pci;
> + struct dw_pcie_rp *port = &pci->pp;
> + unsigned long flags;
> + u32 val;
> +
> + raw_spin_lock_irqsave(&port->lock, flags);
> + val = AMD_MDB_PCIE_INTX_BIT(data->hwirq);
> + pcie_write(pcie, val, AMD_MDB_TLP_IR_ENABLE_MISC);
> + raw_spin_unlock_irqrestore(&port->lock, flags);
> +}
> +static irqreturn_t dw_pcie_rp_intx_flow(int irq, void *args)
> +{
> + struct amd_mdb_pcie *pcie = args;
> + unsigned long val;
> + int i;
> +
> + val = FIELD_GET(AMD_MDB_TLP_PCIE_INTX_MASK,
> + val = pcie_read(pcie, AMD_MDB_TLP_IR_STATUS_MISC));
The "val = pcie_read()" looks like a useless assignment to val. I
would do something like this:
val = pcie_read(pcie, AMD_MDB_TLP_IR_STATUS_MISC);
intx_status = FIELD_GET(AMD_MDB_TLP_PCIE_INTX_MASK, val);
for (i = 0; i < PCI_NUM_INTX; i++) {
if (intx_status & AMD_MDB_PCIE_INTR_INTX(i))
generic_handle_domain_irq(pcie->intx_domain, i);
}
> + for (i = 0; i < PCI_NUM_INTX; i++) {
> + if (val & AMD_MDB_PCIE_INTR_INTX_ASSERT(i))
> + generic_handle_domain_irq(pcie->intx_domain, i);
> + }
> +
> + return IRQ_HANDLED;
> +}
prev parent reply other threads:[~2025-02-19 18:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-19 10:21 [PATCH v13 0/3] Add support for AMD MDB IP as Root Port Thippeswamy Havalige
2025-02-19 10:21 ` [PATCH v13 1/3] dt-bindings: PCI: dwc: Add AMD Versal2 mdb slcr support Thippeswamy Havalige
2025-02-19 10:21 ` [PATCH v13 2/3] dt-bindings: PCI: amd-mdb: Add AMD Versal2 MDB PCIe Root Port Bridge Thippeswamy Havalige
2025-02-19 10:21 ` [PATCH v13 3/3] PCI: amd-mdb: Add AMD MDB Root Port driver Thippeswamy Havalige
2025-02-19 18:19 ` Bjorn Helgaas [this message]
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=20250219181952.GA225098@bhelgaas \
--to=helgaas@kernel.org \
--cc=bharat.kumar.gogada@amd.com \
--cc=bhelgaas@google.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jingoohan1@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=michal.simek@amd.com \
--cc=robh@kernel.org \
--cc=thippeswamy.havalige@amd.com \
/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