| bff6efc5 | 12-May-2023 |
Anup Sharma <anupnewsmail@gmail.com> |
ntb: hw: amd: Fix debugfs_create_dir error checking
The debugfs_create_dir function returns ERR_PTR in case of error, and the only correct way to check if an error occurred is 'IS_ERR' inline functi
ntb: hw: amd: Fix debugfs_create_dir error checking
The debugfs_create_dir function returns ERR_PTR in case of error, and the only correct way to check if an error occurred is 'IS_ERR' inline function. This patch will replace the null-comparison with IS_ERR.
Signed-off-by: Anup Sharma <anupnewsmail@gmail.com> Suggested-by: Ivan Orlov <ivan.orlov0322@gmail.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
show more ...
|
| da6b4dc4 | 24-Mar-2023 |
Cai Huoqing <cai.huoqing@linux.dev> |
ntb_hw_amd: Remove redundant pci_clear_master
Remove pci_clear_master to simplify the code, the bus-mastering is also cleared in do_pci_disable_device, like this: ./drivers/pci/pci.c:2197 static voi
ntb_hw_amd: Remove redundant pci_clear_master
Remove pci_clear_master to simplify the code, the bus-mastering is also cleared in do_pci_disable_device, like this: ./drivers/pci/pci.c:2197 static void do_pci_disable_device(struct pci_dev *dev) { u16 pci_command;
pci_read_config_word(dev, PCI_COMMAND, &pci_command); if (pci_command & PCI_COMMAND_MASTER) { pci_command &= ~PCI_COMMAND_MASTER; pci_write_config_word(dev, PCI_COMMAND, pci_command); }
pcibios_disable_device(dev); }. And dev->is_busmaster is set to 0 in pci_disable_device.
Signed-off-by: Cai Huoqing <cai.huoqing@linux.dev> Signed-off-by: Jon Mason <jdmason@kudzu.us>
show more ...
|
| b350f0a3 | 05-Feb-2020 |
Arindam Nath <arindam.nath@amd.com> |
NTB: add pci shutdown handler for AMD NTB
The PCI shutdown handler is invoked in response to system reboot or shutdown. A data transfer might still be in flight when this happens. So the very first
NTB: add pci shutdown handler for AMD NTB
The PCI shutdown handler is invoked in response to system reboot or shutdown. A data transfer might still be in flight when this happens. So the very first action we take here is to send a link down notification, so that any pending data transfer is terminated. Rest of the actions are same as that of PCI remove handler.
Signed-off-by: Arindam Nath <arindam.nath@amd.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
show more ...
|
| ac10d4f6 | 05-Feb-2020 |
Arindam Nath <arindam.nath@amd.com> |
NTB: send DB event when driver is loaded or un-loaded
When the driver on the local side is loaded, it sets SIDE_READY bit in SIDE_INFO register. Likewise, when it is un-loaded, it clears the bit.
A
NTB: send DB event when driver is loaded or un-loaded
When the driver on the local side is loaded, it sets SIDE_READY bit in SIDE_INFO register. Likewise, when it is un-loaded, it clears the bit.
Also just after being loaded, the driver polls for peer SIDE_READY bit to be set. Since that bit is set when the peer side driver has loaded, the polling on local side breaks as soon as this condition is met.
But the situation is different when the driver is un-loaded. Since the polling has already been stopped as mentioned before, if the peer side driver gets un-loaded, the driver on the local side is not notified implicitly.
So, we improvise using existing doorbell mechanism. We reserve the highest order bit of the DB register to send a notification to peer when the driver on local side is un-loaded. This also means that now we are one short of 16 DB events and that is taken care of in the valid DB mask.
Signed-off-by: Arindam Nath <arindam.nath@amd.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
show more ...
|
| 41dfc3f7 | 05-Feb-2020 |
Arindam Nath <arindam.nath@amd.com> |
NTB: remove redundant setting of DB valid mask
db_valid_mask is set at two places, once within amd_init_ntb(), and again within amd_init_dev(). Since amd_init_ntb() is actually called from amd_init_
NTB: remove redundant setting of DB valid mask
db_valid_mask is set at two places, once within amd_init_ntb(), and again within amd_init_dev(). Since amd_init_ntb() is actually called from amd_init_dev(), setting db_valid_mask from former does not really make sense. So remove it.
Signed-off-by: Arindam Nath <arindam.nath@amd.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
show more ...
|
| 5f0856be | 05-Feb-2020 |
Arindam Nath <arindam.nath@amd.com> |
NTB: return link up status correctly for PRI and SEC
Since NTB connects two physically separate systems, there can be scenarios where one system goes down while the other one remains active. In case
NTB: return link up status correctly for PRI and SEC
Since NTB connects two physically separate systems, there can be scenarios where one system goes down while the other one remains active. In case of NTB primary, if the NTB secondary goes down, a Link-Down event is received. For the NTB secondary, if the NTB primary goes down, the PCIe hotplug mechanism ensures that the driver on the secondary side is also unloaded.
But there are other scenarios to consider as well, when suppose the physical link remains active, but the driver on primary or secondary side is loaded or un-loaded.
When the driver is loaded, on either side, it sets SIDE_READY bit(bit-1) of SIDE_INFO register. Similarly, when the driver is un-loaded, it resets the same bit.
We consider the NTB link to be up and operational only when the driver on both sides of link are loaded and ready. But we also need to take account of Link Up and Down events which signify the physical link status. So amd_link_is_up() is modified to take care of the above scenarios.
Signed-off-by: Arindam Nath <arindam.nath@amd.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
show more ...
|
| ae5f4bdc | 05-Feb-2020 |
Arindam Nath <arindam.nath@amd.com> |
NTB: add helper functions to set and clear sideinfo
We define two new helper functions to set and clear sideinfo registers respectively. These functions take an additional boolean parameter which si
NTB: add helper functions to set and clear sideinfo
We define two new helper functions to set and clear sideinfo registers respectively. These functions take an additional boolean parameter which signifies whether we want to set/clear the sideinfo register of the peer(true) or local host(false).
Signed-off-by: Arindam Nath <arindam.nath@amd.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
show more ...
|
| 92abf4cb | 05-Feb-2020 |
Arindam Nath <arindam.nath@amd.com> |
NTB: move ntb_ctrl handling to init and deinit
It does not really make sense to enable or disable the bits of NTB_CTRL register only during enable and disable link callbacks. They should be done ind
NTB: move ntb_ctrl handling to init and deinit
It does not really make sense to enable or disable the bits of NTB_CTRL register only during enable and disable link callbacks. They should be done independent of these callbacks. The correct placement for that is during the amd_init_side_info() and amd_deinit_side_info() functions, which are invoked during probe and remove respectively.
Signed-off-by: Arindam Nath <arindam.nath@amd.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
show more ...
|
| 673dd0c2 | 05-Feb-2020 |
Arindam Nath <arindam.nath@amd.com> |
NTB: handle link up, D0 and D3 events correctly
Just like for Link-Down event, Link-Up and D3 events are also mutually exclusive to Link-Down and D0 events respectively. So we clear the bitmasks in
NTB: handle link up, D0 and D3 events correctly
Just like for Link-Down event, Link-Up and D3 events are also mutually exclusive to Link-Down and D0 events respectively. So we clear the bitmasks in peer_sta depending on event type.
Signed-off-by: Arindam Nath <arindam.nath@amd.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
show more ...
|
| 60ceafd1 | 05-Feb-2020 |
Arindam Nath <arindam.nath@amd.com> |
NTB: handle link down event correctly
Link-Up and Link-Down are mutually exclusive events. So when we receive a Link-Down event, we should also clear the bitmask for Link-Up event in peer_sta.
Sign
NTB: handle link down event correctly
Link-Up and Link-Down are mutually exclusive events. So when we receive a Link-Down event, we should also clear the bitmask for Link-Up event in peer_sta.
Signed-off-by: Arindam Nath <arindam.nath@amd.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
show more ...
|
| fdd8281f | 05-Feb-2020 |
Arindam Nath <arindam.nath@amd.com> |
NTB: remove handling of peer_sta from amd_link_is_up
amd_link_is_up() is a callback to inquire whether the NTB link is up or not. So it should not indulge itself into clearing the bitmasks of peer_s
NTB: remove handling of peer_sta from amd_link_is_up
amd_link_is_up() is a callback to inquire whether the NTB link is up or not. So it should not indulge itself into clearing the bitmasks of peer_sta.
Signed-off-by: Arindam Nath <arindam.nath@amd.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
show more ...
|
| 2465b87c | 05-Feb-2020 |
Arindam Nath <arindam.nath@amd.com> |
NTB: set peer_sta within event handler itself
amd_ack_smu() should only set the corresponding bits into SMUACK register. Setting the bitmask of peer_sta should be done within the event handler. They
NTB: set peer_sta within event handler itself
amd_ack_smu() should only set the corresponding bits into SMUACK register. Setting the bitmask of peer_sta should be done within the event handler. They are two different things, and so should be handled differently and at different places.
Signed-off-by: Arindam Nath <arindam.nath@amd.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
show more ...
|
| 5cafa485 | 05-Feb-2020 |
Arindam Nath <arindam.nath@amd.com> |
NTB: return the side info status from amd_poll_link
Bit 1 of SIDE_INFO register is an indication that the driver on the other side of link is ready. We set this bit during driver initialization sequ
NTB: return the side info status from amd_poll_link
Bit 1 of SIDE_INFO register is an indication that the driver on the other side of link is ready. We set this bit during driver initialization sequence. So rather than having separate macros to return the status, we can simply return the status of this bit from amd_poll_link(). So a return of 1 or 0 from this function will indicate to the caller whether the driver on the other side of link is ready or not, respectively.
Signed-off-by: Arindam Nath <arindam.nath@amd.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
show more ...
|
| 5c6404d5 | 05-Feb-2020 |
Arindam Nath <arindam.nath@amd.com> |
NTB: define a new function to get link status
Since getting the status of link is a logically separate operation, we simply create a new function which will store the link status to be used later.
NTB: define a new function to get link status
Since getting the status of link is a logically separate operation, we simply create a new function which will store the link status to be used later.
Signed-off-by: Arindam Nath <arindam.nath@amd.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
show more ...
|
| 8a7cedef | 05-Feb-2020 |
Arindam Nath <arindam.nath@amd.com> |
NTB: Enable link up and down event notification
Link-Up and Link-Down events can occur irrespective of whether a data transfer is in progress or not. So we need to enable the interrupt delivery for
NTB: Enable link up and down event notification
Link-Up and Link-Down events can occur irrespective of whether a data transfer is in progress or not. So we need to enable the interrupt delivery for these events early during driver load.
Signed-off-by: Arindam Nath <arindam.nath@amd.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
show more ...
|
| 52ba4478 | 05-Feb-2020 |
Arindam Nath <arindam.nath@amd.com> |
NTB: clear interrupt status register
The interrupt status register should be cleared by driver once the particular event is handled. The patch fixes this.
Signed-off-by: Arindam Nath <arindam.nath@
NTB: clear interrupt status register
The interrupt status register should be cleared by driver once the particular event is handled. The patch fixes this.
Signed-off-by: Arindam Nath <arindam.nath@amd.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
show more ...
|
| cb004c28 | 05-Feb-2020 |
Arindam Nath <arindam.nath@amd.com> |
NTB: Fix access to link status and control register
The design of AMD NTB implementation is such that NTB primary acts as an endpoint device and NTB secondary is an endpoint device behind a combinat
NTB: Fix access to link status and control register
The design of AMD NTB implementation is such that NTB primary acts as an endpoint device and NTB secondary is an endpoint device behind a combination of Switch Upstream and Switch Downstream. Considering that, the link status and control register needs to be accessed differently based on the NTB topology.
So in the case of NTB secondary, we first get the pointer to the Switch Downstream device for the NTB device. Then we get the pointer to the Switch Upstream device. Once we have that, we read the Link Status and Control register to get the correct status of link at the secondary.
In the case of NTB primary, simply reading the Link Status and Control register of the NTB device itself will suffice.
Suggested-by: Jiasen Lin <linjiasen@hygon.cn> Signed-off-by: Arindam Nath <arindam.nath@amd.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
show more ...
|