All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saif Abrar <saif.abrar@linux.ibm.com>
To: Aditya Gupta <adityag@linux.ibm.com>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, clg@kaod.org,
	npiggin@gmail.com, fbarrat@linux.ibm.com, mst@redhat.com,
	marcel.apfelbaum@gmail.com, cohuck@redhat.com,
	pbonzini@redhat.com, thuth@redhat.com, lvivier@redhat.com,
	danielhb413@gmail.com, Harsh Prateek Bora <harshpb@linux.ibm.com>,
	jishnuvw@linux.ibm.com
Subject: Re: [PATCH v4 7/9] pnv/phb4: Set link speed and width in the DLP training control register
Date: Wed, 17 Jun 2026 12:41:36 +0530	[thread overview]
Message-ID: <b0df3fff-b66e-4b21-be87-fa0621734151@linux.ibm.com> (raw)
In-Reply-To: <af9MP4rWy-CBRI42@li-3c92a0cc-27cf-11b2-a85c-b804d9ca68fa.ibm.com>


On 09-05-2026 20:32, Aditya Gupta wrote:
> On 26/03/05 12:09AM, Saif Abrar wrote:
>> Get the current link-status from PCIE macro.
>> Extract link-speed and link-width from the link-status
>> and set in the DLP training control (PCIE_DLP_TCR) register.
>>
>> Signed-off-by: Saif Abrar <saif.abrar@linux.vnet.ibm.com>
>> Reviewed-by: Cédric Le Goater <clg@kaod.org>
>> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
>> ---
>> v4: Variables declaration moved to the top of the method pnv_phb4_reg_read().
>> v3: Updates for coding guidelines.
>>
>>   hw/pci-host/pnv_phb4.c | 22 ++++++++++++++++++++--
>>   1 file changed, 20 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c
>> index c35f632e64..a6fa578e85 100644
>> --- a/hw/pci-host/pnv_phb4.c
>> +++ b/hw/pci-host/pnv_phb4.c
>> @@ -900,6 +900,7 @@ static uint64_t pnv_phb4_reg_read(void *opaque, hwaddr off, unsigned size)
>>       PCIDevice *pdev = pci_find_device(pci->bus, 0, 0);
>>       uint32_t exp_base = get_exp_offset(pdev);
>>       uint64_t val;
>> +    uint32_t v, lnkstatus;
>>   
>>       if ((off & 0xfffc) == PHB_CONFIG_DATA) {
>>           return pnv_phb4_config_read(phb, off & 0x3, size);
>> @@ -961,10 +962,27 @@ static uint64_t pnv_phb4_reg_read(void *opaque, hwaddr off, unsigned size)
>>           val |= PHB_PCIE_SCR_PLW_X16; /* RO bit */
>>           break;
>>   
>> -    /* Link training always appears trained */
>>       case PHB_PCIE_DLP_TRAIN_CTL:
>> -        /* TODO: Do something sensible with speed ? */
>> +        /* Get the current link-status from PCIE */
>> +        lnkstatus = bswap32(pnv_phb4_rc_config_read(phb,
>> +                                exp_base + PCI_EXP_LNKSTA, 4));
> nit: s/bswap32/be32_to_cpu/ ?


Updated.


>> +
>> +        /* Extract link-speed from the link-status */
>> +        v = lnkstatus & PCI_EXP_LNKSTA_CLS;
>> +
>> +        /* Link training always appears trained */
>>           val |= PHB_PCIE_DLP_INBAND_PRESENCE | PHB_PCIE_DLP_TL_LINKACT;
>> +
>> +        /* Set the current link-speed at the LINK_SPEED position */
>> +        val = SETFIELD(PHB_PCIE_DLP_LINK_SPEED, val, v);
>> +
>> +        /*
>> +         * Extract link-width from the link-status,
>> +         * after shifting the required bitfields.
>> +         */
>> +        v = (lnkstatus & PCI_EXP_LNKSTA_NLW) >> PCI_EXP_LNKSTA_NLW_SHIFT;
>> +        /* Set the current link-width at the LINK_WIDTH position */
>> +        val = SETFIELD(PHB_PCIE_DLP_LINK_WIDTH, val, v);
> v is little-endian, while val is supposed to be big-endian, is it correct ?
> if so, should v be converted to big-endian before SETFIELDs ?


In these cases 'v' is a 6 bit number, hence there is no LE/BE consideration.


>
>>           return val;
>>   
>>       /*
> - Aditya G


Thanks,

Saif




  reply	other threads:[~2026-06-17  7:12 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-30 10:21 [PATCH v2 0/9] pnv/phb4: Update PHB4 to the latest PHB5 spec Saif Abrar
2025-12-30 10:21 ` [PATCH v2 1/9] qtest/phb4: Add testbench for PHB4 Saif Abrar
2025-12-30 10:21 ` [PATCH v2 2/9] pnv/phb4: Add reset logic to PHB4 Saif Abrar
2025-12-30 12:04   ` Michael S. Tsirkin
2025-12-30 10:21 ` [PATCH v2 3/9] pnv/phb4: Implement sticky reset logic in PHB4 Saif Abrar
2025-12-30 10:21 ` [PATCH v2 4/9] pnv/phb4: Implement read-only and write-only bits of registers Saif Abrar
2026-02-04  5:04   ` Michael S. Tsirkin
2026-02-04  5:11     ` Michael S. Tsirkin
2026-02-04  6:42       ` Michael S. Tsirkin
2026-02-09  5:35         ` Saif Abrar
2025-12-30 10:21 ` [PATCH v2 5/9] pnv/phb4: Implement write-clear and return 1's on unimplemented reg read Saif Abrar
2025-12-30 10:21 ` [PATCH v2 6/9] pnv/phb4: Set link-active status in HPSTAT and LMR registers Saif Abrar
2025-12-30 10:21 ` [PATCH v2 7/9] pnv/phb4: Set link speed and width in the DLP training control register Saif Abrar
2025-12-30 10:21 ` [PATCH v2 8/9] pnv/phb4: Implement IODA PCT table Saif Abrar
2025-12-30 10:21 ` [PATCH v2 9/9] pnv/phb4: Mask off LSI Source-ID based on number of interrupts Saif Abrar
2026-02-10 13:40 ` [PATCH v3 0/9] : pnv/phb4: Update PHB4 to the latest PHB5 spec Saif Abrar
2026-02-10 13:40   ` [PATCH v3 1/9] qtest/phb4: Add testbench for PHB4 Saif Abrar
2026-02-10 13:40   ` [PATCH v3 2/9] pnv/phb4: Add reset logic to PHB4 Saif Abrar
2026-02-10 13:40   ` [PATCH v3 3/9] pnv/phb4: Implement sticky reset logic in PHB4 Saif Abrar
2026-02-10 13:40   ` [PATCH v3 4/9] pnv/phb4: Implement read-only and write-only bits of registers Saif Abrar
2026-02-10 13:40   ` [PATCH v3 5/9] pnv/phb4: Implement write-clear and return 1's on unimplemented reg read Saif Abrar
2026-02-10 13:40   ` [PATCH v3 6/9] pnv/phb4: Set link-active status in HPSTAT and LMR registers Saif Abrar
2026-02-10 13:40   ` [PATCH v3 7/9] pnv/phb4: Set link speed and width in the DLP training control register Saif Abrar
2026-02-10 13:40   ` [PATCH v3 8/9] pnv/phb4: Implement IODA PCT table Saif Abrar
2026-02-10 13:40   ` [PATCH v3 9/9] pnv/phb4: Mask off LSI Source-ID based on number of interrupts Saif Abrar
2026-02-10 13:43   ` [PATCH v3 0/9] : pnv/phb4: Update PHB4 to the latest PHB5 spec Michael S. Tsirkin
2026-02-11  5:30     ` Saif Abrar
2026-02-20 16:22   ` Michael S. Tsirkin
     [not found]     ` <d65ab628-99e3-47af-839c-e059207b692e@linux.vnet.ibm.com>
2026-02-22 14:38       ` Michael S. Tsirkin
2026-03-05  6:09   ` [PATCH v4 0/9] " Saif Abrar
2026-03-05  6:09     ` [PATCH v4 1/9] qtest/phb4: Add testbench for PHB4 Saif Abrar
2026-05-01 13:59       ` Harsh Prateek Bora
2026-06-17  5:54         ` Saif Abrar
2026-05-09 14:33       ` Aditya Gupta
2026-05-09 14:45         ` Aditya Gupta
2026-06-17  5:58         ` Saif Abrar
2026-03-05  6:09     ` [PATCH v4 2/9] pnv/phb4: Add reset logic to PHB4 Saif Abrar
2026-05-01 14:37       ` Harsh Prateek Bora
2026-06-17  6:12         ` Saif Abrar
2026-05-05 14:16       ` Harsh Prateek Bora
2026-06-17  6:13         ` Saif Abrar
2026-05-09 14:42       ` Aditya Gupta
2026-06-17  6:19         ` Saif Abrar
2026-03-05  6:09     ` [PATCH v4 3/9] pnv/phb4: Implement sticky reset logic in PHB4 Saif Abrar
2026-05-05 14:29       ` Harsh Prateek Bora
2026-05-05 15:08         ` Harsh Prateek Bora
2026-06-17  6:22           ` Saif Abrar
2026-06-17  6:20         ` Saif Abrar
2026-05-09 14:48       ` Aditya Gupta
2026-06-17  6:22         ` Saif Abrar
2026-03-05  6:09     ` [PATCH v4 4/9] pnv/phb4: Implement read-only and write-only bits of registers Saif Abrar
2026-05-05 14:55       ` Harsh Prateek Bora
2026-06-17  6:23         ` Saif Abrar
2026-05-09 14:54       ` Aditya Gupta
2026-06-17  6:25         ` Saif Abrar
2026-03-05  6:09     ` [PATCH v4 5/9] pnv/phb4: Implement write-clear and return 1's on unimplemented reg read Saif Abrar
2026-05-09 14:56       ` Aditya Gupta
2026-06-17  6:28         ` Saif Abrar
2026-03-05  6:09     ` [PATCH v4 6/9] pnv/phb4: Set link-active status in HPSTAT and LMR registers Saif Abrar
2026-05-05 17:46       ` Harsh Prateek Bora
2026-06-17  6:29         ` Saif Abrar
2026-05-09 15:00       ` Aditya Gupta
2026-06-17  6:32         ` Saif Abrar
2026-03-05  6:09     ` [PATCH v4 7/9] pnv/phb4: Set link speed and width in the DLP training control register Saif Abrar
2026-05-09 15:02       ` Aditya Gupta
2026-06-17  7:11         ` Saif Abrar [this message]
2026-03-05  6:09     ` [PATCH v4 8/9] pnv/phb4: Implement IODA PCT table Saif Abrar
2026-05-09 15:03       ` Aditya Gupta
2026-06-17  7:12         ` Saif Abrar
2026-05-11  7:24       ` Jishnu Warrier
2026-06-17  7:13         ` Saif Abrar
2026-03-05  6:09     ` [PATCH v4 9/9] pnv/phb4: Mask off LSI Source-ID based on number of interrupts Saif Abrar
2026-05-09 15:04       ` Aditya Gupta
2026-06-17  7:15         ` Saif Abrar
2026-05-11  8:46       ` Jishnu Warrier
2026-06-17  7:16         ` Saif Abrar
2026-05-08 16:00     ` [PATCH v4 0/9] pnv/phb4: Update PHB4 to the latest PHB5 spec Aditya Gupta
2026-06-17  7:14       ` Saif Abrar
2026-05-19  5:52     ` Saif Abrar

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=b0df3fff-b66e-4b21-be87-fa0621734151@linux.ibm.com \
    --to=saif.abrar@linux.ibm.com \
    --cc=adityag@linux.ibm.com \
    --cc=clg@kaod.org \
    --cc=cohuck@redhat.com \
    --cc=danielhb413@gmail.com \
    --cc=fbarrat@linux.ibm.com \
    --cc=harshpb@linux.ibm.com \
    --cc=jishnuvw@linux.ibm.com \
    --cc=lvivier@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=npiggin@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=thuth@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.