Skip to content

Commit

Permalink
Merge tag 'platform-drivers-x86-v6.8-2' of git://git.kernel.org/pub/s…
Browse files Browse the repository at this point in the history
…cm/linux/kernel/git/pdx86/platform-drivers-x86

Pull x86 platform driver fixes from Hans de Goede:

 - WMI bus driver fixes

 - Second attempt (previously reverted) at P2SB PCI rescan deadlock fix

 - AMD PMF driver improvements

 - MAINTAINERS updates

 - Misc other small fixes and hw-id additions

* tag 'platform-drivers-x86-v6.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86:
  platform/x86: touchscreen_dmi: Add info for the TECLAST X16 Plus tablet
  platform/x86/intel/ifs: Call release_firmware() when handling errors.
  platform/x86/amd/pmf: Fix memory leak in amd_pmf_get_pb_data()
  platform/x86/amd/pmf: Get ambient light information from AMD SFH driver
  platform/x86/amd/pmf: Get Human presence information from AMD SFH driver
  platform/mellanox: mlxbf-pmc: Fix offset calculation for crspace events
  platform/mellanox: mlxbf-tmfifo: Drop Tx network packet when Tx TmFIFO is full
  MAINTAINERS: remove defunct acpi4asus project info from asus notebooks section
  MAINTAINERS: add Luke Jones as maintainer for asus notebooks
  MAINTAINERS: Remove Perry Yuan as DELL WMI HARDWARE PRIVACY SUPPORT maintainer
  platform/x86: silicom-platform: Add missing "Description:" for power_cycle sysfs attr
  platform/x86: intel-wmi-sbl-fw-update: Fix function name in error message
  platform/x86: p2sb: Use pci_resource_n() in p2sb_read_bar0()
  platform/x86: p2sb: Allow p2sb_bar() calls during PCI device probe
  platform/x86: intel-uncore-freq: Fix types in sysfs callbacks
  platform/x86: wmi: Fix wmi_dev_probe()
  platform/x86: wmi: Fix notify callback locking
  platform/x86: wmi: Decouple legacy WMI notify handlers from wmi_block_list
  platform/x86: wmi: Return immediately if an suitable WMI event is found
  platform/x86: wmi: Fix error handling in legacy WMI notify handler functions
  • Loading branch information
torvalds committed Jan 27, 2024
2 parents 9553404 + 1abdf28 commit 8a696a2
Show file tree
Hide file tree
Showing 14 changed files with 460 additions and 177 deletions.
1 change: 1 addition & 0 deletions Documentation/ABI/testing/sysfs-platform-silicom
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ What: /sys/devices/platform/silicom-platform/power_cycle
Date: November 2023
KernelVersion: 6.7
Contact: Henry Shi <henrys@silicom-usa.com>
Description:
This file allow user to power cycle the platform.
Default value is 0; when set to 1, it powers down
the platform, waits 5 seconds, then powers on the
Expand Down
5 changes: 2 additions & 3 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -3168,10 +3168,10 @@ F: drivers/hwmon/asus-ec-sensors.c

ASUS NOTEBOOKS AND EEEPC ACPI/WMI EXTRAS DRIVERS
M: Corentin Chary <corentin.chary@gmail.com>
L: acpi4asus-user@lists.sourceforge.net
M: Luke D. Jones <luke@ljones.dev>
L: platform-driver-x86@vger.kernel.org
S: Maintained
W: http://acpi4asus.sf.net
W: https://asus-linux.org/
F: drivers/platform/x86/asus*.c
F: drivers/platform/x86/eeepc*.c

Expand Down Expand Up @@ -5958,7 +5958,6 @@ S: Maintained
F: drivers/platform/x86/dell/dell-wmi-descriptor.c

