Skip to content

Commit b4b7777

Browse files
quic-jhugoliuw
authored andcommitted
PCI: hv: Reuse existing IRTE allocation in compose_msi_msg()
Currently if compose_msi_msg() is called multiple times, it will free any previous IRTE allocation, and generate a new allocation. While nothing prevents this from occurring, it is extraneous when Linux could just reuse the existing allocation and avoid a bunch of overhead. However, when future IRTE allocations operate on blocks of MSIs instead of a single line, freeing the allocation will impact all of the lines. This could cause an issue where an allocation of N MSIs occurs, then some of the lines are retargeted, and finally the allocation is freed/reallocated. The freeing of the allocation removes all of the configuration for the entire block, which requires all the lines to be retargeted, which might not happen since some lines might already be unmasked/active. Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com> Reviewed-by: Dexuan Cui <decui@microsoft.com> Tested-by: Dexuan Cui <decui@microsoft.com> Tested-by: Michael Kelley <mikelley@microsoft.com> Link: https://lore.kernel.org/r/1652282582-21595-1-git-send-email-quic_jhugo@quicinc.com Signed-off-by: Wei Liu <wei.liu@kernel.org>
1 parent ac6811a commit b4b7777

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

drivers/pci/controller/pci-hyperv.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,6 +1707,15 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
17071707
u32 size;
17081708
int ret;
17091709

1710+
/* Reuse the previous allocation */
1711+
if (data->chip_data) {
1712+
int_desc = data->chip_data;
1713+
msg->address_hi = int_desc->address >> 32;
1714+
msg->address_lo = int_desc->address & 0xffffffff;
1715+
msg->data = int_desc->data;
1716+
return;
1717+
}
1718+
17101719
pdev = msi_desc_to_pci_dev(irq_data_get_msi_desc(data));
17111720
dest = irq_data_get_effective_affinity_mask(data);
17121721
pbus = pdev->bus;
@@ -1716,13 +1725,6 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
17161725
if (!hpdev)
17171726
goto return_null_message;
17181727

1719-
/* Free any previous message that might have already been composed. */
1720-
if (data->chip_data) {
1721-
int_desc = data->chip_data;
1722-
data->chip_data = NULL;
1723-
hv_int_desc_free(hpdev, int_desc);
1724-
}
1725-
17261728
int_desc = kzalloc(sizeof(*int_desc), GFP_ATOMIC);
17271729
if (!int_desc)
17281730
goto drop_reference;

0 commit comments

Comments
 (0)