Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (xgene-hwmon) Simplify PCC shared memory region handling

The PCC driver now handles mapping and unmapping of shared memory
areas as part of pcc_mbox_{request,free}_channel(). Without these before,
this xgene hwmon driver did handling of those mappings like several
other PCC mailbox client drivers.

There were redundant operations, leading to unnecessary code. Maintaining
the consistency across these driver was harder due to scattered handling
of shmem.

Just use the mapped shmem and remove all redundant operations from this
driver.

Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Link: https://lore.kernel.org/r/20250411112053.1148624-1-sudeep.holla@arm.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Sudeep Holla and committed by
Guenter Roeck
80fcd1e7 56591083

+4 -35
+4 -35
drivers/hwmon/xgene-hwmon.c
··· 103 103 struct device *hwmon_dev; 104 104 bool temp_critical_alarm; 105 105 106 - phys_addr_t comm_base_addr; 107 - void *pcc_comm_addr; 108 106 unsigned int usecs_lat; 109 107 }; 110 108 ··· 123 125 124 126 static int xgene_hwmon_pcc_rd(struct xgene_hwmon_dev *ctx, u32 *msg) 125 127 { 126 - struct acpi_pcct_shared_memory *generic_comm_base = ctx->pcc_comm_addr; 128 + struct acpi_pcct_shared_memory __iomem *generic_comm_base = 129 + ctx->pcc_chan->shmem; 127 130 u32 *ptr = (void *)(generic_comm_base + 1); 128 131 int rc, i; 129 132 u16 val; ··· 522 523 static void xgene_hwmon_pcc_rx_cb(struct mbox_client *cl, void *msg) 523 524 { 524 525 struct xgene_hwmon_dev *ctx = to_xgene_hwmon_dev(cl); 525 - struct acpi_pcct_shared_memory *generic_comm_base = ctx->pcc_comm_addr; 526 + struct acpi_pcct_shared_memory __iomem *generic_comm_base = 527 + ctx->pcc_chan->shmem; 526 528 struct slimpro_resp_msg amsg; 527 529 528 530 /* ··· 649 649 } else { 650 650 struct pcc_mbox_chan *pcc_chan; 651 651 const struct acpi_device_id *acpi_id; 652 - int version; 653 652 654 653 acpi_id = acpi_match_device(pdev->dev.driver->acpi_match_table, 655 654 &pdev->dev); ··· 656 657 rc = -EINVAL; 657 658 goto out_mbox_free; 658 659 } 659 - 660 - version = (int)acpi_id->driver_data; 661 660 662 661 if (device_property_read_u32(&pdev->dev, "pcc-channel", 663 662 &ctx->mbox_idx)) { ··· 679 682 if (!ctx->mbox_chan->mbox->txdone_irq) { 680 683 dev_err(&pdev->dev, "PCC IRQ not supported\n"); 681 684 rc = -ENODEV; 682 - goto out; 683 - } 684 - 685 - /* 686 - * This is the shared communication region 687 - * for the OS and Platform to communicate over. 688 - */ 689 - ctx->comm_base_addr = pcc_chan->shmem_base_addr; 690 - if (ctx->comm_base_addr) { 691 - if (version == XGENE_HWMON_V2) 692 - ctx->pcc_comm_addr = (void __force *)devm_ioremap(&pdev->dev, 693 - ctx->comm_base_addr, 694 - pcc_chan->shmem_size); 695 - else 696 - ctx->pcc_comm_addr = devm_memremap(&pdev->dev, 697 - ctx->comm_base_addr, 698 - pcc_chan->shmem_size, 699 - MEMREMAP_WB); 700 - } else { 701 - dev_err(&pdev->dev, "Failed to get PCC comm region\n"); 702 - rc = -ENODEV; 703 - goto out; 704 - } 705 - 706 - if (IS_ERR_OR_NULL(ctx->pcc_comm_addr)) { 707 - dev_err(&pdev->dev, 708 - "Failed to ioremap PCC comm region\n"); 709 - rc = -ENOMEM; 710 685 goto out; 711 686 } 712 687