lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 12 Mar 2021 15:26:39 -0800
From:   "Kuppuswamy, Sathyanarayanan" 
        <sathyanarayanan.kuppuswamy@...ux.intel.com>
To:     Bjorn Helgaas <helgaas@...nel.org>
Cc:     bhelgaas@...gle.com, linux-pci@...r.kernel.org,
        linux-kernel@...r.kernel.org, ashok.raj@...el.com,
        dan.j.williams@...el.com, keith.busch@...el.com,
        knsathya@...nel.org, Lukas Wunner <lukas@...ner.de>
Subject: Re: [PATCH v1 1/1] PCI: pciehp: Skip DLLSC handling if DPC is
 triggered



On 3/12/21 3:14 PM, Bjorn Helgaas wrote:
> On Fri, Mar 12, 2021 at 02:11:03PM -0800, Kuppuswamy, Sathyanarayanan wrote:
>> On 3/12/21 1:33 PM, Bjorn Helgaas wrote:
>>> On Mon, Mar 08, 2021 at 10:34:10PM -0800, sathyanarayanan.kuppuswamy@...ux.intel.com wrote:
>>>> From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@...ux.intel.com>
> 
>>>> +bool is_dpc_reset_active(struct pci_dev *dev)
>>>> +{
>>>> +	struct pci_host_bridge *host = pci_find_host_bridge(dev->bus);
>>>> +	u16 status;
>>>> +
>>>> +	if (!dev->dpc_cap)
>>>> +		return false;
>>>> +
>>>> +	/*
>>>> +	 * If DPC is owned by firmware and EDR is not supported, there is
>>>> +	 * no race between hotplug and DPC recovery handler. So return
>>>> +	 * false.
>>>> +	 */
>>>> +	if (!host->native_dpc && !IS_ENABLED(CONFIG_PCIE_EDR))
>>>> +		return false;
>>>> +
>>>> +	if (atomic_read_acquire(&dev->dpc_reset_active))
>>>> +		return true;
>>>> +
>>>> +	pci_read_config_word(dev, dev->dpc_cap + PCI_EXP_DPC_STATUS, &status);
>>>> +
>>>> +	return !!(status & PCI_EXP_DPC_STATUS_TRIGGER);
>>>
>>> I know it's somewhat common in drivers/pci/, but I'm not really a
>>> big fan of "!!".
>> I can change it to use ternary operator.
>> (status & PCI_EXP_DPC_STATUS_TRIGGER) ? true : false;
> 
> Ternary isn't terrible, but what's wrong with:
> 
>    if (status & PCI_EXP_DPC_STATUS_TRIGGER)
>      return true;
>    return false;
I am fine with above format.
> 
> which matches the style of the rest of the function.
> 
> Looking at this again, we return "true" if either dpc_reset_active or
> PCI_EXP_DPC_STATUS_TRIGGER.  I haven't worked this all out, but that
> pattern feels racy.  I guess the thought is that if
> PCI_EXP_DPC_STATUS_TRIGGER is set, dpc_reset_link() will be invoked
> soon and we don't want to interfere?
Yes, the reason for checking dpc_reset_active before
PCI_EXP_DPC_STATUS_TRIGGER is because, we want suppress DLLSC events
till link comes back or it times out.

137         atomic_inc_return_acquire(&pdev->dpc_reset_active);
138
139         pci_write_config_word(pdev, cap + PCI_EXP_DPC_STATUS,
140                               PCI_EXP_DPC_STATUS_TRIGGER);
141
142         if (!pcie_wait_for_link(pdev, true)) {
143                 pci_info(pdev, "Data Link Layer Link Active not set in 1000 msec\n");
144                 status = PCI_ERS_RESULT_DISCONNECT;
145         }
146
147         atomic_dec_return_release(&pdev->dpc_reset_active);

> 

-- 
Sathyanarayanan Kuppuswamy
Linux Kernel Developer

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