DELL WMI HARDWARE PRIVACY SUPPORT
M: Perry Yuan <Perry.Yuan@dell.com>
L: Dell.Client.Kernel@dell.com
L: platform-driver-x86@vger.kernel.org
S: Maintained
Expand Down
4 changes: 2 additions & 2 deletions drivers/platform/mellanox/mlxbf-pmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ static int mlxbf_pmc_program_crspace_counter(int blk_num, uint32_t cnt_num,
int ret;

addr = pmc->block[blk_num].mmio_base +
(rounddown(cnt_num, 2) * MLXBF_PMC_CRSPACE_PERFSEL_SZ);
((cnt_num / 2) * MLXBF_PMC_CRSPACE_PERFSEL_SZ);
ret = mlxbf_pmc_readl(addr, &word);
if (ret)
return ret;
Expand Down Expand Up @@ -1413,7 +1413,7 @@ static int mlxbf_pmc_read_crspace_event(int blk_num, uint32_t cnt_num,
int ret;

addr = pmc->block[blk_num].mmio_base +
(rounddown(cnt_num, 2) * MLXBF_PMC_CRSPACE_PERFSEL_SZ);
((cnt_num / 2) * MLXBF_PMC_CRSPACE_PERFSEL_SZ);
ret = mlxbf_pmc_readl(addr, &word);
if (ret)
return ret;
Expand Down
67 changes: 67 additions & 0 deletions drivers/platform/mellanox/mlxbf-tmfifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
/* Message with data needs at least two words (for header & data). */
#define MLXBF_TMFIFO_DATA_MIN_WORDS 2

/* Tx timeout in milliseconds. */
#define TMFIFO_TX_TIMEOUT 2000

/* ACPI UID for BlueField-3. */
#define TMFIFO_BF3_UID 1

Expand All @@ -62,12 +65,14 @@ struct mlxbf_tmfifo;
* @drop_desc: dummy desc for packet dropping
* @cur_len: processed length of the current descriptor
* @rem_len: remaining length of the pending packet
* @rem_padding: remaining bytes to send as paddings
* @pkt_len: total length of the pending packet
* @next_avail: next avail descriptor id
* @num: vring size (number of descriptors)
* @align: vring alignment size
* @index: vring index
* @vdev_id: vring virtio id (VIRTIO_ID_xxx)
* @tx_timeout: expire time of last tx packet
* @fifo: pointer to the tmfifo structure
*/
struct mlxbf_tmfifo_vring {
Expand All @@ -79,12 +84,14 @@ struct mlxbf_tmfifo_vring {
struct vring_desc drop_desc;
int cur_len;
int rem_len;
int rem_padding;
u32 pkt_len;
u16 next_avail;
int num;
int align;
int index;
int vdev_id;
unsigned long tx_timeout;
struct mlxbf_tmfifo *fifo;
};

Expand Down Expand Up @@ -819,6 +826,50 @@ static bool mlxbf_tmfifo_rxtx_one_desc(struct mlxbf_tmfifo_vring *vring,
return true;
}

static void mlxbf_tmfifo_check_tx_timeout(struct mlxbf_tmfifo_vring *vring)
{
unsigned long flags;

/* Only handle Tx timeout for network vdev. */
if (vring->vdev_id != VIRTIO_ID_NET)
return;

/* Initialize the timeout or return if not expired. */
if (!vring->tx_timeout) {
/* Initialize the timeout. */
vring->tx_timeout = jiffies +
msecs_to_jiffies(TMFIFO_TX_TIMEOUT);
return;
} else if (time_before(jiffies, vring->tx_timeout)) {
/* Return if not timeout yet. */
return;
}

/*
* Drop the packet after timeout. The outstanding packet is
* released and the remaining bytes will be sent with padding byte 0x00
* as a recovery. On the peer(host) side, the padding bytes 0x00 will be
* either dropped directly, or appended into existing outstanding packet
* thus dropped as corrupted network packet.
*/
vring->rem_padding = round_up(vring->rem_len, sizeof(u64));
mlxbf_tmfifo_release_pkt(vring);
vring->cur_len = 0;
vring->rem_len = 0;
vring->fifo->vring[0] = NULL;

/*
* Make sure the load/store are in order before
* returning back to virtio.
*/
virtio_mb(false);

/* Notify upper layer. */
spin_lock_irqsave(&vring->fifo->spin_lock[0], flags);
vring_interrupt(0, vring->vq);
spin_unlock_irqrestore(&vring->fifo->spin_lock[0], flags);
}

/* Rx & Tx processing of a queue. */
static void mlxbf_tmfifo_rxtx(struct mlxbf_tmfifo_vring *vring, bool is_rx)
{
Expand All @@ -841,6 +892,7 @@ static void mlxbf_tmfifo_rxtx(struct mlxbf_tmfifo_vring *vring, bool is_rx)
return;

do {
retry:
/* Get available FIFO space. */
if (avail == 0) {
if (is_rx)
Expand All @@ -851,6 +903,17 @@ static void mlxbf_tmfifo_rxtx(struct mlxbf_tmfifo_vring *vring, bool is_rx)
break;
}

/* Insert paddings for discarded Tx packet. */
if (!is_rx) {
vring->tx_timeout = 0;
while (vring->rem_padding >= sizeof(u64)) {
writeq(0, vring->fifo->tx.data);
vring->rem_padding -= sizeof(u64);
if (--avail == 0)
goto retry;
}
}

/* Console output always comes from the Tx buffer. */
if (!is_rx && devid == VIRTIO_ID_CONSOLE) {
mlxbf_tmfifo_console_tx(fifo, avail);
Expand All @@ -860,6 +923,10 @@ static void mlxbf_tmfifo_rxtx(struct mlxbf_tmfifo_vring *vring, bool is_rx)
/* Handle one descriptor. */
more = mlxbf_tmfifo_rxtx_one_desc(vring, is_rx, &avail);
} while (more);

/* Check Tx timeout. */
if (avail <= 0 && !is_rx)
mlxbf_tmfifo_check_tx_timeout(vring);
}

/* Handle Rx or Tx queues. */
Expand Down
1 change: 1 addition & 0 deletions drivers/platform/x86/amd/pmf/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ config AMD_PMF
depends on AMD_NB
select ACPI_PLATFORM_PROFILE
depends on TEE && AMDTEE
depends on AMD_SFH_HID
help
This driver provides support for the AMD Platform Management Framework.
The goal is to enhance end user experience by making AMD PCs smarter,
Expand Down
36 changes: 36 additions & 0 deletions drivers/platform/x86/amd/pmf/spc.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

#include <acpi/button.h>
#include <linux/amd-pmf-io.h>
#include <linux/power_supply.h>
#include <linux/units.h>
#include "pmf.h"
Expand Down Expand Up @@ -44,6 +45,8 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *
dev_dbg(dev->dev, "Max C0 Residency: %u\n", in->ev_info.max_c0residency);
dev_dbg(dev->dev, "GFX Busy: %u\n", in->ev_info.gfx_busy);
dev_dbg(dev->dev, "LID State: %s\n", in->ev_info.lid_state ? "close" : "open");
dev_dbg(dev->dev, "User Presence: %s\n", in->ev_info.user_present ? "Present" : "Away");
dev_dbg(dev->dev, "Ambient Light: %d\n", in->ev_info.ambient_light);
dev_dbg(dev->dev, "==== TA inputs END ====\n");
}
#else
Expand Down Expand Up @@ -147,6 +150,38 @@ static int amd_pmf_get_slider_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_
return 0;
}

static int amd_pmf_get_sensor_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
{
struct amd_sfh_info sfh_info;
int ret;

/* Get ALS data */
ret = amd_get_sfh_info(&sfh_info, MT_ALS);
if (!ret)
in->ev_info.ambient_light = sfh_info.ambient_light;
else
return ret;

/* get HPD data */
ret = amd_get_sfh_info(&sfh_info, MT_HPD);
if (ret)
return ret;

switch (sfh_info.user_present) {
case SFH_NOT_DETECTED:
in->ev_info.user_present = 0xff; /* assume no sensors connected */
break;
case SFH_USER_PRESENT:
in->ev_info.user_present = 1;
break;
case SFH_USER_AWAY:
in->ev_info.user_present = 0;
break;
}

return 0;
}

void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
{
/* TA side lid open is 1 and close is 0, hence the ! here */
Expand All @@ -155,4 +190,5 @@ void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_tab
amd_pmf_get_smu_info(dev, in);
amd_pmf_get_battery_info(dev, in);
amd_pmf_get_slider_info(dev, in);
amd_pmf_get_sensor_info(dev, in);
}
4 changes: 3 additions & 1 deletion drivers/platform/x86/amd/pmf/tee-if.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,10 @@ static ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf,
if (!new_policy_buf)
return -ENOMEM;

if (copy_from_user(new_policy_buf, buf, length))
if (copy_from_user(new_policy_buf, buf, length)) {
kfree(new_policy_buf);
return -EFAULT;
}

kfree(dev->policy_buf);
dev->policy_buf = new_policy_buf;
Expand Down
3 changes: 2 additions & 1 deletion drivers/platform/x86/intel/ifs/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ int ifs_load_firmware(struct device *dev)
if (fw->size != expected_size) {
dev_err(dev, "File size mismatch (expected %u, actual %zu). Corrupted IFS image.\n",
expected_size, fw->size);
return -EINVAL;
ret = -EINVAL;
goto release;
}

ret = image_sanity_check(dev, (struct microcode_header_intel *)fw->data);
Expand Down
Loading

0 comments on commit 8a696a2

Please sign in to comment.